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

Dedicated panel for editing Link's 14 graphics sheets. More...

#include <link_sprite_panel.h>

Inheritance diagram for yaze::editor::LinkSpritePanel:
Collaboration diagram for yaze::editor::LinkSpritePanel:

Public Types

enum class  PaletteType { kGreenMail = 0 , kBlueMail = 1 , kRedMail = 2 , kBunny = 3 }
 Link sprite palette types. More...
 

Public Member Functions

 LinkSpritePanel (GraphicsEditorState *state, Rom *rom)
 
std::string GetId () const override
 Unique identifier for this panel.
 
std::string GetDisplayName () const override
 Human-readable name shown in menus and title bars.
 
std::string GetIcon () const override
 Material Design icon for this panel.
 
std::string GetEditorCategory () const override
 Editor category this panel belongs to.
 
int GetPriority () const override
 Get display priority for menu ordering.
 
void Initialize ()
 Initialize the panel and load Link sheets.
 
void Draw (bool *p_open) override
 Draw the panel UI (EditorPanel interface)
 
absl::Status Update ()
 Legacy Update method for backward compatibility.
 
bool HasUnsavedChanges () const
 Check if the panel has unsaved changes.
 
- Public Member Functions inherited from yaze::editor::EditorPanel
virtual ~EditorPanel ()=default
 
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 PanelCategory GetPanelCategory () const
 Get the lifecycle category for this panel.
 
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 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.
 

Static Public Attributes

static constexpr int kNumLinkSheets = 14
 

Private Member Functions

void DrawToolbar ()
 Draw the toolbar with Import/Reset buttons.
 
void DrawSheetGrid ()
 Draw the 4x4 sheet selection grid.
 
void DrawSheetThumbnail (int sheet_index)
 Draw a single Link sheet thumbnail.
 
void DrawPreviewCanvas ()
 Draw the preview canvas for selected sheet.
 
void DrawPaletteSelector ()
 Draw the palette selector dropdown.
 
void DrawInfoPanel ()
 Draw info panel with stats.
 
void ImportZspr ()
 Handle ZSPR file import.
 
void ResetToVanilla ()
 Reset Link sheets to vanilla ROM data.
 
void OpenSheetInPixelEditor ()
 Open selected sheet in the main pixel editor.
 
absl::Status LoadLinkSheets ()
 Load Link graphics sheets from ROM.
 
void ApplySelectedPalette ()
 Apply the selected palette to Link sheets for display.
 

Static Private Member Functions

static const char * GetPaletteName (PaletteType type)
 Get the name of a palette type.
 

Private Attributes

GraphicsEditorStatestate_
 
Romrom_
 
std::array< gfx::Bitmap, kNumLinkSheetslink_sheets_
 
bool sheets_loaded_ = false
 
int selected_sheet_ = 0
 
PaletteType selected_palette_ = PaletteType::kGreenMail
 
bool has_unsaved_changes_ = false
 
gui::Canvas preview_canvas_
 
float preview_zoom_ = 4.0f
 
std::optional< gfx::ZsprDataloaded_zspr_
 

Static Private Attributes

static constexpr float kThumbnailSize = 64.0f
 
static constexpr float kThumbnailPadding = 4.0f
 

Detailed Description

Dedicated panel for editing Link's 14 graphics sheets.

Features:

  • Sheet thumbnail grid (4x4 layout, 14 sheets)
  • ZSPR import support
  • Palette switcher (Green/Blue/Red/Bunny mail)
  • Integration with main pixel editor
  • Reset to vanilla option

Definition at line 31 of file link_sprite_panel.h.

Member Enumeration Documentation

◆ PaletteType

Link sprite palette types.

Enumerator
kGreenMail 
kBlueMail 
kRedMail 
kBunny 

Definition at line 38 of file link_sprite_panel.h.

Constructor & Destructor Documentation

◆ LinkSpritePanel()

yaze::editor::LinkSpritePanel::LinkSpritePanel ( GraphicsEditorState * state,
Rom * rom )

Definition at line 15 of file link_sprite_panel.cc.

Member Function Documentation

◆ GetId()

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

Unique identifier for this panel.

Returns
Panel ID in format "{category}.{name}" (e.g., "dungeon.room_selector")

IDs should be:

  • Lowercase with underscores
  • Prefixed with editor category
  • Unique across all panels

Implements yaze::editor::EditorPanel.

Definition at line 51 of file link_sprite_panel.h.

◆ GetDisplayName()

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

Human-readable name shown in menus and title bars.

Returns
Display name (e.g., "Room Selector")

Implements yaze::editor::EditorPanel.

Definition at line 52 of file link_sprite_panel.h.

◆ GetIcon()

std::string yaze::editor::LinkSpritePanel::GetIcon ( ) const
inlineoverridevirtual

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::EditorPanel.

Definition at line 53 of file link_sprite_panel.h.

References ICON_MD_PERSON.

◆ GetEditorCategory()

std::string yaze::editor::LinkSpritePanel::GetEditorCategory ( ) const
inlineoverridevirtual

Editor category this panel belongs to.

Returns
Category name matching EditorType (e.g., "Dungeon", "Overworld")

Implements yaze::editor::EditorPanel.

Definition at line 54 of file link_sprite_panel.h.

◆ GetPriority()

int yaze::editor::LinkSpritePanel::GetPriority ( ) const
inlineoverridevirtual

Get display priority for menu ordering.

Returns
Priority value (lower = higher in list, default 50)

Reimplemented from yaze::editor::EditorPanel.

Definition at line 55 of file link_sprite_panel.h.

◆ Initialize()

void yaze::editor::LinkSpritePanel::Initialize ( )

Initialize the panel and load Link sheets.

Definition at line 18 of file link_sprite_panel.cc.

References preview_canvas_, preview_zoom_, and yaze::gui::Canvas::SetCanvasSize().

Here is the call graph for this function:

◆ Draw()

void yaze::editor::LinkSpritePanel::Draw ( bool * p_open)
overridevirtual

◆ Update()

absl::Status yaze::editor::LinkSpritePanel::Update ( )

Legacy Update method for backward compatibility.

Returns
Status of the render operation

Definition at line 59 of file link_sprite_panel.cc.

References DrawInfoPanel(), DrawPaletteSelector(), DrawPreviewCanvas(), DrawSheetGrid(), DrawToolbar(), yaze::Rom::is_loaded(), LoadLinkSheets(), rom_, and sheets_loaded_.

◆ HasUnsavedChanges()

bool yaze::editor::LinkSpritePanel::HasUnsavedChanges ( ) const
inline

Check if the panel has unsaved changes.

Definition at line 80 of file link_sprite_panel.h.

References has_unsaved_changes_.

◆ DrawToolbar()

void yaze::editor::LinkSpritePanel::DrawToolbar ( )
private

Draw the toolbar with Import/Reset buttons.

Definition at line 97 of file link_sprite_panel.cc.

References has_unsaved_changes_, HOVER_HINT, ICON_MD_FILE_UPLOAD, ICON_MD_RESTORE, ImportZspr(), loaded_zspr_, and ResetToVanilla().

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ DrawSheetGrid()

void yaze::editor::LinkSpritePanel::DrawSheetGrid ( )
private

Draw the 4x4 sheet selection grid.

Definition at line 124 of file link_sprite_panel.cc.

References DrawSheetThumbnail(), kNumLinkSheets, kThumbnailPadding, and kThumbnailSize.

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ DrawSheetThumbnail()

void yaze::editor::LinkSpritePanel::DrawSheetThumbnail ( int sheet_index)
private

Draw a single Link sheet thumbnail.

Definition at line 148 of file link_sprite_panel.cc.

References yaze::gfx::Arena::CREATE, yaze::gfx::Arena::Get(), kThumbnailPadding, kThumbnailSize, link_sheets_, OpenSheetInPixelEditor(), yaze::gfx::Arena::QueueTextureCommand(), and selected_sheet_.

Referenced by DrawSheetGrid().

Here is the call graph for this function:

◆ DrawPreviewCanvas()

◆ DrawPaletteSelector()

void yaze::editor::LinkSpritePanel::DrawPaletteSelector ( )
private

Draw the palette selector dropdown.

Definition at line 254 of file link_sprite_panel.cc.

References ApplySelectedPalette(), HOVER_HINT, and selected_palette_.

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ DrawInfoPanel()

void yaze::editor::LinkSpritePanel::DrawInfoPanel ( )
private

Draw info panel with stats.

Definition at line 269 of file link_sprite_panel.cc.

References loaded_zspr_.

Referenced by Draw(), and Update().

◆ ImportZspr()

◆ ResetToVanilla()

void yaze::editor::LinkSpritePanel::ResetToVanilla ( )
private

Reset Link sheets to vanilla ROM data.

Todo
Implement reset to vanilla

Definition at line 336 of file link_sprite_panel.cc.

References loaded_zspr_, and LOG_WARN.

Referenced by DrawToolbar().

◆ OpenSheetInPixelEditor()

void yaze::editor::LinkSpritePanel::OpenSheetInPixelEditor ( )
private

Open selected sheet in the main pixel editor.

Todo
Add Link sheet to open_sheets with a special identifier

Definition at line 344 of file link_sprite_panel.cc.

References LOG_INFO, and selected_sheet_.

Referenced by DrawPreviewCanvas(), and DrawSheetThumbnail().

◆ LoadLinkSheets()

absl::Status yaze::editor::LinkSpritePanel::LoadLinkSheets ( )
private

Load Link graphics sheets from ROM.

Definition at line 357 of file link_sprite_panel.cc.

References ApplySelectedPalette(), yaze::Rom::is_loaded(), yaze::zelda3::kNumLinkSheets, link_sheets_, yaze::zelda3::LoadLinkGraphics(), LOG_INFO, rom_, and sheets_loaded_.

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ ApplySelectedPalette()

void yaze::editor::LinkSpritePanel::ApplySelectedPalette ( )
private

◆ GetPaletteName()

const char * yaze::editor::LinkSpritePanel::GetPaletteName ( PaletteType type)
staticprivate

Get the name of a palette type.

Definition at line 444 of file link_sprite_panel.cc.

References kBlueMail, kBunny, kGreenMail, and kRedMail.

Referenced by ApplySelectedPalette().

Member Data Documentation

◆ kNumLinkSheets

constexpr int yaze::editor::LinkSpritePanel::kNumLinkSheets = 14
staticconstexpr

Definition at line 33 of file link_sprite_panel.h.

Referenced by DrawSheetGrid().

◆ state_

GraphicsEditorState* yaze::editor::LinkSpritePanel::state_
private

Definition at line 143 of file link_sprite_panel.h.

◆ rom_

Rom* yaze::editor::LinkSpritePanel::rom_
private

Definition at line 144 of file link_sprite_panel.h.

Referenced by ApplySelectedPalette(), Draw(), ImportZspr(), LoadLinkSheets(), and Update().

◆ link_sheets_

std::array<gfx::Bitmap, kNumLinkSheets> yaze::editor::LinkSpritePanel::link_sheets_
private

◆ sheets_loaded_

bool yaze::editor::LinkSpritePanel::sheets_loaded_ = false
private

Definition at line 148 of file link_sprite_panel.h.

Referenced by Draw(), ImportZspr(), LoadLinkSheets(), and Update().

◆ selected_sheet_

int yaze::editor::LinkSpritePanel::selected_sheet_ = 0
private

◆ selected_palette_

PaletteType yaze::editor::LinkSpritePanel::selected_palette_ = PaletteType::kGreenMail
private

Definition at line 152 of file link_sprite_panel.h.

Referenced by ApplySelectedPalette(), and DrawPaletteSelector().

◆ has_unsaved_changes_

bool yaze::editor::LinkSpritePanel::has_unsaved_changes_ = false
private

Definition at line 153 of file link_sprite_panel.h.

Referenced by DrawToolbar(), HasUnsavedChanges(), and ImportZspr().

◆ preview_canvas_

gui::Canvas yaze::editor::LinkSpritePanel::preview_canvas_
private

Definition at line 156 of file link_sprite_panel.h.

Referenced by DrawPreviewCanvas(), and Initialize().

◆ preview_zoom_

float yaze::editor::LinkSpritePanel::preview_zoom_ = 4.0f
private

Definition at line 157 of file link_sprite_panel.h.

Referenced by DrawPreviewCanvas(), and Initialize().

◆ loaded_zspr_

std::optional<gfx::ZsprData> yaze::editor::LinkSpritePanel::loaded_zspr_
private

Definition at line 160 of file link_sprite_panel.h.

Referenced by DrawInfoPanel(), DrawToolbar(), ImportZspr(), and ResetToVanilla().

◆ kThumbnailSize

constexpr float yaze::editor::LinkSpritePanel::kThumbnailSize = 64.0f
staticconstexprprivate

Definition at line 163 of file link_sprite_panel.h.

Referenced by DrawSheetGrid(), and DrawSheetThumbnail().

◆ kThumbnailPadding

constexpr float yaze::editor::LinkSpritePanel::kThumbnailPadding = 4.0f
staticconstexprprivate

Definition at line 164 of file link_sprite_panel.h.

Referenced by DrawSheetGrid(), and DrawSheetThumbnail().


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