diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs new file mode 100644 index 00000000..012a0bab --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs @@ -0,0 +1,80 @@ +using AxibugEmuOnline.Client.ClientCore; +using System; +using System.Collections.Generic; +using UnityEngine; +using static AxibugEmuOnline.Client.ScreenScaler; + +namespace AxibugEmuOnline.Client +{ + public class InGameUI_Scaler : ExpandMenu + { + private List m_subMenus = new List(); + + public InGameUI_Scaler(InGameUI inGameUI) : base("屏幕比例", null) + { + m_subMenus.Add(new Scale(inGameUI, null)); + foreach (EnumScalerMode scaleModeValue in Enum.GetValues(typeof(EnumScalerMode))) + { + m_subMenus.Add(new Scale(inGameUI, scaleModeValue)); + } + } + + protected override List GetOptionMenus() + { + return m_subMenus; + } + + public class Scale : ExecuteMenu + { + private EnumScalerMode? m_mode; + private InGameUI m_gameUI; + + public override bool IsApplied + { + get + { + if (m_gameUI.Core.IsNull()) return false; + + var isSetMode = App.settings.ScreenScaler.IsSetMode(m_gameUI.Core.Platform); + + if (m_mode == null && !isSetMode) + { + return true; + } + else if (isSetMode && m_mode.HasValue) + { + var mode = App.settings.ScreenScaler.GetMode(m_gameUI.Core.Platform); + return mode == m_mode.Value; + } + else return false; + } + } + + public Scale(InGameUI inGameUI, EnumScalerMode? mode) : base(ModeToName(mode), null) + { + m_mode = mode; + m_gameUI = inGameUI; + } + + public override void OnExcute(OptionUI optionUI, ref bool cancelHide) + { + App.settings.ScreenScaler.SetMode(m_gameUI.Core.Platform, m_mode); + } + + static string ModeToName(EnumScalerMode? mode) + { + if (mode == null) return "使用全局设置"; + else + { + switch (mode.Value) + { + case EnumScalerMode.FullScreen: return "全屏"; + case EnumScalerMode.Raw: return "原始尺寸"; + case EnumScalerMode.Fix: return "适应"; + default: throw new Exception($"Not Support Mode : {mode.Value}"); + } + } + } + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta new file mode 100644 index 00000000..6cf22a5d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 2703b2b6867eb344386509ff36bf1459 \ No newline at end of file