private void BuildGump() { GumpPic pic = new GumpPic(0, 0, Graphic, 0); Add(pic); pic.SetTooltip(ClilocLoader.Instance.GetString(1112198 + (Graphic - 0x5DD0)), 200); }
private void CreateBook() { Clear(); _pageCornerLeft = _pageCornerRight = null; GetBookInfo(_spellBookType, out Graphic bookGraphic, out Graphic minimizedGraphic, out Graphic iconStartGraphic, out int maxSpellsCount, out int spellsOnPage, out int dictionaryPagesCount); Add(new GumpPic(0, 0, bookGraphic, 0)); Add(_pageCornerLeft = new GumpPic(50, 8, 0x08BB, 0)); _pageCornerLeft.LocalSerial = 0; _pageCornerLeft.Page = int.MaxValue; _pageCornerLeft.MouseUp += PageCornerOnMouseClick; _pageCornerLeft.MouseDoubleClick += PageCornerOnMouseDoubleClick; Add(_pageCornerRight = new GumpPic(321, 8, 0x08BC, 0)); _pageCornerRight.LocalSerial = 1; _pageCornerRight.Page = 1; _pageCornerRight.MouseUp += PageCornerOnMouseClick; _pageCornerRight.MouseDoubleClick += PageCornerOnMouseDoubleClick; int totalSpells = 0; for (int circle = 0; circle < 8; circle++) { for (int i = 1; i <= 8; i++) { if (_spellBook.HasSpell(circle, i)) { _spells[circle * 8 + i - 1] = true; totalSpells++; } } } _maxPage = (dictionaryPagesCount >> 1) + ((totalSpells + 1) >> 1); int offs = 0; if (_spellBookType == SpellBookType.Magery) { Add(new Button((int)ButtonCircle.Circle_1_2, 0x08B1, 0x08B1) { X = 58, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 1 }); Add(new Button((int)ButtonCircle.Circle_1_2, 0x08B2, 0x08B2) { X = 93, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 1 }); Add(new Button((int)ButtonCircle.Circle_3_4, 0x08B3, 0x08B3) { X = 130, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 2 }); Add(new Button((int)ButtonCircle.Circle_3_4, 0x08B4, 0x08B4) { X = 164, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 2 }); Add(new Button((int)ButtonCircle.Circle_5_6, 0x08B5, 0x08B5) { X = 227, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 3 }); Add(new Button((int)ButtonCircle.Circle_5_6, 0x08B6, 0x08B6) { X = 260, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 3 }); Add(new Button((int)ButtonCircle.Circle_7_8, 0x08B7, 0x08B7) { X = 297, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 4 }); Add(new Button((int)ButtonCircle.Circle_7_8, 0x08B8, 0x08B8) { X = 332, Y = 175, ButtonAction = ButtonAction.Activate, ToPage = 4 }); } int spellDone = 0; for (int i = 1; i <= dictionaryPagesCount >> 1; i++) { int page = i; for (int j = 0; j < 2; j++) { if (page == 1 && _spellBookType == SpellBookType.Chivalry) { Label label = new Label("Tithing points\nAvailable: " + World.Player.TithingPoints, false, 0x0288, font: 6) { X = 62, Y = 162 }; Add(label, page); } int indexX = 106; int dataX = 62; int y = 0; if (j % 2 != 0) { indexX = 269; dataX = 225; } Label text = new Label("INDEX", false, 0x0288, font: 6) { X = indexX, Y = 10 }; Add(text, page); if (_spellBookType == SpellBookType.Magery) { text = new Label(SpellsMagery.CircleNames[(i - 1) * 2 + j % 2], false, 0x0288, font: 6) { X = dataX, Y = 30 }; Add(text, page); } int topage = (dictionaryPagesCount >> 1) + ((spellDone + 1) >> 1); for (int k = 0; k < spellsOnPage; k++) { if (_spells[offs]) { GetSpellNames(offs, out string name, out string abbreviature, out string reagents); if (spellDone % 2 == 0) { topage++; } spellDone++; text = new HoveredLabel(name, false, 0x0288, 0x33, font: 9) { X = dataX, Y = 52 + y, LocalSerial = (uint)topage, AcceptMouseInput = true, Tag = offs + 1 }; text.MouseUp += OnClicked; text.MouseDoubleClick += OnDoubleClicked; Add(text, page); y += 15; } offs++; } } } int page1 = (dictionaryPagesCount >> 1) + 1; int topTextY = 6; for (int i = 0, spellsDone = 0; i < maxSpellsCount; i++) { if (!_spells[i]) { continue; } int iconX = 62; int topTextX = 87; int iconTextX = 112; uint iconSerial = 100 + (uint)i; if (spellsDone > 0) { if (spellsDone % 2 != 0) { iconX = 225; topTextX = 224; iconTextX = 275; iconSerial = 1000 + (uint)i; } else { page1++; } } spellsDone++; GetSpellNames(i, out string name, out string abbreviature, out string reagents); switch (_spellBookType) { case SpellBookType.Magery: { Label text = new Label(SpellsMagery.CircleNames[i >> 3], false, 0x0288, font: 6) { X = topTextX, Y = topTextY + 4 }; Add(text, page1); text = new Label(name, false, 0x0288, 80, 6) { X = iconTextX, Y = 34 }; Add(text, page1); int abbreviatureY = 26; if (text.Height < 24) { abbreviatureY = 31; } abbreviatureY += text.Height; text = new Label(abbreviature, false, 0x0288, font: 8) { X = iconTextX, Y = abbreviatureY }; Add(text, page1); break; } case SpellBookType.Bardic: { Label text = new Label(SpellsBardic.GetUsedSkillName(i), false, 0x0288, font: 6) { X = topTextX, Y = topTextY + 4 }; Add(text, page1); text = new Label(name, false, 0x0288, 80, 6) { X = iconTextX, Y = 34 }; Add(text, page1); break; } default: { Label text = new Label(name, false, 0x0288, font: 6) { X = topTextX, Y = topTextY }; Add(text, page1); if (!string.IsNullOrEmpty(abbreviature)) { text = new Label(abbreviature, false, 0x0288, 80, 6) { X = iconTextX, Y = 34 }; Add(text, page1); } break; } } GumpPic icon = new GumpPic(iconX, 40, (Graphic)(iconStartGraphic + i), 0) { X = iconX, Y = 40, LocalSerial = iconSerial }; GetSpellToolTip(out int toolTipCliloc); if (toolTipCliloc > 0) { string tooltip = FileManager.Cliloc.GetString(toolTipCliloc + i); icon.SetTooltip(tooltip, 150); } icon.MouseDoubleClick += (sender, e) => { if (e.Button == MouseButton.Left) { SpellDefinition def = GetSpellDefinition(sender as Control); if (def != null) { GameActions.CastSpell(def.ID); } } }; icon.DragBegin += (sender, e) => { if (Engine.UI.IsDragging) { return; } SpellDefinition def = GetSpellDefinition(sender as Control); if (def == null) { return; } UseSpellButtonGump gump = new UseSpellButtonGump(def) { X = Mouse.Position.X - 22, Y = Mouse.Position.Y - 22 }; Engine.UI.Add(gump); Engine.UI.AttemptDragControl(gump, Mouse.Position, true); }; Add(icon, page1); if (!string.IsNullOrEmpty(reagents)) { Add(new GumpPicTiled(iconX, 88, 120, 5, 0x0835), page1); Label text = new Label("Reagents:", false, 0x0288, font: 6) { X = iconX, Y = 92 }; Add(text, page1); text = new Label(reagents, false, 0x0288, font: 9) { X = iconX, Y = 114 }; Add(text, page1); } if (_spellBookType != SpellBookType.Magery) { GetSpellRequires(i, out int requiriesY, out string requires); Label text = new Label(requires, false, 0x0288, font: 6) { X = iconX, Y = requiriesY }; Add(text, page1); } } SetActivePage(1); }
private void BuildGump() { Add(new GumpPic(0, 0, 0x2B29, 0)); Add(_pageCornerLeft = new GumpPic(50, 8, 0x08BB, 0)); _pageCornerLeft.LocalSerial = 0; _pageCornerLeft.Page = int.MaxValue; _pageCornerLeft.MouseUp += PageCornerOnMouseClick; _pageCornerLeft.MouseDoubleClick += PageCornerOnMouseDoubleClick; Add(_pageCornerRight = new GumpPic(321, 8, 0x08BC, 0)); _pageCornerRight.LocalSerial = 1; _pageCornerRight.Page = 1; _pageCornerRight.MouseUp += PageCornerOnMouseClick; _pageCornerRight.MouseDoubleClick += PageCornerOnMouseDoubleClick; int abilityOnPage = 0; ushort iconStartGraphic = 0; GetSummaryBookInfo(ref abilityOnPage, ref iconStartGraphic); _pagesCount = _dictionaryPagesCount + (_abilityCount >> 1); //_pagesCount >>= 1; int offs = 0; for (int page = 1; page <= _dictionaryPagesCount; page++) { for (int j = 0; j < 2; j++) { int indexX = 106; int dataX = 62; int y = 0; if (j % 2 != 0) { indexX = 269; dataX = 225; } Label text = new Label("INDEX", false, 0x0288, font: 6) { X = indexX, Y = 10 }; Add(text, page); for (int i = 0; i < abilityOnPage; i++) { if (offs >= _abilityCount) { break; } bool passive = true; text = new HoveredLabel(GetAbilityName(offs, ref passive), false, 0x0288, 0x33, font: 9) { X = dataX, Y = 52 + y, AcceptMouseInput = true }; Add(text, page); y += 15; offs++; } } } int page1 = _dictionaryPagesCount; for (int i = 0; i < _abilityCount; i++) { int iconX = 62; int iconTextX = 112; if (i > 0 && i % 2 != 0) { iconX = 225; iconTextX = 275; } else { page1++; } bool passive = true; string spellName = GetAbilityName(i, ref passive); Label text = new Label(spellName, false, 0x0288, 100, 6) { X = iconTextX, Y = 34 }; Add(text, page1); if (passive) { text = new Label("(Passive)", false, 0x0288, font: 6) { X = iconTextX, Y = 64 }; Add(text, page1); } GumpPic pic = new GumpPic(iconX, 40, iconStartGraphic, 0); Add(pic, page1); pic.SetTooltip(UOFileManager.Cliloc.GetString(_tooltipOffset + i), 150); Add(new GumpPicTiled(iconX, 88, 120, 4, 0x0835), page1); } }
private void BuildGump() { Add(new GumpPic(0, 0, 0x2B02, 0)); Add(_pageCornerLeft = new GumpPic(50, 8, 0x08BB, 0)); _pageCornerLeft.LocalSerial = 0; _pageCornerLeft.Page = int.MaxValue; _pageCornerLeft.MouseUp += PageCornerOnMouseClick; _pageCornerLeft.MouseDoubleClick += PageCornerOnMouseDoubleClick; Add(_pageCornerRight = new GumpPic(321, 8, 0x08BC, 0)); _pageCornerRight.LocalSerial = 1; _pageCornerRight.Page = 1; _pageCornerRight.MouseUp += PageCornerOnMouseClick; _pageCornerRight.MouseDoubleClick += PageCornerOnMouseDoubleClick; int offs = 0; int maxPages = _dictionaryPagesCount + 1; for (int page = 1; page <= _dictionaryPagesCount; page++) { for (int j = 0; j < 2; j++) { int indexX = 96; int dataX = 52; int y = 0; int spellsOnPage = 9; if (j % 2 != 0) { indexX = 259; dataX = 215; spellsOnPage = 4; } Label text = new Label(ResGumps.Index, false, 0x0288, font: 6) { X = indexX, Y = 6 }; Add(text, page); for (int i = 0; i < spellsOnPage; i++) { if (offs >= _abilityCount) { break; } text = new HoveredLabel ( AbilityData.Abilities[offs].Name, false, 0x0288, 0x33, 0x0288, font: 9 ) { X = dataX, Y = 42 + y, AcceptMouseInput = true, LocalSerial = (uint)maxPages++, Tag = offs }; text.MouseUp += (s, e) => { if (s is HoveredLabel l && e.Button == MouseButtonType.Left) { _clickTiming += Mouse.MOUSE_DELAY_DOUBLE_CLICK; if (_clickTiming > 0) { _lastPressed = l; } } }; Add(text, page); text.SetTooltip(ClilocLoader.Instance.GetString(1061693 + offs), 150); y += 15; offs++; } if (spellsOnPage == 4) { byte bab1 = (byte)(((byte)World.Player.PrimaryAbility & 0x7F) - 1); _primAbility = new GumpPic(215, 105, (ushort)(0x5200 + bab1), 0); text = new Label ( ResGumps.PrimaryAbilityIcon, false, 0x0288, 80, 6 ) { X = 265, Y = 105 }; Add(_primAbility, page); Add(text, page); _primAbility.SetTooltip(ClilocLoader.Instance.GetString(1028838 + bab1)); _primAbility.DragBegin += OnGumpicDragBeginPrimary; byte bab2 = (byte)(((byte)World.Player.SecondaryAbility & 0x7F) - 1); _secAbility = new GumpPic(215, 150, (ushort)(0x5200 + bab2), 0); text = new Label ( ResGumps.SecondaryAbilityIcon, false, 0x0288, 80, 6 ) { X = 265, Y = 150 }; Add(_secAbility, page); Add(text, page); _secAbility.SetTooltip(ClilocLoader.Instance.GetString(1028838 + bab2)); _secAbility.DragBegin += OnGumpicDragBeginSecondary; } } } int pageW = _dictionaryPagesCount + 1; _dictionaryPagesCount += _abilityCount; for (int i = 0; i < _abilityCount; i++, pageW++) { if (i >= AbilityData.Abilities.Length) { break; } GumpPic icon = new GumpPic(62, 40, (ushort)(0x5200 + i), 0); Add(icon, pageW); icon.SetTooltip(ClilocLoader.Instance.GetString(1061693 + i), 150); Label text = new Label ( StringHelper.CapitalizeAllWords(AbilityData.Abilities[i].Name), false, 0x0288, 80, 6 ) { X = 110, Y = 34 }; Add(text, pageW); Add ( new GumpPicTiled(0x0835) { X = 62, Y = 88, Width = 128 }, pageW ); List <ushort> list = GetItemsList((byte)i); int maxStaticCount = TileDataLoader.Instance.StaticData.Length; int textX = 62; int textY = 98; for (int j = 0; j < list.Count; j++) { if (j == 6) { textX = 215; textY = 34; } ushort id = list[j]; if (id >= maxStaticCount) { continue; } text = new Label(StringHelper.CapitalizeAllWords(TileDataLoader.Instance.StaticData[id].Name), false, 0x0288, font: 9) { X = textX, Y = textY }; Add(text, pageW); textY += 16; } } }
public static Control Create(uint sender, uint gumpID, int x, int y, string layout, string[] lines) { Gump gump = null; bool mustBeAdded = true; if (GetGumpCachePosition(gumpID, out Point pos)) { x = pos.X; y = pos.Y; for (var last = Gumps.Last; last != null; last = last.Previous) { var g = last.Value; if (!g.IsDisposed && g.LocalSerial == sender && g.ServerSerial == gumpID) { g.Clear(); gump = g as Gump; mustBeAdded = false; break; } } } else { SavePosition(gumpID, new Point(x, y)); } if (gump == null) { gump = new Gump(sender, gumpID) { X = x, Y = y, CanMove = true, CanCloseWithRightClick = true, CanCloseWithEsc = true } } ; int group = 0; int page = 0; List <string> cmdlist = _parser.GetTokens(layout); int cmdlen = cmdlist.Count; bool applyCheckerTrans = false; bool textBoxFocused = false; for (int cnt = 0; cnt < cmdlen; cnt++) { List <string> gparams = _cmdparser.GetTokens(cmdlist[cnt], false); if (gparams.Count == 0) { continue; } switch (gparams[0].ToLower()) { case "button": gump.Add(new Button(gparams), page); break; case "buttontileart": gump.Add(new ButtonTileArt(gparams), page); break; case "checkertrans": applyCheckerTrans = true; gump.Add(new CheckerTrans(gparams), page); break; case "croppedtext": gump.Add(new CroppedText(gparams, lines), page); break; case "gumppic": GumpPic pic = new GumpPic(gparams); if (gparams.Count >= 6 && gparams[5].ToLower().Contains("virtuegumpitem")) { pic.ContainsByBounds = true; pic.IsVirtue = true; string s, lvl; switch (pic.Hue) { case 2403: lvl = ""; break; case 1154: case 1547: case 2213: case 235: case 18: case 2210: case 1348: lvl = "Seeker of "; break; case 2404: case 1552: case 2216: case 2302: case 2118: case 618: case 2212: case 1352: lvl = "Follower of "; break; case 43: case 53: case 1153: case 33: case 318: case 67: case 98: lvl = "Knight of "; break; case 2406: if (pic.Graphic == 0x6F) { lvl = "Seeker of "; } else { lvl = "Knight of "; } break; default: lvl = ""; break; } switch (pic.Graphic) { case 0x69: s = ClilocLoader.Instance.GetString(1051000 + 2); break; case 0x6A: s = ClilocLoader.Instance.GetString(1051000 + 7); break; case 0x6B: s = ClilocLoader.Instance.GetString(1051000 + 5); break; case 0x6D: s = ClilocLoader.Instance.GetString(1051000 + 6); break; case 0x6E: s = ClilocLoader.Instance.GetString(1051000 + 1); break; case 0x6F: s = ClilocLoader.Instance.GetString(1051000 + 3); break; case 0x70: s = ClilocLoader.Instance.GetString(1051000 + 4); break; case 0x6C: default: s = ClilocLoader.Instance.GetString(1051000); break; } if (string.IsNullOrEmpty(s)) { s = "Unknown virtue"; } pic.SetTooltip(lvl + s, 100); } gump.Add(pic, page); break; case "gumppictiled": gump.Add(new GumpPicTiled(gparams), page); break; case "htmlgump": gump.Add(new HtmlControl(gparams, lines), page); break; case "xmfhtmlgump": gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", ClilocLoader.Instance.GetString(int.Parse(gparams[5])), 0, true), page); break; case "xmfhtmlgumpcolor": int color = int.Parse(gparams[8]); if (color == 0x7FFF) { color = 0x00FFFFFF; } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", ClilocLoader.Instance.GetString(int.Parse(gparams[5])), color, true), page); break; case "xmfhtmltok": color = int.Parse(gparams[7]); if (color == 0x7FFF) { color = 0x00FFFFFF; } StringBuilder sb = null; if (gparams.Count > 9) { sb = new StringBuilder(); sb.Append(gparams[9]); for (int i = 10; i < gparams.Count; i++) { sb.Append(' '); sb.Append(gparams[i]); } } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[5]) == 1, int.Parse(gparams[6]) != 0, gparams[5] != "0" && gparams[6] == "2", sb == null ? ClilocLoader.Instance.GetString(int.Parse(gparams[8])) : ClilocLoader.Instance.Translate(ClilocLoader.Instance.GetString(int.Parse(gparams[8])), sb.ToString().Trim('@').Replace('@', '\t')), color, true), page); break; case "page": if (gparams.Count >= 2) { page = int.Parse(gparams[1]); } break; case "resizepic": gump.Add(new ResizePic(gparams), page); break; case "text": if (gparams.Count >= 5) { gump.Add(new Label(gparams, lines), page); } break; case "textentrylimited": case "textentry": TextBox textBox = new TextBox(gparams, lines); if (!textBoxFocused) { textBox.SetKeyboardFocus(); textBoxFocused = true; } gump.Add(textBox, page); break; case "tilepichue": case "tilepic": gump.Add(new StaticPic(gparams), page); break; case "noclose": gump.CanCloseWithRightClick = false; break; case "nodispose": gump.CanCloseWithEsc = false; break; case "nomove": gump.BlockMovement = true; break; case "group": case "endgroup": group++; break; case "radio": gump.Add(new RadioButton(group, gparams, lines), page); break; case "checkbox": gump.Add(new Checkbox(gparams, lines), page); break; case "tooltip": if (World.ClientFeatures.TooltipsEnabled) { string text = ClilocLoader.Instance.GetString(int.Parse(gparams[1])); if (gparams.Count > 2 && gparams[2].Length != 0) { string args = gparams[2]; if (args.Length > 1) { text = ClilocLoader.Instance.Translate(text, args); } else { Log.Error($"String '{args}' too short, something wrong with gump tooltip: {text}"); } } gump.Children.LastOrDefault()?.SetTooltip(text); } break; case "itemproperty": if (World.ClientFeatures.TooltipsEnabled) { gump.Children.LastOrDefault()?.SetTooltip(SerialHelper.Parse(gparams[1])); } break; case "noresize": break; case "mastergump": Log.Warn("Gump part 'mastergump' not handled."); break; default: Log.Warn(gparams[0]); break; } } if (applyCheckerTrans) { bool applyTrans(int ii, int current_page) { bool transparent = false; for (; ii < gump.Children.Count; ii++) { var child = gump.Children[ii]; if (current_page == 0) { current_page = child.Page; } bool canDraw = /*current_page == 0 || child.Page == 0 ||*/ current_page == child.Page; if (canDraw && child.IsVisible && child is CheckerTrans) { transparent = true; continue; } child.Alpha = transparent ? 0.5f : 0; } return(transparent); } bool trans = applyTrans(0, 0); float alpha = trans ? 0.5f : 0; for (int i = 0; i < gump.Children.Count; i++) { var cc = gump.Children[i]; if (cc is CheckerTrans) { trans = applyTrans(i + 1, cc.Page); alpha = trans ? 0.5f : 0; } else { cc.Alpha = alpha; } } } if (mustBeAdded) { Add(gump); } gump.Update(Time.Ticks, 0); gump.SetInScreen(); return(gump); }
private void BuildGump() { Add(new GumpPic(0, 0, 0x2B29, 0)); Add(_pageCornerLeft = new GumpPic(50, 8, 0x08BB, 0)); _pageCornerLeft.LocalSerial = 0; _pageCornerLeft.Page = int.MaxValue; _pageCornerLeft.MouseUp += PageCornerOnMouseClick; _pageCornerLeft.MouseDoubleClick += PageCornerOnMouseDoubleClick; Add(_pageCornerRight = new GumpPic(321, 8, 0x08BC, 0)); _pageCornerRight.LocalSerial = 1; _pageCornerRight.Page = 1; _pageCornerRight.MouseUp += PageCornerOnMouseClick; _pageCornerRight.MouseDoubleClick += PageCornerOnMouseDoubleClick; int abilityOnPage = 0; ushort iconStartGraphic = 0; GetSummaryBookInfo(ref abilityOnPage, ref iconStartGraphic); _pagesCount = _dictionaryPagesCount + (_abilityCount >> 1); int offs = 0; for (int page = 1, topage = _dictionaryPagesCount - 1; page <= _dictionaryPagesCount; page++) { for (int j = 0; j < 2; j++) { int indexX = 106; int dataX = 62; int y = 0; if (j % 2 != 0) { indexX = 269; dataX = 225; } Label text = new Label(ResGumps.Index, false, 0x0288, font: 6) { X = indexX, Y = 10 }; Add(text, page); for (int i = 0; i < abilityOnPage; i++) { if (offs >= _abilityCount) { break; } if (offs % 2 == 0) { topage++; } bool passive = true; text = new HoveredLabel(GetAbilityName(offs, ref passive), false, 0x0288, 0x33, 0x0288, font: 9) { X = dataX, Y = 52 + y, AcceptMouseInput = true, LocalSerial = (uint)topage }; text.MouseUp += OnClicked; Add(text, page); y += 15; offs++; } } } int page1 = _dictionaryPagesCount - 1; for (int i = 0; i < _abilityCount; i++) { int iconX = 62; int iconTextX = 112; if (i > 0 && i % 2 != 0) { iconX = 225; iconTextX = 275; } else { page1++; } bool passive = true; string spellName = GetAbilityName(i, ref passive); Label text = new Label(spellName, false, 0x0288, 100, 6) { X = iconTextX, Y = 34 }; Add(text, page1); if (passive) { text = new Label(ResGumps.Passive, false, 0x0288, font: 6) { X = iconTextX, Y = 64 }; Add(text, page1); } ushort graphic = (ushort)(iconStartGraphic + i); GumpPic pic = new GumpPic(iconX, 40, graphic, 0) { LocalSerial = graphic }; if (!passive) { pic.DragBegin += (sender, e) => { if (UIManager.IsDragging) { return; } RacialAbilityButton gump = new RacialAbilityButton((ushort)((GumpPic)sender).LocalSerial) { X = Mouse.LDropPosition.X - 20, Y = Mouse.LDropPosition.Y - 20 }; UIManager.Add(gump); UIManager.AttemptDragControl(gump, Mouse.Position, true); }; pic.MouseDoubleClick += (sender, e) => { if ((ushort)((GumpPic)sender).LocalSerial == 0x5DDA && World.Player.Race == RaceType.GARGOYLE) { NetClient.Socket.Send(new PToggleGargoyleFlying()); e.Result = true; } }; } Add(pic, page1); pic.SetTooltip(ClilocLoader.Instance.GetString(_tooltipOffset + i), 150); Add(new GumpPicTiled(iconX, 88, 120, 4, 0x0835), page1); } }
public static Control Create(Serial sender, Serial gumpID, int x, int y, string layout, string[] lines) { if (GetGumpCachePosition(gumpID, out Point pos)) { x = pos.X; y = pos.Y; } else { SavePosition(gumpID, new Point(x, y)); } Gump gump = new Gump(sender, gumpID) { X = x, Y = y, CanMove = true, CanCloseWithRightClick = true, CanCloseWithEsc = true }; int group = 0; int page = 0; List <string> cmdlist = _parser.GetTokens(layout); int cmdlen = cmdlist.Count; bool applyCheckerTrans = false; for (int cnt = 0; cnt < cmdlen; cnt++) { List <string> gparams = _cmdparser.GetTokens(cmdlist[cnt], false); if (gparams.Count == 0) { continue; } switch (gparams[0].ToLower()) { case "button": gump.Add(new Button(gparams), page); break; case "buttontileart": gump.Add(new Button(gparams) { ContainsByBounds = true }, page); gump.Add(new StaticPic(Graphic.Parse(gparams[8]), Hue.Parse(gparams[9])) { X = int.Parse(gparams[1]) + int.Parse(gparams[10]), Y = int.Parse(gparams[2]) + int.Parse(gparams[11]), AcceptMouseInput = true }, page); break; case "checkertrans": CheckerTrans t = new CheckerTrans(gparams); applyCheckerTrans = true; //bool applyTrans(int ii, int current_page) //{ // bool transparent = false; // for (; ii < gump.Children.Count; ii++) // { // var child = gump.Children[ii]; // bool canDraw = /*current_page == 0 || child.Page == 0 ||*/ // current_page == child.Page; // if (canDraw && child.IsVisible && child is CheckerTrans) // { // transparent = true; // } // } // return transparent; //} //void checkerContains(int ii, float tr) //{ // var master = gump.Children[ii]; // for (int i = 0; i < ii; i++) // { // var cc = gump.Children[i]; // if (master.Bounds.Contains(cc.Bounds)) // { // cc.Alpha = 1f; // } // } //} //Rectangle bounds = t.Bounds; //bool trans = false; //for (int i = gump.Children.Count - 1; i >= 0; i--) //{ // var cc = gump.Children[i]; // if (cc is CheckerTrans) // { // trans = applyTrans(i, cc.Page); // bounds = cc.Bounds; // continue; // } // if (bounds.Contains(cc.Bounds)) // { // cc.Alpha = 1f; // } // else // cc.Alpha = trans ? 1 : 0.5f; //} gump.Add(t, page); // int j = 0; // bool trans = applyTrans(j, page, null); // float alpha = trans ? 1 : 0.5f; //// checkerContains(j, alpha); // for (; j < gump.Children.Count; j++) // { // var child = gump.Children[j]; // if (child is CheckerTrans tt) // { // trans = applyTrans(j, child.Page, tt); // alpha = trans ? 1 : .5f; // checkerContains(j, alpha); // } // else // { // child.Alpha = alpha != 1 ? 0.5f : alpha; // } // } //float[] alpha = { 1f, 0.5f }; //bool checkTransparent(Control c, int start) //{ // bool transparent = false; // for (int i = start; i < c.Children.Count; i++) // //for (int i = start; i >= 0; i--) // { // var control = c.Children[i]; // bool canDraw = /*c.Page == 0 || control.Page == 0 || c.Page == control.Page ||*/ control.Page == page; // if (canDraw && control is CheckerTrans) // { // transparent = true; // } // } // return transparent; //} //bool trans = checkTransparent(gump, 0); //for (int i = gump.Children.Count - 1; i >= 0; i--) //{ // Control g = gump.Children[i]; // g.Initialize(); // g.IsTransparent = true; // if (g is CheckerTrans) // { // trans = checkTransparent(gump, i + 1); // continue; // } // g.Alpha = alpha[trans ? 0 : 1]; //} break; case "croppedtext": gump.Add(new CroppedText(gparams, lines), page); break; case "gumppic": GumpPic pic = new GumpPic(gparams); if (gparams.Count >= 6 && gparams[5].ToLower().Contains("virtuegumpitem")) { pic.ContainsByBounds = true; pic.IsVirtue = true; string s, lvl; switch (pic.Hue) { case 2403: lvl = ""; break; case 1154: case 1547: case 2213: case 235: case 18: case 2210: case 1348: lvl = "Seeker of "; break; case 2404: case 1552: case 2216: case 2302: case 2118: case 618: case 2212: case 1352: lvl = "Follower of "; break; case 43: case 53: case 1153: case 33: case 318: case 67: case 98: lvl = "Knight of "; break; case 2406: if (pic.Graphic == 0x6F) { lvl = "Seeker of "; } else { lvl = "Knight of "; } break; default: lvl = ""; break; } switch (pic.Graphic) { case 0x69: s = UOFileManager.Cliloc.GetString(1051000 + 2); break; case 0x6A: s = UOFileManager.Cliloc.GetString(1051000 + 7); break; case 0x6B: s = UOFileManager.Cliloc.GetString(1051000 + 5); break; case 0x6D: s = UOFileManager.Cliloc.GetString(1051000 + 6); break; case 0x6E: s = UOFileManager.Cliloc.GetString(1051000 + 1); break; case 0x6F: s = UOFileManager.Cliloc.GetString(1051000 + 3); break; case 0x70: s = UOFileManager.Cliloc.GetString(1051000 + 4); break; case 0x6C: default: s = UOFileManager.Cliloc.GetString(1051000); break; } if (string.IsNullOrEmpty(s)) { s = "Unknown virtue"; } pic.SetTooltip(lvl + s, 100); } gump.Add(pic, page); break; case "gumppictiled": gump.Add(new GumpPicTiled(gparams), page); break; case "htmlgump": gump.Add(new HtmlControl(gparams, lines), page); break; case "xmfhtmlgump": gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", UOFileManager.Cliloc.GetString(int.Parse(gparams[5])), 0, true), page); break; case "xmfhtmlgumpcolor": int color = int.Parse(gparams[8]); if (color == 0x7FFF) { color = 0x00FFFFFF; } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[6]) == 1, int.Parse(gparams[7]) != 0, gparams[6] != "0" && gparams[7] == "2", UOFileManager.Cliloc.GetString(int.Parse(gparams[5])), color, true), page); break; case "xmfhtmltok": color = int.Parse(gparams[7]); if (color == 0x7FFF) { color = 0x00FFFFFF; } StringBuilder sb = null; if (gparams.Count > 9) { sb = new StringBuilder(); sb.Append(gparams[9]); for (int i = 10; i < gparams.Count; i++) { sb.Append(' '); sb.Append(gparams[i]); } } gump.Add(new HtmlControl(int.Parse(gparams[1]), int.Parse(gparams[2]), int.Parse(gparams[3]), int.Parse(gparams[4]), int.Parse(gparams[5]) == 1, int.Parse(gparams[6]) != 0, gparams[5] != "0" && gparams[6] == "2", sb == null ? UOFileManager.Cliloc.GetString(int.Parse(gparams[8])) : UOFileManager.Cliloc.Translate(UOFileManager.Cliloc.GetString(int.Parse(gparams[8])), sb.ToString().Trim('@')), color, true), page); break; case "page": if (gparams.Count >= 1) { page = int.Parse(gparams[1]); } break; case "resizepic": gump.Add(new ResizePic(gparams), page); break; case "text": if (gparams.Count >= 5) { gump.Add(new Label(gparams, lines), page); } break; case "textentrylimited": case "textentry": gump.Add(new TextBox(gparams, lines), page); break; case "tilepichue": case "tilepic": gump.Add(new StaticPic(gparams), page); break; case "noclose": gump.CanCloseWithRightClick = false; break; case "nodispose": gump.CanCloseWithEsc = false; break; case "nomove": gump.BlockMovement = true; break; case "group": case "endgroup": group++; break; case "radio": gump.Add(new RadioButton(group, gparams, lines), page); break; case "checkbox": gump.Add(new Checkbox(gparams, lines), page); break; case "tooltip": if (World.ClientFeatures.TooltipsEnabled) { string cliloc = UOFileManager.Cliloc.GetString(int.Parse(gparams[1])); if (gparams.Count > 2 && gparams[2][0] == '@') { string args = gparams[2]; //Convert tooltip args format to standard cliloc format args = args.Trim('@').Replace('@', '\t'); if (args.Length > 1) { cliloc = UOFileManager.Cliloc.Translate(cliloc, args); } else { Log.Error($"String '{args}' too short, something wrong with gump tooltip: {cliloc}"); } } gump.Children.Last()?.SetTooltip(cliloc); } break; case "itemproperty": if (World.ClientFeatures.TooltipsEnabled) { var entity = World.Get(Serial.Parse(gparams[1])); var lastControl = gump.Children.LastOrDefault(); if (lastControl != default(Control) && entity != default(Entity)) { lastControl.SetTooltip(entity); } } break; case "noresize": break; case "mastergump": Log.Warn("Gump part 'mastergump' not handled."); break; } } if (applyCheckerTrans) { bool applyTrans(int ii, int current_page) { bool transparent = false; for (; ii < gump.Children.Count; ii++) { var child = gump.Children[ii]; if (current_page == 0) { current_page = child.Page; } bool canDraw = /*current_page == 0 || child.Page == 0 ||*/ current_page == child.Page; if (canDraw && child.IsVisible && child is CheckerTrans) { transparent = true; continue; } child.Alpha = transparent ? 0.5f : 0; } return(transparent); } bool trans = applyTrans(0, 0); float alpha = trans ? 0.5f : 0; for (int i = 0; i < gump.Children.Count; i++) { var cc = gump.Children[i]; if (cc is CheckerTrans) { trans = applyTrans(i + 1, cc.Page); alpha = trans ? 0.5f : 0; } else { cc.Alpha = alpha; } } } Add(gump); gump.Initialize(); gump.Update(Time.Ticks, 0); gump.SetInScreen(); return(gump); }