Skip to content

Commit

Permalink
Added sysse to options menu
Browse files Browse the repository at this point in the history
  • Loading branch information
PringlesGang committed Dec 27, 2024
1 parent 95ab928 commit 0dc85ea
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 12 deletions.
28 changes: 26 additions & 2 deletions src/games/cclcc/optionsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
Expand All @@ -233,12 +248,16 @@ void OptionsMenu::UpdateInput() {
if (static_cast<OptionsEntry*>(CurrentlyFocusedElement)->Selected) return;

if (GetControlState(CT_Back) || PADinputMouseWentDown & PAD1B) {
Audio::Channels[Audio::AC_REV]->Play("sysse", 3, false, 0.0f);

static_cast<OptionsEntry*>(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() {
Expand Down Expand Up @@ -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;
Expand Down
28 changes: 22 additions & 6 deletions src/ui/widgets/cclcc/optionsbinarybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions src/ui/widgets/cclcc/optionsentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/ui/widgets/cclcc/optionsvoiceslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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;
}

Expand Down

0 comments on commit 0dc85ea

Please sign in to comment.