shithub: choc

Download patch

ref: 587a0f7758ecee136824dbb8f7337d7b75392a08
parent: 904ed263f5f7c36ff12e7c6a527feda1986d4232
author: Simon Howard <fraggle@soulsphere.org>
date: Tue Jan 5 16:41:54 EST 2016

doom: Convert menu to use new input method.

--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -29,6 +29,7 @@
 #include "d_main.h"
 #include "deh_main.h"
 
+#include "i_input.h"
 #include "i_swap.h"
 #include "i_system.h"
 #include "i_timer.h"
@@ -634,9 +635,16 @@
 //
 void M_SaveSelect(int choice)
 {
+    int x, y;
+
     // we are going to be intercepting all chars
     saveStringEnter = 1;
-    
+
+    // We need to turn on text input:
+    x = LoadDef.x - 11;
+    y = LoadDef.y + choice * LINEHEIGHT - 4;
+    I_StartTextInput(x, y, x + 8 + 24 * 8 + 8, y + LINEHEIGHT - 2);
+
     saveSlot = choice;
     M_StringCopy(saveOldString,savegamestrings[choice], SAVESTRINGSIZE);
     if (!strcmp(savegamestrings[choice], EMPTYSTRING))
@@ -1577,6 +1585,7 @@
 
           case KEY_ESCAPE:
             saveStringEnter = 0;
+            I_StopTextInput();
             M_StringCopy(savegamestrings[saveSlot], saveOldString,
                          SAVESTRINGSIZE);
             break;
@@ -1583,22 +1592,32 @@
 
 	  case KEY_ENTER:
 	    saveStringEnter = 0;
+            I_StopTextInput();
 	    if (savegamestrings[saveSlot][0])
 		M_DoSave(saveSlot);
 	    break;
 
 	  default:
-            // This is complicated.
+            // Savegame name entry. This is complicated.
             // Vanilla has a bug where the shift key is ignored when entering
             // a savegame name. If vanilla_keyboard_mapping is on, we want
-            // to emulate this bug by using 'data1'. But if it's turned off,
-            // it implies the user doesn't care about Vanilla emulation: just
-            // use the correct 'data2'.
+            // to emulate this bug by using ev->data1. But if it's turned off,
+            // it implies the user doesn't care about Vanilla emulation:
+            // instead, use ev->data3 which gives the fully-translated and
+            // modified key input.
 
+            if (ev->type != ev_keydown)
+            {
+                break;
+            }
             if (vanilla_keyboard_mapping)
             {
-                ch = key;
+                ch = ev->data1;
             }
+            else
+            {
+                ch = ev->data3;
+            }
 
             ch = toupper(ch);
 
@@ -1620,7 +1639,7 @@
 	}
 	return true;
     }
-    
+
     // Take care of any messages that need input
     if (messageToPrint)
     {