OpenTTD Source: src/base_media_graphics.h Source File

OpenTTD Source 15.3

base_media_graphics.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef BASE_MEDIA_GRAPHICS_H
11#define BASE_MEDIA_GRAPHICS_H
12
13#include "base_media_base.h"
14
16 enum GraphicsFileType : uint8_t {
17 GFT_BASE,
18 GFT_LOGOS,
19 GFT_ARCTIC,
20 GFT_TROPICAL,
21 GFT_TOYLAND,
22 GFT_EXTRA,
23 MAX_GFT,
24};
25
27 enum BlitterType : uint8_t {
28 BLT_8BPP,
29 BLT_32BPP,
30};
31
32struct GRFConfig;
33
34 template <> struct BaseSetTraits<struct GraphicsSet> {
35 static constexpr size_t num_files = MAX_GFT;
36 static constexpr bool search_in_tars = true;
37 static constexpr std::string_view set_type = "graphics";
38};
39
41 struct GraphicsSet : BaseSet<GraphicsSet> {
42private:
43 mutable std::unique_ptr<GRFConfig> extra_cfg;
44public:
45 PaletteType palette{};
46 BlitterType blitter{};
47
48 GraphicsSet();
49 ~GraphicsSet();
50
51 bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
52 GRFConfig *GetExtraConfig() const { return this->extra_cfg.get(); }
53 GRFConfig &GetOrCreateExtraConfig() const;
54 bool IsConfigurable() const;
55 void CopyCompatibleConfig(const GraphicsSet &src);
56
57 static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir);
58};
59
61 class BaseGraphics : public BaseMedia<GraphicsSet> {
62public:
64 struct Ini {
65 std::string name;
66 uint32_t shortname;
67 uint32_t extra_version;
68 std::vector<uint32_t> extra_params;
69 };
70 static inline Ini ini_data;
71};
72
73#endif /* BASE_MEDIA_BASE_H */
base_media_base.h
Generic functions for replacing base data (graphics, sounds).
BlitterType
BlitterType
Blitter type for base graphics sets.
Definition base_media_graphics.h:27
BLT_32BPP
@ BLT_32BPP
Base set has both 8 bpp and 32 bpp sprites.
Definition base_media_graphics.h:29
BLT_8BPP
@ BLT_8BPP
Base set has 8 bpp sprites only.
Definition base_media_graphics.h:28
GraphicsFileType
GraphicsFileType
Types of graphics in the base graphics set.
Definition base_media_graphics.h:16
GFT_TOYLAND
@ GFT_TOYLAND
Landscape replacement sprites for toyland.
Definition base_media_graphics.h:21
GFT_LOGOS
@ GFT_LOGOS
Logos, landscape icons and original terrain generator sprites.
Definition base_media_graphics.h:18
MAX_GFT
@ MAX_GFT
We are looking for this amount of GRFs.
Definition base_media_graphics.h:23
GFT_EXTRA
@ GFT_EXTRA
Extra sprites that were not part of the original sprites.
Definition base_media_graphics.h:22
GFT_ARCTIC
@ GFT_ARCTIC
Landscape replacement sprites for arctic.
Definition base_media_graphics.h:19
GFT_TROPICAL
@ GFT_TROPICAL
Landscape replacement sprites for tropical.
Definition base_media_graphics.h:20
GFT_BASE
@ GFT_BASE
Base sprites for all climates.
Definition base_media_graphics.h:17
BaseGraphics
All data/functions related with replacing the base graphics.
Definition base_media_graphics.h:61
BaseMedia
Base for all base media (graphics, sounds)
Definition base_media_base.h:163
Subdirectory
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition fileio_type.h:88
PaletteType
PaletteType
Palettes OpenTTD supports.
Definition gfx_type.h:351
BaseGraphics::Ini
Values loaded from config file.
Definition base_media_graphics.h:64
BaseGraphics::Ini::extra_version
uint32_t extra_version
version of the extra GRF
Definition base_media_graphics.h:67
BaseGraphics::Ini::extra_params
std::vector< uint32_t > extra_params
parameters for the extra GRF
Definition base_media_graphics.h:68
BaseGraphics::Ini::shortname
uint32_t shortname
unique key for base set
Definition base_media_graphics.h:66
BaseSetTraits
Defines the traits of a BaseSet type.
Definition base_media_base.h:43
BaseSet
Information about a single base set.
Definition base_media_base.h:50
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition newgrf_config.h:158
GraphicsSet
All data of a graphics set.
Definition base_media_graphics.h:41
GraphicsSet::extra_cfg
std::unique_ptr< GRFConfig > extra_cfg
Parameters for extra GRF.
Definition base_media_graphics.h:43
GraphicsSet::palette
PaletteType palette
Palette of this graphics set.
Definition base_media_graphics.h:45
GraphicsSet::CheckMD5
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied GRF.
Definition gfxinit.cpp:423
GraphicsSet::blitter
BlitterType blitter
Blitter of this graphics set.
Definition base_media_graphics.h:46
GraphicsSet::GetOrCreateExtraConfig
GRFConfig & GetOrCreateExtraConfig() const
Return configuration for the extra GRF, or lazily create it.
Definition gfxinit.cpp:378
IniFile
Ini file that supports both loading and saving.
Definition ini_type.h:86
MD5File
Structure holding filename and MD5 information about a single file.
Definition base_media_base.h:25
MD5File::ChecksumResult
ChecksumResult
The result of a checksum check.
Definition base_media_base.h:27