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
6#include "absl/status/status.h"
7#include "app/editor/editor.h"
10#include "app/gfx/core/bitmap.h"
15#include "imgui/imgui.h"
16#include "rom/rom.h"
21
22namespace yaze {
23namespace editor {
24
37class ScreenEditor : public Editor {
38 public:
39 explicit ScreenEditor(Rom* rom = nullptr) : rom_(rom) {
40 screen_canvas_.SetCanvasSize(ImVec2(512, 512));
42 }
43
44 void Initialize() override;
45 absl::Status Load() override;
46 absl::Status Update() override;
47 absl::Status Undo() override { return undo_manager_.Undo(); }
48 absl::Status Redo() override { return undo_manager_.Redo(); }
49 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
50 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
51 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
52 absl::Status Find() override { return absl::UnimplementedError("Find"); }
53 absl::Status Save() override;
54 void set_rom(Rom* rom) { rom_ = rom; }
55 Rom* rom() const { return rom_; }
56
57 std::vector<zelda3::DungeonMap> dungeon_maps_;
58
59 private:
63
66 void DrawToolset();
69
70 // Title screen layer editing
75
76 absl::Status LoadDungeonMapTile16(const std::vector<uint8_t>& gfx_data,
77 bool bin_mode = false);
78 absl::Status SaveDungeonMapTile16();
79
80 void DrawDungeonMapScreen(int i);
84
85 void LoadBinaryGfx();
86
87 // Undo/redo helpers
90 void SaveDungeonMapUndoState(const std::string& description);
91 void SaveTile16CompUndoState(const std::string& description);
94 void RestoreFromSnapshot(const ScreenSnapshot& snapshot);
95
96 enum class EditingMode { DRAW, EDIT };
97
99
100 bool binary_gfx_loaded_ = false;
101
102 uint8_t selected_room = 0;
103
108
111
113
117 gfx::Tilemap tile8_tilemap_; // Tilemap for 8x8 tiles with on-demand caching
118 std::array<gfx::TileInfo, 4> current_tile16_info;
119
120 gui::Canvas current_tile_canvas_{"##CurrentTileCanvas", ImVec2(32, 32),
124 gui::Canvas tilemap_canvas_{"##TilemapCanvas", ImVec2(128 + 2, (192) + 4),
126
127 // Title screen canvases
128 // Title screen is 32x32 tiles at 8x8 pixels = 256x256 pixels total
129 gui::Canvas title_bg1_canvas_{"##TitleBG1Canvas", ImVec2(256, 256),
131 gui::Canvas title_bg2_canvas_{"##TitleBG2Canvas", ImVec2(256, 256),
133 // Blockset is 128 pixels wide x 512 pixels tall (16x64 8x8 tiles)
134 gui::Canvas title_blockset_canvas_{"##TitleBlocksetCanvas", ImVec2(128, 512),
136
138 bool inventory_loaded_ = false;
141
142 // Title screen state
145 bool title_h_flip_ = false;
146 bool title_v_flip_ = false;
148 bool show_title_bg1_ = true;
149 bool show_title_bg2_ = true;
150
151 // Overworld map screen state
153 bool ow_map_loaded_ = false;
155
156 // Overworld map canvases
157 gui::Canvas ow_map_canvas_{"##OWMapCanvas", ImVec2(512, 512),
159 gui::Canvas ow_tileset_canvas_{"##OWTilesetCanvas", ImVec2(128, 128),
161
162 // Undo/redo pending state
169
171 absl::Status status_;
172};
173
174} // namespace editor
175} // namespace yaze
176
177#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:240
UndoManager undo_manager_
Definition editor.h:317
EditorType type_
Definition editor.h:315
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 Undo() override
ScreenSnapshot CaptureTile16CompSnapshot() const
absl::Status SaveDungeonMapTile16()
ScreenSnapshot pending_dungeon_before_
absl::Status Paste() override
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
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)
ScreenEditor(Rom *rom=nullptr)
zelda3::TitleScreen title_screen_
zelda3::Inventory inventory_
zelda3::DungeonMapLabels dungeon_map_labels_
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 palette of colors for the Super Nintendo Entertainment System (SNES).
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
void SetCanvasSize(ImVec2 canvas_size)
Definition canvas.h:466
Inventory manages the inventory screen graphics and layout.
Definition inventory.h:36
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:497
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