Skip to content

Commit

Permalink
MERGE PR 228 + fix timer not get hidden when hitting a star
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin452 committed May 2, 2024
1 parent cf08e8f commit e455183
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"gfx_window_manager_api.h": "c",
"stdbool.h": "c",
"graph_node.h": "c",
"windows.h": "c"
"windows.h": "c",
"ingame_menu.h": "c"
},
"git.ignoreLimitWarning": true,
"[cpp]": {
Expand Down
8 changes: 8 additions & 0 deletions include/text_options_strings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
#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)")
#define TEXT_OPT_FOREVER_SHELL _("FOREVER SHELL")
#define TEXT_OPT_FOREVER_CAP _("FOREVER CAP")
#define TEXT_OPT_WING_CAP _("GET WING CAP")
Expand Down Expand Up @@ -161,6 +165,10 @@
#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)")
#define TEXT_OPT_FOREVER_SHELL _("Forever Shell")
#define TEXT_OPT_FOREVER_CAP _("Forever Cap")
#define TEXT_OPT_WING_CAP _("Get WING Cap")
Expand Down
15 changes: 14 additions & 1 deletion src/game/interaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "sm64.h"
#include "sound_init.h"
#include "thread6.h"
#include "pc/cheats.h"

#define INT_GROUND_POUND_OR_TWIRL (1 << 0) // 0x01
#define INT_PUNCH (1 << 1) // 0x02
Expand Down Expand Up @@ -764,6 +765,14 @@ 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) {
level_control_timer(TIMER_CONTROL_HIDE);
noExit = TRUE;
}
u32 grandStar = (o->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0;

if (m->health >= 0x100) {
Expand Down Expand Up @@ -821,7 +830,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;
Expand Down
10 changes: 9 additions & 1 deletion src/game/mario_actions_cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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,
Expand Down Expand Up @@ -656,6 +656,14 @@ 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);
// fix camera bug when getting a star underwater with StayInLevel cheat enabled
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);
}
}
}
}
}
Expand Down
33 changes: 23 additions & 10 deletions src/game/options_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ static const u8 optsAudioStr[][32] = {
};

static const u8 optsCheatsStr[][64] = {
{ TEXT_OPT_CHEAT1 }, { TEXT_OPT_CHEAT2 }, { TEXT_OPT_CHEAT3 }, { TEXT_OPT_CHEAT4 },
{ TEXT_OPT_CHEAT5 }, { TEXT_OPT_CHEAT6 }, { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 },
{ TEXT_OPT_CHEAT9 }, { TEXT_OPT_FOREVER_SHELL }, { TEXT_OPT_FOREVER_CAP }, { TEXT_OPT_WING_CAP },
{ TEXT_OPT_METAL_CAP }, { TEXT_OPT_VANISH_CAP }, { TEXT_OPT_NORMAL_CAP },
{ TEXT_OPT_CHEAT1 }, { TEXT_OPT_CHEAT2 }, { TEXT_OPT_CHEAT3 }, { TEXT_OPT_CHEAT4 },
{ TEXT_OPT_CHEAT5 }, { TEXT_OPT_CHEAT6 }, { TEXT_OPT_CHEAT7 }, { TEXT_OPT_CHEAT8 },
{ TEXT_OPT_CHEAT9 }, { TEXT_OPT_CHEAT10 }, { TEXT_OPT_FOREVER_SHELL }, { TEXT_OPT_FOREVER_CAP },
{ TEXT_OPT_WING_CAP }, { TEXT_OPT_METAL_CAP }, { TEXT_OPT_VANISH_CAP }, { TEXT_OPT_NORMAL_CAP },
};

static const u8 optsStayInLevelStr[][32] = {
{ TEXT_CHEAT_STAY1 },
{ TEXT_CHEAT_STAY2 },
{ TEXT_CHEAT_STAY3 },
};

static const u8 bindStr[][32] = {
Expand All @@ -106,6 +112,12 @@ static const u8 *vsyncChoices[] = {
optsVideoStr[6],
};

static const u8 *stayInLevelChoices[] = {
optsStayInLevelStr[0],
optsStayInLevelStr[1],
optsStayInLevelStr[2],
};

enum OptType {
OPT_INVALID = 0,
OPT_TOGGLE,
Expand Down Expand Up @@ -263,12 +275,13 @@ 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_TOGGLE(optsCheatsStr[9], &Cheats.ForeverShell),
DEF_OPT_TOGGLE(optsCheatsStr[10], &Cheats.ForeverCap),
DEF_OPT_BUTTON(optsCheatsStr[11], setCap_Wing),
DEF_OPT_BUTTON(optsCheatsStr[12], setCap_Metal),
DEF_OPT_BUTTON(optsCheatsStr[13], setCap_Vanish),
DEF_OPT_BUTTON(optsCheatsStr[14], setCap_Normal),
DEF_OPT_CHOICE(optsCheatsStr[9], &Cheats.StayInLevel, stayInLevelChoices),
DEF_OPT_TOGGLE(optsCheatsStr[10], &Cheats.ForeverShell),
DEF_OPT_TOGGLE(optsCheatsStr[11], &Cheats.ForeverCap),
DEF_OPT_BUTTON(optsCheatsStr[12], setCap_Wing),
DEF_OPT_BUTTON(optsCheatsStr[13], setCap_Metal),
DEF_OPT_BUTTON(optsCheatsStr[14], setCap_Vanish),
DEF_OPT_BUTTON(optsCheatsStr[15], setCap_Normal),
};

/* submenu definitions */
Expand Down
1 change: 1 addition & 0 deletions src/pc/cheats.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ struct CheatList {
bool ExitAnywhere;
bool HugeMario;
bool TinyMario;
unsigned int StayInLevel;
bool ForeverShell;
bool ForeverCap;
bool WingCap;
Expand Down

0 comments on commit e455183

Please sign in to comment.