Example #1
0
        public void ClearButtons()
        {
            UIComponent[] carray = new UIComponent[ScrollPanel.components.Count];
            ScrollPanel.components.CopyTo(carray, 0);

            foreach (UIComponent child in carray)
            {
                ScrollPanel.RemoveUIComponent(child);
                UnityEngine.Object.Destroy(child);
            }
        }
        public void RemoveRow(IUIWorkshopAssetRowData workshopAssetRowData)
        {
            try
            {
                ModLogger.Debug("Trying to remove row");
                var row = _rows.FirstOrDefault(r => r.WorkshopId == workshopAssetRowData.WorkshopId);
                if (row != null)
                {
                    ModLogger.Debug("Removing row '{0}'", workshopAssetRowData.ReadableName);
                    _scrollablePanel.RemoveUIComponent(row);
                    _rows.Remove(row);
                }
                else
                {
                    ModLogger.Debug("Row '{0}' not found", workshopAssetRowData.ReadableName);
                }

                ClearWorkshopAssets();
                PopulateWorkshopAssets();
            }
            catch (Exception ex)
            {
                ModLogger.Exception(ex);
            }
        }
Example #3
0
 protected void RemoveExtraLines(int linesCount)
 {
     while (mainPanel.components.Count > linesCount)
     {
         UIComponent uIComponent = mainPanel.components[linesCount];
         mainPanel.RemoveUIComponent(uIComponent);
         Destroy(uIComponent.gameObject);
     }
 }
        public void InitSavesListUI(UIScrollablePanel panel)
        {
            if (panel == null)
            {
                return;
            }

            // clear panel
            List <UIComponent> workingChildren = new List <UIComponent>(panel.components);

            foreach (UIComponent child in workingChildren)
            {
                if (child.name == "BetterLoadRowPanel" && child is UIPanel)
                {
                    panel.RemoveUIComponent(child);

                    UnityEngine.Object.Destroy(child);
                }
            }
            //panel.Reset();

            if (GamesList == null || GamesList.Count <= 0)
            {
                return;
            }

            float thirds = panel.width / 3f;

            //
            foreach (SaveGameRowStruct row in GamesList)
            {
                UIPanel rowPanel = panel.AddUIComponent <UIPanel>();

                row.RowPanel            = rowPanel;
                rowPanel.objectUserData = row;

                rowPanel.name     = "BetterLoadRowPanel";
                rowPanel.autoSize = false;

                rowPanel.eventMouseEnter += (component, param) => // was eventMouseHover
                {
                    if ((component as UIPanel).backgroundSprite != "ListItemHighlight")
                    {
                        (component as UIPanel).backgroundSprite = "ListItemHover";
                    }
                };

                rowPanel.eventMouseLeave += (component, param) =>
                {
                    if ((component as UIPanel).backgroundSprite != "ListItemHighlight")
                    {
                        (component as UIPanel).backgroundSprite = "";
                    }
                };

                rowPanel.eventMouseDown += (component, param) =>
                {
                    this.SelectRowObject(component);
                };

                rowPanel.eventDoubleClick += (component, param) =>
                {
                    this.LaunchRowObject(component);
                };

                row.SaveLabel                  = rowPanel.AddUIComponent <UILabel>();
                row.SaveLabel.text             = row.SaveName;
                row.SaveLabel.autoSize         = false;
                row.SaveLabel.relativePosition = Vector3.zero;
                row.SaveLabel.width            = thirds;
                row.SaveLabel.padding          = new RectOffset(3, 3, 0, 0);

                if (row.IsSteam)
                {
                    row.SaveLabel.processMarkup = true;
                    row.SaveLabel.text          = "<sprite SteamCloud> " + row.SaveLabel.text;
                }

                row.CityLabel                  = rowPanel.AddUIComponent <UILabel>();
                row.CityLabel.text             = row.CityName;
                row.CityLabel.autoSize         = false;
                row.CityLabel.relativePosition = new Vector3(thirds, 0, 0);
                row.CityLabel.width            = thirds;
                row.CityLabel.padding          = new RectOffset(3, 3, 0, 0);

                row.TimestampLabel                  = rowPanel.AddUIComponent <UILabel>();
                row.TimestampLabel.text             = row.SaveTimestamp.ToString();
                row.TimestampLabel.autoSize         = false;
                row.TimestampLabel.relativePosition = new Vector3(thirds + thirds, 0, 0);
                row.TimestampLabel.width            = thirds;
                row.TimestampLabel.padding          = new RectOffset(3, 3, 0, 0);

                rowPanel.width  = panel.width;
                rowPanel.height = row.SaveLabel.height;//?
            }
        }