From 43399cf933c8bff8921a45f351e30e946f1f8bf3 Mon Sep 17 00:00:00 2001 From: sippy-thinks Date: Sun, 11 Aug 2024 14:52:08 +0800 Subject: [PATCH] game(ui,scripts): interim options menu --- .../Assets/Scripts/ScreenOptionsMenu.cs | 37 +++++++++++++++---- .../Interfaces/ScreenOptionsMenu.uxml | 5 ++- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/RunningLateGame/Assets/Scripts/ScreenOptionsMenu.cs b/RunningLateGame/Assets/Scripts/ScreenOptionsMenu.cs index 0912fb6..985a3c2 100644 --- a/RunningLateGame/Assets/Scripts/ScreenOptionsMenu.cs +++ b/RunningLateGame/Assets/Scripts/ScreenOptionsMenu.cs @@ -16,6 +16,11 @@ public class ScreenOptionsMenu : CommonMenu /// public Button ButtonReturn; + /// + /// slider for master (music + sfx) volume + /// + public Slider SliderAudioMaster; + /// /// slider for music volume /// @@ -25,7 +30,7 @@ public class ScreenOptionsMenu : CommonMenu /// slider for sfx volume /// public Slider SliderAudioSfx; - + /// /// function to associate a display state with the menu, /// and subscribe button events to their respective functions @@ -42,14 +47,21 @@ public override void OnEnable() ButtonReturn.clicked += OptionReturnToMainMenu; // get the music slider from the ui root - SliderAudioMusic = UI.Q("Music"); + SliderAudioMaster = UI.Q("MasterSlider"); + // TODO: and set the initial value to the current music volume + // SliderAudioMusic.value = Audio.GetMusicVolume() * 100; + // and subscribe appropriate functions + SliderAudioMaster.RegisterCallback>(OptionSetMasterVolume); + + // get the music slider from the ui root + SliderAudioMusic = UI.Q("MusicSlider"); // TODO: and set the initial value to the current music volume // SliderAudioMusic.value = Audio.GetMusicVolume() * 100; // and subscribe appropriate functions SliderAudioMusic.RegisterCallback>(OptionSetMusicVolume); - + // get the sfx slider from the ui root - SliderAudioSfx = UI.Q("SFX"); + SliderAudioSfx = UI.Q("SFXSlider"); // TODO: and set the initial value to the current sfx volume // SliderAudioSfx.value = Audio.GetSfxVolume() * 100; // and subscribe appropriate functions @@ -65,12 +77,23 @@ private void OptionReturnToMainMenu() // return to the main menu Game.SetDisplayState(GameManager.DisplayState.ScreenMainMenu); } - + /// /// handle music volume slider change, /// sets the music channel volume in the audio manager appropriately /// - /// + /// change event + private void OptionSetMasterVolume(ChangeEvent evt) + { + // TODO: slider is from 0 to 100, convert to 0 to 1, and set + // Audio.SetMusicVolume(evt.newValue / 100); + } + + /// + /// handle music volume slider change, + /// sets the music channel volume in the audio manager appropriately + /// + /// change event private void OptionSetMusicVolume(ChangeEvent evt) { // TODO: slider is from 0 to 100, convert to 0 to 1, and set @@ -81,7 +104,7 @@ private void OptionSetMusicVolume(ChangeEvent evt) /// handle sfx volume slider change, /// sets the sfx channel volume in the audio manager appropriately /// - /// + /// change event private void OptionSetSfxVolume(ChangeEvent evt) { // TODO: slider is from 0 to 100, convert to 0 to 1, and set diff --git a/RunningLateGame/Assets/UI Toolkit/Interfaces/ScreenOptionsMenu.uxml b/RunningLateGame/Assets/UI Toolkit/Interfaces/ScreenOptionsMenu.uxml index 13a4184..0beaef7 100644 --- a/RunningLateGame/Assets/UI Toolkit/Interfaces/ScreenOptionsMenu.uxml +++ b/RunningLateGame/Assets/UI Toolkit/Interfaces/ScreenOptionsMenu.uxml @@ -4,8 +4,9 @@ - - + + +