12 #ifndef STRINGS_FUNC_H 13 #define STRINGS_FUNC_H 81 template <
size_t Tnum_param>
89 assert_compile(
sizeof(data[0]) ==
sizeof(uint64));
98 data(parent.data + parent.offset),
103 if (parent.
type == NULL) {
112 if (this->parent != NULL) {
132 return &this->data[this->
offset];
138 return this->num_param - this->
offset;
144 assert(offset < this->num_param);
145 return &this->data[
offset];
151 return this->type != NULL;
157 assert(offset < this->num_param);
159 return this->type[
offset];
162 void SetParam(uint n, uint64 v)
164 assert(n < this->num_param);
168 uint64 GetParam(uint n)
const 170 assert(n < this->num_param);
171 return this->data[n];
176 char *GetString(
char *buffr,
StringID string,
const char *last);
178 const char *GetStringPtr(
StringID string);
203 _global_string_params.SetParam(n, v);
211 void CopyInDParam(
int offs,
const uint64 *src,
int num);
233 return _global_string_params.GetParam(n);
255 virtual const char *NextString() = 0;
266 virtual void Reset() = 0;
272 virtual bool Monospace() = 0;
279 virtual void SetFontNames(
struct FreeTypeSettings *settings,
const char *font_name) = 0;
281 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 NULL 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.
void CheckForMissingGlyphs(bool base_font=true, MissingGlyphSearcher *search=NULL)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
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.
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.
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 NULL, 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.