diff --git a/WeakAuras/GenericTrigger.lua b/WeakAuras/GenericTrigger.lua index bd673ec964..bd1118e421 100644 --- a/WeakAuras/GenericTrigger.lua +++ b/WeakAuras/GenericTrigger.lua @@ -4425,11 +4425,40 @@ WeakAuras.GetHitChance = function() return max(melee, ranged, spell) end +Private.ExecEnv.GetCurrencyInfo = function(id) + if WeakAuras.IsRetail() then + return C_CurrencyInfo.GetCurrencyInfo(id) + elseif WeakAuras.IsWrathClassic() then + local name, currentAmount, texture, earnedThisWeek, weeklyMax, totalMax, isDiscovered, rarity = GetCurrencyInfo(id) + local currencyInfo = { + name = name, + description = "", + isHeader = false, + isHeaderExpanded = false, + isTypeUnused = false, + isShowInBackpack = false, + quantity = currentAmount, + trackedQuantity = 0, + iconFileID = texture, + maxQuantity = totalMax, + canEarnPerWeek = weeklyMax > 0, + quantityEarnedThisWeek = earnedThisWeek, + isTradeable = false, + quality = rarity, + maxWeeklyQuantity = weeklyMax, + totalEarned = 0, + discovered = isDiscovered, + useTotalEarnedForMaxQty = false, + } + return currencyInfo + end +end + Private.GetCurrencyInfoForTrigger = function(trigger) if trigger.currencyId then local currencyId = tonumber(trigger.currencyId) if currencyId then - return C_CurrencyInfo.GetCurrencyInfo(currencyId) + return Private.ExecEnv.GetCurrencyInfo(currencyId) end end end diff --git a/WeakAuras/Prototypes.lua b/WeakAuras/Prototypes.lua index 8988e84710..d7a3c809c8 100644 --- a/WeakAuras/Prototypes.lua +++ b/WeakAuras/Prototypes.lua @@ -10234,9 +10234,9 @@ Private.event_prototypes = { name = WeakAuras.newFeatureString..L["Currency"], init = function(trigger) local ret = [=[ - local currencyInfo = C_CurrencyInfo.GetCurrencyInfo(%d) + local currencyInfo = Private.ExecEnv.GetCurrencyInfo(%d) if not currencyInfo then - currencyInfo = C_CurrencyInfo.GetCurrencyInfo(1) --Currency Token Test Token 4 + currencyInfo = Private.ExecEnv.GetCurrencyInfo(1) --Currency Token Test Token 4 currencyInfo.iconFileID = "Interface\\Icons\\INV_Misc_QuestionMark" --We don't want the user to think their input was valid end ]=] @@ -10417,6 +10417,7 @@ if WeakAuras.IsClassicEraOrWrath() then end if not WeakAuras.IsWrathClassic() then Private.event_prototypes["Death Knight Rune"] = nil + Private.event_prototypes["Currency"] = nil end Private.event_prototypes["Evoker Essence"] = nil Private.event_prototypes["Alternate Power"] = nil diff --git a/WeakAuras/Types.lua b/WeakAuras/Types.lua index fe80bee54f..ab919b4352 100644 --- a/WeakAuras/Types.lua +++ b/WeakAuras/Types.lua @@ -1320,6 +1320,50 @@ for id, str in pairs(Private.combatlog_spell_school_types) do Private.combatlog_spell_school_types_for_ui[id] = ("%.3d - %s"):format(id, str) end +if WeakAuras.IsRetail() then + Private.GetCurrencyListSize = C_CurrencyInfo.GetCurrencyListSize + Private.GetCurrencyIDFromLink = C_CurrencyInfo.GetCurrencyIDFromLink + Private.ExpandCurrencyList = C_CurrencyInfo.ExpandCurrencyList + Private.GetCurrencyListInfo = C_CurrencyInfo.GetCurrencyListInfo +elseif WeakAuras.IsWrathClassic() then + Private.GetCurrencyListSize = GetCurrencyListSize + Private.GetCurrencyIDFromLink = function(currencyLink) + local currencyID = string.match(currencyLink, "|Hcurrency:(%d+):") + return currencyID + end + Private.ExpandCurrencyList = function(index, expand) + ExpandCurrencyList(index, expand and 1 or 0) + end + Private.GetCurrencyListInfo = function(index) + local name, isHeader, isExpanded, isUnused, isWatched, _, icon, _, hasWeeklyLimit, _, _, itemID = GetCurrencyListInfo(index) + local currentAmount, earnedThisWeek, weeklyMax, totalMax, isDiscovered, rarity + if itemID then + _, currentAmount, _, earnedThisWeek, weeklyMax, totalMax, isDiscovered, rarity = GetCurrencyInfo(itemID) + end + local currencyInfo = { + name = name, + description = "", + isHeader = isHeader, + isHeaderExpanded = isExpanded, + isTypeUnused = isUnused, + isShowInBackpack = isWatched, + quantity = currentAmount, + trackedQuantity = 0, + iconFileID = icon, + maxQuantity = totalMax, + canEarnPerWeek = hasWeeklyLimit, + quantityEarnedThisWeek = earnedThisWeek, + isTradeable = false, + quality = rarity, + maxWeeklyQuantity = weeklyMax, + totalEarned = 0, + discovered = isDiscovered, + useTotalEarnedForMaxQty = false, + } + return currencyInfo + end +end + local function InitializeCurrencies() if Private.discovered_currencies then return @@ -1328,20 +1372,21 @@ local function InitializeCurrencies() Private.discovered_currencies_sorted = {} Private.discovered_currencies_headers = {} local expanded = {} - for index = C_CurrencyInfo.GetCurrencyListSize(), 1, -1 do - local currencyInfo = C_CurrencyInfo.GetCurrencyListInfo(index) + + for index = Private.GetCurrencyListSize(), 1, -1 do + local currencyInfo = Private.GetCurrencyListInfo(index) if currencyInfo.isHeader and not currencyInfo.isHeaderExpanded then - C_CurrencyInfo.ExpandCurrencyList(index, true) + Private.ExpandCurrencyList(index, true) expanded[currencyInfo.name] = true end end - for index = 1, C_CurrencyInfo.GetCurrencyListSize() do + for index = 1, Private.GetCurrencyListSize() do local currencyLink = C_CurrencyInfo.GetCurrencyListLink(index) - local currencyInfo = C_CurrencyInfo.GetCurrencyListInfo(index) + local currencyInfo = Private.GetCurrencyListInfo(index) if currencyLink then - local currencyID = C_CurrencyInfo.GetCurrencyIDFromLink(currencyLink) + local currencyID = Private.GetCurrencyIDFromLink(currencyLink) local icon = currencyInfo.iconFileID or "Interface\\Icons\\INV_Misc_QuestionMark" --iconFileID not available on first login Private.discovered_currencies[currencyID] = "|T" .. icon .. ":0|t" .. currencyInfo.name Private.discovered_currencies_sorted[currencyID] = index @@ -1352,10 +1397,10 @@ local function InitializeCurrencies() end end - for index = C_CurrencyInfo.GetCurrencyListSize(), 1, -1 do - local currencyInfo = C_CurrencyInfo.GetCurrencyListInfo(index) + for index = Private.GetCurrencyListSize(), 1, -1 do + local currencyInfo = Private.GetCurrencyListInfo(index) if currencyInfo.isHeader and expanded[currencyInfo.name] then - C_CurrencyInfo.ExpandCurrencyList(index, false) + Private.ExpandCurrencyList(index, false) end end