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

#include <usage_preview.h>

Collaboration diagram for yaze::editor::usage_preview::SpriteUsagePreview:

Public Member Functions

absl::Status Configure (Rom *rom, zelda3::GameData *game_data, int spriteset, int palette_room, std::string hack_name={})
 
void SetVanillaSprite (uint8_t sprite_id)
 Plays a vanilla sprite (single pose from the sprite catalog).
 
void SetZsm (const zsprite::ZSprite &zsm, int animation)
 Plays animation animation of a .zsm (the preview keeps a copy).
 
bool has_zsm () const
 
int frame_count () const
 Frames in the current animation (1 for vanilla sprites).
 
int frame () const
 
void SetFrame (int frame)
 
bool Advance (float seconds)
 
PreviewImage RenderFrame (const SheetPixels &sheets) const
 Draws the current frame with sheets (edited pixels) over the ROM's.
 
const std::array< uint8_t, 8 > & slots () const
 
bool UsesSheet (uint16_t sheet) const
 

Private Member Functions

std::vector< uint8_t > SheetOrRom (const SheetPixels &sheets, uint16_t sheet) const
 

Private Attributes

Rom * rom_ = nullptr
 
zelda3::GameData * game_data_ = nullptr
 
std::array< uint8_t, 8 > slots_ {}
 
std::array< SDL_Color, 256 > colors_ {}
 
std::string hack_name_
 
uint8_t sprite_id_ = 0
 
std::optional< zsprite::ZSprite > zsm_
 
int animation_ = 0
 
int frame_ = 0
 
float remainder_ = 0.0f
 

Detailed Description

Definition at line 175 of file usage_preview.h.

Member Function Documentation

◆ Configure()

absl::Status yaze::editor::usage_preview::SpriteUsagePreview::Configure ( Rom * rom,
zelda3::GameData * game_data,
int spriteset,
int palette_room,
std::string hack_name = {} )

Sets the spriteset (sheets for OAM slots 4-7) and the palette source: the sprite palette of dungeon room palette_room, or the default sprite preview palettes when it is -1. hack_name selects project sprite layouts (SpriteOamRegistry::GetPreviewOverride).

Definition at line 387 of file usage_preview.cc.

References yaze::zelda3::BuildDungeonSpriteRenderPalette(), colors_, yaze::editor::internal::DefaultSpritePreviewPalettes(), game_data_, hack_name_, yaze::Rom::is_loaded(), yaze::zelda3::IsUnderworldSpriteset(), yaze::zelda3::LoadRoomHeaderFromRom(), yaze::zelda3::GameData::palette_groups, rom_, slots_, yaze::zelda3::GameData::spriteset_ids, and yaze::zelda3::SpriteSheetSlots().

◆ SetVanillaSprite()

void yaze::editor::usage_preview::SpriteUsagePreview::SetVanillaSprite ( uint8_t sprite_id)

Plays a vanilla sprite (single pose from the sprite catalog).

Definition at line 427 of file usage_preview.cc.

References frame_, remainder_, sprite_id_, and zsm_.

◆ SetZsm()

void yaze::editor::usage_preview::SpriteUsagePreview::SetZsm ( const zsprite::ZSprite & zsm,
int animation )

Plays animation animation of a .zsm (the preview keeps a copy).

Definition at line 434 of file usage_preview.cc.

References animation_, yaze::editor::zsprite::ZSprite::animations, frame_, remainder_, and zsm_.

◆ has_zsm()

bool yaze::editor::usage_preview::SpriteUsagePreview::has_zsm ( ) const
inline

Definition at line 188 of file usage_preview.h.

References zsm_.

◆ frame_count()

int yaze::editor::usage_preview::SpriteUsagePreview::frame_count ( ) const

Frames in the current animation (1 for vanilla sprites).

Definition at line 443 of file usage_preview.cc.

References zsm_.

Referenced by RenderFrame(), and SetFrame().

◆ frame()

int yaze::editor::usage_preview::SpriteUsagePreview::frame ( ) const
inline

Definition at line 192 of file usage_preview.h.

References frame_.

Referenced by SetFrame().

◆ SetFrame()

void yaze::editor::usage_preview::SpriteUsagePreview::SetFrame ( int frame)

Definition at line 450 of file usage_preview.cc.

References frame(), frame_, frame_count(), and remainder_.

Here is the call graph for this function:

◆ Advance()

bool yaze::editor::usage_preview::SpriteUsagePreview::Advance ( float seconds)

Advances by seconds at the animation's speed (60 ticks per second). Returns true when the frame changed.

Definition at line 455 of file usage_preview.cc.

References yaze::editor::sprite_authoring::Advance(), animation_, frame_, remainder_, and zsm_.

Here is the call graph for this function:

◆ RenderFrame()

◆ slots()

const std::array< uint8_t, 8 > & yaze::editor::usage_preview::SpriteUsagePreview::slots ( ) const
inline

Definition at line 201 of file usage_preview.h.

References slots_.

◆ UsesSheet()

bool yaze::editor::usage_preview::SpriteUsagePreview::UsesSheet ( uint16_t sheet) const

Definition at line 464 of file usage_preview.cc.

References slots_.

◆ SheetOrRom()

std::vector< uint8_t > yaze::editor::usage_preview::SpriteUsagePreview::SheetOrRom ( const SheetPixels & sheets,
uint16_t sheet ) const
private

Member Data Documentation

◆ rom_

Rom* yaze::editor::usage_preview::SpriteUsagePreview::rom_ = nullptr
private

Definition at line 208 of file usage_preview.h.

Referenced by Configure().

◆ game_data_

zelda3::GameData* yaze::editor::usage_preview::SpriteUsagePreview::game_data_ = nullptr
private

Definition at line 209 of file usage_preview.h.

Referenced by Configure(), RenderFrame(), and SheetOrRom().

◆ slots_

std::array<uint8_t, 8> yaze::editor::usage_preview::SpriteUsagePreview::slots_ {}
private

Definition at line 210 of file usage_preview.h.

Referenced by Configure(), RenderFrame(), slots(), and UsesSheet().

◆ colors_

std::array<SDL_Color, 256> yaze::editor::usage_preview::SpriteUsagePreview::colors_ {}
private

Definition at line 211 of file usage_preview.h.

Referenced by Configure(), and RenderFrame().

◆ hack_name_

std::string yaze::editor::usage_preview::SpriteUsagePreview::hack_name_
private

Definition at line 212 of file usage_preview.h.

Referenced by Configure(), and RenderFrame().

◆ sprite_id_

uint8_t yaze::editor::usage_preview::SpriteUsagePreview::sprite_id_ = 0
private

Definition at line 213 of file usage_preview.h.

Referenced by RenderFrame(), and SetVanillaSprite().

◆ zsm_

std::optional<zsprite::ZSprite> yaze::editor::usage_preview::SpriteUsagePreview::zsm_
private

Definition at line 214 of file usage_preview.h.

Referenced by Advance(), frame_count(), has_zsm(), RenderFrame(), SetVanillaSprite(), and SetZsm().

◆ animation_

int yaze::editor::usage_preview::SpriteUsagePreview::animation_ = 0
private

Definition at line 215 of file usage_preview.h.

Referenced by Advance(), and SetZsm().

◆ frame_

int yaze::editor::usage_preview::SpriteUsagePreview::frame_ = 0
private

Definition at line 216 of file usage_preview.h.

Referenced by Advance(), frame(), RenderFrame(), SetFrame(), SetVanillaSprite(), and SetZsm().

◆ remainder_

float yaze::editor::usage_preview::SpriteUsagePreview::remainder_ = 0.0f
private

Definition at line 217 of file usage_preview.h.

Referenced by Advance(), SetFrame(), SetVanillaSprite(), and SetZsm().


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