HeavenStudio/Assets/Scripts/LevelEditor/SettingsDialog/Tabs/DispAudioSettings.cs

83 lines
2.8 KiB
C#
Raw Normal View History

2022-07-09 02:11:55 +00:00
using System.Collections.Generic;
using UnityEngine;
2022-07-10 21:39:14 +00:00
using UnityEngine.UI;
2022-07-09 02:11:55 +00:00
using TMPro;
namespace HeavenStudio.Editor
{
2022-09-02 00:57:47 +00:00
public class DispAudioSettings : TabsContent
2022-07-09 02:11:55 +00:00
{
public TMP_Dropdown resolutionsDropdown;
public GameObject customSetter;
public TMP_InputField widthInputField, heightInputField;
2022-07-10 21:39:14 +00:00
public Slider volSlider;
public TMP_InputField volLabel;
2022-07-09 02:11:55 +00:00
private void Start() {
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
var vals = GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING;
for (int i = 0; i < vals.Length; i++)
{
TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData();
optionData.text = vals[i];
dropDownData.Add(optionData);
}
resolutionsDropdown.AddOptions(dropDownData);
resolutionsDropdown.value = GlobalGameManager.ScreenSizeIndex;
resolutionsDropdown.onValueChanged.AddListener(delegate
{
GlobalGameManager.ScreenSizeIndex = resolutionsDropdown.value;
customSetter.SetActive(resolutionsDropdown.value == GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING.Length - 1);
});
widthInputField.onEndEdit.AddListener(delegate
{
GlobalGameManager.CustomScreenWidth = System.Math.Max(int.Parse(widthInputField.text), 64);
widthInputField.text = GlobalGameManager.CustomScreenWidth.ToString();
});
heightInputField.onEndEdit.AddListener(delegate
{
GlobalGameManager.CustomScreenHeight = System.Math.Max(int.Parse(heightInputField.text), 64);
heightInputField.text = GlobalGameManager.CustomScreenHeight.ToString();
});
2022-07-10 21:39:14 +00:00
volSlider.value = GlobalGameManager.MasterVolume;
volLabel.text = System.Math.Round(volSlider.value * 100, 2).ToString();
2022-07-09 02:11:55 +00:00
}
public void WindowFullScreen()
{
GlobalGameManager.WindowFullScreen();
}
public void WindowConfirmSize()
{
GlobalGameManager.ChangeScreenSize();
}
2022-07-10 21:39:14 +00:00
public void OnVolSliderChanged()
{
GlobalGameManager.ChangeMasterVolume(volSlider.value);
volLabel.text = System.Math.Round(volSlider.value * 100, 2).ToString();
}
public void OnVolLabelChanged()
{
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text) / 100f, 2);
2022-07-10 21:39:14 +00:00
GlobalGameManager.ChangeMasterVolume(volSlider.value);
}
2022-09-02 00:57:47 +00:00
public override void OnOpenTab()
{
}
public override void OnCloseTab()
{
}
2022-07-09 02:11:55 +00:00
}
}