(client) feat:实现热重载,实现多维度,实现武器,实现掉落物,实现状态UI,实现攻击AI (#44)
Co-authored-by: zzdxxz <2079238449@qq.com> Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
75
Client/Assets/Scripts/UI/SettingUI.cs
Normal file
75
Client/Assets/Scripts/UI/SettingUI.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System.Globalization;
|
||||
using Base;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class SettingUI : UIBase
|
||||
{
|
||||
[SerializeField] private Scrollbar globalVolume;
|
||||
[SerializeField] private Toggle developerMode;
|
||||
[SerializeField] private Toggle friendlyFire;
|
||||
[SerializeField] private Toggle showMiniMap;
|
||||
[SerializeField] private TMP_Dropdown windowMode;
|
||||
[SerializeField] private TMP_Dropdown windowResolution;
|
||||
[SerializeField] private TMP_InputField progressStepDuration;
|
||||
[SerializeField] private TMP_InputField exitAnimationDuration;
|
||||
|
||||
Base.Setting.GameSettings currentSettings;
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
currentSettings = Base.Setting.Instance.CurrentSettings;
|
||||
globalVolume.value = currentSettings.globalVolume;
|
||||
developerMode.isOn = currentSettings.developerMode;
|
||||
friendlyFire.isOn = currentSettings.friendlyFire;
|
||||
showMiniMap.isOn = currentSettings.showMiniMap;
|
||||
|
||||
progressStepDuration.text = currentSettings.progressStepDuration.ToString(CultureInfo.InvariantCulture);
|
||||
exitAnimationDuration.text = currentSettings.exitAnimationDuration.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
windowResolution.ClearOptions();
|
||||
var options = new System.Collections.Generic.List<TMP_Dropdown.OptionData>();
|
||||
foreach (var resolution in Base.Setting.CommonResolutions)
|
||||
{
|
||||
options.Add(new TMP_Dropdown.OptionData(resolution.ToString()));
|
||||
}
|
||||
windowResolution.AddOptions(options);
|
||||
if (currentSettings.windowResolution != null)
|
||||
{
|
||||
var resolutionIndex = System.Array.FindIndex(Base.Setting.CommonResolutions, r => r == currentSettings.windowResolution);
|
||||
windowResolution.value = resolutionIndex >= 0 ? resolutionIndex : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
windowResolution.value = 0;
|
||||
}
|
||||
}
|
||||
public void CancelSettings()
|
||||
{
|
||||
UIInputControl.Instance.Hide(this);
|
||||
}
|
||||
public void ApplySettings()
|
||||
{
|
||||
currentSettings.globalVolume = globalVolume.value;
|
||||
currentSettings.developerMode = developerMode.isOn;
|
||||
currentSettings.friendlyFire = friendlyFire.isOn;
|
||||
currentSettings.currentWindowMode = (Base.Setting.WindowMode)windowMode.value;
|
||||
currentSettings.windowResolution = Base.Setting.CommonResolutions[windowResolution.value];
|
||||
currentSettings.progressStepDuration = float.Parse(progressStepDuration.text, CultureInfo.InvariantCulture);
|
||||
currentSettings.exitAnimationDuration = float.Parse(exitAnimationDuration.text, CultureInfo.InvariantCulture);
|
||||
currentSettings.showMiniMap = showMiniMap.isOn;
|
||||
Base.Setting.Instance.CurrentSettings = currentSettings;
|
||||
Base.Setting.Instance.Apply();
|
||||
}
|
||||
public void EnterSetting()
|
||||
{
|
||||
ApplySettings();
|
||||
UIInputControl.Instance.Hide(this);
|
||||
Base.Setting.Instance.SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user