Boss Rush cleanup (#5652)
* Reduce stuff in the `.h`s & use `COND_HOOK` + variants * Move some boss rush stuff from `z_file_choose.c` * clang * Update BossRush.cpp
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "libultraship/bridge.h"
|
||||
#include "soh/Enhancements/gameplaystats.h"
|
||||
#include "soh/Enhancements/boss-rush/BossRushTypes.h"
|
||||
#include "soh/Enhancements/custom-message/CustomMessageInterfaceAddon.h"
|
||||
#include "soh/Enhancements/cosmetics/cosmeticsTypes.h"
|
||||
#include "soh/Enhancements/enhancementTypes.h"
|
||||
@@ -6374,11 +6373,10 @@ void Interface_Draw(PlayState* play) {
|
||||
|
||||
void Interface_DrawTotalGameplayTimer(PlayState* play) {
|
||||
// Draw timer based on the Gameplay Stats total time.
|
||||
|
||||
if ((IS_BOSS_RUSH && gSaveContext.ship.quest.data.bossRush.options[BR_OPTIONS_TIMER] == BR_CHOICE_TIMER_YES) ||
|
||||
(CVarGetInteger(CVAR_GAMEPLAY_STATS("ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 &&
|
||||
gSaveContext.fileNum <= 2)) {
|
||||
|
||||
if (GameInteractor_Should(VB_SHOW_GAMEPLAY_TIMER,
|
||||
CVarGetInteger(CVAR_GAMEPLAY_STATS("ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 &&
|
||||
gSaveContext.fileNum <= 2,
|
||||
play)) {
|
||||
s32 X_Margins_Timer = 0;
|
||||
if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.UseMargins"), 0) != 0) {
|
||||
if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.PosType"), 0) == ORIGINAL_LOCATION) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "z_door_warp1.h"
|
||||
#include "objects/object_warp1/object_warp1.h"
|
||||
#include "soh/Enhancements/randomizer/randomizer_entrance.h"
|
||||
#include "soh/Enhancements/boss-rush/BossRush.h"
|
||||
#include "soh/OTRGlobals.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h"
|
||||
|
||||
@@ -693,12 +692,7 @@ void DoorWarp1_AdultWarpIdle(DoorWarp1* this, PlayState* play) {
|
||||
|
||||
Audio_PlayActorSound2(&this->actor, NA_SE_EV_WARP_HOLE - SFX_FLAG);
|
||||
|
||||
if (DoorWarp1_PlayerInRange(this, play)) {
|
||||
// Heal player in Boss Rush
|
||||
if (IS_BOSS_RUSH) {
|
||||
BossRush_HandleBlueWarpHeal(play);
|
||||
}
|
||||
|
||||
if (GameInteractor_Should(VB_BLUE_WARP_CONSIDER_ADULT_IN_RANGE, DoorWarp1_PlayerInRange(this, play), this)) {
|
||||
player = GET_PLAYER(play);
|
||||
|
||||
OnePointCutscene_Init(play, 0x25E8, 999, &this->actor, MAIN_CAM);
|
||||
|
||||
@@ -1398,110 +1398,6 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) {
|
||||
}
|
||||
}
|
||||
|
||||
static s8 sLastBossRushOptionIndex = -1;
|
||||
static s8 sLastBossRushOptionValue = -1;
|
||||
|
||||
void FileChoose_UpdateBossRushMenu(GameState* thisx) {
|
||||
FileChoose_UpdateStickDirectionPromptAnim(thisx);
|
||||
FileChooseContext* this = (FileChooseContext*)thisx;
|
||||
Input* input = &this->state.input[0];
|
||||
bool dpad = CVarGetInteger(CVAR_SETTING("DpadInText"), 0);
|
||||
|
||||
// Fade in elements after opening Boss Rush options menu
|
||||
this->bossRushUIAlpha += 25;
|
||||
if (this->bossRushUIAlpha > 255) {
|
||||
this->bossRushUIAlpha = 255;
|
||||
}
|
||||
|
||||
// Animate up/down arrows.
|
||||
this->bossRushArrowOffset += 1;
|
||||
if (this->bossRushArrowOffset >= 30) {
|
||||
this->bossRushArrowOffset = 0;
|
||||
}
|
||||
|
||||
// Move menu selection up or down.
|
||||
if (ABS(this->stickRelY) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN | BTN_DUP))) {
|
||||
// Move down
|
||||
if (this->stickRelY < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DDOWN))) {
|
||||
// When selecting past the last option, cycle back to the first option.
|
||||
if ((this->bossRushIndex + 1) > BR_OPTIONS_MAX - 1) {
|
||||
this->bossRushIndex = 0;
|
||||
this->bossRushOffset = 0;
|
||||
} else {
|
||||
this->bossRushIndex++;
|
||||
// When last visible option is selected when moving down, offset the list down by one.
|
||||
if (this->bossRushIndex - this->bossRushOffset > BOSSRUSH_MAX_OPTIONS_ON_SCREEN - 1) {
|
||||
this->bossRushOffset++;
|
||||
}
|
||||
}
|
||||
} else if (this->stickRelY > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DUP))) {
|
||||
// When selecting past the first option, cycle back to the last option and offset the list to view it
|
||||
// properly.
|
||||
if ((this->bossRushIndex - 1) < 0) {
|
||||
this->bossRushIndex = BR_OPTIONS_MAX - 1;
|
||||
this->bossRushOffset = this->bossRushIndex - BOSSRUSH_MAX_OPTIONS_ON_SCREEN + 1;
|
||||
} else {
|
||||
// When first visible option is selected when moving up, offset the list up by one.
|
||||
if (this->bossRushIndex - this->bossRushOffset == 0) {
|
||||
this->bossRushOffset--;
|
||||
}
|
||||
this->bossRushIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
}
|
||||
|
||||
// Cycle through choices for currently selected option.
|
||||
if (ABS(this->stickRelX) > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT | BTN_DRIGHT))) {
|
||||
if (this->stickRelX > 30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DRIGHT))) {
|
||||
// If exceeding the amount of choices for the selected option, cycle back to the first.
|
||||
if ((gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex] + 1) ==
|
||||
BossRush_GetSettingOptionsAmount(this->bossRushIndex)) {
|
||||
gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex] = 0;
|
||||
} else {
|
||||
gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex]++;
|
||||
}
|
||||
} else if (this->stickRelX < -30 || (dpad && CHECK_BTN_ANY(input->press.button, BTN_DLEFT))) {
|
||||
// If cycling back when already at the first choice for the selected option, cycle back to the last choice.
|
||||
if ((gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex] - 1) < 0) {
|
||||
gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex] =
|
||||
BossRush_GetSettingOptionsAmount(this->bossRushIndex) - 1;
|
||||
} else {
|
||||
gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex]--;
|
||||
}
|
||||
}
|
||||
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_CURSOR, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
}
|
||||
|
||||
if (sLastBossRushOptionIndex != this->bossRushIndex ||
|
||||
sLastBossRushOptionValue != gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex]) {
|
||||
GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(
|
||||
this->bossRushIndex, gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex]);
|
||||
sLastBossRushOptionIndex = this->bossRushIndex;
|
||||
sLastBossRushOptionValue = gSaveContext.ship.quest.data.bossRush.options[this->bossRushIndex];
|
||||
}
|
||||
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_B)) {
|
||||
this->configMode = CM_BOSS_RUSH_TO_QUEST;
|
||||
return;
|
||||
}
|
||||
|
||||
// Load into the game.
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_START) || CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
this->buttonIndex = 0xFE;
|
||||
this->menuMode = FS_MENU_MODE_SELECT;
|
||||
this->selectMode = SM_FADE_OUT;
|
||||
this->prevConfigMode = this->configMode;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void FileChoose_UpdateRandomizerMenu(GameState* thisx) {
|
||||
FileChoose_UpdateStickDirectionPromptAnim(thisx);
|
||||
FileChooseContext* this = (FileChooseContext*)thisx;
|
||||
@@ -2590,63 +2486,7 @@ void FileChoose_DrawWindowContents(GameState* thisx) {
|
||||
break;
|
||||
}
|
||||
} else if (this->configMode == CM_BOSS_RUSH_MENU) {
|
||||
uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language;
|
||||
uint8_t listOffset = this->bossRushOffset;
|
||||
uint8_t textAlpha = this->bossRushUIAlpha;
|
||||
|
||||
// Draw arrows to indicate that the list can scroll up or down.
|
||||
// Arrow up
|
||||
if (listOffset > 0) {
|
||||
uint16_t arrowUpX = 140;
|
||||
uint16_t arrowUpY = 76 - (this->bossRushArrowOffset / 10);
|
||||
gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowUpTex, G_IM_FMT_IA, G_IM_SIZ_16b, 16, 16, 0,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
|
||||
G_TX_NOLOD, G_TX_NOLOD);
|
||||
gSPWideTextureRectangle(POLY_OPA_DISP++, arrowUpX << 2, arrowUpY << 2, (arrowUpX + 8) << 2,
|
||||
(arrowUpY + 8) << 2, G_TX_RENDERTILE, 0, 0, (1 << 11), (1 << 11));
|
||||
}
|
||||
// Arrow down
|
||||
if (BR_OPTIONS_MAX - listOffset > BOSSRUSH_MAX_OPTIONS_ON_SCREEN) {
|
||||
uint16_t arrowDownX = 140;
|
||||
uint16_t arrowDownY = 181 + (this->bossRushArrowOffset / 10);
|
||||
gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowDownTex, G_IM_FMT_IA, G_IM_SIZ_16b, 16, 16, 0,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK,
|
||||
G_TX_NOLOD, G_TX_NOLOD);
|
||||
gSPWideTextureRectangle(POLY_OPA_DISP++, arrowDownX << 2, arrowDownY << 2, (arrowDownX + 8) << 2,
|
||||
(arrowDownY + 8) << 2, G_TX_RENDERTILE, 0, 0, (1 << 11), (1 << 11));
|
||||
}
|
||||
|
||||
// Draw options. There's more options than what fits on the screen, so the visible options
|
||||
// depend on the current offset of the list. Currently selected option pulses in
|
||||
// color and has arrows surrounding the option.
|
||||
for (uint8_t i = listOffset; i - listOffset < BOSSRUSH_MAX_OPTIONS_ON_SCREEN; i++) {
|
||||
uint16_t textYOffset = (i - listOffset) * 16;
|
||||
|
||||
// Option name.
|
||||
Interface_DrawTextLine(this->state.gfxCtx, BossRush_GetSettingName(i, language), 65, (87 + textYOffset),
|
||||
255, 255, 80, textAlpha, 0.8f, true);
|
||||
|
||||
// Selected choice for option.
|
||||
uint16_t finalKerning = Interface_DrawTextLine(
|
||||
this->state.gfxCtx,
|
||||
BossRush_GetSettingChoiceName(i, gSaveContext.ship.quest.data.bossRush.options[i], language), 165,
|
||||
(87 + textYOffset), 255, 255, 255, textAlpha, 0.8f, true);
|
||||
|
||||
// Draw arrows around selected option.
|
||||
if (this->bossRushIndex == i) {
|
||||
Gfx_SetupDL_39Opa(this->state.gfxCtx);
|
||||
gDPSetCombineMode(POLY_OPA_DISP++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
|
||||
gDPLoadTextureBlock(POLY_OPA_DISP++, gArrowCursorTex, G_IM_FMT_IA, G_IM_SIZ_8b, 16, 24, 0,
|
||||
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 4, G_TX_NOMASK, G_TX_NOLOD,
|
||||
G_TX_NOLOD);
|
||||
FileChoose_DrawTextRec(this->state.gfxCtx, this->stickLeftPrompt.arrowColorR,
|
||||
this->stickLeftPrompt.arrowColorG, this->stickLeftPrompt.arrowColorB, textAlpha,
|
||||
160, (92 + textYOffset), 0.42f, 0, 0, -1.0f, 1.0f);
|
||||
FileChoose_DrawTextRec(this->state.gfxCtx, this->stickRightPrompt.arrowColorR,
|
||||
this->stickRightPrompt.arrowColorG, this->stickRightPrompt.arrowColorB,
|
||||
textAlpha, (171 + finalKerning), (92 + textYOffset), 0.42f, 0, 0, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
FileChoose_DrawBossRushMenuWindowContents(this);
|
||||
} else if (this->configMode == CM_RANDOMIZER_SETTINGS_MENU) {
|
||||
uint8_t language = (gSaveContext.language == LANGUAGE_JPN) ? LANGUAGE_ENG : gSaveContext.language;
|
||||
uint8_t textAlpha = this->randomizerUIAlpha;
|
||||
|
||||
Reference in New Issue
Block a user