about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-13 17:18:06 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2009-06-13 17:18:06 +0000
commitbc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2 (patch)
tree172eb47c01b26969ccda334006f83859f43abe90 /src/game/client
parent6d9ccee95dd99fecda3a6ba62c2768b4d39f69e5 (diff)
downloadzcatch-bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2.tar.gz
zcatch-bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2.zip
localization update
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/components/menus.cpp29
-rw-r--r--src/game/client/components/menus_browser.cpp3
-rw-r--r--src/game/client/components/menus_settings.cpp49
-rw-r--r--src/game/client/gameclient.cpp13
-rw-r--r--src/game/client/gameclient.hpp1
5 files changed, 41 insertions, 54 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 398bd1ae..932597f7 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -12,9 +12,7 @@
 #include "skins.hpp"
 
 #include <engine/e_client_interface.h>
-extern "C" {
-#include <engine/e_linereader.h>
-}
+
 #include <game/version.hpp>
 #include <game/generated/g_protocol.hpp>
 
@@ -622,32 +620,7 @@ void MENUS::render_news(RECT main_view)
 
 void MENUS::on_init()
 {
-	LINEREADER lr;
-	IOHANDLE io = io_open("swedish.txt", IOFLAG_READ);
-	linereader_init(&lr, io);
-	char *line;
-	while((line = linereader_get(&lr)))
-	{
-		if(!str_length(line))
-			continue;
-			
-		char *replacement = linereader_get(&lr);
-		if(!replacement)
-		{
-			dbg_msg("", "unexpected end of file");
-			break;
-		}
-		
-		if(replacement[0] != '=' || replacement[1] != '=' || replacement[2] != ' ')
-		{
-			dbg_msg("", "malform replacement line for '%s'", line);
-			continue;
-		}
 
-		replacement += 3;
-		localization.add_string(line, replacement);
-	}
-	
 	/*
 	array<string> my_strings;
 	array<string>::range r2;
diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp
index a7751347..3d58af93 100644
--- a/src/game/client/components/menus_browser.cpp
+++ b/src/game/client/components/menus_browser.cpp
@@ -9,6 +9,7 @@
 #include <game/client/ui.hpp>
 #include <game/client/render.hpp>
 #include "menus.hpp"
+#include <game/localization.hpp>
 #include <game/version.hpp>
 
 void MENUS::render_serverbrowser_serverlist(RECT view)
@@ -27,7 +28,7 @@ void MENUS::render_serverbrowser_serverlist(RECT view)
 	{
 		int id;
 		int sort;
-		const char *caption;
+		LOC_CONSTSTRING caption;
 		int direction;
 		float width;
 		int flags;
diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp
index beeab046..58678b80 100644
--- a/src/game/client/components/menus_settings.cpp
+++ b/src/game/client/components/menus_settings.cpp
@@ -13,6 +13,7 @@
 #include <game/client/render.hpp>
 #include <game/client/gameclient.hpp>
 #include <game/client/animstate.hpp>
+#include <game/localization.hpp>
 
 #include "binds.hpp"
 #include "menus.hpp"
@@ -248,35 +249,35 @@ typedef void (*assign_func_callback)(CONFIGURATION *config, int value);
 
 typedef struct 
 {
-	const char *name;
+	LOC_CONSTSTRING name;
 	const char *command;
 	int keyid;
 } KEYINFO;
 
-// TODO: localize
 KEYINFO keys[] = 
 {
-	{ "Move Left:", "+left", 0},
-	{ "Move Right:", "+right", 0 },
-	{ "Jump:", "+jump", 0 },
-	{ "Fire:", "+fire", 0 },
-	{ "Hook:", "+hook", 0 },
-	{ "Hammer:", "+weapon1", 0 },
-	{ "Pistol:", "+weapon2", 0 },
-	{ "Shotgun:", "+weapon3", 0 },
-	{ "Grenade:", "+weapon4", 0 },
-	{ "Rifle:", "+weapon5", 0 },
-	{ "Next Weapon:", "+nextweapon", 0 },
-	{ "Prev. Weapon:", "+prevweapon", 0 },
-	{ "Vote Yes:", "vote yes", 0 },
-	{ "Vote No:", "vote no", 0 },
-	{ "Chat:", "chat all", 0 },
-	{ "Team Chat:", "chat team", 0 },
-	{ "Emoticon:", "+emote", 0 },
-	{ "Console:", "toggle_local_console", 0 },
-	{ "Remote Console:", "toggle_remote_console", 0 },
-	{ "Screenshot:", "screenshot", 0 },
-	{ "Scoreboard:", "+scoreboard", 0 },
+	// we need to do localize so the scripts can pickup the string
+	{ localize("Move Left:"), "+left", 0},
+	{ localize("Move Right:"), "+right", 0 },
+	{ localize("Jump:"), "+jump", 0 },
+	{ localize("Fire:"), "+fire", 0 },
+	{ localize("Hook:"), "+hook", 0 },
+	{ localize("Hammer:"), "+weapon1", 0 },
+	{ localize("Pistol:"), "+weapon2", 0 },
+	{ localize("Shotgun:"), "+weapon3", 0 },
+	{ localize("Grenade:"), "+weapon4", 0 },
+	{ localize("Rifle:"), "+weapon5", 0 },
+	{ localize("Next Weapon:"), "+nextweapon", 0 },
+	{ localize("Prev. Weapon:"), "+prevweapon", 0 },
+	{ localize("Vote Yes:"), "vote yes", 0 },
+	{ localize("Vote No:"), "vote no", 0 },
+	{ localize("Chat:"), "chat all", 0 },
+	{ localize("Team Chat:"), "chat team", 0 },
+	{ localize("Emoticon:"), "+emote", 0 },
+	{ localize("Console:"), "toggle_local_console", 0 },
+	{ localize("Remote Console:"), "toggle_remote_console", 0 },
+	{ localize("Screenshot:"), "screenshot", 0 },
+	{ localize("Scoreboard:"), "+scoreboard", 0 },
 };
 
 const int key_count = sizeof(keys) / sizeof(KEYINFO);
@@ -292,7 +293,7 @@ void MENUS::ui_do_getbuttons(int start, int stop, RECT view)
 	
 		ui_do_label(&label, key.name, 14.0f, -1);
 		int oldid = key.keyid;
-		int newid = ui_do_key_reader((void *)keys[i].name, &button, oldid);
+		int newid = ui_do_key_reader((void *)&keys[i].name, &button, oldid);
 		if(newid != oldid)
 		{
 			gameclient.binds->bind(oldid, "");
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index ae501fa2..834aa29b 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -6,6 +6,7 @@
 #include <game/generated/gc_data.hpp>
 
 #include <game/layers.hpp>
+#include <game/localization.hpp>
 #include "render.hpp"
 
 #include "gameclient.hpp"
@@ -158,7 +159,10 @@ void GAMECLIENT::on_console_init()
 	input.add(&emoticon);
 	input.add(controls);
 	input.add(binds);
-		
+	
+	//	
+	MACRO_REGISTER_COMMAND("language", "s", CFGFLAG_CLIENT, con_language, this, "Sets the language");
+	
 	// add the some console commands
 	MACRO_REGISTER_COMMAND("team", "i", CFGFLAG_CLIENT, con_team, this, "Switch team");
 	MACRO_REGISTER_COMMAND("kill", "", CFGFLAG_CLIENT, con_kill, this, "Kill yourself");
@@ -881,3 +885,10 @@ void GAMECLIENT::con_kill(void *result, void *user_data)
 {
 	((GAMECLIENT*)user_data)->send_kill(-1);
 }
+
+void GAMECLIENT::con_language(void *result, void *user_data)
+{
+	char buf[128];
+	str_format(buf, sizeof(buf), "data/languages/%s.txt", console_arg_string(result, 0));
+	localization.load(buf);
+}
diff --git a/src/game/client/gameclient.hpp b/src/game/client/gameclient.hpp
index 35b95f27..7d8c3701 100644
--- a/src/game/client/gameclient.hpp
+++ b/src/game/client/gameclient.hpp
@@ -31,6 +31,7 @@ class GAMECLIENT
 	int predicted_tick;
 	int last_new_predicted_tick;
 
+	static void con_language(void *result, void *user_data);
 	static void con_team(void *result, void *user_data);
 	static void con_kill(void *result, void *user_data);