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

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

#include <link_sprite_view.h>

Inheritance diagram for yaze::editor::LinkSpriteView:
Collaboration diagram for yaze::editor::LinkSpriteView:

Public Types

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

Public Member Functions

 LinkSpriteView (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.
 
float GetPreferredWidth () const override
 Get preferred width for this panel (optional)
 
void Initialize ()
 Initialize the view and load Link sheets.
 
void Draw (bool *p_open) override
 Draw the view UI (WindowContent interface)
 
absl::Status Update ()
 Legacy Update method for backward compatibility.
 
bool HasUnsavedChanges () const
 Check if the view has unsaved changes.
 
- Public Member Functions inherited from yaze::editor::WindowContent
virtual ~WindowContent ()=default
 
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 WindowLifecycle GetWindowLifecycle () const
 Get the lifecycle category for this window.
 
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 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 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()
 

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
 

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

Dedicated view 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_view.h.

Member Enumeration Documentation

◆ PaletteType

Link sprite palette types.

Enumerator
kGreenMail 
kBlueMail 
kRedMail 
kBunny 

Definition at line 38 of file link_sprite_view.h.

Constructor & Destructor Documentation

◆ LinkSpriteView()

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

Definition at line 18 of file link_sprite_view.cc.

Member Function Documentation

◆ GetId()

std::string yaze::editor::LinkSpriteView::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::WindowContent.

Definition at line 51 of file link_sprite_view.h.

◆ GetDisplayName()

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

Human-readable name shown in menus and title bars.

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

Implements yaze::editor::WindowContent.

Definition at line 52 of file link_sprite_view.h.

◆ GetIcon()

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

Material Design icon for this panel.

Returns
Icon constant (e.g., ICON_MD_LIST)

Implements yaze::editor::WindowContent.

Definition at line 53 of file link_sprite_view.h.

References ICON_MD_PERSON.

◆ GetEditorCategory()

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

Editor category this panel belongs to.

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

Implements yaze::editor::WindowContent.

Definition at line 54 of file link_sprite_view.h.

◆ GetPriority()

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

Get display priority for menu ordering.

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

Reimplemented from yaze::editor::WindowContent.

Definition at line 55 of file link_sprite_view.h.

◆ GetPreferredWidth()

float yaze::editor::LinkSpriteView::GetPreferredWidth ( ) const
inlineoverridevirtual

Get preferred width for this panel (optional)

Returns
Preferred width in pixels, or 0 to use default (250px)

Override this to specify content-based sizing. For example, a tile selector with 8 tiles at 16px × 2.0 scale would return ~276px.

Reimplemented from yaze::editor::WindowContent.

Definition at line 56 of file link_sprite_view.h.

◆ Initialize()

void yaze::editor::LinkSpriteView::Initialize ( )

Initialize the view and load Link sheets.

Definition at line 21 of file link_sprite_view.cc.

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

Here is the call graph for this function:

◆ Draw()

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

◆ Update()

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

Legacy Update method for backward compatibility.

Returns
Status of the render operation

Definition at line 62 of file link_sprite_view.cc.

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

◆ HasUnsavedChanges()

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

Check if the view has unsaved changes.

Definition at line 81 of file link_sprite_view.h.

References has_unsaved_changes_.

◆ DrawToolbar()

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

Draw the toolbar with Import/Reset buttons.

Definition at line 99 of file link_sprite_view.cc.

References yaze::gui::GetSuccessColor(), yaze::gui::GetWarningColor(), has_unsaved_changes_, HOVER_HINT, ICON_MD_CHECK_CIRCLE, ICON_MD_EDIT, 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::LinkSpriteView::DrawSheetGrid ( )
private

Draw the 4x4 sheet selection grid.

Definition at line 126 of file link_sprite_view.cc.

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

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ DrawSheetThumbnail()

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

Draw a single Link sheet thumbnail.

Definition at line 150 of file link_sprite_view.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::LinkSpriteView::DrawPaletteSelector ( )
private

Draw the palette selector dropdown.

Definition at line 256 of file link_sprite_view.cc.

References ApplySelectedPalette(), yaze::gui::LayoutHelpers::GetComboWidth(), HOVER_HINT, and selected_palette_.

Referenced by Draw(), and Update().

Here is the call graph for this function:

◆ DrawInfoPanel()

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

Draw info panel with stats.

Definition at line 272 of file link_sprite_view.cc.

References loaded_zspr_.

Referenced by Draw(), and Update().

◆ ImportZspr()

◆ ResetToVanilla()

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

Reset Link sheets to vanilla ROM data.

Todo
Implement reset to vanilla

Definition at line 339 of file link_sprite_view.cc.

References loaded_zspr_, and LOG_WARN.

Referenced by DrawToolbar().

◆ OpenSheetInPixelEditor()

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

Open selected sheet in the main pixel editor.

Todo
Add Link sheet to open_sheets with a special identifier

Definition at line 347 of file link_sprite_view.cc.

References LOG_INFO, and selected_sheet_.

Referenced by DrawPreviewCanvas(), and DrawSheetThumbnail().

◆ LoadLinkSheets()

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

Load Link graphics sheets from ROM.

Definition at line 360 of file link_sprite_view.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::LinkSpriteView::ApplySelectedPalette ( )
private

◆ GetPaletteName()

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

Get the name of a palette type.

Definition at line 449 of file link_sprite_view.cc.

References kBlueMail, kBunny, kGreenMail, and kRedMail.

Referenced by ApplySelectedPalette().

Member Data Documentation

◆ kNumLinkSheets

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

Definition at line 33 of file link_sprite_view.h.

Referenced by DrawSheetGrid().

◆ state_

GraphicsEditorState* yaze::editor::LinkSpriteView::state_
private

Definition at line 144 of file link_sprite_view.h.

◆ rom_

Rom* yaze::editor::LinkSpriteView::rom_
private

Definition at line 145 of file link_sprite_view.h.

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

◆ link_sheets_

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

◆ sheets_loaded_

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

Definition at line 149 of file link_sprite_view.h.

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

◆ selected_sheet_

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

◆ selected_palette_

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

Definition at line 153 of file link_sprite_view.h.

Referenced by ApplySelectedPalette(), and DrawPaletteSelector().

◆ has_unsaved_changes_

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

Definition at line 154 of file link_sprite_view.h.

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

◆ preview_canvas_

gui::Canvas yaze::editor::LinkSpriteView::preview_canvas_
private

Definition at line 157 of file link_sprite_view.h.

Referenced by DrawPreviewCanvas(), and Initialize().

◆ preview_zoom_

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

Definition at line 158 of file link_sprite_view.h.

Referenced by DrawPreviewCanvas(), and Initialize().

◆ loaded_zspr_

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

Definition at line 161 of file link_sprite_view.h.

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

◆ kThumbnailSize

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

Definition at line 164 of file link_sprite_view.h.

Referenced by DrawSheetGrid(), and DrawSheetThumbnail().

◆ kThumbnailPadding

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

Definition at line 165 of file link_sprite_view.h.

Referenced by DrawSheetGrid(), and DrawSheetThumbnail().


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