ref: e3e71290f86c785a29ec6b9eeb609c7625776255
parent: b30d83c55a749994d95ebe4d7320db6db3bd43da
author: Simon Howard <[email protected]>
date: Fri Jun 5 12:58:48 EDT 2009
Add key binding variables for automap and weapon keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1551
--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -283,6 +283,7 @@
{"mouseb_use", &mousebuse, DEFAULT_INT, 0, 0},
{"mouseb_backward", &mousebbackward, DEFAULT_INT, 0, 0},
{"use_libsamplerate", &use_libsamplerate, DEFAULT_INT, 0, 0},
+
{"key_menu_activate", &key_menu_activate, DEFAULT_KEY, 0, 0},
{"key_menu_up", &key_menu_up, DEFAULT_KEY, 0, 0},
{"key_menu_down", &key_menu_down, DEFAULT_KEY, 0, 0},
@@ -305,6 +306,27 @@
{"key_menu_gamma", &key_menu_gamma, DEFAULT_KEY, 0, 0},
{"key_menu_incscreen", &key_menu_incscreen, DEFAULT_KEY, 0, 0},
{"key_menu_decscreen", &key_menu_decscreen, DEFAULT_KEY, 0, 0},
+
+ {"key_map_toggle", &key_map_toggle, DEFAULT_KEY, 0, 0},
+ {"key_map_north", &key_map_north, DEFAULT_KEY, 0, 0},
+ {"key_map_south", &key_map_south, DEFAULT_KEY, 0, 0},
+ {"key_map_east", &key_map_east, DEFAULT_KEY, 0, 0},
+ {"key_map_west", &key_map_west, DEFAULT_KEY, 0, 0},
+ {"key_map_zoomin", &key_map_zoomin, DEFAULT_KEY, 0, 0},
+ {"key_map_zoomout", &key_map_zoomout, DEFAULT_KEY, 0, 0},
+ {"key_map_maxzoom", &key_map_maxzoom, DEFAULT_KEY, 0, 0},
+ {"key_map_follow", &key_map_follow, DEFAULT_KEY, 0, 0},
+ {"key_map_grid", &key_map_grid, DEFAULT_KEY, 0, 0},
+ {"key_map_mark", &key_map_mark, DEFAULT_KEY, 0, 0},
+ {"key_map_clearmark", &key_map_clearmark, DEFAULT_KEY, 0, 0},
+ {"key_weapon1", &key_weapon1, DEFAULT_KEY, 0, 0},
+ {"key_weapon2", &key_weapon2, DEFAULT_KEY, 0, 0},
+ {"key_weapon3", &key_weapon3, DEFAULT_KEY, 0, 0},
+ {"key_weapon4", &key_weapon4, DEFAULT_KEY, 0, 0},
+ {"key_weapon5", &key_weapon5, DEFAULT_KEY, 0, 0},
+ {"key_weapon6", &key_weapon6, DEFAULT_KEY, 0, 0},
+ {"key_weapon7", &key_weapon7, DEFAULT_KEY, 0, 0},
+ {"key_weapon8", &key_weapon8, DEFAULT_KEY, 0, 0},
};
static default_collection_t extra_defaults =
--- a/setup/keyboard.c
+++ b/setup/keyboard.c
@@ -66,6 +66,28 @@
int key_menu_incscreen = KEY_EQUALS;
int key_menu_decscreen = KEY_MINUS;
+int key_map_north = KEY_UPARROW;
+int key_map_south = KEY_DOWNARROW;
+int key_map_east = KEY_RIGHTARROW;
+int key_map_west = KEY_LEFTARROW;
+int key_map_zoomin = '=';
+int key_map_zoomout = '-';
+int key_map_toggle = KEY_TAB;
+int key_map_maxzoom = '0';
+int key_map_follow = 'f';
+int key_map_grid = 'g';
+int key_map_mark = 'm';
+int key_map_clearmark = 'c';
+
+int key_weapon1 = '1';
+int key_weapon2 = '2';
+int key_weapon3 = '3';
+int key_weapon4 = '4';
+int key_weapon5 = '5';
+int key_weapon6 = '6';
+int key_weapon7 = '7';
+int key_weapon8 = '8';
+
int vanilla_keyboard_mapping = 1;
static int always_run = 0;
@@ -74,7 +96,10 @@
static int *controls[] = { &key_left, &key_right, &key_up, &key_down,
&key_strafeleft, &key_straferight, &key_fire,
- &key_use, &key_strafe, &key_speed, NULL };
+ &key_use, &key_strafe, &key_speed,
+ &key_weapon1, &key_weapon2, &key_weapon3,
+ &key_weapon4, &key_weapon5, &key_weapon6,
+ &key_weapon7, &key_weapon8, NULL };
static int *menu_nav[] = { &key_menu_activate, &key_menu_up, &key_menu_down,
&key_menu_left, &key_menu_right, &key_menu_back,
@@ -86,6 +111,12 @@
&key_menu_qload, &key_menu_quit, &key_menu_gamma,
&key_menu_incscreen, &key_menu_decscreen, NULL };
+static int *map_keys[] = { &key_map_north, &key_map_south, &key_map_east,
+ &key_map_west, &key_map_zoomin, &key_map_zoomout,
+ &key_map_toggle, &key_map_maxzoom, &key_map_follow,
+ &key_map_grid, &key_map_mark, &key_map_clearmark,
+ NULL };
+
static void UpdateJoybSpeed(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(var))
{
if (always_run)
@@ -156,6 +187,7 @@
CheckKeyGroup(variable, controls);
CheckKeyGroup(variable, menu_nav);
CheckKeyGroup(variable, shortcuts);
+ CheckKeyGroup(variable, map_keys);
}
// Add a label and keyboard input to the specified table.
@@ -171,18 +203,37 @@
TXT_SignalConnect(key_input, "set", KeySetCallback, var);
}
-static void MenuKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
+static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
{
txt_window_t *window;
txt_table_t *table;
txt_scrollpane_t *scrollpane;
- window = TXT_NewWindow("Menu keys");
+ window = TXT_NewWindow("Other keys");
table = TXT_NewTable(2);
TXT_SetColumnWidths(table, 25, 10);
+ TXT_AddWidgets(table, TXT_NewLabel(" - Weapons - "),
+ TXT_NewStrut(0, 0),
+ NULL);
+
+ AddKeyControl(table, "Weapon 1", &key_weapon1);
+ AddKeyControl(table, "Weapon 2", &key_weapon2);
+ AddKeyControl(table, "Weapon 3", &key_weapon3);
+ AddKeyControl(table, "Weapon 4", &key_weapon4);
+ AddKeyControl(table, "Weapon 5", &key_weapon5);
+ AddKeyControl(table, "Weapon 6", &key_weapon6);
+ AddKeyControl(table, "Weapon 7", &key_weapon7);
+ AddKeyControl(table, "Weapon 8", &key_weapon8);
+
+ TXT_AddWidgets(table, TXT_NewStrut(0, 1),
+ TXT_NewStrut(0, 1),
+ TXT_NewLabel(" - Menu navigation - "),
+ TXT_NewStrut(0, 0),
+ NULL);
+
AddKeyControl(table, "Activate menu", &key_menu_activate);
AddKeyControl(table, "Move cursor up", &key_menu_up);
AddKeyControl(table, "Move cursor down", &key_menu_down);
@@ -193,6 +244,12 @@
AddKeyControl(table, "Confirm action", &key_menu_confirm);
AddKeyControl(table, "Cancel action", &key_menu_abort);
+ TXT_AddWidgets(table, TXT_NewStrut(0, 1),
+ TXT_NewStrut(0, 1),
+ TXT_NewLabel(" - Shortcut keys - "),
+ TXT_NewStrut(0, 0),
+ NULL);
+
AddKeyControl(table, "Help screen", &key_menu_help);
AddKeyControl(table, "Save game", &key_menu_save);
AddKeyControl(table, "Load game", &key_menu_load);
@@ -208,6 +265,25 @@
AddKeyControl(table, "Increase screen size", &key_menu_incscreen);
AddKeyControl(table, "Decrease screen size", &key_menu_decscreen);
+ TXT_AddWidgets(table, TXT_NewStrut(0, 1),
+ TXT_NewStrut(0, 1),
+ TXT_NewLabel(" - Map - "),
+ TXT_NewStrut(0, 0),
+ NULL);
+
+ AddKeyControl(table, "Toggle map", &key_map_toggle);
+ AddKeyControl(table, "Zoom in", &key_map_zoomin);
+ AddKeyControl(table, "Zoom out", &key_map_zoomout);
+ AddKeyControl(table, "Maximum zoom out", &key_map_maxzoom);
+ AddKeyControl(table, "Follow mode", &key_map_follow);
+ AddKeyControl(table, "Pan north", &key_map_north);
+ AddKeyControl(table, "Pan south", &key_map_south);
+ AddKeyControl(table, "Pan east", &key_map_east);
+ AddKeyControl(table, "Pan west", &key_map_west);
+ AddKeyControl(table, "Toggle grid", &key_map_grid);
+ AddKeyControl(table, "Mark location", &key_map_mark);
+ AddKeyControl(table, "Clear all marks", &key_map_clearmark);
+
scrollpane = TXT_NewScrollPane(0, 12, table);
TXT_AddWidget(window, scrollpane);
@@ -230,7 +306,7 @@
TXT_NewSeparator("Action"),
action_table = TXT_NewTable(4),
- TXT_NewButton2("Menu keys...", MenuKeysDialog, NULL),
+ TXT_NewButton2("Other keys...", OtherKeysDialog, NULL),
NULL);
TXT_AddWidgets(window,
--- a/setup/keyboard.h
+++ b/setup/keyboard.h
@@ -35,6 +35,8 @@
extern int joybspeed;
extern int vanilla_keyboard_mapping;
+// Menu keys:
+
extern int key_menu_activate;
extern int key_menu_up;
extern int key_menu_down;
@@ -59,6 +61,32 @@
extern int key_menu_incscreen;
extern int key_menu_decscreen;
+
+// Automap keys:
+
+extern int key_map_north;
+extern int key_map_south;
+extern int key_map_east;
+extern int key_map_west;
+extern int key_map_zoomin;
+extern int key_map_zoomout;
+extern int key_map_toggle;
+extern int key_map_maxzoom;
+extern int key_map_follow;
+extern int key_map_grid;
+extern int key_map_mark;
+extern int key_map_clearmark;
+
+// Weapon keys:
+
+extern int key_weapon1;
+extern int key_weapon2;
+extern int key_weapon3;
+extern int key_weapon4;
+extern int key_weapon5;
+extern int key_weapon6;
+extern int key_weapon7;
+extern int key_weapon8;
void ConfigKeyboard(void);
--- a/src/am_map.c
+++ b/src/am_map.c
@@ -90,19 +90,18 @@
// drawing stuff
#define FB 0
-#define AM_PANDOWNKEY KEY_DOWNARROW
-#define AM_PANUPKEY KEY_UPARROW
-#define AM_PANRIGHTKEY KEY_RIGHTARROW
-#define AM_PANLEFTKEY KEY_LEFTARROW
-#define AM_ZOOMINKEY '='
-#define AM_ZOOMOUTKEY '-'
-#define AM_STARTKEY KEY_TAB
-#define AM_ENDKEY KEY_TAB
-#define AM_GOBIGKEY '0'
-#define AM_FOLLOWKEY 'f'
-#define AM_GRIDKEY 'g'
-#define AM_MARKKEY 'm'
-#define AM_CLEARMARKKEY 'c'
+int key_map_north = KEY_UPARROW;
+int key_map_south = KEY_DOWNARROW;
+int key_map_east = KEY_RIGHTARROW;
+int key_map_west = KEY_LEFTARROW;
+int key_map_zoomin = '=';
+int key_map_zoomout = '-';
+int key_map_toggle = KEY_TAB;
+int key_map_maxzoom = '0';
+int key_map_follow = 'f';
+int key_map_grid = 'g';
+int key_map_mark = 'm';
+int key_map_clearmark = 'c';
#define AM_NUMMARKPOINTS 10
@@ -632,12 +631,13 @@
static int cheatstate=0;
static int bigstate=0;
static char buffer[20];
+ int key;
rc = false;
if (!automapactive)
{
- if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY)
+ if (ev->type == ev_keydown && ev->data1 == key_map_toggle)
{
AM_Start ();
viewactive = false;
@@ -644,79 +644,91 @@
rc = true;
}
}
-
else if (ev->type == ev_keydown)
{
-
rc = true;
- switch(ev->data1)
- {
- 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 ();
- 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;
+ key = ev->data1;
+
+ if (key == key_map_east) // pan right
+ {
+ 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 ();
+ }
+ 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;
if (followplayer)
plr->message = DEH_String(AMSTR_FOLLOWON);
else
plr->message = DEH_String(AMSTR_FOLLOWOFF);
- break;
- case AM_GRIDKEY:
- grid = !grid;
+ }
+ else if (key == key_map_grid)
+ {
+ grid = !grid;
if (grid)
plr->message = DEH_String(AMSTR_GRIDON);
else
plr->message = DEH_String(AMSTR_GRIDOFF);
- break;
- case AM_MARKKEY:
- sprintf(buffer, "%s %d", DEH_String(AMSTR_MARKEDSPOT), markpointnum);
- plr->message = buffer;
- AM_addMark();
- break;
- case AM_CLEARMARKKEY:
- AM_clearMarks();
- plr->message = DEH_String(AMSTR_MARKSCLEARED);
- break;
- default:
- cheatstate=0;
- rc = false;
- }
+ }
+ else if (key == key_map_mark)
+ {
+ sprintf(buffer, "%s %d", DEH_String(AMSTR_MARKEDSPOT), markpointnum);
+ plr->message = buffer;
+ AM_addMark();
+ }
+ else if (key == key_map_clearmark)
+ {
+ AM_clearMarks();
+ plr->message = DEH_String(AMSTR_MARKSCLEARED);
+ }
+ else
+ {
+ cheatstate=0;
+ rc = false;
+ }
+
if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data2))
{
rc = false;
@@ -723,30 +735,32 @@
cheating = (cheating+1) % 3;
}
}
-
else if (ev->type == ev_keyup)
{
- rc = false;
- switch (ev->data1)
- {
- 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;
- }
+ rc = false;
+ key = ev->data1;
+
+ if (key == key_map_east)
+ {
+ 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_zoomout || key == key_map_zoomin)
+ {
+ mtof_zoommul = FRACUNIT;
+ ftom_zoommul = FRACUNIT;
+ }
}
return rc;
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -173,6 +173,15 @@
int key_use = ' ';
int key_strafe = KEY_RALT;
int key_speed = KEY_RSHIFT;
+
+int key_weapon1 = '1';
+int key_weapon2 = '2';
+int key_weapon3 = '3';
+int key_weapon4 = '4';
+int key_weapon5 = '5';
+int key_weapon6 = '6';
+int key_weapon7 = '7';
+int key_weapon8 = '8';
int mousebfire = 0;
int mousebstrafe = 1;
@@ -211,6 +220,17 @@
fixed_t sidemove[2] = {0x18, 0x28};
fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn
+static int *weapon_keys[] = {
+ &key_weapon1,
+ &key_weapon2,
+ &key_weapon3,
+ &key_weapon4,
+ &key_weapon5,
+ &key_weapon6,
+ &key_weapon7,
+ &key_weapon8
+};
+
#define SLOWTURNTICS 6
#define NUMKEYS 256
@@ -501,13 +521,18 @@
}
// chainsaw overrides
- for (i=0 ; i<NUMWEAPONS-1 ; i++)
- if (gamekeydown['1'+i])
- {
+
+ for (i=0; i<arrlen(weapon_keys); ++i)
+ {
+ int key = *weapon_keys[i];
+
+ if (gamekeydown[key])
+ {
cmd->buttons |= BT_CHANGE;
cmd->buttons |= i<<BT_WEAPONSHIFT;
break;
- }
+ }
+ }
// mouse
if (mousebuttons[mousebforward])
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -99,6 +99,8 @@
extern int key_menu_confirm;
extern int key_menu_abort;
+// Keyboard shortcuts:
+
extern int key_menu_help;
extern int key_menu_save;
extern int key_menu_load;
@@ -114,6 +116,28 @@
extern int key_menu_incscreen;
extern int key_menu_decscreen;
+extern int key_map_north;
+extern int key_map_south;
+extern int key_map_east;
+extern int key_map_west;
+extern int key_map_zoomin;
+extern int key_map_zoomout;
+extern int key_map_toggle;
+extern int key_map_maxzoom;
+extern int key_map_follow;
+extern int key_map_grid;
+extern int key_map_mark;
+extern int key_map_clearmark;
+
+extern int key_weapon1;
+extern int key_weapon2;
+extern int key_weapon3;
+extern int key_weapon4;
+extern int key_weapon5;
+extern int key_weapon6;
+extern int key_weapon7;
+extern int key_weapon8;
+
extern int mousebfire;
extern int mousebstrafe;
extern int mousebforward;
@@ -870,6 +894,125 @@
CONFIG_VARIABLE_KEY(key_menu_decscreen, key_menu_decscreen),
+ //!
+ // Key to toggle the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_toggle, key_map_toggle),
+
+ //!
+ // Key to pan north when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_north, key_map_north),
+
+ //!
+ // Key to pan south when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_south, key_map_south),
+
+ //!
+ // Key to pan east when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_east, key_map_east),
+
+ //!
+ // Key to pan west when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_west, key_map_west),
+
+ //!
+ // Key to zoom in when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_zoomin, key_map_zoomin),
+
+ //!
+ // Key to zoom out when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_zoomout, key_map_zoomout),
+
+ //!
+ // Key to zoom out the maximum amount when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_maxzoom, key_map_maxzoom),
+
+ //!
+ // Key to toggle follow mode when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_follow, key_map_follow),
+
+ //!
+ // Key to toggle the grid display when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_grid, key_map_grid),
+
+ //!
+ // Key to set a mark when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_mark, key_map_mark),
+
+ //!
+ // Key to clear all marks when in the map view.
+ //
+
+ CONFIG_VARIABLE_KEY(key_map_clearmark, key_map_clearmark),
+
+ //!
+ // Key to select weapon 1.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon1, key_weapon1),
+
+ //!
+ // Key to select weapon 2.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon2, key_weapon2),
+
+ //!
+ // Key to select weapon 3.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon3, key_weapon3),
+
+ //!
+ // Key to select weapon 4.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon4, key_weapon4),
+
+ //!
+ // Key to select weapon 5.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon5, key_weapon5),
+
+ //!
+ // Key to select weapon 6.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon6, key_weapon6),
+
+ //!
+ // Key to select weapon 7.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon7, key_weapon7),
+
+ //!
+ // Key to select weapon 8.
+ //
+
+ CONFIG_VARIABLE_KEY(key_weapon8, key_weapon8),
};
static default_collection_t extra_defaults =