yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_editor.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEONEDITOR_H
2#define YAZE_APP_EDITOR_DUNGEONEDITOR_H
3
4#include "app/core/common.h"
5#include "absl/container/flat_hash_map.h"
8#include "app/editor/editor.h"
9#include "app/gui/canvas.h"
10#include "app/rom.h"
11#include "imgui/imgui.h"
12#include "zelda3/dungeon/room.h"
15
16namespace yaze {
17namespace app {
18namespace editor {
19
20constexpr ImGuiTabItemFlags kDungeonTabFlags =
21 ImGuiTabItemFlags_Trailing | ImGuiTabItemFlags_NoTooltip;
22
23constexpr ImGuiTabBarFlags kDungeonTabBarFlags =
24 ImGuiTabBarFlags_AutoSelectNewTabs | ImGuiTabBarFlags_Reorderable |
25 ImGuiTabBarFlags_FittingPolicyResizeDown |
26 ImGuiTabBarFlags_TabListPopupButton;
27
28constexpr ImGuiTableFlags kDungeonTableFlags =
29 ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable |
30 ImGuiTableFlags_Hideable | ImGuiTableFlags_BordersOuter |
31 ImGuiTableFlags_BordersV;
32
43class DungeonEditor : public Editor,
44 public SharedRom,
46 public:
48
49 absl::Status Update() override;
50 absl::Status Undo() override { return absl::UnimplementedError("Undo"); }
51 absl::Status Redo() override { return absl::UnimplementedError("Redo"); }
52 absl::Status Cut() override { return absl::UnimplementedError("Cut"); }
53 absl::Status Copy() override { return absl::UnimplementedError("Copy"); }
54 absl::Status Paste() override { return absl::UnimplementedError("Paste"); }
55 absl::Status Find() override { return absl::UnimplementedError("Find"); }
56
57 void add_room(int i) { active_rooms_.push_back(i); }
58
59 private:
60 absl::Status Initialize();
61 absl::Status RefreshGraphics();
62
64
65 absl::Status UpdateDungeonRoomView();
66
67 void DrawToolset();
68 void DrawRoomSelector();
70
71 void DrawDungeonTabView();
72 void DrawDungeonCanvas(int room_id);
73
74 void DrawRoomGraphics();
75 void DrawTileSelector();
76 void DrawObjectRenderer();
77
79 void DrawUsageStats();
80 void DrawUsageGrid();
81 void RenderSetUsage(const absl::flat_hash_map<uint16_t, int>& usage_map,
82 uint16_t& selected_set, int spriteset_offset = 0x00);
83
92
96
97 bool is_loaded_ = false;
98 bool object_loaded_ = false;
99 bool palette_showing_ = false;
100 bool refresh_graphics_ = false;
101
103 uint16_t current_room_id_ = 0;
106
107 ImVector<int> active_rooms_;
108
114
118
120 std::array<gfx::Bitmap, kNumGfxSheets> graphics_bin_;
121
122 std::vector<gfx::Bitmap*> room_gfx_sheets_;
123 std::vector<zelda3::dungeon::Room> rooms_;
124 std::vector<zelda3::dungeon::RoomEntrance> entrances_;
126
127 absl::flat_hash_map<uint16_t, int> spriteset_usage_;
128 absl::flat_hash_map<uint16_t, int> blockset_usage_;
129 absl::flat_hash_map<uint16_t, int> palette_usage_;
130
131 std::vector<int64_t> room_size_pointers_;
132
133 uint16_t selected_blockset_ = 0xFFFF; // 0xFFFF indicates no selection
134 uint16_t selected_spriteset_ = 0xFFFF;
135 uint16_t selected_palette_ = 0xFFFF;
136
137 uint64_t total_room_size_ = 0;
138
139 std::unordered_map<int, int> room_size_addresses_;
140 std::unordered_map<int, ImVec4> room_palette_;
141
142 absl::Status status_;
143};
144
145} // namespace editor
146} // namespace app
147} // namespace yaze
148
149#endif
A class to hold a shared pointer to a Rom object.
Definition rom.h:576
A class to manage experimental feature flags.
Definition common.h:36
DungeonEditor class for editing dungeons.
std::unordered_map< int, int > room_size_addresses_
absl::flat_hash_map< uint16_t, int > blockset_usage_
absl::Status Redo() override
std::vector< zelda3::dungeon::Room > rooms_
absl::Status Cut() override
std::array< gfx::Bitmap, kNumGfxSheets > graphics_bin_
absl::Status Undo() override
absl::flat_hash_map< uint16_t, int > palette_usage_
gfx::PaletteGroup current_palette_group_
std::vector< zelda3::dungeon::RoomEntrance > entrances_
absl::Status Copy() override
absl::Status Paste() override
std::vector< gfx::Bitmap * > room_gfx_sheets_
absl::Status Update() override
std::unordered_map< int, ImVec4 > room_palette_
zelda3::dungeon::DungeonObjectRenderer object_renderer_
absl::Status Find() override
std::vector< int64_t > room_size_pointers_
absl::flat_hash_map< uint16_t, int > spriteset_usage_
void RenderSetUsage(const absl::flat_hash_map< uint16_t, int > &usage_map, uint16_t &selected_set, int spriteset_offset=0x00)
Interface for editor classes.
Definition editor.h:54
Manage graphics group configurations in a Rom.
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
constexpr ImGuiTableFlags kDungeonTableFlags
constexpr ImGuiTabBarFlags kDungeonTabBarFlags
constexpr ImGuiTabItemFlags kDungeonTabFlags
Definition common.cc:22
Represents a group of palettes.