Exemplo n.º 1
0
        public void SetParent(BoundedBagMenu Menu)
        {
            this.Menu = Menu;
            if (Menu == null)
            {
                this.PlaceholderItems = new ReadOnlyCollection <Object>(new List <Object>());
            }
            else
            {
                List <AllowedObject> UngroupedObjects = BoundedBag.AllowedObjects.Where(x => !Menu.GroupByQuality || !x.HasQualities).ToList();

                List <Object> Placeholders = new List <Object>();
                foreach (AllowedObject Item in UngroupedObjects)
                {
                    if (!Item.HasQualities || Item.IsBigCraftable)
                    {
                        Object Obj = Item.IsBigCraftable ?
                                     new Object(Vector2.Zero, Item.Id, false) :
                                     new Object(Item.Id, 0, false, -1, 0);
                        Placeholders.Add(Obj);
                    }
                    else
                    {
                        Placeholders.AddRange(Item.Qualities.Select(x => new Object(Item.Id, 0, false, -1, (int)x)));
                    }
                }
                this.PlaceholderItems = new ReadOnlyCollection <Object>(Placeholders);

                UpdateQuantities();

                SetTopLeft(Point.Zero, false);
            }
        }
Exemplo n.º 2
0
        public void SetParent(BoundedBagMenu Menu)
        {
            this.Menu = Menu;
            if (Menu == null)
            {
                this.GroupedObjects = new ReadOnlyCollection <AllowedObject>(new List <AllowedObject>());
                this.Placeholders   = new Dictionary <int, Dictionary <ObjectQuality, Object> >();
            }
            else
            {
                this.GroupedObjects = new ReadOnlyCollection <AllowedObject>(BoundedBag.AllowedObjects.Where(x => Menu.GroupByQuality && x.HasQualities && !x.IsBigCraftable).ToList());

                int TotalFilledSlots = GroupedObjects.Count * ColumnsPerGroup;
                this.TotalSlots = ((GroupedObjects.Count - 1) / GroupsPerRow + 1) * GroupsPerRow * ColumnsPerGroup; // Force grid to perfect square, for ex if there were 13 items and 12 columns, we'd want 2x12=24 slots
                this.RowCount   = (GroupedObjects.Count - 1) / GroupsPerRow + 1;

                List <ObjectQuality> Qualities = Enum.GetValues(typeof(ObjectQuality)).Cast <ObjectQuality>().ToList();

                //  Create an item with quantity=0 for each Item that the Bag is capable of storing
                this.Placeholders = new Dictionary <int, Dictionary <ObjectQuality, Object> >();
                foreach (AllowedObject Item in GroupedObjects)
                {
                    if (Item.IsBigCraftable)
                    {
                        throw new InvalidOperationException(string.Format("BigCraftable Items are not valid for GroupedLayouts. Bag = {0}, ItemId = {1}", Menu.BoundedBag.DisplayName, Item.Id));
                    }

                    Dictionary <ObjectQuality, Object> Group = new Dictionary <ObjectQuality, Object>();

                    foreach (ObjectQuality Quality in Qualities)
                    {
                        Group.Add(Quality, new Object(Item.Id, 0, false, -1, (int)Quality));
                    }

                    Placeholders.Add(Item.Id, Group);
                }

                UpdateQuantities();

                SetTopLeft(Point.Zero, false);
            }
        }