Update Clique.lua (#4)

fix event driven profile swapping
linting
This commit is contained in:
Anthony Narkevicius
2025-05-28 12:38:07 -07:00
committed by GitHub
parent 3b440fb15f
commit 960eafdab0
+67 -61
View File
@@ -1,13 +1,15 @@
--[[---------------------------------------------------------------------------------
Clique by Cladhaire <cladhaire@gmail.com>
----------------------------------------------------------------------------------]]
Clique = {Locals = {}}
----------------------------------------------------------------------------------]] Clique = {
Locals = {}
}
assert(DongleStub, string.format("Clique requires DongleStub."))
DongleStub("Dongle-1.2"):New("Clique", Clique)
Clique.version = GetAddOnMetadata("Clique", "Version")
if Clique.version == "wowi:revision" then Clique.version = "SVN" end
if Clique.version == "wowi:revision" then
Clique.version = "SVN"
end
local L = Clique.Locals
@@ -22,16 +24,15 @@ function Clique:Enable()
[L.CLICKSET_DEFAULT] = {},
[L.CLICKSET_HARMFUL] = {},
[L.CLICKSET_HELPFUL] = {},
[L.CLICKSET_OOC] = {},
[L.CLICKSET_OOC] = {}
},
blacklist = {
},
tooltips = false,
blacklist = {},
tooltips = false
},
char = {
switchSpec = false,
downClick = false,
},
downClick = false
}
}
self.db = self:InitializeDB("CliqueDB", self.defaults)
@@ -53,7 +54,9 @@ function Clique:Enable()
end
end
ClickCastFrames = setmetatable({}, {__newindex=newindex})
ClickCastFrames = setmetatable({}, {
__newindex = newindex
})
Clique:OptionsOnLoad()
Clique:EnableFrames()
@@ -67,7 +70,7 @@ function Clique:Enable()
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("LEARNED_SPELL_IN_TAB")
self:RegisterEvent("COMMENTATOR_SKIRMISH_QUEUE_REQUEST")
self:RegisterEvent("ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED")
self:RegisterEvent("ADDON_LOADED")
-- Change to correct profile based on talent spec
@@ -113,7 +116,8 @@ function Clique:Enable()
self.cmd:RegisterSlashHandler("debug - Enables extra messages for debugging purposes", "debug", "ShowAttributes")
self.cmd:InjectDBCommands(self.db, "copy", "delete", "list", "reset", "set")
self.cmd:RegisterSlashHandler("tooltip - Enables binding lists in tooltips.", "tooltip", "ToggleTooltip")
self.cmd:RegisterSlashHandler("showbindings - Shows a window that contains the current bindings", "showbindings", "ShowBindings")
self.cmd:RegisterSlashHandler("showbindings - Shows a window that contains the current bindings", "showbindings",
"ShowBindings")
-- Place the Clique tab
self:LEARNED_SPELL_IN_TAB()
@@ -125,26 +129,10 @@ function Clique:Enable()
end
function Clique:EnableFrames()
local tbl = {
PlayerFrame,
PetFrame,
PartyMemberFrame1,
PartyMemberFrame2,
PartyMemberFrame3,
PartyMemberFrame4,
PartyMemberFrame1PetFrame,
PartyMemberFrame2PetFrame,
PartyMemberFrame3PetFrame,
PartyMemberFrame4PetFrame,
TargetFrame,
TargetFrameToT,
FocusFrame,
FocusFrameToT,
Boss1TargetFrame,
Boss2TargetFrame,
Boss3TargetFrame,
Boss4TargetFrame,
}
local tbl = {PlayerFrame, PetFrame, PartyMemberFrame1, PartyMemberFrame2, PartyMemberFrame3, PartyMemberFrame4,
PartyMemberFrame1PetFrame, PartyMemberFrame2PetFrame, PartyMemberFrame3PetFrame,
PartyMemberFrame4PetFrame, TargetFrame, TargetFrameToT, FocusFrame, FocusFrameToT, Boss1TargetFrame,
Boss2TargetFrame, Boss3TargetFrame, Boss4TargetFrame}
for i, frame in pairs(tbl) do
rawset(self.ccframes, frame, true)
@@ -183,7 +171,7 @@ function Clique:SpellBookButtonPressed(frame, button)
["texture"] = texture,
["type"] = type,
["arg1"] = name,
["arg2"] = rank,
["arg2"] = rank
}
local key = t.modifier .. t.button
@@ -373,7 +361,6 @@ function Clique:DONGLE_PROFILE_RESET(event, db, parent, svname, profileKey)
end
end
function Clique:DONGLE_PROFILE_DELETED(event, db, parent, svname, profileKey)
if db == self.db then
self:PrintF(L.PROFILE_DELETED, profileKey)
@@ -527,7 +514,9 @@ end
function Clique:ShowAttributes()
self:Print("Enabled enhanced debugging.")
PlayerFrame:SetScript("OnAttributeChanged", function(...) self:Print(...) end)
PlayerFrame:SetScript("OnAttributeChanged", function(...)
self:Print(...)
end)
self:UnregisterFrame(PlayerFrame)
self:RegisterFrame(PlayerFrame)
end
@@ -543,17 +532,28 @@ function Clique:UpdateTooltip()
local harm = self.clicksets[L.CLICKSET_HARMFUL]
local help = self.clicksets[L.CLICKSET_HELPFUL]
for k,v in pairs(tt_ooc) do tt_ooc[k] = nil end
for k,v in pairs(tt_help) do tt_help[k] = nil end
for k,v in pairs(tt_harm) do tt_harm[k] = nil end
for k,v in pairs(tt_default) do tt_default[k] = nil end
for k, v in pairs(tt_ooc) do
tt_ooc[k] = nil
end
for k, v in pairs(tt_help) do
tt_help[k] = nil
end
for k, v in pairs(tt_harm) do
tt_harm[k] = nil
end
for k, v in pairs(tt_default) do
tt_default[k] = nil
end
-- Build the ooc lines, which includes both helpful and harmful
for k, v in pairs(ooc) do
local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type)
table.insert(tt_ooc, {mod = mod, action = action})
table.insert(tt_ooc, {
mod = mod,
action = action
})
end
-- Build the default lines
@@ -561,7 +561,10 @@ function Clique:UpdateTooltip()
local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type)
table.insert(tt_default, {mod = mod, action = action})
table.insert(tt_default, {
mod = mod,
action = action
})
end
-- Build the harm lines
@@ -569,7 +572,10 @@ function Clique:UpdateTooltip()
local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type)
table.insert(tt_harm, {mod = mod, action = action})
table.insert(tt_harm, {
mod = mod,
action = action
})
end
-- Build the help lines
@@ -577,7 +583,10 @@ function Clique:UpdateTooltip()
local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type)
table.insert(tt_help, {mod = mod, action = action})
table.insert(tt_help, {
mod = mod,
action = action
})
end
local function sort(a, b)
@@ -591,11 +600,17 @@ function Clique:UpdateTooltip()
end
function Clique:AddTooltipLines()
if not self.profile.tooltips then return end
if not self.profile.tooltips then
return
end
local frame = GetMouseFocus()
if not frame then return end
if not self.ccframes[frame] then return end
if not frame then
return
end
if not self.ccframes[frame] then
return
end
-- Add a buffer line
GameTooltip:AddLine(" ")
@@ -632,8 +647,7 @@ end
function Clique:ToggleTooltip()
self.profile.tooltips = not self.profile.tooltips
self:PrintF("Listing of bindings in tooltips has been %s",
self.profile.tooltips and "Enabled" or "Disabled")
self:PrintF("Listing of bindings in tooltips has been %s", self.profile.tooltips and "Enabled" or "Disabled")
end
function Clique:ShowBindings()
@@ -655,7 +669,8 @@ function Clique:ShowBindings()
CliqueTooltip:SetMovable()
CliqueTooltip:SetPadding(16)
CliqueTooltip:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b);
CliqueTooltip:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b);
CliqueTooltip:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g,
TOOLTIP_DEFAULT_BACKGROUND_COLOR.b);
CliqueTooltip:RegisterForDrag("LeftButton")
CliqueTooltip:SetScript("OnDragStart", function(self)
@@ -710,14 +725,11 @@ function Clique:ShowBindings()
CliqueTooltip:Show()
end
function Clique:COMMENTATOR_SKIRMISH_QUEUE_REQUEST(event, typeName, newGroup)
if typeName ~= "ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED" then return end
function Clique:ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED(event, newGroup)
if self.db.char.switchSpec then
self:Print("Detected a talent spec change, changing profile")
-- self:Print("Detected "..typeName..", changing profile to "..newGroup)
newGroup = newGroup + 1
if self.db.char["spec" .. newGroup .. "Profile"] then
self.db:SetProfile(self.db.char["spec" .. newGroup .. "Profile"])
end
@@ -742,13 +754,7 @@ function Clique:SetClickType(frame)
end
function Clique:EnableArenaFrames()
local arenaFrames = {
ArenaEnemyFrame1,
ArenaEnemyFrame2,
ArenaEnemyFrame3,
ArenaEnemyFrame4,
ArenaEnemyFrame5,
}
local arenaFrames = {ArenaEnemyFrame1, ArenaEnemyFrame2, ArenaEnemyFrame3, ArenaEnemyFrame4, ArenaEnemyFrame5}
for idx, frame in ipairs(arenaFrames) do
rawset(self.ccframes, frame, true)