diff options
| author | Jakob Fries <jakob.fries@gmail.com> | 2007-06-10 15:19:04 +0000 |
|---|---|---|
| committer | Jakob Fries <jakob.fries@gmail.com> | 2007-06-10 15:19:04 +0000 |
| commit | 7ad13ccb127edf520dead3f20570dd5f772cc61d (patch) | |
| tree | 4984ef63f6655bf2ba14ad837d5624e69369c105 /src/game/client | |
| parent | 6523310be6401ca8e2a3974214a97495c63b2523 (diff) | |
| download | zcatch-7ad13ccb127edf520dead3f20570dd5f772cc61d.tar.gz zcatch-7ad13ccb127edf520dead3f20570dd5f772cc61d.zip | |
new input thingies
Diffstat (limited to 'src/game/client')
| -rw-r--r-- | src/game/client/game_client.cpp | 6 | ||||
| -rw-r--r-- | src/game/client/menu.cpp | 59 |
2 files changed, 39 insertions, 26 deletions
diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index bab7a496..932585cf 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -1742,10 +1742,10 @@ void modc_render() input.angle = (int)(a*256.0f); input.jump = inp_key_pressed(config.key_jump); - input.fire = inp_mouse_button_pressed(0);// | (oldinput.fire << 16); + input.fire = inp_key_pressed(input::mouse_1);// | (oldinput.fire << 16); //oldinput.fire = input.fire & 0x0000ffff; - input.hook = inp_mouse_button_pressed(1) || inp_key_pressed(baselib::keys::lctrl); // be nice to mac users O.o + input.hook = inp_key_pressed(input::mouse_2) || inp_key_pressed(baselib::input::lctrl); // be nice to mac users O.o input.blink = inp_key_pressed('S'); // Weapon switching @@ -1965,7 +1965,7 @@ void modc_render() // render gui stuff gfx_mapscreen(0,0,400,300); // render score board - if(inp_key_pressed(baselib::keys::tab)) + if(inp_key_pressed(baselib::input::tab)) { gfx_texture_set(font_texture); gfx_quads_text(10, 50, 8, "Score Board"); diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index bcdb740c..aa8ddd08 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -3,8 +3,7 @@ #include <string.h> #include <baselib/system.h> -#include <baselib/keys.h> -#include <baselib/mouse.h> +#include <baselib/input.h> #include <baselib/network.h> #include <engine/interface.h> @@ -119,7 +118,6 @@ struct gui_part { int x, y; int w, h; - bool stretch_x, stretch_y; }; gui_part parts[] = @@ -427,24 +425,39 @@ struct server_list int ui_do_key_reader(void *id, float x, float y, float w, float h, int key) { // process + static bool can_be_selected = true; int inside = ui_mouse_inside(x, y, w, h); int new_key = key; - if (inside) + if (!ui_mouse_button(0) && !can_be_selected) + can_be_selected = true; + + if (can_be_selected) { - ui_set_hot_item(id); + if (inside) + { + ui_set_hot_item(id); - if (ui_mouse_button(0)) - ui_set_active_item(id); + if (ui_mouse_button(0) && ui_active_item() != id) + { + ui_set_active_item(id); + can_be_selected = false; + } + } } - if (ui_active_item() == id) + if (can_be_selected) { - int k = keys::last_key(); - if (k) + if (ui_active_item() == id) { - new_key = k; - ui_set_active_item(0); + int k = input::last_key(); + dbg_msg("menu/-", "%i", k); + if (k) + { + new_key = k; + ui_set_active_item(0); + can_be_selected = false; + } } } @@ -452,7 +465,7 @@ int ui_do_key_reader(void *id, float x, float y, float w, float h, int key) gui_composite_box_enum box_style = screen_info_box; draw_box(box_style, tileset_regular, x, y, w, h); - const char *str = keys::key_name(key); + const char *str = input::key_name(key); ui_do_label(x + 10, y, str, 36); if (ui_active_item() == id) { @@ -530,8 +543,8 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int if (ui_active_item() == id) { - int c = keys::last_char(); - int k = keys::last_key(); + int c = input::last_char(); + int k = input::last_key(); int len = strlen(str); if (c >= 32 && c < 128) @@ -543,7 +556,7 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int } } - if (k == keys::backspace) + if (k == input::backspace) { if (len > 0) str[len-1] = 0; @@ -926,8 +939,8 @@ static int menu_render(netaddr4 *server_address) void modmenu_init() { - keys::enable_char_cache(); - keys::enable_key_cache(); + input::enable_char_cache(); + input::enable_key_cache(); current_font->font_texture = gfx_load_texture("data/big_font.png"); @@ -974,9 +987,9 @@ int modmenu_render(void *ptr) mwy = mx*3.0f; // adjust to zoom and offset int buttons = 0; - if(inp_mouse_button_pressed(0)) buttons |= 1; - if(inp_mouse_button_pressed(1)) buttons |= 2; - if(inp_mouse_button_pressed(2)) buttons |= 4; + if(inp_key_pressed(input::mouse_1)) buttons |= 1; + if(inp_key_pressed(input::mouse_2)) buttons |= 2; + if(inp_key_pressed(input::mouse_3)) buttons |= 4; ui_update(mx,my,mx*3.0f,my*3.0f,buttons); } @@ -1003,8 +1016,8 @@ int modmenu_render(void *ptr) music_menu_id = -1; } - keys::clear_char(); - keys::clear_key(); + input::clear_char(); + input::clear_key(); return r; } |