yaze 0.2.0
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::app::gfx::Tilesheet Class Reference

Represents a tilesheet, which is a collection of tiles stored in a bitmap. More...

#include <tilesheet.h>

Collaboration diagram for yaze::app::gfx::Tilesheet:

Classes

struct  InternalTile16
 

Public Member Functions

 Tilesheet ()=default
 
 Tilesheet (std::shared_ptr< Bitmap > bitmap, int tileWidth, int tileHeight, TileType tile_type)
 
void Init (int width, int height, TileType tile_type)
 
void ComposeTile16 (const std::vector< uint8_t > &graphics_buffer, const TileInfo &top_left, const TileInfo &top_right, const TileInfo &bottom_left, const TileInfo &bottom_right)
 
void ComposeAndPlaceTilePart (const std::vector< uint8_t > &graphics_buffer, const TileInfo &tile_info, int baseX, int baseY)
 
Bitmap GetTile (int tileX, int tileY, int bmp_width, int bmp_height)
 
Bitmap GetTile16 (int tile_x, int tile_y)
 
Bitmap GetTile16 (int tile_id)
 
void CopyTile (int srcX, int srcY, int destX, int destY, bool mirrorX=false, bool mirrorY=false)
 
auto bitmap () const
 
auto mutable_bitmap ()
 
auto num_tiles () const
 
auto tile_width () const
 
auto tile_height () const
 
auto set_palette (gfx::SnesPalette &palette)
 
auto palette () const
 
auto tile_type () const
 
auto tile_info () const
 
auto mutable_tile_info ()
 

Private Member Functions

int CalculateTileIndex (int x, int y)
 
std::vector< uint8_t > FetchTileDataFromGraphicsBuffer (const std::vector< uint8_t > &graphics_buffer, int tile_id)
 
void MirrorTileDataVertically (std::vector< uint8_t > &tileData)
 
void MirrorTileDataHorizontally (std::vector< uint8_t > &tileData)
 
void MirrorTileData (std::vector< uint8_t > &tileData, bool mirrorX, bool mirrorY)
 
void WriteTile (int x, int y, const std::vector< uint8_t > &tileData)
 

Private Attributes

gfx::SnesPalette palette_
 
std::vector< uint8_t > internal_data_
 
std::shared_ptr< Bitmapbitmap_
 
std::vector< InternalTile16tile_info_
 
int num_tiles_ = 0
 
int tile_width_ = 0
 
int tile_height_ = 0
 
TileType tile_type_
 

Detailed Description

Represents a tilesheet, which is a collection of tiles stored in a bitmap.

The Tilesheet class provides methods to manipulate and extract tiles from the tilesheet. It also supports copying and mirroring tiles within the tilesheet.

Definition at line 26 of file tilesheet.h.

Constructor & Destructor Documentation

◆ Tilesheet() [1/2]

yaze::app::gfx::Tilesheet::Tilesheet ( )
default

◆ Tilesheet() [2/2]

yaze::app::gfx::Tilesheet::Tilesheet ( std::shared_ptr< Bitmap > bitmap,
int tileWidth,
int tileHeight,
TileType tile_type )
inline

Definition at line 29 of file tilesheet.h.

Member Function Documentation

◆ Init()

void yaze::app::gfx::Tilesheet::Init ( int width,
int height,
TileType tile_type )

◆ ComposeTile16()

void yaze::app::gfx::Tilesheet::ComposeTile16 ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & top_left,
const TileInfo & top_right,
const TileInfo & bottom_left,
const TileInfo & bottom_right )

Definition at line 62 of file tilesheet.cc.

References bitmap_, ComposeAndPlaceTilePart(), num_tiles_, tile_height_, tile_info_, and tile_width_.

Referenced by yaze::app::editor::ScreenEditor::LoadDungeonMapTile16().

Here is the call graph for this function:

◆ ComposeAndPlaceTilePart()

void yaze::app::gfx::Tilesheet::ComposeAndPlaceTilePart ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & tile_info,
int baseX,
int baseY )

Definition at line 85 of file tilesheet.cc.

References bitmap_, FetchTileDataFromGraphicsBuffer(), internal_data_, MirrorTileDataHorizontally(), MirrorTileDataVertically(), and tile_info().

Referenced by ComposeTile16().

Here is the call graph for this function:

◆ GetTile()

Bitmap yaze::app::gfx::Tilesheet::GetTile ( int tileX,
int tileY,
int bmp_width,
int bmp_height )
inline

Definition at line 46 of file tilesheet.h.

References bitmap_, CalculateTileIndex(), tile_height_, and tile_width_.

Referenced by CopyTile().

Here is the call graph for this function:

◆ GetTile16() [1/2]

Bitmap yaze::app::gfx::Tilesheet::GetTile16 ( int tile_x,
int tile_y )
inline

◆ GetTile16() [2/2]

Bitmap yaze::app::gfx::Tilesheet::GetTile16 ( int tile_id)
inline

Definition at line 61 of file tilesheet.h.

References bitmap_, GetTile16(), tile_height_, tile_width_, and yaze::app::gfx::Bitmap::width().

Here is the call graph for this function:

◆ CopyTile()

void yaze::app::gfx::Tilesheet::CopyTile ( int srcX,
int srcY,
int destX,
int destY,
bool mirrorX = false,
bool mirrorY = false )
inline

Definition at line 69 of file tilesheet.h.

References GetTile(), MirrorTileData(), tile_height_, tile_width_, and WriteTile().

Here is the call graph for this function:

◆ bitmap()

auto yaze::app::gfx::Tilesheet::bitmap ( ) const
inline

Definition at line 78 of file tilesheet.h.

References bitmap_.

Referenced by yaze::app::editor::ScreenEditor::DrawDungeonMapsEditor().

◆ mutable_bitmap()

auto yaze::app::gfx::Tilesheet::mutable_bitmap ( )
inline

◆ num_tiles()

auto yaze::app::gfx::Tilesheet::num_tiles ( ) const
inline

Definition at line 80 of file tilesheet.h.

References num_tiles_.

Referenced by yaze::app::editor::ScreenEditor::LoadDungeonMapTile16().

◆ tile_width()

auto yaze::app::gfx::Tilesheet::tile_width ( ) const
inline

Definition at line 81 of file tilesheet.h.

References tile_width_.

◆ tile_height()

auto yaze::app::gfx::Tilesheet::tile_height ( ) const
inline

Definition at line 82 of file tilesheet.h.

References tile_height_.

◆ set_palette()

auto yaze::app::gfx::Tilesheet::set_palette ( gfx::SnesPalette & palette)
inline

Definition at line 83 of file tilesheet.h.

References palette(), and palette_.

Here is the call graph for this function:

◆ palette()

auto yaze::app::gfx::Tilesheet::palette ( ) const
inline

Definition at line 84 of file tilesheet.h.

References palette_.

Referenced by set_palette().

◆ tile_type()

auto yaze::app::gfx::Tilesheet::tile_type ( ) const
inline

Definition at line 85 of file tilesheet.h.

References tile_type_.

Referenced by Init().

◆ tile_info()

auto yaze::app::gfx::Tilesheet::tile_info ( ) const
inline

Definition at line 86 of file tilesheet.h.

References tile_info_.

Referenced by ComposeAndPlaceTilePart().

◆ mutable_tile_info()

auto yaze::app::gfx::Tilesheet::mutable_tile_info ( )
inline

Definition at line 87 of file tilesheet.h.

References tile_info_.

◆ CalculateTileIndex()

int yaze::app::gfx::Tilesheet::CalculateTileIndex ( int x,
int y )
inlineprivate

Definition at line 90 of file tilesheet.h.

References bitmap_, and tile_width_.

Referenced by GetTile(), and WriteTile().

◆ FetchTileDataFromGraphicsBuffer()

std::vector< uint8_t > yaze::app::gfx::Tilesheet::FetchTileDataFromGraphicsBuffer ( const std::vector< uint8_t > & graphics_buffer,
int tile_id )
inlineprivate

Definition at line 94 of file tilesheet.h.

Referenced by ComposeAndPlaceTilePart().

◆ MirrorTileDataVertically()

void yaze::app::gfx::Tilesheet::MirrorTileDataVertically ( std::vector< uint8_t > & tileData)
inlineprivate

Definition at line 133 of file tilesheet.h.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileDataHorizontally()

void yaze::app::gfx::Tilesheet::MirrorTileDataHorizontally ( std::vector< uint8_t > & tileData)
inlineprivate

Definition at line 145 of file tilesheet.h.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileData()

void yaze::app::gfx::Tilesheet::MirrorTileData ( std::vector< uint8_t > & tileData,
bool mirrorX,
bool mirrorY )
inlineprivate

Definition at line 157 of file tilesheet.h.

References MirrorTileDataHorizontally(), and MirrorTileDataVertically().

Referenced by CopyTile().

Here is the call graph for this function:

◆ WriteTile()

void yaze::app::gfx::Tilesheet::WriteTile ( int x,
int y,
const std::vector< uint8_t > & tileData )
inlineprivate

Definition at line 170 of file tilesheet.h.

References bitmap_, and CalculateTileIndex().

Referenced by CopyTile().

Here is the call graph for this function:

Member Data Documentation

◆ palette_

gfx::SnesPalette yaze::app::gfx::Tilesheet::palette_
private

Definition at line 177 of file tilesheet.h.

Referenced by palette(), and set_palette().

◆ internal_data_

std::vector<uint8_t> yaze::app::gfx::Tilesheet::internal_data_
private

Definition at line 178 of file tilesheet.h.

Referenced by ComposeAndPlaceTilePart(), and Init().

◆ bitmap_

std::shared_ptr<Bitmap> yaze::app::gfx::Tilesheet::bitmap_
private

◆ tile_info_

std::vector<InternalTile16> yaze::app::gfx::Tilesheet::tile_info_
private

Definition at line 183 of file tilesheet.h.

Referenced by ComposeTile16(), mutable_tile_info(), and tile_info().

◆ num_tiles_

int yaze::app::gfx::Tilesheet::num_tiles_ = 0
private

Definition at line 184 of file tilesheet.h.

Referenced by ComposeTile16(), and num_tiles().

◆ tile_width_

int yaze::app::gfx::Tilesheet::tile_width_ = 0
private

◆ tile_height_

int yaze::app::gfx::Tilesheet::tile_height_ = 0
private

Definition at line 186 of file tilesheet.h.

Referenced by ComposeTile16(), CopyTile(), GetTile(), GetTile16(), GetTile16(), Init(), and tile_height().

◆ tile_type_

TileType yaze::app::gfx::Tilesheet::tile_type_
private

Definition at line 187 of file tilesheet.h.

Referenced by Init(), and tile_type().


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