diff --git a/Dominos/core/barStates.lua b/Dominos/core/barStates.lua index 0a20bb0..b24867e 100644 --- a/Dominos/core/barStates.lua +++ b/Dominos/core/barStates.lua @@ -3,6 +3,13 @@ local _, Addon = ... local states = {} +local getSpellName +if type(GetSpellInfo) == "function" then + getSpellName = function(spell) return (GetSpellInfo(spell)) end +else + getSpellName = C_Spell.GetSpellName +end + local function getStateIterator(type, i) for j = i + 1, #states do local state = states[j] @@ -68,13 +75,13 @@ local function addFormState(stateType, stateId, spellID) end end - local name = (GetSpellInfo(spellID)) + local name = getSpellName(spellID) addState(stateType, stateId, lookupFormConditional, name) end local function getEquippedConditional(classId, subclassId) - local name = GetItemSubClassInfo(classId, subclassId) + local name = C_Item.GetItemSubClassInfo(classId, subclassId) return ('[equipped:%s]'):format(name) end @@ -105,12 +112,12 @@ local class = UnitClassBase('player') local race = select(2, UnitRace('player')) if class == 'DRUID' then - addState('class', 'bear', '[bonusbar:3]', GetSpellInfo(5487)) - addState('class', 'prowl', '[bonusbar:1,stealth]', GetSpellInfo(5215)) - addState('class', 'cat', '[bonusbar:1]', GetSpellInfo(768)) + addState('class', 'bear', '[bonusbar:3]', getSpellName(5487)) + addState('class', 'prowl', '[bonusbar:1,stealth]', getSpellName(5215)) + addState('class', 'cat', '[bonusbar:1]', getSpellName(768)) if Addon:IsBuild('retail') then - addState('class', 'moonkin', '[bonusbar:4]', GetSpellInfo(24858)) + addState('class', 'moonkin', '[bonusbar:4]', getSpellName(24858)) addFormState('class', 'tree', 114282) addFormState('class', 'travel', 783) @@ -140,7 +147,7 @@ elseif class == 'DEATHKNIGHT' then addFormState('class', 'unholy', 48265) end elseif class == 'EVOKER' then - addState('class', 'soar', '[bonusbar:1]', GetSpellInfo(369536)) + addState('class', 'soar', '[bonusbar:1]', getSpellName(369536)) elseif class == 'HUNTER' then if Addon:IsBuild('cata') then addFormState('class', 'hawk', 13165) @@ -183,21 +190,21 @@ elseif class == 'PRIEST' then if Addon:IsBuild('retail') then addFormState('class', 'shadowform', 232698) else - addState('class', 'shadowform', '[form:1]', GetSpellInfo(15473)) + addState('class', 'shadowform', '[form:1]', getSpellName(15473)) end elseif class == 'ROGUE' then -- classic shadowdance if Addon:IsBuild('cata', 'wrath') then - addState('class', 'shadowdance', '[bonusbar:2]', GetSpellInfo(51713)) + addState('class', 'shadowdance', '[bonusbar:2]', getSpellName(51713)) -- retail shadowdance - elseif GetSpellInfo(185313) then - addState('class', 'shadowdance', '[bonusbar:1,form:2]', GetSpellInfo(185313)) + elseif getSpellName(185313) then + addState('class', 'shadowdance', '[bonusbar:1,form:2]', getSpellName(185313)) end - addState('class', 'stealth', '[bonusbar:1]', GetSpellInfo(1784)) + addState('class', 'stealth', '[bonusbar:1]', getSpellName(1784)) elseif class == 'WARLOCK' then if not Addon:IsBuild('retail') then - addState('class', 'metamorphosis', '[form:1]', GetSpellInfo(47241)) + addState('class', 'metamorphosis', '[form:1]', getSpellName(47241)) end elseif class == 'WARRIOR' then if Addon:IsBuild('retail') then @@ -205,9 +212,9 @@ elseif class == 'WARRIOR' then addFormState('class', 'defensive', 386208) addFormState('class', 'berserker', 386196) else - addState('class', 'battle', '[bonusbar:1]', GetSpellInfo(2457)) - addState('class', 'defensive', '[bonusbar:2]', GetSpellInfo(71)) - addState('class', 'berserker', '[bonusbar:3]', GetSpellInfo(2458)) + addState('class', 'battle', '[bonusbar:1]', getSpellName(2457)) + addState('class', 'defensive', '[bonusbar:2]', getSpellName(71)) + addState('class', 'berserker', '[bonusbar:3]', getSpellName(2458)) end if Addon:IsBuild("retail", "cata") then @@ -217,7 +224,7 @@ end -- race if race == 'NightElf' then - local name = (GetSpellInfo(58984) or GetSpellInfo(20580)) + local name = (getSpellName(58984) or getSpellName(20580)) if name then addState('class', 'shadowmeld', '[stealth]', name) diff --git a/Dominos/core/frame.lua b/Dominos/core/frame.lua index 063c028..d5ddde2 100644 --- a/Dominos/core/frame.lua +++ b/Dominos/core/frame.lua @@ -434,30 +434,63 @@ local function isFlyoutFocus(flyout, owner) return false end -local function isFocus(frame) - if frame:IsForbidden() then - return false - end +local isFocus +if type (GetMouseFocus) == "function" then + isFocus = function(frame) + if frame:IsForbidden() then + return false + end - local focus = GetMouseFocus() + local focus = GetMouseFocus() - -- not focused on a particular frame, check to see if the mouse is over - -- either the frame itself, or a flyout owned by the frame - if focus == WorldFrame then - if frame:IsMouseOver(1, -1, -1, 1) then - return true + -- not focused on a particular frame, check to see if the mouse is over + -- either the frame itself, or a flyout owned by the frame + if focus == WorldFrame then + if frame:IsMouseOver(1, -1, -1, 1) then + return true + end + + if isFlyoutFocus(_G.SpellFlyout, frame) then + return true + end + + if isFlyoutFocus(Addon.SpellFlyout, frame) then + return true + end end - if isFlyoutFocus(_G.SpellFlyout, frame) then - return true + return focus and isDescendant(focus, frame) + end +else + isFocus = function(frame) + if frame:IsForbidden() then + return false end - if isFlyoutFocus(Addon.SpellFlyout, frame) then - return true + for _, focus in ipairs(GetMouseFoci()) do + -- not focused on a particular frame, check to see if the mouse is over + -- either the frame itself, or a flyout owned by the frame + if focus == WorldFrame then + if frame:IsMouseOver(1, -1, -1, 1) then + return true + end + + if isFlyoutFocus(_G.SpellFlyout, frame) then + return true + end + + if isFlyoutFocus(Addon.SpellFlyout, frame) then + return true + end + end + + if isDescendant(focus, frame) then + return true + end end - end - return focus and isDescendant(focus, frame) + return false + end end -- returns all frames docked to the given frame diff --git a/Dominos_Cast/castBar.lua b/Dominos_Cast/castBar.lua index 6321179..c6ff8c7 100644 --- a/Dominos_Cast/castBar.lua +++ b/Dominos_Cast/castBar.lua @@ -4,7 +4,6 @@ local LSM = LibStub("LibSharedMedia-3.0") local L = LibStub("AceLocale-3.0"):GetLocale("Dominos-CastBar") -- local aliases for some globals -local GetSpellInfo = _G.GetSpellInfo local GetTime = _G.GetTime local UnitCastingInfo = _G.UnitCastingInfo or _G.CastingInfo @@ -29,8 +28,46 @@ local CAST_BAR_COLORS = { local LATENCY_BAR_ALPHA = 0.5 -local function GetSpellReaction(spellID) - local name = GetSpellInfo(spellID) +local function getSpellInfo(spellID) + if type(GetSpellInfo) == "function" then + local name, _, iconID, castTime = GetSpellInfo(spellID) + + return name, iconID, castTime + end + + local info = C_Spell.GetSpellInfo(spellID) + if info then + return info.name, info.iconID, info.castTime + end +end + +local function getRandomSpellID() + if type(GetSpellTabInfo) == "function" then + local _, _, offset, numSlots = GetSpellTabInfo(GetNumSpellTabs()) + local _, spellID + + repeat + _, spellID = GetSpellBookItemInfo(math.random(1, offset + numSlots), "player") + until spellID ~= nil + + return spellID + end + + local lineInfo = C_SpellBook.GetSpellBookSkillLineInfo(C_SpellBook.GetNumSpellBookSkillLines()) + local offset = lineInfo.itemIndexOffset + local numSlots = lineInfo.numSpellBookItems + local _, spellID + + repeat + _, _, spellID = C_SpellBook.GetSpellBookItemType(math.random(1, offset + numSlots), Enum.SpellBookSpellBank.Player) + until spellID ~= nil + + return spellID +end + +local function getSpellReaction(spellID) + local name = (GetSpellInfo or C_Spell.GetSpellName)(spellID) + if name then if IsHelpfulSpell(name) then return "help" @@ -289,7 +326,7 @@ function CastBar:reaction_update(reaction) end function CastBar:spell_update(spellID) - local reaction = GetSpellReaction(spellID) + local reaction = getSpellReaction(spellID) self:SetProperty("reaction", reaction) end @@ -488,8 +525,8 @@ function CastBar:Stop() end function CastBar:SetupDemo() - local spellID = self:GetRandomSpellID() - local name, rank, icon, castTime = GetSpellInfo(spellID) + local spellID = getRandomSpellID() + local name, iconID, castTime = getSpellInfo(spellID) -- use the spell cast time if we have it, otherwise set a default one -- of a few seconds @@ -501,9 +538,9 @@ function CastBar:SetupDemo() self:SetProperty("state", "demo") self:SetProperty("label", name) - self:SetProperty("icon", icon) + self:SetProperty("icon", iconID) self:SetProperty("spell", spellID) - self:SetProperty("reaction", GetSpellReaction(spellID)) + self:SetProperty("reaction", getSpellReaction(spellID)) self:SetProperty("uninterruptible", nil) self.timer:SetCountdown(false) diff --git a/changelog.md b/changelog.md index 2f25ef0..d2b5cd6 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Dominos Changelog +## 10.2.30 + +* Add preliminary support for War Within + ## 10.2.29 * Updated TOCs for 10.2.7