about summary refs log tree commit diff
path: root/src/game/client/components/menus.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 23:38:23 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-20 23:38:23 +0000
commit6224fc776364fb47286c950a2aa7c568d3dc0b17 (patch)
treef0f96058cc1797618f1a8f3b1529d05c0120a012 /src/game/client/components/menus.cpp
parent15217d84585fd6aaacfc75ac36961398bf74e693 (diff)
downloadzcatch-6224fc776364fb47286c950a2aa7c568d3dc0b17.tar.gz
zcatch-6224fc776364fb47286c950a2aa7c568d3dc0b17.zip
fixed sending of new player info when player changes something in the info
Diffstat (limited to 'src/game/client/components/menus.cpp')
-rw-r--r--src/game/client/components/menus.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index a3ee6762..311e70cc 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -86,6 +86,7 @@ MENUS::MENUS()
 	game_page = PAGE_GAME;
 	
 	need_restart = false;
+	need_sendinfo = false;
 	menu_active = true;
 	
 	escape_pressed = false;
@@ -245,6 +246,7 @@ int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, f
 					memmove(str + at_index + 1, str + at_index, len - at_index + 1);
 					str[at_index] = c;
 					at_index++;
+					r = 1;
 				}
 			}
 			
@@ -254,9 +256,13 @@ int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, f
 				{
 					memmove(str + at_index - 1, str + at_index, len - at_index + 1);
 					at_index--;
+					r = 1;
 				}
 				else if (k == KEY_DEL && at_index < len)
+				{
 					memmove(str + at_index, str + at_index + 1, len - at_index);
+					r = 1;
+				}
 				else if (k == KEY_ENTER)
 					ui_clear_last_active_item();
 				else if (k == KEY_LEFT && at_index > 0)
@@ -269,8 +275,6 @@ int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, f
 					at_index = len;
 			}
 		}
-		
-		r = 1;
 	}
 
 	bool just_got_active = false;
@@ -889,6 +893,17 @@ int MENUS::render()
 	return 0;
 }
 
+
+void MENUS::set_active(bool active)
+{
+	menu_active = active;
+	if(!menu_active && need_sendinfo)
+	{
+		gameclient.send_info(false);
+		need_sendinfo = false;
+	}
+}
+
 void MENUS::on_reset()
 {
 }
@@ -920,7 +935,7 @@ bool MENUS::on_input(INPUT_EVENT e)
 		if(e.key == KEY_ESC)
 		{
 			escape_pressed = true;
-			menu_active	= !menu_active;
+			set_active(!is_active());
 			return true;
 		}
 		else if(e.key == KEY_ENTER)
@@ -930,7 +945,7 @@ bool MENUS::on_input(INPUT_EVENT e)
 		}
 	}
 	
-	if(menu_active)
+	if(is_active())
 	{
 		if(num_inputevents < MAX_INPUTEVENTS)
 			inputevents[num_inputevents++] = e;
@@ -962,14 +977,14 @@ void MENUS::on_statechange(int new_state, int old_state)
 	else if (new_state == CLIENTSTATE_ONLINE || new_state == CLIENTSTATE_DEMOPLAYBACK)
 	{
 		popup = POPUP_NONE;
-		menu_active = false;
+		set_active(false);
 	}
 }
 
 void MENUS::on_render()
 {
 	if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK)
-		menu_active = true;
+		set_active(true);
 
 	if(client_state() == CLIENTSTATE_DEMOPLAYBACK)
 	{
@@ -978,7 +993,7 @@ void MENUS::on_render()
 		render_demoplayer(screen);
 	}
 	
-	if(!menu_active)
+	if(!is_active())
 	{
 		escape_pressed = false;
 		enter_pressed = false;