Example #1
0
        public PopupMenuGump(PopupMenuData data) : base(0, 0)
        {
            CanMove = false;
            CanCloseWithRightClick = true;


            ResizePic pic = new ResizePic(0x0A3C)
            {
                Alpha = 0.25f
            };

            Add(pic);
            int  offsetY = 10;
            bool arrowAdded = false;
            int  width = 0, height = 20;

            for (int i = 0; i < data.Items.Length; i++)
            {
                ref readonly var item = ref data.Items[i];
Example #2
0
        public PopupMenuGump(PopupMenuData data) : base(0, 0)
        {
            CanMove = false;
            CanCloseWithRightClick = true;


            ResizePic pic = new ResizePic(0x0A3C)
            {
                Alpha = 0.25f
            };

            Add(pic);
            int  offsetY = 10;
            bool arrowAdded = false;
            int  width = 0, height = 20;

            for (int i = 0; i < data.Items.Length; i++)
            {
                ref PopupMenuItem item = ref data.Items[i];

                string text = ClilocLoader.Instance.GetString(item.Cliloc);

                ushort hue = item.Hue;

                if (item.ReplacedHue != 0)
                {
                    uint h = HuesHelper.Color16To32(item.ReplacedHue);
                    (byte b, byte g, byte r, byte a) = HuesHelper.GetBGRA(h);

                    Color c = new Color(r, g, b, a);

                    if (c.A == 0)
                    {
                        c.A = 0xFF;
                    }

                    FontsLoader.Instance.SetUseHTML(true, HuesHelper.RgbaToArgb(c.PackedValue));
                }

                Label label = new Label(text, true, hue, font: 1)
                {
                    X = 10,
                    Y = offsetY
                };

                FontsLoader.Instance.SetUseHTML(false);

                HitBox box = new HitBox(10, offsetY, label.Width, label.Height)
                {
                    Tag = item.Index
                };

                box.MouseUp += (sender, e) =>
                {
                    if (e.Button == MouseButtonType.Left)
                    {
                        HitBox l = (HitBox)sender;
                        GameActions.ResponsePopupMenu(data.Serial, (ushort)l.Tag);
                        Dispose();
                    }
                };

                Add(box);
                Add(label);

                if ((item.Flags & 0x02) != 0 && !arrowAdded)
                {
                    arrowAdded = true;

                    // TODO: wat?
                    Add
                    (
                        new Button(0, 0x15E6, 0x15E2, 0x15E2)
                    {
                        X = 20,
                        Y = offsetY
                    }
                    );

                    height += 20;
                }

                offsetY += label.Height;

                if (!arrowAdded)
                {
                    height += label.Height;

                    if (width < label.Width)
                    {
                        width = label.Width;
                    }
                }
            }
Example #3
0
        public PopupMenuGump(PopupMenuData data) : base(0, 0)
        {
            CloseIfClickOutside = true;
            //ControlInfo.IsModal = true;
            //ControlInfo.ModalClickOutsideAreaClosesThisControl = true;
            CanMove = false;

            ResizePic pic = new ResizePic(0x0A3C)
            {
                Alpha = 0.25f
            };

            Add(pic);
            int  offsetY = 10;
            bool arrowAdded = false;
            int  width = 0, height = 20;

            foreach (PopupMenuItem item in data.Items)
            {
                string text = UOFileManager.Cliloc.GetString(item.Cliloc);

                ushort hue = item.Hue;

                if (item.ReplacedHue != 0)
                {
                    uint h = HuesHelper.Color16To32(item.ReplacedHue);
                    (byte b, byte g, byte r, byte a) = HuesHelper.GetBGRA(h);

                    Color c = new Color(r, g, b, a);

                    if (c.A == 0)
                    {
                        c.A = 0xFF;
                    }

                    UOFileManager.Fonts.SetUseHTML(true, HuesHelper.RgbaToArgb(c.PackedValue));
                }

                Label label = new Label(text, true, 0xFFFF, font: 1)
                {
                    X = 10, Y = offsetY
                };
                UOFileManager.Fonts.SetUseHTML(false);

                HitBox box = new HitBox(10, offsetY, label.Width, label.Height)
                {
                    Tag = item.Index
                };

                box.MouseUp += (sender, e) =>
                {
                    if (e.Button == MouseButton.Left)
                    {
                        HitBox l = (HitBox)sender;
                        GameActions.ResponsePopupMenu(data.Serial, (ushort)l.Tag);
                        Dispose();
                    }
                };
                Add(box);
                Add(label);

                if ((item.Flags & 0x02) != 0 && !arrowAdded)
                {
                    arrowAdded = true;

                    // TODO: wat?
                    Add(new Button(0, 0x15E6, 0x15E2, 0x15E2)
                    {
                        X = 20, Y = offsetY
                    });
                    height += 20;
                }

                offsetY += label.Height;

                if (!arrowAdded)
                {
                    height += label.Height;

                    if (width < label.Width)
                    {
                        width = label.Width;
                    }
                }
            }

            width += 20;

            if (height <= 10 || width <= 20)
            {
                Dispose();
            }
            else
            {
                pic.Width  = width;
                pic.Height = height;
                foreach (HitBox box in FindControls <HitBox>())
                {
                    box.Width = width - 20;
                }
            }
        }
Example #4
0
        public PopupMenuGump(PopupMenuData data) : base(0, 0)
        {
            _data = data;
            CloseIfClickOutside = true;
            //ControlInfo.IsModal = true;
            //ControlInfo.ModalClickOutsideAreaClosesThisControl = true;
            CanMove = false;

            ResizePic pic = new ResizePic(0x0A3C)
            {
                IsTransparent = true, Alpha = 0.25f
            };

            Add(pic);
            int  offsetY = 10;
            bool arrowAdded = false;
            int  width = 0, height = 20;

            foreach (PopupMenuItem item in data.Items)
            {
                string text = FileManager.Cliloc.GetString(item.Cliloc);

                Label label = new Label(text, true, item.Hue, font: 1)
                {
                    X = 10, Y = offsetY
                };

                HitBox box = new HitBox(10, offsetY, label.Width, label.Height)
                {
                    IsTransparent = true, Tag = item.Index
                };

                box.MouseClick += (sender, e) =>
                {
                    if (e.Button == MouseButton.Left)
                    {
                        HitBox l = (HitBox)sender;
                        GameActions.ResponsePopupMenu(_data.Serial, (ushort)l.Tag);
                        Dispose();
                    }
                };
                Add(box);
                Add(label);

                if ((item.Flags & 0x02) != 0 && !arrowAdded)
                {
                    arrowAdded = true;

                    // TODO: wat?
                    Add(new Button(0, 0x15E6, 0x15E2, 0x15E2)
                    {
                        X = 20, Y = offsetY
                    });
                    height += 20;
                }

                offsetY += label.Height;

                if (!arrowAdded)
                {
                    height += label.Height;

                    if (width < label.Width)
                    {
                        width = label.Width;
                    }
                }
            }

            width += 20;

            if (height <= 10 || width <= 20)
            {
                Dispose();
            }
            else
            {
                pic.Width  = width;
                pic.Height = height;
                foreach (HitBox box in FindControls <HitBox>())
                {
                    box.Width = width - 20;
                }
            }
        }
Example #5
0
        public PopupMenuGump(PopupMenuData data) : base(0, 0)
        {
            CanMove = false;
            CanCloseWithRightClick = true;
            _data = data;

            ResizePic pic = new ResizePic(0x0A3C)
            {
                Alpha = 0.75f
            };

            Add(pic);
            int  offsetY = 10;
            bool arrowAdded = false;
            int  width = 0, height = 20;

            for (int i = 0; i < data.Items.Length; i++)
            {
                ref PopupMenuItem item = ref data.Items[i];

                string text = ClilocLoader.Instance.GetString(item.Cliloc);

                ushort hue = item.Hue;

                if (item.ReplacedHue != 0)
                {
                    uint h = (HuesHelper.Color16To32(item.ReplacedHue) << 8) | 0xFF;

                    FontsLoader.Instance.SetUseHTML(true, h);
                }

                Label label = new Label(text, true, hue, font: 1)
                {
                    X = 10,
                    Y = offsetY
                };

                FontsLoader.Instance.SetUseHTML(false);

                HitBox box = new HitBox(10, offsetY, label.Width, label.Height)
                {
                    Tag = item.Index
                };

                box.MouseEnter += (sender, e) =>
                {
                    _selectedItem = (ushort)(sender as HitBox).Tag;
                };

                Add(box);
                Add(label);

                if ((item.Flags & 0x02) != 0 && !arrowAdded)
                {
                    arrowAdded = true;

                    // TODO: wat?
                    Add
                    (
                        new Button(0, 0x15E6, 0x15E2, 0x15E2)
                    {
                        X = 20,
                        Y = offsetY
                    }
                    );

                    height += 20;
                }

                offsetY += label.Height;

                if (!arrowAdded)
                {
                    height += label.Height;

                    if (width < label.Width)
                    {
                        width = label.Width;
                    }
                }
            }