Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Currency Trigger: support classic wrath, disable on classic era #4755

Merged
merged 6 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
]=]
Expand Down Expand Up @@ -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
Expand Down
63 changes: 54 additions & 9 deletions WeakAuras/Types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down