about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/client/components/chat.cpp4
-rw-r--r--src/game/client/components/menus.cpp24
-rw-r--r--src/game/client/components/menus.hpp5
-rw-r--r--src/game/client/gameclient.cpp2
4 files changed, 25 insertions, 10 deletions
diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp
index 9f48b292..fbca1256 100644
--- a/src/game/client/components/chat.cpp
+++ b/src/game/client/components/chat.cpp
@@ -52,7 +52,9 @@ bool CHAT::on_input(INPUT_EVENT e)
 	if(mode == MODE_NONE)
 		return false;
 
-	if(e.flags&INPFLAG_PRESS && (e.key == KEY_ENTER || e.key == KEY_KP_ENTER))
+	if(e.flags&INPFLAG_PRESS && e.key == KEY_ESC)
+		mode = MODE_NONE;
+	else if(e.flags&INPFLAG_PRESS && (e.key == KEY_ENTER || e.key == KEY_KP_ENTER))
 	{
 		if(input.get_string()[0])
 			gameclient.chat->say(mode == MODE_ALL ? 0 : 1, input.get_string());
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 05af1c7b..4a37669e 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -38,6 +38,10 @@ vec4 MENUS::color_tabbar_inactive_ingame;
 vec4 MENUS::color_tabbar_active_ingame;
 
 
+INPUT_EVENT MENUS::inputevents[MAX_INPUTEVENTS];
+int MENUS::num_inputevents;
+
+
 MENUS::MENUS()
 {
 	popup = POPUP_NONE;
@@ -46,6 +50,7 @@ MENUS::MENUS()
 	
 	need_restart = false;
 	menu_active = true;
+	num_inputevents = 0;
 }
 
 vec4 MENUS::button_color_mul(const void *id)
@@ -188,9 +193,9 @@ int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, f
 			}
 		}
 
-		for(int i = 0; i < inp_num_events(); i++)
+		for(int i = 0; i < num_inputevents; i++)
 		{
-			INPUT_EVENT e = inp_get_event(i);
+			INPUT_EVENT e = inputevents[i];
 			char c = e.ch;
 			int k = e.key;
 
@@ -403,15 +408,15 @@ int MENUS::ui_do_key_reader(void *id, const RECT *rect, int key)
 
 	if(ui_active_item() == id)
 	{
-		for(int i = 0; i < inp_num_events(); i++)
+		for(int i = 0; i < num_inputevents; i++)
 		{
-			INPUT_EVENT e = inp_get_event(i);
+			INPUT_EVENT e = inputevents[i];
 			if(e.flags&INPFLAG_PRESS && e.key && e.key != KEY_ESC)
 			{
 				new_key = e.key;
 				ui_set_active_item(0);
 				mouse_released = false;
-				inp_clear_events();
+				num_inputevents = 0;
 				break;
 			}
 		}
@@ -955,8 +960,6 @@ bool MENUS::on_mousemove(float x, float y)
 
 bool MENUS::on_input(INPUT_EVENT e)
 {
-//	if(e.)
-	//
 	if(e.flags&INPFLAG_PRESS && e.key == KEY_ESC)
 	{
 		menu_active	= !menu_active;
@@ -964,7 +967,11 @@ bool MENUS::on_input(INPUT_EVENT e)
 	}
 	
 	if(menu_active)
+	{
+		if(num_inputevents < MAX_INPUTEVENTS)
+			inputevents[num_inputevents++] = e;
 		return true;
+	}
 	return false;
 }
 
@@ -1002,7 +1009,7 @@ void MENUS::on_render()
 	
 	if(!menu_active)
 		return;
-
+		
 	// update colors
 	vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f));
 	gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f);
@@ -1059,4 +1066,5 @@ void MENUS::on_render()
 		gfx_text_ex(&cursor, buf, -1);
 	}
 
+	num_inputevents = 0;
 }
diff --git a/src/game/client/components/menus.hpp b/src/game/client/components/menus.hpp
index 4d45c65a..6caaa479 100644
--- a/src/game/client/components/menus.hpp
+++ b/src/game/client/components/menus.hpp
@@ -60,6 +60,11 @@ class MENUS : public COMPONENT
 	int active_page;
 	bool menu_active;
 	vec2 mouse_pos;
+
+	// TODO: this is a bit ugly but.. well.. yeah	
+	enum { MAX_INPUTEVENTS = 32 };
+	static INPUT_EVENT inputevents[MAX_INPUTEVENTS];
+	static int num_inputevents;
 	
 	// for graphic settings
 	bool need_restart;
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index a209eef8..a88e7d3c 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -102,9 +102,9 @@ void GAMECLIENT::on_init()
 	
 	// build the input stack
 	input.add(console);
+	input.add(chat); // chat has higher prio due to tha you can quit it by pressing esc
 	input.add(motd); // for pressing esc to remove it
 	input.add(menus);
-	input.add(chat);
 	input.add(&emoticon);
 	input.add(controls);
 	input.add(binds);