mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed various issues with binding keys like enter and f1-f15
This commit is contained in:
parent
ac1aeab149
commit
da473cf614
|
@ -444,23 +444,22 @@ int MENUS::ui_do_key_reader(void *id, const RECT *rect, int key)
|
|||
|
||||
if(ui_active_item() == id)
|
||||
{
|
||||
for(int i = 0; i < num_inputevents; i++)
|
||||
if(binder.got_key)
|
||||
{
|
||||
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;
|
||||
num_inputevents = 0;
|
||||
break;
|
||||
}
|
||||
new_key = binder.key.key;
|
||||
binder.got_key = false;
|
||||
ui_set_active_item(0);
|
||||
mouse_released = false;
|
||||
}
|
||||
}
|
||||
else if(ui_hot_item() == id)
|
||||
{
|
||||
if(ui_mouse_button(0) && mouse_released)
|
||||
{
|
||||
binder.take_key = true;
|
||||
binder.got_key = false;
|
||||
ui_set_active_item(id);
|
||||
}
|
||||
}
|
||||
|
||||
if(inside)
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
#include <game/client/component.hpp>
|
||||
#include <game/client/ui.hpp>
|
||||
|
||||
|
||||
// compnent to fetch keypresses, override all other input
|
||||
class MENUS_KEYBINDER : public COMPONENT
|
||||
{
|
||||
public:
|
||||
bool take_key;
|
||||
bool got_key;
|
||||
INPUT_EVENT key;
|
||||
MENUS_KEYBINDER();
|
||||
virtual bool on_input(INPUT_EVENT e);
|
||||
};
|
||||
|
||||
class MENUS : public COMPONENT
|
||||
{
|
||||
static vec4 gui_color;
|
||||
|
@ -150,6 +162,8 @@ class MENUS : public COMPONENT
|
|||
void render_settings(RECT main_view);
|
||||
|
||||
public:
|
||||
static MENUS_KEYBINDER binder;
|
||||
|
||||
MENUS();
|
||||
|
||||
void render_loading(float percent);
|
||||
|
|
|
@ -18,6 +18,30 @@
|
|||
#include "menus.hpp"
|
||||
#include "skins.hpp"
|
||||
|
||||
MENUS_KEYBINDER MENUS::binder;
|
||||
|
||||
MENUS_KEYBINDER::MENUS_KEYBINDER()
|
||||
{
|
||||
take_key = false;
|
||||
got_key = false;
|
||||
}
|
||||
|
||||
bool MENUS_KEYBINDER::on_input(INPUT_EVENT e)
|
||||
{
|
||||
if(take_key)
|
||||
{
|
||||
if(e.flags&INPFLAG_PRESS && e.key != KEY_ESC)
|
||||
{
|
||||
key = e;
|
||||
got_key = true;
|
||||
take_key = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MENUS::render_settings_player(RECT main_view)
|
||||
{
|
||||
RECT button;
|
||||
|
|
|
@ -146,6 +146,7 @@ void GAMECLIENT::on_console_init()
|
|||
all.add(console);
|
||||
|
||||
// build the input stack
|
||||
input.add(&menus->binder); // this will take over all input when we want to bind a key
|
||||
input.add(&binds->special_binds);
|
||||
input.add(console);
|
||||
input.add(chat); // chat has higher prio due to tha you can quit it by pressing esc
|
||||
|
|
Loading…
Reference in a new issue