mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
fixed so that menus doesn't use inp_get_event. fixes the gui key binder
This commit is contained in:
parent
9672fe674f
commit
dfe7cb1579
|
@ -52,7 +52,9 @@ bool CHAT::on_input(INPUT_EVENT e)
|
||||||
if(mode == MODE_NONE)
|
if(mode == MODE_NONE)
|
||||||
return false;
|
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])
|
if(input.get_string()[0])
|
||||||
gameclient.chat->say(mode == MODE_ALL ? 0 : 1, input.get_string());
|
gameclient.chat->say(mode == MODE_ALL ? 0 : 1, input.get_string());
|
||||||
|
|
|
@ -38,6 +38,10 @@ vec4 MENUS::color_tabbar_inactive_ingame;
|
||||||
vec4 MENUS::color_tabbar_active_ingame;
|
vec4 MENUS::color_tabbar_active_ingame;
|
||||||
|
|
||||||
|
|
||||||
|
INPUT_EVENT MENUS::inputevents[MAX_INPUTEVENTS];
|
||||||
|
int MENUS::num_inputevents;
|
||||||
|
|
||||||
|
|
||||||
MENUS::MENUS()
|
MENUS::MENUS()
|
||||||
{
|
{
|
||||||
popup = POPUP_NONE;
|
popup = POPUP_NONE;
|
||||||
|
@ -46,6 +50,7 @@ MENUS::MENUS()
|
||||||
|
|
||||||
need_restart = false;
|
need_restart = false;
|
||||||
menu_active = true;
|
menu_active = true;
|
||||||
|
num_inputevents = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 MENUS::button_color_mul(const void *id)
|
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;
|
char c = e.ch;
|
||||||
int k = e.key;
|
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)
|
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)
|
if(e.flags&INPFLAG_PRESS && e.key && e.key != KEY_ESC)
|
||||||
{
|
{
|
||||||
new_key = e.key;
|
new_key = e.key;
|
||||||
ui_set_active_item(0);
|
ui_set_active_item(0);
|
||||||
mouse_released = false;
|
mouse_released = false;
|
||||||
inp_clear_events();
|
num_inputevents = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,8 +960,6 @@ bool MENUS::on_mousemove(float x, float y)
|
||||||
|
|
||||||
bool MENUS::on_input(INPUT_EVENT e)
|
bool MENUS::on_input(INPUT_EVENT e)
|
||||||
{
|
{
|
||||||
// if(e.)
|
|
||||||
//
|
|
||||||
if(e.flags&INPFLAG_PRESS && e.key == KEY_ESC)
|
if(e.flags&INPFLAG_PRESS && e.key == KEY_ESC)
|
||||||
{
|
{
|
||||||
menu_active = !menu_active;
|
menu_active = !menu_active;
|
||||||
|
@ -964,7 +967,11 @@ bool MENUS::on_input(INPUT_EVENT e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(menu_active)
|
if(menu_active)
|
||||||
|
{
|
||||||
|
if(num_inputevents < MAX_INPUTEVENTS)
|
||||||
|
inputevents[num_inputevents++] = e;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,4 +1066,5 @@ void MENUS::on_render()
|
||||||
gfx_text_ex(&cursor, buf, -1);
|
gfx_text_ex(&cursor, buf, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
num_inputevents = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,11 @@ class MENUS : public COMPONENT
|
||||||
bool menu_active;
|
bool menu_active;
|
||||||
vec2 mouse_pos;
|
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
|
// for graphic settings
|
||||||
bool need_restart;
|
bool need_restart;
|
||||||
|
|
||||||
|
|
|
@ -102,9 +102,9 @@ void GAMECLIENT::on_init()
|
||||||
|
|
||||||
// build the input stack
|
// build the input stack
|
||||||
input.add(console);
|
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(motd); // for pressing esc to remove it
|
||||||
input.add(menus);
|
input.add(menus);
|
||||||
input.add(chat);
|
|
||||||
input.add(&emoticon);
|
input.add(&emoticon);
|
||||||
input.add(controls);
|
input.add(controls);
|
||||||
input.add(binds);
|
input.add(binds);
|
||||||
|
|
Loading…
Reference in a new issue