public static int GetSpellHueFor(Mobile mobile, HueableSpell hueableSpell) { int hue = 0; BaseCreature bc_Creature = mobile as BaseCreature; if (bc_Creature != null) { return(bc_Creature.SpellHue); } PlayerMobile player = mobile as PlayerMobile; if (player == null) { return(hue); } SpellHueEntry entry = GetSpellHueEntry(player, hueableSpell); if (entry == null) { return(hue); } return(SpellHue.GetSpellHue(entry.m_ActiveHue)); }
public override void OnResponse(NetState sender, RelayInfo info) { PlayerMobile player = sender.Mobile as PlayerMobile; if (player == null) { return; } if (player.Deleted) { return; } //Previous if (info.ButtonID == 1) { if (m_PageNumber > 1) { m_PageNumber--; player.SendSound(0x055); player.CloseGump(typeof(PlayerSpellHuesGump)); player.SendGump(new PlayerSpellHuesGump(player, m_PageNumber)); return; } } //Next if (info.ButtonID == 2) { if (m_PageNumber < m_TotalPages) { m_PageNumber++; player.SendSound(0x055); player.CloseGump(typeof(PlayerSpellHuesGump)); player.SendGump(new PlayerSpellHuesGump(player, m_PageNumber)); return; } } //Entries if (info.ButtonID > 2) { if (m_SpellsOnPage.Count == 0) { return; } int totalHues = Enum.GetNames(typeof(SpellHueType)).Length; int baseIndex = info.ButtonID - 3; int spellIndex = (int)(Math.Floor((double)baseIndex / (double)totalHues)); int hueTypeIndex = baseIndex - (spellIndex * totalHues); if (spellIndex > m_SpellsOnPage.Count || spellIndex < 0) { player.SendMessage("Invalid selection."); return; } if (spellIndex >= m_SpellsOnPage.Count) { return; } HueableSpell hueableSpell = m_SpellsOnPage[spellIndex]; if (hueTypeIndex >= totalHues || hueableSpell == null) { return; } SpellHueType spellHueType = (SpellHueType)hueTypeIndex; HueableSpellDetail spellDetail = SpellHue.GetHueableSpellDetail(hueableSpell); SpellHueEntry spellEntry = PlayerEnhancementPersistance.GetSpellHueEntry(player, hueableSpell); if (spellDetail == null || spellEntry == null) { return; } bool unlocked = false; bool active = false; if (spellEntry.m_UnlockedHues.Contains(spellHueType)) { unlocked = true; } if (spellEntry.m_ActiveHue == spellHueType) { active = true; } if (unlocked) { if (active) { if (spellHueType == SpellHueType.Basic) { player.SendMessage("The standard hue for a spell cannot be deactivated."); } else { player.SendMessage("You disable the custom spell hue and activate the basic hue."); spellEntry.m_ActiveHue = SpellHueType.Basic; player.SendSound(0x1EC); } } else { player.SendMessage("You activate the custom spell hue."); spellEntry.m_ActiveHue = spellHueType; player.SendSound(0x1EC); } player.CloseGump(typeof(PlayerSpellHuesGump)); player.SendGump(new PlayerSpellHuesGump(player, m_PageNumber)); return; } else { player.SendMessage("You have not unlocked that hue for that spell. Spell Hue Deeds may be obtained from the Donation Shop or may be discovered out in the world."); player.CloseGump(typeof(PlayerSpellHuesGump)); player.SendGump(new PlayerSpellHuesGump(player, m_PageNumber)); return; } } player.CloseGump(typeof(PlayerSpellHuesGump)); player.SendGump(new PlayerEnhancementGump(player)); return; }
public PlayerSpellHuesGump(Mobile from, int pageNumber) : base(10, 10) { PlayerMobile player = from as PlayerMobile; if (player == null) { return; } m_Player = player; m_PageNumber = pageNumber; Closable = true; Disposable = true; Dragable = true; Resizable = false; AddImage(0, 44, 202); AddImage(44, 0, 201); AddImage(0, 0, 206); AddImage(0, 468, 204); AddImage(590, 1, 207); AddImage(590, 468, 205); AddImage(44, 468, 233); AddImage(590, 45, 203); AddImageTiled(44, 44, 546, 424, 200); AddImage(0, 152, 202); AddImage(163, 0, 201); AddImage(166, 468, 233); AddImage(590, 152, 203); //------------- int textHue = 2036; int boldHue = 149; int totalSpells = Enum.GetNames(typeof(HueableSpell)).Length; int totalHues = Enum.GetNames(typeof(SpellHueType)).Length; int spellsPerPage = 3; m_TotalPages = (int)(Math.Ceiling((double)totalSpells / (double)spellsPerPage)); int indexStart = (m_PageNumber - 1) * spellsPerPage; int indexEnd; if (indexStart + spellsPerPage <= totalSpells) { indexEnd = indexStart + spellsPerPage; } else { indexEnd = totalSpells; } var iStartY = 50; var iSpacingY = 135; AddLabel(292, 20, 2606, "Spell Hues"); int iRow = 0; //Entry for (int a = indexStart; a < indexEnd; a++) { HueableSpell hueableSpell = (HueableSpell)a; HueableSpellDetail spellDetail = SpellHue.GetHueableSpellDetail(hueableSpell); SpellHueEntry spellEntry = PlayerEnhancementPersistance.GetSpellHueEntry(player, hueableSpell); if (hueableSpell == null || spellDetail == null || spellEntry == null) { return; } m_SpellsOnPage.Add(hueableSpell); AddLabel(320 - (spellDetail.m_SpellName.Length * 3), iStartY, boldHue, spellDetail.m_SpellName); for (int b = 0; b < totalHues; b++) { SpellHueType spellHueType = (SpellHueType)b; SpellHueTypeDetail spellHueTypeDetail = SpellHue.GetSpellHueTypeDetail(spellHueType); AddItem((100 + (75 * b)), iStartY + 25, spellDetail.m_IconItemId, spellHueTypeDetail.m_DisplayHue); AddLabel((120 + (75 * b)) - (spellHueTypeDetail.m_Name.Length * 3), iStartY + 75, textHue, spellHueTypeDetail.m_Name); bool unlocked = false; bool active = false; if (spellEntry.m_UnlockedHues.Contains(spellHueType)) { unlocked = true; } if (spellEntry.m_ActiveHue == spellHueType) { active = true; } int buttonIndex = 3 + (iRow * totalHues) + b; if (unlocked) { if (active) { AddButton(105 + (75 * b), iStartY + 100, 2154, 2151, buttonIndex, GumpButtonType.Reply, 0); } else { AddButton(105 + (75 * b), iStartY + 100, 2151, 2154, buttonIndex, GumpButtonType.Reply, 0); } } else { AddButton(105 + (75 * b), iStartY + 100, 9727, 9727, buttonIndex, GumpButtonType.Reply, 0); } } iStartY += iSpacingY; iRow++; } //Navigation if (m_PageNumber > 1) { AddButton(50, 465, 4014, 4016, 1, GumpButtonType.Reply, 0); AddLabel(85, 465, textHue, @"Previous Page"); } if (m_PageNumber < m_TotalPages) { AddButton(485, 465, 4005, 4007, 2, GumpButtonType.Reply, 0); AddLabel(520, 465, textHue, @"Next Page"); } }