10 #ifndef BASE_MEDIA_BASE_H
11 #define BASE_MEDIA_BASE_H
17 #include "3rdparty/md5/md5.h"
18 #include <unordered_map>
48 template <
class T,
size_t Tnum_files,
bool Tsearch_in_tars>
50 typedef std::unordered_map<std::string, std::string> TranslatedStrings;
99 bool FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename,
bool allow_empty_filename =
true);
100 void CopyCompatibleConfig([[maybe_unused]]
const T &src) {}
112 if (!isocode.empty()) {
114 auto desc = this->description.find(isocode);
115 if (desc != this->description.end())
return desc->second;
118 desc = this->description.find(isocode.substr(0, 2));
119 if (desc != this->description.end())
return desc->second;
122 return this->description.at(std::string{});
151 return file->
CheckMD5(subdir, SIZE_MAX);
161 for (
const auto &file : this->files) {
163 if (textfile.has_value()) {
175 template <
class Tbase_set>
182 bool AddFile(
const std::string &filename,
size_t basepath_length,
const std::string &tar_filename)
override;
208 static bool SetSet(
const Tbase_set *set);
211 static void GetSetsList(std::back_insert_iterator<std::string> &output_iterator);
214 static const Tbase_set *
GetSet(
int index);
237 template <
class Tbase_set>
270 bool FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename);
271 GRFConfig *GetExtraConfig()
const {
return this->extra_cfg.get(); }
273 bool IsConfigurable()
const;
289 static inline Ini ini_data;
317 std::optional<std::vector<uint8_t>>
GetMusicCatEntryData(
const std::string &filename,
size_t entrynum);
343 bool FillSetDetails(
const IniFile &ini,
const std::string &path,
const std::string &full_filename);
All data/functions related with replacing the base graphics.
All data/functions related with replacing the base music.
static std::string ini_set
The set as saved in the config file.
All data/functions related with replacing the base sounds.
static std::string ini_set
The set as saved in the config file.
Helper for scanning for files with a given name.
uint Scan(std::string_view extension, Subdirectory sd, bool tars=true, bool recursive=true)
Scan for files with the given extension in the given search path.
Functions for Standard In/Out file operations.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
@ OLD_DATA_DIR
Old subdirectory for the data.
@ OLD_GM_DIR
Old subdirectory for the music.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
Types related to the graphics and/or input devices.
PaletteType
Palettes OpenTTD supports.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
Values loaded from config file.
uint32_t extra_version
version of the extra GRF
std::vector< uint32_t > extra_params
parameters for the extra GRF
uint32_t shortname
unique key for base set
Information about a single base set.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied file.
T * next
The next base set in this list.
bool fallback
This set is a fallback set, i.e. it should be used only as last resort.
static const bool SEARCH_IN_TARS
Whether to search in the tars or not.
int GetNumInvalid() const
Get the number of invalid files.
uint found_files
Number of the files that could be found.
TranslatedStrings description
Description of the base set.
~BaseSet()
Free everything we allocated.
int GetNumMissing() const
Get the number of missing files.
const std::string & GetDescription(const std::string &isocode) const
Get the description for the given ISO code.
bool FillSetDetails(const IniFile &ini, const std::string &path, const std::string &full_filename, bool allow_empty_filename=true)
Read the set information from a loaded ini.
uint32_t version
The version of this base set.
static const char *const * file_names
Internal names of the files in this set.
static const size_t NUM_FILES
Number of files in this set.
std::string name
The name of the base set.
std::string GetListLabel() const
Get string to use when listing this set in the settings window.
std::optional< std::string > GetTextfile(TextfileType type) const
Search a textfile file next to this base media.
uint valid_files
Number of the files that could be found and are valid.
MD5File files[NUM_FILES]
All files part of this set.
std::string url
URL for information about the base set.
uint32_t shortname
Four letter short variant of the name.
Container for all important information about a piece of content.
Information about GRF, used in the game and (part of it) in savegames.
All data of a graphics set.
std::unique_ptr< GRFConfig > extra_cfg
Parameters for extra GRF.
PaletteType palette
Palette of this graphics set.
static MD5File::ChecksumResult CheckMD5(const MD5File *file, Subdirectory subdir)
Calculate and check the MD5 hash of the supplied GRF.
BlitterType blitter
Blitter of this graphics set.
GRFConfig & GetOrCreateExtraConfig() const
Return configuration for the extra GRF, or lazily create it.
Ini file that supports both loading and saving.
Structure holding filename and MD5 information about a single file.
std::string missing_warning
warning when this file is missing
ChecksumResult
The result of a checksum check.
@ CR_MATCH
The file did exist and the md5 checksum did match.
@ CR_MISMATCH
The file did exist, just the md5 checksum did not match.
@ CR_NO_FILE
The file did not exist.
@ CR_UNKNOWN
The file has not been checked yet.
ChecksumResult check_result
cached result of md5 check
ChecksumResult CheckMD5(Subdirectory subdir, size_t max_size) const
Calculate and check the MD5 hash of the supplied filename.
MD5Hash hash
md5 sum of the file
std::string filename
filename
MusicSongInfo songinfo[NUM_SONGS_AVAILABLE]
Data about individual songs in set.
uint8_t num_available
Number of valid songs in set.
Metadata about a music track.
MusicTrackType filetype
decoder required for song file
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)
int override_start
MIDI ticks to skip over in beginning.
bool loop
song should play in a tight loop if possible, never ending
int cat_index
entry index in CAT file, for filetype==MTT_MPSMIDI
int override_end
MIDI tick to end the song at (0 if no override)
All data of a sounds set.
GUI functions related to textfiles.
Types related to textfiles.
TextfileType
Additional text files accompanying Tar archives.