Exemplo n.º 1
0
        //public float[] CreateHuesPalette()
        //{
        //    float[] p = new float[32 * 3 * HuesCount];

        //    Palette = new FloatHues[HuesCount];
        //    int entrycount = HuesCount >> 3;
        //    int iddd = 0;
        //    for (int i = 0; i < entrycount; i++)
        //    {
        //        for (int j = 0; j < 8; j++)
        //        {
        //            int idx = i * 8 + j;
        //            Palette[idx].Palette = new float[32 * 3];

        //            for (int h = 0; h < 32; h++)
        //            {
        //                int idx1 = h * 3;
        //                ushort c = HuesRange[i].Entries[j].ColorTable[h];
        //                Palette[idx].Palette[idx1] = ((c >> 10) & 0x1F) / 31.0f;
        //                Palette[idx].Palette[idx1 + 1] = ((c >> 5) & 0x1F) / 31.0f;
        //                Palette[idx].Palette[idx1 + 2] = (c & 0x1F) / 31.0f;

        //                p[(idx * 96) + idx1 + 0] = Palette[idx].Palette[idx1];
        //                p[(idx * 96) + idx1 + 1] = Palette[idx].Palette[idx1 + 1];
        //                p[(idx * 96) + idx1 + 2] = Palette[idx].Palette[idx1 + 2];

        //                //p[iddd++] = Palette[idx].Palette[idx1];
        //                //p[iddd++] = Palette[idx].Palette[idx1 + 1];
        //                //p[iddd++] = Palette[idx].Palette[idx1 + 2];
        //            }
        //        }
        //    }

        //    return p;
        //}

        public void CreateShaderColors(uint[] buffer)
        {
            int len = HuesRange.Length;

            int idx = 0;

            for (int r = 0; r < len; r++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 32; x++)
                    {
                        buffer[idx++] = HuesHelper.Color16To32(HuesRange[r].Entries[y].ColorTable[x]);
                    }
                }
            }

            //for (int r = 0; r < len; r++)
            //{
            //    for (int y = 0; y < 8; y++)
            //    {
            //        for (int x = 0; x < 32; x++)
            //        {
            //            if (x == 0)
            //                hues[idx++] = HuesHelper.Color16To32(HuesRange[0].Entries[0].ColorTable[0]);
            //            else
            //                hues[idx++] = HuesHelper.Color16To32(HuesRange[r].Entries[y].ColorTable[x]);
            //        }
            //    }
            //}
        }
Exemplo n.º 2
0
        private uint[] CreateTexture(int radius, ref short width, ref short height)
        {
            _texture?.Dispose();

            int fixRadius = radius + 1;
            int mulRadius = fixRadius * 2;

            uint[] pixels = new uint[mulRadius * mulRadius];

            width  = (short)mulRadius;
            height = (short)mulRadius;

            for (int x = -fixRadius; x < fixRadius; x++)
            {
                int mulX = x * x;
                int posX = ((x + fixRadius) * mulRadius) + fixRadius;

                for (int y = -fixRadius; y < fixRadius; y++)
                {
                    int r = (int)Math.Sqrt(mulX + (y * y));

                    uint pic = (uint)((r <= radius) ? ((radius - r) & 0xFF) : 0);

                    int pos = posX + y;

                    pixels[pos] = HuesHelper.RgbaToArgb(pic);
                }
            }

            return(pixels);
        }
Exemplo n.º 3
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 R = (byte)(cl & 0xFF);
                byte G = (byte)((cl >> 8) & 0xFF);
                byte B = (byte)((cl >> 16) & 0xFF);

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

                return(cl);
            }

            return(HuesHelper.Color16To32(c));
        }
Exemplo n.º 4
0
        public void CreateShaderColors(uint[] buffer)
        {
            int len = HuesRange.Length;

            int idx = 0;

            for (int r = 0; r < len; r++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 32; x++)
                    {
                        buffer[idx++] = HuesHelper.Color16To32
                                        (
                            HuesRange[r]
                            .Entries[y]
                            .ColorTable[x]
                                        ) | 0xFF_00_00_00;

                        if (idx >= buffer.Length)
                        {
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void CreatePixels(uint[] data, int color, int x, int y, int w, int h, Point[] table, int count)
        {
            int px = x;
            int py = y;

            for (int i = 0; i < count; i++)
            {
                px += table[i]
                      .X;

                py += table[i]
                      .Y;

                int gx = px;

                if (gx < 0 || gx >= w)
                {
                    continue;
                }

                int gy = py;

                if (gy < 0 || gy >= h)
                {
                    break;
                }

                int block = gy * w + gx;

                if (data[block] == 0xFF080808)
                {
                    data[block] = HuesHelper.Color16To32((ushort)color) | 0xFF_00_00_00;
                }
            }
        }
Exemplo n.º 6
0
        public uint GetColor(ushort c, ushort color)
        {
            if (color != 0 && color < HuesCount)
            {
                color -= 1;
                int g = color >> 3;
                int e = color % 8;

                return(HuesHelper.Color16To32(HuesRange[g].Entries[e].ColorTable[(c >> 10) & 0x1F]));
            }

            return(HuesHelper.Color16To32(c));
        }
Exemplo n.º 7
0
        public uint GetPolygoneColor(ushort c, ushort color)
        {
            if (color != 0 && color < HuesCount)
            {
                color -= 1;
                int g = color >> 3;
                int e = color % 8;

                return(HuesHelper.Color16To32(HuesRange[g].Entries[e].ColorTable[c]));
            }

            return(0xFF010101);
        }
Exemplo n.º 8
0
        public uint[] CreateShaderColors()
        {
            uint[] hues = new uint[32 * 2 * HuesCount];
            int    len  = HuesRange.Length;

            int idx = 0;

            for (int r = 0; r < len; r++)
            {
                for (int y = 0; y < 8; y++)
                {
                    for (int x = 0; x < 32; x++)
                    {
                        hues[idx++] = HuesHelper.Color16To32(HuesRange[r].Entries[y].ColorTable[x]);
                    }
                }
            }

            return(hues);
        }
Exemplo n.º 9
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
            });
        }
Exemplo n.º 10
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));
        }
        public static void Create(int radius)
        {
            if (radius < Constants.MIN_CIRCLE_OF_TRANSPARENCY_RADIUS)
            {
                radius = Constants.MIN_CIRCLE_OF_TRANSPARENCY_RADIUS;
            }
            else if (radius > Constants.MAX_CIRCLE_OF_TRANSPARENCY_RADIUS)
            {
                radius = Constants.MAX_CIRCLE_OF_TRANSPARENCY_RADIUS;
            }

            if (_radius == radius && _texture != null && !_texture.IsDisposed)
            {
                return;
            }

            _radius = radius;
            _texture?.Dispose();
            _texture = null;

            uint[] pixels = CreateCircleTexture(radius, ref _width, ref _height);

            for (int i = 0; i < pixels.Length; i++)
            {
                ref uint pixel = ref pixels[i];

                if (pixel != 0)
                {
                    pixel = HuesHelper.RgbaToArgb(pixel);
                    //ushort value = (ushort)(pixel << 3);

                    //if (value > 0xFF)
                    //    value = 0xFF;

                    //pixel = (uint)((value << 24) | (value << 16) | (value << 8) | value);
                }
            }
Exemplo n.º 12
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;
                    }
                }
            }
Exemplo n.º 13
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;
                }
            }
        }
Exemplo n.º 14
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;
                    }
                }
            }