2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-12-21 19:49:27 +00:00
|
|
|
/** @file strings_func.h Functions related to OTTD's strings. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2007-12-21 19:49:27 +00:00
|
|
|
#ifndef STRINGS_FUNC_H
|
|
|
|
#define STRINGS_FUNC_H
|
|
|
|
|
|
|
|
#include "strings_type.h"
|
2005-02-06 08:18:00 +00:00
|
|
|
|
2007-07-16 09:16:58 +00:00
|
|
|
char *InlineString(char *buf, StringID string);
|
2007-07-24 17:01:23 +00:00
|
|
|
char *GetString(char *buffr, StringID string, const char *last);
|
2005-07-15 14:53:44 +00:00
|
|
|
|
2005-07-26 19:05:07 +00:00
|
|
|
extern char _userstring[128];
|
|
|
|
|
2005-02-06 08:18:00 +00:00
|
|
|
void InjectDParam(int amount);
|
2007-07-16 09:16:58 +00:00
|
|
|
|
|
|
|
static inline void SetDParamX(uint64 *s, uint n, uint64 v)
|
|
|
|
{
|
|
|
|
s[n] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetDParam(uint n, uint64 v)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
|
|
|
|
assert(n < lengthof(_decode_parameters));
|
|
|
|
_decode_parameters[n] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Used to bind a C string name to a dparam number.
|
|
|
|
* NOTE: This has a short lifetime. You can't
|
|
|
|
* use this string much later or it will be gone. */
|
|
|
|
void SetDParamStr(uint n, const char *str);
|
|
|
|
|
|
|
|
/** This function takes a C-string and allocates a temporary string ID.
|
|
|
|
* The duration of the bound string is valid only until the next call to GetString,
|
|
|
|
* so be careful. */
|
|
|
|
StringID BindCString(const char *str);
|
|
|
|
|
|
|
|
static inline uint64 GetDParamX(const uint64 *s, uint n)
|
|
|
|
{
|
|
|
|
return s[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint64 GetDParam(uint n)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
|
|
|
|
assert(n < lengthof(_decode_parameters));
|
|
|
|
return _decode_parameters[n];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void CopyInDParam(int offs, const uint64 *src, int num)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void CopyOutDParam(uint64 *dst, int offs, int num)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
memcpy(dst, _decode_parameters + offs, sizeof(uint64) * (num));
|
|
|
|
}
|
|
|
|
|
|
|
|
extern DynamicLanguages _dynlang; // defined in strings.cpp
|
2005-02-06 08:18:00 +00:00
|
|
|
|
2007-03-17 22:21:05 +00:00
|
|
|
bool ReadLanguagePack(int index);
|
|
|
|
void InitializeLanguagePacks();
|
|
|
|
|
2007-06-04 16:07:22 +00:00
|
|
|
int CDECL StringIDSorter(const void *a, const void *b);
|
|
|
|
|
2008-01-17 00:21:43 +00:00
|
|
|
/** Key comparison function for std::map */
|
|
|
|
struct StringIDCompare
|
|
|
|
{
|
|
|
|
bool operator()(StringID s1, StringID s2) { return StringIDSorter(&s1, &s2) < 0; }
|
|
|
|
};
|
|
|
|
|
2007-12-16 18:38:19 +00:00
|
|
|
void CheckForMissingGlyphsInLoadedLanguagePack();
|
|
|
|
|
2007-12-21 19:49:27 +00:00
|
|
|
#endif /* STRINGS_TYPE_H */
|