Skip to content

Commit

Permalink
feat: initial WoW 11.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Jun 19, 2024
1 parent ab7de4b commit 038ca6a
Show file tree
Hide file tree
Showing 23 changed files with 152 additions and 73 deletions.
2 changes: 1 addition & 1 deletion Components/Core/Common/IconDragger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function IconDragger:CompleteDrag(script, icon)
IconDragger:ScheduleTimer("SetIsDraggingFalse", 0.1)

-- icon is the destination
icon = icon or GetMouseFocus()
icon = icon or (GetMouseFoci and GetMouseFoci()[1] or GetMouseFocus())

if IconDragger.IsDragging then

Expand Down
3 changes: 2 additions & 1 deletion Components/Core/Conditions/Categories/PlayerAttributes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ local strlowerCache = TMW.strlowerCache

local _, pclass = UnitClass("Player")

local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or GetSpellTexture
local IsInInstance, GetInstanceDifficulty, GetNumShapeshiftForms, GetShapeshiftFormInfo =
IsInInstance, GetInstanceDifficulty, GetNumShapeshiftForms, GetShapeshiftFormInfo
local GetPetActionInfo = GetPetActionInfo
Expand Down Expand Up @@ -223,7 +224,7 @@ ConditionCategory:RegisterCondition(12, "AUTOCAST", {
icon = "Interface\\Icons\\ability_physical_taunt",
tcoords = CNDT.COMMON.standardtcoords,
Env = {
GetSpellAutocast = GetSpellAutocast,
GetSpellAutocast = C_Spell.GetSpellAutocast or _G.GetSpellAutocast,
},
funcstr = [[BOOLCHECK( select(2, GetSpellAutocast(c.Spells.FirstString)) )]],
events = function(ConditionObject, c)
Expand Down
10 changes: 5 additions & 5 deletions Components/Core/Conditions/Categories/Spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function Env.CooldownDuration(spell, gcdAsUnusable)
return 0, 0, 0
end

local GetSpellCharges = GetSpellCharges
local GetSpellCharges = TMW.GetSpellCharges
function Env.RechargeDuration(spell)
local charges, maxCharges, start, duration = GetSpellCharges(spell)
if charges and charges ~= maxCharges then
Expand Down Expand Up @@ -180,8 +180,8 @@ if TMW.isRetail then
icon = "Interface\\Icons\\ability_monk_roll",
tcoords = CNDT.COMMON.standardtcoords,
Env = {
GetSpellCharges = GetSpellCharges,
GetSpellCount = GetSpellCount,
GetSpellCharges = TMW.GetSpellCharges,
GetSpellCount = C_Spell.GetSpellCastCount or _G.GetSpellCount
},
funcstr = [[(GetSpellCharges(c.OwnSpells.First) or GetSpellCount(c.OwnSpells.First)) c.Operator c.Level]],
events = function(ConditionObject, c)
Expand Down Expand Up @@ -212,7 +212,7 @@ if TMW.isRetail then
icon = "Interface\\Icons\\ability_warlock_handofguldan",
tcoords = CNDT.COMMON.standardtcoords,
Env = {
GetSpellCharges = GetSpellCharges,
GetSpellCharges = TMW.GetSpellCharges,
},
funcstr = [[RechargeDuration(c.OwnSpells.First) c.Operator c.Level]],
events = function(ConditionObject, c)
Expand Down Expand Up @@ -301,7 +301,7 @@ ConditionCategory:RegisterCondition(2.8, "LASTCAST", {

ConditionCategory:RegisterSpacer(2.9)

local IsUsableSpell = IsUsableSpell
local IsUsableSpell = C_Spell.IsSpellUsable or _G.IsUsableSpell
function Env.ReactiveHelper(NameFirst, Checked)
local usable, nomana = IsUsableSpell(NameFirst)
if Checked then
Expand Down
8 changes: 4 additions & 4 deletions Components/Core/Conditions/Categories/Talents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,10 @@ end

if C_Covenants then
TMW.CovenantIcons = {
[1] = GetSpellTexture(321076),
[2] = GetSpellTexture(321079),
[3] = GetSpellTexture(299206),
[4] = GetSpellTexture(321078),
[1] = TMW.GetSpellTexture(321076),
[2] = TMW.GetSpellTexture(321079),
[3] = TMW.GetSpellTexture(299206),
[4] = TMW.GetSpellTexture(321078),
}
ConditionCategory:RegisterCondition(22, "COVENANT", {
text = L["CONDITIONPANEL_COVENANT"],
Expand Down
2 changes: 1 addition & 1 deletion Components/Core/Conditions/Categories/Talents_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function Module:Entry_AddToList_1(f, id)
f.tooltipmethod = "SetSpellByID"
f.tooltiparg = id

f.Icon:SetTexture(GetSpellTexture(id))
f.Icon:SetTexture(TMW.GetSpellTexture(id))
elseif GetNumTalentTabs then
-- Wrath
local tab, talent = parseId(id)
Expand Down
1 change: 1 addition & 0 deletions Components/Core/IconDataProcessors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ local print = TMW.print

local format = format
local isNumber = TMW.isNumber
local GetSpellLink = C_Spell and C_Spell.GetSpellLink or GetSpellLink



Expand Down
17 changes: 8 additions & 9 deletions Components/Core/IconType.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ local TMW = TMW
local L = TMW.L
local print = TMW.print

local GetSpellInfo, GetSpellLink, GetSpellBookItemInfo, GetSpellBookItemName
= GetSpellInfo, GetSpellLink, GetSpellBookItemInfo, GetSpellBookItemName
local GetSpellInfo
= GetSpellInfo
local pairs, ipairs, setmetatable, rawget, date, tinsert, type
= pairs, ipairs, setmetatable, rawget, date, tinsert, type

local GetSpellBookItemInfo = TMW.GetSpellBookItemInfo

local GetSpellLink = C_Spell and C_Spell.GetSpellLink or GetSpellLink
local GetSpellTexture = TMW.GetSpellTexture
local tContains = TMW.tContains
local tDeleteItem = TMW.tDeleteItem
Expand Down Expand Up @@ -215,17 +217,14 @@ function IconType:DragReceived(icon, t, data, subType, param4)
-- It handles some special sort of spell, though, and is required.
input = GetSpellInfo(param4)
else
local type, baseSpellID = GetSpellBookItemInfo(data, subType)

if not baseSpellID or type ~= "SPELL" then
local spellData = GetSpellBookItemInfo(data, subType)
if not spellData or spellData.typeName ~= "SPELL" then
return
end

local baseSpellName = GetSpellInfo(spellData.actionId)

local currentSpellName = GetSpellBookItemName(data, subType)
local baseSpellName = GetSpellInfo(baseSpellID)

input = baseSpellName or currentSpellName
input = baseSpellName or spellData.name
end

ics.Name = TMW:CleanString(ics.Name .. ";" .. input)
Expand Down
4 changes: 2 additions & 2 deletions Components/Core/Spells/Spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ local print = TMW.print
local type, pairs, gsub, strfind, strmatch, strsplit, strtrim, tonumber, tremove, ipairs, tinsert, CopyTable, setmetatable =
type, pairs, gsub, strfind, strmatch, strsplit, strtrim, tonumber, tremove, ipairs, tinsert, CopyTable, setmetatable
local tconcat = table.concat
local GetSpellInfo =
GetSpellInfo
local GetSpellInfo = GetSpellInfo
local GetSpellTexture = TMW.GetSpellTexture

local strlowerCache = TMW.strlowerCache

Expand Down
56 changes: 53 additions & 3 deletions Components/Core/Utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ local math, max, ceil, floor, random, abs =
local _G, coroutine, table, GetTime, CopyTable, tostringall, geterrorhandler, C_Timer =
_G, coroutine, table, GetTime, CopyTable, tostringall, geterrorhandler, C_Timer

local IsUsableSpell, GetRuneCooldown, GetSpecialization, GetSpecializationInfo, GetFramerate =
IsUsableSpell, GetRuneCooldown, GetSpecialization, GetSpecializationInfo, GetFramerate
local GetRuneCooldown, GetSpecialization, GetSpecializationInfo, GetFramerate =
GetRuneCooldown, GetSpecialization, GetSpecializationInfo, GetFramerate

local IsUsableSpell = C_Spell.IsSpellUsable or _G.IsUsableSpell
local GetSpellPowerCost = C_Spell.GetSpellPowerCost or _G.GetSpellPowerCost

local debugprofilestop = debugprofilestop_SAFE

Expand Down Expand Up @@ -1255,7 +1258,7 @@ function TMW:TT_Copy(src, dest)
end

function TMW:TT_Update(f)
if GetMouseFocus() == f and f:IsMouseOver() and f:IsVisible() then
if f:IsMouseMotionFocus() and f:IsMouseOver() and f:IsVisible() then
f:GetScript("OnLeave")(f)
if not f.IsEnabled or f:IsEnabled() or (f:IsObjectType("Button") and f:GetMotionScriptsWhileDisabled()) then
f:GetScript("OnEnter")(f)
Expand Down Expand Up @@ -1367,6 +1370,53 @@ function TMW.GetRuneCooldownDuration()
return floor(duration * 1e3 + 0.5) / 1e3
end

if C_Spell.GetSpellCharges then
local GetSpellCharges = C_Spell.GetSpellCharges
TMW.GetSpellCharges = function(spell)
local data = GetSpellCharges(spell)
if not data then return end

return data.currentCharges, data.maxCharges, data.cooldownStartTime, data.cooldownDuration
end
else
TMW.GetSpellCharges = GetSpellCharges
end

if C_SpellBook and C_SpellBook.GetSpellBookItemType then
TMW.GetSpellBookItemInfo = function(index, book)
if book == "pet" then
book = Enum.SpellBookSpellBank.Pet
else
book = Enum.SpellBookSpellBank.Player
end

local data = C_SpellBook.GetSpellBookItemInfo(index, book)
if not data then return end

-- typeName is for backwards compat
if data.itemType == Enum.SpellBookItemType.Spell then data.typeName = "SPELL" end
-- Nothing in TMW uses the other types besides SPELL

return data
end
else
TMW.GetSpellBookItemInfo = function(index, book)
local type, baseSpellID = GetSpellBookItemInfo(index, book)
if not type then return end

if data.itemType == Enum.SpellBookItemType.Spell then data.typeName = "SPELL" end

return {
-- Nothing in TMW uses the other types besides SPELL
-- itemType is for forward compat
itemType = type == "SPELL" and 1 or -1,
typeName = type,
actionId = baseSpellID,
name = GetSpellBookItemName(index, book)
}
end
end

local function spellCostSorter(a, b)
local hasA = a.requiredAuraID ~= 0 and a.hasRequiredAura
local hasB = b.requiredAuraID ~= 0 and b.hasRequiredAura
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
end)


local GetSpellBookItemInfo = TMW.GetSpellBookItemInfo
function self:DragReceived(icon, t, data, subType)
local ics = icon:GetSettings()

local _, input
if t == "spell" then
_, input = GetSpellBookItemInfo(data, subType)
local spellData = GetSpellBookItemInfo(data, subType)
input = spellData and spellData.actionID
elseif t == "item" then
input = GetItemIcon(data)
end
Expand Down
9 changes: 2 additions & 7 deletions Components/IconModules/IconModule_PowerBar/PowerBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ local LSM = LibStub("LibSharedMedia-3.0")
local _, pclass = UnitClass("Player")
local GetSpellInfo, UnitPower =
GetSpellInfo, UnitPower
local GetSpellLink = C_Spell and C_Spell.GetSpellLink or GetSpellLink
local pairs, wipe, _G =
pairs, wipe, _G
local PowerBarColor = PowerBarColor
Expand Down Expand Up @@ -100,14 +101,8 @@ end
function PowerBar:SetSpell(spell)
local bar = self.bar
self.spell = spell
self.spellLink = GetSpellLink(spell)


if self.spellLink then
-- We have to manually extract the spellID from the link because
-- GetSpellInfo doesn't work for spell links since wotlk.
self.spellID = self.spellLink:match("Hspell:(%d+)")

if spell then
self:UpdateCost()

self:UpdateTable_Register()
Expand Down
1 change: 1 addition & 0 deletions Components/IconTypes/IconType_cleu/cleu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local bit_band, bit_bor, tinsert, tremove, unpack, wipe =
local UnitGUID, GetItemIcon, CombatLogGetCurrentEventInfo =
UnitGUID, GetItemIcon, CombatLogGetCurrentEventInfo
local GetSpellTexture = TMW.GetSpellTexture
local GetSpellLink = C_Spell and C_Spell.GetSpellLink or GetSpellLink

local pGUID = nil -- This can't be defined at load.
local clientVersion = select(4, GetBuildInfo())
Expand Down
9 changes: 6 additions & 3 deletions Components/IconTypes/IconType_conditionicon/conditionicon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ if not TMW then return end
local L = TMW.L

local print = TMW.print
local GetSpellBookItemInfo, GetItemIcon =
GetSpellBookItemInfo, GetItemIcon
local GetItemIcon =
GetItemIcon

local GetSpellBookItemInfo = TMW.GetSpellBookItemInfo

local Type = TMW.Classes.IconType:New("conditionicon")
Type.name = L["ICONMENU_CNDTIC"]
Type.desc = L["ICONMENU_CNDTIC_DESC"]
Expand Down Expand Up @@ -177,7 +179,8 @@ function Type:DragReceived(icon, t, data, subType)

local _, input
if t == "spell" then
_, input = GetSpellBookItemInfo(data, subType)
local spellData = GetSpellBookItemInfo(data, subType)
input = spellData and spellData.actionID
elseif t == "item" then
input = GetItemIcon(data)
end
Expand Down
7 changes: 5 additions & 2 deletions Components/IconTypes/IconType_cooldown/cooldown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ if not TMW then return end
local L = TMW.L

local print = TMW.print
local GetSpellInfo, GetSpellCooldown, GetSpellCharges, GetSpellCount, IsUsableSpell =
GetSpellInfo, GetSpellCooldown, GetSpellCharges, GetSpellCount, IsUsableSpell
local GetSpellInfo, GetSpellCooldown =
GetSpellInfo, GetSpellCooldown
local UnitRangedDamage =
UnitRangedDamage
local pairs, wipe, strlower =
Expand All @@ -25,6 +25,9 @@ local pairs, wipe, strlower =
local OnGCD = TMW.OnGCD
local SpellHasNoMana = TMW.SpellHasNoMana
local GetSpellTexture = TMW.GetSpellTexture
local GetSpellCharges = TMW.GetSpellCharges
local IsUsableSpell = C_Spell.IsSpellUsable or _G.IsUsableSpell
local GetSpellCount = C_Spell.GetSpellCastCount or _G.GetSpellCount
local GetRuneCooldownDuration = TMW.GetRuneCooldownDuration

local _, pclass = UnitClass("Player")
Expand Down
18 changes: 8 additions & 10 deletions Components/IconTypes/IconType_default/default.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ local L = TMW.L
local print = TMW.print
local type =
type
local GetSpellInfo, GetSpellBookItemInfo, GetSpellBookItemName =
GetSpellInfo, GetSpellBookItemInfo, GetSpellBookItemName
local GetSpellInfo =
GetSpellInfo

local GetSpellBookItemInfo = TMW.GetSpellBookItemInfo

local Type = TMW.Classes.IconType:New("")
Type.name = L["ICONMENU_TYPE"]
Expand Down Expand Up @@ -56,7 +58,6 @@ function Type:DragReceived(icon, t, data, subType, param4)
local ics = icon:GetSettings()

-- Take the dragged thing and create a new icon from it of the appropriate type.

local newType, input
if t == "spell" then
if data == 0 and type(param4) == "number" then
Expand All @@ -65,17 +66,14 @@ function Type:DragReceived(icon, t, data, subType, param4)
-- param4 here is a spellID, obviously.
input = GetSpellInfo(param4)
else
local type, baseSpellID = GetSpellBookItemInfo(data, subType)

if not baseSpellID or type ~= "SPELL" then
local spellData = GetSpellBookItemInfo(data, subType)
if not spellData or spellData.typeName ~= "SPELL" then
return
end


local currentSpellName = GetSpellBookItemName(data, subType)
local baseSpellName = GetSpellInfo(baseSpellID)

input = baseSpellName or currentSpellName
local baseSpellName = GetSpellInfo(spellData.actionId)
input = baseSpellName or spellData.name
end

newType = "cooldown"
Expand Down
11 changes: 8 additions & 3 deletions Components/IconTypes/IconType_reactive/reactive.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ local TMW = TMW
if not TMW then return end
local L = TMW.L

local print = TMW.print
local GetSpellCooldown, IsUsableSpell, GetSpellInfo, GetSpellCharges, GetSpellCount =
GetSpellCooldown, IsUsableSpell, GetSpellInfo, GetSpellCharges, GetSpellCount
local _, pclass = UnitClass("player")

local print = TMW.print
local GetSpellCooldown, GetSpellInfo =
GetSpellCooldown, GetSpellInfo

local GetSpellTexture = TMW.GetSpellTexture
local GetSpellCharges = TMW.GetSpellCharges
local IsUsableSpell = C_Spell.IsSpellUsable or _G.IsUsableSpell
local GetSpellCount = C_Spell.GetSpellCastCount or _G.GetSpellCount

local strlowerCache = TMW.strlowerCache
local OnGCD = TMW.OnGCD
local SpellHasNoMana = TMW.SpellHasNoMana
Expand Down
Loading

0 comments on commit 038ca6a

Please sign in to comment.