about summary refs log tree commit diff
path: root/src/game/localization.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/localization.hpp')
-rw-r--r--src/game/localization.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/game/localization.hpp b/src/game/localization.hpp
new file mode 100644
index 00000000..87b6e2f8
--- /dev/null
+++ b/src/game/localization.hpp
@@ -0,0 +1,46 @@
+#include <base/tl/array.hpp>
+
+class LOCALIZATIONDATABASE
+{
+	class STRING
+	{
+	public:
+		unsigned hash;
+		string replacement;
+		
+		bool operator ==(unsigned h) const { return hash == h; }
+		
+	};
+
+	array<STRING> strings;
+	int current_version;
+	
+public:
+	LOCALIZATIONDATABASE();
+
+	int version() { return current_version; }
+	
+	void add_string(const char *org_str, const char *new_str);
+	const char *find_string(unsigned hash);
+};
+
+static LOCALIZATIONDATABASE localization;
+
+
+class LOC_CONSTSTRING
+{
+	const char *default_str;
+	const char *current_str;
+	unsigned hash;
+	int version;
+public:
+	LOC_CONSTSTRING(const char *str);
+	void reload();
+	
+	inline operator const char *()
+	{
+		if(version != localization.version())
+			reload();
+		return current_str;
+	}
+};