shithub: choc

Download patch

ref: 78e4c2833de6ae33f70dcfb9f5f656658eac2dfc
parent: 32565063e7dd9a0e18e496a31bc46ddfe65eee4d
author: Simon Howard <[email protected]>
date: Fri Oct 10 19:54:52 EDT 2008

Convert Heretic/Hexen menu code to use translated key value when
entering save game names.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1353

--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -1030,6 +1030,7 @@
 
 boolean MN_Responder(event_t * event)
 {
+    int charTyped;
     int key;
     int i;
     MenuItem_t *item;
@@ -1048,6 +1049,8 @@
         return (false);
     }
     key = event->data1;
+    charTyped = event->data2;
+
     if (InfoType)
     {
         if (gamemode == shareware)
@@ -1081,7 +1084,7 @@
 
     if (askforquit)
     {
-        switch (key)
+        switch (charTyped)
         {
             case 'y':
                 if (askforquit)
@@ -1413,7 +1416,7 @@
                 {
                     if (CurrentMenu->items[i].text)
                     {
-                        if (toupper(key)
+                        if (toupper(charTyped)
                             == toupper(CurrentMenu->items[i].text[0]))
                         {
                             CurrentItPos = i;
@@ -1463,24 +1466,18 @@
         }
         if (slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
         {
-            if ((key >= 'a' && key <= 'z'))
+            if (isalpha(charTyped))
             {
-                *textBuffer++ = key - 32;
+                *textBuffer++ = toupper(charTyped);
                 *textBuffer = ASCII_CURSOR;
                 slotptr++;
                 return (true);
             }
-            if (((key >= '0' && key <= '9') || key == ' '
-                 || key == ',' || key == '.' || key == '-') && !shiftdown)
+            if (isdigit(charTyped) || charTyped == ' '
+              || charTyped == ',' || charTyped == '.' || charTyped == '-'
+              || charTyped == '!')
             {
-                *textBuffer++ = key;
-                *textBuffer = ASCII_CURSOR;
-                slotptr++;
-                return (true);
-            }
-            if (shiftdown && key == '1')
-            {
-                *textBuffer++ = '!';
+                *textBuffer++ = charTyped;
                 *textBuffer = ASCII_CURSOR;
                 slotptr++;
                 return (true);
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -1133,6 +1133,7 @@
 boolean MN_Responder(event_t * event)
 {
     int key;
+    int charTyped;
     int i;
     MenuItem_t *item;
     extern boolean automapactive;
@@ -1150,6 +1151,8 @@
         return (false);
     }
     key = event->data1;
+    charTyped = event->data2;
+
     if (InfoType)
     {
         if (gamemode == shareware)
@@ -1186,7 +1189,7 @@
 
     if (askforquit)
     {
-        switch (key)
+        switch (charTyped)
         {
             case 'y':
                 if (askforquit)
@@ -1548,7 +1551,7 @@
                 {
                     if (CurrentMenu->items[i].text)
                     {
-                        if (toupper(key)
+                        if (toupper(charTyped)
                             == toupper(CurrentMenu->items[i].text[0]))
                         {
                             CurrentItPos = i;
@@ -1598,24 +1601,18 @@
         }
         if (slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE)
         {
-            if ((key >= 'a' && key <= 'z'))
+            if (isalpha(charTyped))
             {
-                *textBuffer++ = key - 32;
+                *textBuffer++ = toupper(charTyped);
                 *textBuffer = ASCII_CURSOR;
                 slotptr++;
                 return (true);
             }
-            if (((key >= '0' && key <= '9') || key == ' '
-                 || key == ',' || key == '.' || key == '-') && !shiftdown)
+            if (isdigit(charTyped) || charTyped == ' '
+             || charTyped == ',' || charTyped == '.' || charTyped == '-'
+             || charTyped == '!')
             {
-                *textBuffer++ = key;
-                *textBuffer = ASCII_CURSOR;
-                slotptr++;
-                return (true);
-            }
-            if (shiftdown && key == '1')
-            {
-                *textBuffer++ = '!';
+                *textBuffer++ = charTyped;
                 *textBuffer = ASCII_CURSOR;
                 slotptr++;
                 return (true);