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