summaryrefslogtreecommitdiff
path: root/src/strings.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-07-16 09:16:58 +0000
committerrubidium <rubidium@openttd.org>2007-07-16 09:16:58 +0000
commitefc7fdf2fdad3d17a0e5acdcf744c32ae4065ea3 (patch)
treee5f239c13d0bce3b501cd16094df719e1af4be61 /src/strings.h
parent4896d437b17bb91840108450fe899f5e3a2ec644 (diff)
downloadopenttd-efc7fdf2fdad3d17a0e5acdcf744c32ae4065ea3.tar.xz
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
Diffstat (limited to 'src/strings.h')
-rw-r--r--src/strings.h71
1 files changed, 68 insertions, 3 deletions
diff --git a/src/strings.h b/src/strings.h
index 22ec9f39d..0f2665e99 100644
--- a/src/strings.h
+++ b/src/strings.h
@@ -5,13 +5,78 @@
#ifndef STRINGS_H
#define STRINGS_H
-char *InlineString(char *buf, uint16 string);
-char *GetString(char *buffr, uint16 string, const char* last);
+char *InlineString(char *buf, StringID string);
+char *GetString(char *buffr, StringID string, const char* last);
extern char _userstring[128];
void InjectDParam(int amount);
-int32 GetParamInt32();
+
+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));
+}
+
+
+/** Information about a language */
+struct Language {
+ char *name; ///< The internal name of the language
+ char *file; ///< The name of the language as it appears on disk
+};
+
+/** Used for dynamic language support */
+struct DynamicLanguages {
+ int num; ///< Number of languages
+ int curr; ///< Currently selected language index
+ char curr_file[MAX_PATH]; ///< Currently selected language file name without path (needed for saving the filename of the loaded language).
+ StringID dropdown[MAX_LANG + 1]; ///< List of languages in the settings gui
+ Language ent[MAX_LANG]; ///< Information about the languages
+};
+
+extern DynamicLanguages _dynlang; // defined in strings.cpp
bool ReadLanguagePack(int index);
void InitializeLanguagePacks();