shithub: choc

Download patch

ref: 3c1733b7b356efc7c4531242472a047fa23d1740
parent: 1d8283647fe152be88fad6b675c601ff8c423487
author: Simon Howard <[email protected]>
date: Sat Aug 21 13:47:24 EDT 2010

"Bug fix".

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

--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -45,6 +45,61 @@
 #include "multiplayer.h"
 #include "sound.h"
 
+static const int cheat_sequence[] =
+{
+    KEY_UPARROW, KEY_UPARROW, KEY_DOWNARROW, KEY_DOWNARROW,
+    KEY_LEFTARROW, KEY_RIGHTARROW, KEY_LEFTARROW, KEY_RIGHTARROW,
+    'b', 'a', KEY_ENTER, 0
+};
+
+static unsigned int cheat_sequence_index = 0;
+
+// I think these are good "sensible" defaults:
+
+static void SensibleDefaults(void)
+{
+    key_up = 'w';
+    key_down = 's';
+    key_strafeleft = 'a';
+    key_straferight = 'd';
+    mousebprevweapon = 4;
+    mousebnextweapon = 3;
+    snd_musicdevice = 3;
+    joybspeed = 29;
+    vanilla_savegame_limit = 0;
+    vanilla_keyboard_mapping = 0;
+    vanilla_demo_limit = 0;
+    show_endoom = 0;
+    dclick_use = 0;
+    novert = 1;
+}
+
+static int MainMenuKeyPress(txt_window_t *window, int key, void *user_data)
+{
+    if (key == cheat_sequence[cheat_sequence_index])
+    {
+        ++cheat_sequence_index;
+
+        if (cheat_sequence[cheat_sequence_index] == 0)
+        {
+            SensibleDefaults();
+            cheat_sequence_index = 0;
+
+            window = TXT_NewWindow(NULL);
+            TXT_AddWidget(window, TXT_NewLabel("    \x01    "));
+            TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, NULL);
+
+            return 1;
+        }
+    }
+    else
+    {
+        cheat_sequence_index = 0;
+    }
+
+    return 0;
+}
+
 static void DoQuit(void *widget, void *dosave)
 {
     if (dosave != NULL)
@@ -136,6 +191,8 @@
     quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit");
     TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL);
     TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action);
+
+    TXT_SetKeyListener(window, MainMenuKeyPress, NULL);
 }
 
 //