2021-05-17 16:49:54 +02:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local type = type
|
|
|
|
local tostring = tostring
|
|
|
|
local select = select
|
|
|
|
local pairs = pairs
|
|
|
|
local tinsert = table.insert
|
|
|
|
local tsort = table.sort
|
2021-09-22 17:12:10 +02:00
|
|
|
local str_lower = string.lower
|
2021-09-03 01:42:35 +02:00
|
|
|
local GetTime = GetTime
|
2022-01-11 00:05:57 +01:00
|
|
|
local GetPhysicalScreenSize = GetPhysicalScreenSize
|
2021-09-25 14:03:57 +02:00
|
|
|
local InCombatLockdown = InCombatLockdown
|
2021-05-17 16:49:54 +02:00
|
|
|
local CreateFrame = CreateFrame
|
|
|
|
local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME
|
|
|
|
local IsAddOnLoaded = IsAddOnLoaded
|
|
|
|
local GetBattlefieldStatus = GetBattlefieldStatus
|
|
|
|
local IsActiveBattlefieldArena = IsActiveBattlefieldArena
|
2022-01-11 00:04:08 +01:00
|
|
|
local IsInInstance = IsInInstance
|
|
|
|
local GetNumArenaOpponents = GetNumArenaOpponents
|
2021-05-18 16:34:10 +02:00
|
|
|
local RELEASE_TYPES = { alpha = "Alpha", beta = "Beta", release = "Release"}
|
|
|
|
local PREFIX = "TBC-Classic_v"
|
|
|
|
local VERSION_REGEX = PREFIX .. "(%d+%.%d+)%-(%a)"
|
2021-09-26 14:06:50 +02:00
|
|
|
local LibStub = LibStub
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- CORE
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
2022-01-14 00:39:46 +01:00
|
|
|
local MAJOR, MINOR = "Gladdy", 5
|
2021-05-17 16:49:54 +02:00
|
|
|
local Gladdy = LibStub:NewLibrary(MAJOR, MINOR)
|
|
|
|
local L
|
2022-01-11 00:30:32 +01:00
|
|
|
Gladdy.version_major_num = 2
|
2022-03-25 17:02:37 +01:00
|
|
|
Gladdy.version_minor_num = 0.10
|
2021-05-18 16:34:10 +02:00
|
|
|
Gladdy.version_num = Gladdy.version_major_num + Gladdy.version_minor_num
|
2021-09-15 00:42:49 +02:00
|
|
|
Gladdy.version_releaseType = RELEASE_TYPES.release
|
2021-05-18 16:34:10 +02:00
|
|
|
Gladdy.version = PREFIX .. Gladdy.version_num .. "-" .. Gladdy.version_releaseType
|
|
|
|
Gladdy.VERSION_REGEX = VERSION_REGEX
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2022-01-11 00:04:54 +01:00
|
|
|
Gladdy.debug = false
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
LibStub("AceTimer-3.0"):Embed(Gladdy)
|
|
|
|
LibStub("AceComm-3.0"):Embed(Gladdy)
|
|
|
|
Gladdy.modules = {}
|
|
|
|
setmetatable(Gladdy, {
|
|
|
|
__tostring = function()
|
|
|
|
return MAJOR
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
function Gladdy:Print(...)
|
|
|
|
local text = "|cff0384fcGladdy|r:"
|
|
|
|
local val
|
|
|
|
for i = 1, select("#", ...) do
|
|
|
|
val = select(i, ...)
|
|
|
|
if (type(val) == 'boolean') then val = val and "true" or false end
|
|
|
|
text = text .. " " .. tostring(val)
|
|
|
|
end
|
|
|
|
DEFAULT_CHAT_FRAME:AddMessage(text)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:Warn(...)
|
2022-01-11 00:04:54 +01:00
|
|
|
local text = "|cfff29f05Gladdy|r:"
|
|
|
|
local val
|
|
|
|
for i = 1, select("#", ...) do
|
|
|
|
val = select(i, ...)
|
|
|
|
if (type(val) == 'boolean') then val = val and "true" or false end
|
|
|
|
text = text .. " " .. tostring(val)
|
|
|
|
end
|
|
|
|
DEFAULT_CHAT_FRAME:AddMessage(text)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:Error(...)
|
2021-05-17 16:49:54 +02:00
|
|
|
local text = "|cfffc0303Gladdy|r:"
|
|
|
|
local val
|
|
|
|
for i = 1, select("#", ...) do
|
|
|
|
val = select(i, ...)
|
|
|
|
if (type(val) == 'boolean') then val = val and "true" or false end
|
|
|
|
text = text .. " " .. tostring(val)
|
|
|
|
end
|
|
|
|
DEFAULT_CHAT_FRAME:AddMessage(text)
|
|
|
|
end
|
|
|
|
|
2022-01-11 00:04:54 +01:00
|
|
|
function Gladdy:Debug(lvl, ...)
|
|
|
|
if Gladdy.debug then
|
|
|
|
if lvl == "INFO" then
|
|
|
|
Gladdy:Print(...)
|
|
|
|
elseif lvl == "WARN" then
|
|
|
|
Gladdy:Warn(...)
|
|
|
|
elseif lvl == "ERROR" then
|
|
|
|
Gladdy:Error(...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
Gladdy.events = CreateFrame("Frame")
|
|
|
|
Gladdy.events.registered = {}
|
|
|
|
Gladdy.events:RegisterEvent("PLAYER_LOGIN")
|
2022-01-11 00:29:17 +01:00
|
|
|
Gladdy.events:RegisterEvent("PLAYER_LOGOUT")
|
2021-09-22 17:12:10 +02:00
|
|
|
Gladdy.events:RegisterEvent("CVAR_UPDATE")
|
|
|
|
hooksecurefunc("VideoOptionsFrameOkay_OnClick", function(self, button, down, apply)
|
|
|
|
if (self:GetName() == "VideoOptionsFrameApply") then
|
|
|
|
Gladdy:PixelPerfectScale(true)
|
|
|
|
end
|
|
|
|
end)
|
2021-05-17 16:49:54 +02:00
|
|
|
Gladdy.events:SetScript("OnEvent", function(self, event, ...)
|
|
|
|
if (event == "PLAYER_LOGIN") then
|
|
|
|
Gladdy:OnInitialize()
|
|
|
|
Gladdy:OnEnable()
|
2021-09-22 17:12:10 +02:00
|
|
|
elseif (event == "CVAR_UPDATE") then
|
|
|
|
if (str_lower(select(1, ...)) == "uiscale") then
|
|
|
|
Gladdy:PixelPerfectScale(true)
|
|
|
|
end
|
2022-01-11 00:29:17 +01:00
|
|
|
elseif (event == "PLAYER_LOGOUT") then
|
|
|
|
Gladdy:DeleteUnknownOptions(Gladdy.db, Gladdy.defaults.profile)
|
2021-05-17 16:49:54 +02:00
|
|
|
else
|
|
|
|
local func = self.registered[event]
|
|
|
|
|
|
|
|
if (type(Gladdy[func]) == "function") then
|
|
|
|
Gladdy[func](Gladdy, event, ...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
function Gladdy:RegisterEvent(event, func)
|
|
|
|
self.events.registered[event] = func or event
|
|
|
|
self.events:RegisterEvent(event)
|
|
|
|
end
|
|
|
|
function Gladdy:UnregisterEvent(event)
|
|
|
|
self.events.registered[event] = nil
|
|
|
|
self.events:UnregisterEvent(event)
|
|
|
|
end
|
|
|
|
function Gladdy:UnregisterAllEvents()
|
|
|
|
self.events.registered = {}
|
|
|
|
self.events:UnregisterAllEvents()
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- MODULE FUNCTIONS
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
local function pairsByPrio(t)
|
|
|
|
local a = {}
|
|
|
|
for k, v in pairs(t) do
|
|
|
|
tinsert(a, { k, v.priority })
|
|
|
|
end
|
|
|
|
tsort(a, function(x, y)
|
|
|
|
return x[2] > y[2]
|
|
|
|
end)
|
|
|
|
|
|
|
|
local i = 0
|
|
|
|
return function()
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
if (a[i] ~= nil) then
|
|
|
|
return a[i][1], t[a[i][1]]
|
|
|
|
else
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function Gladdy:IterModules()
|
|
|
|
return pairsByPrio(self.modules)
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:Call(module, func, ...)
|
|
|
|
if (type(module) == "string") then
|
|
|
|
module = self.modules[module]
|
|
|
|
end
|
|
|
|
|
|
|
|
if (type(module[func]) == "function") then
|
|
|
|
module[func](module, ...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
function Gladdy:SendMessage(message, ...)
|
2021-07-29 15:53:34 +02:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, module.messages[message], ...)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:NewModule(name, priority, defaults)
|
|
|
|
local module = CreateFrame("Frame")
|
|
|
|
module.name = name
|
|
|
|
module.priority = priority or 0
|
|
|
|
module.defaults = defaults or {}
|
|
|
|
module.messages = {}
|
|
|
|
|
2022-01-27 14:00:59 +01:00
|
|
|
module.RegisterMessages = function(self, ...)
|
|
|
|
for _,message in pairs({...}) do
|
|
|
|
self.messages[message] = message
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
module.RegisterMessage = function(self, message, func)
|
|
|
|
self.messages[message] = func or message
|
|
|
|
end
|
|
|
|
|
2022-01-13 23:11:06 +01:00
|
|
|
module.UnregisterMessage = function(self, message)
|
|
|
|
self.messages[message] = nil
|
|
|
|
end
|
|
|
|
|
2022-01-27 14:00:59 +01:00
|
|
|
module.UnregisterMessages = function(self, ...)
|
|
|
|
for _,message in pairs({...}) do
|
|
|
|
self.messages[message] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-13 23:11:06 +01:00
|
|
|
module.UnregisterAllMessages = function(self)
|
|
|
|
for msg,_ in pairs(self.messages) do
|
|
|
|
self.messages[msg] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
module.GetOptions = function()
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
|
|
|
for k, v in pairs(module.defaults) do
|
|
|
|
self.defaults.profile[k] = v
|
|
|
|
end
|
|
|
|
|
|
|
|
self.modules[name] = module
|
|
|
|
|
|
|
|
return module
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- INIT
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
2021-05-18 16:34:45 +02:00
|
|
|
function Gladdy:DeleteUnknownOptions(tbl, refTbl, str)
|
|
|
|
if str == nil then
|
|
|
|
str = "Gladdy.db"
|
|
|
|
end
|
|
|
|
for k,v in pairs(tbl) do
|
|
|
|
if refTbl[k] == nil then
|
2022-01-12 21:04:25 +01:00
|
|
|
Gladdy:Debug("INFO", "SavedVariable deleted:", str .. "." .. k, "not found!")
|
2021-05-18 16:34:45 +02:00
|
|
|
tbl[k] = nil
|
|
|
|
else
|
|
|
|
if type(v) ~= type(refTbl[k]) then
|
2022-01-12 21:04:25 +01:00
|
|
|
Gladdy:Debug("INFO", "SavedVariable deleted:", str .. "." .. k, "type error!", "Expected", type(refTbl[k]), "but found", type(v))
|
2021-05-18 16:34:45 +02:00
|
|
|
tbl[k] = nil
|
|
|
|
elseif type(v) == "table" then
|
|
|
|
Gladdy:DeleteUnknownOptions(v, refTbl[k], str .. "." .. k)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-09-22 17:12:10 +02:00
|
|
|
function Gladdy:PixelPerfectScale(update)
|
|
|
|
local physicalWidth, physicalHeight = GetPhysicalScreenSize()
|
2022-01-11 00:05:57 +01:00
|
|
|
local perfectUIScale = 768.0/physicalHeight--768/select(2, strsplit("x",({ GetScreenResolutions()})[GetCurrentResolution()]))
|
2021-09-22 17:12:10 +02:00
|
|
|
if self.db and self.db.pixelPerfect and self.frame then
|
|
|
|
self.frame:SetIgnoreParentScale(true)
|
|
|
|
self.frame:SetScale(perfectUIScale)
|
2022-01-11 00:05:57 +01:00
|
|
|
--local adaptiveScale = (GetCVar("useUiScale") == "1" and 1.0 + perfectUIScale - GetCVar("UIScale") or perfectUIScale)
|
|
|
|
--self.frame:SetScale(adaptiveScale)
|
2021-09-22 17:12:10 +02:00
|
|
|
if update then
|
|
|
|
self:UpdateFrame()
|
|
|
|
end
|
|
|
|
elseif self.frame then
|
2022-01-11 00:05:57 +01:00
|
|
|
self.frame:SetScale(self.db.frameScale)
|
2021-09-22 17:12:10 +02:00
|
|
|
self.frame:SetIgnoreParentScale(false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
function Gladdy:OnInitialize()
|
|
|
|
self.dbi = LibStub("AceDB-3.0"):New("GladdyXZ", self.defaults)
|
|
|
|
self.dbi.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
|
|
|
|
self.dbi.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
|
2022-01-11 00:29:17 +01:00
|
|
|
self.dbi.RegisterCallback(self, "OnProfileReset", "OnProfileReset")
|
2021-05-17 16:49:54 +02:00
|
|
|
self.db = self.dbi.profile
|
|
|
|
|
|
|
|
self.LSM = LibStub("LibSharedMedia-3.0")
|
|
|
|
self.LSM:Register("statusbar", "Gloss", "Interface\\AddOns\\Gladdy\\Images\\Gloss")
|
|
|
|
self.LSM:Register("statusbar", "Smooth", "Interface\\AddOns\\Gladdy\\Images\\Smooth")
|
|
|
|
self.LSM:Register("statusbar", "Minimalist", "Interface\\AddOns\\Gladdy\\Images\\Minimalist")
|
|
|
|
self.LSM:Register("statusbar", "LiteStep", "Interface\\AddOns\\Gladdy\\Images\\LiteStep.tga")
|
2022-01-14 05:51:56 +01:00
|
|
|
self.LSM:Register("statusbar", "Flat", "Interface\\AddOns\\Gladdy\\Images\\UI-StatusBar")
|
2021-05-17 16:49:54 +02:00
|
|
|
self.LSM:Register("border", "Gladdy Tooltip round", "Interface\\AddOns\\Gladdy\\Images\\UI-Tooltip-Border_round_selfmade")
|
|
|
|
self.LSM:Register("border", "Gladdy Tooltip squared", "Interface\\AddOns\\Gladdy\\Images\\UI-Tooltip-Border_square_selfmade")
|
|
|
|
self.LSM:Register("font", "DorisPP", "Interface\\AddOns\\Gladdy\\Images\\DorisPP.TTF")
|
2021-06-15 09:06:32 +02:00
|
|
|
self.LSM:Register("border", "Square Full White", "Interface\\AddOns\\Gladdy\\Images\\Square_FullWhite.tga")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
L = self.L
|
|
|
|
|
|
|
|
self.testData = {
|
2022-03-03 23:40:47 +01:00
|
|
|
["arena1"] = { name = "Swift", raceLoc = L["NightElf"], classLoc = L["Hunter"], class = "HUNTER", health = 67, healthMax = 100, power = 76, powerMax = 100, powerType = 1, testSpec = L["Marksmanship"], race = "NightElf" },
|
|
|
|
["arena2"] = { name = "Vilden", raceLoc = L["Undead"], classLoc = L["Mage"], class = "MAGE", health = 99, healthMax = 100, power = 7833, powerMax = 10460, powerType = 0, testSpec = L["Frost"], race = "Scourge" },
|
|
|
|
["arena3"] = { name = "Krymu", raceLoc = L["Human"], classLoc = L["Rogue"], class = "ROGUE", health = 13, healthMax = 100, power = 45, powerMax = 110, powerType = 3, testSpec = L["Subtlety"], race = "Human" },
|
|
|
|
["arena4"] = { name = "Talmon", raceLoc = L["Human"], classLoc = L["Warlock"], class = "WARLOCK", health = 68, healthMax = 100, power = 9855, powerMax = 9855, powerType = 0, testSpec = L["Demonology"], race = "Human" },
|
|
|
|
["arena5"] = { name = "Hydra", raceLoc = L["Undead"], classLoc = L["Priest"], class = "PRIEST", health = 100, healthMax = 100, power = 2515, powerMax = 10240, powerType = 0, testSpec = L["Discipline"], race = "Human" },
|
2021-05-17 16:49:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
self.cooldownSpellIds = {}
|
|
|
|
self.spellTextures = {}
|
|
|
|
self.specBuffs = self:GetSpecBuffs()
|
|
|
|
self.specSpells = self:GetSpecSpells()
|
|
|
|
self.buttons = {}
|
|
|
|
self.guids = {}
|
|
|
|
self.curBracket = nil
|
|
|
|
self.curUnit = 1
|
|
|
|
|
|
|
|
self:SetupOptions()
|
|
|
|
|
2021-07-29 15:53:34 +02:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, "Initialize") -- B.E > A.E :D
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
2021-06-15 09:06:32 +02:00
|
|
|
if Gladdy.db.hideBlizzard == "always" then
|
2021-07-29 14:06:15 +02:00
|
|
|
Gladdy:BlizzArenaSetAlpha(0)
|
2021-06-15 09:06:32 +02:00
|
|
|
end
|
2022-01-11 00:29:17 +01:00
|
|
|
if not self.db.newLayout then
|
|
|
|
self:ToggleFrame(3)
|
|
|
|
self:HideFrame()
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
2022-01-11 00:29:17 +01:00
|
|
|
function Gladdy:OnProfileReset()
|
2021-05-17 16:49:54 +02:00
|
|
|
self.db = self.dbi.profile
|
2022-01-11 00:29:17 +01:00
|
|
|
Gladdy:Debug("INFO", "OnProfileReset")
|
|
|
|
self:HideFrame()
|
|
|
|
self:ToggleFrame(3)
|
|
|
|
Gladdy.options.args.lock.name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"]
|
|
|
|
Gladdy.options.args.showMover.name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"]
|
|
|
|
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2022-01-11 00:29:17 +01:00
|
|
|
function Gladdy:OnProfileChanged()
|
|
|
|
self.db = self.dbi.profile
|
2021-05-17 16:49:54 +02:00
|
|
|
self:HideFrame()
|
|
|
|
self:ToggleFrame(3)
|
2022-01-11 00:29:17 +01:00
|
|
|
Gladdy.options.args.lock.name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"]
|
|
|
|
Gladdy.options.args.showMover.name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"]
|
|
|
|
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:OnEnable()
|
|
|
|
self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
|
|
|
|
self:RegisterEvent("PLAYER_ENTERING_WORLD")
|
2021-07-27 16:32:37 +02:00
|
|
|
self:RegisterEvent("PLAYER_REGEN_ENABLED")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-07-26 12:58:40 +02:00
|
|
|
if (IsAddOnLoaded("Clique")) then
|
2021-07-27 16:32:37 +02:00
|
|
|
for i = 1, 5 do
|
|
|
|
self:CreateButton(i)
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
ClickCastFrames = ClickCastFrames or {}
|
|
|
|
ClickCastFrames[self.buttons.arena1.secure] = true
|
|
|
|
ClickCastFrames[self.buttons.arena2.secure] = true
|
|
|
|
ClickCastFrames[self.buttons.arena3.secure] = true
|
|
|
|
ClickCastFrames[self.buttons.arena4.secure] = true
|
|
|
|
ClickCastFrames[self.buttons.arena5.secure] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
if (not self.db.locked and self.db.x == 0 and self.db.y == 0) then
|
|
|
|
self:Print(L["Welcome to Gladdy!"])
|
|
|
|
self:Print(L["First run has been detected, displaying test frame."])
|
|
|
|
self:Print(L["Valid slash commands are:"])
|
|
|
|
self:Print(L["/gladdy ui"])
|
|
|
|
self:Print(L["/gladdy test2-5"])
|
|
|
|
self:Print(L["/gladdy hide"])
|
|
|
|
self:Print(L["/gladdy reset"])
|
|
|
|
self:Print(L["If this is not your first run please lock or move the frame to prevent this from happening."])
|
|
|
|
|
|
|
|
self:HideFrame()
|
|
|
|
self:ToggleFrame(3)
|
2021-06-20 02:46:52 +02:00
|
|
|
self.showConfig = true
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:GetIconStyles()
|
|
|
|
return
|
|
|
|
{
|
|
|
|
["Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp"] = L["Gladdy Tooltip round"],
|
|
|
|
["Interface\\AddOns\\Gladdy\\Images\\Border_squared_blp"] = L["Gladdy Tooltip squared"],
|
|
|
|
["Interface\\AddOns\\Gladdy\\Images\\Border_Gloss"] = L["Gloss (black border)"],
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- TEST
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:Test()
|
2021-06-16 14:10:49 +02:00
|
|
|
self.frame.testing = true
|
2021-07-27 16:32:37 +02:00
|
|
|
if self.curBracket then
|
|
|
|
for i = 1, self.curBracket do
|
|
|
|
local unit = "arena" .. i
|
|
|
|
if (not self.buttons[unit]) then
|
|
|
|
self:CreateButton(i)
|
|
|
|
end
|
|
|
|
local button = self.buttons[unit]
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-07-27 16:32:37 +02:00
|
|
|
for k, v in pairs(self.testData[unit]) do
|
|
|
|
button[k] = v
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-07-29 15:53:34 +02:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, "Test", unit)
|
2021-07-27 16:32:37 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-07-27 16:32:37 +02:00
|
|
|
button:SetAlpha(1)
|
|
|
|
end
|
2022-03-03 23:40:47 +01:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, "TestOnce")
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- EVENT HANDLING
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:PLAYER_ENTERING_WORLD()
|
2021-06-20 02:46:52 +02:00
|
|
|
if self.showConfig then
|
|
|
|
LibStub("AceConfigDialog-3.0"):Open("Gladdy", nil, LibStub("AceConfigDialog-3.0"):SelectGroup("Gladdy", "XiconProfiles"))
|
|
|
|
self.showConfig = nil
|
|
|
|
end
|
2021-09-25 14:03:57 +02:00
|
|
|
if (self.frame and self.frame:IsVisible()) then
|
2021-05-17 16:49:54 +02:00
|
|
|
self:Reset()
|
|
|
|
self:HideFrame()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:UPDATE_BATTLEFIELD_STATUS(_, index)
|
|
|
|
local status, mapName, instanceID, levelRangeMin, levelRangeMax, teamSize, isRankedArena, suspendedQueue, bool, queueType = GetBattlefieldStatus(index)
|
2022-01-11 00:04:08 +01:00
|
|
|
local instanceType = select(2, IsInInstance())
|
|
|
|
Gladdy:Debug("INFO", "UPDATE_BATTLEFIELD_STATUS", instanceType, status, teamSize)
|
|
|
|
if ((instanceType == "arena" or GetNumArenaOpponents() > 0) and status == "active" and teamSize > 0) then
|
2021-05-17 16:49:54 +02:00
|
|
|
self.curBracket = teamSize
|
|
|
|
self:JoinedArena()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-27 16:32:37 +02:00
|
|
|
function Gladdy:PLAYER_REGEN_ENABLED()
|
|
|
|
if self.showFrame then
|
|
|
|
self:UpdateFrame()
|
|
|
|
if self.startTest then
|
|
|
|
self:Test()
|
|
|
|
self.startTest = nil
|
|
|
|
end
|
|
|
|
self.frame:Show()
|
2022-01-12 16:11:10 +01:00
|
|
|
self:SendMessage("JOINED_ARENA")
|
2021-07-27 16:32:37 +02:00
|
|
|
self.showFrame = nil
|
|
|
|
end
|
|
|
|
if self.hideFrame then
|
|
|
|
self:Reset()
|
|
|
|
self.frame:Hide()
|
|
|
|
self.hideFrame = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- RESET FUNCTIONS (ARENA LEAVE)
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:Reset()
|
|
|
|
if type(self.guids) == "table" then
|
2021-07-29 15:53:34 +02:00
|
|
|
for k,_ in pairs(self.guids) do
|
2021-05-17 16:49:54 +02:00
|
|
|
self.guids[k] = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self.guids = {}
|
|
|
|
self.curBracket = nil
|
|
|
|
self.curUnit = 1
|
|
|
|
|
2021-07-29 15:53:34 +02:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, "Reset")
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
for unit in pairs(self.buttons) do
|
|
|
|
self:ResetUnit(unit)
|
|
|
|
end
|
2021-06-15 09:06:32 +02:00
|
|
|
if Gladdy.db.hideBlizzard == "never" or Gladdy.db.hideBlizzard == "arena" then
|
2021-07-29 14:06:15 +02:00
|
|
|
Gladdy:BlizzArenaSetAlpha(1)
|
2021-06-15 09:06:32 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:ResetUnit(unit)
|
|
|
|
local button = self.buttons[unit]
|
|
|
|
if (not button) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
button:SetAlpha(0)
|
|
|
|
self:ResetButton(unit)
|
|
|
|
|
2021-07-29 15:53:34 +02:00
|
|
|
for _, module in self:IterModules() do
|
|
|
|
self:Call(module, "ResetUnit", unit)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:ResetButton(unit)
|
|
|
|
local button = self.buttons[unit]
|
|
|
|
if (not button) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
for k1, v1 in pairs(self.BUTTON_DEFAULTS) do
|
|
|
|
if (type(v1) == "string") then
|
|
|
|
button[k1] = nil
|
|
|
|
elseif (type(v1) == "number") then
|
|
|
|
button[k1] = 0
|
2021-06-16 14:10:49 +02:00
|
|
|
elseif (type(v1) == "table") then
|
2021-05-17 16:49:54 +02:00
|
|
|
button[k1] = {}
|
|
|
|
elseif (type(v1) == "boolean") then
|
|
|
|
button[k1] = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- ARENA JOINED
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:JoinedArena()
|
|
|
|
if not self.curBracket then
|
|
|
|
self.curBracket = 2
|
|
|
|
end
|
|
|
|
|
2021-07-27 16:32:37 +02:00
|
|
|
for i = 1, self.curBracket do
|
|
|
|
if (not self.buttons["arena" .. i]) then
|
|
|
|
self:CreateButton(i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if InCombatLockdown() then
|
|
|
|
Gladdy:Print("Gladdy frames show as soon as you leave combat")
|
|
|
|
self.showFrame = true
|
|
|
|
else
|
|
|
|
self:UpdateFrame()
|
|
|
|
self.frame:Show()
|
2022-01-12 16:11:10 +01:00
|
|
|
self:SendMessage("JOINED_ARENA")
|
2021-07-27 16:32:37 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
for i=1, self.curBracket do
|
|
|
|
self.buttons["arena" .. i]:SetAlpha(1)
|
|
|
|
end
|
2021-06-15 09:06:32 +02:00
|
|
|
if Gladdy.db.hideBlizzard == "arena" or Gladdy.db.hideBlizzard == "always" then
|
2021-07-29 14:06:15 +02:00
|
|
|
Gladdy:BlizzArenaSetAlpha(0)
|
2021-06-15 09:06:32 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
2021-07-29 14:06:15 +02:00
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- BLIZZARD FRAMES
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:BlizzArenaSetAlpha(alpha)
|
|
|
|
if IsAddOnLoaded("Blizzard_ArenaUI") then
|
2021-09-15 19:33:33 +02:00
|
|
|
if (ArenaEnemyFrames) then
|
|
|
|
ArenaEnemyFrames:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame1 then
|
|
|
|
ArenaEnemyFrame1:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame1PetFrame then
|
|
|
|
ArenaEnemyFrame1PetFrame:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame2 then
|
|
|
|
ArenaEnemyFrame2:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame2PetFrame then
|
|
|
|
ArenaEnemyFrame2PetFrame:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame3 then
|
|
|
|
ArenaEnemyFrame3:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame3PetFrame then
|
|
|
|
ArenaEnemyFrame3PetFrame:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame4 then
|
|
|
|
ArenaEnemyFrame4:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame4PetFrame then
|
|
|
|
ArenaEnemyFrame4PetFrame:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame5 then
|
|
|
|
ArenaEnemyFrame5:SetAlpha(alpha)
|
|
|
|
end
|
|
|
|
if ArenaEnemyFrame5PetFrame then
|
|
|
|
ArenaEnemyFrame5PetFrame:SetAlpha(alpha)
|
|
|
|
end
|
2021-07-29 14:06:15 +02:00
|
|
|
end
|
2021-09-03 01:42:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- FONT/STATUSBAR/BORDER
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
local defaults = {["statusbar"] = "Smooth", ["border"] = "Gladdy Tooltip round", ["font"] = "DorisPP"}
|
|
|
|
|
|
|
|
local lastWarning = {}
|
2021-09-14 23:55:17 +02:00
|
|
|
function Gladdy:SMFetch(lsmType, key)
|
|
|
|
local smMediaType = self.LSM:Fetch(lsmType, Gladdy.db[key])
|
|
|
|
if (smMediaType == nil and Gladdy.db[key] ~= "None") then
|
|
|
|
if not lastWarning[key] or GetTime() - lastWarning[key] > 120 then
|
|
|
|
lastWarning[key] = GetTime()
|
|
|
|
Gladdy:Warn("Could not find", "\"" .. lsmType .. "\" \"", Gladdy.db[key], " \" for", "\"" .. key .. "\"", "- setting it to", "\"" .. defaults[lsmType] .. "\"")
|
2021-09-03 01:42:35 +02:00
|
|
|
end
|
|
|
|
return self.LSM:Fetch(lsmType, defaults[lsmType])
|
|
|
|
end
|
|
|
|
return smMediaType
|
2021-07-29 14:06:15 +02:00
|
|
|
end
|