yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
overworld_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_OVERWORLDEDITOR_H
2#define YAZE_APP_EDITOR_OVERWORLDEDITOR_H
3
4#include "absl/status/status.h"
5#include "app/editor/editor.h"
9#include "app/gfx/bitmap.h"
11#include "app/gui/canvas.h"
12#include "app/gui/input.h"
13#include "app/gui/zeml.h"
14#include "app/rom.h"
16#include "imgui/imgui.h"
17
18namespace yaze {
19namespace editor {
20
21constexpr unsigned int k4BPP = 4;
22constexpr unsigned int kByteSize = 3;
23constexpr unsigned int kMessageIdSize = 5;
24constexpr unsigned int kNumSheetsToLoad = 223;
25constexpr unsigned int kTile8DisplayHeight = 64;
26constexpr unsigned int kOverworldMapSize = 0x200;
27constexpr float kInputFieldSize = 30.f;
30constexpr ImVec2 kCurrentGfxCanvasSize(0x100 + 1, 0x10 * 0x40 + 1);
31constexpr ImVec2 kBlocksetCanvasSize(0x100 + 1, 0x4000 + 1);
32constexpr ImVec2 kGraphicsBinCanvasSize(0x100 + 1, kNumSheetsToLoad * 0x40 + 1);
33
34constexpr ImGuiTableFlags kOWMapFlags =
35 ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable;
36constexpr ImGuiTableFlags kToolsetTableFlags = ImGuiTableFlags_SizingFixedFit;
37constexpr ImGuiTableFlags kOWEditFlags =
38 ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable |
39 ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter |
40 ImGuiTableFlags_BordersV;
41
42static constexpr absl::string_view kToolsetColumnNames[] = {
43 "#undoTool", "#redoTool", "#separator2", "#zoomOutTool",
44 "#zoomInTool", "#separator", "#drawTool", "#history",
45 "#entranceTool", "#exitTool", "#itemTool", "#spriteTool",
46 "#transportTool", "#musicTool", "#separator3", "#tilemapTool",
47 "propertiesTool", "#separator4", "#experimentalTool", "#properties",
48 "#separator5"};
49
50constexpr absl::string_view kWorldList =
51 "Light World\0Dark World\0Extra World\0";
52
53constexpr absl::string_view kGamePartComboString = "Part 0\0Part 1\0Part 2\0";
54
55constexpr absl::string_view kTileSelectorTab = "##TileSelectorTabBar";
56constexpr absl::string_view kOWEditTable = "##OWEditTable";
57constexpr absl::string_view kOWMapTable = "#MapSettingsTable";
58
75class OverworldEditor : public Editor, public gfx::GfxContext {
76 public:
78
79 void Initialize();
80
81 absl::Status Update() final;
82 absl::Status Undo() override { return absl::UnimplementedError("Undo"); }
83 absl::Status Redo() override { return absl::UnimplementedError("Redo"); }
84 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
85 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
86 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
87 absl::Status Find() override {
88 return absl::UnimplementedError("Find Unused Tiles");
89 }
90 absl::Status Save();
91
92 int jump_to_tab() { return jump_to_tab_; }
93 int jump_to_tab_ = -1;
94
102 absl::Status LoadGraphics();
103
104 private:
106 void DrawToolset();
109
110 void RefreshChildMap(int i);
111 void RefreshOverworldMap();
112 absl::Status RefreshMapPalette();
114 absl::Status RefreshTile16Blockset();
115
116 void DrawOverworldEntrances(ImVec2 canvas_p, ImVec2 scrolling,
117 bool holes = false);
118 void DrawOverworldExits(ImVec2 zero, ImVec2 scrolling);
119 void DrawOverworldItems();
121
122 void DrawOverworldMaps();
123 void DrawOverworldEdits();
124 void RenderUpdatedMapBitmap(const ImVec2& click_position,
125 const std::vector<uint8_t>& tile_data);
126
136
141
147 absl::Status CheckForCurrentMap();
148 void CheckForMousePan();
149 void DrawOverworldCanvas();
150
151 absl::Status DrawTile16Selector();
152 void DrawTile8Selector();
153 absl::Status DrawAreaGraphics();
154 absl::Status DrawTileSelector();
155
156 absl::Status LoadSpriteGraphics();
157
159
160 absl::Status UpdateUsageStats();
161 void DrawUsageGrid();
162 void DrawDebugWindow();
163
174
177
192
201 int game_state_ = 1;
205
206 bool all_gfx_loaded_ = false;
213
214 std::vector<uint8_t> selected_tile_data_;
215 std::array<gfx::Bitmap, zelda3::kNumTile16Individual> tile16_individual_;
216
217 std::vector<std::vector<uint8_t>> tile8_individual_data_;
218 std::vector<gfx::Bitmap> tile8_individual_;
219
221
225
227
232
233 std::array<gfx::Bitmap, zelda3::kNumOverworldMaps> maps_bmp_;
235 std::vector<gfx::Bitmap> sprite_previews_;
236
239
241
246
249
259
263
265 absl::Status status_;
266};
267} // namespace editor
268} // namespace yaze
269
270#endif
The Rom class is used to load, save, and modify Rom data.
Definition rom.h:59
EditorType type_
Definition editor.h:68
Manage graphics group configurations in a Rom.
zelda3::OverworldItem current_item_
zelda3::OverworldEntranceTileTypes entrance_tiletypes_
zelda3::OverworldEntrance current_entrance_
absl::Status CheckForCurrentMap()
Check for changes to the overworld map. Calls RefreshOverworldMap and RefreshTile16Blockset on the cu...
absl::Status Cut() override
zelda3::OverworldBlockset refresh_blockset_
std::vector< gfx::Bitmap > tile8_individual_
void DrawOverworldExits(ImVec2 zero, ImVec2 scrolling)
absl::Status Undo() override
zelda3::GameEntity * dragged_entity_
std::array< gfx::Bitmap, zelda3::kNumOverworldMaps > maps_bmp_
void CheckForOverworldEdits()
Check for changes to the overworld map.
zelda3::OverworldExit current_exit_
std::vector< std::vector< uint8_t > > tile8_individual_data_
void RenderUpdatedMapBitmap(const ImVec2 &click_position, const std::vector< uint8_t > &tile_data)
absl::Status Redo() override
void CheckForSelectRectangle()
Draw and create the tile16 IDs that are currently selected.
std::vector< gfx::Bitmap > sprite_previews_
absl::Status Copy() override
absl::Status Paste() override
std::vector< uint8_t > selected_tile_data_
absl::Status LoadGraphics()
Load the Bitmap objects for each OverworldMap.
absl::Status Find() override
std::array< gfx::Bitmap, zelda3::kNumTile16Individual > tile16_individual_
void DrawOverworldEntrances(ImVec2 canvas_p, ImVec2 scrolling, bool holes=false)
zelda3::GameEntity * current_entity_
Allows the user to view and edit in game palettes.
Popup window to edit Tile16 data.
Represents a bitmap image.
Definition bitmap.h:66
Shared graphical context across editors.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Represents a canvas for drawing and manipulating graphics.
Definition canvas.h:34
Base class for all overworld and dungeon entities.
Definition common.h:20
Represents the full Overworld data, light and dark world.
Definition overworld.h:111
A class for managing sprites in the overworld and underworld.
Definition sprite.h:279
Editors are the view controllers for the application.
constexpr ImVec2 kOverworldCanvasSize(kOverworldMapSize *8, kOverworldMapSize *8)
constexpr absl::string_view kOWMapTable
constexpr ImGuiTableFlags kOWMapFlags
constexpr unsigned int kOverworldMapSize
constexpr unsigned int kTile8DisplayHeight
constexpr absl::string_view kWorldList
constexpr absl::string_view kGamePartComboString
constexpr ImGuiTableFlags kToolsetTableFlags
constexpr unsigned int kNumSheetsToLoad
constexpr ImVec2 kCurrentGfxCanvasSize(0x100+1, 0x10 *0x40+1)
constexpr ImVec2 kBlocksetCanvasSize(0x100+1, 0x4000+1)
constexpr ImVec2 kGraphicsBinCanvasSize(0x100+1, kNumSheetsToLoad *0x40+1)
constexpr unsigned int kByteSize
constexpr ImGuiTableFlags kOWEditFlags
constexpr absl::string_view kOWEditTable
constexpr float kInputFieldSize
Definition entity.cc:19
constexpr absl::string_view kTileSelectorTab
constexpr unsigned int k4BPP
constexpr unsigned int kMessageIdSize
std::unordered_map< int, gfx::Bitmap > BitmapTable
Definition bitmap.h:193
std::vector< std::vector< uint16_t > > OverworldBlockset
Represents tile32 data for the overworld.
Main namespace for the application.
Definition controller.cc:18
Node for a zeml tree.
Definition zeml.h:124