- moved out the Doom specific parts from menu.cpp and messagebox.cpp.
This commit is contained in:
parent
86e5f5a4cb
commit
90befff479
16 changed files with 539 additions and 455 deletions
|
|
@ -33,18 +33,14 @@
|
|||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include "menu/menu.h"
|
||||
#include "d_main.h"
|
||||
#include "menu.h"
|
||||
#include "gstrings.h"
|
||||
#include "gi.h"
|
||||
#include "i_video.h"
|
||||
#include "st_start.h"
|
||||
#include "c_dispatch.h"
|
||||
#include "g_game.h"
|
||||
#include "vm.h"
|
||||
|
||||
EXTERN_CVAR (Bool, saveloadconfirmation) // [mxd]
|
||||
EXTERN_CVAR (Bool, quicksaverotation)
|
||||
void M_StartControlPanel(bool makeSound, bool scaleoverride = false);
|
||||
FName MessageBoxClass = NAME_MessageBoxMenu;
|
||||
|
||||
CVAR(Bool, m_quickexit, false, CVAR_ARCHIVE)
|
||||
|
||||
|
|
@ -65,7 +61,7 @@ DEFINE_ACTION_FUNCTION(DMessageBoxMenu, CallHandler)
|
|||
|
||||
DMenu *CreateMessageBoxMenu(DMenu *parent, const char *message, int messagemode, bool playsound, FName action = NAME_None, hfunc handler = nullptr)
|
||||
{
|
||||
auto c = PClass::FindClass(gameinfo.MessageBoxClass);
|
||||
auto c = PClass::FindClass(MessageBoxClass);
|
||||
if (!c->IsDescendantOf(NAME_MessageBoxMenu)) c = PClass::FindClass(NAME_MessageBoxMenu);
|
||||
auto p = c->CreateNew();
|
||||
FString namestr = message;
|
||||
|
|
@ -85,191 +81,6 @@ DMenu *CreateMessageBoxMenu(DMenu *parent, const char *message, int messagemode,
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
CCMD (menu_quit)
|
||||
{ // F10
|
||||
if (m_quickexit)
|
||||
{
|
||||
ST_Endoom();
|
||||
}
|
||||
|
||||
M_StartControlPanel (true);
|
||||
|
||||
const size_t messageindex = static_cast<size_t>(gametic) % gameinfo.quitmessages.Size();
|
||||
FString EndString;
|
||||
const char *msg = gameinfo.quitmessages[messageindex];
|
||||
if (msg[0] == '$')
|
||||
{
|
||||
if (msg[1] == '*')
|
||||
{
|
||||
EndString = GStrings(msg + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
EndString.Format("%s\n\n%s", GStrings(msg + 1), GStrings("DOSY"));
|
||||
}
|
||||
}
|
||||
else EndString = gameinfo.quitmessages[messageindex];
|
||||
|
||||
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, EndString, 0, false, NAME_None, []()
|
||||
{
|
||||
if (!netgame)
|
||||
{
|
||||
if (gameinfo.quitSound.IsNotEmpty())
|
||||
{
|
||||
S_Sound(CHAN_VOICE, CHANF_UI, gameinfo.quitSound, snd_menuvolume, ATTN_NONE);
|
||||
I_WaitVBL(105);
|
||||
}
|
||||
}
|
||||
ST_Endoom();
|
||||
});
|
||||
|
||||
|
||||
M_ActivateMenu(newmenu);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void ActivateEndGameMenu()
|
||||
{
|
||||
FString tempstring = GStrings(netgame ? "NETEND" : "ENDGAME");
|
||||
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []()
|
||||
{
|
||||
M_ClearMenus();
|
||||
if (!netgame)
|
||||
{
|
||||
if (demorecording)
|
||||
G_CheckDemoStatus();
|
||||
D_StartTitle();
|
||||
}
|
||||
});
|
||||
|
||||
M_ActivateMenu(newmenu);
|
||||
}
|
||||
|
||||
CCMD (menu_endgame)
|
||||
{ // F7
|
||||
if (!usergame)
|
||||
{
|
||||
S_Sound (CHAN_VOICE, CHANF_UI, "menu/invalid", snd_menuvolume, ATTN_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
//M_StartControlPanel (true);
|
||||
S_Sound (CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE);
|
||||
|
||||
ActivateEndGameMenu();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
CCMD (quicksave)
|
||||
{ // F6
|
||||
if (!usergame || (players[consoleplayer].health <= 0 && !multiplayer))
|
||||
{
|
||||
S_Sound (CHAN_VOICE, CHANF_UI, "menu/invalid", snd_menuvolume, ATTN_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
// If the quick save rotation is enabled, it handles the save slot.
|
||||
if (quicksaverotation)
|
||||
{
|
||||
G_DoQuickSave();
|
||||
return;
|
||||
}
|
||||
|
||||
if (savegameManager.quickSaveSlot == NULL || savegameManager.quickSaveSlot == (FSaveGameNode*)1)
|
||||
{
|
||||
S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE);
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_Savegamemenu);
|
||||
return;
|
||||
}
|
||||
|
||||
// [mxd]. Just save the game, no questions asked.
|
||||
if (!saveloadconfirmation)
|
||||
{
|
||||
G_SaveGame(savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
return;
|
||||
}
|
||||
|
||||
S_Sound(CHAN_VOICE, CHANF_UI, "menu/activate", snd_menuvolume, ATTN_NONE);
|
||||
|
||||
FString tempstring = GStrings("QSPROMPT");
|
||||
tempstring.Substitute("%s", savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
|
||||
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []()
|
||||
{
|
||||
G_SaveGame(savegameManager.quickSaveSlot->Filename.GetChars(), savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
S_Sound(CHAN_VOICE, CHANF_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE);
|
||||
M_ClearMenus();
|
||||
});
|
||||
|
||||
M_ActivateMenu(newmenu);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
CCMD (quickload)
|
||||
{ // F9
|
||||
if (netgame)
|
||||
{
|
||||
M_StartControlPanel(true);
|
||||
M_StartMessage (GStrings("QLOADNET"), 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (savegameManager.quickSaveSlot == NULL || savegameManager.quickSaveSlot == (FSaveGameNode*)1)
|
||||
{
|
||||
M_StartControlPanel(true);
|
||||
// signal that whatever gets loaded should be the new quicksave
|
||||
savegameManager.quickSaveSlot = (FSaveGameNode *)1;
|
||||
M_SetMenu(NAME_Loadgamemenu);
|
||||
return;
|
||||
}
|
||||
|
||||
// [mxd]. Just load the game, no questions asked.
|
||||
if (!saveloadconfirmation)
|
||||
{
|
||||
G_LoadGame(savegameManager.quickSaveSlot->Filename.GetChars());
|
||||
return;
|
||||
}
|
||||
FString tempstring = GStrings("QLPROMPT");
|
||||
tempstring.Substitute("%s", savegameManager.quickSaveSlot->SaveTitle.GetChars());
|
||||
|
||||
M_StartControlPanel(true);
|
||||
|
||||
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []()
|
||||
{
|
||||
G_LoadGame(savegameManager.quickSaveSlot->Filename.GetChars());
|
||||
S_Sound(CHAN_VOICE, CHANF_UI, "menu/dismiss", snd_menuvolume, ATTN_NONE);
|
||||
M_ClearMenus();
|
||||
});
|
||||
M_ActivateMenu(newmenu);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
void M_StartMessage(const char *message, int messagemode, FName action)
|
||||
{
|
||||
if (CurrentMenu == NULL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue