yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::editor::ResourceWindowContent Class Referenceabstract

Base class for windows that edit specific ROM resources. More...

#include <resource_panel.h>

Inheritance diagram for yaze::editor::ResourceWindowContent:
Collaboration diagram for yaze::editor::ResourceWindowContent:

Public Member Functions

virtual ~ResourceWindowContent ()=default
 
virtual int GetResourceId () const =0
 The numeric ID of the resource.
 
virtual std::string GetResourceType () const =0
 The resource type name.
 
virtual std::string GetResourceName () const
 Human-readable resource name.
 
std::string GetId () const override
 Generated panel ID from resource type and ID.
 
std::string GetDisplayName () const override
 Generated display name from resource name.
 
WindowLifecycle GetWindowLifecycle () const override
 Resource windows use CrossEditor lifecycle for opt-in persistence.
 
virtual bool AllowMultipleInstances () const
 Whether multiple instances of this resource type can be open.
 
virtual size_t GetSessionId () const
 Get the session ID this resource belongs to.
 
void SetSessionId (size_t session_id)
 Set the session ID for this resource panel.
 
virtual void OnResourceModified ()
 Called when resource data changes externally.
 
virtual void OnResourceDeleted ()
 Called when resource is deleted from ROM.
 
virtual ~ResourceWindowContent ()=default
 
virtual int GetResourceId () const =0
 The numeric ID of the resource.
 
virtual std::string GetResourceType () const =0
 The resource type name.
 
virtual std::string GetResourceName () const
 Human-readable resource name.
 
std::string GetId () const override
 Generated panel ID from resource type and ID.
 
std::string GetDisplayName () const override
 Generated display name from resource name.
 
WindowLifecycle GetWindowLifecycle () const override
 Resource windows use CrossEditor lifecycle for opt-in persistence.
 
virtual bool AllowMultipleInstances () const
 Whether multiple instances of this resource type can be open.
 
virtual size_t GetSessionId () const
 Get the session ID this resource belongs to.
 
void SetSessionId (size_t session_id)
 Set the session ID for this resource panel.
 
virtual void OnResourceModified ()
 Called when resource data changes externally.
 
virtual void OnResourceDeleted ()
 Called when resource is deleted from ROM.
 
- Public Member Functions inherited from yaze::editor::WindowContent
virtual ~WindowContent ()=default
 
virtual std::string GetIcon () const =0
 Material Design icon for this panel.
 
virtual std::string GetEditorCategory () const =0
 Editor category this panel belongs to.
 
virtual void Draw (bool *p_open)=0
 Draw the panel content.
 
virtual void OnFirstDraw ()
 Called once before the first Draw() in a session.
 
virtual bool RequiresLazyInit () const
 Whether this panel uses lazy initialization.
 
void InvalidateLazyInit ()
 Reset lazy init state so OnFirstDraw() runs again.
 
virtual void OnOpen ()
 Called when panel becomes visible.
 
virtual void OnClose ()
 Called when panel is hidden.
 
virtual void OnFocus ()
 Called when panel receives focus.
 
virtual WindowContextScope GetContextScope () const
 Optional context binding for this window (room/selection/etc)
 
virtual WindowScope GetScope () const
 Get the registration scope for this window.
 
virtual bool IsEnabled () const
 Check if this panel is currently enabled.
 
virtual std::string GetDisabledTooltip () const
 Get tooltip text when panel is disabled.
 
virtual std::string GetShortcutHint () const
 Get keyboard shortcut hint for display.
 
virtual int GetPriority () const
 Get display priority for menu ordering.
 
virtual std::string GetWorkflowGroup () const
 Optional workflow group for hack-centric actions.
 
virtual std::string GetWorkflowLabel () const
 Optional workflow label for menus/command palette.
 
virtual std::string GetWorkflowDescription () const
 Optional workflow description for menus/command palette.
 
virtual int GetWorkflowPriority () const
 Optional workflow ordering priority (lower sorts first).
 
virtual float GetPreferredWidth () const
 Get preferred width for this panel (optional)
 
virtual bool PreferAutoHideTabBar () const
 Whether the dock node hosting this panel should auto-hide its tab bar.
 
virtual bool IsVisibleByDefault () const
 Whether this panel should be visible by default.
 
virtual std::string GetParentPanelId () const
 Get parent panel ID for cascade behavior.
 
virtual bool CascadeCloseChildren () const
 Whether closing this panel should close child panels.
 
void DrawWithLazyInit (bool *p_open)
 Execute lazy initialization if needed, then call Draw()
 

Protected Attributes

size_t session_id_ = 0
 Session ID for multi-ROM editing (0 = single session)
 

Additional Inherited Members

- Protected Member Functions inherited from yaze::editor::WindowContent
void InvalidateCache ()
 Invalidate all cached computations.
 
template<typename T >
T & GetCached (const std::string &key, std::function< T()> compute)
 Get or compute a cached value.
 
bool IsCacheValid () const
 Check if cache has been invalidated.
 
void ClearCache ()
 Clear all cached values (more aggressive than InvalidateCache)
 

Detailed Description

Base class for windows that edit specific ROM resources.

A ResourceWindowContent represents a window for editing a specific piece of data within a ROM, such as a dungeon room, a song, or a graphics sheet.

Key Features:

  • Session-aware: Can distinguish between same resource in different ROMs
  • Multi-instance: Multiple resources can be open simultaneously
  • LRU managed: Oldest panels auto-close when limit reached

Panel ID Format

Resource panel IDs follow a specific format:

[{session}.]{category}.{resource_type}_{resource_id}[.{subpanel}]
Examples:
dungeon.room_42 -- Room 42 (single session)
s0.dungeon.room_42 -- Room 42 in session 0 (multi-session)
s1.dungeon.room_42 -- Room 42 in session 1 (different ROM)
music.song_5.piano_roll -- Piano roll subpanel for song 5

Subclasses

Typical subclasses include:

  • DungeonRoomPanel: Edits a specific room (0-295)
  • MusicSongPanel: Edits a specific song with tracker/piano roll
  • GraphicsSheetPanel: Edits a specific GFX sheet
  • OverworldMapPanel: Edits a specific overworld map

Implementation

public:
DungeonRoomPanel(size_t session_id, int room_id, zelda3::Room* room)
: room_id_(room_id), room_(room) {
session_id_ = session_id;
}
int GetResourceId() const override { return room_id_; }
std::string GetResourceType() const override { return "room"; }
std::string GetIcon() const override { return ICON_MD_DOOR_FRONT; }
std::string GetEditorCategory() const override { return "Dungeon"; }
void Draw(bool* p_open) override {
// Draw room canvas with objects, sprites, etc.
DrawRoomCanvas();
}
private:
int room_id_;
zelda3::Room* room_;
};
ResourceWindowContent for editing individual dungeon rooms.
Base class for windows that edit specific ROM resources.
#define ICON_MD_DOOR_FRONT
Definition icons.h:613
See also
WindowContent - Base interface for all windows
WorkspaceWindowManager - Manages resource panel lifecycle and limits

Definition at line 71 of file resource_panel.h.

Constructor & Destructor Documentation

◆ ~ResourceWindowContent() [1/2]

virtual yaze::editor::ResourceWindowContent::~ResourceWindowContent ( )
virtualdefault

◆ ~ResourceWindowContent() [2/2]

virtual yaze::editor::ResourceWindowContent::~ResourceWindowContent ( )
virtualdefault

Member Function Documentation

◆ GetResourceId() [1/2]

virtual int yaze::editor::ResourceWindowContent::GetResourceId ( ) const
pure virtual

The numeric ID of the resource.

Returns
Resource ID (room_id, song_index, sheet_id, map_id, etc.)

This is the primary key for the resource within its type.

Implemented in yaze::editor::DungeonRoomPanel.

Referenced by GetId(), and GetResourceName().

◆ GetResourceType() [1/2]

virtual std::string yaze::editor::ResourceWindowContent::GetResourceType ( ) const
pure virtual

The resource type name.

Returns
Type string (e.g., "room", "song", "sheet", "map")

Used in panel ID generation and display.

Implemented in yaze::editor::DungeonRoomPanel.

Referenced by GetId(), GetResourceName(), and yaze::editor::WorkspaceWindowManager::TrackResourceWindow().

◆ GetResourceName() [1/2]

virtual std::string yaze::editor::ResourceWindowContent::GetResourceName ( ) const
inlinevirtual

Human-readable resource name.

Returns
Friendly name (e.g., "Hyrule Castle Entrance", "Overworld Theme")

Default implementation returns "{type} {id}". Override to provide game-specific names from ROM data.

Reimplemented in yaze::editor::DungeonRoomPanel.

Definition at line 102 of file resource_panel.h.

References GetResourceId(), and GetResourceType().

Referenced by GetDisplayName().

Here is the call graph for this function:

◆ GetId() [1/2]

std::string yaze::editor::ResourceWindowContent::GetId ( ) const
inlineoverridevirtual

Generated panel ID from resource type and ID.

Returns
ID in format "{category}.{type}_{id}"

Implements yaze::editor::WindowContent.

Definition at line 114 of file resource_panel.h.

References yaze::editor::WindowContent::GetEditorCategory(), GetResourceId(), and GetResourceType().

Here is the call graph for this function:

◆ GetDisplayName() [1/2]

std::string yaze::editor::ResourceWindowContent::GetDisplayName ( ) const
inlineoverridevirtual

Generated display name from resource name.

Returns
The resource name

Implements yaze::editor::WindowContent.

Definition at line 123 of file resource_panel.h.

References GetResourceName().

Here is the call graph for this function:

◆ GetWindowLifecycle() [1/2]

WindowLifecycle yaze::editor::ResourceWindowContent::GetWindowLifecycle ( ) const
inlineoverridevirtual

Resource windows use CrossEditor lifecycle for opt-in persistence.

Returns
WindowLifecycle::CrossEditor

Resource panels (rooms, songs, etc.) can be pinned to persist across editor switches. By default, they're NOT pinned and will be hidden (but not closed) when switching to another editor.

Pin behavior:

  • Open a room → NOT pinned, hidden when switching editors
  • Pin it → stays visible across all editors
  • Unpin it → hidden when switching editors
  • Close via X → fully removed regardless of pin state

The drawing loops in each editor handle the category filtering.

Reimplemented from yaze::editor::WindowContent.

Definition at line 145 of file resource_panel.h.

References yaze::editor::CrossEditor.

◆ AllowMultipleInstances() [1/2]

virtual bool yaze::editor::ResourceWindowContent::AllowMultipleInstances ( ) const
inlinevirtual

Whether multiple instances of this resource type can be open.

Returns
true to allow multiple (default), false for singleton behavior

Definition at line 153 of file resource_panel.h.

◆ GetSessionId() [1/2]

virtual size_t yaze::editor::ResourceWindowContent::GetSessionId ( ) const
inlinevirtual

Get the session ID this resource belongs to.

Returns
Session ID (0 for single-ROM mode)

In multi-ROM editing mode, each loaded ROM gets a session ID. This allows the same resource (e.g., room 42) to be open for different ROMs simultaneously.

Definition at line 167 of file resource_panel.h.

References session_id_.

◆ SetSessionId() [1/2]

void yaze::editor::ResourceWindowContent::SetSessionId ( size_t session_id)
inline

Set the session ID for this resource panel.

Parameters
session_idThe session ID to set

Definition at line 173 of file resource_panel.h.

References session_id_.

◆ OnResourceModified() [1/2]

virtual void yaze::editor::ResourceWindowContent::OnResourceModified ( )
inlinevirtual

Called when resource data changes externally.

Override to refresh panel state when the underlying ROM data is modified by another editor or operation.

Reimplemented in yaze::editor::DungeonRoomPanel.

Definition at line 185 of file resource_panel.h.

◆ OnResourceDeleted() [1/2]

virtual void yaze::editor::ResourceWindowContent::OnResourceDeleted ( )
inlinevirtual

Called when resource is deleted from ROM.

Default behavior: the panel should be closed. Override to implement custom cleanup or warnings.

Definition at line 193 of file resource_panel.h.

◆ GetResourceId() [2/2]

virtual int yaze::editor::ResourceWindowContent::GetResourceId ( ) const
pure virtual

The numeric ID of the resource.

Returns
Resource ID (room_id, song_index, sheet_id, map_id, etc.)

This is the primary key for the resource within its type.

Implemented in yaze::editor::DungeonRoomPanel.

◆ GetResourceType() [2/2]

virtual std::string yaze::editor::ResourceWindowContent::GetResourceType ( ) const
pure virtual

The resource type name.

Returns
Type string (e.g., "room", "song", "sheet", "map")

Used in panel ID generation and display.

Implemented in yaze::editor::DungeonRoomPanel.

◆ GetResourceName() [2/2]

virtual std::string yaze::editor::ResourceWindowContent::GetResourceName ( ) const
inlinevirtual

Human-readable resource name.

Returns
Friendly name (e.g., "Hyrule Castle Entrance", "Overworld Theme")

Default implementation returns "{type} {id}". Override to provide game-specific names from ROM data.

Reimplemented in yaze::editor::DungeonRoomPanel.

Definition at line 102 of file resource_panel.h.

References GetResourceId(), and GetResourceType().

Here is the call graph for this function:

◆ GetId() [2/2]

std::string yaze::editor::ResourceWindowContent::GetId ( ) const
inlineoverridevirtual

Generated panel ID from resource type and ID.

Returns
ID in format "{category}.{type}_{id}"

Implements yaze::editor::WindowContent.

Definition at line 114 of file resource_panel.h.

References yaze::editor::WindowContent::GetEditorCategory(), GetResourceId(), and GetResourceType().

Here is the call graph for this function:

◆ GetDisplayName() [2/2]

std::string yaze::editor::ResourceWindowContent::GetDisplayName ( ) const
inlineoverridevirtual

Generated display name from resource name.

Returns
The resource name

Implements yaze::editor::WindowContent.

Definition at line 123 of file resource_panel.h.

References GetResourceName().

Here is the call graph for this function:

◆ GetWindowLifecycle() [2/2]

WindowLifecycle yaze::editor::ResourceWindowContent::GetWindowLifecycle ( ) const
inlineoverridevirtual

Resource windows use CrossEditor lifecycle for opt-in persistence.

Returns
WindowLifecycle::CrossEditor

Resource panels (rooms, songs, etc.) can be pinned to persist across editor switches. By default, they're NOT pinned and will be hidden (but not closed) when switching to another editor.

Pin behavior:

  • Open a room → NOT pinned, hidden when switching editors
  • Pin it → stays visible across all editors
  • Unpin it → hidden when switching editors
  • Close via X → fully removed regardless of pin state

The drawing loops in each editor handle the category filtering.

Reimplemented from yaze::editor::WindowContent.

Definition at line 145 of file resource_panel.h.

References yaze::editor::CrossEditor.

◆ AllowMultipleInstances() [2/2]

virtual bool yaze::editor::ResourceWindowContent::AllowMultipleInstances ( ) const
inlinevirtual

Whether multiple instances of this resource type can be open.

Returns
true to allow multiple (default), false for singleton behavior

Definition at line 153 of file resource_panel.h.

◆ GetSessionId() [2/2]

virtual size_t yaze::editor::ResourceWindowContent::GetSessionId ( ) const
inlinevirtual

Get the session ID this resource belongs to.

Returns
Session ID (0 for single-ROM mode)

In multi-ROM editing mode, each loaded ROM gets a session ID. This allows the same resource (e.g., room 42) to be open for different ROMs simultaneously.

Definition at line 167 of file resource_panel.h.

References session_id_.

◆ SetSessionId() [2/2]

void yaze::editor::ResourceWindowContent::SetSessionId ( size_t session_id)
inline

Set the session ID for this resource panel.

Parameters
session_idThe session ID to set

Definition at line 173 of file resource_panel.h.

References session_id_.

◆ OnResourceModified() [2/2]

virtual void yaze::editor::ResourceWindowContent::OnResourceModified ( )
inlinevirtual

Called when resource data changes externally.

Override to refresh panel state when the underlying ROM data is modified by another editor or operation.

Reimplemented in yaze::editor::DungeonRoomPanel.

Definition at line 185 of file resource_panel.h.

◆ OnResourceDeleted() [2/2]

virtual void yaze::editor::ResourceWindowContent::OnResourceDeleted ( )
inlinevirtual

Called when resource is deleted from ROM.

Default behavior: the panel should be closed. Override to implement custom cleanup or warnings.

Definition at line 193 of file resource_panel.h.

Member Data Documentation

◆ session_id_

size_t yaze::editor::ResourceWindowContent::session_id_ = 0
protected

Session ID for multi-ROM editing (0 = single session)

Definition at line 199 of file resource_panel.h.

Referenced by yaze::editor::DungeonRoomPanel::DungeonRoomPanel(), GetSessionId(), and SetSessionId().


The documentation for this class was generated from the following files: