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
8#include "app/editor/editor.h"
9#include "imgui/imgui.h"
10#include "rom/rom.h"
11#include "zelda3/dungeon/room.h"
13#include "zelda3/game_data.h"
14
15namespace yaze {
16namespace editor {
17
22 kFocusInWorkbench, // Default: navigate workbench to this room
23 kOpenStandalone, // Open as separate panel (even in workbench mode)
24 kPreview, // Update state only, don't show/focus panels
25};
26
31 public:
32 explicit DungeonRoomSelector(Rom* rom = nullptr) : rom_(rom) {}
33
34 void Draw();
35 void DrawRoomSelector(RoomSelectionIntent single_click_intent =
38
39 // Unified context setter (preferred)
41 rom_ = ctx.rom;
43 }
44 EditorContext context() const { return {rom_, game_data_}; }
45
46 // Individual setters for compatibility
47 void SetRom(Rom* rom) { rom_ = rom; }
48 Rom* rom() const { return rom_; }
51
52 // Room selection
53 void set_current_room_id(uint16_t room_id) { current_room_id_ = room_id; }
54 int current_room_id() const { return current_room_id_; }
55
56 void set_active_rooms(const ImVector<int>& rooms) { active_rooms_ = rooms; }
57 const ImVector<int>& active_rooms() const { return active_rooms_; }
58 ImVector<int>& mutable_active_rooms() { return active_rooms_; }
59
60 // Entrance selection
61 void set_current_entrance_id(int entrance_id) {
62 current_entrance_id_ = entrance_id;
63 }
65
66 // Room data access
67 void set_rooms(std::array<zelda3::Room, 0x128>* rooms) { rooms_ = rooms; }
68 void set_entrances(std::array<zelda3::RoomEntrance, 0x8C>* entrances) {
69 entrances_ = entrances;
70 }
71
72 // Callback for room selection events (single-click / default)
73 void SetRoomSelectedCallback(std::function<void(int)> callback) {
74 room_selected_callback_ = std::move(callback);
75 }
76 [[deprecated("Use SetRoomSelectedCallback() instead")]]
77 void set_room_selected_callback(std::function<void(int)> callback) {
78 SetRoomSelectedCallback(std::move(callback));
79 }
80
81 // Intent-aware room selection callback (double-click, context menu)
83 std::function<void(int, RoomSelectionIntent)> callback) {
84 room_intent_callback_ = std::move(callback);
85 }
86
87 // Callback for entrance selection events (triggers room opening)
88 void SetEntranceSelectedCallback(std::function<void(int)> callback) {
89 entrance_selected_callback_ = std::move(callback);
90 }
91 [[deprecated("Use SetEntranceSelectedCallback() instead")]]
92 void set_entrance_selected_callback(std::function<void(int)> callback) {
93 SetEntranceSelectedCallback(std::move(callback));
94 }
95
96 // Get dungeon name from blockset value (public utility)
97 static const char* GetBlocksetGroupName(uint8_t blockset);
98
99 private:
100 Rom* rom_ = nullptr;
102 uint16_t current_room_id_ = 0;
104 ImVector<int> active_rooms_;
105
106 std::array<zelda3::Room, 0x128>* rooms_ = nullptr;
107 std::array<zelda3::RoomEntrance, 0x8C>* entrances_ = nullptr;
108
109 // Callback for room selection events (single-click / default)
110 std::function<void(int)> room_selected_callback_;
111
112 // Intent-aware room selection callback (double-click, context menu)
114
115 // Callback for entrance selection events
116 std::function<void(int)> entrance_selected_callback_;
117
118 ImGuiTextFilter room_filter_;
119 ImGuiTextFilter entrance_filter_;
120
121 // View mode for room list
122 enum ViewMode : uint8_t {
123 kViewList = 0, // Flat list (original)
124 kViewGrouped = 1, // Grouped by dungeon/blockset
125 };
127
128 // Object-type filter for room list (especially useful on iOS)
129 // When enabled, only rooms containing the selected entity types are shown
137
138 // Cached filtered indices for virtualization
139 std::vector<int> filtered_room_indices_;
141 std::string last_room_filter_;
143
146 bool PassesEntityTypeFilter(int room_id) const;
147
148 // Draw the grouped-by-dungeon view
149 void DrawGroupedRoomList(RoomSelectionIntent single_click_intent);
150};
151
152} // namespace editor
153} // namespace yaze
154
155#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 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 set_current_entrance_id(int entrance_id)
void set_room_selected_callback(std::function< void(int)> callback)
void DrawRoomSelector(RoomSelectionIntent single_click_intent=RoomSelectionIntent::kFocusInWorkbench)
std::array< zelda3::RoomEntrance, 0x8C > * entrances_
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)
std::array< zelda3::Room, 0x128 > * rooms_
void set_active_rooms(const ImVector< int > &rooms)
zelda3::GameData * game_data() const
std::function< void(int)> entrance_selected_callback_
void set_rooms(std::array< zelda3::Room, 0x128 > *rooms)
RoomSelectionIntent
Intent for room selection in the dungeon editor.
Lightweight view into the essential runtime context (Rom + GameData)
Definition editor.h:70
zelda3::GameData * game_data
Definition editor.h:72