OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef STRINGS_FUNC_H
11 #define STRINGS_FUNC_H
79 template <
size_t Tnum_param>
87 static_assert(
sizeof(
data[0]) ==
sizeof(uint64));
102 this->type =
nullptr;
110 if (this->parent !=
nullptr) {
128 return &this->data[this->
offset];
134 return this->num_param - this->
offset;
141 return &this->data[
offset];
147 return this->type !=
nullptr;
155 return this->type[
offset];
158 void SetParam(uint n, uint64 v)
164 uint64 GetParam(uint n)
const
167 return this->data[n];
175 const char *GetStringPtr(
StringID string);
198 _global_string_params.SetParam(n, v);
207 void CopyInDParam(
int offs,
const uint64 *src,
int num);
229 return _global_string_params.GetParam(n);
262 virtual void Reset() = 0;
uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
Convert the given km/h-ish speed to the display speed.
StringParameters(StringParameters &parent, uint size)
Create a new StringParameters instance that can reference part of the data of the given partent insta...
bool FindMissingGlyphs()
Check whether there are glyphs missing in the current language.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
virtual FontSize DefaultSize()=0
Get the default (font) size of the string.
virtual ~MissingGlyphSearcher()
Make sure everything gets destructed right.
char32_t WChar
Type for wide characters, i.e.
A searcher for missing glyphs.
@ TEXT_TAB_END
End of language files.
virtual const char * NextString()=0
Get the next string to search through.
@ TEXT_TAB_NEWGRF_START
Start of NewGRF supplied strings.
static StringID MakeStringID(StringTab tab, uint index)
Create a StringID.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
StringParameters * parent
If not nullptr, this instance references data from this parent instance.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
static uint64 GetDParamX(const uint64 *s, uint n)
Get the current string parameter at index n from parameter array s.
StringTab
StringTabs to group StringIDs.
virtual void Reset()=0
Reset the search, i.e.
static void SetDParamX(uint64 *s, uint n, uint64 v)
Set a string parameter v at index n in a given array s.
static const uint TAB_SIZE_NEWGRF
Number of strings for NewGRFs.
WChar GetTypeAtOffset(uint offset) const
Get the type of a specific element.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
Convert the given display speed to the km/h-ish speed.
char * GetStringWithArgs(char *buffr, StringID string, StringParameters *args, const char *last, uint case_index=0, bool game_script=false)
Get a parsed string with most special stringcodes replaced by the string parameters.
static const uint TAB_SIZE
Number of strings per StringTab.
int64 GetInt64(WChar type=0)
Read an int64 from the argument array.
TextDirection _current_text_dir
Text direction of the currently selected language.
@ FS_NORMAL
Index of the normal font in the font tables.
uint GetDataLeft() const
Return the amount of elements which can still be read.
void CheckForMissingGlyphs(bool base_font=true, MissingGlyphSearcher *search=nullptr)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
uint offset
Current offset in the data/type arrays.
static const uint TAB_SIZE_GAMESCRIPT
Number of strings for GameScripts.
StringParameters(int64(&data)[Tnum_param])
Create a new StringParameters instance.
static uint64 GetDParam(uint n)
Get the current string parameter at index n from the global string parameter array.
fluid_settings_t * settings
FluidSynth settings handle.
WChar * type
Array with type information about the data. Can be nullptr when no type information is needed....
virtual bool Monospace()=0
Whether to search for a monospace font or not.
uint64 * GetPointerToOffset(uint offset) const
Get a pointer to a specific element in the data array.
uint64 * GetDataPointer() const
Get a pointer to the current element in the data array.
uint num_param
Length of the data array.
void SetDParamMaxDigits(uint n, uint count, FontSize size=FS_NORMAL)
Set DParam n to some number that is suitable for string size computations.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
uint64 * data
Array with the actual data.
void CopyOutDParam(uint64 *dst, int offs, int num)
Copy num string parameters from the global string parameter array to the dst array.
int32 GetInt32(WChar type=0)
Read an int32 from the argument array.
TextDirection
Directions a text can go to.
@ TEXT_TAB_GAMESCRIPT_START
Start of GameScript supplied strings.
void ClearTypeInformation()
Reset the type array.
void InitializeLanguagePacks()
Make a list of the available language packs.
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array.
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count=0, FontSize size=FS_NORMAL)
Set DParam n to some number that is suitable for string size computations.
FontSize
Available font sizes.
static uint GetStringIndex(StringID str)
Extract the StringIndex from a StringID.
virtual void SetFontNames(struct FreeTypeSettings *settings, const char *font_name, const void *os_data=nullptr)=0
Set the right font names.
bool HasTypeInformation() const
Does this instance store information about the type of the parameters.
static const uint TAB_SIZE_BITS
Number of bits for the StringIndex within a StringTab.
Settings for the freetype fonts.
StringParameters(uint64 *data, uint num_param, WChar *type)
Create a new StringParameters instance.