shithub: choc

Download patch

ref: adcd838e72854528dec15016b32b6e0bfa292fcd
parent: 334af5fd565c261f070a42d17a1429cfca1b6651
author: Simon Howard <[email protected]>
date: Wed Jun 3 16:45:54 EDT 2009

Add dialog to setup tool for editing menu shortcuts.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1546

--- a/setup/configfile.c
+++ b/setup/configfile.c
@@ -239,6 +239,7 @@
     {"chatmacro7", &chat_macros[7], DEFAULT_STRING, 0, 0 },
     {"chatmacro8", &chat_macros[8], DEFAULT_STRING, 0, 0 },
     {"chatmacro9", &chat_macros[9], DEFAULT_STRING, 0, 0 },
+
 };
 
 static default_collection_t doom_defaults = 
@@ -282,6 +283,28 @@
     {"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},
+    {"key_menu_left",               &key_menu_left, DEFAULT_KEY, 0, 0},
+    {"key_menu_right",              &key_menu_right, DEFAULT_KEY, 0, 0},
+    {"key_menu_back",               &key_menu_back, DEFAULT_KEY, 0, 0},
+    {"key_menu_forward",            &key_menu_forward, DEFAULT_KEY, 0, 0},
+    {"key_menu_confirm",            &key_menu_confirm, DEFAULT_KEY, 0, 0},
+    {"key_menu_abort",              &key_menu_abort, DEFAULT_KEY, 0, 0},
+    {"key_menu_help",               &key_menu_help, DEFAULT_KEY, 0, 0},
+    {"key_menu_save",               &key_menu_save, DEFAULT_KEY, 0, 0},
+    {"key_menu_load",               &key_menu_load, DEFAULT_KEY, 0, 0},
+    {"key_menu_volume",             &key_menu_volume, DEFAULT_KEY, 0, 0},
+    {"key_menu_detail",             &key_menu_detail, DEFAULT_KEY, 0, 0},
+    {"key_menu_qsave",              &key_menu_qsave, DEFAULT_KEY, 0, 0},
+    {"key_menu_endgame",            &key_menu_endgame, DEFAULT_KEY, 0, 0},
+    {"key_menu_messages",           &key_menu_messages, DEFAULT_KEY, 0, 0},
+    {"key_menu_qload",              &key_menu_qload, DEFAULT_KEY, 0, 0},
+    {"key_menu_quit",               &key_menu_quit, DEFAULT_KEY, 0, 0},
+    {"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},
 };
 
 static default_collection_t extra_defaults =
--- a/setup/keyboard.c
+++ b/setup/keyboard.c
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 // 02111-1307, USA.
 //
+
 #include "textscreen.h"
 #include "doomtype.h"
 
@@ -38,6 +39,33 @@
 int key_strafe = KEY_RALT;
 int key_speed = KEY_RSHIFT;
 
+// Menu keys:
+
+int key_menu_activate  = KEY_ESCAPE;
+int key_menu_up        = KEY_UPARROW;
+int key_menu_down      = KEY_DOWNARROW;
+int key_menu_left      = KEY_LEFTARROW;
+int key_menu_right     = KEY_RIGHTARROW;
+int key_menu_back      = KEY_BACKSPACE;
+int key_menu_forward   = KEY_ENTER;
+int key_menu_confirm   = 'y';
+int key_menu_abort     = 'n';
+
+int key_menu_help      = KEY_F1;
+int key_menu_save      = KEY_F2;
+int key_menu_load      = KEY_F3;
+int key_menu_volume    = KEY_F4;
+int key_menu_detail    = KEY_F5;
+int key_menu_qsave     = KEY_F6;
+int key_menu_endgame   = KEY_F7;
+int key_menu_messages  = KEY_F8;
+int key_menu_qload     = KEY_F9;
+int key_menu_quit      = KEY_F10;
+int key_menu_gamma     = KEY_F11;
+
+int key_menu_incscreen = KEY_EQUALS;
+int key_menu_decscreen = KEY_MINUS;
+
 int vanilla_keyboard_mapping = 1;
 
 static int always_run = 0;
@@ -86,7 +114,9 @@
     }
 }
 
-static void AddKeyControl(txt_table_t *table, char *name, int *var)
+// Add a label and keyboard input to the specified table.
+
+static txt_key_input_t *AddKeyInput(txt_table_t *table, char *name, int *var)
 {
     txt_key_input_t *key_input;
 
@@ -93,9 +123,63 @@
     TXT_AddWidget(table, TXT_NewLabel(name));
     key_input = TXT_NewKeyInput(var);
     TXT_AddWidget(table, key_input);
+
+    return key_input;
+}
+
+// Add a keyboard input for a game control.  Each key can only be bound
+// to one game control at a time.
+
+static void AddKeyControl(txt_table_t *table, char *name, int *var)
+{
+    txt_key_input_t *key_input;
+
+    key_input = AddKeyInput(table, name, var);
     TXT_SignalConnect(key_input, "set", KeySetCallback, var);
 }
 
+static void MenuKeysDialog(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");
+
+    table = TXT_NewTable(2);
+
+    TXT_SetColumnWidths(table, 25, 10);
+
+    AddKeyInput(table, "Activate menu",         &key_menu_activate);
+    AddKeyInput(table, "Move cursor up",        &key_menu_up);
+    AddKeyInput(table, "Move cursor down",      &key_menu_down);
+    AddKeyInput(table, "Move slider left",      &key_menu_left);
+    AddKeyInput(table, "Move slider right",     &key_menu_right);
+    AddKeyInput(table, "Go to previous menu",   &key_menu_back);
+    AddKeyInput(table, "Activate menu item",    &key_menu_forward);
+    AddKeyInput(table, "Confirm action",        &key_menu_confirm);
+    AddKeyInput(table, "Cancel action",         &key_menu_abort);
+
+    AddKeyInput(table, "Help screen",           &key_menu_help);
+    AddKeyInput(table, "Save game",             &key_menu_save);
+    AddKeyInput(table, "Load game",             &key_menu_load);
+    AddKeyInput(table, "Sound volume",          &key_menu_volume);
+    AddKeyInput(table, "Toggle detail",         &key_menu_detail);
+    AddKeyInput(table, "Quick save",            &key_menu_qsave);
+    AddKeyInput(table, "End game",              &key_menu_endgame);
+    AddKeyInput(table, "Toggle messages",       &key_menu_messages);
+    AddKeyInput(table, "Quick load",            &key_menu_qload);
+    AddKeyInput(table, "Quit game",             &key_menu_quit);
+    AddKeyInput(table, "Toggle gamma",          &key_menu_gamma);
+
+    AddKeyInput(table, "Increase screen size",  &key_menu_incscreen);
+    AddKeyInput(table, "Decrease screen size",  &key_menu_decscreen);
+
+    scrollpane = TXT_NewScrollPane(0, 10, table);
+
+    TXT_AddWidget(window, scrollpane);
+}
+
 void ConfigKeyboard(void)
 {
     txt_window_t *window;
@@ -113,6 +197,7 @@
 
                    TXT_NewSeparator("Action"),
                    action_table = TXT_NewTable(2),
+                   TXT_NewButton2("Menu keys...", MenuKeysDialog, NULL),
 
                    TXT_NewSeparator("Misc."),
                    run_control = TXT_NewCheckBox("Always run", &always_run),
--- a/setup/keyboard.h
+++ b/setup/keyboard.h
@@ -35,6 +35,31 @@
 extern int joybspeed;
 extern int vanilla_keyboard_mapping;
 
+extern int key_menu_activate;
+extern int key_menu_up;
+extern int key_menu_down;
+extern int key_menu_left;
+extern int key_menu_right;
+extern int key_menu_back;
+extern int key_menu_forward;
+extern int key_menu_confirm;
+extern int key_menu_abort;
+
+extern int key_menu_help;
+extern int key_menu_save;
+extern int key_menu_load;
+extern int key_menu_volume;
+extern int key_menu_detail;
+extern int key_menu_qsave;
+extern int key_menu_endgame;
+extern int key_menu_messages;
+extern int key_menu_qload;
+extern int key_menu_quit;
+extern int key_menu_gamma;
+
+extern int key_menu_incscreen;
+extern int key_menu_decscreen;
+
 void ConfigKeyboard(void);
 
 #endif /* #ifndef SETUP_KEYBOARD_H */