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

Allows the user to edit sprites. More...

#include <sprite_editor.h>

Inheritance diagram for yaze::editor::SpriteEditor:

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)
 
Romrom () 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
 
Romrom () const
 
zelda3::GameDatagame_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::ZSpritecustom_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_
 
Romrom_
 

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_
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SpriteEditor()

yaze::editor::SpriteEditor::SpriteEditor ( Rom * rom = nullptr)
inlineexplicit

Definition at line 45 of file sprite_editor.h.

References yaze::editor::kSprite, and yaze::editor::Editor::type_.

Member Function Documentation

◆ Initialize()

void yaze::editor::SpriteEditor::Initialize ( )
overridevirtual

◆ Load()

absl::Status yaze::editor::SpriteEditor::Load ( )
overridevirtual

Implements yaze::editor::Editor.

Definition at line 52 of file sprite_editor.cc.

◆ Update()

absl::Status yaze::editor::SpriteEditor::Update ( )
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().

Here is the call graph for this function:

◆ Undo()

absl::Status yaze::editor::SpriteEditor::Undo ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 52 of file sprite_editor.h.

◆ Redo()

absl::Status yaze::editor::SpriteEditor::Redo ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 53 of file sprite_editor.h.

◆ Cut()

absl::Status yaze::editor::SpriteEditor::Cut ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 54 of file sprite_editor.h.

◆ Copy()

absl::Status yaze::editor::SpriteEditor::Copy ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 55 of file sprite_editor.h.

◆ Paste()

absl::Status yaze::editor::SpriteEditor::Paste ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 56 of file sprite_editor.h.

◆ Find()

absl::Status yaze::editor::SpriteEditor::Find ( )
inlineoverridevirtual

Implements yaze::editor::Editor.

Definition at line 57 of file sprite_editor.h.

◆ Save()

absl::Status yaze::editor::SpriteEditor::Save ( )
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().

Here is the call graph for this function:

◆ set_rom()

void yaze::editor::SpriteEditor::set_rom ( Rom * rom)
inline

Definition at line 60 of file sprite_editor.h.

References rom(), and rom_.

Here is the call graph for this function:

◆ rom()

Rom * yaze::editor::SpriteEditor::rom ( ) const
inline

Definition at line 61 of file sprite_editor.h.

References rom_.

Referenced by DrawSpritesList(), set_rom(), and Update().

◆ HandleEditorShortcuts()

void yaze::editor::SpriteEditor::HandleEditorShortcuts ( )
private

◆ DrawVanillaSpriteEditor()

void yaze::editor::SpriteEditor::DrawVanillaSpriteEditor ( )
private

◆ DrawSpritesList()

◆ DrawSpriteCanvas()

◆ DrawCurrentSheets()

◆ DrawToolset()

void yaze::editor::SpriteEditor::DrawToolset ( )
private

Definition at line 120 of file sprite_editor.cc.

◆ DrawCustomSprites()

void yaze::editor::SpriteEditor::DrawCustomSprites ( )
private

Definition at line 337 of file sprite_editor.cc.

References DrawCurrentSheets(), DrawCustomSpritesMetadata(), and DrawZSpriteOnCanvas().

Referenced by Initialize().

Here is the call graph for this function:

◆ DrawCustomSpritesMetadata()

◆ DrawAnimationFrames()

void yaze::editor::SpriteEditor::DrawAnimationFrames ( )
private

Definition at line 324 of file sprite_editor.cc.

Referenced by DrawSpriteCanvas().

◆ CreateNewZSprite()

◆ LoadZsmFile()

void yaze::editor::SpriteEditor::LoadZsmFile ( const std::string & path)
private

◆ SaveZsmFile()

void yaze::editor::SpriteEditor::SaveZsmFile ( const std::string & path)
private

◆ SaveZsmFileAs()

void yaze::editor::SpriteEditor::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().

Here is the call graph for this function:

◆ DrawSpritePropertiesPanel()

void yaze::editor::SpriteEditor::DrawSpritePropertiesPanel ( )
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().

Here is the call graph for this function:

◆ DrawBooleanProperties()

void yaze::editor::SpriteEditor::DrawBooleanProperties ( )
private

Definition at line 569 of file sprite_editor.cc.

References current_custom_sprite_index_, custom_sprites_, and zsm_dirty_.

Referenced by DrawSpritePropertiesPanel().

◆ DrawStatProperties()

void yaze::editor::SpriteEditor::DrawStatProperties ( )
private

Definition at line 514 of file sprite_editor.cc.

References current_custom_sprite_index_, custom_sprites_, and zsm_dirty_.

Referenced by DrawSpritePropertiesPanel().

◆ DrawAnimationPanel()

void yaze::editor::SpriteEditor::DrawAnimationPanel ( )
private

◆ DrawAnimationList()

void yaze::editor::SpriteEditor::DrawAnimationList ( )
private

◆ DrawFrameEditor()

void yaze::editor::SpriteEditor::DrawFrameEditor ( )
private

◆ UpdateAnimationPlayback()

void yaze::editor::SpriteEditor::UpdateAnimationPlayback ( float delta_time)
private

◆ DrawUserRoutinesPanel()

void yaze::editor::SpriteEditor::DrawUserRoutinesPanel ( )
private

◆ RenderZSpriteFrame()

◆ DrawZSpriteOnCanvas()

◆ LoadSpriteGraphicsBuffer()

void yaze::editor::SpriteEditor::LoadSpriteGraphicsBuffer ( )
private

◆ LoadSpritePalettes()

◆ RenderVanillaSprite()

◆ LoadSheetsForSprite()

void yaze::editor::SpriteEditor::LoadSheetsForSprite ( const std::array< uint8_t, 4 > & sheets)
private

Definition at line 1033 of file sprite_editor.cc.

References current_sheets_, gfx_buffer_loaded_, and vanilla_preview_needs_update_.

Referenced by DrawSpriteCanvas().

Member Data Documentation

◆ active_sprites_

ImVector<int> yaze::editor::SpriteEditor::active_sprites_
private

Definition at line 118 of file sprite_editor.h.

Referenced by DrawSpritesList(), and DrawVanillaSpriteEditor().

◆ current_sprite_id_

int yaze::editor::SpriteEditor::current_sprite_id_ = 0
private

◆ current_sheets_

uint8_t yaze::editor::SpriteEditor::current_sheets_[8] = {0x00, 0x0A, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00}
private

◆ sheets_loaded_

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

◆ oam_config_

OAMConfig yaze::editor::SpriteEditor::oam_config_
private

Definition at line 133 of file sprite_editor.h.

Referenced by DrawSpriteCanvas().

◆ oam_bitmap_

gfx::Bitmap yaze::editor::SpriteEditor::oam_bitmap_
private

Definition at line 134 of file sprite_editor.h.

◆ vanilla_preview_bitmap_

gfx::Bitmap yaze::editor::SpriteEditor::vanilla_preview_bitmap_
private

Definition at line 135 of file sprite_editor.h.

Referenced by DrawSpriteCanvas(), and RenderVanillaSprite().

◆ vanilla_preview_needs_update_

bool yaze::editor::SpriteEditor::vanilla_preview_needs_update_ = true
private

◆ custom_sprites_

◆ current_custom_sprite_index_

◆ current_zsm_path_

std::string yaze::editor::SpriteEditor::current_zsm_path_
private

◆ zsm_dirty_

◆ animation_playing_

bool yaze::editor::SpriteEditor::animation_playing_ = false
private

◆ current_frame_

int yaze::editor::SpriteEditor::current_frame_ = 0
private

◆ current_animation_index_

int yaze::editor::SpriteEditor::current_animation_index_ = 0
private

Definition at line 149 of file sprite_editor.h.

Referenced by DrawAnimationPanel(), and UpdateAnimationPlayback().

◆ frame_timer_

float yaze::editor::SpriteEditor::frame_timer_ = 0.0f
private

Definition at line 150 of file sprite_editor.h.

Referenced by DrawAnimationPanel(), and UpdateAnimationPlayback().

◆ last_frame_time_

float yaze::editor::SpriteEditor::last_frame_time_ = 0.0f
private

Definition at line 151 of file sprite_editor.h.

Referenced by Update().

◆ selected_routine_index_

int yaze::editor::SpriteEditor::selected_routine_index_ = -1
private

Definition at line 154 of file sprite_editor.h.

Referenced by DrawUserRoutinesPanel().

◆ selected_tile_index_

int yaze::editor::SpriteEditor::selected_tile_index_ = -1
private

Definition at line 155 of file sprite_editor.h.

Referenced by DrawFrameEditor(), and RenderZSpriteFrame().

◆ show_tile_grid_

bool yaze::editor::SpriteEditor::show_tile_grid_ = true
private

Definition at line 156 of file sprite_editor.h.

Referenced by RenderZSpriteFrame().

◆ sprite_preview_bitmap_

gfx::Bitmap yaze::editor::SpriteEditor::sprite_preview_bitmap_
private

Definition at line 159 of file sprite_editor.h.

Referenced by RenderZSpriteFrame().

◆ preview_needs_update_

bool yaze::editor::SpriteEditor::preview_needs_update_ = true
private

◆ sprite_drawer_

SpriteDrawer yaze::editor::SpriteEditor::sprite_drawer_
private

◆ sprite_gfx_buffer_

std::vector<uint8_t> yaze::editor::SpriteEditor::sprite_gfx_buffer_
private

◆ sprite_palettes_

gfx::PaletteGroup yaze::editor::SpriteEditor::sprite_palettes_
private

Definition at line 167 of file sprite_editor.h.

Referenced by LoadSpritePalettes(), RenderVanillaSprite(), and RenderZSpriteFrame().

◆ gfx_buffer_loaded_

bool yaze::editor::SpriteEditor::gfx_buffer_loaded_ = false
private

◆ sprite_canvas_

gui::Canvas yaze::editor::SpriteEditor::sprite_canvas_
private
Initial value:
{"SpriteCanvas", ImVec2(0x200, 0x200),

Definition at line 173 of file sprite_editor.h.

Referenced by DrawSpriteCanvas(), DrawZSpriteOnCanvas(), and RenderZSpriteFrame().

◆ graphics_sheet_canvas_

gui::Canvas yaze::editor::SpriteEditor::graphics_sheet_canvas_
private
Initial value:
{"GraphicsSheetCanvas",
ImVec2(0x80 * 2 + 2, 0x40 * 8 + 2),

Definition at line 176 of file sprite_editor.h.

Referenced by DrawCurrentSheets().

◆ status_

absl::Status yaze::editor::SpriteEditor::status_
private

Definition at line 183 of file sprite_editor.h.

Referenced by LoadZsmFile(), SaveZsmFile(), and Update().

◆ rom_

Rom* yaze::editor::SpriteEditor::rom_
private

Definition at line 184 of file sprite_editor.h.

Referenced by Initialize(), LoadSpritePalettes(), rom(), and set_rom().


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