From 0dc85ea130b96515eb208babb78277e03f676f46 Mon Sep 17 00:00:00 2001 From: PringlesGang Date: Sat, 28 Dec 2024 00:24:24 +0100 Subject: [PATCH] Added sysse to options menu --- src/games/cclcc/optionsmenu.cpp | 28 ++++++++++++++++++-- src/ui/widgets/cclcc/optionsbinarybutton.cpp | 28 +++++++++++++++----- src/ui/widgets/cclcc/optionsentry.cpp | 20 +++++++++++--- src/ui/widgets/cclcc/optionsvoiceslider.cpp | 14 +++++++++- 4 files changed, 78 insertions(+), 12 deletions(-) diff --git a/src/games/cclcc/optionsmenu.cpp b/src/games/cclcc/optionsmenu.cpp index 6266223b..d82497e3 100644 --- a/src/games/cclcc/optionsmenu.cpp +++ b/src/games/cclcc/optionsmenu.cpp @@ -193,10 +193,17 @@ void OptionsMenu::Update(float dt) { } void OptionsMenu::UpdateInput() { - for (ClickButton& button : PageButtons) button.UpdateInput(); + for (ClickButton& button : PageButtons) { + const bool wasHovered = button.Hovered; + button.UpdateInput(); + if (!wasHovered && button.Hovered) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + } // Tab cycling if (PADinputButtonWentDown & (PAD1L1 | PAD1R1)) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + const bool focusedElement = CurrentlyFocusedElement; const int direction = (bool)(PADinputButtonWentDown & PAD1R1) - (bool)(PADinputButtonWentDown & PAD1L1); @@ -210,18 +217,26 @@ void OptionsMenu::UpdateInput() { if (CurrentlyFocusedElement == nullptr) { if (GetControlState(CT_Back)) { + if (!GetFlag(SF_SUBMENUEXIT)) + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + SetFlag(SF_SUBMENUEXIT, true); return; } const int direction = (bool)(PADinputButtonWentDown & PAD1DOWN) - (bool)(PADinputButtonWentDown & PAD1UP); - if (direction) GoToPage((CurrentPage + direction) % Pages.size()); + if (direction) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + GoToPage((CurrentPage + direction) % Pages.size()); + } if (PADinputButtonWentDown & PAD1A) { // Don't have anything else consume the confirmation PADinputButtonWentDown &= ~PAD1A; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); CurrentlyFocusedElement->HasFocus = true; } @@ -233,12 +248,16 @@ void OptionsMenu::UpdateInput() { if (static_cast(CurrentlyFocusedElement)->Selected) return; if (GetControlState(CT_Back) || PADinputMouseWentDown & PAD1B) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + static_cast(CurrentlyFocusedElement)->Hide(); CurrentlyFocusedElement = nullptr; return; } Menu::UpdateInput(); + if (PADinputButtonWentDown & (PAD1DOWN | PAD1UP)) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); } void OptionsMenu::Render() { @@ -296,6 +315,11 @@ void OptionsMenu::Select(OptionsEntry* toSelect) { } void OptionsMenu::PageButtonOnClick(ClickButton* target) { + if (target->Id != CurrentPage || !CurrentlyFocusedElement) + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + + if (target->Id == CurrentPage && CurrentlyFocusedElement) return; + GoToPage(target->Id); CurrentlyFocusedElement = Pages.at(CurrentPage)->GetFirstFocusableChild(); CurrentlyFocusedElement->HasFocus = true; diff --git a/src/ui/widgets/cclcc/optionsbinarybutton.cpp b/src/ui/widgets/cclcc/optionsbinarybutton.cpp index b7255136..7cd606e2 100644 --- a/src/ui/widgets/cclcc/optionsbinarybutton.cpp +++ b/src/ui/widgets/cclcc/optionsbinarybutton.cpp @@ -56,22 +56,38 @@ void OptionsBinaryButton::Render() { } void OptionsBinaryButton::UpdateInput() { - OptionsEntry::UpdateInput(); - // Handle mouse/touch input TrueButton.UpdateInput(); FalseButton.UpdateInput(); + OptionsEntry::UpdateInput(); + if (!Selected) return; // Handle keyboard/controller input - if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) - State = PADinputButtonWentDown & PAD1LEFT; + if (PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) { + const bool newState = PADinputButtonWentDown & PAD1LEFT; + + if (State != newState) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = newState; + } } -void OptionsBinaryButton::TrueOnClick(ClickButton* target) { State = true; } +void OptionsBinaryButton::TrueOnClick(ClickButton* target) { + if (Selected && State != true) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = true; +} -void OptionsBinaryButton::FalseOnClick(ClickButton* target) { State = false; } +void OptionsBinaryButton::FalseOnClick(ClickButton* target) { + if (Selected && State != false) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + + State = false; +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsentry.cpp b/src/ui/widgets/cclcc/optionsentry.cpp index 098ebadd..596f55b5 100644 --- a/src/ui/widgets/cclcc/optionsentry.cpp +++ b/src/ui/widgets/cclcc/optionsentry.cpp @@ -42,13 +42,22 @@ void OptionsEntry::Render() { } void OptionsEntry::UpdateInput() { + const bool wasHovered = EntryButton.Hovered; EntryButton.UpdateInput(); + if (!wasHovered && EntryButton.Hovered) + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); if (!HasFocus) return; - Selected ^= (bool)(PADinputButtonWentDown & PAD1A); - if (PADinputButtonWentDown & PAD1B || PADinputMouseWentDown & PAD1B) + if (PADinputButtonWentDown & PAD1A) { + Selected = !Selected; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + } + + if (PADinputButtonWentDown & PAD1B || PADinputMouseWentDown & PAD1B) { Selected = false; + Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f); + } } void OptionsEntry::Show() { EntryButton.Show(); } @@ -59,7 +68,12 @@ void OptionsEntry::Hide() { Selected = false; } -void OptionsEntry::EntryButtonOnClick(ClickButton* target) { Select(this); } +void OptionsEntry::EntryButtonOnClick(ClickButton* target) { + if (Selected) return; + + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + Select(this); +} } // namespace CCLCC } // namespace Widgets diff --git a/src/ui/widgets/cclcc/optionsvoiceslider.cpp b/src/ui/widgets/cclcc/optionsvoiceslider.cpp index f2fbab02..00b54e7f 100644 --- a/src/ui/widgets/cclcc/optionsvoiceslider.cpp +++ b/src/ui/widgets/cclcc/optionsvoiceslider.cpp @@ -62,7 +62,17 @@ void OptionsVoiceSlider::UpdateInput() { OptionsSlider::UpdateInput(); MuteButton.UpdateInput(); - if (HasFocus) Muted ^= (bool)(PADinputButtonWentDown & PAD1Y); + if (!HasFocus) return; + + if (PADinputButtonWentDown & PAD1Y) { + Muted = !Muted; + Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + } + + if ((bool)(PADinputButtonWentDown & (PAD1LEFT | PAD1RIGHT)) && + !(bool)(PADinputButtonWentDown & (PAD1UP | PAD1DOWN))) { + Audio::Channels[Audio::AC_REV]->Play("sysse", 1, false, 0.0f); + } } void OptionsVoiceSlider::Show() { @@ -76,6 +86,8 @@ void OptionsVoiceSlider::Hide() { } void OptionsVoiceSlider::MuteButtonOnClick(ClickButton* target) { + if (HasFocus) Audio::Channels[Audio::AC_REV]->Play("sysse", 2, false, 0.0f); + Muted = !Muted; }