Skip to content

Commit

Permalink
Hook up a couple more sounds. Unfortunately clickable back buttons no…
Browse files Browse the repository at this point in the history
…w play both back and confirm sounds...
  • Loading branch information
hrydgard committed Aug 2, 2020
1 parent c746e7b commit d3ec52b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion UI/BackgroundAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ int BackgroundAudio::Play() {
}
}

// Mix in menu sound effects
// Mix in menu sound effects. Terribly slow mixer but meh.
if (!plays_.empty()) {
for (int i = 0; i < sz * 2; i += 2) {
std::vector<PlayInstance>::iterator iter = plays_.begin();
Expand Down
2 changes: 1 addition & 1 deletion ext/native/ui/root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void SetSoundCallback(std::function<void(UISound)> func) {

void PlayUISound(UISound sound) {
if (soundCallback) {
soundCallback(UISound::SELECT);
soundCallback(sound);
}
}

Expand Down
1 change: 1 addition & 0 deletions ext/native/ui/root.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <functional>

#include "ui/ui_context.h"
#include "input/input_state.h"

Expand Down
4 changes: 4 additions & 0 deletions ext/native/ui/ui_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ bool UIScreen::key(const KeyInput &key) {
}

void UIScreen::TriggerFinish(DialogResult result) {
switch (result) {
case DialogResult::DR_BACK: UI::PlayUISound(UI::UISound::BACK); break;
case DialogResult::DR_OK: UI::PlayUISound(UI::UISound::CONFIRM); break;
}
screenManager()->finishDialog(this, result);
}

Expand Down
1 change: 1 addition & 0 deletions ext/native/ui/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ void Clickable::Click() {
UI::EventParams e{};
e.v = this;
OnClick.Trigger(e);
UI::PlayUISound(UI::UISound::CONFIRM);
};

void Clickable::FocusChanged(int focusFlags) {
Expand Down

0 comments on commit d3ec52b

Please sign in to comment.