yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_workbench_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_WORKBENCH_PANEL_H
2#define YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_WORKBENCH_PANEL_H
3
4#include <deque>
5#include <functional>
6#include <string>
7#include <unordered_map>
8
11
12namespace yaze {
13class Rom;
14} // namespace yaze
15
16namespace yaze::editor {
17
18class DungeonCanvasViewer;
19class DungeonRoomSelector;
20enum class RoomSelectionIntent;
21
22// Single stable window for dungeon editing. This is step 2 in the Workbench plan.
24 public:
26 DungeonRoomSelector* room_selector, int* current_room_id,
27 std::function<void(int)> on_room_selected,
28 std::function<void(int, RoomSelectionIntent)>
29 on_room_selected_with_intent,
30 std::function<void(int)> on_save_room,
31 std::function<DungeonCanvasViewer*()> get_viewer,
32 std::function<DungeonCanvasViewer*()> get_compare_viewer,
33 std::function<const std::deque<int>&()> get_recent_rooms,
34 std::function<void(int)> forget_recent_room,
35 std::function<void(const std::string&)> show_panel,
36 std::function<void(bool)> set_workflow_mode, Rom* rom = nullptr);
37
38 std::string GetId() const override;
39 std::string GetDisplayName() const override;
40 std::string GetIcon() const override;
41 std::string GetEditorCategory() const override;
42 int GetPriority() const override;
43
44 void SetRom(Rom* rom);
45
47 void NotifyRoomChanged(int previous_room_id) {
48 previous_room_id_ = previous_room_id;
49 }
50
51 // Wire undo/redo state from the editor's UndoManager.
52 void SetUndoRedoProvider(std::function<bool()> can_undo,
53 std::function<bool()> can_redo,
54 std::function<void()> on_undo,
55 std::function<void()> on_redo,
56 std::function<std::string()> undo_desc,
57 std::function<std::string()> redo_desc,
58 std::function<int()> undo_depth) {
59 can_undo_ = std::move(can_undo);
60 can_redo_ = std::move(can_redo);
61 on_undo_ = std::move(on_undo);
62 on_redo_ = std::move(on_redo);
63 undo_desc_ = std::move(undo_desc);
64 redo_desc_ = std::move(redo_desc);
65 undo_depth_ = std::move(undo_depth);
66 }
67
68 // Wire tool mode name provider (e.g., from DungeonToolset::GetToolModeName).
69 void SetToolModeProvider(std::function<const char*()> provider) {
70 get_tool_mode_ = std::move(provider);
71 }
72
73 void Draw(bool* p_open) override;
74
75 private:
76 void DrawRecentRoomTabs();
77 void DrawSplitView(DungeonCanvasViewer& primary_viewer);
84
85 // Lazily build a room_id → dungeon_name cache from ROM entrance tables so the
86 // room badge can show accurate group context for custom Oracle dungeons.
88
90 int* current_room_id_ = nullptr;
91
92 // Workbench-owned UI state (was in DungeonEditorV2, moved here Phase 6.2).
94 bool split_view_enabled_ = false;
97 std::function<void(int)> on_room_selected_;
99 std::function<void(int)> on_save_room_;
102 std::function<const std::deque<int>&()> get_recent_rooms_;
103 std::function<void(int)> forget_recent_room_;
104 std::function<void(const std::string&)> show_panel_;
105 std::function<void(bool)> set_workflow_mode_;
106 Rom* rom_ = nullptr;
107
108 char compare_search_buf_[64] = {};
109
110 // Track collapse→expand transitions for one-shot column width reset
111 bool prev_show_left_ = true;
112 bool prev_show_right_ = true;
114
115 // ROM-based room→dungeon group label cache (lazy-built on first room render).
116 std::unordered_map<int, std::string> room_dungeon_cache_;
118
119 // Undo/redo providers (set via SetUndoRedoProvider).
120 std::function<bool()> can_undo_;
121 std::function<bool()> can_redo_;
122 std::function<void()> on_undo_;
123 std::function<void()> on_redo_;
124 std::function<std::string()> undo_desc_;
125 std::function<std::string()> redo_desc_;
126 std::function<int()> undo_depth_;
127
128 // Tool mode name provider (set via SetToolModeProvider).
129 std::function<const char*()> get_tool_mode_;
130
131 // Shortcut legend toggle.
133};
134
135} // namespace yaze::editor
136
137#endif // YAZE_APP_EDITOR_DUNGEON_PANELS_DUNGEON_WORKBENCH_PANEL_H
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 NotifyRoomChanged(int previous_room_id)
Called by the editor when the current room changes.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
std::function< void(const std::string &) show_panel_)
void DrawInspectorShelfView(DungeonCanvasViewer &viewer)
DungeonWorkbenchPanel(DungeonRoomSelector *room_selector, int *current_room_id, std::function< void(int)> on_room_selected, std::function< void(int, RoomSelectionIntent)> on_room_selected_with_intent, std::function< void(int)> on_save_room, std::function< DungeonCanvasViewer *()> get_viewer, std::function< DungeonCanvasViewer *()> get_compare_viewer, std::function< const std::deque< int > &()> get_recent_rooms, std::function< void(int)> forget_recent_room, std::function< void(const std::string &)> show_panel, std::function< void(bool)> set_workflow_mode, Rom *rom=nullptr)
void DrawInspectorShelf(DungeonCanvasViewer &viewer)
DungeonWorkbenchLayoutState layout_state_
std::string GetIcon() const override
Material Design icon for this panel.
std::function< const char *()> get_tool_mode_
std::function< DungeonCanvasViewer *()> get_compare_viewer_
void DrawSplitView(DungeonCanvasViewer &primary_viewer)
std::function< const std::deque< int > &()> get_recent_rooms_
std::function< void(int, RoomSelectionIntent)> on_room_selected_with_intent_
void DrawInspector(DungeonCanvasViewer &viewer)
void DrawInspectorShelfRoom(DungeonCanvasViewer &viewer)
std::unordered_map< int, std::string > room_dungeon_cache_
int GetPriority() const override
Get display priority for menu ordering.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::function< std::string()> redo_desc_
void SetUndoRedoProvider(std::function< bool()> can_undo, std::function< bool()> can_redo, std::function< void()> on_undo, std::function< void()> on_redo, std::function< std::string()> undo_desc, std::function< std::string()> redo_desc, std::function< int()> undo_depth)
std::string GetId() const override
Unique identifier for this panel.
void Draw(bool *p_open) override
Draw the panel content.
void DrawInspectorShelfTools(DungeonCanvasViewer &viewer)
void SetToolModeProvider(std::function< const char *()> provider)
void DrawInspectorShelfSelection(DungeonCanvasViewer &viewer)
std::function< void(bool)> set_workflow_mode_
std::function< DungeonCanvasViewer *()> get_viewer_
std::function< std::string()> undo_desc_
Base interface for all logical panel components.
Editors are the view controllers for the application.
RoomSelectionIntent
Intent for room selection in the dungeon editor.