yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
resource_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_RESOURCE_PANEL_H_
2#define YAZE_APP_EDITOR_SYSTEM_RESOURCE_PANEL_H_
3
4#include <string>
5
6#include "absl/strings/str_format.h"
8
9namespace yaze {
10namespace editor {
11
72 public:
73 virtual ~ResourceWindowContent() = default;
74
75 // ==========================================================================
76 // Resource Identity (Required)
77 // ==========================================================================
78
85 virtual int GetResourceId() const = 0;
86
93 virtual std::string GetResourceType() const = 0;
94
102 virtual std::string GetResourceName() const {
103 return absl::StrFormat("%s %d", GetResourceType(), GetResourceId());
104 }
105
106 // ==========================================================================
107 // Window Identity (from WindowContent - auto-generated)
108 // ==========================================================================
109
114 std::string GetId() const override {
115 return absl::StrFormat("%s.%s_%d", GetEditorCategory(), GetResourceType(),
116 GetResourceId());
117 }
118
123 std::string GetDisplayName() const override { return GetResourceName(); }
124
125 // ==========================================================================
126 // Behavior (from WindowContent - resource-specific defaults)
127 // ==========================================================================
128
148
153 virtual bool AllowMultipleInstances() const { return true; }
154
155 // ==========================================================================
156 // Session Support
157 // ==========================================================================
158
167 virtual size_t GetSessionId() const { return session_id_; }
168
173 void SetSessionId(size_t session_id) { session_id_ = session_id; }
174
175 // ==========================================================================
176 // Resource Lifecycle Hooks
177 // ==========================================================================
178
185 virtual void OnResourceModified() {}
186
193 virtual void OnResourceDeleted() {
194 // Default: WorkspaceWindowManager will close this panel
195 }
196
197 protected:
199 size_t session_id_ = 0;
200};
201
212 constexpr size_t kMaxRoomPanels = 8;
213
215 constexpr size_t kMaxSongPanels = 4;
216
218 constexpr size_t kMaxSheetPanels = 6;
219
221 constexpr size_t kMaxMapPanels = 8;
222
224 constexpr size_t kMaxTotalResourcePanels = 20;
225} // namespace ResourcePanelLimits
226
227} // namespace editor
228} // namespace yaze
229
230#endif // YAZE_APP_EDITOR_SYSTEM_RESOURCE_PANEL_H_
Base class for windows that edit specific ROM resources.
std::string GetId() const override
Generated panel ID from resource type and ID.
void SetSessionId(size_t session_id)
Set the session ID for this resource panel.
WindowLifecycle GetWindowLifecycle() const override
Resource windows use CrossEditor lifecycle for opt-in persistence.
std::string GetDisplayName() const override
Generated display name from resource name.
size_t session_id_
Session ID for multi-ROM editing (0 = single session)
virtual void OnResourceDeleted()
Called when resource is deleted from ROM.
virtual ~ResourceWindowContent()=default
virtual bool AllowMultipleInstances() const
Whether multiple instances of this resource type can be open.
virtual std::string GetResourceName() const
Human-readable resource name.
virtual size_t GetSessionId() const
Get the session ID this resource belongs to.
virtual std::string GetResourceType() const =0
The resource type name.
virtual void OnResourceModified()
Called when resource data changes externally.
virtual int GetResourceId() const =0
The numeric ID of the resource.
Base interface for all logical window content components.
virtual std::string GetEditorCategory() const =0
Editor category this panel belongs to.
Default limits for resource panel counts.
constexpr size_t kMaxTotalResourcePanels
Maximum total resource panels across all types.
constexpr size_t kMaxSongPanels
Maximum open song panels (music editor)
constexpr size_t kMaxSheetPanels
Maximum open graphics sheet panels.
constexpr size_t kMaxRoomPanels
Maximum open room panels (dungeon editor)
constexpr size_t kMaxMapPanels
Maximum open map panels (overworld editor)
WindowLifecycle
Defines lifecycle behavior for editor windows.
@ CrossEditor
User can pin to persist across editors.