Fix circumstances the game restricts access to certain pause menu options.

Changed conditions -
- Switch Map and Addons on in-game pause menu
    - now restricted by !K_CanChangeRules(), which covers all singleplayer conditions
- Gameplay and Server Options
    - now restricted if in-game, and either singleplayer conditions or not admin
- Erase data
    - now restricted if in-game at all (fixes new-menus regression)
This commit is contained in:
toaster 2022-09-02 21:55:29 +01:00
parent c95fed770e
commit bcd9c7efba
3 changed files with 34 additions and 18 deletions

View file

@ -258,6 +258,18 @@ typedef enum
mopt_manual,
} mopt_e;
typedef enum
{
dopt_screenshot = 0,
dopt_addon,
dopt_replay,
#ifdef HAVE_DISCORDRPC
dopt_discord,
#endif
dopt_spacer,
dopt_erase,
} dopt_e;
extern menuitem_t OPTIONS_Profiles[];
extern menu_t OPTIONS_ProfilesDef;

View file

@ -474,7 +474,7 @@ menu_t PLAY_MP_ServerBrowserDef = {
M_ServerBrowserInputs
};
// options menu
// options menu -- see mopt_e
menuitem_t OPTIONS_Main[] =
{
@ -1249,6 +1249,7 @@ menu_t OPTIONS_ServerAdvancedDef = {
};
#endif
// data options menu -- see dopt_e
menuitem_t OPTIONS_Data[] =
{
@ -1269,8 +1270,7 @@ menuitem_t OPTIONS_Data[] =
{IT_SPACE | IT_NOTHING, NULL, NULL,
NULL, {NULL}, 0, 0},
// escape sequences don't like any letter from A to E following them... So let's also put E as an escape sequence lol. E is 69 (nice) which is 45 in hex.
{IT_STRING | IT_SUBMENU, "\x85\x45rase Data...", "Erase specific data. Be careful, what's deleted is gone forever!",
{IT_STRING | IT_SUBMENU, "\x85""Erase Data...", "Erase specific data. Be careful, what's deleted is gone forever!",
NULL, {.submenu = &OPTIONS_DataEraseDef}, 0, 0},
};

View file

@ -4391,17 +4391,21 @@ void M_InitOptions(INT32 choice)
{
(void)choice;
OPTIONS_MainDef.menuitems[mopt_profiles].status = IT_STRING | IT_CALL;
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_SUBMENU;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_SUBMENU;
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_TRANSTEXT;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_TRANSTEXT;
// disable gameplay & server options if you aren't an admin in netgames. (GS_MENU check maybe unecessary but let's not take any chances)
if (netgame && gamestate != GS_MENU && !IsPlayerAdmin(consoleplayer))
// enable gameplay & server options under the right circumstances.
if (gamestate == GS_MENU
|| ((server || IsPlayerAdmin(consoleplayer)) && K_CanChangeRules()))
{
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_TRANSTEXT;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_TRANSTEXT;
OPTIONS_MainDef.menuitems[mopt_gameplay].status = IT_STRING | IT_SUBMENU;
OPTIONS_MainDef.menuitems[mopt_server].status = IT_STRING | IT_SUBMENU;
}
OPTIONS_DataDef.menuitems[dopt_erase].status = (gamestate == GS_MENU
? (IT_STRING | IT_SUBMENU)
: (IT_TRANSTEXT2 | IT_SPACE));
M_ResetOptions();
// So that pause doesn't go to the main menu...
@ -5706,7 +5710,6 @@ struct pausemenu_s pausemenu;
// Pause menu!
void M_OpenPauseMenu(void)
{
boolean singleplayermode = (modeattacking || grandprixinfo.gp);
currentMenu = &PAUSE_MainDef;
// Ready the variables
@ -5736,18 +5739,19 @@ void M_OpenPauseMenu(void)
Dummymenuplayer_OnChange(); // Make sure the consvar is within bounds of the amount of splitscreen players we have.
if (!singleplayermode && (server || IsPlayerAdmin(consoleplayer)))
if (K_CanChangeRules())
{
PAUSE_Main[mpause_switchmap].status = IT_STRING | IT_SUBMENU;
PAUSE_Main[mpause_addons].status = IT_STRING | IT_CALL;
}
if (!singleplayermode)
PAUSE_Main[mpause_psetup].status = IT_STRING | IT_CALL;
if (server || IsPlayerAdmin(consoleplayer))
{
PAUSE_Main[mpause_switchmap].status = IT_STRING | IT_SUBMENU;
PAUSE_Main[mpause_addons].status = IT_STRING | IT_CALL;
}
}
if (G_GametypeHasSpectators())
{
if (splitscreen)
PAUSE_Main[mpause_spectatemenu].status = IT_STRING|IT_SUBMENU;
else