Exemplo n.º 1
0
        private void ItemsOnAdded(object sender, CollectionChangedEventArgs <Serial> e)
        {
            foreach (ItemGump v in Children.OfType <ItemGump>().Where(s => e.Contains(s.LocalSerial)))
            {
                v.Dispose();
            }

            foreach (Serial s in e)
            {
                var item = World.Items.Get(s);

                if (item == null || item.ItemData.Layer == (int)Layer.Hair || item.ItemData.Layer == (int)Layer.Beard || item.ItemData.Layer == (int)Layer.Face)
                {
                    continue;
                }


                var itemControl = new ItemGump(item);
                CheckItemControlPosition(itemControl, item);

                if (Engine.Profile.Current != null && Engine.Profile.Current.ScaleItemsInsideContainers)
                {
                    float scale = Engine.UI.ContainerScale;

                    itemControl.Width  = (int)(itemControl.Width * scale);
                    itemControl.Height = (int)(itemControl.Height * scale);
                }

                Add(itemControl);
            }
        }
Exemplo n.º 2
0
        public ContainerGump(uint serial, ushort gumpid) : this()
        {
            LocalSerial = serial;
            Item item = World.Items.Get(serial);

            if (item == null)
            {
                Dispose();
                return;
            }

            Graphic = gumpid;

            BuildGump();

            foreach (var c in Children.OfType <ItemGump>())
            {
                c.Dispose();
            }

            foreach (Item i in item.Items.Where(s => s != null && s.IsLootable))
            //FIXME: this should be disabled. Server sends the right position
            //CheckItemPosition(i);
            {
                var x = new ItemGump(i);
                Add(x);
            }
        }
Exemplo n.º 3
0
            public ShopItem(Item item)
            {
                Item = item;
                var itemName = StringHelper.CapitalizeAllWords(item.Name);

                ItemGump itemGunp;

                Add(itemGunp = new ItemGump(item)
                {
                    X = 5, Y = 5, Height = 50, AcceptMouseInput = false
                });

                Label label;

                Add(label = new Label($"{itemName} at {item.Price}gp", false, 0x021F, 110, 9)
                {
                    Y = 5, X = 65
                });

                Add(_amountLabel = new Label(item.Amount.ToString(), false, 0x021F, font: 9)
                {
                    X = 180, Y = 20
                });

                Width = 220;
                ArtTexture texture = itemGunp.Texture as ArtTexture;

                Height = Math.Max(label.Height, texture.ImageRectangle.Height) + 10;

                WantUpdateSize = false;
            }
Exemplo n.º 4
0
        public override void Dispose()
        {
            _okButton.MouseClick -= OkButtonOnMouseClick;

            if (_itemGump != null && _itemGump.IsAlive)
            {
                ItemGump gump = _itemGump.Target as ItemGump;
                if (gump != null)
                {
                    gump.Disposed -= ItemGumpOnDisposed;
                }
            }

            base.Dispose();
        }
Exemplo n.º 5
0
        public SplitMenuGump(Item item, Point offset) : base(item, 0)
        {
            Item = item;

            ItemGump itemGump = Engine.UI.GetChildByLocalSerial <ContainerGump, ItemGump>(item.Container, item.Serial);

            if (itemGump != null)
            {
                _itemGump          = new WeakReference(itemGump);
                itemGump.Disposed += ItemGumpOnDisposed;
            }

            _offsert = offset;

            CanMove          = true;
            AcceptMouseInput = false;

            GumpPic background = new GumpPic(0, 0, 0x085C, 0);

            Add(background);
            Add(_slider = new HSliderBar(29, 16, 105, 1, item.Amount, item.Amount, HSliderBarStyle.BlueWidgetNoBar));
            _lastValue  = _slider.Value;

            Add(_okButton = new Button(0, 0x085d, 0x085e, 0x085f)
            {
                ButtonAction = ButtonAction.Default,
                X            = 102, Y = 37
            });

            _okButton.MouseClick += OkButtonOnMouseClick;

            Add(_textBox = new TextBox(1, isunicode: false, hue: 0x0386, width: 60, maxWidth: 1000)
            {
                X           = 29, Y = 42,
                Width       = 60,
                NumericOnly = true
            });
            _textBox.SetText(item.Amount.ToString());
        }
Exemplo n.º 6
0
        private void CheckItemControlPosition(ItemGump itemGump, Item item)
        {
            float scale = Engine.UI.ContainerScale;

            int x = (int)(itemGump.X * scale);
            int y = (int)(itemGump.Y * scale);

            ArtTexture texture = FileManager.Art.GetTexture(item.DisplayedGraphic);

            int boundX = (int)(_data.Bounds.X * scale);
            int boundY = (int)(_data.Bounds.Y * scale);

            if (texture != null && !texture.IsDisposed)
            {
                int boundW = (int)(_data.Bounds.Width * scale);
                int boundH = (int)(_data.Bounds.Height * scale);

                int textureW, textureH;

                if (Engine.Profile.Current != null && Engine.Profile.Current.ScaleItemsInsideContainers)
                {
                    textureW = (int)(texture.Width * scale);
                    textureH = (int)(texture.Height * scale);
                }
                else
                {
                    textureW = texture.Width;
                    textureH = texture.Height;
                }

                if (x < boundX)
                {
                    x = boundX;
                }

                if (y < boundY)
                {
                    y = boundY;
                }


                if (x + textureW > boundW)
                {
                    x = boundW - textureW;
                }

                if (y + textureH > boundH)
                {
                    y = boundH - textureH;
                }
            }
            else
            {
                x = boundX;
                y = boundY;
            }

            if (x < 0)
            {
                x = 0;
            }

            if (y < 0)
            {
                y = 0;
            }


            if (x != itemGump.X || y != itemGump.Y)
            {
                itemGump.X = x;
                itemGump.Y = y;
            }
        }