mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Split baseset type definitions into separate files.
parent
9feaa6b7bc
commit
6914d99778
|
@ -79,6 +79,9 @@ add_files(
|
|||
base_consist.h
|
||||
base_media_base.h
|
||||
base_media_func.h
|
||||
base_media_graphics.h
|
||||
base_media_music.h
|
||||
base_media_sounds.h
|
||||
base_station_base.h
|
||||
bitmap_type.h
|
||||
bmp.cpp
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#define BASE_MEDIA_BASE_H
|
||||
|
||||
#include "fileio_func.h"
|
||||
#include "gfx_type.h"
|
||||
#include "textfile_type.h"
|
||||
#include "textfile_gui.h"
|
||||
#include "3rdparty/md5/md5.h"
|
||||
|
@ -222,118 +221,4 @@ template <class Tbase_set> /* static */ Tbase_set *BaseMedia<Tbase_set>::duplica
|
|||
template <class Tbase_set>
|
||||
const char *TryGetBaseSetFile(const ContentInfo *ci, bool md5sum, const Tbase_set *s);
|
||||
|
||||
/** Types of graphics in the base graphics set */
|
||||
enum GraphicsFileType : uint8_t {
|
||||
GFT_BASE, ///< Base sprites for all climates
|
||||
GFT_LOGOS, ///< Logos, landscape icons and original terrain generator sprites
|
||||
GFT_ARCTIC, ///< Landscape replacement sprites for arctic
|
||||
GFT_TROPICAL, ///< Landscape replacement sprites for tropical
|
||||
GFT_TOYLAND, ///< Landscape replacement sprites for toyland
|
||||
GFT_EXTRA, ///< Extra sprites that were not part of the original sprites
|
||||
MAX_GFT, ///< We are looking for this amount of GRFs
|
||||
};
|
||||
|
||||
/** Blitter type for base graphics sets. */
|
||||
enum BlitterType : uint8_t {
|
||||
BLT_8BPP, ///< Base set has 8 bpp sprites only.
|
||||
BLT_32BPP, ///< Base set has both 8 bpp and 32 bpp sprites.
|
||||
};
|
||||
|
||||
struct GRFConfig;
|
||||
|
||||
/** All data of a graphics set. */
|
||||
struct GraphicsSet : BaseSet<GraphicsSet, MAX_GFT, true> {
|
||||
private:
|
||||
mutable std::unique_ptr<GRFConfig> extra_cfg; ///< Parameters for extra GRF
|
||||
public:
|
||||
PaletteType palette; ///< Palette of this graphics set
|
||||
BlitterType blitter; ///< Blitter of this graphics set
|
||||
|
||||
GraphicsSet();
|
||||
~GraphicsSet();
|
||||
|
||||
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
|
||||
GRFConfig *GetExtraConfig() const { return this->extra_cfg.get(); }
|
||||
GRFConfig &GetOrCreateExtraConfig() const;
|
||||
bool IsConfigurable() const;
|
||||
void CopyCompatibleConfig(const GraphicsSet &src);
|
||||
|
||||
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir);
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base graphics. */
|
||||
class BaseGraphics : public BaseMedia<GraphicsSet> {
|
||||
public:
|
||||
/** Values loaded from config file. */
|
||||
struct Ini {
|
||||
std::string name;
|
||||
uint32_t shortname; ///< unique key for base set
|
||||
uint32_t extra_version; ///< version of the extra GRF
|
||||
std::vector<uint32_t> extra_params; ///< parameters for the extra GRF
|
||||
};
|
||||
static inline Ini ini_data;
|
||||
|
||||
};
|
||||
|
||||
/** All data of a sounds set. */
|
||||
struct SoundsSet : BaseSet<SoundsSet, 1, true> {
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base sounds */
|
||||
class BaseSounds : public BaseMedia<SoundsSet> {
|
||||
public:
|
||||
/** The set as saved in the config file. */
|
||||
static inline std::string ini_set;
|
||||
|
||||
};
|
||||
|
||||
/** Maximum number of songs in the 'class' playlists. */
|
||||
static const uint NUM_SONGS_CLASS = 10;
|
||||
/** Number of classes for songs */
|
||||
static const uint NUM_SONG_CLASSES = 3;
|
||||
/** Maximum number of songs in the full playlist; theme song + the classes */
|
||||
static const uint NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS;
|
||||
|
||||
/** Maximum number of songs in the (custom) playlist */
|
||||
static const uint NUM_SONGS_PLAYLIST = 32;
|
||||
|
||||
/* Functions to read DOS music CAT files, similar to but not quite the same as sound effect CAT files */
|
||||
std::optional<std::string> GetMusicCatEntryName(const std::string &filename, size_t entrynum);
|
||||
std::optional<std::vector<uint8_t>> GetMusicCatEntryData(const std::string &filename, size_t entrynum);
|
||||
|
||||
enum MusicTrackType : uint8_t {
|
||||
MTT_STANDARDMIDI, ///< Standard MIDI file
|
||||
MTT_MPSMIDI, ///< MPS GM driver MIDI format (contained in a CAT file)
|
||||
};
|
||||
|
||||
/** Metadata about a music track. */
|
||||
struct MusicSongInfo {
|
||||
std::string songname; ///< name of song displayed in UI
|
||||
uint8_t tracknr; ///< track number of song displayed in UI
|
||||
std::string filename; ///< file on disk containing song (when used in MusicSet class)
|
||||
MusicTrackType filetype; ///< decoder required for song file
|
||||
int cat_index; ///< entry index in CAT file, for filetype==MTT_MPSMIDI
|
||||
bool loop; ///< song should play in a tight loop if possible, never ending
|
||||
int override_start; ///< MIDI ticks to skip over in beginning
|
||||
int override_end; ///< MIDI tick to end the song at (0 if no override)
|
||||
};
|
||||
|
||||
/** All data of a music set. */
|
||||
struct MusicSet : BaseSet<MusicSet, NUM_SONGS_AVAILABLE, false> {
|
||||
/** Data about individual songs in set. */
|
||||
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE];
|
||||
/** Number of valid songs in set. */
|
||||
uint8_t num_available;
|
||||
|
||||
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base music */
|
||||
class BaseMusic : public BaseMedia<MusicSet> {
|
||||
public:
|
||||
/** The set as saved in the config file. */
|
||||
static inline std::string ini_set;
|
||||
|
||||
};
|
||||
|
||||
#endif /* BASE_MEDIA_BASE_H */
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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 base_media_graphics.h Generic functions for replacing base graphics data. */
|
||||
|
||||
#ifndef BASE_MEDIA_GRAPHICS_H
|
||||
#define BASE_MEDIA_GRAPHICS_H
|
||||
|
||||
#include "base_media_base.h"
|
||||
|
||||
/** Types of graphics in the base graphics set */
|
||||
enum GraphicsFileType : uint8_t {
|
||||
GFT_BASE, ///< Base sprites for all climates
|
||||
GFT_LOGOS, ///< Logos, landscape icons and original terrain generator sprites
|
||||
GFT_ARCTIC, ///< Landscape replacement sprites for arctic
|
||||
GFT_TROPICAL, ///< Landscape replacement sprites for tropical
|
||||
GFT_TOYLAND, ///< Landscape replacement sprites for toyland
|
||||
GFT_EXTRA, ///< Extra sprites that were not part of the original sprites
|
||||
MAX_GFT, ///< We are looking for this amount of GRFs
|
||||
};
|
||||
|
||||
/** Blitter type for base graphics sets. */
|
||||
enum BlitterType : uint8_t {
|
||||
BLT_8BPP, ///< Base set has 8 bpp sprites only.
|
||||
BLT_32BPP, ///< Base set has both 8 bpp and 32 bpp sprites.
|
||||
};
|
||||
|
||||
struct GRFConfig;
|
||||
|
||||
/** All data of a graphics set. */
|
||||
struct GraphicsSet : BaseSet<GraphicsSet, MAX_GFT, true> {
|
||||
private:
|
||||
mutable std::unique_ptr<GRFConfig> extra_cfg; ///< Parameters for extra GRF
|
||||
public:
|
||||
PaletteType palette; ///< Palette of this graphics set
|
||||
BlitterType blitter; ///< Blitter of this graphics set
|
||||
|
||||
GraphicsSet();
|
||||
~GraphicsSet();
|
||||
|
||||
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
|
||||
GRFConfig *GetExtraConfig() const { return this->extra_cfg.get(); }
|
||||
GRFConfig &GetOrCreateExtraConfig() const;
|
||||
bool IsConfigurable() const;
|
||||
void CopyCompatibleConfig(const GraphicsSet &src);
|
||||
|
||||
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir);
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base graphics. */
|
||||
class BaseGraphics : public BaseMedia<GraphicsSet> {
|
||||
public:
|
||||
/** Values loaded from config file. */
|
||||
struct Ini {
|
||||
std::string name;
|
||||
uint32_t shortname; ///< unique key for base set
|
||||
uint32_t extra_version; ///< version of the extra GRF
|
||||
std::vector<uint32_t> extra_params; ///< parameters for the extra GRF
|
||||
};
|
||||
static inline Ini ini_data;
|
||||
};
|
||||
|
||||
#endif /* BASE_MEDIA_BASE_H */
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* 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 base_media_music.h Generic functions for replacing base music data. */
|
||||
|
||||
#ifndef BASE_MEDIA_MUSIC_H
|
||||
#define BASE_MEDIA_MUSIC_H
|
||||
|
||||
#include "base_media_base.h"
|
||||
|
||||
/** Maximum number of songs in the 'class' playlists. */
|
||||
static const uint NUM_SONGS_CLASS = 10;
|
||||
/** Number of classes for songs */
|
||||
static const uint NUM_SONG_CLASSES = 3;
|
||||
/** Maximum number of songs in the full playlist; theme song + the classes */
|
||||
static const uint NUM_SONGS_AVAILABLE = 1 + NUM_SONG_CLASSES * NUM_SONGS_CLASS;
|
||||
|
||||
/** Maximum number of songs in the (custom) playlist */
|
||||
static const uint NUM_SONGS_PLAYLIST = 32;
|
||||
|
||||
/* Functions to read DOS music CAT files, similar to but not quite the same as sound effect CAT files */
|
||||
std::optional<std::string> GetMusicCatEntryName(const std::string &filename, size_t entrynum);
|
||||
std::optional<std::vector<uint8_t>> GetMusicCatEntryData(const std::string &filename, size_t entrynum);
|
||||
|
||||
enum MusicTrackType : uint8_t {
|
||||
MTT_STANDARDMIDI, ///< Standard MIDI file
|
||||
MTT_MPSMIDI, ///< MPS GM driver MIDI format (contained in a CAT file)
|
||||
};
|
||||
|
||||
/** Metadata about a music track. */
|
||||
struct MusicSongInfo {
|
||||
std::string songname; ///< name of song displayed in UI
|
||||
uint8_t tracknr; ///< track number of song displayed in UI
|
||||
std::string filename; ///< file on disk containing song (when used in MusicSet class)
|
||||
MusicTrackType filetype; ///< decoder required for song file
|
||||
int cat_index; ///< entry index in CAT file, for filetype==MTT_MPSMIDI
|
||||
bool loop; ///< song should play in a tight loop if possible, never ending
|
||||
int override_start; ///< MIDI ticks to skip over in beginning
|
||||
int override_end; ///< MIDI tick to end the song at (0 if no override)
|
||||
};
|
||||
|
||||
/** All data of a music set. */
|
||||
struct MusicSet : BaseSet<MusicSet, NUM_SONGS_AVAILABLE, false> {
|
||||
/** Data about individual songs in set. */
|
||||
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE];
|
||||
/** Number of valid songs in set. */
|
||||
uint8_t num_available;
|
||||
|
||||
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename);
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base music */
|
||||
class BaseMusic : public BaseMedia<MusicSet> {
|
||||
public:
|
||||
/** The set as saved in the config file. */
|
||||
static inline std::string ini_set;
|
||||
};
|
||||
|
||||
#endif /* BASE_MEDIA_MUSIC_H */
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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 base_media_sounds.h Generic functions for replacing base sounds data. */
|
||||
|
||||
#ifndef BASE_MEDIA_SOUNDS_H
|
||||
#define BASE_MEDIA_SOUNDS_H
|
||||
|
||||
#include "base_media_base.h"
|
||||
|
||||
/** All data of a sounds set. */
|
||||
struct SoundsSet : BaseSet<SoundsSet, 1, true> {
|
||||
};
|
||||
|
||||
/** All data/functions related with replacing the base sounds */
|
||||
class BaseSounds : public BaseMedia<SoundsSet> {
|
||||
public:
|
||||
/** The set as saved in the config file. */
|
||||
static inline std::string ini_set;
|
||||
|
||||
};
|
||||
|
||||
#endif /* BASE_MEDIA_SOUNDS_H */
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "stdafx.h"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "blitter/factory.hpp"
|
||||
#include "error_func.h"
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
/* The type of set we're replacing */
|
||||
#define SET_TYPE "graphics"
|
||||
#include "base_media_func.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "base_media_sounds.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
/** The type of set we're replacing */
|
||||
#define SET_TYPE "music"
|
||||
#include "base_media_func.h"
|
||||
#include "base_media_music.h"
|
||||
#include "random_access_file_type.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "../thread.h"
|
||||
#include "../fileio_func.h"
|
||||
#include "../base_media_base.h"
|
||||
#include "../base_media_music.h"
|
||||
#include "dmusic.h"
|
||||
#include "midifile.hpp"
|
||||
#include "midi.h"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "../string_func.h"
|
||||
#include "../core/endian_func.hpp"
|
||||
#include "../base_media_base.h"
|
||||
#include "../base_media_music.h"
|
||||
#include "midi.h"
|
||||
|
||||
#include "../console_func.h"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "midifile.hpp"
|
||||
#include "midi.h"
|
||||
#include "../base_media_base.h"
|
||||
#include "../base_media_music.h"
|
||||
#include "../core/mem_func.hpp"
|
||||
#include <mutex>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_music.h"
|
||||
#include "music/music_driver.hpp"
|
||||
#include "window_gui.h"
|
||||
#include "strings_func.h"
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
#include "../../textfile_gui.h"
|
||||
#include "../../newgrf_config.h"
|
||||
#include "../../base_media_base.h"
|
||||
#include "../../base_media_graphics.h"
|
||||
#include "../../base_media_music.h"
|
||||
#include "../../base_media_sounds.h"
|
||||
#include "../../ai/ai.hpp"
|
||||
#include "../../game/game.hpp"
|
||||
#include "../../fios.h"
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "../error.h"
|
||||
#include "../fileio_func.h"
|
||||
#include "../base_media_base.h"
|
||||
#include "../base_media_graphics.h"
|
||||
#include "../base_media_music.h"
|
||||
#include "../base_media_sounds.h"
|
||||
#include "../settings_type.h"
|
||||
#include "../strings_func.h"
|
||||
#include "network_content.h"
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
#include "../ai/ai.hpp"
|
||||
#include "../game/game.hpp"
|
||||
#include "../base_media_base.h"
|
||||
#include "../base_media_graphics.h"
|
||||
#include "../base_media_music.h"
|
||||
#include "../base_media_sounds.h"
|
||||
#include "../openttd.h"
|
||||
#include "../sortlist_type.h"
|
||||
#include "../stringfilter_type.h"
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#include "gui.h"
|
||||
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "base_media_music.h"
|
||||
#include "base_media_sounds.h"
|
||||
#include "saveload/saveload.h"
|
||||
#include "company_cmd.h"
|
||||
#include "company_func.h"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ai/ai_info.hpp"
|
||||
#include "company_base.h"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#endif /* PNG_TEXT_SUPPORTED */
|
||||
|
||||
#include "safeguards.h"
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "newgrf_config.h"
|
||||
#include "picker_func.h"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "fios.h"
|
||||
#include "fileio_func.h"
|
||||
#include "settings_cmd.h"
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#include "slider_func.h"
|
||||
#include "highscore.h"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "base_media_music.h"
|
||||
#include "base_media_sounds.h"
|
||||
#include "company_base.h"
|
||||
#include "company_func.h"
|
||||
#include "viewport_func.h"
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
#include "music/music_driver.hpp"
|
||||
#include "blitter/factory.hpp"
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_music.h"
|
||||
#include "base_media_sounds.h"
|
||||
#include "ai/ai_config.hpp"
|
||||
#include "ai/ai.hpp"
|
||||
#include "game/game_config.hpp"
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
/* The type of set we're replacing */
|
||||
#define SET_TYPE "sounds"
|
||||
#include "base_media_func.h"
|
||||
#include "base_media_sounds.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
#include "video/video_driver.hpp"
|
||||
|
||||
#include "base_media_base.h"
|
||||
#include "base_media_graphics.h"
|
||||
#include "base_media_music.h"
|
||||
#include "base_media_sounds.h"
|
||||
#include "blitter/factory.hpp"
|
||||
|
||||
#include "social_integration.h"
|
||||
|
|
Loading…
Reference in New Issue