From b4f244fca02c24eb02d7b200a3ff1d0d2e17281a Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期五, 24 八月 2018 11:49:16 +0800
Subject: [PATCH] 2824 1.0.15【前端】系统设置的标签页新增最大帧数选项

---
 Core/GameEngine/Login/Launch.cs       |    2 
 System/SystemSetting/SystemSetting.cs |   46 +++++++++++++++++-----
 System/SystemSetting/SystemSetWin.cs  |   28 +++++++-------
 3 files changed, 50 insertions(+), 26 deletions(-)

diff --git a/Core/GameEngine/Login/Launch.cs b/Core/GameEngine/Login/Launch.cs
index 4d48dcb..d420a09 100644
--- a/Core/GameEngine/Login/Launch.cs
+++ b/Core/GameEngine/Login/Launch.cs
@@ -43,7 +43,7 @@
         SoundPlayer.CreateSoundPlayer();
         SoundPlayer.Instance.PlayLoginMusic();
         SystemSetting.Instance.SetSoundVolume(SystemSetting.Instance.GetSoundVolume());
-        SystemSetting.Instance.SetVSyncCount(SystemSetting.Instance.GetVSyncCount());
+        SystemSetting.Instance.SetGameFrame(SystemSetting.Instance.GetGameFrame());
 
         SDKUtility.Instance.Init();
         GameObjectPoolManager.Instance.gameObject.name = "GameObjectPool";
diff --git a/System/SystemSetting/SystemSetWin.cs b/System/SystemSetting/SystemSetWin.cs
index 35b357c..ad86884 100644
--- a/System/SystemSetting/SystemSetWin.cs
+++ b/System/SystemSetting/SystemSetWin.cs
@@ -50,7 +50,7 @@
             m_HighQuality.AddListener(OnSetQualityHigh);
             m_MediumQuality.AddListener(OnSetQualityMedium);
             m_LowQuality.AddListener(OnSetQualityLow);
-            m_SixtyFrame.AddListener(SwitchVSyncCount);
+            m_SixtyFrame.AddListener(SwitchGameFrame);
 
             m_OtherPlayer.AddListener(OnShowOrHideOtherPlayers);
             m_Monster.AddListener(OnShowOrHideMonsters);
@@ -82,7 +82,7 @@
             UpdateToggleSkin(m_OtherPlayer);
             UpdateToggleSkin(m_Monster);
 
-            m_SixtyFrame.isOn = SystemSetting.Instance.GetVSyncCount() == 1;
+            m_SixtyFrame.isOn = SystemSetting.Instance.GetGameFrame() == GameFrame.FullFrame;
 
             var serverName = ServerListCenter.Instance.GetServerData(ServerListCenter.Instance.currentServer.region_flag).name;
             var playerAccount = PlayerDatas.Instance.baseData.AccID.Split('@');
@@ -116,7 +116,7 @@
 
             loginModel.accountBindOkEvent += UpdateAccountBindTitle;
             SDKUtility.Instance.onFreePlatfromDoIDAuthenticationOk += OnAuthenticationOk;
-            SystemSetting.Instance.vSyncCountChangeEvent += OnSwitchVSyncCount;
+            SystemSetting.Instance.gameFrameChangeEvent += OnSwitchGameFrame;
             SystemSetting.Instance.playerSyncCountChangeEvent += OnPlayerSyncCountChange;
 
             isInited = true;
@@ -127,7 +127,7 @@
             isInited = false;
             loginModel.accountBindOkEvent -= UpdateAccountBindTitle;
             SDKUtility.Instance.onFreePlatfromDoIDAuthenticationOk -= OnAuthenticationOk;
-            SystemSetting.Instance.vSyncCountChangeEvent -= OnSwitchVSyncCount;
+            SystemSetting.Instance.gameFrameChangeEvent -= OnSwitchGameFrame;
             SystemSetting.Instance.playerSyncCountChangeEvent -= OnPlayerSyncCountChange;
             SystemSetting.Instance.SetPlayerSyncCount(playerSyncCountRef);
         }
@@ -182,7 +182,7 @@
                 SystemSetting.Instance.SetQualityLevel(GameQuality.Low);
                 if (isInited)
                 {
-                    SystemSetting.Instance.SetVSyncCount(2);
+                    SystemSetting.Instance.SetGameFrame(GameFrame.HalfFrame);
                     SystemSetting.Instance.SetPlayerSyncCount(5);
                 }
             }
@@ -190,25 +190,25 @@
             UpdateToggleSkin(m_LowQuality);
         }
 
-        private void SwitchVSyncCount()
+        private void SwitchGameFrame()
         {
-            var currentVSyncCount = SystemSetting.Instance.GetVSyncCount();
-            switch (currentVSyncCount)
+            var gameFrame = SystemSetting.Instance.GetGameFrame();
+            switch (gameFrame)
             {
-                case 1:
-                    SystemSetting.Instance.SetVSyncCount(2);
+                case GameFrame.HalfFrame:
+                    SystemSetting.Instance.SetGameFrame(GameFrame.FullFrame);
                     break;
-                case 2:
-                    SystemSetting.Instance.SetVSyncCount(1);
+                case GameFrame.FullFrame:
+                    SystemSetting.Instance.SetGameFrame(GameFrame.HalfFrame);
                     break;
                 default:
                     break;
             }
         }
 
-        private void OnSwitchVSyncCount()
+        private void OnSwitchGameFrame()
         {
-            m_SixtyFrame.isOn = SystemSetting.Instance.GetVSyncCount() == 1;
+            m_SixtyFrame.isOn = SystemSetting.Instance.GetGameFrame() == GameFrame.FullFrame;
         }
 
         private void OnShowOrHideOtherPlayers(bool _value)
diff --git a/System/SystemSetting/SystemSetting.cs b/System/SystemSetting/SystemSetting.cs
index bb1fc38..f169b15 100644
--- a/System/SystemSetting/SystemSetting.cs
+++ b/System/SystemSetting/SystemSetting.cs
@@ -12,7 +12,7 @@
     const string SOUND_VOLUME_KEY = "SoundRatioKey";  //闊充箰
     const string SOUND_EFFECT_KEY = "SoundEffect"; //闊虫晥
     const string FPS_KEY = "FPSKey";
-    const string VSYNC_KEY = "GameVSyncCountSetting";//鍨傜洿鍚屾鐜�
+    const string GAMEFRAME_KEY = "GameFrameSetting";//鍨傜洿鍚屾鐜�
 
     public Dictionary<SystemSwitch, bool> systemSettings = new Dictionary<SystemSwitch, bool>();
 
@@ -21,7 +21,7 @@
     public event Action<SystemSwitch, bool> OnSettingChanged;
     public event Action qualityLevelChangeEvent;
     public event Action playerSyncCountChangeEvent;
-    public event Action vSyncCountChangeEvent;
+    public event Action gameFrameChangeEvent;
 
     public SystemSetting()
     {
@@ -54,19 +54,28 @@
         return LocalSave.GetFloat(SOUND_EFFECT_KEY, 1);
     }
 
-    public void SetVSyncCount(int _vSync)
+    public void SetGameFrame(GameFrame _frame)
     {
-        LocalSave.SetInt(VSYNC_KEY, QualitySettings.vSyncCount = Mathf.Clamp(_vSync, 0, 2));
-
-        if (vSyncCountChangeEvent != null)
+        LocalSave.SetInt(GAMEFRAME_KEY, (int)_frame);
+        switch (_frame)
         {
-            vSyncCountChangeEvent();
+            case GameFrame.FullFrame:
+                SetFPSLimit(60);
+                break;
+            case GameFrame.HalfFrame:
+                SetFPSLimit(30);
+                break;
+        }
+
+        if (gameFrameChangeEvent != null)
+        {
+            gameFrameChangeEvent();
         }
     }
 
-    public int GetVSyncCount()
+    public GameFrame GetGameFrame()
     {
-        return LocalSave.GetInt(VSYNC_KEY, 2);
+        return (GameFrame)LocalSave.GetInt(GAMEFRAME_KEY, (int)GameFrame.HalfFrame);
     }
 
     public void SetSystemSettingSwitch(SystemSwitch type, bool _value)
@@ -219,12 +228,20 @@
 
     public void SetFPSLimit(int _fps)
     {
-        LocalSave.SetInt(FPS_KEY, Application.targetFrameRate = Mathf.Clamp(_fps, 30, 60));
+        Application.targetFrameRate = Mathf.Clamp(_fps, 30, 60);
     }
 
     public int GetFPSLimit()
     {
-        return LocalSave.GetInt(FPS_KEY, 30);
+        switch (GetGameFrame())
+        {
+            case GameFrame.HalfFrame:
+                return 30;
+            case GameFrame.FullFrame:
+                return 60;
+            default:
+                return 30;
+        }
     }
 
     public void LetFPSUnLimit()
@@ -264,4 +281,11 @@
     Low = 0,
     Medium = 1,
     High = 2,
+}
+
+public enum GameFrame
+{
+    Free = 0,
+    HalfFrame = 1,
+    FullFrame = 2,
 }
\ No newline at end of file

--
Gitblit v1.8.0