yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
link_sprite_panel.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_GRAPHICS_LINK_SPRITE_PANEL_H
2#define YAZE_APP_EDITOR_GRAPHICS_LINK_SPRITE_PANEL_H
3
4#include <array>
5#include <string>
6
7#include "absl/status/status.h"
10#include "app/gfx/core/bitmap.h"
13#include "app/gui/core/icons.h"
14
15namespace yaze {
16
17class Rom;
18
19namespace editor {
20
32 public:
33 static constexpr int kNumLinkSheets = 14;
34
38 enum class PaletteType {
39 kGreenMail = 0,
40 kBlueMail = 1,
41 kRedMail = 2,
42 kBunny = 3
43 };
44
46
47 // ==========================================================================
48 // WindowContent Identity
49 // ==========================================================================
50
51 std::string GetId() const override { return "graphics.link_sprite"; }
52 std::string GetDisplayName() const override { return "Link Sprite"; }
53 std::string GetIcon() const override { return ICON_MD_PERSON; }
54 std::string GetEditorCategory() const override { return "Graphics"; }
55 int GetPriority() const override { return 40; }
56
57 // ==========================================================================
58 // WindowContent Lifecycle
59 // ==========================================================================
60
64 void Initialize();
65
66 void SetRom(Rom* rom) { rom_ = rom; }
67
71 void Draw(bool* p_open) override;
72
77 absl::Status Update();
78
82 bool HasUnsavedChanges() const { return has_unsaved_changes_; }
83
84 private:
88 void DrawToolbar();
89
93 void DrawSheetGrid();
94
98 void DrawSheetThumbnail(int sheet_index);
99
103 void DrawPreviewCanvas();
104
108 void DrawPaletteSelector();
109
113 void DrawInfoPanel();
114
118 void ImportZspr();
119
123 void ResetToVanilla();
124
129
133 absl::Status LoadLinkSheets();
134
139
143 static const char* GetPaletteName(PaletteType type);
144
147
148 // Link sheets loaded from ROM
149 std::array<gfx::Bitmap, kNumLinkSheets> link_sheets_;
150 bool sheets_loaded_ = false;
151
152 // UI state
156
157 // Preview canvas
159 float preview_zoom_ = 4.0f;
160
161 // Currently loaded ZSPR (if any)
162 std::optional<gfx::ZsprData> loaded_zspr_;
163
164 // Thumbnail size
165 static constexpr float kThumbnailSize = 64.0f;
166 static constexpr float kThumbnailPadding = 4.0f;
167};
168
169} // namespace editor
170} // namespace yaze
171
172#endif // YAZE_APP_EDITOR_GRAPHICS_LINK_SPRITE_PANEL_H
The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and do...
Definition rom.h:28
Shared state between GraphicsEditor panel components.
Dedicated panel for editing Link's 14 graphics sheets.
static constexpr float kThumbnailPadding
PaletteType
Link sprite palette types.
absl::Status LoadLinkSheets()
Load Link graphics sheets from ROM.
void Draw(bool *p_open) override
Draw the panel UI (WindowContent interface)
void Initialize()
Initialize the panel and load Link sheets.
void OpenSheetInPixelEditor()
Open selected sheet in the main pixel editor.
absl::Status Update()
Legacy Update method for backward compatibility.
std::optional< gfx::ZsprData > loaded_zspr_
void ApplySelectedPalette()
Apply the selected palette to Link sheets for display.
bool HasUnsavedChanges() const
Check if the panel has unsaved changes.
std::string GetEditorCategory() const override
Editor category this panel belongs to.
std::string GetIcon() const override
Material Design icon for this panel.
void ImportZspr()
Handle ZSPR file import.
int GetPriority() const override
Get display priority for menu ordering.
void DrawSheetGrid()
Draw the 4x4 sheet selection grid.
static constexpr int kNumLinkSheets
void DrawPreviewCanvas()
Draw the preview canvas for selected sheet.
void DrawInfoPanel()
Draw info panel with stats.
static const char * GetPaletteName(PaletteType type)
Get the name of a palette type.
void DrawPaletteSelector()
Draw the palette selector dropdown.
std::array< gfx::Bitmap, kNumLinkSheets > link_sheets_
LinkSpritePanel(GraphicsEditorState *state, Rom *rom)
void DrawToolbar()
Draw the toolbar with Import/Reset buttons.
void ResetToVanilla()
Reset Link sheets to vanilla ROM data.
std::string GetDisplayName() const override
Human-readable name shown in menus and title bars.
void DrawSheetThumbnail(int sheet_index)
Draw a single Link sheet thumbnail.
static constexpr float kThumbnailSize
std::string GetId() const override
Unique identifier for this panel.
Base interface for all logical window content components.
Modern, robust canvas for drawing and manipulating graphics.
Definition canvas.h:150
#define ICON_MD_PERSON
Definition icons.h:1415