From 37fe958376a003a36154bf9e4b456397f5c254b1 Mon Sep 17 00:00:00 2001
From: client_Hale <339726288@qq.com>
Date: 星期五, 12 四月 2019 19:46:18 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.87:10010/r/snxxz_scripts

---
 UI/Common/FunctionButtonGroup.cs |   66 +++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 24 deletions(-)

diff --git a/UI/Common/FunctionButtonGroup.cs b/UI/Common/FunctionButtonGroup.cs
index 4f0ddc3..af06211 100644
--- a/UI/Common/FunctionButtonGroup.cs
+++ b/UI/Common/FunctionButtonGroup.cs
@@ -12,10 +12,12 @@
 
     public class FunctionButtonGroup : MonoBehaviour
     {
+        [SerializeField] ScrollRect m_ScrollRect;
+
         public int unLockedCount {
             get {
                 var count = 0;
-                foreach (var button in toggleButtons.Values)
+                foreach (var button in functionButtons.Values)
                 {
                     if (button.state != TitleBtnState.Locked)
                     {
@@ -29,57 +31,57 @@
 
         int currentOrder = 0;
         List<int> orders = new List<int>();
-        Dictionary<int, FunctionButton> toggleButtons = new Dictionary<int, FunctionButton>();
+        Dictionary<int, FunctionButton> functionButtons = new Dictionary<int, FunctionButton>();
 
-        public void Register(FunctionButton _toggleButton)
+        public void Register(FunctionButton button)
         {
-            toggleButtons[_toggleButton.order] = _toggleButton;
-            if (!orders.Contains(_toggleButton.order))
+            functionButtons[button.order] = button;
+            if (!orders.Contains(button.order))
             {
-                orders.Add(_toggleButton.order);
+                orders.Add(button.order);
                 orders.Sort(OrderCompare);
             }
         }
 
-        public void UnRegister(FunctionButton _toggleButton)
+        public void UnRegister(FunctionButton button)
         {
-            if (toggleButtons.ContainsKey(_toggleButton.order))
+            if (functionButtons.ContainsKey(button.order))
             {
-                toggleButtons.Remove(_toggleButton.order);
+                functionButtons.Remove(button.order);
             }
 
-            if (orders.Contains(_toggleButton.order))
+            if (orders.Contains(button.order))
             {
-                orders.Remove(_toggleButton.order);
+                orders.Remove(button.order);
                 orders.Sort(OrderCompare);
             }
 
         }
 
-        public void NotifyToggleOn(FunctionButton _toggleButton)
+        public void NotifyToggleOn(FunctionButton button)
         {
-            if (_toggleButton.state == TitleBtnState.Click)
+            if (button.state == TitleBtnState.Click)
             {
-                currentOrder = _toggleButton.order;
+                currentOrder = button.order;
                 for (int i = 0; i < orders.Count; i++)
                 {
-                    var toggleButton = toggleButtons[orders[i]];
-                    if (toggleButton != _toggleButton && toggleButton.state != TitleBtnState.Locked)
+                    var functionButton = functionButtons[orders[i]];
+                    if (functionButton != button && functionButton.state != TitleBtnState.Locked)
                     {
-                        toggleButton.state = TitleBtnState.Normal;
+                        functionButton.state = TitleBtnState.Normal;
                     }
                 }
             }
         }
 
-        public void TriggerByOrder(int _order)
+        public void TriggerByOrder(int targetOrder)
         {
             for (int i = 0; i < orders.Count; i++)
             {
                 var order = orders[i];
-                if (order == _order)
+                if (order == targetOrder)
                 {
-                    toggleButtons[order].Invoke(true);
+                    functionButtons[order].Invoke(true);
                     break;
                 }
             }
@@ -104,9 +106,9 @@
                 }
 
                 var next = orders[index];
-                if (toggleButtons[next].state != TitleBtnState.Locked)
+                if (functionButtons[next].state != TitleBtnState.Locked)
                 {
-                    toggleButtons[next].Invoke(false);
+                    functionButtons[next].Invoke(false);
                     break;
                 }
             }
@@ -132,9 +134,9 @@
                 }
 
                 var next = orders[index];
-                if (toggleButtons[next].state != TitleBtnState.Locked)
+                if (functionButtons[next].state != TitleBtnState.Locked)
                 {
-                    toggleButtons[next].Invoke(false);
+                    functionButtons[next].Invoke(false);
                     break;
                 }
             }
@@ -150,6 +152,22 @@
             return orders.Count > 0 && currentOrder == orders[orders.Count - 1];
         }
 
+        public void GotoOrder(int order)
+        {
+            if (m_ScrollRect != null)
+            {
+                var index = orders.IndexOf(order);
+                if (m_ScrollRect.horizontal)
+                {
+                    m_ScrollRect.horizontalNormalizedPosition = (float)index / orders.Count;
+                }
+                else
+                {
+                    m_ScrollRect.verticalNormalizedPosition = (float)index / orders.Count;
+                }
+            }
+        }
+
         private int OrderCompare(int a, int b)
         {
             return a < b ? -1 : 1;

--
Gitblit v1.8.0