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 #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 SWBOOL GamePaused;
extern short QuickLoadNum;
static int rts_delay = 0; static int rts_delay = 0;
int fn_key = 0; int fn_key = 0;
@ -3433,16 +3469,25 @@ void FunctionKeys(PLAYERp pp)
} }
} }
// F6 option menu // F6 quick save
if (inputState.GetKeyStatus(KEYSC_F6)) if (inputState.GetKeyStatus(KEYSC_F6))
{ {
extern SWBOOL QuickSaveMode;
inputState.ClearKeyStatus(KEYSC_F6); inputState.ClearKeyStatus(KEYSC_F6);
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
{ {
inputState.SetKeyStatus(sc_Escape); inputState.SetKeyStatus(sc_Escape);
if (QuickLoadNum < 0)
{
KEY_PRESSED(KEYSC_ESC) = 1;
ControlPanelType = ct_savemenu; ControlPanelType = ct_savemenu;
QuickSaveMode = TRUE; }
else
{
KB_ClearKeysDown();
KB_FlushKeyboardQueue();
DoQuickSave(QuickLoadNum);
ResumeAction();
}
} }
} }
@ -3455,17 +3500,16 @@ void FunctionKeys(PLAYERp pp)
{ {
if (QuickLoadNum < 0) if (QuickLoadNum < 0)
{ {
PutStringInfoLine(pp, "Last saved game not found."); KEY_PRESSED(KEYSC_ESC) = 1;
ControlPanelType = ct_loadmenu;
} }
else else
{ {
inputState.ClearKeysDown(); DoQuickLoad();
inputState.SetKeyStatus(sc_Escape); ResumeAction();
ControlPanelType = ct_quickloadmenu;
} }
} }
} }
} }
@ -3535,7 +3579,6 @@ void FunctionKeys(PLAYERp pp)
void PauseKey(PLAYERp pp) void PauseKey(PLAYERp pp)
{ {
extern SWBOOL GamePaused,CheatInputMode; extern SWBOOL GamePaused,CheatInputMode;
extern short QuickLoadNum;
extern SWBOOL enabled; extern SWBOOL enabled;
if (inputState.GetKeyStatus(sc_Pause) && !CommEnabled && !InputMode && !UsingMenus && !CheatInputMode && !ConPanel) 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 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 struct GameInterface : ::GameInterface
{ {
int app_main() override; 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; short QuickLoadNum = -1;
char QuickLoadDescrDialog[128]; char QuickLoadDescrDialog[128];
SWBOOL QuickSaveMode = FALSE;
SWBOOL SavePrompt = FALSE; SWBOOL SavePrompt = FALSE;
extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop, LoadGameFromDemo; extern SWBOOL InMenuLevel, LoadGameOutsideMoveLoop, LoadGameFromDemo;
extern uint8_t RedBookSong[40]; extern uint8_t RedBookSong[40];
@ -570,7 +569,6 @@ MenuItem_p cust_callback_item;
static void MNU_ClearDialog(void); static void MNU_ClearDialog(void);
static SWBOOL MNU_Dialog(void); static SWBOOL MNU_Dialog(void);
void LoadSaveMsg(const char *msg);
static void MNU_ItemPreProcess(MenuGroup *group); static void MNU_ItemPreProcess(MenuGroup *group);
static void MNU_SelectItem(MenuGroup *group, short index, SWBOOL draw); static void MNU_SelectItem(MenuGroup *group, short index, SWBOOL draw);
static void MNU_PushItem(MenuItem *item, SWBOOL draw); static void MNU_PushItem(MenuItem *item, SWBOOL draw);
@ -1796,24 +1794,17 @@ MNU_QuickLoadCustom(UserCall call, MenuItem_p item)
// Y pressed // Y pressed
cust_callback = NULL; cust_callback = NULL;
inputState.ClearKeysDown();
LoadSaveMsg("Loading..."); LoadSaveMsg("Loading...");
PauseAction(); if (DoQuickLoad() == FALSE)
ReloadPrompt = FALSE;
if (LoadGame(QuickLoadNum) == -1)
{ {
ResumeAction(); ResumeAction();
return FALSE; return FALSE;
} }
ready2send = 1;
LastSaveNum = -1;
// do a load game here
inputState.ClearKeysDown();
ExitMenus(); ExitMenus();
return TRUE;
} }
inputState.ClearKeysDown(); inputState.ClearKeysDown();
@ -2429,16 +2420,11 @@ SWBOOL MNU_GetSaveCustom(void)
if (MenuInputMode) if (MenuInputMode)
{ {
PauseAction();
LoadSaveMsg("Saving..."); LoadSaveMsg("Saving...");
if (SaveGame(save_num) != -1) if (DoQuickSave(save_num) == FALSE)
{ {
QuickLoadNum = save_num;
LoadGameGroup.cursor = save_num; LoadGameGroup.cursor = save_num;
LastSaveNum = -1;
} }
ResumeAction(); ResumeAction();
@ -2523,15 +2509,6 @@ SWBOOL MNU_LoadSaveMove(UserCall call, MenuItem_p item)
SaveGameInfo2[0] = 0; SaveGameInfo2[0] = 0;
} }
if (QuickSaveMode)
{
QuickSaveMode = FALSE;
MenuInputMode = TRUE;
strcpy(BackupSaveGameDescr, SaveGameDescr[game_num]);
inputState.ClearKeysDown();
inputState.keyFlushChars();
}
LastSaveNum = game_num; LastSaveNum = game_num;
// input mode check // input mode check