diff options
| author | Joel de Vahl <joel@stalverk80.se> | 2007-08-05 23:00:32 +0000 |
|---|---|---|
| committer | Joel de Vahl <joel@stalverk80.se> | 2007-08-05 23:00:32 +0000 |
| commit | 313781b365dcce8dce03a3c26babdcb4637ca2bf (patch) | |
| tree | 9ba43c34f29818929f067fde1d82f0d0b64eeae8 /src | |
| parent | 01306887157deabe2c4d5ea0ffd0813fcc874f89 (diff) | |
| download | zcatch-313781b365dcce8dce03a3c26babdcb4637ca2bf.tar.gz zcatch-313781b365dcce8dce03a3c26babdcb4637ca2bf.zip | |
scroll wheel for weapon switch
Diffstat (limited to 'src')
| -rw-r--r-- | src/engine/client/client.cpp | 1 | ||||
| -rw-r--r-- | src/engine/interface.h | 2 | ||||
| -rw-r--r-- | src/game/client/game_client.cpp | 13 | ||||
| -rw-r--r-- | src/game/client/menu.cpp | 8 | ||||
| -rw-r--r-- | src/game/game_variables.h | 1 |
5 files changed, 21 insertions, 4 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 379b7a88..d184bb22 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -45,6 +45,7 @@ static int keyboard_current = 0; static int keyboard_first = 1; void inp_mouse_relative(int *x, int *y) { input::mouse_position(x, y); } +int inp_mouse_scroll() { input::mouse_scroll(); } int inp_key_pressed(int key) { return keyboard_state[keyboard_current][key]; } int inp_key_was_pressed(int key) { return keyboard_state[keyboard_current^1][key]; } int inp_key_down(int key) { return inp_key_pressed(key)&&!inp_key_was_pressed(key); } diff --git a/src/engine/interface.h b/src/engine/interface.h index 5d3e2fe6..7809d810 100644 --- a/src/engine/interface.h +++ b/src/engine/interface.h @@ -350,6 +350,8 @@ bool snd_shutdown(); */ void inp_mouse_relative(int *x, int *y); +int inp_mouse_scroll(); + /* Function: inp_key_pressed Checks if a key is pressed. 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) |