예제 #1
0
        public uint GetPartialHueColor(ushort c, ushort color)
        {
            if (color != 0 && color < HuesCount)
            {
                color -= 1;
                int  g  = color >> 3;
                int  e  = color % 8;
                uint cl = HuesHelper.Color16To32(c);
                (byte B, byte G, byte R, byte A) = HuesHelper.GetBGRA(cl);
                //(byte R, byte G, byte B, byte A) = HuesHelper.GetBGRA(cl);

                if (R == G && B == G)
                {
                    return(HuesHelper.Color16To32(HuesRange[g].Entries[e].ColorTable[(c >> 10) & 0x1F]));
                }

                return(cl);
            }

            return(HuesHelper.Color16To32(c));
        }
예제 #2
0
        public void SetColor(ushort hue, uint pol)
        {
            Hue = hue;

            (byte b, byte g, byte r, byte a) = HuesHelper.GetBGRA(HuesHelper.RgbaToArgb(pol));

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

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

            if (Texture == null || Texture.IsDisposed)
            {
                Texture = new SpriteTexture(1, 1);
            }
            Texture.SetData(new Color[1] {
                _colorRGBA
            });
        }
예제 #3
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;
                    }
                }
            }
예제 #4
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;
                }
            }
        }