disable cheats by default; use --cheats CLI option to enable for now

This commit is contained in:
fgsfds 2020-05-19 01:59:29 +03:00
parent 6a79a9af99
commit 26705aed7a
4 changed files with 25 additions and 5 deletions

View File

@ -268,8 +268,8 @@ static struct Option optsMain[] = {
DEF_OPT_SUBMENU( menuStr[6], &menuVideo ), DEF_OPT_SUBMENU( menuStr[6], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[7], &menuAudio ), DEF_OPT_SUBMENU( menuStr[7], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ), 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 ); static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain );
@ -459,6 +459,17 @@ void optmenu_toggle(void) {
#ifndef nosound #ifndef nosound
play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs); play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs);
#endif #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; currentMenu = &menuMain;
optmenu_open = 1; optmenu_open = 1;
} else { } else {

View File

@ -1,2 +1,3 @@
#include "cheats.h" #include "cheats.h"
struct CheatList Cheats; struct CheatList Cheats;

View File

@ -1,7 +1,9 @@
#ifndef _CHEATS_H
#define _CHEATS_H
#include <stdbool.h> #include <stdbool.h>
struct CheatList struct CheatList {
{
bool EnableCheats; bool EnableCheats;
bool MoonJump; bool MoonJump;
bool GodMode; bool GodMode;
@ -11,3 +13,5 @@ struct CheatList
}; };
extern struct CheatList Cheats; extern struct CheatList Cheats;
#endif // _CHEATS_H

View File

@ -1,5 +1,6 @@
#include "cliopts.h" #include "cliopts.h"
#include "configfile.h" #include "configfile.h"
#include "cheats.h"
#include "pc_main.h" #include "pc_main.h"
#include <strings.h> #include <strings.h>
@ -32,6 +33,9 @@ void parse_cli_opts(int argc, char* argv[]) {
else if (strcmp(argv[i], "--windowed") == 0) // Open game in windowed mode else if (strcmp(argv[i], "--windowed") == 0) // Open game in windowed mode
gCLIOpts.FullScreen = 2; gCLIOpts.FullScreen = 2;
else if (strcmp(argv[i], "--cheats") == 0) // Enable cheats menu
Cheats.EnableCheats = true;
// Print help // Print help
else if (strcmp(argv[i], "--help") == 0) { else if (strcmp(argv[i], "--help") == 0) {
print_help(); print_help();