yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
dungeon_workbench_content.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_WORKSPACE_DUNGEON_WORKBENCH_CONTENT_H
2#define YAZE_APP_EDITOR_DUNGEON_WORKSPACE_DUNGEON_WORKBENCH_CONTENT_H
3
4#include <cstdint>
5#include <deque>
6#include <functional>
7#include <string>
8#include <unordered_map>
9
12
13namespace yaze {
14class Rom;
15} // namespace yaze
16
17namespace yaze::editor {
18
19class DungeonCanvasViewer;
20class DungeonRoomSelector;
21enum class RoomSelectionIntent;
22
23// Single stable window for dungeon editing. This is step 2 in the Workbench plan.
25 public:
27 DungeonRoomSelector* room_selector, int* current_room_id,
28 std::function<void(int)> on_room_selected,
29 std::function<void(int, RoomSelectionIntent)>
30 on_room_selected_with_intent,
31 std::function<void(int)> on_save_room,
32 std::function<DungeonCanvasViewer*()> get_viewer,
33 std::function<DungeonCanvasViewer*()> get_compare_viewer,
34 std::function<const std::deque<int>&()> get_recent_rooms,
35 std::function<void(int)> forget_recent_room,
36 std::function<void(const std::string&)> show_panel,
37 std::function<void(bool)> set_workflow_mode, Rom* rom = nullptr);
38
39 std::string GetId() const override;
40 std::string GetDisplayName() const override;
41 std::string GetIcon() const override;
42 std::string GetEditorCategory() const override;
43 int GetPriority() const override;
44
45 void SetRom(Rom* rom);
46
48 void NotifyRoomChanged(int previous_room_id) {
49 previous_room_id_ = previous_room_id;
50 }
51
52 // Wire undo/redo state from the editor's UndoManager.
53 void SetUndoRedoProvider(std::function<bool()> can_undo,
54 std::function<bool()> can_redo,
55 std::function<void()> on_undo,
56 std::function<void()> on_redo,
57 std::function<std::string()> undo_desc,
58 std::function<std::string()> redo_desc,
59 std::function<int()> undo_depth) {
60 can_undo_ = std::move(can_undo);
61 can_redo_ = std::move(can_redo);
62 on_undo_ = std::move(on_undo);
63 on_redo_ = std::move(on_redo);
64 undo_desc_ = std::move(undo_desc);
65 redo_desc_ = std::move(redo_desc);
66 undo_depth_ = std::move(undo_depth);
67 }
68
69 // Wire tool mode name provider (e.g., from DungeonToolset::GetToolModeName).
70 void SetToolModeProvider(std::function<const char*()> provider) {
71 get_tool_mode_ = std::move(provider);
72 }
73
74 void Draw(bool* p_open) override;
75
76 private:
77 void DrawRecentRoomTabs();
78 void DrawSidebarPane(float width, float height, float button_size,
79 bool compact);
80 void DrawSidebarHeader(float button_size, bool compact);
81 void DrawSidebarModeTabs(bool stacked, float segment_height);
82 void DrawSidebarContent();
83 void DrawCanvasPane(float width, float height,
84 DungeonCanvasViewer* primary_viewer,
85 bool left_sidebar_visible);
86 void DrawSplitView(DungeonCanvasViewer& primary_viewer);
87 void DrawInspectorPane(float width, float height, float button_size,
88 bool compact, DungeonCanvasViewer* viewer);
89 void DrawInspectorHeader(float button_size, bool compact);
91 void DrawInspectorPrimarySelector(float segment_height);
98
99 // Lazily build a room_id → dungeon_name cache from ROM entrance tables so the
100 // room badge can show accurate group context for custom Oracle dungeons.
102
104 int* current_room_id_ = nullptr;
105
106 // Workbench-owned UI state (was in DungeonEditorV2, moved here Phase 6.2).
111 std::function<void(int)> on_room_selected_;
113 std::function<void(int)> on_save_room_;
116 std::function<const std::deque<int>&()> get_recent_rooms_;
117 std::function<void(int)> forget_recent_room_;
118 std::function<void(const std::string&)> show_panel_;
119 std::function<void(bool)> set_workflow_mode_;
120 Rom* rom_ = nullptr;
121
122 enum class SidebarMode : uint8_t { Rooms, Entrances };
124 enum class InspectorFocus : uint8_t { Room, Selection };
126
127 char compare_search_buf_[64] = {};
128
129 // ROM-based room→dungeon group label cache (lazy-built on first room render).
130 std::unordered_map<int, std::string> room_dungeon_cache_;
132
133 // Undo/redo providers (set via SetUndoRedoProvider).
134 std::function<bool()> can_undo_;
135 std::function<bool()> can_redo_;
136 std::function<void()> on_undo_;
137 std::function<void()> on_redo_;
138 std::function<std::string()> undo_desc_;
139 std::function<std::string()> redo_desc_;
140 std::function<int()> undo_depth_;
141
142 // Tool mode name provider (set via SetToolModeProvider).
143 std::function<const char*()> get_tool_mode_;
144
145 // Shortcut legend toggle.
147};
148
149} // namespace yaze::editor
150
151#endif // YAZE_APP_EDITOR_DUNGEON_WORKSPACE_DUNGEON_WORKBENCH_CONTENT_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 DrawInspectorShelfSelection(DungeonCanvasViewer &viewer)
int GetPriority() const override
Get display priority for menu ordering.
std::function< DungeonCanvasViewer *()> get_compare_viewer_
void DrawInspectorHeader(float button_size, bool compact)
void DrawInspectorCompactSummary(DungeonCanvasViewer &viewer)
void DrawSidebarModeTabs(bool stacked, float segment_height)
void DrawInspectorPrimarySelector(float segment_height)
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)
void DrawSidebarPane(float width, float height, float button_size, bool compact)
void DrawInspectorShelf(DungeonCanvasViewer &viewer)
void DrawInspectorPane(float width, float height, float button_size, bool compact, DungeonCanvasViewer *viewer)
void DrawInspectorShelfRoom(DungeonCanvasViewer &viewer)
void DrawInspectorShelfView(DungeonCanvasViewer &viewer)
std::function< void(const std::string &) show_panel_)
void SetToolModeProvider(std::function< const char *()> provider)
std::string GetEditorCategory() const override
Editor category this panel belongs to.
void DrawInspectorShelfTools(DungeonCanvasViewer &viewer)
void DrawCanvasPane(float width, float height, DungeonCanvasViewer *primary_viewer, bool left_sidebar_visible)
void DrawSidebarHeader(float button_size, bool compact)
DungeonWorkbenchContent(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)
std::function< void(int, RoomSelectionIntent)> on_room_selected_with_intent_
void NotifyRoomChanged(int previous_room_id)
Called by the editor when the current room changes.
std::string GetId() const override
Unique identifier for this panel.
void DrawSplitView(DungeonCanvasViewer &primary_viewer)
std::string GetIcon() const override
Material Design icon for this panel.
std::unordered_map< int, std::string > room_dungeon_cache_
std::function< const char *()> get_tool_mode_
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void Draw(bool *p_open) override
Draw the panel content.
std::function< const std::deque< int > &()> get_recent_rooms_
void DrawInspector(DungeonCanvasViewer &viewer)
std::function< DungeonCanvasViewer *()> get_viewer_
Base interface for all logical window content components.
Editors are the view controllers for the application.
RoomSelectionIntent
Intent for room selection in the dungeon editor.