Add quickload/save osdcmd

This commit is contained in:
nukeykt 2019-09-24 11:14:59 +09:00 committed by Christoph Oelckers
parent d12563f644
commit b1713d7e67
3 changed files with 103 additions and 43 deletions

View file

@ -744,6 +744,40 @@ void StartNetworkLevel(void)
StartLevel(&gGameOptions); StartLevel(&gGameOptions);
} }
int gDoQuickSave = 0;
static void DoQuickLoad(void)
{
if (!gGameMenuMgr.m_bActive)
{
if (gQuickLoadSlot != -1)
{
QuickLoadGame();
return;
}
if (gQuickLoadSlot == -1 && gQuickSaveSlot != -1)
{
gQuickLoadSlot = gQuickSaveSlot;
QuickLoadGame();
return;
}
gGameMenuMgr.Push(&menuLoadGame,-1);
}
}
static void DoQuickSave(void)
{
if (gGameStarted && !gGameMenuMgr.m_bActive && gPlayer[myconnectindex].pXSprite->health != 0)
{
if (gQuickSaveSlot != -1)
{
QuickSaveGame();
return;
}
gGameMenuMgr.Push(&menuSaveGame,-1);
}
}
void LocalKeys(void) void LocalKeys(void)
{ {
char alt = keystatus[sc_LeftAlt] | keystatus[sc_RightAlt]; char alt = keystatus[sc_LeftAlt] | keystatus[sc_RightAlt];
@ -781,12 +815,27 @@ void LocalKeys(void)
gView = &gPlayer[gViewIndex]; gView = &gPlayer[gViewIndex];
} }
} }
if (gDoQuickSave)
{
keyFlushScans();
switch (gDoQuickSave)
{
case 1:
DoQuickSave();
break;
case 2:
DoQuickLoad();
break;
}
gDoQuickSave = 0;
return;
}
char key; char key;
if ((key = keyGetScan()) != 0) if ((key = keyGetScan()) != 0)
{ {
if ((alt || shift) && gGameOptions.nGameType > 0 && key >= 0x3b && key <= 0x44) if ((alt || shift) && gGameOptions.nGameType > 0 && key >= sc_F1 && key <= sc_F10)
{ {
char fk = key - 0x3b; char fk = key - sc_F1;
if (alt) if (alt)
{ {
netBroadcastTaunt(myconnectindex, fk); netBroadcastTaunt(myconnectindex, fk);
@ -798,20 +847,20 @@ void LocalKeys(void)
} }
keyFlushScans(); keyFlushScans();
keystatus[key] = 0; keystatus[key] = 0;
CONTROL_ClearButton(41); CONTROL_ClearButton(gamefunc_See_Chase_View);
return; return;
} }
switch (key) switch (key)
{ {
case 0x53: case sc_kpad_Period:
case 0xd3: case sc_Delete:
if (ctrl && alt) if (ctrl && alt)
{ {
gQuitGame = 1; gQuitGame = 1;
return; return;
} }
break; break;
case 0x01: case sc_Escape:
keyFlushScans(); keyFlushScans();
if (gGameStarted && gPlayer[myconnectindex].pXSprite->health != 0) if (gGameStarted && gPlayer[myconnectindex].pXSprite->health != 0)
{ {
@ -824,73 +873,51 @@ void LocalKeys(void)
gGameMenuMgr.Push(&menuMain,-1); gGameMenuMgr.Push(&menuMain,-1);
} }
return; return;
case 0x3b: case sc_F1:
keyFlushScans(); keyFlushScans();
if (gGameOptions.nGameType == 0) if (gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuOrder,-1); gGameMenuMgr.Push(&menuOrder,-1);
break; break;
case 0x3c: case sc_F2:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuSaveGame,-1); gGameMenuMgr.Push(&menuSaveGame,-1);
break; break;
case 0x3d: case sc_F3:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0) if (!gGameMenuMgr.m_bActive && gGameOptions.nGameType == 0)
gGameMenuMgr.Push(&menuLoadGame,-1); gGameMenuMgr.Push(&menuLoadGame,-1);
break; break;
case 0x3e: case sc_F4:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuOptionsSound,-1); gGameMenuMgr.Push(&menuOptionsSound,-1);
return; return;
case 0x3f: case sc_F5:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuOptions,-1); gGameMenuMgr.Push(&menuOptions,-1);
return; return;
case 0x40: case sc_F6:
keyFlushScans(); keyFlushScans();
if (gGameStarted && !gGameMenuMgr.m_bActive && gPlayer[myconnectindex].pXSprite->health != 0) DoQuickSave();
{
if (gQuickSaveSlot != -1)
{
QuickSaveGame();
return;
}
gGameMenuMgr.Push(&menuSaveGame,-1);
}
break; break;
case 0x42: case sc_F8:
keyFlushScans(); keyFlushScans();
gGameMenuMgr.Push(&menuOptions,-1); gGameMenuMgr.Push(&menuOptions,-1);
break; break;
case 0x43: case sc_F9:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive) DoQuickLoad();
{
if (gQuickLoadSlot != -1)
{
QuickLoadGame();
return;
}
if (gQuickLoadSlot == -1 && gQuickSaveSlot != -1)
{
gQuickLoadSlot = gQuickSaveSlot;
QuickLoadGame();
return;
}
gGameMenuMgr.Push(&menuLoadGame,-1);
}
break; break;
case 0x44: case sc_F10:
keyFlushScans(); keyFlushScans();
if (!gGameMenuMgr.m_bActive) if (!gGameMenuMgr.m_bActive)
gGameMenuMgr.Push(&menuQuit,-1); gGameMenuMgr.Push(&menuQuit,-1);
break; break;
case 0x57: case sc_F11:
break; break;
case 0x58: case sc_F12:
videoCaptureScreen("blud0000.tga", 0); videoCaptureScreen("blud0000.tga", 0);
break; break;
} }

View file

@ -71,6 +71,7 @@ extern bool gSavingGame;
extern bool gQuitGame; extern bool gQuitGame;
extern int gQuitRequest; extern int gQuitRequest;
extern int gCacheMiss; extern int gCacheMiss;
extern int gDoQuickSave;
void QuitGame(void); void QuitGame(void);
void PreloadCache(void); void PreloadCache(void);

View file

@ -690,6 +690,37 @@ static int osdcmd_unbind(osdcmdptr_t parm)
return OSDCMD_SHOWHELP; return OSDCMD_SHOWHELP;
} }
static int osdcmd_unbound(osdcmdptr_t parm)
{
if (parm->numparms != 1)
return OSDCMD_OK;
int const gameFunc = CONFIG_FunctionNameToNum(parm->parms[0]);
if (gameFunc != -1)
KeyboardKeys[gameFunc][0] = 0;
return OSDCMD_OK;
}
static int osdcmd_quicksave(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
if (!gGameStarted || gDemo.at1 || gGameMenuMgr.m_bActive)
OSD_Printf("quicksave: not in a game.\n");
else gDoQuickSave = 1;
return OSDCMD_OK;
}
static int osdcmd_quickload(osdcmdptr_t UNUSED(parm))
{
UNREFERENCED_CONST_PARAMETER(parm);
if (!gGameStarted || gDemo.at1 || gGameMenuMgr.m_bActive)
OSD_Printf("quickload: not in a game.\n");
else gDoQuickSave = 2;
return OSDCMD_OK;
}
static int osdcmd_screenshot(osdcmdptr_t parm) static int osdcmd_screenshot(osdcmdptr_t parm)
{ {
static const char *fn = "blud0000.png"; static const char *fn = "blud0000.png";
@ -1109,8 +1140,8 @@ int32_t registerosdcommands(void)
// //
// OSD_RegisterFunction("purgesaves", "purgesaves: deletes obsolete and unreadable save files", osdcmd_purgesaves); // OSD_RegisterFunction("purgesaves", "purgesaves: deletes obsolete and unreadable save files", osdcmd_purgesaves);
// //
// OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave); OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave);
// OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload); OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload);
OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit); OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit); OSD_RegisterFunction("exit","exit: exits the game immediately", osdcmd_quit);
// //
@ -1131,6 +1162,7 @@ int32_t registerosdcommands(void)
OSD_RegisterFunction("unbind","unbind <key>: unbinds a key", osdcmd_unbind); OSD_RegisterFunction("unbind","unbind <key>: unbinds a key", osdcmd_unbind);
OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall); OSD_RegisterFunction("unbindall","unbindall: unbinds all keys", osdcmd_unbindall);
OSD_RegisterFunction("unbound", NULL, osdcmd_unbound);
OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode); OSD_RegisterFunction("vidmode","vidmode <xdim> <ydim> <bpp> <fullscreen>: change the video mode",osdcmd_vidmode);
#ifdef USE_OPENGL #ifdef USE_OPENGL