-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattleHerald_Main.lua
More file actions
85 lines (67 loc) · 2.25 KB
/
Copy pathBattleHerald_Main.lua
File metadata and controls
85 lines (67 loc) · 2.25 KB
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
--[[
BattleHerald_Main.lua
Starting point for the addon
]]--
local BH_VERSION_INFO = 1.04;
local NEWVERSION = false;
function BattleHerald_MainFrameLoad(self)
self:RegisterEvent("VARIABLES_LOADED");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PLAYER_ENTERING_BATTLEFIELD");
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
self:RegisterEvent("CHAT_MSG_ADDON");
RegisterAddonMessagePrefix("BHVerInfo");
end
function BattleHerald_MainFrameEvent(self, event, ...)
if (event == "CHAT_MSG_ADDON") then
if (arg1 == "BHVerInfo") then
BattleHerald_HandleVersionInfo(arg2, arg4, arg3);
end
elseif (event == "VARIABLES_LOADED") then
BattleHerald_InitializeUserOptions();
BattleHerald_CreateUserOptionsPanels();
ChatFrame1:AddMessage("Battle Herald Loaded.");
elseif (event == "PLAYER_ENTERING_WORLD") then
if (IsInGuild()) then
BattleHerald_PostVersionInfo("GUILD");
end
elseif (event == "PLAYER_ENTERING_BATTLEGROUND") then
BattleHerald_PostVersionInfo("BATTLEGROUND");
elseif (event == "PARTY_MEMBERS_CHANGED") then
if (GetRealNumRaidMembers() > 1) then
BattleHerald_PostVersionInfo("RAID");
elseif (GetRealNumPartyMembers() > 1) then
BattleHerald_PostVersionInfo("PARTY");
end
end
end
function BattleHerald_IsInBattlefield()
local zone = GetInstanceInfo();
if (zone == "Warsong Gulch" or zone == "Arathi Basin"
or zone == "Alterac Valley" or zone == "Isle of Conquest"
or zone == "Eye of the Storm" or zone == "Strand of the Ancients"
or zone == "The Battle for Gilneas" or zone == "Twin Peaks") then
return true;
else
zone = GetRealZoneText();
if (zone == "Wintergrasp" or zone == "Tol Barad") then
return true;
else
return false;
end
end
end
function BattleHerald_PostVersionInfo(channel, target)
SendAddonMessage("BHVerInfo", BH_VERSION_INFO, channel, target);
end
function BattleHerald_HandleVersionInfo(msg, author, channel)
local recNumber = tonumber(msg);
if (recNumber > BH_VERSION_INFO) then
if (not NEWVERSION) then
NEWVERSION = true;
DEFAULT_CHAT_FRAME:AddMessage(BHSTR_NEW_VERSION);
end
elseif (recNumber < BH_VERSION_INFO) then
BattleHerald_PostVersionInfo("WHISPER", author);
end
end