10 #ifndef STRINGS_FUNC_H 11 #define STRINGS_FUNC_H 79 template <
size_t Tnum_param>
87 assert_compile(
sizeof(data[0]) ==
sizeof(uint64));
96 data(parent.data + parent.offset),
101 if (parent.
type ==
nullptr) {
102 this->type =
nullptr;
110 if (this->parent !=
nullptr) {
130 return &this->data[this->
offset];
136 return this->num_param - this->
offset;
142 assert(offset < this->num_param);
143 return &this->data[
offset];
149 return this->type !=
nullptr;
155 assert(offset < this->num_param);
157 return this->type[
offset];
160 void SetParam(uint n, uint64 v)
162 assert(n < this->num_param);
166 uint64 GetParam(uint n)
const 168 assert(n < this->num_param);
169 return this->data[n];
174 char *GetString(
char *buffr,
StringID string,
const char *last);
176 const char *GetStringPtr(
StringID string);
201 _global_string_params.SetParam(n, v);
209 void CopyInDParam(
int offs,
const uint64 *src,
int num);
231 return _global_string_params.GetParam(n);
253 virtual const char *NextString() = 0;
264 virtual void Reset() = 0;
270 virtual bool Monospace() = 0;
278 virtual void SetFontNames(
struct FreeTypeSettings *
settings,
const char *font_name,
const void *os_data =
nullptr) = 0;
280 bool FindMissingGlyphs(
const char **str);
StringParameters(int64(&data)[Tnum_param])
Create a new StringParameters instance.
static uint GetStringIndex(StringID str)
Extract the StringIndex from a StringID.
WChar * type
Array with type information about the data. Can be nullptr when no type information is needed...
static uint64 GetDParamX(const uint64 *s, uint n)
Get the current string parameter at index n from parameter array s.
void ClearTypeInformation()
Reset the type array.
uint num_param
Length of the data array.
void CopyOutDParam(uint64 *dst, int offs, int num)
Copy num string parameters from the global string parameter array to the dst array.
fluid_settings_t * settings
FluidSynth settings handle.
void ShiftParameters(uint amount)
Shift all data in the data array by the given amount to make room for some extra parameters.
uint offset
Current offset in the data/type arrays.
static StringID MakeStringID(StringTab tab, uint index)
Create a StringID.
bool HasTypeInformation() const
Does this instance store information about the type of the parameters.
Functions related to bit mathematics.
StringTab
StringTabs to group StringIDs.
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
const char * GetCurrentLanguageIsoCode()
Get the ISO language code of the currently loaded language.
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.
virtual ~MissingGlyphSearcher()
Make sure everything gets destructed right.
Settings for the freetype fonts.
void SetDParamStr(uint n, const char *str)
This function is used to "bind" a C string to a OpenTTD dparam slot.
void InitializeLanguagePacks()
Make a list of the available language packs.
uint64 * data
Array with the actual data.
void SetDParamMaxDigits(uint n, uint count, FontSize size=FS_NORMAL)
Set DParam n to some number that is suitable for string size computations.
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_NEWGRF
Number of strings for NewGRFs.
A searcher for missing glyphs.
static const uint TAB_SIZE
Number of strings per StringTab.
int64 GetInt64(WChar type=0)
Read an int64 from the argument array.
static const uint TAB_SIZE_GAMESCRIPT
Number of strings for GameScripts.
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.
void CopyInDParam(int offs, const uint64 *src, int num)
Copy num string parameters from array src into the global string parameter array. ...
uint GetDataLeft() const
Return the amount of elements which can still be read.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Start of GameScript supplied strings.
TextDirection
Directions a text can go to.
uint ConvertDisplaySpeedToKmhishSpeed(uint speed)
Convert the given display speed to the km/h-ish speed.
WChar GetTypeAtOffset(uint offset) const
Get the type of a specific element.
static uint64 GetDParam(uint n)
Get the current string parameter at index n from the global string parameter array.
StringParameters(uint64 *data, uint num_param, WChar *type)
Create a new StringParameters instance.
StringParameters * parent
If not nullptr, this instance references data from this parent instance.
FontSize
Available font sizes.
static const uint TAB_SIZE_BITS
Number of bits for the StringIndex within a StringTab.
Index of the normal font in the font tables.
Start of NewGRF supplied strings.
Types related to strings.
TextDirection _current_text_dir
Text direction of the currently selected language.
StringParameters(StringParameters &parent, uint size)
Create a new StringParameters instance that can reference part of the data of the given partent insta...
uint64 * GetPointerToOffset(uint offset) const
Get a pointer to a specific element in the data array.
int32 GetInt32(WChar type=0)
Read an int32 from the argument array.
void InjectDParam(uint amount)
Shift the string parameters in the global string parameter array by amount positions, making room at the beginning.
static void SetDParamX(uint64 *s, uint n, uint64 v)
Set a string parameter v at index n in a given array s.
uint32 WChar
Type for wide characters, i.e.
Types related to the graphics and/or input devices.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
uint ConvertKmhishSpeedToDisplaySpeed(uint speed)
Convert the given km/h-ish speed to the display speed.
uint64 * GetDataPointer() const
Get a pointer to the current element in the data array.