scroll wheel for weapon switch

This commit is contained in:
Joel de Vahl 2007-08-05 23:00:32 +00:00
parent 0130688715
commit 313781b365
5 changed files with 21 additions and 4 deletions

View file

@ -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); }

View file

@ -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.

View file

@ -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));

View file

@ -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;
}

View file

@ -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)