Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 34 additions & 28 deletions src/game/options_menu.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifdef EXT_OPTIONS_MENU

#include "sm64.h"
#include "include/text_strings.h"
#include "text_strings.h"
#include "engine/math_util.h"
#include "audio/external.h"
#include "game/camera.h"
Expand Down Expand Up @@ -45,18 +45,21 @@ static const u8 toggleStr[][16] = {
{ TEXT_OPT_ENABLED },
};

static const u8 menuStr[][32] = {
{ TEXT_OPT_HIGHLIGHT },
static const u8 optSmallStr[][32] = {
{ TEXT_OPT_BUTTON1 },
{ TEXT_OPT_BUTTON2 },
{ TEXT_OPT_L_HIGHLIGHT },
{ TEXT_OPT_R_HIGHLIGHT },
};

static const u8 menuStr[][32] = {
{ TEXT_OPT_OPTIONS },
{ TEXT_OPT_CAMERA },
{ TEXT_OPT_CONTROLS },
{ TEXT_OPT_VIDEO },
{ TEXT_OPT_AUDIO },
{ TEXT_EXIT_GAME },
{ TEXT_OPT_CHEATS },

};

static const u8 optsCameraStr[][32] = {
Expand Down Expand Up @@ -122,7 +125,7 @@ static const u8 bindStr[][32] = {
{ TEXT_BIND_LEFT },
{ TEXT_BIND_RIGHT },
{ TEXT_OPT_DEADZONE },
{ TEXT_OPT_RUMBLE }
{ TEXT_OPT_RUMBLE },
};

static const u8 *filterChoices[] = {
Expand Down Expand Up @@ -285,33 +288,34 @@ static struct Option optsCheats[] = {
/* submenu definitions */

#ifdef BETTERCAMERA
static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[4], optsCamera );
static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[1], optsCamera );
#endif
static struct SubMenu menuControls = DEF_SUBMENU( menuStr[5], optsControls );
static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[6], optsVideo );
static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[7], optsAudio );
static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats );
static struct SubMenu menuControls = DEF_SUBMENU( menuStr[2], optsControls );
static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[3], optsVideo );
static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[4], optsAudio );
static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[6], optsCheats );

/* main options menu definition */

static struct Option optsMain[] = {
#ifdef BETTERCAMERA
DEF_OPT_SUBMENU( menuStr[4], &menuCamera ),
DEF_OPT_SUBMENU( menuStr[1], &menuCamera ),
#endif
DEF_OPT_SUBMENU( menuStr[5], &menuControls ),
DEF_OPT_SUBMENU( menuStr[6], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[7], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ),
DEF_OPT_SUBMENU( menuStr[2], &menuControls ),
DEF_OPT_SUBMENU( menuStr[3], &menuVideo ),
DEF_OPT_SUBMENU( menuStr[4], &menuAudio ),
DEF_OPT_BUTTON ( menuStr[5], optmenu_act_exit ),
// NOTE: always keep cheats the last option here because of the half-assed way I toggle them
DEF_OPT_SUBMENU( menuStr[9], &menuCheats )
DEF_OPT_SUBMENU( menuStr[6], &menuCheats )
};

static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain );
static struct SubMenu menuMain = DEF_SUBMENU( menuStr[0], optsMain );

/* implementation */

static s32 optmenu_option_timer = 0;
static u8 optmenu_hold_count = 0;
static s32 optmenu_sin_timer = 0;

static struct SubMenu *currentMenu = &menuMain;

Expand Down Expand Up @@ -450,6 +454,7 @@ static inline s16 get_hudstr_centered_x(const s16 sx, const u8 *str) {
void optmenu_draw(void) {
s16 scroll;
s16 scrollpos;
f32 sinpos;

const s16 labelX = get_hudstr_centered_x(160, currentMenu->label);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
Expand All @@ -465,26 +470,26 @@ void optmenu_draw(void) {

gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 80, SCREEN_WIDTH, SCREEN_HEIGHT);

for (u8 i = 0; i < currentMenu->numOpts; i++) {
scroll = 140 - 32 * i + currentMenu->scroll * 32;
// FIXME: just start from the first visible option bruh
if (scroll <= 140 && scroll > 32)
optmenu_draw_opt(&currentMenu->opts[i], 160, scroll, (currentMenu->select == i));
}

sinpos = sins(optmenu_sin_timer*5000)*4;
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_begin);
print_hud_lut_string(HUD_LUT_GLOBAL, 80, 90 + (32 * (currentMenu->select - currentMenu->scroll)), menuStr[0]);
print_hud_lut_string(HUD_LUT_GLOBAL, 224, 90 + (32 * (currentMenu->select - currentMenu->scroll)), menuStr[0]);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end);
print_generic_string(80 - sinpos, 132 - (32 * (currentMenu->select - currentMenu->scroll)), optSmallStr[2]);
print_generic_string(224 + sinpos, 132 - (32 * (currentMenu->select - currentMenu->scroll)), optSmallStr[3]);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
}

//This has been separated for interesting reasons. Don't question it.
void optmenu_draw_prompt(void) {
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);
optmenu_draw_text(264, 212, menuStr[1 + optmenu_open], 0);
optmenu_draw_text(264, 212, optSmallStr[optmenu_open], 0);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
}

Expand All @@ -506,7 +511,6 @@ void optmenu_toggle(void) {

currentMenu = &menuMain;
optmenu_open = 1;

/* Resets l_counter to 0 every time the options menu is open */
l_counter = 0;
} else {
Expand Down Expand Up @@ -539,6 +543,8 @@ void optmenu_check_buttons(void) {
if (gPlayer1Controller->buttonPressed & R_TRIG)
optmenu_toggle();

optmenu_sin_timer++;

/* Enables cheats if the user press the L trigger 3 times while in the options menu. Also plays a sound. */

if ((gPlayer1Controller->buttonPressed & L_TRIG) && !Cheats.EnableCheats) {
Expand Down Expand Up @@ -566,13 +572,13 @@ void optmenu_check_buttons(void) {
allowInput = 1;
}

if (ABS(gPlayer1Controller->stickY) > 60) {
if ((ABS(gPlayer1Controller->stickY) > 60) || (gPlayer1Controller->buttonPressed & (D_CBUTTONS|U_CBUTTONS))) {
if (allowInput) {
#ifndef nosound
play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs);
#endif

if (gPlayer1Controller->stickY >= 60) {
if ((gPlayer1Controller->stickY >= 60) || (gPlayer1Controller->buttonPressed & U_CBUTTONS)) {
currentMenu->select--;
if (currentMenu->select < 0)
currentMenu->select = currentMenu->numOpts-1;
Expand All @@ -587,12 +593,12 @@ void optmenu_check_buttons(void) {
else if (currentMenu->select > currentMenu->scroll + 3)
currentMenu->scroll = currentMenu->select - 3;
}
} else if (ABS(gPlayer1Controller->stickX) > 60) {
} else if ((ABS(gPlayer1Controller->stickX) > 60) || (gPlayer1Controller->buttonPressed & (L_CBUTTONS|R_CBUTTONS))) {
if (allowInput) {
#ifndef nosound
play_sound(SOUND_MENU_CHANGE_SELECT, gDefaultSoundArgs);
#endif
if (gPlayer1Controller->stickX >= 60)
if ((gPlayer1Controller->stickX >= 60) || (gPlayer1Controller->buttonPressed & R_CBUTTONS))
optmenu_opt_change(&currentMenu->opts[currentMenu->select], 1);
else
optmenu_opt_change(&currentMenu->opts[currentMenu->select], -1);
Expand Down