about summary refs log tree commit diff
path: root/src/game/client
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-23 09:22:15 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-03-23 09:22:15 +0000
commit8a0ee875867bf06f060726ad639e4ab5a92017a1 (patch)
tree4f045b72b0524ebc997eaa6b4f60e85acf3ae458 /src/game/client
parent1788d1b08cab71393d24a218a842deeea0d66759 (diff)
downloadzcatch-8a0ee875867bf06f060726ad639e4ab5a92017a1.tar.gz
zcatch-8a0ee875867bf06f060726ad639e4ab5a92017a1.zip
added button to reset binds to default
Diffstat (limited to 'src/game/client')
-rw-r--r--src/game/client/gc_client.h1
-rw-r--r--src/game/client/gc_console.cpp56
-rw-r--r--src/game/client/gc_menu.cpp12
3 files changed, 43 insertions, 26 deletions
diff --git a/src/game/client/gc_client.h b/src/game/client/gc_client.h
index b3a42561..66d52292 100644
--- a/src/game/client/gc_client.h
+++ b/src/game/client/gc_client.h
@@ -263,6 +263,7 @@ void flow_init();
 void flow_update();
 
 //
+void binds_default();
 void binds_save();
 void binds_set(int keyid, const char *str);
 const char *binds_get(int keyid);
diff --git a/src/game/client/gc_console.cpp b/src/game/client/gc_console.cpp
index b2c4c3b3..a2700478 100644
--- a/src/game/client/gc_console.cpp
+++ b/src/game/client/gc_console.cpp
@@ -227,6 +227,37 @@ void binds_set(int keyid, const char *str)
 		dbg_msg("binds", "bound %s (%d) = %s", inp_key_name(keyid), keyid, keybindings[keyid]);
 }
 
+void binds_default()
+{
+	for(int i = 0; i < KEY_LAST; i++)
+		keybindings[i][0] = 0;
+
+	// set default key bindings
+	binds_set(KEY_F1, "toggle_local_console");
+	binds_set(KEY_F2, "toggle_remote_console");
+	binds_set(KEY_TAB, "+scoreboard");
+	binds_set(KEY_F10, "screenshot");
+	
+	binds_set('A', "+left");
+	binds_set('D', "+right");
+	binds_set(KEY_SPACE, "+jump");
+	binds_set(KEY_MOUSE_1, "+fire");
+	binds_set(KEY_MOUSE_2, "+hook");
+	binds_set(KEY_LSHIFT, "+emote");
+
+	binds_set('1', "+weapon1");
+	binds_set('2', "+weapon2");
+	binds_set('3', "+weapon3");
+	binds_set('4', "+weapon4");
+	binds_set('5', "+weapon5");
+	
+	binds_set(KEY_MOUSE_WHEEL_UP, "+prevweapon");
+	binds_set(KEY_MOUSE_WHEEL_DOWN, "+nextweapon");
+	
+	binds_set('T', "chat all");
+	binds_set('Y', "chat team");
+}
+
 static int get_key_id(const char *key_name)
 {
 	// check for numeric
@@ -374,30 +405,7 @@ void client_console_init()
 	MACRO_REGISTER_COMMAND("+emote", "", con_key_input_state, &emoticon_selector_active);
 	MACRO_REGISTER_COMMAND("+scoreboard", "", con_key_input_state, &scoreboard_active);
 	
-	// set default key bindings
-	binds_set(KEY_F1, "toggle_local_console");
-	binds_set(KEY_F2, "toggle_remote_console");
-	binds_set(KEY_TAB, "+scoreboard");
-	binds_set(KEY_F10, "screenshot");
-	
-	binds_set('A', "+left");
-	binds_set('D', "+right");
-	binds_set(KEY_SPACE, "+jump");
-	binds_set(KEY_MOUSE_1, "+fire");
-	binds_set(KEY_MOUSE_2, "+hook");
-	binds_set(KEY_LSHIFT, "+emote");
-
-	binds_set('1', "+weapon1");
-	binds_set('2', "+weapon2");
-	binds_set('3', "+weapon3");
-	binds_set('4', "+weapon4");
-	binds_set('5', "+weapon5");
-	
-	binds_set(KEY_MOUSE_WHEEL_UP, "+prevweapon");
-	binds_set(KEY_MOUSE_WHEEL_DOWN, "+nextweapon");
-	
-	binds_set('T', "chat all");
-	binds_set('Y', "chat team");
+	binds_default();
 }
 
 bool console_input_cli(INPUT_EVENT e, void *user_data)
diff --git a/src/game/client/gc_menu.cpp b/src/game/client/gc_menu.cpp
index ef3d839f..03817383 100644
--- a/src/game/client/gc_menu.cpp
+++ b/src/game/client/gc_menu.cpp
@@ -1337,8 +1337,9 @@ typedef void (*assign_func_callback)(CONFIGURATION *config, int value);
 
 static void menu2_render_settings_controls(RECT main_view)
 {
-	ui_vsplit_l(&main_view, 300.0f, &main_view, 0);
-	
+	RECT right_part;
+	ui_vsplit_l(&main_view, 300.0f, &main_view, &right_part);
+
 	{
 		RECT button, label;
 		ui_hsplit_t(&main_view, 20.0f, &button, &main_view);
@@ -1413,6 +1414,13 @@ static void menu2_render_settings_controls(RECT main_view)
 		}
     	ui_hsplit_t(&main_view, 5.0f, 0, &main_view);
     }	
+    
+    // defaults
+	RECT button;
+	ui_hsplit_b(&right_part, 25.0f, &right_part, &button);
+	ui_vsplit_l(&button, 50.0f, 0, &button);
+	if (ui_do_button((void*)binds_default, "Reset to defaults", 0, &button, ui_draw_menu_button, 0))
+		binds_default();
 }
 
 static void menu2_render_settings_graphics(RECT main_view)