Invalidate() public method

Invalidating the panel should reset its alpha.
public Invalidate ( bool includeChildren ) : void
includeChildren bool
return void
Exemplo n.º 1
0
        public static UICheckBox CreateIconToggle(UIComponent parent, string atlas, string checkedSprite, string uncheckedSprite)
        {
            UICheckBox checkBox = parent.AddUIComponent <UICheckBox>();

            checkBox.width        = 35f;
            checkBox.height       = 35f;
            checkBox.clipChildren = true;

            UIPanel panel = checkBox.AddUIComponent <UIPanel>();

            panel.atlas            = GetAtlas("Ingame");
            panel.backgroundSprite = "IconPolicyBaseRect";
            panel.size             = checkBox.size;
            panel.relativePosition = Vector3.zero;

            checkBox.eventCheckChanged += (c, b) =>
            {
                if (checkBox.isChecked)
                {
                    panel.backgroundSprite = "IconPolicyBaseRect";
                }
                else
                {
                    panel.backgroundSprite = "IconPolicyBaseRectDisabled";
                }
                panel.Invalidate();
            };

            checkBox.eventMouseEnter += (c, p) =>
            {
                panel.backgroundSprite = "IconPolicyBaseRectHovered";
            };

            checkBox.eventMouseLeave += (c, p) =>
            {
                if (checkBox.isChecked)
                {
                    panel.backgroundSprite = "IconPolicyBaseRect";
                }
                else
                {
                    panel.backgroundSprite = "IconPolicyBaseRectDisabled";
                }
            };

            UISprite sprite = panel.AddUIComponent <UISprite>();

            sprite.atlas            = GetAtlas(atlas);
            sprite.spriteName       = uncheckedSprite;
            sprite.size             = checkBox.size;
            sprite.relativePosition = Vector3.zero;

            checkBox.checkedBoxObject = sprite.AddUIComponent <UISprite>();
            ((UISprite)checkBox.checkedBoxObject).atlas      = sprite.atlas;
            ((UISprite)checkBox.checkedBoxObject).spriteName = checkedSprite;
            checkBox.checkedBoxObject.size             = checkBox.size;
            checkBox.checkedBoxObject.relativePosition = Vector3.zero;

            return(checkBox);
        }
 private void ApplyToIconPanel(UIPanel groupPanel, IconPanelModifier modifier, bool verticalScroll)
 {
     if (groupPanel == null)
     {
         return;
     }
     if (modifier == null)
     {
         return;
     }
     try{                                                      //seperator panels do not have UIScrollablePanels nor UIScrollbars
         UITabContainer tabContainer = groupPanel.GetComponentInChildren <UITabContainer>();
         foreach (UIComponent comp in tabContainer.components) //for each displayable panel of icons
         {
             if (comp is UIPanel)
             {
                 UIPanel           panel = comp as UIPanel;
                 UIScrollablePanel sp    = panel.GetComponentInChildren <UIScrollablePanel>();
                 UIScrollbar       sb    = panel.GetComponentInChildren <UIScrollbar>();
                 modifier.Invoke(panel, sp, sb, verticalScroll);
                 panel.Invalidate();
                 sp.Invalidate();
                 sb.Invalidate();
             }
         }
         tabContainer.Invalidate();
     }catch (Exception e) {
         //Debug.Print(groupPanel,e);
     }
 }
Exemplo n.º 3
0
 static public int Invalidate(IntPtr l)
 {
     try {
         UIPanel        self = (UIPanel)checkSelf(l);
         System.Boolean a1;
         checkType(l, 2, out a1);
         self.Invalidate(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Exemplo n.º 4
0
 static int Invalidate(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UIPanel obj  = (UIPanel)ToLua.CheckObject <UIPanel>(L, 1);
         bool    arg0 = LuaDLL.luaL_checkboolean(L, 2);
         obj.Invalidate(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 5
0
                                : "";// KlyteResourceLoader.GetDefaultSpriteNameFor(LineIconSpriteNames.K45_CircleIcon, true);

        private void CreateConnectionPanel(NetManager instance, UIPanel basePanel, ushort currentStop)
        {
            ushort lineID     = GetLineID();
            var    linesFound = new List <ushort>();

            TLMLineUtils.GetNearLines(instance.m_nodes.m_buffer[currentStop].m_position, 150f, ref linesFound);
            linesFound.Remove(lineID);
            UIPanel connectionPanel = basePanel.Find <UIPanel>("ConnectionPanel");

            while (connectionPanel.childCount < linesFound.Count)
            {
                KlyteMonoUtils.CreateUIElement(out UILabel lineLabel, connectionPanel.transform, "", new Vector4(0, 0, 17, 17));
                lineLabel.processMarkup     = true;
                lineLabel.textScale         = 0.5f;
                lineLabel.eventClicked     += OpenLineLabel;
                lineLabel.verticalAlignment = UIVerticalAlignment.Middle;
            }
            while (connectionPanel.childCount > linesFound.Count)
            {
                UIComponent comp = connectionPanel.components[linesFound.Count];
                connectionPanel.components.RemoveAt(linesFound.Count);
                GameObject.Destroy(comp);
                connectionPanel.Invalidate();
            }
            int multiplier = linesFound.Count > m_kMaxConnectionsLine ? 1 : 2;

            for (int i = 0; i < linesFound.Count; i++)
            {
                ushort  line      = linesFound[i];
                UILabel lineLabel = connectionPanel.components[i].GetComponent <UILabel>();
                lineLabel.name    = $"L{line}";
                lineLabel.tooltip = Singleton <TransportManager> .instance.GetLineName(line);

                lineLabel.text           = TLMLineUtils.GetIconString(line);
                lineLabel.stringUserData = line.ToString();
                lineLabel.size           = m_kBasicConnectionLogoSize * multiplier;
                lineLabel.textScale      = m_kBasicConnectionLogoFontSize * multiplier;
            }

            connectionPanel.isVisible = m_currentMode == MapMode.CONNECTIONS;
        }
Exemplo n.º 6
0
        public static void SetLayerOver(this UIPanel over, UIPanel[] belowPanels)
        {
            UIPanel[] overPanels = over.GetComponentsInChildren <UIPanel>(true);
            Array.Sort(overPanels, (p1, p2) => p1.depth - p2.depth);

            int maxDepth = -1;

            foreach (UIPanel p in belowPanels)
            {
                maxDepth = Math.Max(maxDepth, p.depth);
            }
            int minDepth = int.MaxValue;

            foreach (UIPanel p in overPanels)
            {
                minDepth = Math.Min(minDepth, p.depth);
            }
            if (minDepth == int.MaxValue)
            {
                minDepth = 0;
            }
            int baseDepth = Math.Max(0, maxDepth - minDepth + 1);

            Assert.IsTrue(baseDepth < 20000);
            // depth must be equal or above 100
            foreach (UIPanel p in overPanels)
            {
                                #if RQ
                p.depth = Math.Max(100, p.depth + baseDepth);
                                #else
                p.depth = p.depth + baseDepth;
                                #endif
            }

            int belowMaxQ = -1;
            foreach (UIPanel p in belowPanels)
            {
                int q = p.GetMaxRenderQueue();
                if (q >= 0)
                {
                    belowMaxQ = Math.Max(belowMaxQ, q);
                }
            }
            if (belowMaxQ >= 0)
            {
                int overMinQ = int.MaxValue;
                foreach (UIPanel p in overPanels)
                {
                    int q = p.GetMinRenderQueue();
                    if (q >= 0)
                    {
                        overMinQ = Math.Min(overMinQ, q);
                    }
                }
                int baseQ = belowMaxQ - overMinQ + 1;
                foreach (UIPanel p in overPanels)
                {
                    if (p.gameObject.activeInHierarchy && p.renderQueue != UIPanel.RenderQueue.Explicit)
                    {
                        p.renderQueue = UIPanel.RenderQueue.StartAt;
                        if (overMinQ != int.MaxValue)
                        {
                            if (baseQ > 0)
                            {
                                p.startingRenderQueue += baseQ;
                            }
                        }
                        else
                        {
                            p.startingRenderQueue = belowMaxQ + (p.depth - minDepth) * 10;                       // 10 delta per depth
                        }
                    }
                }
            }

            int maxOrder = -1;
            foreach (UIPanel p in belowPanels)
            {
                maxOrder = Math.Max(maxOrder, p.sortingOrder);
            }
            // get non-NGUI renderer
            if (!belowPanels.IsEmpty())
            {
                foreach (Renderer r in belowPanels[0].GetComponentsInChildren <Renderer>(true))
                {
                    maxOrder = Math.Max(maxOrder, r.sortingOrder);
                }
            }

            SetMinSortingOrder(over, overPanels, maxOrder);

            over.Invalidate(true);
        }