message editor housekeeping
This commit is contained in:
@@ -110,7 +110,7 @@ class Tile16Editor : public gfx::GfxContext, public SharedRom {
|
||||
|
||||
absl::Status status_;
|
||||
|
||||
Rom *transfer_rom_;
|
||||
Rom *transfer_rom_ = nullptr;
|
||||
zelda3::Overworld transfer_overworld_{transfer_rom_};
|
||||
std::array<gfx::Bitmap, kNumGfxSheets> transfer_gfx_;
|
||||
absl::Status transfer_status_;
|
||||
|
||||
@@ -275,10 +275,6 @@ std::vector<std::string> ParseMessageData(
|
||||
std::vector<std::string> parsed_messages;
|
||||
|
||||
for (auto &message : message_data) {
|
||||
std::cout << "Message #" << message.ID << " at address "
|
||||
<< util::HexLong(message.Address) << std::endl;
|
||||
std::cout << " " << message.RawString << std::endl;
|
||||
|
||||
std::string parsed_message = "";
|
||||
for (const uint8_t &byte : message.Data) {
|
||||
if (CharEncoder.contains(byte)) {
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_replace.h"
|
||||
#include "app/rom.h"
|
||||
|
||||
@@ -127,7 +127,7 @@ void MessageEditor::DrawMessageList() {
|
||||
|
||||
TableHeadersRow();
|
||||
|
||||
for (const auto &message : list_of_texts_) {
|
||||
for (const auto& message : list_of_texts_) {
|
||||
TableNextColumn();
|
||||
if (Button(util::HexWord(message.ID).c_str())) {
|
||||
current_message_ = message;
|
||||
@@ -190,7 +190,7 @@ void MessageEditor::DrawCurrentMessage() {
|
||||
void MessageEditor::DrawTextCommands() {
|
||||
if (BeginChild("##TextCommands", ImVec2(0, 0), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
for (const auto &text_element : TextCommands) {
|
||||
for (const auto& text_element : TextCommands) {
|
||||
if (Button(text_element.GenericToken.c_str())) {
|
||||
// Insert the command into the message text box.
|
||||
message_text_box_.text.append(text_element.GenericToken);
|
||||
@@ -204,14 +204,16 @@ void MessageEditor::DrawTextCommands() {
|
||||
}
|
||||
|
||||
void MessageEditor::DrawDictionary() {
|
||||
if (ImGui::BeginChild("##DictionaryChild", ImVec2(0, 0), true,
|
||||
if (all_dictionaries_.empty()) {
|
||||
return;
|
||||
}
|
||||
if (ImGui::BeginChild("##DictionaryChild", ImVec2(200, 0), true,
|
||||
ImGuiWindowFlags_AlwaysVerticalScrollbar)) {
|
||||
if (BeginTable("##Dictionary", 2, kMessageTableFlags)) {
|
||||
TableHeadersRow();
|
||||
TableSetupColumn("ID");
|
||||
TableSetupColumn("Contents");
|
||||
|
||||
for (const auto &dictionary : all_dictionaries_) {
|
||||
TableHeadersRow();
|
||||
for (const auto& dictionary : all_dictionaries_) {
|
||||
TableNextColumn();
|
||||
Text("%s", util::HexWord(dictionary.ID).c_str());
|
||||
TableNextColumn();
|
||||
@@ -451,8 +453,8 @@ void MessageEditor::DrawCharacterToPreview(char c) {
|
||||
DrawCharacterToPreview(FindMatchingCharacter(c));
|
||||
}
|
||||
|
||||
void MessageEditor::DrawCharacterToPreview(const std::vector<uint8_t> &text) {
|
||||
for (const uint8_t &value : text) {
|
||||
void MessageEditor::DrawCharacterToPreview(const std::vector<uint8_t>& text) {
|
||||
for (const uint8_t& value : text) {
|
||||
if (skip_next) {
|
||||
skip_next = false;
|
||||
continue;
|
||||
@@ -570,7 +572,7 @@ absl::Status MessageEditor::Save() {
|
||||
int pos = kTextData;
|
||||
bool in_second_bank = false;
|
||||
|
||||
for (const auto &message : list_of_texts_) {
|
||||
for (const auto& message : list_of_texts_) {
|
||||
for (const auto value : message.Data) {
|
||||
RETURN_IF_ERROR(rom()->WriteByte(pos, value));
|
||||
|
||||
@@ -636,5 +638,16 @@ void MessageEditor::SelectAll() {
|
||||
}
|
||||
}
|
||||
|
||||
absl::Status MessageEditor::Redo() {
|
||||
// Implementation of redo functionality
|
||||
// This would require tracking a redo stack in the TextBox struct
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
absl::Status MessageEditor::Find() {
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
} // namespace editor
|
||||
} // namespace yaze
|
||||
|
||||
@@ -32,7 +32,9 @@ constexpr uint8_t kMessageBankChangeId = 0x80;
|
||||
|
||||
class MessageEditor : public Editor, public SharedRom {
|
||||
public:
|
||||
MessageEditor() { type_ = EditorType::kMessage; }
|
||||
explicit MessageEditor(Rom* rom = nullptr) : rom_(rom) {
|
||||
type_ = EditorType::kMessage;
|
||||
}
|
||||
|
||||
void Initialize() override;
|
||||
absl::Status Load() override;
|
||||
@@ -49,12 +51,8 @@ class MessageEditor : public Editor, public SharedRom {
|
||||
absl::Status Copy() override;
|
||||
absl::Status Paste() override;
|
||||
absl::Status Undo() override;
|
||||
absl::Status Redo() override {
|
||||
return absl::UnimplementedError("Redo not implemented");
|
||||
}
|
||||
absl::Status Find() override {
|
||||
return absl::UnimplementedError("Find not implemented");
|
||||
}
|
||||
absl::Status Redo() override;
|
||||
absl::Status Find() override;
|
||||
absl::Status Save() override;
|
||||
void Delete();
|
||||
void SelectAll();
|
||||
@@ -68,7 +66,11 @@ class MessageEditor : public Editor, public SharedRom {
|
||||
void DrawMessagePreview();
|
||||
std::string DisplayTextOverflowError(int pos, bool bank);
|
||||
|
||||
void set_rom(Rom* rom) { rom_ = rom; }
|
||||
Rom* rom() const { return rom_; }
|
||||
|
||||
private:
|
||||
Rom* rom_;
|
||||
bool skip_next = false;
|
||||
bool data_loaded_ = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user