Menus: Delete key in save/load game menu

git-svn-id: https://svn.eduke32.com/eduke32@6745 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2018-03-08 03:55:25 +00:00
parent 8019d8f6f0
commit 867b4db1a0
3 changed files with 62 additions and 9 deletions

View file

@ -2647,6 +2647,23 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin)
}
static void Menu_ReadSaveGameHeaders();
static void Menu_LoadReadHeaders()
{
Menu_ReadSaveGameHeaders();
for (size_t i = 0; i < g_nummenusaves; ++i)
MenuEntry_DisableOnCondition(&ME_LOAD[i], g_menusaves[i].isOldVer);
}
static void Menu_SaveReadHeaders()
{
Menu_ReadSaveGameHeaders();
for (size_t i = 0; i < g_nummenusaves; ++i)
MenuEntry_LookDisabledOnCondition(&ME_SAVE[i], g_menusaves[i].isOldVer);
}
static void Menu_PreInput(MenuEntry_t *entry)
{
@ -2667,6 +2684,31 @@ static void Menu_PreInput(MenuEntry_t *entry)
}
break;
case MENU_LOAD:
if (KB_KeyPressed(sc_Delete))
{
KB_ClearKeyDown(sc_Delete);
if ((unsigned)M_LOAD.currentEntry < g_nummenusaves)
{
G_DeleteSave(g_menusaves[M_LOAD.currentEntry].brief);
Menu_LoadReadHeaders();
M_LOAD.currentEntry = clamp(M_LOAD.currentEntry, 0, (int32_t)g_nummenusaves-1);
}
}
break;
case MENU_SAVE:
if (KB_KeyPressed(sc_Delete))
{
KB_ClearKeyDown(sc_Delete);
if (0 < M_SAVE.currentEntry && M_SAVE.currentEntry <= (int32_t)g_nummenusaves)
{
G_DeleteSave(g_menusaves[M_SAVE.currentEntry-1].brief);
Menu_SaveReadHeaders();
M_SAVE.currentEntry = clamp(M_SAVE.currentEntry, 0, (int32_t)g_nummenusaves);
}
}
break;
default:
break;
}
@ -3856,10 +3898,7 @@ static void Menu_AboutToStartDisplaying(Menu_t * m)
if (KXDWN)
M_LOAD.title = (g_player[myconnectindex].ps->gm & MODE_GAME) ? s_LoadGame : s_Continue;
Menu_ReadSaveGameHeaders();
for (size_t i = 0; i < g_nummenusaves; ++i)
MenuEntry_DisableOnCondition(&ME_LOAD[i], g_menusaves[i].isOldVer);
Menu_LoadReadHeaders();
if (g_quickload && g_quickload->isValid())
{
@ -3879,7 +3918,7 @@ static void Menu_AboutToStartDisplaying(Menu_t * m)
if (g_previousMenu == MENU_SAVEVERIFY)
break;
Menu_ReadSaveGameHeaders();
Menu_SaveReadHeaders();
if (g_lastusersave.isValid())
{
@ -3894,9 +3933,6 @@ static void Menu_AboutToStartDisplaying(Menu_t * m)
}
}
for (size_t i = 0; i < g_nummenusaves; ++i)
MenuEntry_LookDisabledOnCondition(&ME_SAVE[i], g_menusaves[i].isOldVer);
if (g_player[myconnectindex].ps->gm&MODE_GAME)
{
g_screenCapture = 1;
@ -6540,7 +6576,7 @@ static void Menu_RunInput(Menu_t *cm)
currentry = Menu_RunInput_Menu_Movement(menu, MM_Down);
}
if (currentry != NULL && !(currentry->flags & MEF_Disabled))
if (currentry != NULL)
Menu_PreInput(currentry);
}
else if (state == 1)

View file

@ -434,6 +434,22 @@ static void G_SavePalette(void)
}
#endif
void G_DeleteSave(savebrief_t const & sv)
{
if (!sv.isValid())
return;
char temp[BMAX_PATH];
if (G_ModDirSnprintf(temp, sizeof(temp), "%s", sv.path))
{
OSD_Printf("G_SavePlayer: file name \"%s\" too long\n", sv.path);
return;
}
unlink(temp);
}
int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
{
#ifdef __ANDROID__

View file

@ -115,6 +115,7 @@ int32_t sv_loadheader(int32_t fil, int32_t spot, savehead_t *h);
int32_t sv_loadsnapshot(int32_t fil, int32_t spot, savehead_t *h);
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
void sv_freemem();
void G_DeleteSave(savebrief_t const & sv);
int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave);
int32_t G_LoadPlayer(savebrief_t & sv);
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh);