yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
screen_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SCREEN_EDITOR_H
2#define YAZE_APP_EDITOR_SCREEN_EDITOR_H
3
4#include <array>
5#include <memory>
6
7#include "absl/status/status.h"
8#include "app/editor/editor.h"
11#include "app/gfx/core/bitmap.h"
16#include "imgui/imgui.h"
17#include "rom/rom.h"
22
23namespace yaze {
24namespace editor {
25
38class ScreenEditor : public Editor {
39 public:
40 explicit ScreenEditor(Rom* rom = nullptr) : rom_(rom) {
41 screen_canvas_.SetCanvasSize(ImVec2(512, 512));
43 }
44
45 void Initialize() override;
46 absl::Status Load() override;
47 absl::Status Update() override;
48 absl::Status Undo() override { return undo_manager_.Undo(); }
49 absl::Status Redo() override { return undo_manager_.Redo(); }
50 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
51 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
52 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
53 absl::Status Find() override { return absl::UnimplementedError("Find"); }
54 absl::Status Save() override;
55 void set_rom(Rom* rom) { rom_ = rom; }
56 Rom* rom() const { return rom_; }
57
77 absl::Status RefreshRomBackedState();
79
80 std::vector<zelda3::DungeonMap> dungeon_maps_;
81
82 private:
84
88
91 void DrawToolset();
94
95 // Title screen layer editing
100
101 absl::Status LoadDungeonMapTile16(const std::vector<uint8_t>& gfx_data,
102 bool bin_mode = false);
103
104 void DrawDungeonMapScreen(int i);
105 void DrawDungeonMapsTabs();
108
109 void LoadBinaryGfx();
110 gfx::Bitmap* GetOrCreateSheet(int index);
112 bool HasValidDungeonSelection() const;
113 bool HasValidDungeonFloorSelection(int floor) const;
114
115 // Undo/redo helpers
118 void SaveDungeonMapUndoState(const std::string& description);
119 void SaveTile16CompUndoState(const std::string& description);
122 void RestoreFromSnapshot(const ScreenSnapshot& snapshot);
133 absl::Status SaveTitleScreenToRom();
134 absl::Status SaveOverworldMapToRom();
135
136 enum class EditingMode { DRAW, EDIT };
137
139
140 bool binary_gfx_loaded_ = false;
141
142 uint8_t selected_room = 0;
143
148
151
153
157 gfx::Tilemap tile8_tilemap_; // Tilemap for 8x8 tiles with on-demand caching
158 std::array<gfx::TileInfo, 4> current_tile16_info;
159
160 gui::Canvas current_tile_canvas_{"##CurrentTileCanvas", ImVec2(32, 32),
164 gui::Canvas tilemap_canvas_{"##TilemapCanvas", ImVec2(128 + 2, (192) + 4),
166
167 // Title screen canvases
168 // Title screen is 32x32 tiles at 8x8 pixels = 256x256 pixels total
169 gui::Canvas title_bg1_canvas_{"##TitleBG1Canvas", ImVec2(256, 256),
171 gui::Canvas title_bg2_canvas_{"##TitleBG2Canvas", ImVec2(256, 256),
173 // Blockset is 128 pixels wide x 512 pixels tall (16x64 8x8 tiles)
174 gui::Canvas title_blockset_canvas_{"##TitleBlocksetCanvas", ImVec2(128, 512),
176
177 std::unique_ptr<zelda3::Inventory> inventory_ =
178 std::make_unique<zelda3::Inventory>();
179 bool inventory_loaded_ = false;
182
183 // Title screen state
186 bool title_h_flip_ = false;
187 bool title_v_flip_ = false;
189 bool show_title_bg1_ = true;
190 bool show_title_bg2_ = true;
191
192 // Overworld map screen state
194 bool ow_map_loaded_ = false;
196
197 // Overworld map canvases
198 gui::Canvas ow_map_canvas_{"##OWMapCanvas", ImVec2(512, 512),
200 gui::Canvas ow_tileset_canvas_{"##OWTilesetCanvas", ImVec2(128, 128),
202
203 // Undo/redo pending state
216
218 absl::Status status_;
219};
220
221} // namespace editor
222} // namespace yaze
223
224#endif
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
UndoManager undo_manager_
Definition editor.h:334
EditorType type_
Definition editor.h:332
The ScreenEditor class allows the user to edit a variety of screens in the game or create a custom me...
absl::Status LoadDungeonMapTile16(const std::vector< uint8_t > &gfx_data, bool bin_mode=false)
void DrawDungeonMapsRoomGfx()
Draw dungeon room graphics editor with enhanced tile16 editing.
absl::Status RefreshRomBackedState()
absl::Status Undo() override
ScreenSnapshot CaptureTile16CompSnapshot() const
absl::Status SaveOverworldMapToRom()
gfx::Bitmap * GetOrCreateSheet(int index)
friend class ScreenEditorSaveStoplossTestPeer
ScreenSnapshot pending_dungeon_before_
bool HasPendingOverworldMapChanges() const
absl::Status Paste() override
bool HasPendingDungeonMapChanges() const
absl::Status Cut() override
std::array< gfx::TileInfo, 4 > current_tile16_info
absl::Status Save() override
absl::Status Load() override
void SaveDungeonMapUndoState(const std::string &description)
absl::Status Update() override
bool HasValidDungeonFloorSelection(int floor) const
absl::Status Copy() override
absl::Status Find() override
void RestoreFromSnapshot(const ScreenSnapshot &snapshot)
zelda3::OverworldMapScreen ow_map_screen_
ScreenSnapshot pending_tile16_before_
ScreenSnapshot CaptureDungeonMapSnapshot() const
void DrawDungeonMapsEditor()
Draw dungeon maps editor with enhanced ROM hacking features.
absl::Status Redo() override
void SaveTile16CompUndoState(const std::string &description)
bool HasPendingDungeonMapTile16Changes() const
ScreenEditor(Rom *rom=nullptr)
absl::Status SaveTitleScreenToRom()
bool HasPendingTitleScreenChanges() const
zelda3::TitleScreen title_screen_
std::unique_ptr< zelda3::Inventory > inventory_
zelda3::DungeonMapLabels dungeon_map_labels_
bool HasPendingScreenChanges() const
void RefreshTileCacheForReload(gfx::Tilemap &tilemap)
bool IsRomBackedStateValid() const
std::vector< zelda3::DungeonMap > dungeon_maps_
absl::Status Redo()
Redo the top action. Returns error if stack is empty.
absl::Status Undo()
Undo the top action. Returns error if stack is empty.
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
void SetCanvasSize(ImVec2 canvas_size)
Definition canvas.h:374
OverworldMapScreen manages the overworld map (pause menu) graphics.
TitleScreen manages the title screen graphics and tilemap data.
std::unordered_map< int, std::unique_ptr< gfx::Bitmap > > BitmapTable
Definition bitmap.h:518
std::array< std::vector< std::array< std::string, kNumRooms > >, kNumDungeons > DungeonMapLabels
Definition dungeon_map.h:72
Unified screen editor snapshot.
Tilemap structure for SNES tile-based graphics management.
Definition tilemap.h:118