Tutorial mode support for control switching

This commit is contained in:
mazmazz 2018-11-11 08:20:08 -05:00
parent 75fc91644b
commit 85bcf6d389
4 changed files with 46 additions and 1 deletions

View file

@ -71,6 +71,7 @@ int snprintf(char *str, size_t n, const char *fmt, ...);
#include "fastcmp.h"
#include "keys.h"
#include "filesrch.h" // refreshdirmenu, mainwadstally
#include "g_input.h" // tutorial mode control scheming
#ifdef CMAKECONFIG
#include "config.h"
@ -667,6 +668,7 @@ void D_AdvanceDemo(void)
void D_StartTitle(void)
{
INT32 i;
boolean tutorialpostprompt = false;
S_StopMusic();
@ -712,6 +714,13 @@ void D_StartTitle(void)
modeattacking = ATTACKING_NONE;
// The title screen is obviously not a tutorial! (Unless I'm mistaken)
if (tutorialmode)
{
// check if retained controls are custom
tutorialpostprompt = (G_GetControlScheme(gamecontroldefault[gcs_custom], gcmovement, num_gcmovement) == gcs_custom
&& G_GetControlScheme(gamecontrol, gcmovement, num_gcmovement) != gcs_custom);
G_CopyControls(gamecontrol, gamecontroldefault[gcs_custom], gcmovement, num_gcmovement); // using gcs_custom as temp storage
}
tutorialmode = false;
// empty maptol so mario/etc sounds don't play in sound test when they shouldn't
@ -736,6 +745,10 @@ void D_StartTitle(void)
// Reset the palette
if (rendermode != render_none)
V_SetPaletteLump("PLAYPAL");
if (tutorialpostprompt)
M_StartMessage("Do you want to save the recommended controls?\n\n(Press 'Y' to confirm, \nor any key to keep \nyour current controls.)",
M_TutorialSaveControlResponse, MM_YESNO);
}
//

View file

@ -1808,6 +1808,8 @@ static void Command_Map_f(void)
else
fromlevelselect = ((netgame || multiplayer) && ((gametype == newgametype) && (newgametype == GT_COOP)));
if (tutorialmode)
G_CopyControls(gamecontrol, gamecontroldefault[gcs_custom], gcmovement, num_gcmovement); // using gcs_custom as temp storage
tutorialmode = false; // warping takes us out of tutorial mode
D_MapChange(newmapnum, newgametype, false, newresetplayers, 0, false, fromlevelselect);

View file

@ -6134,13 +6134,41 @@ static void M_LoadGameLevelSelect(INT32 choice)
M_SetupNextMenu(&SP_LevelSelectDef);
}
void M_TutorialSaveControlResponse(INT32 ch)
{
if (ch == 'y' || ch == KEY_ENTER)
{
G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], gcmovement, num_gcmovement);
S_StartSound(NULL, sfx_strpst);
}
else
S_StartSound(NULL, sfx_wdjump);
}
static void M_TutorialControlResponse(INT32 ch)
{
if (ch == 'y' || ch == KEY_ENTER)
{
G_CopyControls(gamecontroldefault[gcs_custom], gamecontrol, NULL, 0);
G_CopyControls(gamecontrol, gamecontroldefault[gcs_fps], gcmovement, num_gcmovement);
}
M_StartTutorial(INT32_MAX);
}
// Starts up the tutorial immediately (tbh I wasn't sure where else to put this)
static void M_StartTutorial(INT32 choice)
{
(void)choice;
if (!tutorialmap)
return; // no map to go to, don't bother
if (choice != INT32_MAX && G_GetControlScheme(gamecontrol, gcmovement, num_gcmovement) == gcs_custom)
{
M_StartMessage("Do you want to try the \202recommended \202controls\x80?\n\nWe will set them just for this tutorial.\n\n(Press 'Y' to confirm,\nor any key to keep \nyour current controls.)\n",M_TutorialControlResponse,MM_YESNO);
return;
}
else if (choice != INT32_MAX)
G_CopyControls(gamecontroldefault[gcs_custom], gamecontrol, NULL, 0);
tutorialmode = true; // turn on tutorial mode
emeralds = 0;

View file

@ -240,6 +240,8 @@ extern INT16 char_on, startchar;
#define BwehHehHe() S_StartSound(NULL, sfx_bewar1+M_RandomKey(4)) // Bweh heh he
void M_TutorialSaveControlResponse(INT32 ch);
void M_ForceSaveSlotSelected(INT32 sslot);
void M_CheatActivationResponder(INT32 ch);