OpenTTD Source  20240917-master-g9ab0a47812
SpriteFile Class Reference

RandomAccessFile with some extra information specific for sprite files. More...

#include <sprite_file_type.hpp>

Inheritance diagram for SpriteFile:
RandomAccessFile

Public Member Functions

 SpriteFile (const std::string &filename, Subdirectory subdir, bool palette_remap)
 Create the SpriteFile. More...
 
 SpriteFile (const SpriteFile &)=delete
 
void operator= (const SpriteFile &)=delete
 
bool NeedsPaletteRemap () const
 Whether a palette remap is needed when loading sprites from this file. More...
 
uint8_t GetContainerVersion () const
 Get the version number of container type used by the file. More...
 
void SeekToBegin ()
 Seek to the begin of the content, i.e. More...
 
- Public Member Functions inherited from RandomAccessFile
 RandomAccessFile (const std::string &filename, Subdirectory subdir)
 Create the RandomAccesFile. More...
 
 RandomAccessFile (const RandomAccessFile &)=delete
 
void operator= (const RandomAccessFile &)=delete
 
const std::string & GetFilename () const
 Get the filename of the opened file with the path from the SubDirectory and the extension. More...
 
const std::string & GetSimplifiedFilename () const
 Get the simplified filename of the opened file. More...
 
size_t GetPos () const
 Get position in the file. More...
 
size_t GetStartPos () const
 
size_t GetEndPos () const
 
void SeekTo (size_t pos, int mode)
 Seek in the current file. More...
 
bool AtEndOfFile () const
 Test if we have reached the end of the file. More...
 
uint8_t ReadByte ()
 Read a byte from the file. More...
 
uint16_t ReadWord ()
 Read a word (16 bits) from the file (in low endian format). More...
 
uint32_t ReadDword ()
 Read a double word (32 bits) from the file (in low endian format). More...
 
void ReadBlock (void *ptr, size_t size)
 Read a block. More...
 
void SkipBytes (size_t n)
 Skip n bytes ahead in the file. More...
 

Private Attributes

bool palette_remap
 Whether or not a remap of the palette is required for this file.
 
uint8_t container_version
 Container format of the sprite file.
 
size_t content_begin
 The begin of the content of the sprite file, i.e. after the container metadata.
 

Detailed Description

RandomAccessFile with some extra information specific for sprite files.

It automatically detects and stores the container version upload opening the file.

Definition at line 19 of file sprite_file_type.hpp.

Constructor & Destructor Documentation

◆ SpriteFile()

SpriteFile::SpriteFile ( const std::string &  filename,
Subdirectory  subdir,
bool  palette_remap 
)

Create the SpriteFile.

Parameters
filenameName of the file at the disk.
subdirThe sub directory to search this file in.
palette_remapWhether a palette remap needs to be performed for this file.

Definition at line 45 of file sprite_file.cpp.

References container_version, content_begin, GetGRFContainerVersion(), and RandomAccessFile::GetPos().

Member Function Documentation

◆ GetContainerVersion()

uint8_t SpriteFile::GetContainerVersion ( ) const
inline

Get the version number of container type used by the file.

Returns
The version.

Definition at line 38 of file sprite_file_type.hpp.

References container_version.

Referenced by LoadGrfFile(), LoadGrfFileIndexed(), LoadNextSprite(), and ReadGRFSpriteOffsets().

◆ NeedsPaletteRemap()

bool SpriteFile::NeedsPaletteRemap ( ) const
inline

Whether a palette remap is needed when loading sprites from this file.

Returns
True when needed, otherwise false.

Definition at line 32 of file sprite_file_type.hpp.

References palette_remap.

Referenced by ReadRecolourSprite().

◆ SeekToBegin()

void SpriteFile::SeekToBegin ( )
inline

Seek to the begin of the content, i.e.

the position just after the container version has been determined.

Definition at line 43 of file sprite_file_type.hpp.

References RandomAccessFile::SeekTo().


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