diff options
author | Simon Howard | 2009-06-10 19:49:29 +0000 |
---|---|---|
committer | Simon Howard | 2009-06-10 19:49:29 +0000 |
commit | d1f24077aae2c1258b26688bc67c89c566645576 (patch) | |
tree | f18d8ee7ccdb8015dc513560b119b19a13a2c116 | |
parent | 1dc0e81d95f1057ebf8d42f9932f7e1ba9b46136 (diff) | |
download | chocolate-doom-d1f24077aae2c1258b26688bc67c89c566645576.tar.gz chocolate-doom-d1f24077aae2c1258b26688bc67c89c566645576.tar.bz2 chocolate-doom-d1f24077aae2c1258b26688bc67c89c566645576.zip |
Make Hexen weapon and map keys reconfigurable.
Subversion-branch: /branches/raven-branch
Subversion-revision: 1587
-rw-r--r-- | src/hexen/am_map.c | 179 | ||||
-rw-r--r-- | src/hexen/am_map.h | 24 | ||||
-rw-r--r-- | src/hexen/g_game.c | 20 | ||||
-rw-r--r-- | src/hexen/h2_main.c | 2 |
4 files changed, 114 insertions, 111 deletions
diff --git a/src/hexen/am_map.c b/src/hexen/am_map.c index 27789f3e..458ee449 100644 --- a/src/hexen/am_map.c +++ b/src/hexen/am_map.c @@ -22,15 +22,16 @@ // //----------------------------------------------------------------------------- +#include <stdio.h> #include "h2def.h" #include "doomkeys.h" #include "i_video.h" #include "i_swap.h" +#include "m_controls.h" #include "p_local.h" #include "am_map.h" #include "am_data.h" -#include <stdio.h> #include "v_video.h" #define NUMALIAS 3 // Number of antialiased lines. @@ -422,13 +423,16 @@ void AM_maxOutWindowScale(void) boolean AM_Responder(event_t * ev) { int rc; + int key; static int cheatstate = 0; static int bigstate = 0; + key = ev->data1; + rc = false; if (!automapactive) { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY + if (ev->type == ev_keydown && key == key_map_toggle && gamestate == GS_LEVEL) { AM_Start(); @@ -440,67 +444,76 @@ boolean AM_Responder(event_t * ev) else if (ev->type == ev_keydown) { rc = true; - switch (ev->data1) + + if (key == key_map_east) // pan right { - case AM_PANRIGHTKEY: // pan right - if (!followplayer) - m_paninc.x = FTOM(F_PANINC); - else - rc = false; - break; - case AM_PANLEFTKEY: // pan left - if (!followplayer) - m_paninc.x = -FTOM(F_PANINC); - else - rc = false; - break; - case AM_PANUPKEY: // pan up - if (!followplayer) - m_paninc.y = FTOM(F_PANINC); - else - rc = false; - break; - case AM_PANDOWNKEY: // pan down - if (!followplayer) - m_paninc.y = -FTOM(F_PANINC); - else - rc = false; - break; - case AM_ZOOMOUTKEY: // zoom out - mtof_zoommul = M_ZOOMOUT; - ftom_zoommul = M_ZOOMIN; - break; - case AM_ZOOMINKEY: // zoom in - mtof_zoommul = M_ZOOMIN; - ftom_zoommul = M_ZOOMOUT; - break; - case AM_ENDKEY: - bigstate = 0; - viewactive = true; - AM_Stop(); - SB_state = -1; - break; - case AM_GOBIGKEY: - bigstate = !bigstate; - if (bigstate) - { - AM_saveScaleAndLoc(); - AM_minOutWindowScale(); - } - else - AM_restoreScaleAndLoc(); - break; - case AM_FOLLOWKEY: - followplayer = !followplayer; - f_oldloc.x = INT_MAX; - P_SetMessage(plr, - followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, - true); - break; - default: - cheatstate = 0; + if (!followplayer) + m_paninc.x = FTOM(F_PANINC); + else + rc = false; + } + else if (key == key_map_west) // pan left + { + if (!followplayer) + m_paninc.x = -FTOM(F_PANINC); + else + rc = false; + } + else if (key == key_map_north) // pan up + { + if (!followplayer) + m_paninc.y = FTOM(F_PANINC); + else + rc = false; + } + else if (key == key_map_south) // pan down + { + if (!followplayer) + m_paninc.y = -FTOM(F_PANINC); + else rc = false; } + else if (key == key_map_zoomout) // zoom out + { + mtof_zoommul = M_ZOOMOUT; + ftom_zoommul = M_ZOOMIN; + } + else if (key == key_map_zoomin) // zoom in + { + mtof_zoommul = M_ZOOMIN; + ftom_zoommul = M_ZOOMOUT; + } + else if (key == key_map_toggle) + { + bigstate = 0; + viewactive = true; + AM_Stop(); + SB_state = -1; + } + else if (key == key_map_maxzoom) + { + bigstate = !bigstate; + if (bigstate) + { + AM_saveScaleAndLoc(); + AM_minOutWindowScale(); + } + else + AM_restoreScaleAndLoc(); + } + else if (key == key_map_follow) + { + followplayer = !followplayer; + f_oldloc.x = INT_MAX; + P_SetMessage(plr, + followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, + true); + } + else + { + cheatstate = 0; + rc = false; + } if (cheat_kills[ShowKillsCount] == ev->data1 && netgame && deathmatch) { @@ -520,29 +533,31 @@ boolean AM_Responder(event_t * ev) else if (ev->type == ev_keyup) { rc = false; - switch (ev->data1) + + if (key == key_map_east) { - case AM_PANRIGHTKEY: - if (!followplayer) - m_paninc.x = 0; - break; - case AM_PANLEFTKEY: - if (!followplayer) - m_paninc.x = 0; - break; - case AM_PANUPKEY: - if (!followplayer) - m_paninc.y = 0; - break; - case AM_PANDOWNKEY: - if (!followplayer) - m_paninc.y = 0; - break; - case AM_ZOOMOUTKEY: - case AM_ZOOMINKEY: - mtof_zoommul = FRACUNIT; - ftom_zoommul = FRACUNIT; - break; + if (!followplayer) + m_paninc.x = 0; + } + else if (key == key_map_west) + { + if (!followplayer) + m_paninc.x = 0; + } + else if (key == key_map_north) + { + if (!followplayer) + m_paninc.y = 0; + } + else if (key == key_map_south) + { + if (!followplayer) + m_paninc.y = 0; + } + else if (key == key_map_zoomin || key == key_map_zoomout) + { + mtof_zoommul = FRACUNIT; + ftom_zoommul = FRACUNIT; } } return rc; diff --git a/src/hexen/am_map.h b/src/hexen/am_map.h index 803add40..1be272a0 100644 --- a/src/hexen/am_map.h +++ b/src/hexen/am_map.h @@ -78,30 +78,6 @@ #define XHAIRCOLORS GRAYS // drawing stuff -#define FB 0 - -#define KEY_TAB 9 -#define AM_PANDOWNKEY KEY_DOWNARROW -#define AM_PANUPKEY KEY_UPARROW -#define AM_PANRIGHTKEY KEY_RIGHTARROW -#define AM_PANLEFTKEY KEY_LEFTARROW -//#define AM_PANDOWNKEY SC_DOWNARROW -//#define AM_PANUPKEY SC_UPARROW -//#define AM_PANRIGHTKEY SC_RIGHTARROW -//#define AM_PANLEFTKEY SC_LEFTARROW - -#define AM_ZOOMINKEY '=' -//#define AM_ZOOMINKEY 13 -//#define AM_ZOOMOUTKEY 12 -#define AM_ZOOMOUTKEY '-' -#define AM_STARTKEY KEY_TAB -#define AM_ENDKEY KEY_TAB -#define AM_GOBIGKEY '0' -//#define AM_GOBIGKEY 11 -//#define AM_FOLLOWKEY 33 -//#define AM_GRIDKEY 34 -#define AM_FOLLOWKEY 'f' -#define AM_GRIDKEY 'g' #define AM_NUMMARKPOINTS 10 diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c index 9684eb17..190fdf76 100644 --- a/src/hexen/g_game.c +++ b/src/hexen/g_game.c @@ -135,6 +135,14 @@ fixed_t sidemove[NUMCLASSES][2] = { fixed_t angleturn[3] = { 640, 1280, 320 }; // + slow turn +static int *weapon_keys[] = +{ + &key_weapon1, + &key_weapon2, + &key_weapon3, + &key_weapon4, +}; + #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -446,13 +454,15 @@ void G_BuildTiccmd(ticcmd_t * cmd) dclicks = 0; // clear double clicks if hit use button } - for (i = 0; i < NUMWEAPONS; i++) + for (i=0; i<arrlen(weapon_keys); ++i) { - if (gamekeydown['1' + i]) + int key = *weapon_keys[i]; + + if (gamekeydown[key]) { - cmd->buttons |= BT_CHANGE; - cmd->buttons |= i << BT_WEAPONSHIFT; - break; + cmd->buttons |= BT_CHANGE; + cmd->buttons |= i<<BT_WEAPONSHIFT; + break; } } diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index dd09f631..6c6ab560 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -152,7 +152,9 @@ void D_BindVariables(void) I_BindSoundVariables(); M_BindBaseControls(); + M_BindMapControls(); M_BindMenuControls(); + M_BindWeaponControls(); M_BindHereticControls(); M_BindHexenControls(); |