Skip to content

Commit

Permalink
Added: Console command "deletegamesave"
Browse files Browse the repository at this point in the history
Delete a save slot by name or slot identifiers, with confirmation
dialog (unless affirmed with the "confirm" argument).
  • Loading branch information
danij-deng committed Jul 15, 2012
1 parent e0773c3 commit 0cc2b8d
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doomsday/plugins/common/include/hu_menu.h
Expand Up @@ -46,6 +46,7 @@
#define SFX_MENU_SLIDER_MOVE (SFX_STNMOV)
#define SFX_QUICKSAVE_PROMPT (SFX_SWTCHN)
#define SFX_QUICKLOAD_PROMPT (SFX_SWTCHN)
#define SFX_DELETESAVEGAME_CONFIRM (SFX_SWTCHN)
#elif __JHERETIC__
#define SFX_MENU_CLOSE (SFX_DORCLS)
#define SFX_MENU_OPEN (SFX_SWITCH)
Expand All @@ -58,6 +59,7 @@
#define SFX_MENU_SLIDER_MOVE (SFX_STNMOV)
#define SFX_QUICKSAVE_PROMPT (SFX_CHAT)
#define SFX_QUICKLOAD_PROMPT (SFX_CHAT)
#define SFX_DELETESAVEGAME_CONFIRM (SFX_CHAT)
#elif __JHEXEN__
#define SFX_MENU_CLOSE (SFX_DOOR_LIGHT_CLOSE)
#define SFX_MENU_OPEN (SFX_DOOR_LIGHT_CLOSE)
Expand All @@ -70,6 +72,7 @@
#define SFX_MENU_SLIDER_MOVE (SFX_PICKUP_KEY)
#define SFX_QUICKSAVE_PROMPT (SFX_CHAT)
#define SFX_QUICKLOAD_PROMPT (SFX_CHAT)
#define SFX_DELETESAVEGAME_CONFIRM (SFX_CHAT)
#endif

#define MENU_CURSOR_REWIND_SPEED 20
Expand Down
67 changes: 67 additions & 0 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -133,6 +133,7 @@ MonsterMissileInfo[] =
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------

D_CMD(CycleTextureGamma);
D_CMD(DeleteGameSave);
D_CMD(EndGame);
D_CMD(HelpScreen);
D_CMD(ListMaps);
Expand Down Expand Up @@ -429,6 +430,8 @@ cvartemplate_t gamestatusCVars[] = {
};

ccmdtemplate_t gameCmds[] = {
{ "deletegamesave", "ss", CCmdDeleteGameSave },
{ "deletegamesave", "s", CCmdDeleteGameSave },
{ "endgame", "", CCmdEndGame },
{ "helpscreen", "", CCmdHelpScreen },
{ "listmaps", "", CCmdListMaps },
Expand Down Expand Up @@ -3882,6 +3885,70 @@ D_CMD(QuickSaveGame)
return DD_Execute(true, "savegame quick");
}

boolean G_DeleteSaveGame(int slot)
{
SaveInfo* info;

if(!SV_IsUserWritableSlot(slot) || !SV_IsSlotUsed(slot)) return false;

// A known slot identifier.
info = SV_SaveInfoForSlot(slot);
DENG_ASSERT(info);
SV_ClearSlot(slot);
return true;
}

int deleteSaveGameConfirmResponse(msgresponse_t response, int userValue, void* userPointer)
{
DENG_UNUSED(userPointer);
if(response == MSG_YES)
{
const int slot = userValue;
G_DeleteSaveGame(slot);
}
return true;
}

D_CMD(DeleteGameSave)
{
const boolean confirm = (argc >= 3 && !stricmp(argv[argc-1], "confirm"));
player_t* player = &players[CONSOLEPLAYER];
int slot;

if(G_QuitInProgress()) return false;

// Ensure we have up-to-date info.
SV_UpdateAllSaveInfo();

slot = SV_ParseSlotIdentifier(argv[1]);
if(SV_IsUserWritableSlot(slot) && SV_IsSlotUsed(slot))
{
// A known slot identifier.
if(confirm)
{
return G_DeleteSaveGame(slot);
}
else
{
// Compose the confirmation message.
SaveInfo* info = SV_SaveInfoForSlot(slot);
AutoStr* msg = Str_Appendf(AutoStr_NewStd(), DELETESAVEGAME_CONFIRM, Str_Text(SaveInfo_Name(info)));
S_LocalSound(SFX_DELETESAVEGAME_CONFIRM, NULL);
Hu_MsgStart(MSG_YESNO, Str_Text(msg), deleteSaveGameConfirmResponse, slot, 0);
}
return true;
}

// Clearly the caller needs some assistance...
if(!SV_IsValidSlot(slot))
Con_Message("Failed to determine game-save slot from \"%s\".\n", argv[1]);
else
Con_Message("Game-save slot #%i is non-user-writable.\n", slot);

// No action means the command failed.
return false;
}

D_CMD(HelpScreen)
{
G_StartHelp();
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jdoom/data/conhelp.txt
Expand Up @@ -24,6 +24,10 @@ inf = Params: cheat (cheat)\nFor example, 'cheat idclev25'.
[coord]
desc = Print the coordinates of the consoleplayer.

[deletegamesave]
desc = Deletes a game-save state.
inf = Params: deletegamesave (game-save-name|<keyword>|save-slot-num) (confirm)\nKeywords: last, quick\nExamples:\nA game save by name 'deletegamesave "running low on ammo"'\nLast game save in the "quick" slot, confirmed: 'deletegamesave quick confirm'

[endcycle]
desc = End map rotation.

Expand Down
5 changes: 5 additions & 0 deletions doomsday/plugins/jdoom/defs/text.ded
Expand Up @@ -2022,3 +2022,8 @@ Text {
ID = "DISCONNECT";
Text = "Really disconnect?";
}

Text {
ID = "DELETESAVEGAME_CONFIRM";
Text = "Really delete save game \n\n'%s'?";
}
2 changes: 2 additions & 0 deletions doomsday/plugins/jdoom/include/d_englsh.h
Expand Up @@ -394,4 +394,6 @@
#define CC_CYBER GET_TXT(TXT_CC_CYBER)
#define CC_HERO GET_TXT(TXT_CC_HERO)

#define DELETESAVEGAME_CONFIRM GET_TXT(TXT_DELETESAVEGAME_CONFIRM)

#endif
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom/include/info.h
Expand Up @@ -1681,6 +1681,7 @@ typedef enum {
TXT_GAMESETUP,
TXT_PLAYERSETUP,
TXT_DISCONNECT,
TXT_DELETESAVEGAME_CONFIRM,
NUMTEXT
} textenum_t;

Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jdoom64/data/conhelp.txt
Expand Up @@ -2,6 +2,10 @@
# CONSOLE COMMANDS - JDOOM64 SPECFIC
#

[deletegamesave]
desc = Deletes a game-save state.
inf = Params: deletegamesave (game-save-name|<keyword>|save-slot-num) (confirm)\nKeywords: last, quick\nExamples:\nA game save by name 'deletegamesave "running low on ammo"'\nLast game save in the "quick" slot, confirmed: 'deletegamesave quick confirm'

[setcolor]
desc = Set player color.
inf = Params: setcolor (playernum)\nFor example, 'setcolor 4'.
Expand Down
5 changes: 5 additions & 0 deletions doomsday/plugins/jdoom64/defs/text.ded
Expand Up @@ -1265,3 +1265,8 @@ Text {
ID = "DISCONNECT";
Text = "Really disconnect?";
}

Text {
ID = "DELETESAVEGAME_CONFIRM";
Text = "Really delete save game \n\n'%s'?";
}
2 changes: 2 additions & 0 deletions doomsday/plugins/jdoom64/include/d_englsh.h
Expand Up @@ -226,4 +226,6 @@
#define CC_BITCH GET_TXT(TXT_CC_BITCH) // jd64
#define CC_HERO GET_TXT(TXT_CC_HERO)

#define DELETESAVEGAME_CONFIRM GET_TXT(TXT_DELETESAVEGAME_CONFIRM)

#endif
1 change: 1 addition & 0 deletions doomsday/plugins/jdoom64/include/info.h
Expand Up @@ -1600,6 +1600,7 @@ typedef enum {
TXT_GAMESETUP,
TXT_PLAYERSETUP,
TXT_DISCONNECT,
TXT_DELETESAVEGAME_CONFIRM,
NUMTEXT
} textenum_t;

Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jheretic/data/conhelp.txt
Expand Up @@ -2,6 +2,10 @@
# CONSOLE COMMANDS - JHERETIC SPECFIC
#

[deletegamesave]
desc = Deletes a game-save state.
inf = Params: deletegamesave (game-save-name|<keyword>|save-slot-num) (confirm)\nKeywords: last, quick\nExamples:\nA game save by name 'deletegamesave "running low on ammo"'\nLast game save in the "quick" slot, confirmed: 'deletegamesave quick confirm'

[setcolor]
desc = Set player color.
inf = Params: setcolor (playernum)\nFor example, 'setcolor 4'.
Expand Down
5 changes: 5 additions & 0 deletions doomsday/plugins/jheretic/defs/text.ded
Expand Up @@ -1148,3 +1148,8 @@ Text {
ID = "HUSTR_E6M3";
Text = "E6M3: American's Legacy";
}

Text {
ID = "DELETESAVEGAME_CONFIRM";
Text = "Really delete save game \n\n'%s'?";
}
2 changes: 2 additions & 0 deletions doomsday/plugins/jheretic/include/dstrings.h
Expand Up @@ -219,4 +219,6 @@
#define E4TEXT GET_TXT(TXT_E4TEXT)
#define E5TEXT GET_TXT(TXT_E5TEXT)

#define DELETESAVEGAME_CONFIRM GET_TXT(TXT_DELETESAVEGAME_CONFIRM)

#endif
1 change: 1 addition & 0 deletions doomsday/plugins/jheretic/include/info.h
Expand Up @@ -1759,6 +1759,7 @@ typedef enum {
TXT_HUSTR_E6M1,
TXT_HUSTR_E6M2,
TXT_HUSTR_E6M3,
TXT_DELETESAVEGAME_CONFIRM,
NUMTEXT
} textenum_t;

Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/jhexen/data/conhelp.txt
Expand Up @@ -2,6 +2,10 @@
# CONSOLE COMMANDS - JHEXEN SPECFIC
#

[deletegamesave]
desc = Deletes a game-save state.
inf = Params: deletegamesave (game-save-name|<keyword>|save-slot-num) (confirm)\nKeywords: last, quick\nExamples:\nA game save by name 'deletegamesave "running low on ammo"'\nLast game save in the "quick" slot, confirmed: 'deletegamesave quick confirm'

[setcolor]
desc = Set player color.
inf = Params: setcolor (playernum)\nFor example, 'setcolor 4'.
Expand Down
5 changes: 5 additions & 0 deletions doomsday/plugins/jhexen/defs/text.ded
Expand Up @@ -801,3 +801,8 @@ Text {
ID = "SKILLM5";
Text = "Archimage";
}

Text {
ID = "DELETESAVEGAME_CONFIRM";
Text = "Really delete save game \n\n'%s'?";
}
1 change: 1 addition & 0 deletions doomsday/plugins/jhexen/include/info.h
Expand Up @@ -3757,6 +3757,7 @@ typedef enum {
TXT_SKILLM3,
TXT_SKILLM4,
TXT_SKILLM5,
TXT_DELETESAVEGAME_CONFIRM,
NUMTEXT
} textenum_t;

Expand Down
2 changes: 2 additions & 0 deletions doomsday/plugins/jhexen/include/textdefs.h
Expand Up @@ -187,4 +187,6 @@
#define AMSTR_MARKEDSPOT GET_TXT(TXT_AMSTR_MARKEDSPOT)
#define AMSTR_MARKSCLEARED GET_TXT(TXT_AMSTR_MARKSCLEARED)

#define DELETESAVEGAME_CONFIRM GET_TXT(TXT_DELETESAVEGAME_CONFIRM)

#endif

0 comments on commit 0cc2b8d

Please sign in to comment.