game(ui,scripts): interim options menu
This commit is contained in:
parent
b9141cf5ee
commit
43399cf933
|
@ -16,6 +16,11 @@ public class ScreenOptionsMenu : CommonMenu
|
|||
/// </summary>
|
||||
public Button ButtonReturn;
|
||||
|
||||
/// <summary>
|
||||
/// slider for master (music + sfx) volume
|
||||
/// </summary>
|
||||
public Slider SliderAudioMaster;
|
||||
|
||||
/// <summary>
|
||||
/// slider for music volume
|
||||
/// </summary>
|
||||
|
@ -25,7 +30,7 @@ public class ScreenOptionsMenu : CommonMenu
|
|||
/// slider for sfx volume
|
||||
/// </summary>
|
||||
public Slider SliderAudioSfx;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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<Slider>("Music");
|
||||
SliderAudioMaster = UI.Q<Slider>("MasterSlider");
|
||||
// TODO: and set the initial value to the current music volume
|
||||
// SliderAudioMusic.value = Audio.GetMusicVolume() * 100;
|
||||
// and subscribe appropriate functions
|
||||
SliderAudioMaster.RegisterCallback<ChangeEvent<float>>(OptionSetMasterVolume);
|
||||
|
||||
// get the music slider from the ui root
|
||||
SliderAudioMusic = UI.Q<Slider>("MusicSlider");
|
||||
// TODO: and set the initial value to the current music volume
|
||||
// SliderAudioMusic.value = Audio.GetMusicVolume() * 100;
|
||||
// and subscribe appropriate functions
|
||||
SliderAudioMusic.RegisterCallback<ChangeEvent<float>>(OptionSetMusicVolume);
|
||||
|
||||
|
||||
// get the sfx slider from the ui root
|
||||
SliderAudioSfx = UI.Q<Slider>("SFX");
|
||||
SliderAudioSfx = UI.Q<Slider>("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);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// handle music volume slider change,
|
||||
/// sets the music channel volume in the audio manager appropriately
|
||||
/// </summary>
|
||||
/// <param name="evt"></param>
|
||||
/// <param name="evt">change event</param>
|
||||
private void OptionSetMasterVolume(ChangeEvent<float> evt)
|
||||
{
|
||||
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
|
||||
// Audio.SetMusicVolume(evt.newValue / 100);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// handle music volume slider change,
|
||||
/// sets the music channel volume in the audio manager appropriately
|
||||
/// </summary>
|
||||
/// <param name="evt">change event</param>
|
||||
private void OptionSetMusicVolume(ChangeEvent<float> evt)
|
||||
{
|
||||
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
|
||||
|
@ -81,7 +104,7 @@ private void OptionSetMusicVolume(ChangeEvent<float> evt)
|
|||
/// handle sfx volume slider change,
|
||||
/// sets the sfx channel volume in the audio manager appropriately
|
||||
/// </summary>
|
||||
/// <param name="evt"></param>
|
||||
/// <param name="evt">change event</param>
|
||||
private void OptionSetSfxVolume(ChangeEvent<float> evt)
|
||||
{
|
||||
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
<ui:VisualElement name="HoriHolder" style="flex-grow: 1; flex-direction: column; max-height: 60%; margin-left: 10%; margin-right: 10%;">
|
||||
<ui:VisualElement name="Logospace" style="flex-grow: 1; width: auto; flex-direction: row; padding-bottom: 6%; height: 50%; min-height: 50%;" />
|
||||
<ui:VisualElement name="Buttonspace" style="flex-grow: 1; width: 50%; min-width: 50%; height: 50%; min-height: 50%; align-items: center; justify-content: flex-end; align-self: center;">
|
||||
<ui:Slider label="Music" high-value="100" name="Music" style="justify-content: space-around; align-items: stretch; align-self: stretch;" />
|
||||
<ui:Slider label="Effects" high-value="100" name="SFX" style="align-self: stretch; padding-bottom: 0; margin-bottom: 10%; justify-content: space-around;" />
|
||||
<ui:Slider label="Master" high-value="100" name="MasterSlider" style="justify-content: space-around; align-items: stretch; align-self: stretch;" />
|
||||
<ui:Slider label="Music" high-value="100" name="MusicSlider" style="justify-content: space-around; align-items: stretch; align-self: stretch;" />
|
||||
<ui:Slider label="Effects" high-value="100" name="SFXSlider" style="align-self: stretch; padding-bottom: 0; margin-bottom: 10%; justify-content: space-around;" />
|
||||
<ui:Button text="Return" parse-escape-sequences="true" display-tooltip-when-elided="true" name="ButtonReturn" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
|
|
Reference in a new issue