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"
18#include "app/gfx/core/bitmap.h"
21#include "rom/rom.h"
22#include "zelda3/game_data.h"
23
24namespace yaze {
25namespace editor {
26
27// Super Donkey prototype graphics offsets (from leaked dev materials)
28const std::string kSuperDonkeyTiles[] = {
29 "97C05", "98219", "9871E", "98C00", "99084", "995AF", "99DE0", "9A27E",
30 "9A741", "9AC31", "9B07E", "9B55C", "9B963", "9BB99", "9C009", "9C4B4",
31 "9C92B", "9CDD6", "9D2C2", "9E037", "9E527", "9EA56", "9EF65", "9FCD1",
32 "A0193", "A059E", "A0B17", "A0FB6", "A14A5", "A1988", "A1E66", "A232B",
33 "A27F0", "A2B6E", "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9",
34 "A5089", "A5385", "A5742", "A5BCC", "A6017", "A6361", "A66F8"};
35
36const std::string kSuperDonkeySprites[] = {
37 "A8E5D", "A9435", "A9934", "A9D83", "AA2F1", "AA6D4", "AABE4", "AB127",
38 "AB65A", "ABBDD", "AC38D", "AC797", "ACCC8", "AD0AE", "AD245", "AD554",
39 "ADAAC", "ADECC", "AE453", "AE9D2", "AEF40", "AF3C9", "AF92E", "AFE9D",
40 "B03D2", "B09AC", "B0F0C", "B1430", "B1859", "B1E01", "B229A", "B2854",
41 "B2D27", "B31D7", "B3B58", "B40B5", "B45A5", "B4D64", "B5031", "B555F",
42 "B5F30", "B6858", "B70DD", "B7526", "B79EC", "B7C83", "B80F7", "B85CC",
43 "B8A3F", "B8F97", "B94F2", "B9A20", "B9E9A", "BA3A2", "BA8F6", "BACDC",
44 "BB1F9", "BB781", "BBCCA", "BC26D", "BC7D4", "BCBB0", "BD082", "BD5FC",
45 "BE115", "BE5C2", "BEB63", "BF0CB", "BF607", "BFA55", "BFD71", "C017D",
46 "C0567", "C0981", "C0BA7", "C116D", "C166A", "C1FE0", "C24CE", "C2B19"};
47
62class GraphicsEditor : public Editor {
63 public:
64 explicit GraphicsEditor(Rom* rom = nullptr) : rom_(rom) {
66 }
67
68 void Initialize() override;
69 absl::Status Load() override;
70 absl::Status Save() override;
71 absl::Status Update() override;
72 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
73 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
74 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
75 absl::Status Undo() override;
76 absl::Status Redo() override;
77 absl::Status Find() override { return absl::UnimplementedError("Find"); }
78
79 // Set the ROM pointer
80 void set_rom(Rom* rom) { rom_ = rom; }
81
82 // Set the game data pointer
87 }
88 if (gfx_group_panel_) {
89 gfx_group_panel_->SetGameData(game_data);
90 }
92 paletteset_panel_->SetGameData(game_data);
93 }
94 }
95
96 // Editor shortcuts
97 void NextSheet();
98 void PrevSheet();
99 void SelectSheet(uint16_t sheet_id);
100 void HighlightTile(uint16_t sheet_id, uint16_t tile_index,
101 const std::string& label = "",
102 double duration_secs = 3.0);
103
104 // Get the ROM pointer
105 Rom* rom() const { return rom_; }
106
107 private:
108 // Editor-level shortcut handling
110
111 // --- Panel-Based Architecture ---
113 std::unique_ptr<SheetBrowserPanel> sheet_browser_panel_;
114 std::unique_ptr<PixelEditorPanel> pixel_editor_panel_;
115 std::unique_ptr<PaletteControlsPanel> palette_controls_panel_;
116 std::unique_ptr<LinkSpritePanel> link_sprite_panel_;
117 std::unique_ptr<GfxGroupEditor> gfx_group_panel_;
118 std::unique_ptr<PalettesetEditorPanel> paletteset_panel_;
119
120 // --- Prototype Viewer (Super Donkey / Dev Format Imports) ---
121 void DrawPrototypeViewer();
122 absl::Status DrawCgxImport();
123 absl::Status DrawScrImport();
124 absl::Status DrawFileImport();
125 absl::Status DrawObjImport();
126 absl::Status DrawTilemapImport();
127 absl::Status DrawPaletteControls();
128 absl::Status DrawClipboardImport();
129 absl::Status DrawExperimentalFeatures();
130 absl::Status DrawMemoryEditor();
131 absl::Status DecompressImportData(int size);
132 absl::Status DecompressSuperDonkey();
133
134 // Prototype viewer state
136 uint64_t current_offset_ = 0;
141 uint64_t bin_size_ = 0;
142 uint64_t clipboard_offset_ = 0;
143 uint64_t clipboard_size_ = 0;
144 bool refresh_graphics_ = false;
146 bool gfx_loaded_ = false;
147 bool is_open_ = false;
148 bool super_donkey_ = false;
149 bool col_file_ = false;
150 bool cgx_loaded_ = false;
151 bool scr_loaded_ = false;
152 bool obj_loaded_ = false;
153 bool tilemap_loaded_ = false;
154
155 std::string file_path_;
156 std::string col_file_path_;
157 std::string col_file_name_;
158 std::string cgx_file_path_;
159 std::string cgx_file_name_;
160 std::string scr_file_path_;
161 std::string scr_file_name_;
162 std::string obj_file_path_;
165
168 std::vector<uint8_t> import_data_;
169 std::vector<uint8_t> decoded_cgx_;
170 std::vector<uint8_t> cgx_data_;
171 std::vector<uint8_t> extra_cgx_data_;
172 std::vector<SDL_Color> decoded_col_;
173 std::vector<uint8_t> scr_data_;
174 std::vector<uint8_t> decoded_scr_data_;
178 std::array<gfx::Bitmap, zelda3::kNumGfxSheets> gfx_sheets_;
185
186 // Status tracking
187 absl::Status status_;
188
189 // Core references
192};
193
194} // namespace editor
195} // namespace yaze
196
197#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:236
zelda3::GameData * game_data() const
Definition editor.h:297
EditorType type_
Definition editor.h:305
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< 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_
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)
std::unique_ptr< SheetBrowserPanel > sheet_browser_panel_
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[]
Represents a group of palettes.