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>
11#include "app/editor/editor.h"
14#include "core/project.h"
15#include "rom/rom.h"
16#include "zelda3/dungeon/room.h"
18#include "zelda3/game_data.h"
19// object_renderer.h removed - using ObjectDrawer for production rendering
20#include "imgui/imgui.h"
23
24namespace yaze {
25namespace editor {
26
27class ObjectTileEditorPanel;
28
33 public:
34 explicit DungeonObjectSelector(Rom* rom = nullptr) : rom_(rom) {}
35
36 // Unified context setter (preferred)
38 rom_ = ctx.rom;
40 }
41 EditorContext context() const { return {rom_, game_data_}; }
42
43 // Individual setters for compatibility
44 void SetRom(Rom* rom) { rom_ = rom; }
45 Rom* rom() const { return rom_; }
48
49 // Room data access
50 void set_rooms(DungeonRoomStore* rooms) { rooms_ = rooms; }
52 void set_current_room_id(int room_id) { current_room_id_ = room_id; }
53
54 // Palette access
58 void SetCurrentPaletteGroup(const gfx::PaletteGroup& palette_group) {
59 current_palette_group_ = palette_group;
60 }
61 void SetCurrentPaletteId(uint64_t palette_id) {
62 current_palette_id_ = palette_id;
63 }
64 void SetCustomObjectsFolder(const std::string& folder);
65
66 // Object selection callbacks
68 std::function<void(const zelda3::RoomObject&)> callback) {
70 }
71
72 void SetObjectDoubleClickCallback(std::function<void(int)> callback) {
74 }
75
76 // Get current preview object for placement
78 bool IsObjectLoaded() const { return object_loaded_; }
79
80 // AssetBrowser-style object selection
82
83 // Programmatic selection
84 void SelectObject(int obj_id, int subtype = -1);
85
86 // Tile editor panel and project references for custom object creation
90 void SetProject(project::YazeProject* project) { project_ = project; }
91
92 // Invalidate preview and layout caches (e.g., after new custom object added)
94
95 // Static editor indicator (highlights which object is being viewed in detail)
96 void SetStaticEditorObjectId(int obj_id) {
98 }
100
101 private:
102 bool MatchesObjectFilter(int obj_id, int filter_type);
103 bool MatchesObjectSearch(int obj_id, const std::string& name,
104 int subtype = -1) const;
105 void CalculateObjectDimensions(const zelda3::RoomObject& object, int& width,
106 int& height);
107 bool DrawObjectPreview(const zelda3::RoomObject& object, ImVec2 top_left,
108 float size);
109 zelda3::RoomObject MakePreviewObject(int obj_id) const;
111 ImU32 GetObjectTypeColor(int object_id);
112 std::string GetObjectTypeSymbol(int object_id);
115
116 // Custom object creation dialog state
121 char create_filename_[128] = {0};
122
123 // References for custom object creation
126
127 Rom* rom_ = nullptr;
131
132 // Room data
135
136 // Palette data
140
142
143 // Object preview system
146 bool object_loaded_ = false;
147
148 // Callback for object selection
150 std::function<void(int)> object_double_click_callback_;
151
152 // Object selection state
154 int static_editor_object_id_ = -1; // Object currently open in static editor
155
156 // UI state for object browser filter
158 int object_subtype_tab_ = 0; // 0=Type1, 1=Type2, 2=Type3
159 char object_search_buffer_[64] = {0};
160
161 // Registry initialization flag
163
164 // Performance: enable/disable graphical preview rendering
166
167 // Preview cache for object selector grid
168 // Key: object_id (or object_id+subtype for custom objects)
169 // Value: BackgroundBuffer with rendered preview
170 std::map<uint64_t, std::unique_ptr<gfx::BackgroundBuffer>> preview_cache_;
174
175 std::map<uint32_t, zelda3::ObjectTileLayout> layout_cache_;
176
177 bool GetOrCreatePreview(const zelda3::RoomObject& object, float size,
179};
180
181} // namespace editor
182} // namespace yaze
183
184#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
Handles object selection, preview, and editing UI.
bool GetOrCreatePreview(const zelda3::RoomObject &object, float size, gfx::BackgroundBuffer **out)
void SetCustomObjectsFolder(const std::string &folder)
void CalculateObjectDimensions(const zelda3::RoomObject &object, int &width, int &height)
zelda3::DungeonObjectRegistry object_registry_
std::function< void(int)> object_double_click_callback_
void SetProject(project::YazeProject *project)
std::string GetObjectTypeSymbol(int object_id)
void SetGameData(zelda3::GameData *game_data)
void SetObjectDoubleClickCallback(std::function< void(int)> callback)
bool MatchesObjectSearch(int obj_id, const std::string &name, int subtype=-1) const
void set_rooms(DungeonRoomStore *rooms)
void SetCurrentPaletteGroup(const gfx::PaletteGroup &palette_group)
void SelectObject(int obj_id, int subtype=-1)
void SetCurrentPaletteId(uint64_t palette_id)
const zelda3::RoomObject & GetPreviewObject() const
std::function< void(const zelda3::RoomObject &) object_selected_callback_)
std::map< uint64_t, std::unique_ptr< gfx::BackgroundBuffer > > preview_cache_
void SetTileEditorPanel(ObjectTileEditorPanel *panel)
zelda3::RoomObject MakePreviewObject(int obj_id) const
std::map< uint32_t, zelda3::ObjectTileLayout > layout_cache_
bool DrawObjectPreview(const zelda3::RoomObject &object, ImVec2 top_left, float size)
bool MatchesObjectFilter(int obj_id, int filter_type)
void SetObjectSelectedCallback(std::function< void(const zelda3::RoomObject &)> callback)
Panel for editing the tile8 composition of dungeon objects.
Represents a palette of colors for the Super Nintendo Entertainment System (SNES).
Minimal registry for dungeon objects (vanilla or custom).
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:71
zelda3::GameData * game_data
Definition editor.h:73
Represents a group of palettes.
Modern project structure with comprehensive settings consolidation.
Definition project.h:164