diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 7b8d9f74..d23223b0 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -268,8 +268,8 @@ static struct Option optsMain[] = { DEF_OPT_SUBMENU( menuStr[6], &menuVideo ), DEF_OPT_SUBMENU( menuStr[7], &menuAudio ), DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ), - DEF_OPT_SUBMENU( menuStr[9], &menuCheats ), - + // NOTE: always keep cheats the last option here because of the half-assed way I toggle them + DEF_OPT_SUBMENU( menuStr[9], &menuCheats ) }; static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain ); @@ -459,6 +459,17 @@ void optmenu_toggle(void) { #ifndef nosound play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); #endif + + // HACK: hide the last option in main if cheats are disabled + menuMain.numOpts = sizeof(optsMain) / sizeof(optsMain[0]); + if (!Cheats.EnableCheats) { + menuMain.numOpts--; + if (menuMain.select >= menuMain.numOpts) { + menuMain.select = 0; // don't bother + menuMain.scroll = 0; + } + } + currentMenu = &menuMain; optmenu_open = 1; } else { diff --git a/src/pc/cheats.c b/src/pc/cheats.c index 5663d777..adcc4efe 100644 --- a/src/pc/cheats.c +++ b/src/pc/cheats.c @@ -1,2 +1,3 @@ #include "cheats.h" + struct CheatList Cheats; diff --git a/src/pc/cheats.h b/src/pc/cheats.h index 01a7264b..531c392f 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -1,9 +1,11 @@ +#ifndef _CHEATS_H +#define _CHEATS_H + #include -struct CheatList -{ +struct CheatList { bool EnableCheats; - bool MoonJump; + bool MoonJump; bool GodMode; bool InfiniteLives; bool SuperSpeed; @@ -11,3 +13,5 @@ struct CheatList }; extern struct CheatList Cheats; + +#endif // _CHEATS_H diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index 234660b2..727de38b 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -1,5 +1,6 @@ #include "cliopts.h" #include "configfile.h" +#include "cheats.h" #include "pc_main.h" #include @@ -32,6 +33,9 @@ void parse_cli_opts(int argc, char* argv[]) { else if (strcmp(argv[i], "--windowed") == 0) // Open game in windowed mode gCLIOpts.FullScreen = 2; + else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu + Cheats.EnableCheats = true; + // Print help else if (strcmp(argv[i], "--help") == 0) { print_help();