-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalert_frames.lua
136 lines (108 loc) · 5.62 KB
/
alert_frames.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
-- Prevents the GarrisonMissionAlertFrame and GarrisonBuildingAlertFrame from being shown.
-- http://wowprogramming.com/utils/xmlbrowser/test/FrameXML/AlertFrames.lua
local addonName, addon = ...
setfenv(1, addon)
------------------------------------------------------------------------------------------------------------------------
-- Prevent all MONEY_WON_ALERT_FRAMES from ever showing up. Instead, add a chat message in the style of the normal
-- money loot messages. This should also prevent the creation of a lot of frames as only MoneyWonAlertFrame1 is always
-- created and this function will create an extra unnamed frame when there is no unused frame in MONEY_WON_ALERT_FRAMES.
_G.MoneyWonAlertFrame_ShowAlert = function(amount)
print("MoneyWonAlertFrame_ShowAlert() blocked:", amount)
local gold = _G.math.floor(amount / 10000)
local silver = _G.math.floor((amount - 10000 * gold) / 100)
local copper = amount % 100
local goldString = gold > 0 and _G.string.format(_G.GOLD_AMOUNT, gold) or ""
local silverString = silver > 0 and (gold > 0 and ", " or "") .. _G.string.format(_G.SILVER_AMOUNT, silver) or ""
local copperString = copper > 0 and _G.string.format(", " .. _G.COPPER_AMOUNT, copper) or ""
local message = _G.string.format(_G.YOU_LOOT_MONEY .. "%s%s%s", "", goldString, silverString, copperString)
local info = _G.ChatTypeInfo["MONEY"]
for i = 1, _G.NUM_CHAT_WINDOWS do
local chatFrame = _G["ChatFrame" .. i]
if chatFrame:IsEventRegistered("CHAT_MSG_MONEY") then
chatFrame:AddMessage(message, info.r, info.g, info.b, info.id)
end
end
end
-- http://wowprogramming.com/utils/xmlbrowser/test/FrameXML/AlertFrames.xml
-- http://wowprogramming.com/utils/xmlbrowser/test/FrameXML/AlertFrames.lua
------------------------------------------------------------------------------------------------------------------------
local LOOT_SOURCE_GARRISON_CACHE = 10 -- In wowprogramming.com/utils/xmlbrowser/test/FrameXML/AlertFrames.lua
_G.LootWonAlertFrame_ShowAlert = function(itemLink, quantity, rollType, roll, specId, isCurrency, showFactionBg, source)
print("LootWonAlertFrame_ShowAlert() blocked:", itemLink, quantity, rollType, roll, specId, isCurrency, showFactionBg,
source)
_G.assert(itemLink, quantity, isCurrency)
-- I think there might actually always be a chat message for this type of alert frame already. TODO: confirm.
--[=[
-- There already is a chat message when looting the Garrison Cache. There are probably other instances where a
-- chat message is already added by default.
if source and source == LOOT_SOURCE_GARRISON_CACHE then return end
local message
if isCurrency then
if quantity == 1 then
message = _G.string.format(_G.CURRENCY_GAINED, itemLink)
else
message = _G.string.format(_G.CURRENCY_GAINED_MULTIPLE, itemLink, quantity)
end
local info = _G.ChatTypeInfo["CURRENCY"]
for i = 1, _G.NUM_CHAT_WINDOWS do
local chatFrame = _G["ChatFrame" .. i]
if chatFrame:IsEventRegistered("CHAT_MSG_CURRENCY") then
chatFrame:AddMessage(message, info.r, info.g, info.b, info.id)
end
end
-- I think there always is a chat message for items.
--[[
else
if quantity == 1 then
message = _G.string.format(_G.LOOT_ITEM_PUSHED_SELF, itemLink)
else
message = _G.string.format(_G.LOOT_ITEM_PUSHED_SELF_MULTIPLE, itemLink, quantity)
end
--]]
end
--]=]
end
_G.LootUpgradeFrame_ShowAlert = function()
-- Seems completely useless. I don't feel like there has to be a chat message to replace it.
print("LootWonAlertFrame_ShowAlert() blocked")
end
_G.DigsiteCompleteToastFrame_ShowAlert = function(researchBranchId)
-- Useless.
end
_G.AchievementAlertFrame_ShowAlert = function(...)
-- The normal achievement notification in chat is enough.
end
-- Replacement for criteria alert frames. TODO: Test.
_G.CriteriaAlertFrame_ShowAlert = function(achievementId, criteriaId, ...)
--print("CriteriaAlertFrame_ShowAlert() blocked:", achievementId, criteriaId, ...)
-- Apparently the second argument passed to this function already is the criteria string now.
local criteriaString = criteriaId
--local criteriaString = _G.GetAchievementCriteriaInfoByID(achievementId, criteriaId)
local info = _G.ChatTypeInfo["ACHIEVEMENT"]
for i = 1, _G.NUM_CHAT_WINDOWS do
local chatFrame = _G["ChatFrame" .. i]
if chatFrame:IsEventRegistered("CHAT_MSG_ACHIEVEMENT") then
chatFrame:AddMessage("Achievement progress: " .. _G.GetAchievementLink(achievementId) .. ": " .. criteriaString,
info.r, info.g, info.b, info.id)
end
end
end
-- github.com/tekkub/wow-ui-source/blob/ptr/FrameXML/AlertFrames.lua
_G.AlertFrame:UnregisterEvent("GARRISON_BUILDING_ACTIVATABLE") -- GarrisonBuildingAlertFrame
_G.AlertFrame:UnregisterEvent("GARRISON_MISSION_FINISHED") -- GarrisonMissionAlertFrame
_G.AlertFrame:UnregisterEvent("GARRISON_FOLLOWER_ADDED") -- GarrisonFollowerAlertFrame
local frame = _G.CreateFrame("Frame")
frame:SetScript("OnEvent", function(self, event, ...)
return self[event](self, ...)
end)
function frame:ADDON_LOADED(name)
-- It's not guaranteed that the first ADDON_LOADED event we see is for this addon. It's possible that this file is
-- loaded and we get here in response to a different addon having finished loading.
if name ~= addonName then return end
-- FIXME: this function still gets called for every single other addon loaded later. This seems to be caused by
-- calling LoadAddOn("Blizzard_PVPUI") in this addon's tooltips.lua in response to ADDON_LOADED.
self:UnregisterEvent("ADDON_LOADED")
--self.ADDON_LOADED = nil
end
frame:RegisterEvent("ADDON_LOADED")
-- vim: tw=120 sts=2 sw=2 et