diff --git a/ConROC_Mage.toc b/ConROC_Mage.toc new file mode 100644 index 0000000..31fa71f --- /dev/null +++ b/ConROC_Mage.toc @@ -0,0 +1,11 @@ +## Title:-|cffFFFFFFConROC|r- |cff69CCF0Mage|r +## Version: 2.0.2 +## Author: Vae, 2.0.2 updated by Lith +## Interface: 11500 +## SavedVariablesPerCharacter: ConROCMageSpells +## Dependencies: ConROC +## LoadOnDemand: 1 + +mage_ids.lua +mage_spellmenu.lua +mage.lua diff --git a/README.md b/README.md new file mode 100644 index 0000000..efdaede --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# ConROC_Classic +This is an update to the ConROC rotation optimizer for WoW that fixes issues running the add-on in Classic. + +## License +MIT - Original copyright by Vae2009. Updates done by Lith77 \ No newline at end of file diff --git a/changes.txt b/changes.txt new file mode 100644 index 0000000..f236ece --- /dev/null +++ b/changes.txt @@ -0,0 +1,20 @@ +Ver 2.0.2 + -Support for Classic + -Started to add support for translations. +Ver 1.13.4 + -Updated to WotLK spells and talents + -Added support for not showing all spellranks + -Made Spellmenu into a scrolling area. + +Ver 1.13.3 + -Added Arcane Brilliance. + +Ver 1.13.2 + -Overhauled Rotation. + -Added Spellmenu. + +Ver 1.13.1 + -Fixed IceArmor/FrostArmor rank trail. + +Ver 1.13.0 + -Initial release for Classic WoW. \ No newline at end of file diff --git a/mage.lua b/mage.lua new file mode 100644 index 0000000..628aab4 --- /dev/null +++ b/mage.lua @@ -0,0 +1,623 @@ +local printTalentsMode = false + +-- Slash command for printing talent tree with talent names and ID numbers +SLASH_CONROCPRINTTALENTS1 = "/ConROCPT" +SlashCmdList["CONROCPRINTTALENTS"] = function() + printTalentsMode = not printTalentsMode + ConROC:PopulateTalentIDs() +end + +ConROC.Mage = {}; + +local ConROC_Mage, ids = ...; +local optionMaxIds = ...; +local currentSpecName + +function ConROC:EnableDefenseModule() + self.NextDef = ConROC.Mage.Defense; +end + +function ConROC:UNIT_SPELLCAST_SUCCEEDED(event, unitID, lineID, spellID) + if unitID == 'player' then + self.lastSpellId = spellID; + end + + ConROC:JustCasted(spellID); +end + +function ConROC:PopulateTalentIDs() + local numTabs = GetNumTalentTabs() + + for tabIndex = 1, numTabs do + local tabName = GetTalentTabInfo(tabIndex) .. "_Talent" + tabName = string.gsub(tabName, "%s", "") -- Remove spaces from tab name + if printTalentsMode then + print(tabName..": ") + else + ids[tabName] = {} + end + + local numTalents = GetNumTalents(tabIndex) + + for talentIndex = 1, numTalents do + local name, _, _, _, _ = GetTalentInfo(tabIndex, talentIndex) + + if name then + local talentID = string.gsub(name, "%s", "") -- Remove spaces from talent name + if printTalentsMode then + print(talentID .." = ID no: ", talentIndex) + else + ids[tabName][talentID] = talentIndex + end + end + end + end + if printTalentsMode then printTalentsMode = false end +end +ConROC:PopulateTalentIDs() + +local Racial, Spec, Caster, Arc_Ability, Arc_Talent, Fire_Ability, Fire_Talent, Frost_Ability, Frost_Talent, Player_Buff, Player_Debuff, Target_Debuff = ids.Racial, ids.Spec, ids.Caster, ids.Arc_Ability, ids.Arcane_Talent, ids.Fire_Ability, ids.Fire_Talent, ids.Frost_Ability, ids.Frost_Talent, ids.Player_Buff, ids.Player_Debuff, ids.Target_Debuff; +function ConROC:SpecUpdate() + currentSpecName = ConROC:currentSpec() + + if currentSpecName then + ConROC:Print(self.Colors.Info .. "Current spec:", self.Colors.Success .. currentSpecName) + else + ConROC:Print(self.Colors.Error .. "You do not currently have a spec.") + end +end +ConROC:SpecUpdate() +--Ranks +--Arcane +local _Evocation = Arc_Ability.Evocation; +local _PresenceofMind = Arc_Ability.PresenceofMind; +local _ArcanePower = Arc_Ability.ArcanePower; +local _AmplifyMagic = Arc_Ability.AmplifyMagicRank1; +local _ArcaneBrilliance = Arc_Ability.ArcaneBrilliance; +local _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank1; +local _ArcaneIntellect = Arc_Ability.ArcaneIntellectRank1; +local _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank1; +local _DampenMagic = Arc_Ability.DampenMagicRank1; +local _MageArmor = Arc_Ability.MageArmorRank1; +local _ManaShield = Arc_Ability.ManaShieldRank1; +--Fire +local _BlastWave = Fire_Ability.BlastWaveRank1; +local _Combustion = Fire_Ability.Combustion; +local _FireBlast = Fire_Ability.FireBlastRank1; +local _FireWard = Fire_Ability.FireWardRank1; +local _Fireball = Fire_Ability.FireballRank1; +local _Flamestrike = Fire_Ability.FlamestrikeRank1; +local _FlamestrikeDR = Fire_Ability.FlamestrikeRank1; +local _Pyroblast = Fire_Ability.PyroblastRank1; +local _Scorch = Fire_Ability.ScorchRank1; +--Frost +local _Blizzard = Frost_Ability.BlizzardRank1; +local _ConeofCold = Frost_Ability.ConeofColdRank1; +local _IceBarrier = Frost_Ability.IceBarrierRank1; +local _IceArmor = Frost_Ability.FrostArmorRank1; +local _FrostNova = Frost_Ability.FrostNovaRank1; +local _FrostWard = Frost_Ability.FrostWardRank1; +local _Frostbolt = Frost_Ability.FrostboltRank1; +--runes +local _RuneArcaneBlast = ids.Runes.ArcaneBlast; +local _RuneArcaneSurge = ids.Runes.ArcaneSurge; +local _RuneIceLance = ids.Runes.IceLance; +local _RuneIcyVeins = ids.Runes.IcyVeins; +local _RuneLivingBomb = ids.Runes.LivingBomb; +local _RuneLivingFlame = ids.Runes.LivingFlame; +local _RuneMassRegeneration = ids.Runes.MassRegeneration; +local _RuneRegeneration = ids.Runes.Regeneration; +local _RuneRewindTime = ids.Runes.RewindTime; + +function ConROC:UpdateSpellID() + --Ranks + if IsSpellKnown(Arc_Ability.AmplifyMagicRank4) then _AmplifyMagic = Arc_Ability.AmplifyMagicRank4; + elseif IsSpellKnown(Arc_Ability.AmplifyMagicRank3) then _AmplifyMagic = Arc_Ability.AmplifyMagicRank3; + elseif IsSpellKnown(Arc_Ability.AmplifyMagicRank2) then _AmplifyMagic = Arc_Ability.AmplifyMagicRank2; end + + if IsSpellKnown(Arc_Ability.ArcaneExplosionRank6) then _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank6; + elseif IsSpellKnown(Arc_Ability.ArcaneExplosionRank5) then _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank5; + elseif IsSpellKnown(Arc_Ability.ArcaneExplosionRank4) then _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank4; + elseif IsSpellKnown(Arc_Ability.ArcaneExplosionRank3) then _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank3; + elseif IsSpellKnown(Arc_Ability.ArcaneExplosionRank2) then _ArcaneExplosion = Arc_Ability.ArcaneExplosionRank2; end + + if IsSpellKnown(Arc_Ability.ArcaneIntellectRank5) then _ArcaneIntellect = Arc_Ability.ArcaneIntellectRank5; + elseif IsSpellKnown(Arc_Ability.ArcaneIntellectRank4) then _ArcaneIntellect = Arc_Ability.ArcaneIntellectRank4; + elseif IsSpellKnown(Arc_Ability.ArcaneIntellectRank3) then _ArcaneIntellect = Arc_Ability.ArcaneIntellectRank3; + elseif IsSpellKnown(Arc_Ability.ArcaneIntellectRank2) then _ArcaneIntellect = Arc_Ability.ArcaneIntellectRank2; end + + if IsSpellKnown(Arc_Ability.ArcaneMissilesRank7) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank7; + elseif IsSpellKnown(Arc_Ability.ArcaneMissilesRank6) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank6; + elseif IsSpellKnown(Arc_Ability.ArcaneMissilesRank5) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank5; + elseif IsSpellKnown(Arc_Ability.ArcaneMissilesRank4) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank4; + elseif IsSpellKnown(Arc_Ability.ArcaneMissilesRank3) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank3; + elseif IsSpellKnown(Arc_Ability.ArcaneMissilesRank2) then _ArcaneMissiles = Arc_Ability.ArcaneMissilesRank2; end + + if IsSpellKnown(Arc_Ability.DampenMagicRank5) then _DampenMagic = Arc_Ability.DampenMagicRank5; + elseif IsSpellKnown(Arc_Ability.DampenMagicRank4) then _DampenMagic = Arc_Ability.DampenMagicRank4; + elseif IsSpellKnown(Arc_Ability.DampenMagicRank3) then _DampenMagic = Arc_Ability.DampenMagicRank3; + elseif IsSpellKnown(Arc_Ability.DampenMagicRank2) then _DampenMagic = Arc_Ability.DampenMagicRank2; end + + if IsSpellKnown(Fire_Ability.BlastWaveRank5) then _BlastWave = Fire_Ability.BlastWaveRank5; + elseif IsSpellKnown(Fire_Ability.BlastWaveRank4) then _BlastWave = Fire_Ability.BlastWaveRank4; + elseif IsSpellKnown(Fire_Ability.BlastWaveRank3) then _BlastWave = Fire_Ability.BlastWaveRank3; + elseif IsSpellKnown(Fire_Ability.BlastWaveRank2) then _BlastWave = Fire_Ability.BlastWaveRank2; end + + if IsSpellKnown(Fire_Ability.FireBlastRank7) then _FireBlast = Fire_Ability.FireBlastRank7; + elseif IsSpellKnown(Fire_Ability.FireBlastRank6) then _FireBlast = Fire_Ability.FireBlastRank6; + elseif IsSpellKnown(Fire_Ability.FireBlastRank5) then _FireBlast = Fire_Ability.FireBlastRank5; + elseif IsSpellKnown(Fire_Ability.FireBlastRank4) then _FireBlast = Fire_Ability.FireBlastRank4; + elseif IsSpellKnown(Fire_Ability.FireBlastRank3) then _FireBlast = Fire_Ability.FireBlastRank3; + elseif IsSpellKnown(Fire_Ability.FireBlastRank2) then _FireBlast = Fire_Ability.FireBlastRank2; end + + if IsSpellKnown(Fire_Ability.FireWardRank5) then _FireWard = Fire_Ability.FireWardRank5; + elseif IsSpellKnown(Fire_Ability.FireWardRank4) then _FireWard = Fire_Ability.FireWardRank4; + elseif IsSpellKnown(Fire_Ability.FireWardRank3) then _FireWard = Fire_Ability.FireWardRank3; + elseif IsSpellKnown(Fire_Ability.FireWardRank2) then _FireWard = Fire_Ability.FireWardRank2; end + + if IsSpellKnown(Fire_Ability.FireballRank11) then _Fireball = Fire_Ability.FireballRank11; + elseif IsSpellKnown(Fire_Ability.FireballRank10) then _Fireball = Fire_Ability.FireballRank10; + elseif IsSpellKnown(Fire_Ability.FireballRank9) then _Fireball = Fire_Ability.FireballRank8; + elseif IsSpellKnown(Fire_Ability.FireballRank8) then _Fireball = Fire_Ability.FireballRank9; + elseif IsSpellKnown(Fire_Ability.FireballRank7) then _Fireball = Fire_Ability.FireballRank7; + elseif IsSpellKnown(Fire_Ability.FireballRank6) then _Fireball = Fire_Ability.FireballRank6; + elseif IsSpellKnown(Fire_Ability.FireballRank5) then _Fireball = Fire_Ability.FireballRank5; + elseif IsSpellKnown(Fire_Ability.FireballRank4) then _Fireball = Fire_Ability.FireballRank4; + elseif IsSpellKnown(Fire_Ability.FireballRank3) then _Fireball = Fire_Ability.FireballRank3; + elseif IsSpellKnown(Fire_Ability.FireballRank2) then _Fireball = Fire_Ability.FireballRank2; end + + if IsSpellKnown(Fire_Ability.FlamestrikeRank6) then _Flamestrike = Fire_Ability.FlamestrikeRank6; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank5) then _Flamestrike = Fire_Ability.FlamestrikeRank5; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank4) then _Flamestrike = Fire_Ability.FlamestrikeRank4; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank3) then _Flamestrike = Fire_Ability.FlamestrikeRank3; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank2) then _Flamestrike = Fire_Ability.FlamestrikeRank2; end + + --down ranked Flamestrike + if IsSpellKnown(Fire_Ability.FlamestrikeRank6) then _FlamestrikeDR = Fire_Ability.FlamestrikeRank5; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank5) then _FlamestrikeDR = Fire_Ability.FlamestrikeRank4; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank4) then _FlamestrikeDR = Fire_Ability.FlamestrikeRank3; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank3) then _FlamestrikeDR = Fire_Ability.FlamestrikeRank2; + elseif IsSpellKnown(Fire_Ability.FlamestrikeRank2) then _FlamestrikeDR = Fire_Ability.FlamestrikeRank1; end + + if IsSpellKnown(Fire_Ability.PyroblastRank8) then _Pyroblast = Fire_Ability.PyroblastRank8; + elseif IsSpellKnown(Fire_Ability.PyroblastRank7) then _Pyroblast = Fire_Ability.PyroblastRank7; + elseif IsSpellKnown(Fire_Ability.PyroblastRank6) then _Pyroblast = Fire_Ability.PyroblastRank6; + elseif IsSpellKnown(Fire_Ability.PyroblastRank5) then _Pyroblast = Fire_Ability.PyroblastRank5; + elseif IsSpellKnown(Fire_Ability.PyroblastRank4) then _Pyroblast = Fire_Ability.PyroblastRank4; + elseif IsSpellKnown(Fire_Ability.PyroblastRank3) then _Pyroblast = Fire_Ability.PyroblastRank3; + elseif IsSpellKnown(Fire_Ability.PyroblastRank2) then _Pyroblast = Fire_Ability.PyroblastRank2; end + + if IsSpellKnown(Fire_Ability.ScorchRank7) then _Scorch = Fire_Ability.ScorchRank7; + elseif IsSpellKnown(Fire_Ability.ScorchRank6) then _Scorch = Fire_Ability.ScorchRank6; + elseif IsSpellKnown(Fire_Ability.ScorchRank5) then _Scorch = Fire_Ability.ScorchRank5; + elseif IsSpellKnown(Fire_Ability.ScorchRank4) then _Scorch = Fire_Ability.ScorchRank4; + elseif IsSpellKnown(Fire_Ability.ScorchRank3) then _Scorch = Fire_Ability.ScorchRank3; + elseif IsSpellKnown(Fire_Ability.ScorchRank2) then _Scorch = Fire_Ability.ScorchRank2; end + + if IsSpellKnown(Frost_Ability.BlizzardRank6) then _Blizzard = Frost_Ability.BlizzardRank6; + elseif IsSpellKnown(Frost_Ability.BlizzardRank5) then _Blizzard = Frost_Ability.BlizzardRank5; + elseif IsSpellKnown(Frost_Ability.BlizzardRank4) then _Blizzard = Frost_Ability.BlizzardRank4; + elseif IsSpellKnown(Frost_Ability.BlizzardRank3) then _Blizzard = Frost_Ability.BlizzardRank3; + elseif IsSpellKnown(Frost_Ability.BlizzardRank2) then _Blizzard = Frost_Ability.BlizzardRank2; end + + if IsSpellKnown(Frost_Ability.ConeofColdRank5) then _ConeofCold = Frost_Ability.ConeofColdRank5; + elseif IsSpellKnown(Frost_Ability.ConeofColdRank4) then _ConeofCold = Frost_Ability.ConeofColdRank4; + elseif IsSpellKnown(Frost_Ability.ConeofColdRank3) then _ConeofCold = Frost_Ability.ConeofColdRank3; + elseif IsSpellKnown(Frost_Ability.ConeofColdRank2) then _ConeofCold = Frost_Ability.ConeofColdRank2; end + + if IsSpellKnown(Frost_Ability.FrostWardRank5) then _FrostWard = Frost_Ability.FrostWardRank5; + elseif IsSpellKnown(Frost_Ability.FrostWardRank4) then _FrostWard = Frost_Ability.FrostWardRank4; + elseif IsSpellKnown(Frost_Ability.FrostWardRank3) then _FrostWard = Frost_Ability.FrostWardRank3; + elseif IsSpellKnown(Frost_Ability.FrostWardRank2) then _FrostWard = Frost_Ability.FrostWardRank2; end + + if IsSpellKnown(Frost_Ability.FrostboltRank10) then _Frostbolt = Frost_Ability.FrostboltRank10; + elseif IsSpellKnown(Frost_Ability.FrostboltRank9) then _Frostbolt = Frost_Ability.FrostboltRank9; + elseif IsSpellKnown(Frost_Ability.FrostboltRank8) then _Frostbolt = Frost_Ability.FrostboltRank8; + elseif IsSpellKnown(Frost_Ability.FrostboltRank7) then _Frostbolt = Frost_Ability.FrostboltRank7; + elseif IsSpellKnown(Frost_Ability.FrostboltRank6) then _Frostbolt = Frost_Ability.FrostboltRank6; + elseif IsSpellKnown(Frost_Ability.FrostboltRank5) then _Frostbolt = Frost_Ability.FrostboltRank5; + elseif IsSpellKnown(Frost_Ability.FrostboltRank4) then _Frostbolt = Frost_Ability.FrostboltRank4; + elseif IsSpellKnown(Frost_Ability.FrostboltRank3) then _Frostbolt = Frost_Ability.FrostboltRank3; + elseif IsSpellKnown(Frost_Ability.FrostboltRank2) then _Frostbolt = Frost_Ability.FrostboltRank2; end + + --Ranks Defensive + if IsSpellKnown(Arc_Ability.MageArmorRank3) then _MageArmor = Arc_Ability.MageArmorRank3; + elseif IsSpellKnown(Arc_Ability.MageArmorRank2) then _MageArmor = Arc_Ability.MageArmorRank2; end + + if IsSpellKnown(Arc_Ability.ManaShieldRank6) then _ManaShield = Arc_Ability.ManaShieldRank6; + elseif IsSpellKnown(Arc_Ability.ManaShieldRank5) then _ManaShield = Arc_Ability.ManaShieldRank5; + elseif IsSpellKnown(Arc_Ability.ManaShieldRank4) then _ManaShield = Arc_Ability.ManaShieldRank4; + elseif IsSpellKnown(Arc_Ability.ManaShieldRank3) then _ManaShield = Arc_Ability.ManaShieldRank3; + elseif IsSpellKnown(Arc_Ability.ManaShieldRank2) then _ManaShield = Arc_Ability.ManaShieldRank2; end + + if IsSpellKnown(Frost_Ability.IceBarrierRank4) then _IceBarrier = Frost_Ability.IceBarrierRank4; + elseif IsSpellKnown(Frost_Ability.IceBarrierRank3) then _IceBarrier = Frost_Ability.IceBarrierRank3; + elseif IsSpellKnown(Frost_Ability.IceBarrierRank2) then _IceBarrier = Frost_Ability.IceBarrierRank2; end + + if IsSpellKnown(Frost_Ability.IceArmorRank4) then _IceArmor = Frost_Ability.IceArmorRank4; + elseif IsSpellKnown(Frost_Ability.IceArmorRank3) then _IceArmor = Frost_Ability.IceArmorRank3; + elseif IsSpellKnown(Frost_Ability.IceArmorRank2) then _IceArmor = Frost_Ability.IceArmorRank2; + elseif IsSpellKnown(Frost_Ability.IceArmorRank1) then _IceArmor = Frost_Ability.IceArmorRank1; + elseif IsSpellKnown(Frost_Ability.FrostArmorRank3) then _IceArmor = Frost_Ability.FrostArmorRank3; + elseif IsSpellKnown(Frost_Ability.FrostArmorRank2) then _IceArmor = Frost_Ability.FrostArmorRank2; end + + if IsSpellKnown(Frost_Ability.FrostNovaRank4) then _FrostNova = Frost_Ability.FrostNovaRank4; + elseif IsSpellKnown(Frost_Ability.FrostNovaRank3) then _FrostNova = Frost_Ability.FrostNovaRank3; + elseif IsSpellKnown(Frost_Ability.FrostNovaRank2) then _FrostNova = Frost_Ability.FrostNovaRank2; end + + ids.optionMaxIds = { + --Arcane + Evocation = _Evocation, + PresenceofMind = _PresenceofMind, + ArcanePower = _ArcanePower, + AmplifyMagic = _AmplifyMagic, + ArcaneBrilliance = _ArcaneBrilliance, + ArcaneExplosion = _ArcaneExplosion, + ArcaneIntellect = _ArcaneIntellect, + ArcaneMissiles = _ArcaneMissiles, + DampenMagic = _DampenMagic, + MageArmor = _MageArmor, + --Fire + BlastWave = _BlastWave, + Combustion = _Combustion, + FireBlast =_FireBlast, + FireWard =_FireWard, + Fireball = _Fireball, + Flamestrike = _Flamestrike, + FlamestrikeDR = _FlamestrikeDR, + Pyroblast =_Pyroblast, + Scorch =_Scorch, + --Frost + Blizzard = _Blizzard, + ConeofCold = _ConeofCold, + Frostbolt = _Frostbolt, + IceBarrier = _IceBarrier, + IceArmor = _IceArmor, + FrostNova = _FrostNova, + FrostWard = _FrostWard, + --Runes + RuneArcaneBlast = _RuneArcaneBlast, + RuneArcaneSurge = _RuneArcaneSurge, + RuneIceLance = _RuneIceLance, + RuneIcyVeins = _RuneIcyVeins, + RuneLivingBomb = _RuneLivingBomb, + RuneLivingFlame = _RuneLivingFlame, + RuneMassRegeneration = _RuneMassRegeneration, + RuneRegeneration = _RuneRegeneration, + RuneRewindTime = _RuneRewindTime, + } +end +ConROC:UpdateSpellID() + +local wChillEXP = 0; +local fVulEXP = 0; +local fStrikeEXP = 0; +local fStrikeDREXP = 0; + +function ConROC:EnableRotationModule() + self.Description = "Mage"; + self.NextSpell = ConROC.Mage.Damage; + + self:RegisterEvent('UNIT_SPELLCAST_SUCCEEDED'); + self:RegisterEvent("PLAYER_TALENT_UPDATE"); + self.lastSpellId = 0; + + ConROC:SpellmenuClass(); +end +function ConROC:PLAYER_TALENT_UPDATE() + ConROC:SpecUpdate(); + ConROC:closeSpellmenu(); +end + +function ConROC.Mage.Damage(_, timeShift, currentSpell, gcd) + ConROC:UpdateSpellID() + +--Character + local plvl = UnitLevel('player'); +--Racials + +--Resources + local mana = UnitPower('player', Enum.PowerType.Mana); + local manaMax = UnitPowerMax('player', Enum.PowerType.Mana); + local manaPercent = math.max(0, mana) / math.max(1, manaMax) * 100; + + +--Abilties + local ampMagRDY = ConROC:AbilityReady(_AmplifyMagic, timeShift); + local ampMagBUFF = ConROC:Buff(_AmplifyMagic, timeShift); + local aExpRDY = ConROC:AbilityReady(_ArcaneExplosion, timeShift); + local aIntRDY = ConROC:AbilityReady(_ArcaneIntellect, timeShift); + local aIntBUFF = ConROC:Buff(_ArcaneIntellect, timeShift); + local aBriBUFF = ConROC:Buff(_ArcaneBrilliance, timeShift); + local aMissRDY = ConROC:AbilityReady(_ArcaneMissiles, timeShift); + local aPowerRDY = ConROC:AbilityReady(_ArcanePower, timeShift); + local blinkRDY = ConROC:AbilityReady(Arc_Ability.Blink, timeShift); + local conAgateRDY = ConROC:AbilityReady(Arc_Ability.ConjureManaAgate, timeShift); + local conJadeRDY = ConROC:AbilityReady(Arc_Ability.ConjureManaJade, timeShift); + local conCitRDY = ConROC:AbilityReady(Arc_Ability.ConjureManaCitrine, timeShift); + local conRubyRDY = ConROC:AbilityReady(Arc_Ability.ConjureManaRuby, timeShift); + local cSpellRDY = ConROC:AbilityReady(Arc_Ability.Counterspell, timeShift); + local dampenMagRDY = ConROC:AbilityReady(_DampenMagic, timeShift); + local dampenMagBUFF = ConROC:Buff(_DampenMagic, timeShift); + local evoRDY = ConROC:AbilityReady(_Evocation, timeShift); + local pomRDY = ConROC:AbilityReady(_PresenceofMind, timeShift); + local pomBUFF = ConROC:Buff(_PresenceofMind, timeShift); + local bWaveRDY = ConROC:AbilityReady(_BlastWave, timeShift); + if ConROC:TalentChosen(Spec.Fire, Fire_Talent.Combustion) then + local combRDY = ConROC:AbilityReady(_Combustion, timeShift); + end + local fBlastRDY = ConROC:AbilityReady(_FireBlast, timeShift); + local fBallRDY = ConROC:AbilityReady(_Fireball, timeShift); + local fBallDEBUFF = ConROC:TargetDebuff(_Fireball, timeShift); + local fStrikeRDY = ConROC:AbilityReady(_Flamestrike, timeShift); + local fStrikeDUR = fStrikeEXP - GetTime(); + local fStrikeDRRDY = ConROC:AbilityReady(_FlamestrikeDR, timeShift); + local fStrikeDRDUR = fStrikeDREXP - GetTime(); + local pBlastRDY = ConROC:AbilityReady(_Pyroblast, timeShift); + local scorRDY = ConROC:AbilityReady(_Scorch, timeShift); + local blizRDY = ConROC:AbilityReady(_Blizzard, timeShift); + local cSnapRDY = ConROC:AbilityReady(Frost_Ability.ColdSnap, timeShift); + local cofcRDY = ConROC:AbilityReady(_ConeofCold, timeShift); + local frBoltRDY = ConROC:AbilityReady(_Frostbolt, timeShift); + local frBoltDEBUFF = ConROC:TargetDebuff(_Frostbolt, timeShift); + + local chillDEBUFF = ConROC:TargetDebuff(Target_Debuff.Chilled, timeShift); + local wChillDEBUFF, wChillCount = ConROC:TargetDebuff(Target_Debuff.WintersChill); + local wChillDUR = wChillEXP - GetTime(); + local fVulDEBUFF, fVulCount = ConROC:TargetDebuff(Target_Debuff.FireVulnerability); + local fVulDUR = fVulEXP - GetTime(); + local frNovaDEBUFF = ConROC:TargetDebuff(_FrostNova); + + local _, impArcPoints = ConROC:TalentChosen(Spec.Arcane, Arc_Talent.ImprovedArcaneMissiles) + +--runes + local raBlastRDY = ConROC:AbilityReady(_RuneArcaneBlast, timeShift); + local raBlastDEBUFF, raBlastCount = ConROC:TargetDebuff(Target_Debuff.ArcaneBlast); + local raSurgeRDY = ConROC:AbilityReady(_RuneArcaneSurge, timeShift); + local riLanceRDY = ConROC:AbilityReady(_RuneIceLance, timeShift); + local riVeinsRDY = ConROC:AbilityReady(_RuneIcyVeins, timeShift); + local rlBombRDY = ConROC:AbilityReady(_RuneLivingBomb, timeShift); + local rlBombDEBUFF = ConROC:TargetDebuff(_RuneLivingBomb, timeShift); + local rlFlameRDY = ConROC:AbilityReady(_RuneLivingFlame, timeShift); + local rlFlameDEBUFF = ConROC:TargetDebuff(Target_Debuff.LivingFlame, timeShift); + local rmRegenRDY = ConROC:AbilityReady(_RuneMassRegeneration, timeShift); + local rRegenRDY = ConROC:AbilityReady(_RuneRegeneration, timeShift); + local rrTimeRDY = ConROC:AbilityReady(_RuneRewindTime, timeShift); + local rFoFBUFF, rFoFDUR = ConROC:BuffName(Player_Buff.FingersofFrost, timeShift); + +--Conditions + local inMelee = CheckInteractDistance("target", 3); + local targetPh = ConROC:PercentHealth('target'); + local hasWand = HasWandEquipped(); + local moving = ConROC:PlayerSpeed(); + local incombat = UnitAffectingCombat('player'); + local resting = IsResting(); + local mounted = IsMounted(); + local onVehicle = UnitHasVehicleUI("player"); + + if onVehicle then + return nil + end + +--Indicators + ConROC:AbilityBurst(_Evocation, evoRDY and manaPercent <= 25); + ConROC:AbilityBurst(_PresenceofMind, pomRDY and incombat); + ConROC:AbilityBurst(_ArcanePower, aPowerRDY and incombat and (not ConROC:TalentChosen(Spec.Frost, Frost_Talent.WintersChill) or (ConROC:TalentChosen(Spec.Frost, Frost_Talent.WintersChill) and wChillCount == 5))) ; + ConROC:AbilityBurst(_Combustion, combRDY and incombat and (not ConROC:TalentChosen(Spec.Fire, Fire_Talent.ImprovedScorch) or (ConROC:TalentChosen(Spec.Fire, Fire_Talent.ImprovedScorch) and fVuCount == 5))); + + ConROC:AbilityRaidBuffs(_ArcaneIntellect, aIntRDY and not (aIntBUFF or aBriBUFF)); + +--Warnings + --[[ + if not incombat and not ConROC:TarHostile() and ConROC:CheckBox(ConROC_SM_Option_HideRotation) then + ConROCWindow:Hide(); + else + ConROCWindow:Show(); + end + --]] +--Rotations + --print("IsSpellKnown(_RuneIceLance)",IsSpellKnown(_RuneIceLance)) + --print("IsSpellKnownOrOverridesKnown(_RuneIceLance)",IsSpellKnownOrOverridesKnown(_RuneIceLance)) + --print("ConROC.Seasons.IsSoD",ConROC.Seasons.IsSoD) + if ConROC:CheckBox(ConROC_SM_CD_Evocation) and evoRDY and manaPercent < 25 then + return _Evocation; + end + + if ConROC.Seasons.IsSoD then --DPS rotation for SoD + if ConROC:CheckBox(ConROC_SM_Rune_IcyVeins) and riVeinsRDY then --and fBallRDY then + return _RuneIcyVeins; + end + if ConROC:CheckBox(ConROC_SM_Rune_LivingBomb) and rlBombRDY and not rlBombDEBUFF and ((targetPh >= 5 and ConROC:Raidmob()) or (targetPh >= 20 and not ConROC:Raidmob())) then + return _RuneLivingBomb; + end + if ConROC:CheckBox(ConROC_SM_Rune_LivingFlame) and rlFlameRDY and ConROC_AoEButton:IsVisible() then --and fBallRDY then + return _RuneLivingFlame; + end + if ConROC:CheckBox(ConROC_SM_Rune_ArcaneBlast) and raBlastRDY and raBlastCount < 4 then --and fBallRDY then + return _RuneArcaneBlast; + end + if ConROC:CheckBox(ConROC_SM_Rune_ArcaneSurge) and raSurgeRDY then --and fBallRDY then + return _RuneArcaneSurge; + end + if ConROC:CheckBox(ConROC_SM_Rune_IceLance) and riLanceRDY and (moving or rFoFBUFF) then --and fBallRDY then + return _RuneIceLance; + end + if ConROC:CheckBox(ConROC_SM_Rune_MassRegeneration) and rmRegenRDY then --and fBallRDY then + return _RuneMassRegeneration; + end + if ConROC:CheckBox(ConROC_SM_Rune_Regeneration) and rRegenRDY then --and fBallRDY then + return _RuneRegeneration; + end + if ConROC:CheckBox(ConROC_SM_Rune_RewindTime) and rrTimeRDY then --and fBallRDY then + return _RuneRewindTime; + end + if ConROC_AoEButton:IsVisible() then + if ConROC:CheckBox(ConROC_SM_AoE_ArcaneExplosion) and aExpRDY and inMelee then + return _ArcaneExplosion; + end + + if ConROC:CheckBox(ConROC_SM_AoE_Flamestrike) and fStrikeRDY and not inMelee and fStrikeDUR <= 2 then + return _Flamestrike; + end + + if ConROC:CheckBox(ConROC_SM_AoE_Blizzard) and blizRDY and not inMelee then + return _Blizzard; + end + end + if fBlastRDY and (targetPh <= 25 or inMelee) and not ConROC_AoEButton:IsVisible() then + return _FireBlast; + end + if ConROC:CheckBox(ConROC_SM_Filler_Fireball) and fBallRDY then + return _Fireball; + end + if ConROC:CheckBox(ConROC_SM_Filler_ArcaneMissiles) and aMissRDY then + return _ArcaneMissiles; + end + if ConROC:CheckBox(ConROC_SM_Filler_Frostbolt) and frBoltRDY then + return _Frostbolt; + end + + else --DPS rotation for Classic Era & Classic HC + + + if ConROC:CheckBox(ConROC_SM_CD_Evocation) and evoRDY and manaPercent < 25 then + return _Evocation; + end + + if pBlastRDY and (not incombat or pomBUFF) then + return _Pyroblast; + end + + if wChillCount >= 1 and wChillDUR <= 4 then + return _Frostbolt; + end + + if fVulCount >= 1 and fVulDUR <= 4 then + return _Scorch; + end + + if cofcRDY and frNovaDEBUFF and inMelee then + return _ConeofCold; + end + + if fBlastRDY and (targetPh <= 25 or inMelee) and not ConROC_AoEButton:IsVisible() then + return _FireBlast; + end + + if ConROC:CheckBox(ConROC_SM_Option_UseWand) and hasWand and ((manaPercent <= 20 and not evoRDY) or targetPh <= 5) then + return Caster.Shoot; + end + + if ConROC_AoEButton:IsVisible() and bWaveRDY and inMelee then + return _BlastWave; + end + + if ConROC_AoEButton:IsVisible() and ConROC:CheckBox(ConROC_SM_AoE_ArcaneExplosion) and aExpRDY and inMelee then + return _ArcaneExplosion; + end + + if ConROC_AoEButton:IsVisible() and ConROC:CheckBox(ConROC_SM_AoE_Flamestrike) and fStrikeRDY and not inMelee and fStrikeDUR <= 2 then + return _Flamestrike; + end + + if ConROC_AoEButton:IsVisible() and ConROC:CheckBox(ConROC_SM_AoE_Blizzard) and blizRDY and not inMelee then + return _Blizzard; + end + if ConROC:CheckBox(ConROC_SM_CD_Combustion) and combRDY and incombat and ConROC:TalentChosen(Spec.Fire, Fire_Talent.Combustion) and fVulCount == 5 then + return _Combustion + end + if scorRDY and ConROC:TalentChosen(Spec.Fire, Fire_Talent.ImprovedScorch) and fVulCount < 5 then + return _Scorch; + end + + if ConROC:CheckBox(ConROC_SM_Filler_Fireball) and fBallRDY then + return _Fireball; + end + + if ConROC:CheckBox(ConROC_SM_Filler_ArcaneMissiles) and aMissRDY then + return _ArcaneMissiles; + end + + if ConROC:CheckBox(ConROC_SM_Filler_Frostbolt) and frBoltRDY then + return _Frostbolt; + end + end + + return nil; +end + +function ConROC.Mage.Defense(_, timeShift, currentSpell, gcd) +--Character + local plvl = UnitLevel('player'); + +--Racials + +--Resources + local mana = UnitPower('player', Enum.PowerType.Mana); + local manaMax = UnitPowerMax('player', Enum.PowerType.Mana); + local manaPercent = math.max(0, mana) / math.max(1, manaMax) * 100; + +--Abilties + local mageArmorRDY = ConROC:AbilityReady(_MageArmor, timeShift); + local mageArmorBUFF = ConROC:Buff(_MageArmor, timeShift); + local manaShieldRDY = ConROC:AbilityReady(_ManaShield, timeShift); + local manaShieldBUFF = ConROC:Buff(_ManaShield, timeShift); + local iBarRDY = ConROC:AbilityReady(_IceBarrier, timeShift); + local iBarBUFF = ConROC:Buff(_IceBarrier, timeShift); + local iArmorRDY = ConROC:AbilityReady(_IceArmor, timeShift); + local iArmorBUFF = ConROC:Buff(_IceArmor, timeShift); + local frNovaRDY = ConROC:AbilityReady(_FrostNova, timeShift); + +--Conditions + local inMelee = CheckInteractDistance("target", 3); + local targetPh = ConROC:PercentHealth('target'); + local onVehicle = UnitHasVehicleUI("player"); + + if onVehicle then + return nil + end + +--Indicators + + +--Rotations + if ConROC:CheckBox(ConROC_SM_Armor_Ice) and iArmorRDY and not iArmorBUFF then + return _IceArmor; + end + + if ConROC:CheckBox(ConROC_SM_Armor_Mage) and mageArmorRDY and not mageArmorBUFF then + return _MageArmor; + end + + if frNovaRDY and inMelee and targetPh >= 20 then + return _FrostNova; + end + + if iBarRDY and not iBarBUFF then + return _IceBarrier; + end + + return nil; +end + +function ConROC:JustCasted(spellID) + if spellID == _Frostbolt then + local expTime = GetTime() + 15; + wChillEXP = expTime; + end + + if spellID == _Flamestrike then + local expTime = GetTime() + 8; + fStrikeEXP = expTime; + end + + if spellID == _FlamestrikeDR then + local expTime = GetTime() + 8; + fStrikeDREXP = expTime; + end + + if spellID == _Scorch then + local expTime = GetTime() + 30; + fVulEXP = expTime; + end +end \ No newline at end of file diff --git a/mage_ids.lua b/mage_ids.lua new file mode 100644 index 0000000..fc75128 --- /dev/null +++ b/mage_ids.lua @@ -0,0 +1,217 @@ +local ConROC_Mage, ids = ...; +local ConROC_Mage, optionMaxIds = ...; + +--General + ids.Racial = { + EscapeArtist = 20589, + } + ids.Spec = { + Arcane = 1, + Fire = 2, + Frost = 3, + } + ids.Caster = { + Shoot = 5019, + } +--Arcane + ids.Arc_Ability = { + AmplifyMagicRank1 = 1008, + AmplifyMagicRank2 = 8455, + AmplifyMagicRank3 = 10169, + AmplifyMagicRank4 = 10170, + ArcaneBrilliance = 23028, + ArcaneExplosionRank1 = 1449, + ArcaneExplosionRank2 = 8437, + ArcaneExplosionRank3 = 8438, + ArcaneExplosionRank4 = 8439, + ArcaneExplosionRank5 = 10201, + ArcaneExplosionRank6 = 10202, + ArcaneIntellectRank1 = 1459, + ArcaneIntellectRank2 = 1460, + ArcaneIntellectRank3 = 1461, + ArcaneIntellectRank4 = 10156, + ArcaneIntellectRank5 = 10157, + ArcaneMissilesRank1 = 5143, + ArcaneMissilesRank2 = 5144, + ArcaneMissilesRank3 = 5145, + ArcaneMissilesRank4 = 8416, + ArcaneMissilesRank5 = 8417, + ArcaneMissilesRank6 = 10211, + ArcaneMissilesRank7 = 10212, + ArcanePower = 12042, + Blink = 1953, + ConjureFoodRank1 = 587, + ConjureFoodRank2 = 597, + ConjureFoodRank3 = 990, + ConjureFoodRank4 = 6129, + ConjureFoodRank5 = 10144, + ConjureFoodRank6 = 10145, + ConjureFoodRank7 = 28612, + ConjureManaAgate = 759, + ConjureManaJade = 3552, + ConjureManaCitrine = 10053, + ConjureManaRuby = 10054, + ConjureWaterRank1 = 5504, + ConjureWaterRank2 = 5505, + ConjureWaterRank3 = 5506, + ConjureWaterRank4 = 6127, + ConjureWaterRank5 = 10138, + ConjureWaterRank6 = 10139, + ConjureWaterRank7 = 10140, + Counterspell = 2139, + DampenMagicRank1 = 604, + DampenMagicRank2 = 8450, + DampenMagicRank3 = 8451, + DampenMagicRank4 = 10173, + DampenMagicRank5 = 10174, + DetectMagic = 2855, + Evocation = 12051, + MageArmorRank1 = 6117, + MageArmorRank2 = 22782, + MageArmorRank3 = 22783, + ManaShieldRank1 = 1463, + ManaShieldRank2 = 8494, + ManaShieldRank3 = 8495, + ManaShieldRank4 = 10191, + ManaShieldRank5 = 10192, + ManaShieldRank6 = 10193, + RemoveLesserCurse = 475, + SlowFall = 130, + PolymorphRank1 = 118, + PolymorphRank2 = 12824, + PolymorphRank3 = 12825, + PolymorphRank4 = 12826, + PresenceofMind = 12043, + } +--Fire + ids.Fire_Ability = { + BlastWaveRank1 = 11113, + BlastWaveRank2 = 13018, + BlastWaveRank3 = 13019, + BlastWaveRank4 = 13020, + BlastWaveRank5 = 13021, + Combustion = 11129, + FireBlastRank1 = 2136, + FireBlastRank2 = 2137, + FireBlastRank3 = 2138, + FireBlastRank4 = 8412, + FireBlastRank5 = 8413, + FireBlastRank6 = 10197, + FireBlastRank7 = 10199, + FireWardRank1 = 543, + FireWardRank2 = 8457, + FireWardRank3 = 8458, + FireWardRank4 = 10223, + FireWardRank5 = 10225, + FireballRank1 = 133, + FireballRank2 = 143, + FireballRank3 = 145, + FireballRank4 = 3140, + FireballRank5 = 8400, + FireballRank6 = 8401, + FireballRank7 = 8402, + FireballRank8 = 10148, + FireballRank9 = 10149, + FireballRank10 = 10150, + FireballRank11 = 10151, + FlamestrikeRank1 = 2120, + FlamestrikeRank2 = 2121, + FlamestrikeRank3 = 8422, + FlamestrikeRank4 = 8423, + FlamestrikeRank5 = 10215, + FlamestrikeRank6 = 10216, + PyroblastRank1 = 11366, + PyroblastRank2 = 12505, + PyroblastRank3 = 12522, + PyroblastRank4 = 12523, + PyroblastRank5 = 12524, + PyroblastRank6 = 12525, + PyroblastRank7 = 12526, + PyroblastRank8 = 18809, + ScorchRank1 = 2948, + ScorchRank2 = 8444, + ScorchRank3 = 8445, + ScorchRank4 = 8446, + ScorchRank5 = 10205, + ScorchRank6 = 10206, + ScorchRank7 = 10207, + } +--Frost + ids.Frost_Ability = { + BlizzardRank1 = 10, + BlizzardRank2 = 6141, + BlizzardRank3 = 8427, + BlizzardRank4 = 10185, + BlizzardRank5 = 10186, + BlizzardRank6 = 10187, + ColdSnap = 12472, + ConeofColdRank1 = 120, + ConeofColdRank2 = 8492, + ConeofColdRank3 = 10159, + ConeofColdRank4 = 10160, + ConeofColdRank5 = 10161, + FrostArmorRank1 = 168, + FrostArmorRank2 = 7300, + FrostArmorRank3 = 7301, + FrostNovaRank1 = 122, + FrostNovaRank2 = 865, + FrostNovaRank3 = 6131, + FrostNovaRank4 = 10230, + FrostWardRank1 = 6143, + FrostWardRank2 = 8461, + FrostWardRank3 = 8462, + FrostWardRank4 = 10177, + FrostWardRank5 = 28609, + FrostboltRank1 = 116, + FrostboltRank2 = 205, + FrostboltRank3 = 837, + FrostboltRank4 = 7322, + FrostboltRank5 = 8406, + FrostboltRank6 = 8407, + FrostboltRank7 = 8408, + FrostboltRank8 = 10179, + FrostboltRank9 = 10180, + FrostboltRank10 = 10181, + FrostboltRank11 = 25304, + IceBarrierRank1 = 11426, + IceBarrierRank2 = 13031, + IceBarrierRank3 = 13032, + IceBarrierRank4 = 13033, + IceBlock = 11958, + IceArmorRank1 = 7302, + IceArmorRank2 = 7320, + IceArmorRank3 = 10219, + IceArmorRank4 = 10220, + } + ids.Runes = { + ArcaneBlast = 400574, + ArcaneSurge = 425124, + IceLance = 400640, + IcyVeins = 425121, + LivingBomb = 400613, + LivingFlame = 401556, + MassRegeneration = 412510, + Regeneration = 401417, + RewindTime = 401462, + } +-- Auras + ids.Player_Buff = { + TemporalBeacon = 400735, + FingersofFrost = 400647, + } + ids.Player_Debuff = { + + } + ids.target_Buff = { + + } + ids.Target_Debuff = { + Chilled = 6136, + FireVulnerability = 22959, + WintersChill = 12579, + LivingFlame = 401558, + ArcaneBlast = 400574, + } + ids.optionMaxIds = { + + } \ No newline at end of file diff --git a/mage_spellmenu.lua b/mage_spellmenu.lua new file mode 100644 index 0000000..8a03a2e --- /dev/null +++ b/mage_spellmenu.lua @@ -0,0 +1,1055 @@ +local debugOptions = { + scrollChild = false, + header = false, + spells = false, +} +-- L for translations +local L = LibStub("AceLocale-3.0"):GetLocale("ConROC"); + +local ConROC_Mage, ids = ...; +local optionMaxIds = ...; +local ConROC_RolesTable = {}; +local wandFrame =0; +local lastFrame = 0; + +local showOptions = false; +local fixOptionsWidth = false; +local frameWidth = math.ceil(ConROCSpellmenuFrame:GetWidth()*2); +local spellFrameHeight = 0; +local scrollContentWidth = frameWidth - 30; +local scrollHeight = 0; + +local plvl = UnitLevel('player'); +local defaults = { + ["ConROC_SM_Role_Caster"] = true, + + ["ConROC_Caster_Armor_Ice"] = true, + ["ConROC_Caster_Filler_Fireball"] = true, + ["ConROC_Caster_AoE_ArcaneExplosion"] = true, + ["ConROC_Caster_AoE_Flamestrike"] = true, + ["ConROC_Caster_AoE_Blizzard"] = true, + ["ConROC_Caster_Option_UseWand"] = false, + ["ConROC_Caster_Option_AoE"] = true, +} + +ConROCMageSpells = ConROCMageSpells or defaults; + +local radioGroups = {} + +function ConROC:setRole(radioBtn, roleData, radioButtons) + for _, btn in ipairs(radioButtons) do + btn:SetChecked(false) + ConROCMageSpells[btn.role] = false + end + radioBtn:SetChecked(true) + ConROCMageSpells[roleData.role] = true +end +function ConROC:checkActiveRole() + for _, roleSettings in ipairs(ConROC_RoleSettingsTable) do + local frameName = roleSettings.frameName + local role = _G[roleSettings.role] + + if role:GetChecked() then + local checkboxName = "ConROC_"..frameName.."_" + -- The frame with matching name is checked, perform actions here + return role, checkboxName, frameName + end + end +end + +function ConROC:setRoleChecked(_spellData, _oItem) + local activeRole, checkboxName, _ = ConROC:checkActiveRole() + if ConROC:CheckBox(activeRole) then + local spellCheck = checkboxName .. _spellData.spellCheckbox + if _spellData.type == "textfield" then + _oItem:SetNumber(ConROCMageSpells[spellCheck]); + else + _oItem:SetChecked(ConROCMageSpells[spellCheck]); + end + end +end + +function ConROC:setRoleSpellClicked(_spellData, _oItem) + local activeRole, checkboxName, _ = ConROC:checkActiveRole() + if ConROC:CheckBox(activeRole) then + local spellCheck = checkboxName .. _spellData.spellCheckbox + if _spellData.type == "textfield" then + ConROCMageSpells[spellCheck] = _G["ConROC_SM_".._spellData.spellCheckbox]:GetNumber(); + else + ConROCMageSpells[spellCheck] = _oItem:GetChecked(); + end + end +end + +local function CheckScrollbarVisibility() + local scrollChildHeight = math.ceil(ConROCScrollChild:GetHeight()) + local containerHeight = math.ceil(ConROCScrollFrame:GetHeight()) + if scrollChildHeight <= containerHeight then + ConROCScrollbar:Hide() + ConROCScrollContainer:SetHeight(math.ceil(ConROCScrollChild:GetHeight())+16) + ConROCSpellmenuFrame:SetHeight(math.ceil(ConROCScrollContainer:GetHeight())+68) + ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8) + ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8) + ConROCScrollChild:SetWidth(ConROCScrollFrame:GetWidth()) + else + ConROCScrollbar:Show() + ConROCSpellmenuFrame:SetHeight(300) + ConROCScrollContainer:SetHeight(237) + ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8) + ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8) + ConROCScrollChild:SetWidth(ConROCScrollFrame:GetWidth()) + end +end + +function ConROC:SpellmenuClass() + ConROC_RoleSettingsTable = { + { + frameName = "Caster", + activeTexture = ConROC.Textures.Caster, + disabledTexture = ConROC.Textures.Caster_disabled, + role = "ConROC_SM_Role_Caster", + }, + { + frameName = "PvP", + activeTexture = ConROC.Textures.PvP, + disabledTexture = ConROC.Textures.PvP_disabled, + role = "ConROC_SM_Role_PvP", + }, + } + ConROC_RotationSettingsTable = { + { + frameName = "Runes", + spells = { + {spellID = ids.optionMaxIds.RuneArcaneBlast, spellCheckbox = "Rune_ArcaneBlast", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneArcaneSurge, spellCheckbox = "Rune_ArcaneSurge", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneIceLance, spellCheckbox = "Rune_IceLance", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneIcyVeins, spellCheckbox = "Rune_IcyVeins", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneLivingBomb, spellCheckbox = "Rune_LivingBomb", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneLivingFlame, spellCheckbox = "Rune_LivingFlame", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneMassRegeneration, spellCheckbox = "Rune_MassRegeneration", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneRegeneration, spellCheckbox = "Rune_Regeneration", reqLevel = 1, type="rune"}, + {spellID = ids.optionMaxIds.RuneRewindTime, spellCheckbox = "Rune_RewindTime", reqLevel = 1, type="rune"}, + }, + groupType = "checkBoxes" + },{ + frameName = "Armors", + spells = { + {spellID = ids.optionMaxIds.IceArmor, spellCheckbox = "Armor_Ice", reqLevel = 1, type="spell"}, + {spellID = ids.optionMaxIds.MageArmor, spellCheckbox = "Armor_Mage", reqLevel = 34, type="spell"}, + }, + groupType = "radioButtons" + }, + { + frameName = "Filler", + spells = { + {spellID = ids.optionMaxIds.Fireball, spellCheckbox = "Filler_Fireball", reqLevel = 1, type="spell"}, + {spellID = ids.optionMaxIds.Frostbolt, spellCheckbox = "Filler_Frostbolt", reqLevel = 4, type="spell"}, + {spellID = ids.optionMaxIds.ArcaneMissiles, spellCheckbox = "Filler_ArcaneMissiles", reqLevel = 8, type="spell"} + }, + groupType = "radioButtons" + }, + { + frameName = "Cooldowns", + spells = { + {spellID = ids.optionMaxIds.Evocation, spellCheckbox = "CD_Evocation", reqLevel = 20, type="spell"}, + {spellID = ids.optionMaxIds.ArcanePower, spellCheckbox = "CD_ArcanePower", reqLevel = 40, type="spell"}, + {spellID = ids.optionMaxIds.Combustion, spellCheckbox = "CD_Combustion", reqLevel = 40, type="spell"}, + }, + groupType = "checkBoxes" + }, + { + frameName = "AoEs", + spells = { + {spellID = ids.optionMaxIds.ArcaneExplosion, spellCheckbox = "AoE_ArcaneExplosion", reqLevel = 14, type="spell"}, + {spellID = ids.optionMaxIds.Flamestrike, spellCheckbox = "AoE_Flamestrike", reqLevel = 16, type="spell"}, + {spellID = ids.optionMaxIds.Blizzard, spellCheckbox = "AoE_Blizzard", reqLevel = 20, type="spell"} + }, + groupType = "checkBoxes" + }, + { + frameName = "Options", + spells = { + --{spellID = "Hide rotation window out of combat", spellCheckbox = "Option_HideRotation", reqLevel = 1, type="custom", customName="Hide Out of Combat"}, + {spellID = "AoE Toggle Button", spellCheckbox = "Option_AoE", reqLevel = 14, type="aoetoggler"}, + {spellID = "Use Wand", spellCheckbox = "Option_UseWand", reqLevel = 5, type="wand"}, + } + } + } + + local _, Class, classId = UnitClass("player") + local Color = RAID_CLASS_COLORS[Class] + local frame = CreateFrame("Frame", "ConROCSpellmenuClass", ConROCSpellmenuFrame) + + frame:SetFrameStrata('MEDIUM'); + frame:SetFrameLevel('5') + frame:SetSize(frameWidth, 30) + frame:SetAlpha(1) + + frame:SetPoint("TOP", "ConROCSpellmenuFrame_Title", "BOTTOM", 0, 0) + frame:SetMovable(false) + frame:EnableMouse(true) + frame:SetClampedToScreen(true) + + ConROC_roles(frame) + + frame:Hide(); + lastFrame = frame; + + -- create the frame and set its properties + ConROCScrollContainer = CreateFrame("Frame", "ConROC_ScrollContainer", ConROCSpellmenuClass, "BackdropTemplate") + ConROCScrollContainer:SetSize(frameWidth - 6, 237) + ConROCScrollContainer:SetPoint("TOP", ConROCSpellmenuClass, "CENTER", 0, -20) + ConROCScrollContainer:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + nil, + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }) + if debugOptions.scrollChild then + ConROCScrollContainer:SetBackdropColor(0,1,0,0.2) + else + ConROCScrollContainer:SetBackdropColor(0,0,0,0.0) + end + ConROCScrollContainer:Show() + + -- create the scroll frame and set its properties + ConROCScrollFrame = CreateFrame("ScrollFrame", "ConROC_ScrollFrame", ConROCScrollContainer, "UIPanelScrollFrameTemplate BackdropTemplate") + ConROCScrollFrame:SetPoint("TOPLEFT", 8, -8) + ConROCScrollFrame:SetPoint("BOTTOMRIGHT", -28, 8) + ConROCScrollFrame:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + nil, + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }) + if debugOptions.scrollChild then + ConROCScrollFrame:SetBackdropColor(0,0,1,0.2) + else + ConROCScrollFrame:SetBackdropColor(0,0,0,0.0) + end + ConROCScrollFrame:Show() + scrollContentWidth = ConROCScrollFrame:GetWidth() + -- create the child frame and set its properties + ConROCScrollChild = CreateFrame("Frame", "ConROC_ScrollChild", ConROCScrollFrame, "BackdropTemplate") + ConROCScrollChild:SetSize(ConROCScrollFrame:GetWidth(), ConROCScrollFrame:GetHeight()) + ConROCScrollFrame:SetScrollChild(ConROCScrollChild) + ConROCScrollChild:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + nil, + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }) + if debugOptions.scrollChild then + ConROCScrollChild:SetBackdropColor(1,0,0,0.2) + else + ConROCScrollChild:SetBackdropColor(0,0,0,0.0) + end + ConROCScrollChild:Show() + + -- create the scrollbar and set its properties + ConROCScrollbar = _G[ConROCScrollFrame:GetName() .. "ScrollBar"] + ConROCScrollbar:SetValueStep(10) + ConROCScrollbar.scrollStep = 10 + ConROCScrollbar:SetPoint("TOPLEFT", ConROCScrollFrame, "TOPRIGHT", 4, -16) + ConROCScrollbar:SetPoint("BOTTOMLEFT", ConROCScrollFrame, "BOTTOMRIGHT", 4, 16) + ConROCScrollbar:SetWidth(16) + + lastFrame = ConROCScrollChild; + ConROCScrollContainer:Show(); + ConROCScrollFrame:Show(); + ConROCScrollChild:Show(); + + ConROC_OptionsWindow(ConROC_RotationSettingsTable, ConROC_RoleSettingsTable) + showOptions = true; + fixOptionsWidth = true; + + -- Register for events to check scrollbar visibility + ConROCScrollChild:SetScript("OnSizeChanged", CheckScrollbarVisibility) + ConROCScrollContainer:SetScript("OnShow", CheckScrollbarVisibility) +end +local function ConROC_NoOptionsFrame() + if ConROCNoOptions then + return + end + if not ConROCScrollChild then + return + end + + -- Create ConROCNoOptions frame inside ConROCScrollChild + ConROCNoOptions = CreateFrame("Frame", "ConROC_NoOptions", ConROCScrollFrame) + ConROCNoOptions:SetSize(ConROCScrollFrame:GetWidth(), 80) -- Start with a minimum height, will be adjusted dynamically + + ConROCNoOptions:SetPoint("TOPLEFT", ConROCScrollFrame, "TOPLEFT", 0, 0) + + ConROCNoOptions.text = ConROCNoOptions:CreateFontString(nil, "ARTWORK", "GameFontNormal") + ConROCNoOptions.text:SetPoint("TOPLEFT", ConROCNoOptions, "TOPLEFT", 0, 0) + ConROCNoOptions.text:SetWidth(ConROCNoOptions:GetWidth()) -- Set the width to match the frame width + ConROCNoOptions.text:SetText(L["NO_SPELLS_TO_LIST"]) + ConROCNoOptions.text:SetJustifyH("LEFT") + ConROCNoOptions.text:SetSpacing(2) + ConROCNoOptions.text:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE") + ConROCNoOptions.text:SetTextColor(1, 1, 1) -- White color + + ConROCNoOptions:SetHeight(ConROCNoOptions.text:GetHeight()) + ConROCNoOptions:Show() +end +function ConROC_roles(frame) + + local radioButtons = {} + local roleIconSize = 32; + local sizeCheck = (math.ceil(frame:GetWidth()-20)/#ConROC_RoleSettingsTable) + if(sizeCheck <= 34) then + roleIconSize = 28; + elseif (sizeCheck <= 28) then + roleIconSize = 24 + end + + local roleSpaceValue = (math.ceil(frame:GetWidth())-20-roleIconSize) / (#ConROC_RoleSettingsTable-1) + for i, roleData in ipairs(ConROC_RoleSettingsTable) do + local radioBtn = CreateFrame("CheckButton", roleData.role, frame, "UIRadioButtonTemplate") + radioBtn:SetSize(roleIconSize, roleIconSize) + + local radioNormalTexture = radioBtn:GetNormalTexture() + radioNormalTexture:SetTexture(nil) + radioNormalTexture:SetAlpha(0) + + local radioHighlightTexture = radioBtn:GetHighlightTexture() + radioHighlightTexture:SetTexture(nil) + radioHighlightTexture:SetAlpha(0) + + local radioCheckedTexture = radioBtn:GetCheckedTexture() + radioCheckedTexture:SetTexture(nil) + radioCheckedTexture:SetAlpha(0) + + radioBtn:SetPoint("TOPLEFT", frame, "TOPLEFT", (10 + (i - 1) * roleSpaceValue), -2) + radioBtn:SetChecked(ConROCMageSpells[roleData.role]) + + local checkedTexture = radioBtn:CreateTexture(nil, "ARTWORK") + checkedTexture:SetTexture(roleData.activeTexture) + checkedTexture:SetBlendMode("BLEND") + checkedTexture:SetSize(roleIconSize, roleIconSize) + checkedTexture:SetPoint("CENTER", radioBtn, "CENTER", 0, 0) + radioBtn:SetCheckedTexture(checkedTexture) + + local uncheckedTexture = radioBtn:CreateTexture(nil, "ARTWORK") + uncheckedTexture:SetTexture(roleData.disabledTexture) + uncheckedTexture:SetBlendMode("BLEND") + uncheckedTexture:SetSize(roleIconSize, roleIconSize) + uncheckedTexture:SetPoint("CENTER", radioBtn, "CENTER", 0, 0) + radioBtn:SetNormalTexture(uncheckedTexture) + + radioBtn:SetScript("OnClick", function(self) + ConROC:setRole(self, roleData, radioButtons) + ConROC:RoleProfile() + end) + + local radioText = radioBtn:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") + radioText:SetText(roleData.frameName) + radioText:SetPoint("BOTTOM", radioBtn, "TOP", 0, -5) + radioBtn.role = roleData.role + table.insert(radioButtons, radioBtn) + end +end + +function ConROC_OptionsWindow(_table, _roles) + local _, Class, classId = UnitClass("player") + local Color = RAID_CLASS_COLORS[Class] + -- create the child frames and add text to them + for i = 1, #_table do + local radioButtonsTable = {} + local frame = CreateFrame("Frame", "ConROC_CheckHeader"..i, ConROCScrollChild, "BackdropTemplate") + frame:SetSize(scrollContentWidth, 20) + if i == 1 then + frame:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0) + else + frame:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -10) + end + if debugOptions.header then + frame:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + nil, + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }) + local r, g, b = math.random(), math.random(), math.random() + frame:SetBackdropColor(r, g, b, 0.5) + end + scrollHeight = scrollHeight + math.ceil(frame:GetHeight()); + frame:Show() + + local text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlightLarge") + text:SetPoint("CENTER", frame, "CENTER") + text:SetText(_table[i].frameName) + frame.text = text -- store the text object in the frame for later use + + spellFrameHeight = 0; + local _spellFrame = CreateFrame("Frame", "ConROC_CheckFrame"..i, frame, "BackdropTemplate"); + _spellFrame:SetSize(scrollContentWidth, 5) + _spellFrame:SetPoint("TOPLEFT", "ConROC_CheckHeader"..i, "BOTTOMLEFT", 0, 0) + if debugOptions.spells then + _spellFrame:SetBackdrop({ + bgFile = "Interface\\Buttons\\WHITE8x8", + nil, + tile = true, tileSize = 16, edgeSize = 16, + insets = { left = 0, right = 0, top = 0, bottom = 0 } + }) + local r, g, b = math.random(), math.random(), math.random() + _spellFrame:SetBackdropColor(r, g, b, 0.5) + end + lastFrame = _spellFrame; + scrollHeight = scrollHeight + 5; + + local _spells = _table[i].spells + for j = 1, #_spells do + local _spellData = _spells[j] + if _spellData.type == "spell" or _spellData.type == "poison" or type == "spell" or _spellData.type == "rune" then + if _table[i].groupType == "radioButtons" then + ConROC:OptionRadioButtonSpell(_spellData, i, j, _spellFrame, radioButtonsTable); + else + ConROC:OptionCheckboxSpell(_spellData, i, j, _spellFrame); + end + elseif _spellData.type == "wand" then + ConROC:OptionWand(_spellData, i, j, _spellFrame); + elseif _spellData.type == "custom" then + ConROC:CustomOption(_spellData, i, j, _spellFrame); + elseif _spellData.type == "textfield" then + ConROC:OptionTextfield(_spellData, i, j, _spellFrame); + elseif _spellData.type == "aoetoggler" then + ConROC:OptionAoE(_spellData, i, j, _spellFrame); + elseif _spellData.type == "none" then + if _table[i].groupType == "radioButtons" then + ConROC:OptionNone(_spellData, i, j, _spellFrame, _table[i].groupType, radioButtonsTable); + else + ConROC:OptionNone(_spellData, i, j, _spellFrame); + end + end + _spellFrame:SetHeight(spellFrameHeight); + frame:Show(); + end + end + ConROCScrollChild:SetHeight(scrollHeight); + +end + +function ConROC:wandEquipmentChanged(slotID) + local newTexture = 0; + if plvl >= 5 then + if GetInventoryItemTexture("player", 18) == nil then + newTexture = GetItemIcon(44214) -- Default Wand texture + else + newTexture = GetInventoryItemTexture("player", 18); + end + wandFrame.texture:SetTexture(newTexture); + end + ConROC:SpellMenuUpdate(); +end + +function ConROC:OptionCheckboxSpell(_spellData, i, j, _spellFrame) + --spell start + local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = CreateFrame("CheckButton", "ConROC_SM_".._spellData.spellCheckbox, _spellFrame, "UICheckButtonTemplate"); + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + ConROC:setRoleChecked(_spellData, oItem) + + oItem:SetScript("OnClick", + function(self) + ConROC:setRoleSpellClicked(_spellData, self) + end); + -- static + oItemtext:SetText(spellName); + local c1t = oItem.texture; + if not c1t then + c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK'); + c1t:SetTexture(spellTexture); + c1t:SetBlendMode('BLEND'); + oItem.texture = c1t; + end + c1t:SetSize(20,20) + c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0); + oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0); + + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); + --spell end +end +function ConROC:OptionRadioButtonSpell(_spellData, i, j, _spellFrame, _radioButtonsTable) + --spell start + local spellName, _, spellTexture; + if type(_spellData.spellID) == "number" then + spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + else + spellName, spellTexture = _spellData.spellID, nil; + end + local myFrame = "ConROC_SM_".._spellData.spellCheckbox + local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UIRadioButtonTemplate"); + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + + ConROC:setRoleChecked(_spellData, oItem) + oItem.spellCheckbox = _spellData.spellCheckbox + _radioButtonsTable[j] = oItem; + + oItem:SetScript("OnClick", + function(self) + local role, checkboxName, frameName = ConROC:checkActiveRole() + for _, radioButton in ipairs(_radioButtonsTable) do + if radioButton ~= self then + radioButton:SetChecked(false) + ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = radioButton:GetChecked() + + else + -- Perform any additional logic based on the selected button + self:SetChecked(true) + ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = self:GetChecked() + + end + end + end); + oItemtext:SetText(spellName); + local c1t = oItem.texture; + if not c1t then + c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK'); + c1t:SetTexture(spellTexture); + c1t:SetBlendMode('BLEND'); + oItem.texture = c1t; + end + c1t:SetSize(20,20) + c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0); + if type(_spellData.spellID) == "number" then + oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0); + else + oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0); + end + _G[myFrame] = oItem + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); + --spell end +end +function ConROC:OptionWand(_spellData, i, j, _spellFrame) + local myFrame = "ConROC_SM_".._spellData.spellCheckbox + local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate"); + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + + ConROC:setRoleChecked(_spellData, oItem) + oItem:SetScript("OnClick", + function(self) + ConROC:setRoleSpellClicked(_spellData, self) + if self:GetChecked() then + if (not HasWandEquipped()) then + flashMessage() + end + end + end); + oItemtext:SetText(_spellData.spellID); + local texture = 0; + if GetInventoryItemTexture("player", 18) == nil then + texture = GetItemIcon(44214) -- Default Wand texture + else + texture = GetInventoryItemTexture("player", 18); + end + local c1t = oItem.texture; + if not c1t then + c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK'); + c1t:SetTexture(texture); + c1t:SetBlendMode('BLEND'); + oItem.texture = c1t; + end + c1t:SetSize(20,20) + c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0); + oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0); + + _G[myFrame] = oItem + + wandFrame = oItem; + ConROC:wandEquipmentChanged(18); + + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); +end +function ConROC:OptionTextfield(_spellData, i, j, _spellFrame) + local oItem = CreateFrame("Frame", "ConROC_SM_".._spellData.spellCheckbox.."Frame", _spellFrame,"BackdropTemplate"); + oItem:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0},}); + oItem:SetBackdropColor(0, 0, 0); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20, 20); + + local box1 = CreateFrame("EditBox", "ConROC_SM_".._spellData.spellCheckbox, oItem); + box1:SetPoint("TOP", 0, 0); + box1:SetPoint("BOTTOM", 0, 0); + box1:SetMultiLine(false); + box1:SetFontObject(GameFontNormalSmall); + box1:SetNumeric(true); + box1:SetAutoFocus(false); + box1:SetMaxLetters("2"); + box1:SetWidth(20); + box1:SetTextInsets(3, 0, 0, 0); + + ConROC:setRoleChecked(_spellData, box1) + box1:SetScript("OnEditFocusLost", + function() + ConROC:setRoleSpellClicked(_spellData, box1) + box1:ClearFocus() + end); + box1:SetScript("OnEnterPressed", + function() + ConROC:setRoleSpellClicked(_spellData, box1) + box1:ClearFocus() + end); + box1:SetScript("OnEscapePressed", + function() + ConROC:setRoleSpellClicked(_spellData, box1) + box1:ClearFocus() + end); + + local e1t = oItem:CreateTexture('CheckFrame2_oItem_Texture', 'ARTWORK'); + e1t:SetTexture(GetItemIcon(_spellData.icon)); + e1t:SetBlendMode('BLEND'); + e1t:SetSize(20,20); + e1t:SetPoint("LEFT", oItem, "LEFT", 20, 0); + + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if(_spellData.customName) then + oItemtext:SetText(_spellData.customName); + else + oItemtext:SetText(_spellData.spellID); + end + oItemtext:SetPoint('LEFT', e1t, 'RIGHT', 5, 0); + + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + scrollHeight = scrollHeight + lastFrame:GetHeight(); + lastFrame:Show(); +end + +function ConROC:CustomOption(_spellData, i, j, _spellFrame) + local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = CreateFrame("CheckButton", "ConROC_SM_".._spellData.spellCheckbox, _spellFrame, "UICheckButtonTemplate"); + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + ConROC:setRoleChecked(_spellData, oItem) + + oItem:SetScript("OnClick", + function(self) + ConROC:setRoleSpellClicked(_spellData, self) + end); + -- static + oItemtext:SetText(_spellData.customName); + local c1t = oItem.texture; + if not c1t then + c1t = oItem:CreateTexture('CheckFrame'..j..'_check'..j..'_Texture', 'ARTWORK'); + c1t:SetTexture(spellTexture); + c1t:SetBlendMode('BLEND'); + oItem.texture = c1t; + end + c1t:SetSize(20,20) + c1t:SetPoint("LEFT", oItem, "RIGHT", 2, 0); + oItemtext:SetPoint('LEFT', c1t, 'RIGHT', 4, 0); + + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); +end +function ConROC:OptionAoE(_spellData, i, j, _spellFrame) + local myFrame = "ConROC_SM_".._spellData.spellCheckbox + local oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate"); + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + ConROC:setRoleChecked(_spellData, oItem) + if ConROC:CheckBox(ConROC_SM_Option_AoE) then + ConROCButtonFrame:Show(); + if ConROC.db.profile.unlockWindow then + ConROCToggleMover:Show(); + else + ConROCToggleMover:Hide(); + end + else + ConROCButtonFrame:Hide(); + ConROCToggleMover:Hide(); + end + + oItem:SetScript("OnClick", + function(self) + ConROC:setRoleSpellClicked(_spellData, self) + if ConROC:CheckBox(ConROC_SM_Option_AoE) then + ConROCButtonFrame:Show(); + if ConROC.db.profile.unlockWindow then + ConROCToggleMover:Show(); + else + ConROCToggleMover:Hide(); + end + else + ConROCButtonFrame:Hide(); + ConROCToggleMover:Hide(); + end + end); + oItemtext:SetText(_spellData.spellID); + oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0); + _G[myFrame] = oItem; + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); +end + +function ConROC:OptionNone(_spellData, i, j, _spellFrame, _checkType, _radioButtonsTable) + _checkType = _checkType or nil + _radioButtonsTable = _radioButtonsTable or nil + local myFrame = "ConROC_SM_".._spellData.spellCheckbox + local oItem; + + if _checkType == "radioButtons" then + oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UIRadioButtonTemplate"); + else + oItem = CreateFrame("CheckButton", myFrame, _spellFrame, "UICheckButtonTemplate"); + end + local oItemtext = oItem:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall"); + if j == 1 then + oItem:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, 0); + end + lastFrame = oItem; + oItem:SetSize(20,20) + ConROC:setRoleChecked(_spellData, oItem) + if _checkType == "radioButtons" then + oItem.spellCheckbox = _spellData.spellCheckbox + _radioButtonsTable[j] = oItem; + oItem:SetScript("OnClick", + function(self) + local role, checkboxName, frameName = ConROC:checkActiveRole() + for _, radioButton in ipairs(_radioButtonsTable) do + if radioButton ~= self then + radioButton:SetChecked(false) + ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = radioButton:GetChecked() + + else + -- Perform any additional logic based on the selected button + self:SetChecked(true) + ConROCMageSpells[checkboxName .. radioButton.spellCheckbox] = self:GetChecked() + + end + end + end); + else + oItem:SetScript("OnClick", + function(self) + ConROC:setRoleSpellClicked(_spellData, self) + end); + end + + oItemtext:SetText(_spellData.spellID); + oItemtext:SetPoint('LEFT', oItem, 'RIGHT', 26, 0); + _G[myFrame] = oItem; + scrollHeight = scrollHeight + math.ceil(lastFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(lastFrame:GetHeight()); + lastFrame:Show(); +end + +function ConROC:SpellMenuUpdate(newSpell) + lastFrame = ConROCScrollChild; + local anyHLVisible = false; + scrollHeight = 0; + local _table = ConROC_RotationSettingsTable; + local firstHeadline = 1; + for i = 1, #_table do + local anyChildVisible = false; + local frame = _G["ConROC_CheckHeader"..i] + if i == firstHeadline then + frame:SetPoint("TOPLEFT", lastFrame, "TOPLEFT", 0, 0) + else + frame:SetPoint("TOPLEFT", lastFrame, "BOTTOMLEFT", 0, -10) + --scrollHeight = scrollHeight + 10; + end + --scrollHeight = scrollHeight + math.ceil(frame:GetHeight()); + frame:Show() + + local spellFrameHeight = 0; + local _spellFrame = _G["ConROC_CheckFrame"..i]; + _spellFrame:SetPoint("TOPLEFT", frame, "BOTTOMLEFT", 0, 0); + local lFrame = _spellFrame; + local _spells = _table[i].spells + local firstItem = 1; + for j = 1, #_spells do + local _spellData = _spells[j] + if _spellData.type == "spell" or _spellData.type == "rune" then + local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if type(_spellData.spellID) == "number" then + if plvl >= _spellData.reqLevel and (IsSpellKnown(_spellData.spellID) or IsSpellKnownOrOverridesKnown(_spellData.spellID)) then + lFrame = oItem; + lFrame:Show(); + if oItem:IsShown() then + anyChildVisible = true; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + end + else + if j == firstItem then + if j == #_spells then + --print("all section spells hidden") + else + firstItem = j + 1; + end + end + oItem:Hide() + --print("Hide spell", spellName) + end + else + end + --spell end + elseif _spellData.type == "wand" then + --Use Wand + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if plvl >= _spellData.reqLevel then + lFrame = oItem; + lFrame:Show(); + if oItem:IsShown() then + anyChildVisible = true; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + end + local role, checkboxName, frameName = ConROC:checkActiveRole() + local spellName = "ConROC_" .. frameName .. "_" .. _spellData.spellCheckbox + else + if j == firstItem then + if j == #_spells then + --print("all section spells hidden") + else + firstItem = j + 1; + end + end + oItem:Hide(); + end + elseif _spellData.type == "aoetoggler" then + local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if plvl >= _spellData.reqLevel then + lFrame = oItem; + lFrame:Show(); + if oItem:IsShown() then + anyChildVisible = true; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + end + else + if j == firstItem then + if j == #_spells then + --print("all section spells hidden") + else + firstItem = j + 1; + end + end + oItem:Hide() + end + elseif _spellData.type == "textfield" then + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox.."Frame"] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if plvl >= _spellData.reqLevel and IsSpellKnown(_spellData.spellID) then + lFrame = oItem; + lFrame:Show(); + if oItem:IsShown() then + anyChildVisible = true; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + end + else + if j == firstItem then + if j == #_spells then + --print("all section spells hidden") + else + firstItem = j + 1; + end + end + oItem:Hide() + end + elseif _spellData.type == "custom" then + --local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if plvl >= _spellData.reqLevel then + lFrame = oItem; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + lFrame:Show(); + anyChildVisible = true; + else + if j == firstItem then + if j == #_spells then + --print("all section spells hidden") + else + firstItem = j + 1; + end + end + --print("Hiding", spellName) + oItem:Hide() + end + elseif _spellData.type == "none" then + local spellName, _, spellTexture = GetSpellInfo(_spellData.spellID) + local oItem = _G["ConROC_SM_".._spellData.spellCheckbox] + if j == firstItem then + oItem:SetPoint("TOPLEFT", lFrame, "TOPLEFT", 0, 0); + else + oItem:SetPoint("TOPLEFT", lFrame, "BOTTOMLEFT", 0, 0); + end + if plvl >= _spellData.reqLevel and anyChildVisible then + lFrame = oItem; + oItem:Show(); + else + oItem:Hide(); + end + if oItem:IsShown() then + --anyChildVisible = true; + scrollHeight = scrollHeight + math.ceil(lFrame:GetHeight()); + spellFrameHeight = spellFrameHeight + math.ceil(oItem:GetHeight()); + end + end + if anyChildVisible then + lastFrame = _spellFrame; + _spellFrame:SetHeight(spellFrameHeight); + end + end + + if anyChildVisible then + --print("-- FRAME to show", frame:GetName()) + if i > firstHeadline then scrollHeight = scrollHeight + 10; end + scrollHeight = scrollHeight + math.ceil(frame:GetHeight()); + frame:Show(); + anyHLVisible = true; + else + --print("-- FRAME to hide", frame:GetName()) + frame:Hide(); + if i == firstHeadline then + firstHeadline = i +1; + end + end + end + if not anyHLVisible then + ConROC_NoOptionsFrame(); + ConROC_NoOptions:Show(); + scrollHeight = ConROCNoOptions:GetHeight() + else + if ConROCNoOptions then + ConROC_NoOptions:Hide(); + end + end + + ConROCScrollChild:SetHeight(scrollHeight); + + -- Update for scrolling window -- Start + if fixOptionsWidth then + ConROCSpellmenuFrame:SetWidth(frameWidth); + CheckScrollbarVisibility() + ConROCScrollContainer:Show(); + ConROCScrollChild:Show(); + end + + if newSpell then + ConROC:closeSpellmenu(); + end +end +function flashMessage() + if HasWandEquipped() or not ConROC:CheckBox(ConROC_SM_Option_UseWand) then + return + end + ConROC:DisplayErrorMessage("You should equip a wand!", 3.0, 0.5, 0.5, 1.0) + if not HasWandEquipped() then + C_Timer.After(5, function() + flashMessage() + end); + end +end + +function ConROC:RoleProfile() + + local activeRole, _, frameName = ConROC:checkActiveRole() + + if ConROC:CheckBox(activeRole) then + for _, rotationSettings in ipairs(ConROC_RotationSettingsTable) do + for _, spellData in ipairs(rotationSettings.spells) do + local spellCheckbox = spellData.spellCheckbox + local checkboxName = "ConROC_SM_" .. spellCheckbox + local spellName = "ConROC_" .. frameName .. "_" .. spellCheckbox + if ConROCMageSpells[spellName] ~= nil then + if type(ConROCMageSpells[spellName]) == "boolean" then + _G["ConROC_SM_" .. spellCheckbox]:SetChecked(ConROCMageSpells[spellName]) + elseif type(ConROCMageSpells[spellName]) == "number" then + _G["ConROC_SM_" .. spellCheckbox]:SetNumber(ConROCMageSpells[spellName]) + end + end + end + end + + if ConROC:CheckBox(ConROC_SM_Option_AoE) then + ConROCButtonFrame:Show() + if ConROC.db.profile.unlockWindow then + ConROCToggleMover:Show() + else + ConROCToggleMover:Hide() + end + else + ConROCButtonFrame:Hide() + ConROCToggleMover:Hide() + end + end +end \ No newline at end of file