Dedicated panel for editing Link's 14 graphics sheets. More...
#include <link_sprite_panel.h>
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 | |
| GraphicsEditorState * | state_ |
| Rom * | rom_ |
| std::array< gfx::Bitmap, kNumLinkSheets > | link_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::ZsprData > | loaded_zspr_ |
Static Private Attributes | |
| static constexpr float | kThumbnailSize = 64.0f |
| static constexpr float | kThumbnailPadding = 4.0f |
Dedicated panel for editing Link's 14 graphics sheets.
Features:
Definition at line 31 of file link_sprite_panel.h.
|
strong |
Link sprite palette types.
| Enumerator | |
|---|---|
| kGreenMail | |
| kBlueMail | |
| kRedMail | |
| kBunny | |
Definition at line 38 of file link_sprite_panel.h.
| yaze::editor::LinkSpritePanel::LinkSpritePanel | ( | GraphicsEditorState * | state, |
| Rom * | rom ) |
Definition at line 15 of file link_sprite_panel.cc.
|
inlineoverridevirtual |
Unique identifier for this panel.
IDs should be:
Implements yaze::editor::EditorPanel.
Definition at line 51 of file link_sprite_panel.h.
|
inlineoverridevirtual |
Human-readable name shown in menus and title bars.
Implements yaze::editor::EditorPanel.
Definition at line 52 of file link_sprite_panel.h.
|
inlineoverridevirtual |
Material Design icon for this panel.
Implements yaze::editor::EditorPanel.
Definition at line 53 of file link_sprite_panel.h.
References ICON_MD_PERSON.
|
inlineoverridevirtual |
Editor category this panel belongs to.
Implements yaze::editor::EditorPanel.
Definition at line 54 of file link_sprite_panel.h.
|
inlineoverridevirtual |
Get display priority for menu ordering.
Reimplemented from yaze::editor::EditorPanel.
Definition at line 55 of file link_sprite_panel.h.
| 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().
|
overridevirtual |
Draw the panel UI (EditorPanel interface)
Implements yaze::editor::EditorPanel.
Definition at line 22 of file link_sprite_panel.cc.
References DrawInfoPanel(), DrawPaletteSelector(), DrawPreviewCanvas(), DrawSheetGrid(), DrawToolbar(), yaze::Rom::is_loaded(), LoadLinkSheets(), rom_, and sheets_loaded_.
| absl::Status yaze::editor::LinkSpritePanel::Update | ( | ) |
Legacy Update method for backward compatibility.
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_.
|
inline |
Check if the panel has unsaved changes.
Definition at line 80 of file link_sprite_panel.h.
References has_unsaved_changes_.
|
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().
|
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().
|
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().
|
private |
Draw the preview canvas for selected sheet.
Definition at line 210 of file link_sprite_panel.cc.
References yaze::gui::BeginCanvas(), yaze::gui::CanvasFrameOptions::canvas_size, yaze::gui::BitmapDrawOpts::dest_pos, yaze::gui::BitmapDrawOpts::dest_size, yaze::gui::CanvasFrameOptions::draw_context_menu, yaze::gui::CanvasFrameOptions::draw_grid, yaze::gui::DrawBitmap(), yaze::gui::EndCanvas(), yaze::gui::BitmapDrawOpts::ensure_texture, yaze::gui::CanvasFrameOptions::grid_step, HOVER_HINT, ICON_MD_EDIT, link_sheets_, OpenSheetInPixelEditor(), preview_canvas_, preview_zoom_, selected_sheet_, and yaze::gui::Canvas::SetCanvasSize().
|
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().
|
private |
Draw info panel with stats.
Definition at line 269 of file link_sprite_panel.cc.
References loaded_zspr_.
|
private |
Handle ZSPR file import.
Definition at line 284 of file link_sprite_panel.cc.
References yaze::gfx::ZsprLoader::ApplyPaletteToRom(), yaze::gfx::ZsprLoader::ApplyToRom(), has_unsaved_changes_, yaze::Rom::is_loaded(), loaded_zspr_, yaze::gfx::ZsprLoader::LoadFromFile(), LOG_ERROR, LOG_INFO, LOG_WARN, rom_, sheets_loaded_, and yaze::util::FileDialogWrapper::ShowOpenFileDialog().
Referenced by DrawToolbar().
|
private |
Reset Link sheets to vanilla ROM data.
Definition at line 336 of file link_sprite_panel.cc.
References loaded_zspr_, and LOG_WARN.
Referenced by DrawToolbar().
|
private |
Open selected sheet in the main pixel editor.
Definition at line 344 of file link_sprite_panel.cc.
References LOG_INFO, and selected_sheet_.
Referenced by DrawPreviewCanvas(), and DrawSheetThumbnail().
|
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().
|
private |
Apply the selected palette to Link sheets for display.
Definition at line 379 of file link_sprite_panel.cc.
References yaze::gfx::SnesPalette::empty(), yaze::gfx::Arena::Get(), GetPaletteName(), yaze::Rom::is_loaded(), link_sheets_, LOG_INFO, yaze::gfx::Arena::QueueTextureCommand(), yaze::gfx::SnesPalette::Resize(), rom_, selected_palette_, and yaze::gfx::Arena::UPDATE.
Referenced by DrawPaletteSelector(), and LoadLinkSheets().
|
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().
|
staticconstexpr |
Definition at line 33 of file link_sprite_panel.h.
Referenced by DrawSheetGrid().
|
private |
Definition at line 143 of file link_sprite_panel.h.
|
private |
Definition at line 144 of file link_sprite_panel.h.
Referenced by ApplySelectedPalette(), Draw(), ImportZspr(), LoadLinkSheets(), and Update().
|
private |
Definition at line 147 of file link_sprite_panel.h.
Referenced by ApplySelectedPalette(), DrawPreviewCanvas(), DrawSheetThumbnail(), and LoadLinkSheets().
|
private |
Definition at line 148 of file link_sprite_panel.h.
Referenced by Draw(), ImportZspr(), LoadLinkSheets(), and Update().
|
private |
Definition at line 151 of file link_sprite_panel.h.
Referenced by DrawPreviewCanvas(), DrawSheetThumbnail(), and OpenSheetInPixelEditor().
|
private |
Definition at line 152 of file link_sprite_panel.h.
Referenced by ApplySelectedPalette(), and DrawPaletteSelector().
|
private |
Definition at line 153 of file link_sprite_panel.h.
Referenced by DrawToolbar(), HasUnsavedChanges(), and ImportZspr().
|
private |
Definition at line 156 of file link_sprite_panel.h.
Referenced by DrawPreviewCanvas(), and Initialize().
|
private |
Definition at line 157 of file link_sprite_panel.h.
Referenced by DrawPreviewCanvas(), and Initialize().
|
private |
Definition at line 160 of file link_sprite_panel.h.
Referenced by DrawInfoPanel(), DrawToolbar(), ImportZspr(), and ResetToVanilla().
|
staticconstexprprivate |
Definition at line 163 of file link_sprite_panel.h.
Referenced by DrawSheetGrid(), and DrawSheetThumbnail().
|
staticconstexprprivate |
Definition at line 164 of file link_sprite_panel.h.
Referenced by DrawSheetGrid(), and DrawSheetThumbnail().