-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleRaidFrames_Main.lua
More file actions
executable file
·109 lines (98 loc) · 3.14 KB
/
SimpleRaidFrames_Main.lua
File metadata and controls
executable file
·109 lines (98 loc) · 3.14 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
local ADDON_NAME = ...
local M = _G[ADDON_NAME]
function M:CreateSettingsPanel()
if not Settings or not Settings.RegisterCanvasLayoutCategory then return end
local panel = CreateFrame("Frame")
panel.name = M._settingsCategoryName
local title = panel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
title:SetPoint("TOPLEFT", 16, -16)
title:SetText("SimpleRaidFrames")
local desc = panel:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
desc:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -8)
desc:SetWidth(520)
desc:SetJustifyH("LEFT")
desc:SetText("Settings open in a separate window. Use the button below or type /srf.")
local btn = CreateFrame("Button", nil, panel, "UIPanelButtonTemplate")
btn:SetSize(200, 24)
btn:SetPoint("TOPLEFT", desc, "BOTTOMLEFT", 0, -12)
btn:SetText("Open Settings")
btn:SetScript("OnClick", function() M:OpenSettings() end)
local category = Settings.RegisterCanvasLayoutCategory(panel, M._settingsCategoryName)
Settings.RegisterAddOnCategory(category)
end
local function printSlashHelp()
print("|cFF9CDF95Simple|rRaidFrames: '|cFF9CDF95/srf|r' for in-game configuration.")
end
local function getCurrentPatchKey()
local version, _, _, interfaceVersion = GetBuildInfo()
if type(version) == "string" and version ~= "" then
return version
end
if type(interfaceVersion) == "number" then
return tostring(interfaceVersion)
end
return "unknown"
end
local function maybePrintSlashHelp()
if type(SimpleRaidFramesDB) ~= "table" then
printSlashHelp()
return
end
local patchKey = getCurrentPatchKey()
if SimpleRaidFramesDB.lastSlashHelpPatch ~= patchKey then
SimpleRaidFramesDB.lastSlashHelpPatch = patchKey
printSlashHelp()
end
end
local LATE_HOOK_ADDONS = {
Blizzard_CompactRaidFrames = true,
Blizzard_CUFProfiles = true,
Blizzard_SettingsDefinitions_Frame = true,
Blizzard_UnitFrame = true,
}
SLASH_SIMPLERAIDFRAMES1 = "/srf"
SLASH_SIMPLERAIDFRAMES2 = "/simpleraidframes"
SlashCmdList["SIMPLERAIDFRAMES"] = function(msg)
msg = (msg or ""):lower()
if msg == "" or msg == "settings" or msg == "config" or msg == "options" then
M:OpenSettings()
return
end
printSlashHelp()
end
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("ADDON_LOADED")
eventFrame:RegisterEvent("PLAYER_LOGIN")
eventFrame:RegisterEvent("PLAYER_REGEN_ENABLED")
eventFrame:SetScript("OnEvent", function(_, event, arg1)
if event == "ADDON_LOADED" then
if arg1 == ADDON_NAME then
M.EnsureDefaults()
M:CreateSettingsPanel()
M:EnsureHooks()
elseif LATE_HOOK_ADDONS[arg1] then
M:EnsureHooks()
end
elseif event == "PLAYER_LOGIN" then
M.EnsureDefaults()
M:EnsureHooks()
maybePrintSlashHelp()
elseif event == "PLAYER_REGEN_ENABLED" then
if M._pendingRoleIconRefresh then
M._pendingRoleIconRefresh = false
M:RefreshRaidRoleIcons()
end
if M._pendingPartyVisibilityRefresh then
M._pendingPartyVisibilityRefresh = false
if M.RefreshPartyPlayerVisibility then
M:RefreshPartyPlayerVisibility()
end
end
if M._pendingPartySoloVisibilityRefresh then
M._pendingPartySoloVisibilityRefresh = false
if M.RefreshPartySoloVisibility then
M:RefreshPartySoloVisibility()
end
end
end
end)