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