ref: f27269f7a8a9230c59283cb824ab130226a2101c
parent: c6a63b6286567001f80a5366648ea88265abb2ce
parent: 5e3314ddca27eb4ef5090b482b169d7e8f31690f
author: Jonathan Dowland <jon+github@alcopop.org>
date: Tue Mar 21 13:12:45 EDT 2017
Merge branch 'joystick-allow-savegames' into sdl2-branch
--- a/src/doom/m_menu.c
+++ b/src/doom/m_menu.c
@@ -112,6 +112,7 @@
int saveStringEnter;
int saveSlot; // which slot to save in
int saveCharIndex; // which char we're editing
+static boolean joypadSave = false; // was the save action initiated by joypad?
// old save description before edit
char saveOldString[SAVESTRINGSIZE];
@@ -631,6 +632,17 @@
}
//
+// Generate a default save slot name when the user saves to
+// an empty slot via the joypad.
+//
+static void SetDefaultSaveName(int slot)
+{
+ M_snprintf(savegamestrings[itemOn], SAVESTRINGSIZE - 1,
+ "JOYSTICK SLOT %i", itemOn + 1);
+ joypadSave = false;
+}
+
+//
// User wants to save. Start string input for M_Responder
//
void M_SaveSelect(int choice)
@@ -648,7 +660,14 @@
saveSlot = choice;
M_StringCopy(saveOldString,savegamestrings[choice], SAVESTRINGSIZE);
if (!strcmp(savegamestrings[choice], EMPTYSTRING))
- savegamestrings[choice][0] = 0;
+ {
+ savegamestrings[choice][0] = 0;
+
+ if (joypadSave)
+ {
+ SetDefaultSaveName(choice);
+ }
+ }
saveCharIndex = strlen(savegamestrings[choice]);
}
@@ -1430,8 +1449,19 @@
{
key = key_menu_confirm;
}
+ // Simulate pressing "Enter" when we are supplying a save slot name
+ else if (saveStringEnter)
+ {
+ key = KEY_ENTER;
+ // XXX: fire action bleeding into game
+ }
else
{
+ // if selecting a save slot via joypad, set a flag
+ if (currentMenu == &SaveDef)
+ {
+ joypadSave = true;
+ }
key = key_menu_forward;
}
joywait = I_GetTime() + 5;
@@ -1442,6 +1472,11 @@
if (messageToPrint && messageNeedsInput)
{
key = key_menu_abort;
+ }
+ // If user was entering a save name, back out
+ else if (saveStringEnter)
+ {
+ key = KEY_ESCAPE;
}
else
{