Example #1
0
        /// <summary>
        /// Updates the list of available elements.
        /// </summary>
        public void Update(GridFilterableSideScreen screen)
        {
            Console.WriteLine("updating with the storage");
            Storage    storage = screen.storage;
            GameObject target  = screen.target;

            if (storage.storageFilters != null && storage.storageFilters.Count >= 1)
            {
                // check for which ones aren't added already and add them
                foreach (Tag tag in storage.storageFilters)
                {
                    Console.WriteLine($"Should be checking presence of tag {tag.ToString()}");
                    if (!HasElement(tag))
                    {
                        Console.WriteLine($"Attempted to add {tag.ToString()} to the panel");
                        if (children.Count <= 0)
                        {
                            GridFilterableRow firstRow = new GridFilterableRow(this);
                            children.Add(firstRow);
                            PUIElements.SetParent(firstRow.ChildPanel, childPanel);
                            PUIElements.SetAnchors(firstRow.ChildPanel, PUIAnchoring.Stretch, PUIAnchoring.Stretch);
                        }
                        GridFilterableRow lastRow = children[children.Count - 1];
                        if (lastRow.RowSize >= PER_ROW)
                        {
                            lastRow = new GridFilterableRow(this);
                            PUIElements.SetParent(lastRow.ChildPanel, childPanel);
                            PUIElements.SetAnchors(lastRow.ChildPanel, PUIAnchoring.Stretch, PUIAnchoring.Stretch);
                            children.Add(lastRow);
                        }
                        GridFilterableSelectableEntity entity = new GridFilterableSelectableEntity(lastRow, tag);
                        lastRow.Children.Add(entity);
                        PUIElements.SetParent(entity.CheckBox, lastRow.ChildPanel);
                        if (PCheckBox.GetCheckState(entity.CheckBox) == PCheckBox.STATE_CHECKED)
                        {
                            // Set to checked
                            PCheckBox.SetCheckState(entity.CheckBox, PCheckBox.STATE_CHECKED);
                        }
                    }
                }
            }
            else
            {
                Debug.LogError((object)"If you're filtering, your storage filter should have the filters set on it");
            }
        }
            public static void Postfix()
            {
                List <DetailsScreen.SideScreenRef> sideScreens = Traverse.Create(DetailsScreen.Instance).Field("sideScreens").GetValue <List <DetailsScreen.SideScreenRef> >();
                GameObject               sideScreenContentBody = Traverse.Create(DetailsScreen.Instance).Field("sideScreenContentBody").GetValue <GameObject>();
                GridFilterableControl    gridSelectControl     = new GridFilterableControl();
                GridFilterableSideScreen screen = gridSelectControl.RootPanel.AddComponent <GridFilterableSideScreen>();

                screen.gameObject.transform.parent = sideScreenContentBody.transform;
                PUIUtils.DebugObjectTree(sideScreenContentBody);
                DetailsScreen.SideScreenRef myRef = new DetailsScreen.SideScreenRef {
                    name           = "bob",
                    screenPrefab   = screen,
                    offset         = new Vector2(0f, 0f),
                    screenInstance = screen
                };
                sideScreens.Add(myRef);
                Console.WriteLine("Postfix patch was called and added in the side screen");
            }