shithub: choc

Download patch

ref: f6dd57602af20eaf9a4094a80bb60452f2593b50
parent: a72890d4d15a8b5b316c23ff68def3c8b805b4df
author: Simon Howard <fraggle@soulsphere.org>
date: Tue Jan 5 17:42:01 EST 2016

hexen: Convert chat/menu to use new input interface.

Call I_StartTextInput(), etc.

--- a/src/hexen/ct_chat.c
+++ b/src/hexen/ct_chat.c
@@ -18,6 +18,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "h2def.h"
+#include "i_input.h"
 #include "s_sound.h"
 #include "doomkeys.h"
 #include "m_controls.h"
@@ -136,6 +137,7 @@
 void CT_Stop(void)
 {
     chatmodeon = false;
+    I_StopTextInput();
     return;
 }
 
@@ -228,6 +230,7 @@
         }
         CT_queueChatChar(sendto);
         chatmodeon = true;
+        I_StartTextInput(25, 10, SCREENWIDTH, 18);
         return true;
     }
     else
@@ -270,9 +273,9 @@
             CT_queueChatChar(KEY_BACKSPACE);
             return true;
         }
-        else if (ValidChatChar(ev->data2))
+        else if (ValidChatChar(ev->data3))
         {
-            CT_queueChatChar(toupper(ev->data2));
+            CT_queueChatChar(toupper(ev->data3));
             return true;
         }
     }
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -20,6 +20,7 @@
 #include <ctype.h>
 #include "h2def.h"
 #include "doomkeys.h"
+#include "i_input.h"
 #include "i_system.h"
 #include "i_swap.h"
 #include "i_video.h"
@@ -921,7 +922,15 @@
 
     if (!FileMenuKeySteal)
     {
+        int x, y;
+
         FileMenuKeySteal = true;
+        // We need to activate the text input interface to type the save
+        // game name:
+        x = SaveMenu.x + 1;
+        y = SaveMenu.y + 1 + option * ITEM_HEIGHT;
+        I_StartTextInput(x, y, x + 190, y + ITEM_HEIGHT - 2);
+
         M_StringCopy(oldSlotText, SlotText[option], sizeof(oldSlotText));
         ptr = SlotText[option];
         while (*ptr)
@@ -939,6 +948,7 @@
     {
         G_SaveGame(option, SlotText[option]);
         FileMenuKeySteal = false;
+        I_StopTextInput();
         MN_DeactivateMenu();
     }
     BorderNeedRefresh = true;
@@ -1627,7 +1637,11 @@
         return (false);
     }
     else
-    {                           // Editing file names
+    {
+        // Editing file names
+        // When typing a savegame name, we use the fully shifted and
+        // translated input value from event->data3.
+        charTyped = event->data3;
         textBuffer = &SlotText[currentSlot][slotptr];
         if (key == KEY_BACKSPACE)
         {
@@ -1728,6 +1742,10 @@
         CurrentMenu->oldItPos = CurrentItPos;
     }
     MenuActive = false;
+    if (FileMenuKeySteal)
+    {
+        I_StopTextInput();
+    }
     if (!netgame)
     {
         paused = false;