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

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

#include <resource_panel.h>

Inheritance diagram for yaze::editor::ResourcePanel:
Collaboration diagram for yaze::editor::ResourcePanel:

Public Member Functions

virtual ~ResourcePanel ()=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.
 
PanelCategory GetPanelCategory () const override
 Resource panels use CrossEditor category 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::EditorPanel
virtual ~EditorPanel ()=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 OnOpen ()
 Called when panel becomes visible.
 
virtual void OnClose ()
 Called when panel is hidden.
 
virtual void OnFocus ()
 Called when panel receives focus.
 
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 float GetPreferredWidth () const
 Get preferred width for this panel (optional)
 
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.
 

Protected Attributes

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

Detailed Description

Base class for panels that edit specific ROM resources.

A ResourcePanel 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_;
};
ResourcePanel for editing individual dungeon rooms.
Base class for panels that edit specific ROM resources.
#define ICON_MD_DOOR_FRONT
Definition icons.h:613
See also
EditorPanel - Base interface for all panels
PanelManager - Manages resource panel lifecycle and limits

Definition at line 71 of file resource_panel.h.

Constructor & Destructor Documentation

◆ ~ResourcePanel()

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

Member Function Documentation

◆ GetResourceId()

virtual int yaze::editor::ResourcePanel::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()

virtual std::string yaze::editor::ResourcePanel::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(), and GetResourceName().

◆ GetResourceName()

virtual std::string yaze::editor::ResourcePanel::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()

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

Generated panel ID from resource type and ID.

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

Implements yaze::editor::EditorPanel.

Definition at line 114 of file resource_panel.h.

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

Here is the call graph for this function:

◆ GetDisplayName()

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

Generated display name from resource name.

Returns
The resource name

Implements yaze::editor::EditorPanel.

Definition at line 123 of file resource_panel.h.

References GetResourceName().

Here is the call graph for this function:

◆ GetPanelCategory()

PanelCategory yaze::editor::ResourcePanel::GetPanelCategory ( ) const
inlineoverridevirtual

Resource panels use CrossEditor category for opt-in persistence.

Returns
PanelCategory::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::EditorPanel.

Definition at line 145 of file resource_panel.h.

References yaze::editor::CrossEditor.

◆ AllowMultipleInstances()

virtual bool yaze::editor::ResourcePanel::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()

virtual size_t yaze::editor::ResourcePanel::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()

void yaze::editor::ResourcePanel::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()

virtual void yaze::editor::ResourcePanel::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()

virtual void yaze::editor::ResourcePanel::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::ResourcePanel::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 file: