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)); }
//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]) | 0xFF_00_00_00; if (idx >= buffer.Length) { return; } } } } //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]); // } // } //} }
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; } } }
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; } } }
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; } } }