about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/client.cpp21
-rw-r--r--src/engine/client/ui.cpp8
-rw-r--r--src/engine/client/ui.h2
-rw-r--r--src/engine/interface.h2
4 files changed, 14 insertions, 19 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp
index dd52608c..20ab0b39 100644
--- a/src/engine/client/client.cpp
+++ b/src/engine/client/client.cpp
@@ -17,6 +17,7 @@
 #include <engine/lzw.h>
 
 #include <engine/versions.h>
+#include <engine/config/config.h>
 
 using namespace baselib;
 
@@ -282,7 +283,6 @@ public:
 
 	// data to hold three snapshots
 	// previous, 
-	char name[MAX_NAME_LENGTH];
 
 	bool fullscreen;
 
@@ -303,13 +303,6 @@ public:
 		dbg_msg("game", "state change. last=%d current=%d", state, s);
 		state = s;
 	}
-	
-	void set_name(const char *new_name)
-	{
-		mem_zero(name, MAX_NAME_LENGTH);
-		strncpy(name, new_name, MAX_NAME_LENGTH);
-		name[MAX_NAME_LENGTH-1] = 0;
-	}
 
 	void set_fullscreen(bool flag) { fullscreen = flag; }
 	
@@ -333,7 +326,7 @@ public:
 		
 		packet p(NETMSG_CLIENT_CONNECT);
 		p.write_str(TEEWARS_VERSION); // payload
-		p.write_str(name);
+		p.write_str(config.player_name);
 		p.write_str("no clan");
 		p.write_str("password");
 		p.write_str("myskin");
@@ -405,7 +398,7 @@ public:
 		else if (get_state() != STATE_CONNECTING && get_state() != STATE_LOADING)
 		{
 			netaddr4 server_address;
-			int status = modmenu_render(&server_address, name, MAX_NAME_LENGTH);
+			int status = modmenu_render(&server_address);
 
 			if (status == -1)
 				set_state(STATE_QUIT);
@@ -675,8 +668,11 @@ public:
 int main(int argc, char **argv)
 {
 	dbg_msg("client", "starting...");
+	config_reset();
+	config_load("teewars.cfg");
+
 	netaddr4 server_address(127, 0, 0, 1, 8303);
-	const char *name = "nameless jerk";
+	//const char *name = "nameless jerk";
 	bool connect_at_once = false;
 	bool fullscreen = true;
 
@@ -699,7 +695,7 @@ int main(int argc, char **argv)
 		{
 			// -n NAME
 			i++;
-			name = argv[i];
+			set_player_name(argv[i]);
 		}
 		else if(argv[i][0] == '-' && argv[i][1] == 'w' && argv[i][2] == 0)
 		{
@@ -710,7 +706,6 @@ int main(int argc, char **argv)
 	
 	// start the server
 	client c;
-	c.set_name(name);
 	c.set_fullscreen(fullscreen);
 	c.run(connect_at_once ? &server_address : 0x0);
 	return 0;
diff --git a/src/engine/client/ui.cpp b/src/engine/client/ui.cpp
index 85ebeaf7..8f45bf5d 100644
--- a/src/engine/client/ui.cpp
+++ b/src/engine/client/ui.cpp
@@ -1,3 +1,4 @@
+#include <baselib/system.h>
 #include <engine/interface.h>
 #include "ui.h"
 
@@ -16,7 +17,6 @@ struct pretty_font
 extern pretty_font *current_font;
 void gfx_pretty_text(float x, float y, float size, const char *text);
 
-
 static void *hot_item = 0;
 static void *active_item = 0;
 static void *becomming_hot_item = 0;
@@ -76,11 +76,11 @@ void ui_do_image(int texture, float x, float y, float w, float h)
     gfx_quads_end();
 }
 
-void ui_do_label(float x, float y, char *text)
+void ui_do_label(float x, float y, const char *text, float size)
 {
     gfx_blend_normal();
     gfx_texture_set(current_font->font_texture);
-    gfx_pretty_text(x, y, 36.f, text);
+    gfx_pretty_text(x, y, size, text);
 }
 
 int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra)
@@ -97,7 +97,7 @@ int ui_do_button(void *id, const char *text, int checked, float x, float y, floa
 			ui_set_active_item(id);
 	}
 
-	// this gets rid of an annoying bug :<
+	// this gets rid of an annoying bug :< (but it creates another annoying bug :O)
 	if (!inside && ui_active_item() == id && !ui_mouse_button(0))
 		ui_set_active_item(0);
 
diff --git a/src/engine/client/ui.h b/src/engine/client/ui.h
index 1a420906..268785be 100644
--- a/src/engine/client/ui.h
+++ b/src/engine/client/ui.h
@@ -26,7 +26,7 @@ int ui_mouse_inside(float x, float y, float w, float h);
 typedef void (*draw_button_callback)(void *id, const char *text, int checked, float x, float y, float w, float h, void *extra);
 
 void ui_do_image(int texture, float x, float y, float w, float h);
-void ui_do_label(float x, float y, char *text);
+void ui_do_label(float x, float y, const char *text, float size);
 int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func, void *extra);
 int ui_do_button(void *id, const char *text, int checked, float x, float y, float w, float h, draw_button_callback draw_func);
 
diff --git a/src/engine/interface.h b/src/engine/interface.h
index 200e7322..d4bde2af 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -695,7 +695,7 @@ void modmenu_shutdown();
     Function: modmenu_render
         Called every frame to let the menu render it self.
 */
-int modmenu_render(void *server_address, char *name, int max_len);
+int modmenu_render(void *server_address);
 
 void snap_encode_string(const char *src, int *dst, int length, int max_length);
 void snap_decode_string(const int *src, char *dst, int length);