From 313781b365dcce8dce03a3c26babdcb4637ca2bf Mon Sep 17 00:00:00 2001 From: Joel de Vahl Date: Sun, 5 Aug 2007 23:00:32 +0000 Subject: scroll wheel for weapon switch --- src/game/client/game_client.cpp | 13 +++++++++++-- src/game/client/menu.cpp | 8 ++++++-- src/game/game_variables.h | 1 + 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'src/game') diff --git a/src/game/client/game_client.cpp b/src/game/client/game_client.cpp index 8b813968..487ec73d 100644 --- a/src/game/client/game_client.cpp +++ b/src/game/client/game_client.cpp @@ -1319,12 +1319,21 @@ void render_game() // Weapon switching #define TEST_WEAPON_KEY(key) if (inp_key_pressed(config.key_weapon ## key)) input.activeweapon = key-1; + if(config.scroll_weapon) + { + int delta = inp_mouse_scroll(); + input.activeweapon = input.activeweapon + delta; + + if(input.activeweapon > 3) + input.activeweapon = 3; + else if(input.activeweapon < 0) + input.activeweapon = 0; + } + TEST_WEAPON_KEY(1); TEST_WEAPON_KEY(2); TEST_WEAPON_KEY(3); TEST_WEAPON_KEY(4); - //for(int i = 0; i < 8; i++) - // input.activeweapon = inp_key_pressed('1'+i) ? i : input.activeweapon; } snap_input(&input, sizeof(input)); diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index a3b94356..b39b8c3a 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -804,7 +804,7 @@ static int settings_controls_render() { "Hammer:", &config_copy.key_weapon4, config_set_key_weapon4 }, }; - for (int i = 0; i < 7; i++) + for (int i = 0; i < 6; i++) { key_thing key = keys[i + scroll_index]; @@ -825,7 +825,11 @@ static int settings_controls_render() config_set_key_hook(&config_copy, ui_do_key_reader(&config_copy.key_hook, column2_x, row1_y + 160, 150, 36, config_copy.key_hook)); */ - scroll_index = do_scroll_bar_vert(&scroll_index, 600, row1_y, 40 * 7, 9 - 7, scroll_index); + scroll_index = do_scroll_bar_vert(&scroll_index, 600, row1_y, 40 * 6, 9 - 7, scroll_index); + + ui_do_label(column1_x, row1_y + 40 * 6, "Scroll wheel weapon switch", 22); + config_set_scroll_weapon(&config_copy, ui_do_check_box(&config_copy.scroll_weapon, column2_x + 50, row1_y + 40 * 6, 22, 22, config_copy.scroll_weapon)); + return 0; } diff --git a/src/game/game_variables.h b/src/game/game_variables.h index 2e91bd2b..6b380f85 100644 --- a/src/game/game_variables.h +++ b/src/game/game_variables.h @@ -7,6 +7,7 @@ MACRO_CONFIG_INT(key_weapon1, 49, 32, 512) MACRO_CONFIG_INT(key_weapon2, 50, 32, 512) MACRO_CONFIG_INT(key_weapon3, 51, 32, 512) MACRO_CONFIG_INT(key_weapon4, 52, 32, 512) +MACRO_CONFIG_INT(scroll_weapon, 1, 0, 1) MACRO_CONFIG_INT(scorelimit, 20, 0, 1000) MACRO_CONFIG_INT(timelimit, 0, 0, 1000) -- cgit 1.4.1