OpenTTD Source
20241108-master-g80f628063a
|
Information about a single base set. More...
#include <base_media_base.h>
Public Types | |
typedef std::unordered_map< std::string, std::string > | TranslatedStrings |
Public Member Functions | |
~BaseSet () | |
Free everything we allocated. | |
int | GetNumMissing () const |
Get the number of missing files. More... | |
int | GetNumInvalid () const |
Get the number of invalid files. More... | |
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. More... | |
void | CopyCompatibleConfig ([[maybe_unused]] const T &src) |
const std::string & | GetDescription (const std::string &isocode) const |
Get the description for the given ISO code. More... | |
std::string | GetListLabel () const |
Get string to use when listing this set in the settings window. More... | |
std::optional< std::string > | GetTextfile (TextfileType type) const |
Search a textfile file next to this base media. More... | |
Static Public Member Functions | |
static MD5File::ChecksumResult | CheckMD5 (const MD5File *file, Subdirectory subdir) |
Calculate and check the MD5 hash of the supplied file. More... | |
Data Fields | |
std::string | name |
The name of the base set. | |
std::string | url |
URL for information about the base set. | |
TranslatedStrings | description |
Description of the base set. | |
uint32_t | shortname |
Four letter short variant of the name. | |
uint32_t | version |
The version of this base set. | |
bool | fallback |
This set is a fallback set, i.e. it should be used only as last resort. | |
MD5File | files [NUM_FILES] |
All files part of this set. | |
uint | found_files |
Number of the files that could be found. | |
uint | valid_files |
Number of the files that could be found and are valid. | |
T * | next |
The next base set in this list. | |
Static Public Attributes | |
static const size_t | NUM_FILES = Tnum_files |
Number of files in this set. | |
static const bool | SEARCH_IN_TARS = Tsearch_in_tars |
Whether to search in the tars or not. | |
static const char *const * | file_names = _graphics_file_names |
Internal names of the files in this set. More... | |
Information about a single base set.
T | the real class we're going to be |
Tnum_files | the number of files in the set |
Tsearch_in_tars | whether to search in the tars or not |
Definition at line 49 of file base_media_base.h.
|
inlinestatic |
Calculate and check the MD5 hash of the supplied file.
file | The file get the hash of. |
subdir | The sub directory to get the files from. |
Definition at line 149 of file base_media_base.h.
References MD5File::CheckMD5().
bool BaseSet< T, Tnum_files, Tsearch_in_tars >::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.
ini | the ini to read from |
path | the path to this ini file (for filenames) |
full_filename | the full filename of the loaded file (for error reporting purposes) |
allow_empty_filename | empty filenames are valid |
Definition at line 42 of file base_media_func.h.
References Debug, fetch_metadata, MD5File::filename, IniLoadFile::GetGroup(), IniGroup::GetItem(), IniGroup::items, IniItem::name, SET_TYPE, and IniItem::value.
|
inline |
Get the description for the given ISO code.
It falls back to the first two characters of the ISO code in case no match could be made with the full ISO code. If even then the matching fails the default is returned.
isocode | the isocode to search for |
Definition at line 110 of file base_media_base.h.
|
inline |
Get string to use when listing this set in the settings window.
If there are no invalid files, then this is just the set name, otherwise a string is formatted including the number of invalid files.
Definition at line 131 of file base_media_base.h.
References BaseSet< T, Tnum_files, Tsearch_in_tars >::GetNumInvalid(), GetString(), BaseSet< T, Tnum_files, Tsearch_in_tars >::name, SetDParam(), and SetDParamStr().
|
inline |
Get the number of invalid files.
Definition at line 94 of file base_media_base.h.
References BaseSet< T, Tnum_files, Tsearch_in_tars >::valid_files.
Referenced by CheckExternalFiles(), and BaseSet< T, Tnum_files, Tsearch_in_tars >::GetListLabel().
|
inline |
Get the number of missing files.
Definition at line 84 of file base_media_base.h.
References BaseSet< T, Tnum_files, Tsearch_in_tars >::found_files.
|
inline |
Search a textfile file next to this base media.
type | The type of the textfile to search for. |
Definition at line 159 of file base_media_base.h.
References BASESET_DIR.
|
static |
Internal names of the files in this set.
Make sure we aren't messing things up.
Implementation.
Definition at line 59 of file base_media_base.h.