yaze 0.2.0
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"
8#include "app/editor/editor.h"
9#include "app/gfx/bitmap.h"
10#include "app/gfx/snes_tile.h"
12#include "app/gui/canvas.h"
13#include "app/rom.h"
15#include "imgui/imgui.h"
16#include "imgui_memory_editor.h"
17
18namespace yaze {
19namespace app {
20namespace editor {
21
22// "99973","A3D80",
23
24const std::string kSuperDonkeyTiles[] = {
25 "97C05", "98219", "9871E", "98C00", "99084", "995AF", "99DE0", "9A27E",
26 "9A741", "9AC31", "9B07E", "9B55C", "9B963", "9BB99", "9C009", "9C4B4",
27 "9C92B", "9CDD6", "9D2C2", "9E037", "9E527", "9EA56", "9EF65", "9FCD1",
28 "A0193", "A059E", "A0B17", "A0FB6", "A14A5", "A1988", "A1E66", "A232B",
29 "A27F0", "A2B6E", "A302C", "A3453", "A38CA", "A42BB", "A470C", "A4BA9",
30 "A5089", "A5385", "A5742", "A5BCC", "A6017", "A6361", "A66F8"};
31
32const std::string kSuperDonkeySprites[] = {
33 "A8E5D", "A9435", "A9934", "A9D83", "AA2F1", "AA6D4", "AABE4", "AB127",
34 "AB65A", "ABBDD", "AC38D", "AC797", "ACCC8", "AD0AE", "AD245", "AD554",
35 "ADAAC", "ADECC", "AE453", "AE9D2", "AEF40", "AF3C9", "AF92E", "AFE9D",
36 "B03D2", "B09AC", "B0F0C", "B1430", "B1859", "B1E01", "B229A", "B2854",
37 "B2D27", "B31D7", "B3B58", "B40B5", "B45A5", "B4D64", "B5031", "B555F",
38 "B5F30", "B6858", "B70DD", "B7526", "B79EC", "B7C83", "B80F7", "B85CC",
39 "B8A3F", "B8F97", "B94F2", "B9A20", "B9E9A", "BA3A2", "BA8F6", "BACDC",
40 "BB1F9", "BB781", "BBCCA", "BC26D", "BC7D4", "BCBB0", "BD082", "BD5FC",
41 "BE115", "BE5C2", "BEB63", "BF0CB", "BF607", "BFA55", "BFD71", "C017D",
42 "C0567", "C0981", "C0BA7", "C116D", "C166A", "C1FE0", "C24CE", "C2B19"};
43
58class GraphicsEditor : public SharedRom, public Editor {
59 public:
61
62 absl::Status Update() override;
63
64 absl::Status Undo() override { return absl::UnimplementedError("Undo"); }
65 absl::Status Redo() override { return absl::UnimplementedError("Redo"); }
66 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
67 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
68 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
69 absl::Status Find() override { return absl::UnimplementedError("Find"); }
70
71 private:
72 enum class GfxEditMode {
73 kSelect,
74 kPencil,
75 kFill,
76 };
77
78 // Graphics Editor Tab
79 absl::Status UpdateGfxEdit();
80 absl::Status UpdateGfxSheetList();
81 absl::Status UpdateGfxTabView();
82 absl::Status UpdatePaletteColumn();
83 void DrawGfxEditToolset();
84
85 // Link Graphics Edit Tab
86 absl::Status UpdateLinkGfxView();
87
88 // Prototype Graphics Viewer
89 absl::Status UpdateScadView();
90
91 // Import Functions
92 absl::Status DrawCgxImport();
93 absl::Status DrawScrImport();
94 absl::Status DrawFileImport();
95 absl::Status DrawObjImport();
96 absl::Status DrawTilemapImport();
97
98 // Other Functions
99 absl::Status DrawToolset();
100 absl::Status DrawPaletteControls();
101 absl::Status DrawClipboardImport();
102 absl::Status DrawExperimentalFeatures();
103 absl::Status DrawMemoryEditor();
104
105 absl::Status DecompressImportData(int size);
106 absl::Status DecompressSuperDonkey();
107
108 // Member Variables
110 uint16_t current_sheet_ = 0;
111 uint8_t tile_size_ = 0x01;
112 std::set<uint16_t> open_sheets_;
113 std::set<uint16_t> child_window_sheets_;
114 std::stack<uint16_t> release_queue_;
119 float sheet_scale_ = 2.0f;
120 float current_scale_ = 4.0f;
121
122 // Prototype Graphics Viewer
124 uint64_t current_offset_ = 0;
125 uint64_t current_size_ = 0;
129
131 uint64_t bin_size_ = 0;
132 uint64_t clipboard_offset_ = 0;
133 uint64_t clipboard_size_ = 0;
134
135 bool refresh_graphics_ = false;
137 bool gfx_loaded_ = false;
138 bool is_open_ = false;
139 bool super_donkey_ = false;
140 bool col_file_ = false;
141 bool cgx_loaded_ = false;
142 bool scr_loaded_ = false;
143 bool obj_loaded_ = false;
144 bool tilemap_loaded_ = false;
145
146 char file_path_[256] = "";
147 char col_file_path_[256] = "";
148 char col_file_name_[256] = "";
149 char cgx_file_path_[256] = "";
150 char cgx_file_name_[256] = "";
151 char scr_file_path_[256] = "";
152 char scr_file_name_[256] = "";
153 char obj_file_path_[256] = "";
154 char tilemap_file_path_[256] = "";
155 char tilemap_file_name_[256] = "";
156
158
160
164 MemoryEditor cgx_memory_editor_;
165 MemoryEditor col_memory_editor_;
167 std::vector<uint8_t> import_data_;
168 std::vector<uint8_t> graphics_buffer_;
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_;
179 std::array<gfx::Bitmap, kNumGfxSheets> gfx_sheets_;
180
189 gui::Canvas current_sheet_canvas_{"CurrentSheetCanvas", ImVec2(0x80, 0x20),
195 absl::Status status_;
196};
197
198} // namespace editor
199} // namespace app
200} // namespace yaze
201
202#endif // YAZE_APP_EDITOR_GRAPHICS_EDITOR_H
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:136
A class to hold a shared pointer to a Rom object.
Definition rom.h:576
Interface for editor classes.
Definition editor.h:54
Allows the user to edit graphics sheets from the game or view prototype graphics.
absl::Status DecompressImportData(int size)
std::set< uint16_t > child_window_sheets_
std::array< gfx::Bitmap, kNumGfxSheets > gfx_sheets_
std::vector< uint8_t > graphics_buffer_
gui::GfxSheetAssetBrowser asset_browser_
std::vector< SDL_Color > decoded_col_
std::vector< uint8_t > extra_cgx_data_
std::vector< uint8_t > decoded_scr_data_
std::vector< uint8_t > decoded_cgx_
std::vector< uint8_t > import_data_
absl::Status Paste() override
std::stack< uint16_t > release_queue_
zelda3::overworld::Overworld overworld_
Allows the user to view and edit in game palettes.
Represents a bitmap image.
Definition bitmap.h:67
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Represents a canvas for drawing and manipulating graphics.
Definition canvas.h:34
Represents the full Overworld data, light and dark world.
Definition overworld.h:461
const std::string kSuperDonkeyTiles[]
const std::string kSuperDonkeySprites[]
constexpr int kTilesheetWidth
Definition snes_tile.h:16
constexpr int kTilesheetHeight
Definition snes_tile.h:17
Definition common.cc:22
Represents a group of palettes.