diff --git a/include/text_options_strings.h.in b/include/text_options_strings.h.in index 13faf3dd5..268da4a17 100644 --- a/include/text_options_strings.h.in +++ b/include/text_options_strings.h.in @@ -77,6 +77,11 @@ #define TEXT_OPT_CHEAT7 _("EXIT COURSE AT ANY TIME") #define TEXT_OPT_CHEAT8 _("HUGE MARIO") #define TEXT_OPT_CHEAT9 _("TINY MARIO") +#define TEXT_OPT_CHEAT10 _("STAY IN LEVEL AFTER STAR") + +#define TEXT_CHEAT_STAY1 _("DISABLED") +#define TEXT_CHEAT_STAY2 _("ENABLED (NORMAL)") +#define TEXT_CHEAT_STAY3 _("ENABLED (NON-STOP)") #else // VERSION @@ -134,6 +139,11 @@ #define TEXT_OPT_CHEAT7 _("Exit course at any time") #define TEXT_OPT_CHEAT8 _("Huge Mario") #define TEXT_OPT_CHEAT9 _("Tiny Mario") +#define TEXT_OPT_CHEAT10 _("Stay in level after star") + +#define TEXT_CHEAT_STAY1 _("Disabled") +#define TEXT_CHEAT_STAY2 _("Enabled (Normal)") +#define TEXT_CHEAT_STAY3 _("Enabled (Non-Stop)") #endif // VERSION diff --git a/include/text_strings.h.in b/include/text_strings.h.in index 786e3a36a..a259af223 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -484,4 +484,4 @@ #define TEXT_MENU_STARS_DE _(" GEHEIME STERNE") #endif -#endif +#endif \ No newline at end of file diff --git a/src/game/interaction.c b/src/game/interaction.c index b8f3f881e..16e078623 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -21,6 +21,7 @@ #include "seq_ids.h" #include "course_table.h" #include "thread6.h" +#include "pc/cheats.h" #define INT_GROUND_POUND_OR_TWIRL (1 << 0) // 0x01 #define INT_PUNCH (1 << 1) // 0x02 @@ -766,6 +767,11 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O u32 starIndex; u32 starGrabAction = ACT_STAR_DANCE_EXIT; u32 noExit = (o->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0; + u8 stayInLevelCommon = (Cheats.StayInLevel > 0 && Cheats.EnableCheats == TRUE && !(m->controller->buttonDown & L_TRIG) && + !(gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2 || gCurrLevelNum == LEVEL_BOWSER_3)); + if (Cheats.StayInLevel > 0 && stayInLevelCommon == TRUE) { + noExit = TRUE; + } u32 grandStar = (o->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0; if (m->health >= 0x100) { @@ -825,7 +831,11 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O return set_mario_action(m, ACT_JUMBO_STAR_CUTSCENE, 0); } - return set_mario_action(m, starGrabAction, noExit + 2 * grandStar); + if (Cheats.StayInLevel != 2 || stayInLevelCommon == FALSE) { + return set_mario_action(m, starGrabAction, noExit + 2 * grandStar); + } + //If nonstop StayInLevel is enabled, autosave + save_file_do_save(gCurrSaveFileNum - 1); } return FALSE; diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index ef413cd98..b071e7c02 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -29,6 +29,7 @@ #include "thread6.h" #include "../../include/libc/stdlib.h" #include "../pc/pc_main.h" +#include "pc/cheats.h" // TODO: put this elsewhere enum SaveOption { SAVE_OPT_SAVE_AND_CONTINUE = 1, SAVE_OPT_SAVE_AND_QUIT, SAVE_OPT_SAVE_EXIT_GAME, SAVE_OPT_CONTINUE_DONT_SAVE }; @@ -645,6 +646,13 @@ void general_star_dance_handler(struct MarioState *m, s32 isInWater) { set_mario_action(m, ACT_READING_AUTOMATIC_DIALOG, dialogID); } else { set_mario_action(m, isInWater ? ACT_WATER_IDLE : ACT_IDLE, 0); + if (Cheats.StayInLevel > 0 && Cheats.EnableCheats == TRUE) { + set_fov_function(CAM_FOV_DEFAULT); + // fix camera bug when getting a star underwater with StayInLevel cheat enabled + if (isInWater) { + cutscene_exit_painting_end(m->area->camera); + } + } } } } diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 68cd98f00..0b04c5822 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -96,6 +96,13 @@ static const u8 optsCheatsStr[][64] = { { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 }, { TEXT_OPT_CHEAT9 }, + { TEXT_OPT_CHEAT10 }, +}; + +static const u8 optsStayInLevelStr[][32] = { + { TEXT_CHEAT_STAY1 }, + { TEXT_CHEAT_STAY2 }, + { TEXT_CHEAT_STAY3 }, }; static const u8 bindStr[][32] = { @@ -129,6 +136,12 @@ static const u8 *vsyncChoices[] = { optsVideoStr[6], }; +static const u8 *stayInLevelChoices[] = { + optsStayInLevelStr[0], + optsStayInLevelStr[1], + optsStayInLevelStr[2], +}; + enum OptType { OPT_INVALID = 0, OPT_TOGGLE, @@ -261,6 +274,7 @@ static struct Option optsCheats[] = { DEF_OPT_TOGGLE( optsCheatsStr[6], &Cheats.ExitAnywhere ), DEF_OPT_TOGGLE( optsCheatsStr[7], &Cheats.HugeMario ), DEF_OPT_TOGGLE( optsCheatsStr[8], &Cheats.TinyMario ), + DEF_OPT_CHOICE( optsCheatsStr[9], &Cheats.StayInLevel, stayInLevelChoices ), }; diff --git a/src/pc/cheats.h b/src/pc/cheats.h index eaf71ab4b..321b8ee7e 100644 --- a/src/pc/cheats.h +++ b/src/pc/cheats.h @@ -13,6 +13,7 @@ struct CheatList { bool ExitAnywhere; bool HugeMario; bool TinyMario; + unsigned int StayInLevel; }; extern struct CheatList Cheats;