Add sound to indicate switching option items and tabs. Enable main and game menu to cycle through menu items.

This commit is contained in:
hackgrid 2023-10-18 17:36:34 +02:00
parent 9f7e15e3fd
commit 831370efeb
7 changed files with 33 additions and 13 deletions

View file

@ -126,6 +126,7 @@ enum MenuDirection audioOptionsUpdate(struct AudioOptions* audioOptions) {
if (audioOptions->selectedItem == AudioOptionCount) {
audioOptions->selectedItem = 0;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (controllerDir & ControllerDirectionUp) {
@ -134,6 +135,7 @@ enum MenuDirection audioOptionsUpdate(struct AudioOptions* audioOptions) {
} else {
--audioOptions->selectedItem;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
switch (audioOptions->selectedItem) {
@ -274,4 +276,4 @@ void audioOptionsRender(struct AudioOptions* audioOptions, struct RenderState* r
gSPDisplayList(renderState->dl++, audioOptions->audioLanguageDynamicText);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
}

View file

@ -296,6 +296,7 @@ enum MenuDirection controlsMenuUpdate(struct ControlsMenu* controlsMenu) {
if (controlsMenu->selectedRow == ControllerActionCount + 1) {
controlsMenu->selectedRow = 0;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (controllerDir & ControllerDirectionUp) {
@ -304,6 +305,7 @@ enum MenuDirection controlsMenuUpdate(struct ControlsMenu* controlsMenu) {
if (controlsMenu->selectedRow < 0) {
controlsMenu->selectedRow = ControllerActionCount;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (controlsMenu->selectedRow >= 0 && controlsMenu->selectedRow < ControllerActionCount) {
@ -558,4 +560,4 @@ void controlsRenderSubtitle(char* message, float textOpacity, float backgroundOp
renderState->dl
);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
}

View file

@ -83,6 +83,7 @@ enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions
if (gameplayOptions->selectedItem == GameplayOptionCount) {
gameplayOptions->selectedItem = 0;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (controllerDir & ControllerDirectionUp) {
@ -91,6 +92,7 @@ enum MenuDirection gameplayOptionsUpdate(struct GameplayOptions* gameplayOptions
} else {
--gameplayOptions->selectedItem;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
switch (gameplayOptions->selectedItem) {
@ -192,4 +194,4 @@ void gameplayOptionsRender(struct GameplayOptions* gameplayOptions, struct Rende
gSPDisplayList(renderState->dl++, gameplayOptions->portalRenderDepthText);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
}

View file

@ -92,6 +92,7 @@ enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions
if (joystickOptions->selectedItem == JoystickOptionCount) {
joystickOptions->selectedItem = 0;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (controllerDir & ControllerDirectionUp) {
@ -100,6 +101,7 @@ enum MenuDirection joystickOptionsUpdate(struct JoystickOptions* joystickOptions
} else {
--joystickOptions->selectedItem;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
switch (joystickOptions->selectedItem) {
@ -222,4 +224,4 @@ void joystickOptionsRender(struct JoystickOptions* joystickOptions, struct Rende
gSPDisplayList(renderState->dl++, joystickOptions->joystickDeadzoneText);
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
}

View file

@ -71,13 +71,21 @@ void landingMenuInit(struct LandingMenu* landingMenu, struct LandingMenuOption*
}
struct LandingMenuOption* landingMenuUpdate(struct LandingMenu* landingMenu) {
if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0 && landingMenu->selectedItem > 0) {
--landingMenu->selectedItem;
if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0) {
if (landingMenu->selectedItem > 0) {
--landingMenu->selectedItem;
} else {
landingMenu->selectedItem = landingMenu->optionCount - 1;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0 && landingMenu->selectedItem + 1 < landingMenu->optionCount) {
++landingMenu->selectedItem;
if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0) {
if (landingMenu->selectedItem + 1 < landingMenu->optionCount) {
++landingMenu->selectedItem;
} else {
landingMenu->selectedItem = 0;
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
@ -109,4 +117,4 @@ void landingMenuRender(struct LandingMenu* landingMenu, struct RenderState* rend
gSPDisplayList(renderState->dl++, landingMenu->optionText[i]);
}
gSPDisplayList(renderState->dl++, ui_material_revert_list[DEJAVU_SANS_INDEX]);
}
}

View file

@ -144,13 +144,14 @@ enum MenuDirection newGameUpdate(struct NewGameMenu* newGameMenu) {
newGameMenu->selectedChapter + 1 < newGameMenu->chapterCount &&
gChapters[newGameMenu->selectedChapter + 1].imageData) {
newGameMenu->selectedChapter = newGameMenu->selectedChapter + 1;
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if ((controllerGetDirectionDown(0) & ControllerDirectionLeft) != 0 && newGameMenu->selectedChapter > 0) {
newGameMenu->selectedChapter = newGameMenu->selectedChapter - 1;
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if ((controllerGetDirectionDown(0) & ControllerDirectionLeft) != 0 || (controllerGetDirectionDown(0) & ControllerDirectionRight) != 0)
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
int nextChapterOffset = newGameMenu->selectedChapter & ~1;
@ -229,4 +230,4 @@ void newGameRender(struct NewGameMenu* newGameMenu, struct RenderState* renderSt
gColorWhite
);
}
}
}

View file

@ -8,6 +8,7 @@
#include "../build/assets/materials/ui.h"
#include "../controls/controller.h"
#include "../build/src/audio/clips.h"
struct Tab gOptionTabs[] = {
@ -87,6 +88,7 @@ enum MenuDirection optionsMenuUpdate(struct OptionsMenu* options) {
}
tabsSetSelectedTab(&options->tabs, options->tabs.selectedTab);
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
if (menuDirection == MenuDirectionRight) {
@ -95,6 +97,7 @@ enum MenuDirection optionsMenuUpdate(struct OptionsMenu* options) {
} else {
tabsSetSelectedTab(&options->tabs, options->tabs.selectedTab + 1);
}
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
@ -134,4 +137,4 @@ void optionsMenuRender(struct OptionsMenu* options, struct RenderState* renderSt
gameplayOptionsRender(&options->gameplayOptions, renderState, task);
break;
}
}
}