Exemplo n.º 1
0
 public GridFilterableSelectableEntity(GridFilterableRow parent, Tag elementTag)
 {
     this.Parent = parent ?? throw new ArgumentNullException("parent");
     ElementTag  = elementTag;
     CheckBox    = new PCheckBox("Select")
     {
         OnChecked    = OnCheck,
         Text         = ElementTag.ProperName(),
         InitialState = PCheckBox.
                        STATE_CHECKED,
         Sprite     = GetStorageObjectSprite(elementTag),
         CheckSize  = ROW_SIZE,
         SpriteSize = ROW_SIZE,
     }.Build();
 }
Exemplo n.º 2
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");
            }
        }