Allows the user to edit sprites. More...
#include <sprite_editor.h>
Classes | |
| struct | OAMConfig |
Public Member Functions | |
| SpriteEditor (Rom *rom=nullptr) | |
| void | Initialize () override |
| absl::Status | Load () override |
| absl::Status | Update () override |
| absl::Status | Undo () override |
| absl::Status | Redo () override |
| absl::Status | Cut () override |
| absl::Status | Copy () override |
| absl::Status | Paste () override |
| absl::Status | Find () override |
| absl::Status | Save () override |
| void | set_rom (Rom *rom) |
| Rom * | rom () const |
Public Member Functions inherited from yaze::editor::Editor | |
| Editor ()=default | |
| virtual | ~Editor ()=default |
| void | SetDependencies (const EditorDependencies &deps) |
| virtual void | SetGameData (zelda3::GameData *game_data) |
| virtual absl::Status | Clear () |
| EditorType | type () const |
| bool * | active () |
| void | set_active (bool active) |
| void | toggle_active () |
| virtual bool | IsRomLoaded () const |
| virtual std::string | GetRomStatus () const |
| Rom * | rom () const |
| zelda3::GameData * | game_data () const |
| EditorContext | context () const |
| bool | HasContext () const |
Private Member Functions | |
| void | HandleEditorShortcuts () |
| void | DrawVanillaSpriteEditor () |
| void | DrawSpritesList () |
| void | DrawSpriteCanvas () |
| void | DrawCurrentSheets () |
| void | DrawToolset () |
| void | DrawCustomSprites () |
| void | DrawCustomSpritesMetadata () |
| void | DrawAnimationFrames () |
| void | CreateNewZSprite () |
| void | LoadZsmFile (const std::string &path) |
| void | SaveZsmFile (const std::string &path) |
| void | SaveZsmFileAs () |
| void | DrawSpritePropertiesPanel () |
| void | DrawBooleanProperties () |
| void | DrawStatProperties () |
| void | DrawAnimationPanel () |
| void | DrawAnimationList () |
| void | DrawFrameEditor () |
| void | UpdateAnimationPlayback (float delta_time) |
| void | DrawUserRoutinesPanel () |
| void | RenderZSpriteFrame (int frame_index) |
| void | DrawZSpriteOnCanvas () |
| void | LoadSpriteGraphicsBuffer () |
| void | LoadSpritePalettes () |
| void | RenderVanillaSprite (const zelda3::SpriteOamLayout &layout) |
| void | LoadSheetsForSprite (const std::array< uint8_t, 4 > &sheets) |
Private Attributes | |
| ImVector< int > | active_sprites_ |
| int | current_sprite_id_ = 0 |
| uint8_t | current_sheets_ [8] = {0x00, 0x0A, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00} |
| bool | sheets_loaded_ = false |
| OAMConfig | oam_config_ |
| gfx::Bitmap | oam_bitmap_ |
| gfx::Bitmap | vanilla_preview_bitmap_ |
| bool | vanilla_preview_needs_update_ = true |
| std::vector< zsprite::ZSprite > | custom_sprites_ |
| int | current_custom_sprite_index_ = -1 |
| std::string | current_zsm_path_ |
| bool | zsm_dirty_ = false |
| bool | animation_playing_ = false |
| int | current_frame_ = 0 |
| int | current_animation_index_ = 0 |
| float | frame_timer_ = 0.0f |
| float | last_frame_time_ = 0.0f |
| int | selected_routine_index_ = -1 |
| int | selected_tile_index_ = -1 |
| bool | show_tile_grid_ = true |
| gfx::Bitmap | sprite_preview_bitmap_ |
| bool | preview_needs_update_ = true |
| SpriteDrawer | sprite_drawer_ |
| std::vector< uint8_t > | sprite_gfx_buffer_ |
| gfx::PaletteGroup | sprite_palettes_ |
| bool | gfx_buffer_loaded_ = false |
| gui::Canvas | sprite_canvas_ |
| gui::Canvas | graphics_sheet_canvas_ |
| absl::Status | status_ |
| Rom * | rom_ |
Additional Inherited Members | |
Protected Member Functions inherited from yaze::editor::Editor | |
| std::string | MakePanelTitle (const std::string &base_title) const |
| std::string | MakePanelId (const std::string &base_id) const |
| template<typename T > | |
| absl::StatusOr< T > | SafeRomAccess (std::function< T()> accessor, const std::string &operation="") const |
Protected Attributes inherited from yaze::editor::Editor | |
| bool | active_ = false |
| EditorType | type_ |
| EditorDependencies | dependencies_ |
Allows the user to edit sprites.
This class provides functionality for updating the sprite editor, drawing the editor table, drawing the sprite canvas, and drawing the current sheets. Supports both vanilla ROM sprites and custom ZSM format sprites.
Definition at line 43 of file sprite_editor.h.
|
inlineexplicit |
Definition at line 45 of file sprite_editor.h.
References yaze::editor::kSprite, and yaze::editor::Editor::type_.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 32 of file sprite_editor.cc.
References yaze::editor::Editor::dependencies_, DrawCustomSprites(), yaze::Rom::is_loaded(), yaze::editor::EditorDependencies::panel_manager, yaze::editor::PanelManager::RegisterEditorPanel(), and rom_.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 52 of file sprite_editor.cc.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 57 of file sprite_editor.cc.
References HandleEditorShortcuts(), last_frame_time_, rom(), sheets_loaded_, status_, and UpdateAnimationPlayback().
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 52 of file sprite_editor.h.
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 53 of file sprite_editor.h.
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 54 of file sprite_editor.h.
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 55 of file sprite_editor.h.
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 56 of file sprite_editor.h.
|
inlineoverridevirtual |
Implements yaze::editor::Editor.
Definition at line 57 of file sprite_editor.h.
|
overridevirtual |
Implements yaze::editor::Editor.
Definition at line 108 of file sprite_editor.cc.
References current_custom_sprite_index_, current_zsm_path_, custom_sprites_, SaveZsmFile(), and SaveZsmFileAs().
|
inline |
|
inline |
Definition at line 61 of file sprite_editor.h.
References rom_.
Referenced by DrawSpritesList(), set_rom(), and Update().
|
private |
Definition at line 77 of file sprite_editor.cc.
References animation_playing_, current_frame_, current_sprite_id_, preview_needs_update_, and vanilla_preview_needs_update_.
Referenced by Update().
|
private |
Definition at line 128 of file sprite_editor.cc.
References active_sprites_, current_sprite_id_, DrawCurrentSheets(), DrawSpriteCanvas(), DrawSpritesList(), ICON_MD_ADD, yaze::zelda3::kSpriteDefaultNames, yaze::editor::kSpriteTabBarFlags, and sheets_loaded_.
|
private |
Definition at line 300 of file sprite_editor.cc.
References active_sprites_, current_sprite_id_, yaze::gui::GetID(), yaze::util::HexByte(), yaze::zelda3::kSpriteDefaultNames, yaze::Rom::resource_label(), rom(), yaze::project::ResourceLabelManager::SelectableLabelWithNameEdit(), and vanilla_preview_needs_update_.
Referenced by DrawVanillaSpriteEditor().
|
private |
Definition at line 185 of file sprite_editor.cc.
References current_sprite_id_, DrawAnimationFrames(), yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawContextMenu(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), yaze::editor::SpriteEditor::OAMConfig::flip_x, yaze::editor::SpriteEditor::OAMConfig::flip_y, yaze::gui::GetID(), yaze::zelda3::SpriteOamRegistry::GetLayout(), yaze::gui::InputHexByte(), yaze::gui::InputHexWord(), yaze::gfx::Bitmap::is_active(), LoadSheetsForSprite(), oam_config_, yaze::editor::SpriteEditor::OAMConfig::palette, yaze::editor::SpriteEditor::OAMConfig::priority, RenderVanillaSprite(), sprite_canvas_, yaze::editor::SpriteEditor::OAMConfig::tile, vanilla_preview_bitmap_, yaze::editor::SpriteEditor::OAMConfig::x, and yaze::editor::SpriteEditor::OAMConfig::y.
Referenced by DrawVanillaSpriteEditor().
|
private |
Definition at line 262 of file sprite_editor.cc.
References current_sheets_, yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawBitmap(), yaze::gui::Canvas::DrawContextMenu(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), yaze::gui::Canvas::DrawTileSelector(), yaze::gfx::Arena::Get(), yaze::gui::GetID(), gfx_buffer_loaded_, graphics_sheet_canvas_, yaze::gui::InputHexByte(), and preview_needs_update_.
Referenced by DrawCustomSprites(), and DrawVanillaSpriteEditor().
|
private |
Definition at line 120 of file sprite_editor.cc.
|
private |
Definition at line 337 of file sprite_editor.cc.
References DrawCurrentSheets(), DrawCustomSpritesMetadata(), and DrawZSpriteOnCanvas().
Referenced by Initialize().
|
private |
Definition at line 361 of file sprite_editor.cc.
References CreateNewZSprite(), current_custom_sprite_index_, current_zsm_path_, custom_sprites_, DrawAnimationPanel(), DrawSpritePropertiesPanel(), DrawUserRoutinesPanel(), ICON_MD_ADD, ICON_MD_FOLDER_OPEN, ICON_MD_SAVE, ICON_MD_SAVE_AS, LoadZsmFile(), preview_needs_update_, SaveZsmFile(), SaveZsmFileAs(), and yaze::util::FileDialogWrapper::ShowOpenFileDialog().
Referenced by DrawCustomSprites().
|
private |
Definition at line 324 of file sprite_editor.cc.
Referenced by DrawSpriteCanvas().
|
private |
Definition at line 430 of file sprite_editor.cc.
References yaze::editor::zsprite::ZSprite::animations, current_custom_sprite_index_, current_zsm_path_, custom_sprites_, yaze::editor::zsprite::ZSprite::editor, yaze::editor::zsprite::SubEditor::Frames, preview_needs_update_, yaze::editor::zsprite::ZSprite::Reset(), yaze::editor::zsprite::ZSprite::sprName, and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata().
|
private |
Definition at line 448 of file sprite_editor.cc.
References current_custom_sprite_index_, current_zsm_path_, custom_sprites_, yaze::editor::zsprite::ZSprite::Load(), preview_needs_update_, status_, and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata().
|
private |
Definition at line 460 of file sprite_editor.cc.
References current_custom_sprite_index_, current_zsm_path_, custom_sprites_, status_, and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata(), Save(), and SaveZsmFileAs().
|
private |
Definition at line 471 of file sprite_editor.cc.
References current_custom_sprite_index_, SaveZsmFile(), and yaze::util::FileDialogWrapper::ShowSaveFileDialog().
Referenced by DrawCustomSpritesMetadata(), and Save().
|
private |
Definition at line 485 of file sprite_editor.cc.
References current_custom_sprite_index_, custom_sprites_, DrawBooleanProperties(), DrawStatProperties(), and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata().
|
private |
Definition at line 569 of file sprite_editor.cc.
References current_custom_sprite_index_, custom_sprites_, and zsm_dirty_.
Referenced by DrawSpritePropertiesPanel().
|
private |
Definition at line 514 of file sprite_editor.cc.
References current_custom_sprite_index_, custom_sprites_, and zsm_dirty_.
Referenced by DrawSpritePropertiesPanel().
|
private |
Definition at line 637 of file sprite_editor.cc.
References animation_playing_, current_animation_index_, current_custom_sprite_index_, current_frame_, custom_sprites_, DrawFrameEditor(), frame_timer_, ICON_MD_ADD, ICON_MD_PLAY_ARROW, ICON_MD_SKIP_NEXT, ICON_MD_SKIP_PREVIOUS, ICON_MD_STOP, preview_needs_update_, and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata().
|
private |
|
private |
Definition at line 738 of file sprite_editor.cc.
References current_custom_sprite_index_, current_frame_, custom_sprites_, ICON_MD_ADD, ICON_MD_DELETE, preview_needs_update_, selected_tile_index_, and zsm_dirty_.
Referenced by DrawAnimationPanel().
|
private |
Definition at line 853 of file sprite_editor.cc.
References animation_playing_, current_animation_index_, current_custom_sprite_index_, current_frame_, custom_sprites_, frame_timer_, and preview_needs_update_.
Referenced by Update().
|
private |
Definition at line 884 of file sprite_editor.cc.
References current_custom_sprite_index_, custom_sprites_, ICON_MD_ADD, selected_routine_index_, and zsm_dirty_.
Referenced by DrawCustomSpritesMetadata().
|
private |
Definition at line 1112 of file sprite_editor.cc.
References yaze::gfx::SnesPalette::AddColor(), yaze::editor::SpriteDrawer::ClearBitmap(), yaze::gfx::Bitmap::Create(), current_custom_sprite_index_, custom_sprites_, yaze::gui::Canvas::DrawBitmap(), yaze::editor::SpriteDrawer::DrawFrame(), yaze::gui::Canvas::DrawRect(), gfx_buffer_loaded_, yaze::gfx::Bitmap::is_active(), yaze::editor::SpriteDrawer::IsReady(), LoadSpriteGraphicsBuffer(), LoadSpritePalettes(), yaze::gfx::PaletteGroup::palette(), preview_needs_update_, yaze::gfx::Bitmap::Reformat(), selected_tile_index_, yaze::gfx::Bitmap::SetPalette(), sheets_loaded_, show_tile_grid_, yaze::gfx::SnesPalette::size(), yaze::gfx::PaletteGroup::size(), sprite_canvas_, sprite_drawer_, sprite_gfx_buffer_, sprite_palettes_, and sprite_preview_bitmap_.
Referenced by DrawZSpriteOnCanvas().
|
private |
Definition at line 1193 of file sprite_editor.cc.
References current_custom_sprite_index_, current_frame_, custom_sprites_, yaze::gui::Canvas::DrawBackground(), yaze::gui::Canvas::DrawContextMenu(), yaze::gui::Canvas::DrawGrid(), yaze::gui::Canvas::DrawOverlay(), yaze::gui::GetID(), RenderZSpriteFrame(), and sprite_canvas_.
Referenced by DrawCustomSprites().
|
private |
Definition at line 942 of file sprite_editor.cc.
References current_sheets_, yaze::gfx::Arena::Get(), gfx_buffer_loaded_, yaze::gfx::Arena::gfx_sheets(), yaze::editor::SpriteDrawer::SetGraphicsBuffer(), sprite_drawer_, and sprite_gfx_buffer_.
Referenced by RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 987 of file sprite_editor.cc.
References yaze::gfx::PaletteGroup::AddPalette(), yaze::gfx::PaletteGroup::clear(), yaze::editor::Editor::game_data(), yaze::gfx::PaletteGroupMap::global_sprites, yaze::Rom::is_loaded(), yaze::zelda3::GameData::palette_groups, rom_, yaze::editor::SpriteDrawer::SetPalettes(), yaze::gfx::PaletteGroup::size(), sprite_drawer_, sprite_palettes_, yaze::gfx::PaletteGroupMap::sprites_aux1, yaze::gfx::PaletteGroupMap::sprites_aux2, and yaze::gfx::PaletteGroupMap::sprites_aux3.
Referenced by RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 1049 of file sprite_editor.cc.
References yaze::gfx::SnesPalette::AddColor(), yaze::editor::SpriteDrawer::ClearBitmap(), yaze::gfx::Bitmap::Create(), yaze::editor::SpriteDrawer::DrawOamTile(), gfx_buffer_loaded_, yaze::editor::zsprite::OamTile::id, yaze::gfx::Bitmap::is_active(), yaze::editor::SpriteDrawer::IsReady(), LoadSpriteGraphicsBuffer(), LoadSpritePalettes(), yaze::editor::zsprite::OamTile::mirror_x, yaze::editor::zsprite::OamTile::mirror_y, yaze::editor::zsprite::OamTile::palette, yaze::gfx::PaletteGroup::palette(), yaze::editor::zsprite::OamTile::priority, yaze::gfx::Bitmap::Reformat(), yaze::gfx::Bitmap::SetPalette(), sheets_loaded_, yaze::editor::zsprite::OamTile::size, yaze::gfx::SnesPalette::size(), yaze::gfx::PaletteGroup::size(), sprite_drawer_, sprite_gfx_buffer_, sprite_palettes_, yaze::zelda3::SpriteOamLayout::tiles, vanilla_preview_bitmap_, vanilla_preview_needs_update_, yaze::editor::zsprite::OamTile::x, and yaze::editor::zsprite::OamTile::y.
Referenced by DrawSpriteCanvas().
|
private |
Definition at line 1033 of file sprite_editor.cc.
References current_sheets_, gfx_buffer_loaded_, and vanilla_preview_needs_update_.
Referenced by DrawSpriteCanvas().
|
private |
Definition at line 118 of file sprite_editor.h.
Referenced by DrawSpritesList(), and DrawVanillaSpriteEditor().
|
private |
Definition at line 119 of file sprite_editor.h.
Referenced by DrawSpriteCanvas(), DrawSpritesList(), DrawVanillaSpriteEditor(), and HandleEditorShortcuts().
|
private |
Definition at line 120 of file sprite_editor.h.
Referenced by DrawCurrentSheets(), LoadSheetsForSprite(), and LoadSpriteGraphicsBuffer().
|
private |
Definition at line 121 of file sprite_editor.h.
Referenced by DrawVanillaSpriteEditor(), RenderVanillaSprite(), RenderZSpriteFrame(), and Update().
|
private |
Definition at line 133 of file sprite_editor.h.
Referenced by DrawSpriteCanvas().
|
private |
Definition at line 134 of file sprite_editor.h.
|
private |
Definition at line 135 of file sprite_editor.h.
Referenced by DrawSpriteCanvas(), and RenderVanillaSprite().
|
private |
Definition at line 136 of file sprite_editor.h.
Referenced by DrawSpritesList(), HandleEditorShortcuts(), LoadSheetsForSprite(), and RenderVanillaSprite().
|
private |
Definition at line 141 of file sprite_editor.h.
Referenced by CreateNewZSprite(), DrawAnimationPanel(), DrawBooleanProperties(), DrawCustomSpritesMetadata(), DrawFrameEditor(), DrawSpritePropertiesPanel(), DrawStatProperties(), DrawUserRoutinesPanel(), DrawZSpriteOnCanvas(), LoadZsmFile(), RenderZSpriteFrame(), Save(), SaveZsmFile(), and UpdateAnimationPlayback().
|
private |
Definition at line 142 of file sprite_editor.h.
Referenced by CreateNewZSprite(), DrawAnimationPanel(), DrawBooleanProperties(), DrawCustomSpritesMetadata(), DrawFrameEditor(), DrawSpritePropertiesPanel(), DrawStatProperties(), DrawUserRoutinesPanel(), DrawZSpriteOnCanvas(), LoadZsmFile(), RenderZSpriteFrame(), Save(), SaveZsmFile(), SaveZsmFileAs(), and UpdateAnimationPlayback().
|
private |
Definition at line 143 of file sprite_editor.h.
Referenced by CreateNewZSprite(), DrawCustomSpritesMetadata(), LoadZsmFile(), Save(), and SaveZsmFile().
|
private |
Definition at line 144 of file sprite_editor.h.
Referenced by CreateNewZSprite(), DrawAnimationPanel(), DrawBooleanProperties(), DrawFrameEditor(), DrawSpritePropertiesPanel(), DrawStatProperties(), DrawUserRoutinesPanel(), LoadZsmFile(), and SaveZsmFile().
|
private |
Definition at line 147 of file sprite_editor.h.
Referenced by DrawAnimationPanel(), HandleEditorShortcuts(), and UpdateAnimationPlayback().
|
private |
Definition at line 148 of file sprite_editor.h.
Referenced by DrawAnimationPanel(), DrawFrameEditor(), DrawZSpriteOnCanvas(), HandleEditorShortcuts(), and UpdateAnimationPlayback().
|
private |
Definition at line 149 of file sprite_editor.h.
Referenced by DrawAnimationPanel(), and UpdateAnimationPlayback().
|
private |
Definition at line 150 of file sprite_editor.h.
Referenced by DrawAnimationPanel(), and UpdateAnimationPlayback().
|
private |
Definition at line 151 of file sprite_editor.h.
Referenced by Update().
|
private |
Definition at line 154 of file sprite_editor.h.
Referenced by DrawUserRoutinesPanel().
|
private |
Definition at line 155 of file sprite_editor.h.
Referenced by DrawFrameEditor(), and RenderZSpriteFrame().
|
private |
Definition at line 156 of file sprite_editor.h.
Referenced by RenderZSpriteFrame().
|
private |
Definition at line 159 of file sprite_editor.h.
Referenced by RenderZSpriteFrame().
|
private |
Definition at line 160 of file sprite_editor.h.
Referenced by CreateNewZSprite(), DrawAnimationPanel(), DrawCurrentSheets(), DrawCustomSpritesMetadata(), DrawFrameEditor(), HandleEditorShortcuts(), LoadZsmFile(), RenderZSpriteFrame(), and UpdateAnimationPlayback().
|
private |
Definition at line 165 of file sprite_editor.h.
Referenced by LoadSpriteGraphicsBuffer(), LoadSpritePalettes(), RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 166 of file sprite_editor.h.
Referenced by LoadSpriteGraphicsBuffer(), RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 167 of file sprite_editor.h.
Referenced by LoadSpritePalettes(), RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 168 of file sprite_editor.h.
Referenced by DrawCurrentSheets(), LoadSheetsForSprite(), LoadSpriteGraphicsBuffer(), RenderVanillaSprite(), and RenderZSpriteFrame().
|
private |
Definition at line 173 of file sprite_editor.h.
Referenced by DrawSpriteCanvas(), DrawZSpriteOnCanvas(), and RenderZSpriteFrame().
|
private |
Definition at line 176 of file sprite_editor.h.
Referenced by DrawCurrentSheets().
|
private |
Definition at line 183 of file sprite_editor.h.
Referenced by LoadZsmFile(), SaveZsmFile(), and Update().
|
private |
Definition at line 184 of file sprite_editor.h.
Referenced by Initialize(), LoadSpritePalettes(), rom(), and set_rom().