Files
@ r27978:bcbbe240aea5
Branch filter:
Location: cpp/openttd-patchpack/source/src/spritecache.h - annotation
r27978:bcbbe240aea5
2.8 KiB
text/x-c
Fix: Upgrading NewGRF presets could result in incomplete display of NewGRF parameters until restart.
r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6420:01087f989fd1 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r8123:dde0a9a84019 r24897:25aba2adfe00 r8123:dde0a9a84019 r12246:330df08e87cc r6248:b940b09d7ab8 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r27737:728d55b97775 r18462:a1ba75a7f741 r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r26384:19fce5799803 r26384:19fce5799803 r26384:19fce5799803 r26384:19fce5799803 r26384:19fce5799803 r26384:19fce5799803 r26384:19fce5799803 r6803:f739da58f36c r6803:f739da58f36c r17035:6216511eba9e r17035:6216511eba9e r24900:959a621b6aa9 r24897:25aba2adfe00 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r15087:eb029334c019 r25413:71c42f3ee7f2 r27737:728d55b97775 r25413:71c42f3ee7f2 r15087:eb029334c019 r15087:eb029334c019 r15087:eb029334c019 r10056:7a18efcd8edb r5475:3f5cd13d1b63 r27106:2d95beb51290 r10056:7a18efcd8edb r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r10056:7a18efcd8edb r5475:3f5cd13d1b63 r27106:2d95beb51290 r10056:7a18efcd8edb r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r6247:96e840dbefcc r18461:b013cc5efff8 r27112:f42d2af96b0b r6247:96e840dbefcc r5475:3f5cd13d1b63 r25413:71c42f3ee7f2 r25413:71c42f3ee7f2 r25413:71c42f3ee7f2 r27737:728d55b97775 r25413:71c42f3ee7f2 r27737:728d55b97775 r5587:034e5e185dc2 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 | /*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file spritecache.h Functions to cache sprites in memory. */
#ifndef SPRITECACHE_H
#define SPRITECACHE_H
#include "gfx_type.h"
#include "spriteloader/spriteloader.hpp"
/** Data structure describing a sprite. */
struct Sprite {
uint16_t height; ///< Height of the sprite.
uint16_t width; ///< Width of the sprite.
int16_t x_offs; ///< Number of pixels to shift the sprite to the right.
int16_t y_offs; ///< Number of pixels to shift the sprite downwards.
byte data[]; ///< Sprite data.
};
enum SpriteCacheCtrlFlags {
SCCF_ALLOW_ZOOM_MIN_1X_PAL = 0, ///< Allow use of sprite min zoom setting at 1x in palette mode.
SCCF_ALLOW_ZOOM_MIN_1X_32BPP = 1, ///< Allow use of sprite min zoom setting at 1x in 32bpp mode.
SCCF_ALLOW_ZOOM_MIN_2X_PAL = 2, ///< Allow use of sprite min zoom setting at 2x in palette mode.
SCCF_ALLOW_ZOOM_MIN_2X_32BPP = 3, ///< Allow use of sprite min zoom setting at 2x in 32bpp mode.
};
extern uint _sprite_cache_size;
typedef void *AllocatorProc(size_t size);
void *SimpleSpriteAlloc(size_t size);
void *GetRawSprite(SpriteID sprite, SpriteType type, AllocatorProc *allocator = nullptr, SpriteEncoder *encoder = nullptr);
bool SpriteExists(SpriteID sprite);
SpriteType GetSpriteType(SpriteID sprite);
SpriteFile *GetOriginFile(SpriteID sprite);
uint32_t GetSpriteLocalID(SpriteID sprite);
uint GetSpriteCountForFile(const std::string &filename, SpriteID begin, SpriteID end);
uint GetMaxSpriteID();
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
{
assert(type != SpriteType::Recolour);
return (Sprite*)GetRawSprite(sprite, type);
}
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
{
assert(type == SpriteType::Recolour);
return (byte*)GetRawSprite(sprite, type);
}
void GfxInitSpriteMem();
void GfxClearSpriteCache();
void GfxClearFontSpriteCache();
void IncreaseSpriteLRU();
SpriteFile &OpenCachedSpriteFile(const std::string &filename, Subdirectory subdir, bool palette_remap);
void ReadGRFSpriteOffsets(SpriteFile &file);
size_t GetGRFSpriteOffset(uint32_t id);
bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id);
bool SkipSpriteData(SpriteFile &file, byte type, uint16_t num);
void DupSprite(SpriteID old_spr, SpriteID new_spr);
#endif /* SPRITECACHE_H */
|