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:

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, int sheet_offset=0)
 
void ModifyTile16 (const std::vector< uint8_t > &graphics_buffer, const TileInfo &top_left, const TileInfo &top_right, const TileInfo &bottom_left, const TileInfo &bottom_right, int tile_id, int sheet_offset=0)
 
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_id)
 
void CopyTile (int srcX, int srcY, int destX, int destY, bool mirror_x=false, bool mirror_y=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 ()
 
void clear ()
 

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 mirror_x, bool mirror_y)
 
void WriteTile (int x, int y, const std::vector< uint8_t > &tileData)
 

Private Attributes

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

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 30 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 33 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,
int sheet_offset = 0 )

Definition at line 62 of file tilesheet.cc.

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

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

Here is the call graph for this function:

◆ ModifyTile16()

void yaze::app::gfx::Tilesheet::ModifyTile16 ( const std::vector< uint8_t > & graphics_buffer,
const TileInfo & top_left,
const TileInfo & top_right,
const TileInfo & bottom_left,
const TileInfo & bottom_right,
int tile_id,
int sheet_offset = 0 )

Definition at line 87 of file tilesheet.cc.

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

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

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 111 of file tilesheet.cc.

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

Referenced by ComposeTile16(), and ModifyTile16().

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 55 of file tilesheet.h.

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

Referenced by CopyTile().

Here is the call graph for this function:

◆ GetTile16()

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

◆ CopyTile()

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

Definition at line 78 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 86 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 88 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 89 of file tilesheet.h.

References tile_width_.

Referenced by FetchTileDataFromGraphicsBuffer().

◆ tile_height()

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

Definition at line 90 of file tilesheet.h.

References tile_height_.

Referenced by FetchTileDataFromGraphicsBuffer().

◆ set_palette()

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

Definition at line 91 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 92 of file tilesheet.h.

References palette_.

Referenced by set_palette().

◆ tile_type()

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

Definition at line 93 of file tilesheet.h.

References tile_type_.

Referenced by Init().

◆ tile_info()

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

◆ mutable_tile_info()

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

Definition at line 95 of file tilesheet.h.

References tile_info_.

◆ clear()

void yaze::app::gfx::Tilesheet::clear ( )
inline

Definition at line 96 of file tilesheet.h.

References bitmap_, yaze::app::gfx::SnesPalette::clear(), internal_data_, num_tiles_, palette_, and tile_info_.

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

Here is the call graph for this function:

◆ CalculateTileIndex()

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

Definition at line 105 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 )
private

Definition at line 138 of file tilesheet.cc.

References sheet_offset_, tile_height(), and tile_width().

Referenced by ComposeAndPlaceTilePart().

Here is the call graph for this function:

◆ MirrorTileDataVertically()

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

Definition at line 176 of file tilesheet.cc.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileDataHorizontally()

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

Definition at line 188 of file tilesheet.cc.

Referenced by ComposeAndPlaceTilePart(), and MirrorTileData().

◆ MirrorTileData()

void yaze::app::gfx::Tilesheet::MirrorTileData ( std::vector< uint8_t > & tileData,
bool mirror_x,
bool mirror_y )
private

Definition at line 200 of file tilesheet.cc.

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 117 of file tilesheet.h.

References bitmap_, and CalculateTileIndex().

Referenced by CopyTile().

Here is the call graph for this function:

Member Data Documentation

◆ num_tiles_

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

Definition at line 124 of file tilesheet.h.

Referenced by clear(), 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 126 of file tilesheet.h.

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

◆ sheet_offset_

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

Definition at line 127 of file tilesheet.h.

Referenced by ComposeTile16(), FetchTileDataFromGraphicsBuffer(), and ModifyTile16().

◆ tile_type_

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

Definition at line 129 of file tilesheet.h.

Referenced by Init(), and tile_type().

◆ palette_

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

Definition at line 130 of file tilesheet.h.

Referenced by clear(), palette(), and set_palette().

◆ internal_data_

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

Definition at line 131 of file tilesheet.h.

Referenced by clear(), ComposeAndPlaceTilePart(), and Init().

◆ tile_info_

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

Definition at line 132 of file tilesheet.h.

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

◆ bitmap_

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

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