コード例 #1
0
            public static void Prefix(QuickSlotPanelSwitcher __instance, ref QuickSlotPanel[]  ___m_quickSlotPanels)
            {
                // For simplicity we need at least 4 more slots
                if (SlotsToAdd < 4)
                {
                    return;
                }

                var self = __instance;

                var length = ___m_quickSlotPanels.Length + 1;

                Array.Resize(ref ___m_quickSlotPanels, length);

                // Add the new tab

                Transform LT = ___m_quickSlotPanels[0].transform;

                EditorQuickSlotDisplayPlacer[] quickSlotsLT = LT.GetComponentsInChildren <EditorQuickSlotDisplayPlacer>();
                foreach (EditorQuickSlotDisplayPlacer displayPlacer in quickSlotsLT)
                {
                    displayPlacer.IsTemplate = true;
                }
                GameObject newTab = GameObject.Instantiate <GameObject>(LT.gameObject);

                newTab.transform.parent   = LT.parent;
                newTab.transform.position = LT.transform.position;

                EditorQuickSlotDisplayPlacer[] quickSlotsNewTab = newTab.GetComponentsInChildren <EditorQuickSlotDisplayPlacer>();
                for (int i = 0; i < quickSlotsNewTab.Length; i++)
                {
                    quickSlotsNewTab[i].RefSlotID  = 12 + i;
                    quickSlotsNewTab[i].IsTemplate = false;
                }
                QuickSlotDisplay[] quickSlotsDisplayNewTab = newTab.GetComponentsInChildren <QuickSlotDisplay>();
                for (int i = 0; i < quickSlotsDisplayNewTab.Length; i++)
                {
                    quickSlotsDisplayNewTab[i].RefSlotID = 12 + i;
                }

                foreach (EditorQuickSlotDisplayPlacer displayPlacer in quickSlotsLT)
                {
                    displayPlacer.IsTemplate = false;
                }


                ___m_quickSlotPanels[length - 1] = newTab.GetComponent <QuickSlotPanel>();
            }
コード例 #2
0
            public static bool Prefix(QuickSlotPanelSwitcher __instance, ref QuickSlotPanel[] ___m_quickSlotPanels, ref int ___m_currentlyDisplayedPanel, ref Image[] ___m_panelIndicators)
            {
                // For simplicity we need at least 4 more slots
                if (SlotsToAdd < 4)
                {
                    return(true);
                }

                var self = __instance;

                if (self.LocalCharacter != null)
                {
                    int  previouslyDisplayedPanel = ___m_currentlyDisplayedPanel;
                    bool flag = false;
                    if (self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection1 && !self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection2)
                    {
                        ___m_currentlyDisplayedPanel = 0;
                        flag = true;
                    }
                    else if (!self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection1 && self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection2)
                    {
                        ___m_currentlyDisplayedPanel = 1;
                        flag = true;
                    }
                    else if (self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection1 && self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection2)
                    {
                        flag = true;
                        if (SlotsToAdd >= 4)
                        {
                            ___m_currentlyDisplayedPanel = 2;
                        }
                        else
                        {
                            if (self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection1LastTime > self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection2LastTime)
                            {
                                ___m_currentlyDisplayedPanel = 0;
                            }
                            else if (self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection1LastTime < self.LocalCharacter.QuickSlotMngr.ShowQuickSlotSection2LastTime)
                            {
                                ___m_currentlyDisplayedPanel = 1;
                            }
                        }
                    }
                    Color color = Color.white;
                    for (int i = 0; i < ___m_quickSlotPanels.Length; i++)
                    {
                        color = Color.white;
                        if (i == ___m_currentlyDisplayedPanel)
                        {
                            if (flag)
                            {
                                color = self.ActiveColor;
                            }
                            if (___m_quickSlotPanels[i])
                            {
                                if (___m_quickSlotPanels[i].gameObject.activeSelf)
                                {
                                    ___m_quickSlotPanels[i].SetActive(true);
                                }
                                if (previouslyDisplayedPanel != ___m_currentlyDisplayedPanel)
                                {
                                    ___m_quickSlotPanels[i].ShowFront(false);
                                }
                            }
                        }
                        else
                        {
                            color = self.DisabledColor;
                            if (___m_quickSlotPanels[i])
                            {
                                if (___m_quickSlotPanels[i].gameObject.activeSelf)
                                {
                                    ___m_quickSlotPanels[i].SetActive(false);
                                }
                                if (i == previouslyDisplayedPanel)
                                {
                                    ___m_quickSlotPanels[i].PutBack(false);
                                }
                            }
                        }
                    }
                    if (___m_currentlyDisplayedPanel == 2)
                    {
                        if (flag == true)
                        {
                            color = self.ActiveColor;
                        }
                        else
                        {
                            color = self.DisabledColor;
                        }
                        for (int i = 0; i < ___m_quickSlotPanels.Length - 1; i++)
                        {
                            if (___m_panelIndicators[i] && ___m_panelIndicators[i].color != color)
                            {
                                ___m_panelIndicators[i].color = Vector4.MoveTowards(___m_panelIndicators[i].color, color, 5f * Time.deltaTime);
                            }
                        }
                    }
                    else if (___m_currentlyDisplayedPanel < 2)
                    {
                        for (int i = 0; i < ___m_quickSlotPanels.Length - 1; i++)
                        {
                            if (i == ___m_currentlyDisplayedPanel && flag == true)
                            {
                                color = self.ActiveColor;
                            }
                            else if (i != ___m_currentlyDisplayedPanel)
                            {
                                color = self.DisabledColor;
                            }

                            if (___m_panelIndicators[i] && ___m_panelIndicators[i].color != color)
                            {
                                ___m_panelIndicators[i].color = Vector4.MoveTowards(___m_panelIndicators[i].color, color, 5f * Time.deltaTime);
                            }
                        }
                    }
                }


                return(false);
            }