SW: Make quick save and load actually quick

git-svn-id: https://svn.eduke32.com/eduke32@8337 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/sw/src/game.cpp
#	source/sw/src/game.h
#	source/sw/src/menus.cpp
This commit is contained in:
hendricks266 2019-11-30 06:10:26 +00:00 committed by Christoph Oelckers
parent 8b78440f76
commit 69c01587c7
3 changed files with 65 additions and 39 deletions

View file

@ -3336,10 +3336,46 @@ void ConKey(void)
#endif
}
void FunctionKeys(PLAYERp pp)
char WangBangMacro[10][64];
SWBOOL DoQuickSave(short save_num)
{
PauseAction();
if (SaveGame(save_num) != -1)
{
QuickLoadNum = save_num;
LastSaveNum = -1;
return FALSE;
}
return TRUE;
}
SWBOOL DoQuickLoad()
{
KB_ClearKeysDown();
PauseAction();
ReloadPrompt = FALSE;
if (LoadGame(QuickLoadNum) == -1)
{
return FALSE;
}
ready2send = 1;
LastSaveNum = -1;
return TRUE;
}
void
FunctionKeys(PLAYERp pp)
{
extern SWBOOL GamePaused;
extern short QuickLoadNum;
static int rts_delay = 0;
int fn_key = 0;
@ -3433,16 +3469,25 @@ void FunctionKeys(PLAYERp pp)
}
}
// F6 option menu
// F6 quick save
if (inputState.GetKeyStatus(KEYSC_F6))
{
extern SWBOOL QuickSaveMode;
inputState.ClearKeyStatus(KEYSC_F6);
if (!TEST(pp->Flags, PF_DEAD))
{
inputState.SetKeyStatus(sc_Escape);
if (QuickLoadNum < 0)
{
KEY_PRESSED(KEYSC_ESC) = 1;
ControlPanelType = ct_savemenu;
QuickSaveMode = TRUE;
}
else
{
KB_ClearKeysDown();
KB_FlushKeyboardQueue();
DoQuickSave(QuickLoadNum);
ResumeAction();
}
}
}
@ -3455,17 +3500,16 @@ void FunctionKeys(PLAYERp pp)
{
if (QuickLoadNum < 0)
{
PutStringInfoLine(pp, "Last saved game not found.");
KEY_PRESSED(KEYSC_ESC) = 1;
ControlPanelType = ct_loadmenu;
}
else
{
inputState.ClearKeysDown();
inputState.SetKeyStatus(sc_Escape);
ControlPanelType = ct_quickloadmenu;
DoQuickLoad();
ResumeAction();
}
}
}
}
@ -3535,7 +3579,6 @@ void FunctionKeys(PLAYERp pp)
void PauseKey(PLAYERp pp)
{
extern SWBOOL GamePaused,CheatInputMode;
extern short QuickLoadNum;
extern SWBOOL enabled;
if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel)

View file

@ -2372,6 +2372,12 @@ int COVERinsertsprite(short sectnum, short statnum); //returns (short)spritenu
void AudioUpdate(void); // stupid
extern short LastSaveNum;
extern short QuickLoadNum;
void LoadSaveMsg(const char *msg);
SWBOOL DoQuickSave(short save_num);
SWBOOL DoQuickLoad(void);
struct GameInterface : ::GameInterface
{
int app_main() override;

View file

@ -68,7 +68,6 @@ short TimeLimitTable[9] = {0,3,5,10,15,20,30,45,60};
short QuickLoadNum = -1;
char QuickLoadDescrDialog[128];
SWBOOL QuickSaveMode = FALSE;
SWBOOL SavePrompt = FALSE;
extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop, LoadGameFromDemo;
extern uint8_t RedBookSong[40];
@ -570,7 +569,6 @@ MenuItem_p cust_callback_item;
static void MNU_ClearDialog(void);
static SWBOOL MNU_Dialog(void);
void LoadSaveMsg(const char *msg);
static void MNU_ItemPreProcess(MenuGroup *group);
static void MNU_SelectItem(MenuGroup *group, short index, SWBOOL draw);
static void MNU_PushItem(MenuItem *item, SWBOOL draw);
@ -1796,24 +1794,17 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
// Y pressed
cust_callback = NULL;
inputState.ClearKeysDown();
LoadSaveMsg("Loading...");
PauseAction();
ReloadPrompt = FALSE;
if (LoadGame(QuickLoadNum) == -1)
if (DoQuickLoad() == FALSE)
{
ResumeAction();
return FALSE;
}
ready2send = 1;
LastSaveNum = -1;
// do a load game here
inputState.ClearKeysDown();
ExitMenus();
return TRUE;
}
inputState.ClearKeysDown();
@ -2429,16 +2420,11 @@ SWBOOL MNU_GetSaveCustom(void)
if (MenuInputMode)
{
PauseAction();
LoadSaveMsg("Saving...");
if (SaveGame(save_num) != -1)
if (DoQuickSave(save_num) == FALSE)
{
QuickLoadNum = save_num;
LoadGameGroup.cursor = save_num;
LastSaveNum = -1;
}
ResumeAction();
@ -2523,15 +2509,6 @@ SWBOOL MNU_LoadSaveMove(UserCall call, MenuItem_p item)
SaveGameInfo2[0] = 0;
}
if (QuickSaveMode)
{
QuickSaveMode = FALSE;
MenuInputMode = TRUE;
strcpy(BackupSaveGameDescr, SaveGameDescr[game_num]);
inputState.ClearKeysDown();
inputState.keyFlushChars();
}
LastSaveNum = game_num;
// input mode check