10#ifndef SPRITELOADER_HPP
11#define SPRITELOADER_HPP
13#include "../core/alloc_type.hpp"
14#include "../core/enum_type.hpp"
15#include "../gfx_type.h"
37 inline constexpr const T &operator[](
const ZoomLevel &zoom)
const {
return this->data[
to_underlying(zoom)]; }
113 template <
typename T>
Interface for something that can allocate memory for a sprite.
virtual void * AllocatePtr(size_t size)=0
Allocate memory for a sprite.
T * Allocate(size_t size)
Allocate memory for a sprite.
Interface for something that can encode a sprite.
virtual bool Is32BppSupported()=0
Can the sprite encoder make use of RGBA sprites?
virtual uint GetSpriteAlignment()
Get the value which the height and width on a sprite have to be aligned by.
virtual Sprite * Encode(SpriteType sprite_type, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)=0
Convert a sprite from the loader to our own format.
RandomAccessFile with some extra information specific for sprite files.
Interface for the loader of our sprites.
virtual ZoomLevels LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint8_t control_flags, ZoomLevels &avail_8bpp, ZoomLevels &avail_32bpp)=0
Load a sprite from the disk and return a sprite struct which is the same for all loaders.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
SpriteType
Types of sprites that might be loaded.
Random Access File specialised for accessing sprites.
SpriteComponent
The different colour components a sprite can have.
Information about the currently used palette.
Definition of a common pixel in OpenTTD's realm.
Structure for passing information from the sprite loader to the blitter.
static SpriteCollMap< ReusableBuffer< SpriteLoader::CommonPixel > > buffer
Allocated memory to pass sprite data around.
SpriteComponents colours
The colour components of the sprite with useful information.
void AllocateData(ZoomLevel zoom, size_t size)
Allocate the sprite data of this sprite.
uint16_t width
Width of the sprite.
int16_t x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
uint16_t height
Height of the sprite.
int16_t y_offs
The y-offset of where the sprite will be drawn.
Data structure describing a sprite.
ZoomLevel
All zoom levels we know.