yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_object_selector.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_OBJECT_SELECTOR_H
2#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_OBJECT_SELECTOR_H
3
4#include <array>
5#include <cstdint>
6#include <functional>
7#include <map>
8#include <memory>
9#include <string>
10#include "app/editor/editor.h"
13#include "rom/rom.h"
14#include "zelda3/dungeon/room.h"
16#include "zelda3/game_data.h"
17// object_renderer.h removed - using ObjectDrawer for production rendering
18#include "imgui/imgui.h"
25
26namespace yaze {
27namespace editor {
28
33 public:
34 explicit DungeonObjectSelector(Rom* rom = nullptr) : rom_(rom) {}
35
36 void DrawTileSelector();
37 void DrawObjectRenderer();
39 void Draw();
40
41 // Unified context setter (preferred)
43 rom_ = ctx.rom;
45 }
46 EditorContext context() const { return {rom_, game_data_}; }
47
48 // Individual setters for compatibility
49 void SetRom(Rom* rom) { rom_ = rom; }
50 Rom* rom() const { return rom_; }
53
54 // Editor system access
56 std::unique_ptr<zelda3::DungeonEditorSystem>* system) {
58 }
59 void set_object_editor(std::unique_ptr<zelda3::DungeonObjectEditor>* editor) {
60 object_editor_ = editor ? editor->get() : nullptr;
61 }
62
63 // Room data access
64 void set_rooms(std::array<zelda3::Room, 0x128>* rooms) { rooms_ = rooms; }
65 std::array<zelda3::Room, 0x128>* get_rooms() { return rooms_; }
66 void set_current_room_id(int room_id) { current_room_id_ = room_id; }
67
68 // Palette access
72 void SetCurrentPaletteGroup(const gfx::PaletteGroup& palette_group) {
73 current_palette_group_ = palette_group;
74 }
75 void SetCurrentPaletteId(uint64_t palette_id) {
76 current_palette_id_ = palette_id;
77 }
78
79 // Object selection callbacks
81 std::function<void(const zelda3::RoomObject&)> callback) {
83 }
84
86 std::function<void(const zelda3::RoomObject&)> callback) {
88 }
89
90 void SetObjectDoubleClickCallback(std::function<void(int)> callback) {
92 }
93
94 // Get current preview object for placement
96 bool IsObjectLoaded() const { return object_loaded_; }
97
98 // AssetBrowser-style object selection
100
101 // Programmatic selection
102 void SelectObject(int obj_id);
103
104 // Static editor indicator (highlights which object is being viewed in detail)
105 void SetStaticEditorObjectId(int obj_id) {
107 }
109
110 private:
111 void DrawRoomGraphics();
112 bool MatchesObjectFilter(int obj_id, int filter_type);
113 void CalculateObjectDimensions(const zelda3::RoomObject& object, int& width,
114 int& height);
115 void PlaceObjectAtPosition(int x, int y);
123 bool DrawObjectPreview(const zelda3::RoomObject& object, ImVec2 top_left,
124 float size);
125 zelda3::RoomObject MakePreviewObject(int obj_id) const;
127 ImU32 GetObjectTypeColor(int object_id);
128 std::string GetObjectTypeSymbol(int object_id);
129 void RenderObjectPrimitive(const zelda3::RoomObject& object, int x, int y);
130
131 Rom* rom_ = nullptr;
133 gui::Canvas room_gfx_canvas_{"##RoomGfxCanvas",
134 ImVec2(0x100 + 1, 0x10 * 0x40 + 1)};
136
137 // Editor systems
138 std::unique_ptr<zelda3::DungeonEditorSystem>* dungeon_editor_system_ =
139 nullptr;
141
142 // Room data
143 std::array<zelda3::Room, 0x128>* rooms_ = nullptr;
145
146 // Palette data
150
152
153 // Object preview system
156 bool object_loaded_ = false;
157
158 // Callback for object selection
161 std::function<void(int)> object_double_click_callback_;
162
163 // Object selection state
165 int static_editor_object_id_ = -1; // Object currently open in static editor
166
167 // UI state for placement controls (previously static locals)
168 int place_x_ = 0;
169 int place_y_ = 0;
170
171 // UI state for object browser filter
173 int object_subtype_tab_ = 0; // 0=Type1, 1=Type2, 2=Type3
174
175 // UI state for compact sprite editor
179
180 // UI state for compact item editor
182 int new_item_x_ = 0;
183 int new_item_y_ = 0;
184
185 // UI state for compact entrance editor
191
192 // UI state for compact door editor
193 int door_x_ = 0;
194 int door_y_ = 0;
197
198 // UI state for compact chest editor
199 int chest_x_ = 0;
200 int chest_y_ = 0;
202 bool chest_big_ = false;
203
204 // UI state for room properties editor
205 char room_name_[128] = {0};
206 int dungeon_id_ = 0;
208 bool is_boss_room_ = false;
209 bool is_save_room_ = false;
210 int music_id_ = 0;
211
212 // Registry initialization flag
214
215 // Performance: enable/disable graphical preview rendering
217
218 // Preview cache for object selector grid
219 // Key: object_id, Value: BackgroundBuffer with rendered preview
220 std::map<int, std::unique_ptr<gfx::BackgroundBuffer>> preview_cache_;
224
226 bool GetOrCreatePreview(int obj_id, float size, gfx::BackgroundBuffer** out);
227
229};
230
231} // namespace editor
232} // namespace yaze
233
234#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:24
Handles object selection, preview, and editing UI.
std::function< void(const zelda3::RoomObject &) object_placement_callback_)
std::map< int, std::unique_ptr< gfx::BackgroundBuffer > > preview_cache_
bool GetOrCreatePreview(int obj_id, float size, gfx::BackgroundBuffer **out)
zelda3::DungeonObjectEditor * object_editor_
std::array< zelda3::Room, 0x128 > * rooms_
void CalculateObjectDimensions(const zelda3::RoomObject &object, int &width, int &height)
zelda3::DungeonObjectRegistry object_registry_
void set_rooms(std::array< zelda3::Room, 0x128 > *rooms)
std::function< void(int)> object_double_click_callback_
void RenderObjectPrimitive(const zelda3::RoomObject &object, int x, int y)
void SetGameData(zelda3::GameData *game_data)
void SetObjectDoubleClickCallback(std::function< void(int)> callback)
void set_object_editor(std::unique_ptr< zelda3::DungeonObjectEditor > *editor)
void SetCurrentPaletteGroup(const gfx::PaletteGroup &palette_group)
std::unique_ptr< zelda3::DungeonEditorSystem > * dungeon_editor_system_
std::array< zelda3::Room, 0x128 > * get_rooms()
void set_dungeon_editor_system(std::unique_ptr< zelda3::DungeonEditorSystem > *system)
void SetCurrentPaletteId(uint64_t palette_id)
const zelda3::RoomObject & GetPreviewObject() const
std::function< void(const zelda3::RoomObject &) object_selected_callback_)
zelda3::RoomObject MakePreviewObject(int obj_id) const
bool DrawObjectPreview(const zelda3::RoomObject &object, ImVec2 top_left, float size)
bool MatchesObjectFilter(int obj_id, int filter_type)
void SetObjectPlacementCallback(std::function< void(const zelda3::RoomObject &)> callback)
void SetObjectSelectedCallback(std::function< void(const zelda3::RoomObject &)> callback)
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
Interactive dungeon object editor with scroll wheel support.
Minimal registry for dungeon objects (vanilla or custom).
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:67
zelda3::GameData * game_data
Definition editor.h:69
Represents a group of palettes.