|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
10 #ifndef STRINGS_FUNC_H
11 #define STRINGS_FUNC_H
63 const char *GetStringPtr(
StringID string);
78 return speed | (
static_cast<uint64_t
>(type) << 56);
85 template <typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value,
int> = 0>
91 template <typename T, std::enable_if_t<std::is_base_of<StrongTypedefBase, T>::value,
int> = 0>
101 void CopyInDParam(
const std::span<const StringParameterBackup> backup);
102 void CopyOutDParam(std::vector<StringParameterBackup> &backup,
size_t num);
124 virtual std::optional<std::string_view>
NextString() = 0;
135 virtual void Reset() = 0;
bool FindMissingGlyphs()
Check whether there are glyphs missing in the current language.
virtual FontSize DefaultSize()=0
Get the default (font) size of the string.
void SetDParamMaxDigits(size_t n, uint count, FontSize size=FS_NORMAL)
Set DParam n to some number that is suitable for string size computations.
A searcher for missing glyphs.
@ TEXT_TAB_END
End of language files.
@ TEXT_TAB_NEWGRF_START
Start of NewGRF supplied strings.
bool HaveDParamChanged(const std::vector< StringParameterBackup > &backup)
Checks whether the global string parameters have changed compared to the given backup.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void SetDParamStr(size_t n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
StringTab
StringTabs to group StringIDs.
virtual void Reset()=0
Reset the search, i.e.
uint ConvertKmhishSpeedToDisplaySpeed(uint speed, VehicleType type)
Convert the given km/h-ish speed to the display speed.
static const uint TAB_SIZE_NEWGRF
Number of strings for NewGRFs.
void CopyOutDParam(std::vector< StringParameterBackup > &backup, size_t num)
Copy num string parameters from the global string parameter array to the backup.
uint GetStringIndex(StringID str)
Extract the StringIndex from a StringID.
virtual std::optional< std::string_view > NextString()=0
Get the next string to search through.
static const uint TAB_SIZE
Number of strings per StringTab.
TextDirection _current_text_dir
Text direction of the currently selected language.
Settings for the four different fonts.
@ FS_NORMAL
Index of the normal font in the font tables.
uint64_t GetDParam(size_t n)
Get the current string parameter at index n from the global string parameter array.
void CheckForMissingGlyphs(bool base_font=true, MissingGlyphSearcher *search=nullptr)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
static const uint TAB_SIZE_GAMESCRIPT
Number of strings for GameScripts.
fluid_settings_t * settings
FluidSynth settings handle.
virtual bool Monospace()=0
Whether to search for a monospace font or not.
virtual void SetFontNames(struct FontCacheSettings *settings, const char *font_name, const void *os_data=nullptr)=0
Set the right font names.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
VehicleType
Available vehicle types.
void CopyInDParam(const std::span< const StringParameterBackup > backup)
Copy the parameters from the backup into the global string parameter array.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
TextDirection
Directions a text can go to.
void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count=0, FontSize size=FS_NORMAL)
Set DParam n to some number that is suitable for string size computations.
@ TEXT_TAB_GAMESCRIPT_START
Start of GameScript supplied strings.
StringID MakeStringID(StringTab tab, uint index)
Create a StringID.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
void InitializeLanguagePacks()
Make a list of the available language packs.
virtual ~MissingGlyphSearcher()=default
Make sure everything gets destructed right.
FontSize
Available font sizes.
StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
static const uint TAB_SIZE_BITS
Number of bits for the StringIndex within a StringTab.
uint ConvertDisplaySpeedToKmhishSpeed(uint speed, VehicleType type)
Convert the given display speed to the km/h-ish speed.