about summary refs log tree commit diff
path: root/src/game/client/components/menus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/client/components/menus.cpp')
-rw-r--r--src/game/client/components/menus.cpp46
1 files changed, 3 insertions, 43 deletions
diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp
index 050c7056..0fd024c3 100644
--- a/src/game/client/components/menus.cpp
+++ b/src/game/client/components/menus.cpp
@@ -18,6 +18,7 @@
 
 #include <game/generated/gc_data.hpp>
 #include <game/client/gameclient.hpp>
+#include <game/client/lineinput.hpp>
 #include <mastersrv/mastersrv.h>
 
 vec4 MENUS::gui_color;
@@ -199,7 +200,7 @@ void MENUS::ui_draw_checkbox_number(const void *id, const char *text, int checke
 	ui_draw_checkbox_common(id, text, buf, r);
 }
 
-int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, float font_size, bool hidden)
+int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, unsigned str_size, float font_size, bool hidden)
 {
     int inside = ui_mouse_inside(rect);
 	int r = 0;
@@ -229,48 +230,7 @@ int MENUS::ui_do_edit_box(void *id, const RECT *rect, char *str, int str_size, f
 		for(int i = 0; i < num_inputevents; i++)
 		{
 			len = strlen(str);
-			INPUT_EVENT e = inputevents[i];
-			char c = e.ch;
-			int k = e.key;
-
-			if (at_index > len)
-				at_index = len;
-			
-			if (!(c >= 0 && c < 32) && c != 127)
-			{
-				if (len < str_size - 1 && at_index < str_size - 1)
-				{
-					memmove(str + at_index + 1, str + at_index, len - at_index + 1);
-					str[at_index] = c;
-					at_index++;
-					r = 1;
-				}
-			}
-			
-			if(e.flags&INPFLAG_PRESS)
-			{
-				if (k == KEY_BACKSPACE && at_index > 0)
-				{
-					memmove(str + at_index - 1, str + at_index, len - at_index + 1);
-					at_index--;
-					r = 1;
-				}
-				else if (k == KEY_DELETE && at_index < len)
-				{
-					memmove(str + at_index, str + at_index + 1, len - at_index);
-					r = 1;
-				}
-				else if (k == KEY_RETURN)
-					ui_clear_last_active_item();
-				else if (k == KEY_LEFT && at_index > 0)
-					at_index--;
-				else if (k == KEY_RIGHT && at_index < len)
-					at_index++;
-				else if (k == KEY_HOME)
-					at_index = 0;
-				else if (k == KEY_END)
-					at_index = len;
-			}
+			LINEINPUT::manipulate(inputevents[i], str, str_size, &len, &at_index);
 		}
 	}