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
71class ResourceWindowContent : public WindowContent {
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
159
164 virtual bool AllowMultipleInstances() const { return true; }
165
166 // ==========================================================================
167 // Session Support
168 // ==========================================================================
169
178 virtual size_t GetSessionId() const { return session_id_; }
179
184 void SetSessionId(size_t session_id) { session_id_ = session_id; }
185
186 // ==========================================================================
187 // Resource Lifecycle Hooks
188 // ==========================================================================
189
196 virtual void OnResourceModified() {}
197
204 virtual void OnResourceDeleted() {
205 // Default: WorkspaceWindowManager will close this panel
206 }
207
208 protected:
210 size_t session_id_ = 0;
211};
212
221namespace ResourcePanelLimits {
223constexpr size_t kMaxRoomPanels = 8;
224
226constexpr size_t kMaxSongPanels = 4;
227
229constexpr size_t kMaxSheetPanels = 6;
230
232constexpr size_t kMaxMapPanels = 8;
233
235constexpr size_t kMaxTotalResourcePanels = 20;
236} // namespace ResourcePanelLimits
237
238} // namespace editor
239} // namespace yaze
240
241#endif // YAZE_APP_EDITOR_SYSTEM_RESOURCE_PANEL_H_
std::string GetId() const override
Generated panel ID from resource type and ID.
WindowPresentationPolicy GetPresentationPolicy() const override
Resource windows open on demand, so they are optional pop-outs.
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.
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.
static WindowPresentationPolicy OptionalPopOut()