2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
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);
|
2009-09-22 13:54:54 +00:00
|
|
|
char *GetStringWithArgs(char *buffr, uint string, int64 *argv, const char *last);
|
2008-01-29 17:09:00 +00:00
|
|
|
const char *GetStringPtr(StringID string);
|
2005-07-15 14:53:44 +00:00
|
|
|
|
2008-09-28 13:50:11 +00:00
|
|
|
void InjectDParam(uint amount);
|
2007-07-16 09:16:58 +00:00
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Set a string parameter \a v at index \a n in a given array \a s.
|
|
|
|
* @param s Array of string parameters.
|
|
|
|
* @param n Index of the string parameter.
|
|
|
|
* @param v Value of the string parameter.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
static inline void SetDParamX(uint64 *s, uint n, uint64 v)
|
|
|
|
{
|
|
|
|
s[n] = v;
|
|
|
|
}
|
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Set a string parameter \a v at index \a n in the global string parameter array.
|
|
|
|
* @param n Index of the string parameter.
|
|
|
|
* @param v Value of the string parameter.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
static inline void SetDParam(uint n, uint64 v)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
|
|
|
|
assert(n < lengthof(_decode_parameters));
|
|
|
|
_decode_parameters[n] = v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDParamStr(uint n, const char *str);
|
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Get the current string parameter at index \a n from parameter array \a s.
|
|
|
|
* @param s Array of string parameters.
|
|
|
|
* @param n Index of the string parameter.
|
|
|
|
* @return Value of the requested string parameter.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
static inline uint64 GetDParamX(const uint64 *s, uint n)
|
|
|
|
{
|
|
|
|
return s[n];
|
|
|
|
}
|
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Get the current string parameter at index \a n from the global string parameter array.
|
|
|
|
* @param n Index of the string parameter.
|
|
|
|
* @return Value of the requested string parameter.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
static inline uint64 GetDParam(uint n)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
|
|
|
|
assert(n < lengthof(_decode_parameters));
|
|
|
|
return _decode_parameters[n];
|
|
|
|
}
|
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Copy \a num string parameters from array \a src into the global string parameter array.
|
|
|
|
* @param offs Index in the global array to copy the first string parameter to.
|
|
|
|
* @param src Source array of string parameters.
|
|
|
|
* @param num Number of string parameters to copy.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
static inline void CopyInDParam(int offs, const uint64 *src, int num)
|
|
|
|
{
|
|
|
|
extern uint64 _decode_parameters[20];
|
|
|
|
memcpy(_decode_parameters + offs, src, sizeof(uint64) * (num));
|
|
|
|
}
|
|
|
|
|
2009-07-25 07:49:49 +00:00
|
|
|
/**
|
|
|
|
* Copy \a num string parameters from the global string parameter array to the \a dst array.
|
|
|
|
* @param dst Destination array of string parameters.
|
|
|
|
* @param offs Index in the global array to copy the first string parameter from.
|
|
|
|
* @param num Number of string parameters to copy.
|
|
|
|
*/
|
2007-07-16 09:16:58 +00:00
|
|
|
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();
|
2009-10-17 20:34:09 +00:00
|
|
|
const char *GetCurrentLanguageIsoCode();
|
2007-03-17 22:21:05 +00:00
|
|
|
|
2009-09-13 17:38:07 +00:00
|
|
|
int CDECL StringIDSorter(const StringID *a, const StringID *b);
|
2007-06-04 16:07:22 +00:00
|
|
|
|
2008-01-17 00:21:43 +00:00
|
|
|
/** Key comparison function for std::map */
|
|
|
|
struct StringIDCompare
|
|
|
|
{
|
2008-01-17 16:46:41 +00:00
|
|
|
bool operator()(StringID s1, StringID s2) const { return StringIDSorter(&s1, &s2) < 0; }
|
2008-01-17 00:21:43 +00:00
|
|
|
};
|
|
|
|
|
2007-12-16 18:38:19 +00:00
|
|
|
void CheckForMissingGlyphsInLoadedLanguagePack();
|
|
|
|
|
2007-12-21 19:49:27 +00:00
|
|
|
#endif /* STRINGS_TYPE_H */
|