yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
graphics_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_EDITOR_H
2#define YAZE_APP_EDITOR_GRAPHICS_EDITOR_H
3
4#include <array>
5#include <memory>
6#include <string>
7#include <vector>
8
9#include "absl/status/status.h"
10#include "app/editor/editor.h"
19#include "app/gfx/core/bitmap.h"
22#include "rom/rom.h"
23#include "zelda3/game_data.h"
24
25namespace yaze {
26namespace editor {
27
28// Super Donkey prototype graphics offsets (from leaked dev materials)
29const std::string kSuperDonkeyTiles[] = {
30 "97C05", "98219", "9871E", "98C00", "99084", "995AF", "99DE0", "9A27E",
31 "9A741", "9AC31", "9B07E", "9B55C", "9B963", "9BB99", "9C009", "9C4B4",
32 "9C92B", "9CDD6", "9D2C2", "9E037", "9E527", "9EA56", "9EF65", "9FCD1",
33 "A0193", "A059E", "A0B17", "A0FB6", "A14A5", "A1988", "A1E66", "A232B",
34 "A27F0", "A2B6E", "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9",
35 "A5089", "A5385", "A5742", "A5BCC", "A6017", "A6361", "A66F8"};
36
37const std::string kSuperDonkeySprites[] = {
38 "A8E5D", "A9435", "A9934", "A9D83", "AA2F1", "AA6D4", "AABE4", "AB127",
39 "AB65A", "ABBDD", "AC38D", "AC797", "ACCC8", "AD0AE", "AD245", "AD554",
40 "ADAAC", "ADECC", "AE453", "AE9D2", "AEF40", "AF3C9", "AF92E", "AFE9D",
41 "B03D2", "B09AC", "B0F0C", "B1430", "B1859", "B1E01", "B229A", "B2854",
42 "B2D27", "B31D7", "B3B58", "B40B5", "B45A5", "B4D64", "B5031", "B555F",
43 "B5F30", "B6858", "B70DD", "B7526", "B79EC", "B7C83", "B80F7", "B85CC",
44 "B8A3F", "B8F97", "B94F2", "B9A20", "B9E9A", "BA3A2", "BA8F6", "BACDC",
45 "BB1F9", "BB781", "BBCCA", "BC26D", "BC7D4", "BCBB0", "BD082", "BD5FC",
46 "BE115", "BE5C2", "BEB63", "BF0CB", "BF607", "BFA55", "BFD71", "C017D",
47 "C0567", "C0981", "C0BA7", "C116D", "C166A", "C1FE0", "C24CE", "C2B19"};
48
63class GraphicsEditor : public Editor {
64 public:
65 explicit GraphicsEditor(Rom* rom = nullptr) : rom_(rom) {
67 }
68
69 void SetDependencies(const EditorDependencies& deps) override {
71 if (gfx_group_panel_) {
72 gfx_group_panel_->SetWorkspaceState(deps.gfx_group_workspace);
73 }
74 }
75
76 void Initialize() override;
77 absl::Status Load() override;
78 absl::Status Save() override;
79 absl::Status Update() override;
80 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
81 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
82 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
83 absl::Status Undo() override;
84 absl::Status Redo() override;
85 absl::Status Find() override { return absl::UnimplementedError("Find"); }
86 void ContributeStatus(StatusBar* status_bar) override;
87
88 // Set the ROM pointer (propagates to panels that cache `Rom*`.)
89 void set_rom(Rom* rom) {
90 rom_ = rom;
92 pixel_editor_panel_->SetRom(rom);
93 }
96 }
98 link_sprite_panel_->SetRom(rom);
99 }
100 if (gfx_group_panel_) {
101 gfx_group_panel_->SetRom(rom);
102 }
103 if (paletteset_panel_) {
104 paletteset_panel_->SetRom(rom);
105 }
106 if (polyhedral_panel_) {
107 polyhedral_panel_->SetRom(rom);
108 }
109 }
110
111 // Set the game data pointer
116 }
117 if (gfx_group_panel_) {
118 gfx_group_panel_->SetGameData(game_data);
119 }
120 if (paletteset_panel_) {
121 paletteset_panel_->SetGameData(game_data);
122 }
123 }
124
125 // Editor shortcuts
126 void NextSheet();
127 void PrevSheet();
128 void SelectSheet(uint16_t sheet_id);
129 void HighlightTile(uint16_t sheet_id, uint16_t tile_index,
130 const std::string& label = "", double duration_secs = 3.0);
131
132 // Get the ROM pointer
133 Rom* rom() const { return rom_; }
134
135 private:
136 // Editor-level shortcut handling
138
139 // --- Panel-Based Architecture ---
141 std::unique_ptr<SheetBrowserPanel> sheet_browser_panel_;
142 std::unique_ptr<PixelEditorPanel> pixel_editor_panel_;
143 std::unique_ptr<PaletteControlsPanel> palette_controls_panel_;
144 std::unique_ptr<LinkSpritePanel> link_sprite_panel_;
145 std::unique_ptr<GfxGroupEditor> gfx_group_panel_;
146 std::unique_ptr<PalettesetEditorPanel> paletteset_panel_;
147 std::unique_ptr<PolyhedralEditorPanel> polyhedral_panel_;
148
149 // --- Prototype Viewer (Super Donkey / Dev Format Imports) ---
150 void DrawPrototypeViewer();
151 absl::Status DrawCgxImport();
152 absl::Status DrawScrImport();
153 absl::Status DrawFileImport();
154 absl::Status DrawObjImport();
155 absl::Status DrawTilemapImport();
156 absl::Status DrawPaletteControls();
157 absl::Status DrawClipboardImport();
158 absl::Status DrawExperimentalFeatures();
159 absl::Status DrawMemoryEditor();
160 absl::Status DecompressImportData(int size);
161 absl::Status DecompressSuperDonkey();
162
163 // Prototype viewer state
165 uint64_t current_offset_ = 0;
170 uint64_t bin_size_ = 0;
171 uint64_t clipboard_offset_ = 0;
172 uint64_t clipboard_size_ = 0;
173 bool refresh_graphics_ = false;
175 bool gfx_loaded_ = false;
176 bool is_open_ = false;
177 bool super_donkey_ = false;
178 bool col_file_ = false;
179 bool cgx_loaded_ = false;
180 bool scr_loaded_ = false;
181 bool obj_loaded_ = false;
182 bool tilemap_loaded_ = false;
183
184 std::string file_path_;
185 std::string col_file_path_;
186 std::string col_file_name_;
187 std::string cgx_file_path_;
188 std::string cgx_file_name_;
189 std::string scr_file_path_;
190 std::string scr_file_name_;
191 std::string obj_file_path_;
194
197 std::vector<uint8_t> import_data_;
198 std::vector<uint8_t> decoded_cgx_;
199 std::vector<uint8_t> cgx_data_;
200 std::vector<uint8_t> extra_cgx_data_;
201 std::vector<SDL_Color> decoded_col_;
202 std::vector<uint8_t> scr_data_;
203 std::vector<uint8_t> decoded_scr_data_;
207 std::array<gfx::Bitmap, zelda3::kNumGfxSheets> gfx_sheets_;
214
215 // Last prototype import error (shown inside the Prototype Research panel).
217
218 // Status tracking
219 absl::Status status_;
220
221 // Core references
224};
225
226} // namespace editor
227} // namespace yaze
228
229#endif // YAZE_APP_EDITOR_GRAPHICS_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:240
virtual void SetDependencies(const EditorDependencies &deps)
Definition editor.h:245
zelda3::GameData * game_data() const
Definition editor.h:307
EditorType type_
Definition editor.h:315
Shared state between GraphicsEditor panel components.
Allows the user to edit graphics sheets from the game or view prototype graphics.
std::vector< uint8_t > scr_data_
absl::Status Save() override
GraphicsEditor(Rom *rom=nullptr)
void HighlightTile(uint16_t sheet_id, uint16_t tile_index, const std::string &label="", double duration_secs=3.0)
gfx::PaletteGroup col_file_palette_group_
void SelectSheet(uint16_t sheet_id)
absl::Status Load() override
std::unique_ptr< GfxGroupEditor > gfx_group_panel_
std::unique_ptr< PaletteControlsPanel > palette_controls_panel_
std::vector< uint8_t > decoded_cgx_
absl::Status Copy() override
std::vector< uint8_t > cgx_data_
std::unique_ptr< PixelEditorPanel > pixel_editor_panel_
absl::Status Redo() override
std::unique_ptr< PolyhedralEditorPanel > polyhedral_panel_
std::unique_ptr< PalettesetEditorPanel > paletteset_panel_
absl::Status Cut() override
std::vector< uint8_t > import_data_
absl::Status Paste() override
std::vector< SDL_Color > decoded_col_
absl::Status Undo() override
absl::Status Update() override
absl::Status Find() override
std::vector< uint8_t > extra_cgx_data_
std::array< gfx::Bitmap, zelda3::kNumGfxSheets > gfx_sheets_
void SetDependencies(const EditorDependencies &deps) override
std::vector< uint8_t > decoded_scr_data_
void SetGameData(zelda3::GameData *game_data) override
std::unique_ptr< LinkSpritePanel > link_sprite_panel_
absl::Status DecompressImportData(int size)
void ContributeStatus(StatusBar *status_bar) override
std::unique_ptr< SheetBrowserPanel > sheet_browser_panel_
A session-aware status bar displayed at the bottom of the application.
Definition status_bar.h:54
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
const std::string kSuperDonkeySprites[]
const std::string kSuperDonkeyTiles[]
Unified dependency container for all editor types.
Definition editor.h:164
GfxGroupWorkspaceState * gfx_group_workspace
Definition editor.h:173
Represents a group of palettes.