From 55eb2844fd83f974b6f8b82a60fba31db768ff67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 2 Aug 2020 23:09:04 +0200 Subject: [PATCH] Hook up a couple more sounds. Unfortunately clickable back buttons now play both back and confirm sounds... --- UI/BackgroundAudio.cpp | 2 +- ext/native/ui/root.cpp | 2 +- ext/native/ui/root.h | 1 + ext/native/ui/ui_screen.cpp | 4 ++++ ext/native/ui/view.cpp | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/UI/BackgroundAudio.cpp b/UI/BackgroundAudio.cpp index 794992adc9..82cb981a9c 100644 --- a/UI/BackgroundAudio.cpp +++ b/UI/BackgroundAudio.cpp @@ -369,7 +369,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::iterator iter = plays_.begin(); diff --git a/ext/native/ui/root.cpp b/ext/native/ui/root.cpp index d65bfc0d33..5533359c7c 100644 --- a/ext/native/ui/root.cpp +++ b/ext/native/ui/root.cpp @@ -147,7 +147,7 @@ void SetSoundCallback(std::function func) { void PlayUISound(UISound sound) { if (soundCallback) { - soundCallback(UISound::SELECT); + soundCallback(sound); } } diff --git a/ext/native/ui/root.h b/ext/native/ui/root.h index 5d13c51e2d..97923f93e0 100644 --- a/ext/native/ui/root.h +++ b/ext/native/ui/root.h @@ -1,6 +1,7 @@ #pragma once #include + #include "ui/ui_context.h" #include "input/input_state.h" diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index 0a2a665e34..74e31c8601 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -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); } diff --git a/ext/native/ui/view.cpp b/ext/native/ui/view.cpp index d452b6a8a3..1aea855070 100644 --- a/ext/native/ui/view.cpp +++ b/ext/native/ui/view.cpp @@ -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) {