ref: 92bf6bef31891587d411dbec34452abd084dead9
parent: 587a0f7758ecee136824dbb8f7337d7b75392a08
author: Simon Howard <[email protected]>
date: Tue Jan 5 17:05:31 EST 2016
strife: Convert chat/menu to use new input interface. These match the changes to the Doom code.
--- a/src/strife/hu_stuff.c
+++ b/src/strife/hu_stuff.c
@@ -24,6 +24,7 @@
#include "z_zone.h"
#include "deh_main.h"
+#include "i_input.h"
#include "i_swap.h"
#include "i_video.h"
@@ -514,6 +515,19 @@
return c;
}
+// fraggle 01/05/15: New functions to support the Chocolate input interface.
+static void StartChatInput(void)
+{
+ chat_on = true;
+ I_StartTextInput(HU_INPUTX, HU_INPUTY, SCREENWIDTH, HU_INPUTY + 8);
+}
+
+static void StopChatInput(void)
+{
+ chat_on = false;
+ I_StopTextInput();
+}
+
//
// HU_Responder
//
@@ -563,7 +577,8 @@
}
else if (netgame && ev->data2 == key_multi_msg)
{
- eatkey = chat_on = true;
+ StartChatInput();
+ eatkey = true;
HUlib_resetIText(&w_chat);
HU_queueChatChar(HU_BROADCAST);
}
@@ -572,7 +587,7 @@
}
else
{
- c = ev->data2;
+ c = ev->data3;
// send a macro
if (altdown)
{
@@ -591,7 +606,7 @@
HU_queueChatChar(KEY_ENTER);
// leave chat mode and notify that it was sent
- chat_on = false;
+ StopChatInput();
M_StringCopy(lastmessage, chat_macros[c], sizeof(lastmessage));
plr->message = lastmessage;
eatkey = true;
@@ -610,7 +625,7 @@
// slightly different than vanilla, to allow keys to be customized
for(i = 0; i < MAXPLAYERS; i++)
{
- if(c == key_multi_msgplayer[i])
+ if (ev->data1 == key_multi_msgplayer[i])
break;
}
if(i < MAXPLAYERS)
@@ -658,7 +673,7 @@
if (c == KEY_ENTER)
{
- chat_on = false;
+ StopChatInput();
if (w_chat.l.len)
{
// [STRIFE]: name setting
@@ -682,7 +697,9 @@
}
}
else if (c == KEY_ESCAPE)
- chat_on = false;
+ {
+ StopChatInput();
+ }
}
}
--- a/src/strife/m_menu.c
+++ b/src/strife/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"
@@ -752,9 +753,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);
+
// [STRIFE]
quickSaveSlot = choice;
//saveSlot = choice;
@@ -1849,6 +1857,7 @@
case KEY_ESCAPE:
saveStringEnter = 0;
+ I_StopTextInput();
M_StringCopy(savegamestrings[quickSaveSlot], saveOldString,
sizeof(savegamestrings[quickSaveSlot]));
break;
@@ -1856,6 +1865,7 @@
case KEY_ENTER:
// [STRIFE]
saveStringEnter = 0;
+ I_StopTextInput();
if(gameversion == exe_strife_1_31 && !namingCharacter)
{
// In 1.31, we can be here as a result of normal saving again,
@@ -1869,16 +1879,26 @@
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);