private SpellDefinition GetSpellDefinition(int idx) { SpellDefinition def = null; switch (_spellBookType) { case SpellBookType.Magery: def = SpellsMagery.GetSpell(idx); break; case SpellBookType.Necromancy: def = SpellsNecromancy.GetSpell(idx); break; case SpellBookType.Chivalry: def = SpellsChivalry.GetSpell(idx); break; case SpellBookType.Bushido: def = SpellsBushido.GetSpell(idx); break; case SpellBookType.Ninjitsu: def = SpellsNinjitsu.GetSpell(idx); break; case SpellBookType.Spellweaving: def = SpellsSpellweaving.GetSpell(idx); break; case SpellBookType.Mysticism: def = SpellsMysticism.GetSpell(idx); break; case SpellBookType.Bardic: def = SpellsBardic.GetSpell(idx); break; } return(def); }
private void GetSpellRequires(int offset, out int y, out string text) { y = 162; int manaCost = 0; int minSkill = 0; switch (_spellBookType) { case SpellBookType.Necromancy: SpellDefinition def = SpellsNecromancy.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Chivalry: def = SpellsChivalry.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Bushido: def = SpellsBushido.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Ninjitsu: def = SpellsNinjitsu.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Spellweaving: def = SpellsSpellweaving.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Mysticism: def = SpellsMysticism.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; break; case SpellBookType.Bardic: def = SpellsBardic.GetSpell(offset + 1); manaCost = def.ManaCost; minSkill = def.MinSkill; y = 140; text = $"Upkeep Cost: {def.TithingCost}\nMana cost: {manaCost}\nMin. Skill: {minSkill}"; return; } text = $"Mana cost: {manaCost}\nMin. Skill: {minSkill}"; }
private void GetSpellNames(int offset, out string name, out string abbreviature, out string reagents) { switch (_spellBookType) { case SpellBookType.Magery: SpellDefinition def = SpellsMagery.GetSpell(offset + 1); name = def.Name; abbreviature = SpellsMagery.SpecialReagentsChars[offset]; reagents = def.CreateReagentListString("\n"); break; case SpellBookType.Necromancy: def = SpellsNecromancy.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = def.CreateReagentListString("\n"); break; case SpellBookType.Chivalry: def = SpellsChivalry.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = string.Empty; break; case SpellBookType.Bushido: def = SpellsBushido.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = string.Empty; break; case SpellBookType.Ninjitsu: def = SpellsNinjitsu.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = string.Empty; break; case SpellBookType.Spellweaving: def = SpellsSpellweaving.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = string.Empty; break; case SpellBookType.Mysticism: def = SpellsMysticism.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = def.CreateReagentListString("\n"); break; case SpellBookType.Bardic: def = SpellsBardic.GetSpell(offset + 1); name = def.Name; abbreviature = def.PowerWords; reagents = string.Empty; break; default: throw new ArgumentOutOfRangeException(); } }
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); }