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 <stack>
5
6#include "absl/status/status.h"
7#include "app/editor/editor.h"
9#include "app/gfx/bitmap.h"
11#include "app/gfx/snes_tile.h"
12#include "app/gui/canvas.h"
15#include "app/rom.h"
17#include "imgui/imgui.h"
18#include "imgui_memory_editor.h"
19
20namespace yaze {
21namespace editor {
22
23// "99973","A3D80",
24
25const std::string kSuperDonkeyTiles[] = {
26 "97C05", "98219", "9871E", "98C00", "99084", "995AF", "99DE0", "9A27E",
27 "9A741", "9AC31", "9B07E", "9B55C", "9B963", "9BB99", "9C009", "9C4B4",
28 "9C92B", "9CDD6", "9D2C2", "9E037", "9E527", "9EA56", "9EF65", "9FCD1",
29 "A0193", "A059E", "A0B17", "A0FB6", "A14A5", "A1988", "A1E66", "A232B",
30 "A27F0", "A2B6E", "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9",
31 "A5089", "A5385", "A5742", "A5BCC", "A6017", "A6361", "A66F8"};
32
33const std::string kSuperDonkeySprites[] = {
34 "A8E5D", "A9435", "A9934", "A9D83", "AA2F1", "AA6D4", "AABE4", "AB127",
35 "AB65A", "ABBDD", "AC38D", "AC797", "ACCC8", "AD0AE", "AD245", "AD554",
36 "ADAAC", "ADECC", "AE453", "AE9D2", "AEF40", "AF3C9", "AF92E", "AFE9D",
37 "B03D2", "B09AC", "B0F0C", "B1430", "B1859", "B1E01", "B229A", "B2854",
38 "B2D27", "B31D7", "B3B58", "B40B5", "B45A5", "B4D64", "B5031", "B555F",
39 "B5F30", "B6858", "B70DD", "B7526", "B79EC", "B7C83", "B80F7", "B85CC",
40 "B8A3F", "B8F97", "B94F2", "B9A20", "B9E9A", "BA3A2", "BA8F6", "BACDC",
41 "BB1F9", "BB781", "BBCCA", "BC26D", "BC7D4", "BCBB0", "BD082", "BD5FC",
42 "BE115", "BE5C2", "BEB63", "BF0CB", "BF607", "BFA55", "BFD71", "C017D",
43 "C0567", "C0981", "C0BA7", "C116D", "C166A", "C1FE0", "C24CE", "C2B19"};
44
59class GraphicsEditor : public Editor {
60 public:
61 explicit GraphicsEditor(Rom* rom = nullptr) : rom_(rom) {
63 }
64
65 void Initialize() override;
66 absl::Status Load() override;
67 absl::Status Save() override { return absl::UnimplementedError("Save"); }
68 absl::Status Update() override;
69 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
70 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
71 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
72 absl::Status Undo() override { return absl::UnimplementedError("Undo"); }
73 absl::Status Redo() override { return absl::UnimplementedError("Redo"); }
74 absl::Status Find() override { return absl::UnimplementedError("Find"); }
75
76 // Set the ROM pointer
77 void set_rom(Rom* rom) { rom_ = rom; }
78
79 // Get the ROM pointer
80 Rom* rom() const { return rom_; }
81
82 private:
83 enum class GfxEditMode {
84 kSelect,
85 kPencil,
86 kFill,
87 };
88
89 // Graphics Editor Tab
90 absl::Status UpdateGfxEdit();
91 absl::Status UpdateGfxSheetList();
92 absl::Status UpdateGfxTabView();
93 absl::Status UpdatePaletteColumn();
94 void DrawGfxEditToolset();
95
96 // Link Graphics Edit Tab
97 absl::Status UpdateLinkGfxView();
98
99 // Prototype Graphics Viewer
100 absl::Status UpdateScadView();
101
102 // Import Functions
103 absl::Status DrawCgxImport();
104 absl::Status DrawScrImport();
105 absl::Status DrawFileImport();
106 absl::Status DrawObjImport();
107 absl::Status DrawTilemapImport();
108
109 // Other Functions
110 void DrawToolset();
111 absl::Status DrawPaletteControls();
112 absl::Status DrawClipboardImport();
113 absl::Status DrawExperimentalFeatures();
114 absl::Status DrawMemoryEditor();
115
116 absl::Status DecompressImportData(int size);
117 absl::Status DecompressSuperDonkey();
118
119 // Member Variables
120 // Card visibility - ALL FALSE by default to prevent crash on ROM load
121 // Cards only shown when user explicitly opens them via View menu or shortcuts
122 bool show_sheet_editor_ = false;
126
128 uint16_t current_sheet_ = 0;
129 uint8_t tile_size_ = 0x01;
130 std::set<uint16_t> open_sheets_;
131 std::set<uint16_t> child_window_sheets_;
132 std::stack<uint16_t> release_queue_;
137 float sheet_scale_ = 2.0f;
138 float current_scale_ = 4.0f;
139
140 // Prototype Graphics Viewer
142 uint64_t current_offset_ = 0;
143 uint64_t current_size_ = 0;
147
149 uint64_t bin_size_ = 0;
150 uint64_t clipboard_offset_ = 0;
151 uint64_t clipboard_size_ = 0;
152
153 bool refresh_graphics_ = false;
155 bool gfx_loaded_ = false;
156 bool is_open_ = false;
157 bool super_donkey_ = false;
158 bool col_file_ = false;
159 bool cgx_loaded_ = false;
160 bool scr_loaded_ = false;
161 bool obj_loaded_ = false;
162 bool tilemap_loaded_ = false;
163
164 std::string file_path_ = "";
165 std::string col_file_path_ = "";
166 std::string col_file_name_ = "";
167 std::string cgx_file_path_ = "";
168 std::string cgx_file_name_ = "";
169 std::string scr_file_path_ = "";
170 std::string scr_file_name_ = "";
171 std::string obj_file_path_ = "";
172 std::string tilemap_file_path_ = "";
173 std::string tilemap_file_name_ = "";
174
176
178
182 MemoryEditor cgx_memory_editor_;
183 MemoryEditor col_memory_editor_;
185 std::vector<uint8_t> import_data_;
186 std::vector<uint8_t> graphics_buffer_;
187 std::vector<uint8_t> decoded_cgx_;
188 std::vector<uint8_t> cgx_data_;
189 std::vector<uint8_t> extra_cgx_data_;
190 std::vector<SDL_Color> decoded_col_;
191 std::vector<uint8_t> scr_data_;
192 std::vector<uint8_t> decoded_scr_data_;
197 std::array<gfx::Bitmap, kNumGfxSheets> gfx_sheets_;
198 std::array<gfx::Bitmap, kNumLinkSheets> link_sheets_;
199
208 gui::Canvas current_sheet_canvas_{"CurrentSheetCanvas", ImVec2(0x80, 0x20),
214 absl::Status status_;
215
217};
218
219} // namespace editor
220} // namespace yaze
221
222#endif // YAZE_APP_EDITOR_GRAPHICS_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:71
Interface for editor classes.
Definition editor.h:82
EditorType type_
Definition editor.h:123
Allows the user to edit graphics sheets from the game or view prototype graphics.
std::vector< uint8_t > scr_data_
absl::Status Save() override
std::array< gfx::Bitmap, kNumLinkSheets > link_sheets_
GraphicsEditor(Rom *rom=nullptr)
gfx::PaletteGroup col_file_palette_group_
absl::Status Load() override
std::vector< uint8_t > decoded_cgx_
std::set< uint16_t > child_window_sheets_
absl::Status Copy() override
std::vector< uint8_t > graphics_buffer_
std::array< gfx::Bitmap, kNumGfxSheets > gfx_sheets_
std::vector< uint8_t > cgx_data_
absl::Status Redo() override
void DrawGfxEditToolset()
Draw the graphics editing toolset with enhanced ROM hacking features.
absl::Status Cut() override
std::vector< uint8_t > import_data_
absl::Status Paste() override
std::vector< SDL_Color > decoded_col_
absl::Status Undo() override
std::set< uint16_t > open_sheets_
absl::Status Update() override
absl::Status Find() override
std::vector< uint8_t > extra_cgx_data_
std::vector< uint8_t > decoded_scr_data_
std::stack< uint16_t > release_queue_
gui::GfxSheetAssetBrowser asset_browser_
absl::Status DecompressImportData(int size)
Allows the user to view and edit in game palettes.
Represents a bitmap image optimized for SNES ROM hacking.
Definition bitmap.h:66
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:54
Represents the full Overworld data, light and dark world.
Definition overworld.h:135
const std::string kSuperDonkeySprites[]
const std::string kSuperDonkeyTiles[]
constexpr int kTilesheetHeight
Definition snes_tile.h:17
constexpr int kTilesheetWidth
Definition snes_tile.h:16
Main namespace for the application.
Represents a group of palettes.