yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_room_selector.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
2#define YAZE_APP_EDITOR_DUNGEON_DUNGEON_ROOM_SELECTOR_H
3
4#include <functional>
5#include <string>
6#include <vector>
7
9#include "app/editor/editor.h"
10#include "imgui/imgui.h"
11#include "rom/rom.h"
12#include "zelda3/dungeon/room.h"
14#include "zelda3/game_data.h"
15
16namespace yaze {
17namespace editor {
18
23 kFocusInWorkbench, // Default: navigate workbench to this room
24 kOpenStandalone, // Open as separate panel (even in workbench mode)
25 kPreview, // Update state only, don't show/focus panels
26};
27
32 public:
33 explicit DungeonRoomSelector(Rom* rom = nullptr) : rom_(rom) {}
34
35 void Draw();
36 void DrawRoomSelector(RoomSelectionIntent single_click_intent =
38 void DrawRoomBrowser(RoomSelectionIntent single_click_intent =
42
43 // Unified context setter (preferred)
45 rom_ = ctx.rom;
47 }
48 EditorContext context() const { return {rom_, game_data_}; }
49
50 // Individual setters for compatibility
51 void SetRom(Rom* rom) { rom_ = rom; }
52 Rom* rom() const { return rom_; }
55
56 // Room selection
57 void set_current_room_id(uint16_t room_id) { current_room_id_ = room_id; }
58 int current_room_id() const { return current_room_id_; }
59
60 void set_active_rooms(const ImVector<int>& rooms) { active_rooms_ = rooms; }
61 const ImVector<int>& active_rooms() const { return active_rooms_; }
62 ImVector<int>& mutable_active_rooms() { return active_rooms_; }
63
64 // Entrance selection
65 void set_current_entrance_id(int entrance_id) {
66 current_entrance_id_ = entrance_id;
67 }
69
70 // Room data access
71 void set_rooms(DungeonRoomStore* rooms) { rooms_ = rooms; }
72 void set_entrances(std::array<zelda3::RoomEntrance, 0x8C>* entrances) {
73 entrances_ = entrances;
74 }
75
76 // Callback for room selection events (single-click / default)
77 void SetRoomSelectedCallback(std::function<void(int)> callback) {
78 room_selected_callback_ = std::move(callback);
79 }
80 [[deprecated("Use SetRoomSelectedCallback() instead")]]
81 void set_room_selected_callback(std::function<void(int)> callback) {
82 SetRoomSelectedCallback(std::move(callback));
83 }
84
85 // Intent-aware room selection callback (double-click, context menu)
87 std::function<void(int, RoomSelectionIntent)> callback) {
88 room_intent_callback_ = std::move(callback);
89 }
90
91 // Callback for entrance selection events (triggers room opening)
92 void SetEntranceSelectedCallback(std::function<void(int)> callback) {
93 entrance_selected_callback_ = std::move(callback);
94 }
95 [[deprecated("Use SetEntranceSelectedCallback() instead")]]
96 void set_entrance_selected_callback(std::function<void(int)> callback) {
97 SetEntranceSelectedCallback(std::move(callback));
98 }
99
100 // Get dungeon name from blockset value (public utility)
101 static const char* GetBlocksetGroupName(uint8_t blockset);
102
103 private:
104 Rom* rom_ = nullptr;
106 uint16_t current_room_id_ = 0;
108 ImVector<int> active_rooms_;
109
111 std::array<zelda3::RoomEntrance, 0x8C>* entrances_ = nullptr;
112
113 // Callback for room selection events (single-click / default)
114 std::function<void(int)> room_selected_callback_;
115
116 // Intent-aware room selection callback (double-click, context menu)
118
119 // Callback for entrance selection events
120 std::function<void(int)> entrance_selected_callback_;
121
122 ImGuiTextFilter room_filter_;
123 ImGuiTextFilter entrance_filter_;
124
125 // View mode for room list
126 enum ViewMode : uint8_t {
127 kViewList = 0, // Flat list (original)
128 kViewGrouped = 1, // Grouped by dungeon/blockset
129 };
131
132 // Object-type filter for room list (especially useful on iOS)
133 // When enabled, only rooms containing the selected entity types are shown
141
142 // Cached filtered indices for virtualization
143 std::vector<int> filtered_room_indices_;
145 std::string last_room_filter_;
147
150 bool PassesEntityTypeFilter(int room_id) const;
151 void DrawRoomSelectorInternal(RoomSelectionIntent single_click_intent,
152 bool show_room_id_input);
153 void DrawEntranceSelectorInternal(bool show_properties);
154
155 // Draw the grouped-by-dungeon view
156 void DrawGroupedRoomList(RoomSelectionIntent single_click_intent);
157};
158
159} // namespace editor
160} // namespace yaze
161
162#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 room and entrance selection UI.
void set_entrances(std::array< zelda3::RoomEntrance, 0x8C > *entrances)
void DrawEntranceSelectorInternal(bool show_properties)
void SetRoomSelectedWithIntentCallback(std::function< void(int, RoomSelectionIntent)> callback)
void set_entrance_selected_callback(std::function< void(int)> callback)
void DrawGroupedRoomList(RoomSelectionIntent single_click_intent)
void SetGameData(zelda3::GameData *game_data)
void SetEntranceSelectedCallback(std::function< void(int)> callback)
const ImVector< int > & active_rooms() const
void DrawRoomSelectorInternal(RoomSelectionIntent single_click_intent, bool show_room_id_input)
void set_current_entrance_id(int entrance_id)
void set_rooms(DungeonRoomStore *rooms)
void set_room_selected_callback(std::function< void(int)> callback)
void DrawRoomSelector(RoomSelectionIntent single_click_intent=RoomSelectionIntent::kFocusInWorkbench)
std::array< zelda3::RoomEntrance, 0x8C > * entrances_
void DrawRoomBrowser(RoomSelectionIntent single_click_intent=RoomSelectionIntent::kFocusInWorkbench)
bool PassesEntityTypeFilter(int room_id) const
std::function< void(int)> room_selected_callback_
void SetRoomSelectedCallback(std::function< void(int)> callback)
std::function< void(int, RoomSelectionIntent)> room_intent_callback_
static const char * GetBlocksetGroupName(uint8_t blockset)
void set_active_rooms(const ImVector< int > &rooms)
zelda3::GameData * game_data() const
std::function< void(int)> entrance_selected_callback_
RoomSelectionIntent
Intent for room selection in the dungeon editor.
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:71
zelda3::GameData * game_data
Definition editor.h:73