yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
message_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_MESSAGE_EDITOR_H
2#define YAZE_APP_EDITOR_MESSAGE_EDITOR_H
3
4#include <array>
5#include <optional>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "app/editor/editor.h"
15#include "app/gfx/core/bitmap.h"
18#include "app/gui/core/style.h"
19#include "rom/rom.h"
20
21namespace yaze {
22namespace editor {
23
24constexpr int kGfxFont = 0x70000; // 2bpp format
25constexpr int kCharactersWidth = 0x74ADF;
26constexpr int kNumMessages = 396;
27constexpr int kFontGfxMessageSize = 128;
28constexpr int kFontGfxMessageDepth =
29 8; // Fixed: Must be 8 for indexed palette mode
30constexpr int kFontGfx16Size = 172 * 4096;
31
32constexpr uint8_t kBlockTerminator = 0x80;
33constexpr uint8_t kMessageBankChangeId = 0x80;
34
35class MessageEditor : public Editor {
36 public:
37 explicit MessageEditor(Rom* rom = nullptr) : rom_(rom) {
39 }
40
41 explicit MessageEditor(Rom* rom, const EditorDependencies& deps)
43 dependencies_ = deps;
44 }
45
46 void Initialize() override;
47 absl::Status Load() override;
48 absl::Status Update() override;
50
51 void DrawMessageList();
52 void DrawCurrentMessage();
53 void DrawFontAtlas();
54 void DrawTextCommands();
57 void DrawDictionary();
58 void DrawMessagePreview();
59 void UpdateCurrentMessageFromText(const std::string& text);
60
61 // Jump/navigation helper used by panels (e.g. Story Event Graph).
62 // Accepts vanilla IDs (0..N) and expanded IDs (expanded_base_id..).
63 bool OpenMessageById(int display_id);
64
65 absl::Status Save() override;
66 absl::Status SaveExpandedMessages();
67 absl::Status LoadExpandedMessagesFromRom();
69
70 absl::Status Cut() override;
71 absl::Status Copy() override;
72 absl::Status Paste() override;
73 absl::Status Undo() override;
74 absl::Status Redo() override;
75 absl::Status Find() override;
76 void Delete();
77 void SelectAll();
78
79 void set_rom(Rom* rom) { rom_ = rom; }
80 Rom* rom() const { return rom_; }
81
82 private:
83 bool case_sensitive_ = false;
84 bool match_whole_word_ = false;
85 std::string search_text_ = "";
86
87 std::array<uint8_t, 0x4000> raw_font_gfx_data_;
88 std::vector<std::string> parsed_messages_;
89 std::vector<MessageData> list_of_texts_;
90 std::vector<MessageData> expanded_messages_;
91
94
98
99 gui::Canvas font_gfx_canvas_{"##FontGfxCanvas", ImVec2(256, 256)};
101 ImVec2(172 * 2, 4096)};
109
110 // Undo/Redo - delegates to UndoManager (inherited from Editor)
111 std::optional<MessageSnapshot> pending_undo_before_;
112 void PushUndoSnapshot();
113 void FinalizePendingUndo();
114 void ApplySnapshot(const MessageSnapshot& snapshot);
115
116 // Panel visibility states
117 bool show_message_list_ = false;
119 bool show_font_atlas_ = false;
120 bool show_dictionary_ = false;
121
122 void ResolveFontPalette();
124 void LoadFontGraphics();
125 void RefreshFontAtlasBitmap(const std::vector<uint8_t>& font_data);
126 void ApplyFontPalette();
128 void ImportMessageBundleFromFile(const std::string& path);
130
134};
135
136} // namespace editor
137} // namespace yaze
138
139#endif // YAZE_APP_EDITOR_MESSAGE_EDITOR_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Interface for editor classes.
Definition editor.h:236
zelda3::GameData * game_data() const
Definition editor.h:297
EditorDependencies dependencies_
Definition editor.h:306
EditorType type_
Definition editor.h:305
std::vector< std::string > parsed_messages_
absl::Status Copy() override
std::vector< MessageData > expanded_messages_
absl::Status Find() override
absl::Status Update() override
absl::Status LoadExpandedMessagesFromRom()
void UpdateCurrentMessageFromText(const std::string &text)
absl::Status Paste() override
void ApplySnapshot(const MessageSnapshot &snapshot)
void RefreshFontAtlasBitmap(const std::vector< uint8_t > &font_data)
absl::Status Undo() override
absl::Status Load() override
std::array< uint8_t, 0x4000 > raw_font_gfx_data_
gfx::SnesPalette BuildFallbackFontPalette() const
MessageEditor(Rom *rom=nullptr)
absl::Status Cut() override
MessageEditor(Rom *rom, const EditorDependencies &deps)
std::optional< MessageSnapshot > pending_undo_before_
std::vector< MessageData > list_of_texts_
bool OpenMessageById(int display_id)
gfx::SnesPalette font_preview_colors_
absl::Status Redo() override
void ImportMessageBundleFromFile(const std::string &path)
absl::Status Save() override
void SetGameData(zelda3::GameData *game_data) override
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:67
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
constexpr int kCharactersWidth
constexpr int kFontGfx16Size
constexpr uint8_t kBlockTerminator
constexpr int kGfxFont
constexpr int kFontGfxMessageSize
constexpr int kFontGfxMessageDepth
constexpr uint8_t kMessageBankChangeId
constexpr int kNumMessages
Unified dependency container for all editor types.
Definition editor.h:163