blob: b7492afade0c0220f3023fb8ad1d11d0a63a67e2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
/*
* 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 sprite_file_type.hpp Random Access File specialised for accessing sprites. */
#ifndef SPRITE_FILE_TYPE_HPP
#define SPRITE_FILE_TYPE_HPP
#include "../random_access_file_type.h"
/**
* RandomAccessFile with some extra information specific for sprite files.
* It automatically detects and stores the container version upload opening the file.
*/
class SpriteFile : public RandomAccessFile {
bool palette_remap; ///< Whether or not a remap of the palette is required for this file.
byte 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.
public:
SpriteFile(const std::string &filename, Subdirectory subdir, bool palette_remap);
SpriteFile(const SpriteFile&) = delete;
void operator=(const SpriteFile&) = delete;
/**
* Whether a palette remap is needed when loading sprites from this file.
* @return True when needed, otherwise false.
*/
bool NeedsPaletteRemap() const { return this->palette_remap; }
/**
* Get the version number of container type used by the file.
* @return The version.
*/
byte GetContainerVersion() const { return this->container_version; }
/**
* Seek to the begin of the content, i.e. the position just after the container version has been determined.
*/
void SeekToBegin() { this->SeekTo(this->content_begin, SEEK_SET); }
};
#endif /* SPRITE_FILE_TYPE_HPP */
|