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 ResourcePanel : public EditorPanel {
72 public:
73 virtual ~ResourcePanel() = 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 // Panel Identity (from EditorPanel - 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 EditorPanel - resource-specific defaults)
127 // ==========================================================================
128
147 }
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: PanelManager 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 interface for all logical panel components.
virtual std::string GetEditorCategory() const =0
Editor category this panel belongs to.
Base class for panels that edit specific ROM resources.
virtual size_t GetSessionId() const
Get the session ID this resource belongs to.
virtual int GetResourceId() const =0
The numeric ID of the resource.
std::string GetDisplayName() const override
Generated display name from resource name.
virtual void OnResourceModified()
Called when resource data changes externally.
size_t session_id_
Session ID for multi-ROM editing (0 = single session)
virtual std::string GetResourceType() const =0
The resource type name.
virtual std::string GetResourceName() const
Human-readable resource name.
virtual ~ResourcePanel()=default
std::string GetId() const override
Generated panel ID from resource type and ID.
virtual void OnResourceDeleted()
Called when resource is deleted from ROM.
virtual bool AllowMultipleInstances() const
Whether multiple instances of this resource type can be open.
void SetSessionId(size_t session_id)
Set the session ID for this resource panel.
PanelCategory GetPanelCategory() const override
Resource panels use CrossEditor category for opt-in persistence.
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)
PanelCategory
Defines lifecycle behavior for editor panels.
@ CrossEditor
User can pin to persist across editors.