mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-31 12:30:40 +00:00
- made the confirmation screen functional.
This works but still needs a bit of visual work.
This commit is contained in:
parent
db425a1228
commit
7a9138cde0
11 changed files with 113 additions and 102 deletions
|
@ -98,6 +98,7 @@ struct GameInterface : ::GameInterface
|
||||||
bool SaveGame(FSaveGameNode*) override;
|
bool SaveGame(FSaveGameNode*) override;
|
||||||
bool LoadGame(FSaveGameNode*) override;
|
bool LoadGame(FSaveGameNode*) override;
|
||||||
void DoPrintMessage(int prio, const char*) override;
|
void DoPrintMessage(int prio, const char*) override;
|
||||||
|
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -280,6 +280,16 @@ void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
||||||
viewDrawText(1, text, 160, 20 - height / 2, -128, 0, 1, false);
|
viewDrawText(1, text, 160, 20 - height / 2, -128, 0, 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg)
|
||||||
|
{
|
||||||
|
if (text)
|
||||||
|
{
|
||||||
|
int width;
|
||||||
|
viewGetFontInfo(0, text, &width, NULL);
|
||||||
|
int x = 160 - width / 2;
|
||||||
|
viewDrawText(0, text, x, 100, 0, 0, 0, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@ struct GameInterface
|
||||||
virtual void StartGame(FGameStartup& gs) {}
|
virtual void StartGame(FGameStartup& gs) {}
|
||||||
virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; }
|
virtual FSavegameInfo GetSaveSig() { return { "", 0, 0}; }
|
||||||
virtual bool DrawSpecialScreen(const DVector2 &origin, int tilenum) { return false; }
|
virtual bool DrawSpecialScreen(const DVector2 &origin, int tilenum) { return false; }
|
||||||
virtual void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) {}
|
virtual void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool withbg = true) {}
|
||||||
virtual void DrawMenuCaption(const DVector2& origin, const char* text) {}
|
virtual void DrawMenuCaption(const DVector2& origin, const char* text) {}
|
||||||
virtual bool SaveGame(FSaveGameNode*) { return false; }
|
virtual bool SaveGame(FSaveGameNode*) { return false; }
|
||||||
virtual bool LoadGame(FSaveGameNode*) { return false; }
|
virtual bool LoadGame(FSaveGameNode*) { return false; }
|
||||||
|
|
|
@ -480,23 +480,23 @@ bool M_SetMenu(FName menu, int param, FName caller)
|
||||||
M_StartMessage (msg, 0, -1, NAME_StartgameConfirmed);
|
M_StartMessage (msg, 0, -1, NAME_StartgameConfirmed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
case NAME_Savegamemenu:
|
case NAME_SaveGameMenu:
|
||||||
if (gi->canSave())
|
if (!gi->CanSave())
|
||||||
{
|
{
|
||||||
// cannot save outside the game.
|
// cannot save outside the game.
|
||||||
M_StartMessage (GStrings("SAVEDEAD"), 1, -1);
|
M_StartMessage (GStrings("SAVEDEAD"), 1, -1);
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
case NAME_QuitMenu:
|
case NAME_QuitMenu:
|
||||||
// The separate menu class no longer exists but the name still needs support for existing mods.
|
// This is no separate class
|
||||||
C_DoCommand("menu_quit");
|
C_DoCommand("menu_quit");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case NAME_EndgameMenu:
|
case NAME_EndgameMenu:
|
||||||
// The separate menu class no longer exists but the name still needs support for existing mods.
|
// This is no separate class
|
||||||
C_DoCommand("memnu_endgame");
|
C_DoCommand("memnu_endgame");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ extern FSaveGameNode *quickSaveSlot;
|
||||||
class DMessageBoxMenu : public DMenu
|
class DMessageBoxMenu : public DMenu
|
||||||
{
|
{
|
||||||
using Super = DMenu;
|
using Super = DMenu;
|
||||||
|
FString mFullMessage;
|
||||||
TArray<FBrokenLines> mMessage;
|
TArray<FBrokenLines> mMessage;
|
||||||
int mMessageMode;
|
int mMessageMode;
|
||||||
int messageSelection;
|
int messageSelection;
|
||||||
|
@ -99,6 +100,7 @@ void DMessageBoxMenu::Init(DMenu *parent, const char *message, int messagemode,
|
||||||
mParentMenu = parent;
|
mParentMenu = parent;
|
||||||
if (message != NULL)
|
if (message != NULL)
|
||||||
{
|
{
|
||||||
|
mFullMessage = message;
|
||||||
mMessage = V_BreakLines(SmallFont, 300, GStrings.localize(message));
|
mMessage = V_BreakLines(SmallFont, 300, GStrings.localize(message));
|
||||||
}
|
}
|
||||||
mMessageMode = messagemode;
|
mMessageMode = messagemode;
|
||||||
|
@ -168,6 +170,7 @@ void DMessageBoxMenu::HandleResult(bool res)
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
CVAR(Bool, m_generic_messagebox, false, CVAR_ARCHIVE)
|
||||||
|
|
||||||
void DMessageBoxMenu::Drawer()
|
void DMessageBoxMenu::Drawer()
|
||||||
{
|
{
|
||||||
|
@ -180,6 +183,8 @@ void DMessageBoxMenu::Drawer ()
|
||||||
|
|
||||||
y = 100;
|
y = 100;
|
||||||
|
|
||||||
|
if (m_generic_messagebox)
|
||||||
|
{
|
||||||
if (mMessage.Size())
|
if (mMessage.Size())
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < mMessage.Size(); i++)
|
for (unsigned i = 0; i < mMessage.Size(); i++)
|
||||||
|
@ -197,10 +202,10 @@ void DMessageBoxMenu::Drawer ()
|
||||||
{
|
{
|
||||||
y += fontheight;
|
y += fontheight;
|
||||||
mMouseY = y;
|
mMouseY = y;
|
||||||
DrawText(&twod, SmallFont,
|
DrawText(&twod, NewSmallFont,
|
||||||
messageSelection == 0 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor,
|
messageSelection == 0 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor,
|
||||||
160, y, GStrings["TXT_YES"], DTA_Clean, true, TAG_DONE);
|
160, y, GStrings["TXT_YES"], DTA_Clean, true, TAG_DONE);
|
||||||
DrawText(&twod, SmallFont,
|
DrawText(&twod, NewSmallFont,
|
||||||
messageSelection == 1 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor,
|
messageSelection == 1 ? OptionSettings.mFontColorSelection : OptionSettings.mFontColor,
|
||||||
160, y + fontheight + 1, GStrings["TXT_NO"], DTA_Clean, true, TAG_DONE);
|
160, y + fontheight + 1, GStrings["TXT_NO"], DTA_Clean, true, TAG_DONE);
|
||||||
|
|
||||||
|
@ -208,7 +213,7 @@ void DMessageBoxMenu::Drawer ()
|
||||||
{
|
{
|
||||||
if (((DMenu::MenuTime >> 2) % 8) < 6)
|
if (((DMenu::MenuTime >> 2) % 8) < 6)
|
||||||
{
|
{
|
||||||
DrawText(&twod, ConFont, OptionSettings.mFontColorSelection,
|
DrawText(&twod, NewSmallFont, OptionSettings.mFontColorSelection,
|
||||||
(150 - 160) * CleanXfac + screen->GetWidth() / 2,
|
(150 - 160) * CleanXfac + screen->GetWidth() / 2,
|
||||||
(y + (fontheight + 1) * messageSelection - 100 + fontheight / 2 - 5) * CleanYfac + screen->GetHeight() / 2,
|
(y + (fontheight + 1) * messageSelection - 100 + fontheight / 2 - 5) * CleanYfac + screen->GetHeight() / 2,
|
||||||
"\xd",
|
"\xd",
|
||||||
|
@ -219,6 +224,12 @@ void DMessageBoxMenu::Drawer ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
twod.AddColorOnlyQuad(0, 0, xdim, ydim, 0xa0000000);
|
||||||
|
gi->DrawCenteredTextScreen(origin, mFullMessage, 100, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
|
@ -269,7 +280,7 @@ bool DMessageBoxMenu::MenuEvent(int mkey, bool fromcontroller)
|
||||||
{
|
{
|
||||||
if (mMessageMode == 0)
|
if (mMessageMode == 0)
|
||||||
{
|
{
|
||||||
if (mkey == MKEY_Up || mkey == MKEY_Down)
|
if ((mkey == MKEY_Up || mkey == MKEY_Down) && m_generic_messagebox)
|
||||||
{
|
{
|
||||||
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
|
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
|
||||||
messageSelection = !messageSelection;
|
messageSelection = !messageSelection;
|
||||||
|
@ -304,7 +315,7 @@ bool DMessageBoxMenu::MenuEvent(int mkey, bool fromcontroller)
|
||||||
|
|
||||||
bool DMessageBoxMenu::MouseEvent(int type, int x, int y)
|
bool DMessageBoxMenu::MouseEvent(int type, int x, int y)
|
||||||
{
|
{
|
||||||
if (mMessageMode == 1)
|
if (mMessageMode == 1 || m_generic_messagebox)
|
||||||
{
|
{
|
||||||
if (type == MOUSE_Click)
|
if (type == MOUSE_Click)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +338,7 @@ bool DMessageBoxMenu::MouseEvent(int type, int x, int y)
|
||||||
}
|
}
|
||||||
if (sel != -1 && sel != messageSelection)
|
if (sel != -1 && sel != messageSelection)
|
||||||
{
|
{
|
||||||
//S_Sound (CHAN_VOICE | CHAN_UI, "menu/cursor", snd_menuvolume, ATTN_NONE);
|
gi->MenuSound(CursorSound);
|
||||||
}
|
}
|
||||||
messageSelection = sel;
|
messageSelection = sel;
|
||||||
if (type == MOUSE_Release)
|
if (type == MOUSE_Release)
|
||||||
|
@ -379,38 +390,40 @@ DMenu* CreateMessageBoxMenu(DMenu* parent, const char* message, int messagemode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
void ActivateEndGameMenu()
|
void ActivateEndGameMenu()
|
||||||
{
|
{
|
||||||
FString tempstring = GStrings(netgame ? "NETEND" : "ENDGAME");
|
}
|
||||||
DMenu *newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []()
|
|
||||||
|
CCMD (menu_endgame)
|
||||||
|
{ // F7
|
||||||
|
if (!gi->CanSave())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
M_StartControlPanel (true);
|
||||||
|
FString tempstring = GStrings("ENDGAME");
|
||||||
|
DMenu* newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, tempstring, 0, 501, false, NAME_None, [](bool res)
|
||||||
|
{
|
||||||
|
if (res)
|
||||||
{
|
{
|
||||||
M_ClearMenus();
|
M_ClearMenus();
|
||||||
|
/*/
|
||||||
if (!netgame)
|
if (!netgame)
|
||||||
{
|
{
|
||||||
if (demorecording)
|
if (demorecording)
|
||||||
G_CheckDemoStatus();
|
G_CheckDemoStatus();
|
||||||
D_StartTitle();
|
D_StartTitle();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
//gi->ReturnToTitle();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
M_ActivateMenu(newmenu);
|
M_ActivateMenu(newmenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCMD (menu_endgame)
|
|
||||||
{ // F7
|
|
||||||
if (!usergame)
|
|
||||||
{
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/invalid", snd_menuvolume, ATTN_NONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//M_StartControlPanel (true);
|
|
||||||
S_Sound (CHAN_VOICE | CHAN_UI, "menu/activate", snd_menuvolume, ATTN_NONE);
|
|
||||||
|
|
||||||
ActivateEndGameMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -419,47 +432,18 @@ CCMD (menu_endgame)
|
||||||
|
|
||||||
CCMD (menu_quit)
|
CCMD (menu_quit)
|
||||||
{ // F10
|
{ // F10
|
||||||
if (m_quickexit)
|
|
||||||
{
|
|
||||||
ST_Endoom();
|
|
||||||
}
|
|
||||||
|
|
||||||
M_StartControlPanel (true);
|
M_StartControlPanel (true);
|
||||||
|
|
||||||
const size_t messageindex = static_cast<size_t>(gametic) % gameinfo.quitmessages.Size();
|
FString EndString = GStrings("CONFIRM_QUITMSG");
|
||||||
FString EndString;
|
EndString << "\n[Y/N]";
|
||||||
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, []()
|
DMenu *newmenu = CreateMessageBoxMenu(DMenu::CurrentMenu, EndString, 0, 500, false, NAME_None, [](bool res)
|
||||||
{
|
{
|
||||||
if (!netgame)
|
if (res) throw ExitEvent(0);
|
||||||
{
|
|
||||||
if (gameinfo.quitSound.IsNotEmpty())
|
|
||||||
{
|
|
||||||
S_Sound(CHAN_VOICE | CHAN_UI, gameinfo.quitSound, snd_menuvolume, ATTN_NONE);
|
|
||||||
I_WaitVBL(105);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ST_Endoom();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
M_ActivateMenu(newmenu);
|
M_ActivateMenu(newmenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -751,9 +751,9 @@ bool GameInterface::DrawSpecialScreen(const DVector2 &origin, int tilenum)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position)
|
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg)
|
||||||
{
|
{
|
||||||
Menu_DrawBackground(origin);
|
if (bg) Menu_DrawBackground(origin);
|
||||||
mgametextcenter(int(origin.X * 65536), int((origin.Y + position) * 65536), text);
|
mgametextcenter(int(origin.X * 65536), int((origin.Y + position) * 65536), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,7 +164,7 @@ struct GameInterface : ::GameInterface
|
||||||
void StartGame(FGameStartup& gs) override;
|
void StartGame(FGameStartup& gs) override;
|
||||||
FSavegameInfo GetSaveSig() override;
|
FSavegameInfo GetSaveSig() override;
|
||||||
bool DrawSpecialScreen(const DVector2 &origin, int tilenum) override;
|
bool DrawSpecialScreen(const DVector2 &origin, int tilenum) override;
|
||||||
void DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position) override;
|
void DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg) override;
|
||||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||||
bool SaveGame(FSaveGameNode*) override;
|
bool SaveGame(FSaveGameNode*) override;
|
||||||
bool LoadGame(FSaveGameNode*) override;
|
bool LoadGame(FSaveGameNode*) override;
|
||||||
|
|
|
@ -466,9 +466,9 @@ void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
||||||
Menu_DrawTopBarCaption(text, origin);
|
Menu_DrawTopBarCaption(text, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position)
|
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position, bool bg)
|
||||||
{
|
{
|
||||||
Menu_DrawBackground(origin);
|
if (bg) Menu_DrawBackground(origin);
|
||||||
G_ScreenText(MF_Bluefont.tilenum, int((origin.X + 160) * 65536), int((origin.Y + position) * 65536), MF_Bluefont.zoom, 0, 0, text, 0, MF_Bluefont.pal,
|
G_ScreenText(MF_Bluefont.tilenum, int((origin.X + 160) * 65536), int((origin.Y + position) * 65536), MF_Bluefont.zoom, 0, 0, text, 0, MF_Bluefont.pal,
|
||||||
2 | 8 | 16 | ROTATESPRITE_FULL16, 0, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y,
|
2 | 8 | 16 | ROTATESPRITE_FULL16, 0, MF_Bluefont.emptychar.x, MF_Bluefont.emptychar.y, MF_Bluefont.between.x, MF_Bluefont.between.y,
|
||||||
MF_Bluefont.textflags | TEXT_XCENTER, 0, 0, xdim - 1, ydim - 1);
|
MF_Bluefont.textflags | TEXT_XCENTER, 0, 0, xdim - 1, ydim - 1);
|
||||||
|
|
|
@ -164,7 +164,7 @@ struct GameInterface : ::GameInterface
|
||||||
bool CanSave() override;
|
bool CanSave() override;
|
||||||
void StartGame(FGameStartup& gs) override;
|
void StartGame(FGameStartup& gs) override;
|
||||||
FSavegameInfo GetSaveSig() override;
|
FSavegameInfo GetSaveSig() override;
|
||||||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) override;
|
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
||||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||||
bool SaveGame(FSaveGameNode*) override;
|
bool SaveGame(FSaveGameNode*) override;
|
||||||
bool LoadGame(FSaveGameNode*) override;
|
bool LoadGame(FSaveGameNode*) override;
|
||||||
|
|
|
@ -254,8 +254,24 @@ void GameInterface::DrawMenuCaption(const DVector2& origin, const char* text)
|
||||||
MNU_DrawString(TEXT_XCENTER(w), 5, text, 1, 16);
|
MNU_DrawString(TEXT_XCENTER(w), 5, text, 1, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameInterface::DrawCenteredTextScreen(const DVector2 &origin, const char *text, int position)
|
void GameInterface::DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg)
|
||||||
{
|
{
|
||||||
|
if (text)
|
||||||
|
{
|
||||||
|
short width, height = 0;
|
||||||
|
MNU_MeasureString("T", &width, &height);
|
||||||
|
|
||||||
|
auto lines = FString(text).Split("\n");
|
||||||
|
int y = 100 - (height * lines.Size() / 2);
|
||||||
|
for (auto& l : lines)
|
||||||
|
{
|
||||||
|
short lheight = 0;
|
||||||
|
MNU_MeasureString(text, &width, &lheight);
|
||||||
|
int x = 160 - width / 2;
|
||||||
|
MNU_DrawString(x, y, l, 0, 0);
|
||||||
|
y += height;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2384,7 +2384,7 @@ struct GameInterface : ::GameInterface
|
||||||
void StartGame(FGameStartup& gs) override;
|
void StartGame(FGameStartup& gs) override;
|
||||||
FSavegameInfo GetSaveSig() override;
|
FSavegameInfo GetSaveSig() override;
|
||||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position) override;
|
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
||||||
bool LoadGame(FSaveGameNode* sv) override;
|
bool LoadGame(FSaveGameNode* sv) override;
|
||||||
bool SaveGame(FSaveGameNode* sv) override;
|
bool SaveGame(FSaveGameNode* sv) override;
|
||||||
void DoPrintMessage(int prio, const char* text) override;
|
void DoPrintMessage(int prio, const char* text) override;
|
||||||
|
|
Loading…
Reference in a new issue