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
+144 -138
View File
@@ -1,13 +1,15 @@
--[[--------------------------------------------------------------------------------- --[[---------------------------------------------------------------------------------
Clique by Cladhaire <cladhaire@gmail.com> Clique by Cladhaire <cladhaire@gmail.com>
----------------------------------------------------------------------------------]] ----------------------------------------------------------------------------------]] Clique = {
Locals = {}
Clique = {Locals = {}} }
assert(DongleStub, string.format("Clique requires DongleStub.")) assert(DongleStub, string.format("Clique requires DongleStub."))
DongleStub("Dongle-1.2"):New("Clique", Clique) DongleStub("Dongle-1.2"):New("Clique", Clique)
Clique.version = GetAddOnMetadata("Clique", "Version") 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 local L = Clique.Locals
@@ -22,16 +24,15 @@ function Clique:Enable()
[L.CLICKSET_DEFAULT] = {}, [L.CLICKSET_DEFAULT] = {},
[L.CLICKSET_HARMFUL] = {}, [L.CLICKSET_HARMFUL] = {},
[L.CLICKSET_HELPFUL] = {}, [L.CLICKSET_HELPFUL] = {},
[L.CLICKSET_OOC] = {}, [L.CLICKSET_OOC] = {}
}, },
blacklist = { blacklist = {},
}, tooltips = false
tooltips = false,
}, },
char = { char = {
switchSpec = false, switchSpec = false,
downClick = false, downClick = false
}, }
} }
self.db = self:InitializeDB("CliqueDB", self.defaults) self.db = self:InitializeDB("CliqueDB", self.defaults)
@@ -43,7 +44,7 @@ function Clique:Enable()
ClickCastFrames = ClickCastFrames or {} ClickCastFrames = ClickCastFrames or {}
self.ccframes = ClickCastFrames self.ccframes = ClickCastFrames
local newindex = function(t,k,v) local newindex = function(t, k, v)
if v == nil then if v == nil then
Clique:UnregisterFrame(k) Clique:UnregisterFrame(k)
rawset(self.ccframes, k, nil) rawset(self.ccframes, k, nil)
@@ -53,7 +54,9 @@ function Clique:Enable()
end end
end end
ClickCastFrames = setmetatable({}, {__newindex=newindex}) ClickCastFrames = setmetatable({}, {
__newindex = newindex
})
Clique:OptionsOnLoad() Clique:OptionsOnLoad()
Clique:EnableFrames() Clique:EnableFrames()
@@ -67,15 +70,15 @@ function Clique:Enable()
self:RegisterEvent("PLAYER_REGEN_DISABLED") self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("LEARNED_SPELL_IN_TAB") self:RegisterEvent("LEARNED_SPELL_IN_TAB")
self:RegisterEvent("COMMENTATOR_SKIRMISH_QUEUE_REQUEST") self:RegisterEvent("ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED")
self:RegisterEvent("ADDON_LOADED") self:RegisterEvent("ADDON_LOADED")
-- Change to correct profile based on talent spec -- Change to correct profile based on talent spec
if self.db.char.switchSpec then if self.db.char.switchSpec then
self.silentProfile = true self.silentProfile = true
self.talentGroup = CA_GetActiveSpecId() + 1 self.talentGroup = CA_GetActiveSpecId() + 1
if self.db.char["spec"..self.talentGroup.."Profile"] then if self.db.char["spec" .. self.talentGroup .. "Profile"] then
self.db:SetProfile(self.db.char["spec"..self.talentGroup.."Profile"]) self.db:SetProfile(self.db.char["spec" .. self.talentGroup .. "Profile"])
end end
self.silentProfile = false self.silentProfile = false
end end
@@ -90,7 +93,7 @@ function Clique:Enable()
-- Securehook CreateFrame to catch any new raid frames -- Securehook CreateFrame to catch any new raid frames
local raidFunc = function(type, name, parent, template) local raidFunc = function(type, name, parent, template)
if template == "RaidPulloutButtonTemplate" then if template == "RaidPulloutButtonTemplate" then
ClickCastFrames[getglobal(name.."ClearButton")] = true ClickCastFrames[getglobal(name .. "ClearButton")] = true
end end
end end
@@ -113,7 +116,8 @@ function Clique:Enable()
self.cmd:RegisterSlashHandler("debug - Enables extra messages for debugging purposes", "debug", "ShowAttributes") self.cmd:RegisterSlashHandler("debug - Enables extra messages for debugging purposes", "debug", "ShowAttributes")
self.cmd:InjectDBCommands(self.db, "copy", "delete", "list", "reset", "set") self.cmd:InjectDBCommands(self.db, "copy", "delete", "list", "reset", "set")
self.cmd:RegisterSlashHandler("tooltip - Enables binding lists in tooltips.", "tooltip", "ToggleTooltip") 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 -- Place the Clique tab
self:LEARNED_SPELL_IN_TAB() self:LEARNED_SPELL_IN_TAB()
@@ -125,36 +129,20 @@ function Clique:Enable()
end end
function Clique:EnableFrames() function Clique:EnableFrames()
local tbl = { local tbl = {PlayerFrame, PetFrame, PartyMemberFrame1, PartyMemberFrame2, PartyMemberFrame3, PartyMemberFrame4,
PlayerFrame, PartyMemberFrame1PetFrame, PartyMemberFrame2PetFrame, PartyMemberFrame3PetFrame,
PetFrame, PartyMemberFrame4PetFrame, TargetFrame, TargetFrameToT, FocusFrame, FocusFrameToT, Boss1TargetFrame,
PartyMemberFrame1, Boss2TargetFrame, Boss3TargetFrame, Boss4TargetFrame}
PartyMemberFrame2,
PartyMemberFrame3,
PartyMemberFrame4,
PartyMemberFrame1PetFrame,
PartyMemberFrame2PetFrame,
PartyMemberFrame3PetFrame,
PartyMemberFrame4PetFrame,
TargetFrame,
TargetFrameToT,
FocusFrame,
FocusFrameToT,
Boss1TargetFrame,
Boss2TargetFrame,
Boss3TargetFrame,
Boss4TargetFrame,
}
for i,frame in pairs(tbl) do for i, frame in pairs(tbl) do
rawset(self.ccframes, frame, true) rawset(self.ccframes, frame, true)
end end
end end
function Clique:SpellBookButtonPressed(frame, button) function Clique:SpellBookButtonPressed(frame, button)
local texture = getglobal(frame:GetParent():GetName().."IconTexture"):GetTexture() local texture = getglobal(frame:GetParent():GetName() .. "IconTexture"):GetTexture()
local name = getglobal(frame:GetParent():GetName().."SpellName"):GetText() local name = getglobal(frame:GetParent():GetName() .. "SpellName"):GetText()
local rank = getglobal(frame:GetParent():GetName().."SubSpellName"):GetText() local rank = getglobal(frame:GetParent():GetName() .. "SubSpellName"):GetText()
if rank == L.RACIAL_PASSIVE or rank == L.PASSIVE then if rank == L.RACIAL_PASSIVE or rank == L.PASSIVE then
StaticPopup_Show("CLIQUE_PASSIVE_SKILL") StaticPopup_Show("CLIQUE_PASSIVE_SKILL")
@@ -183,7 +171,7 @@ function Clique:SpellBookButtonPressed(frame, button)
["texture"] = texture, ["texture"] = texture,
["type"] = type, ["type"] = type,
["arg1"] = name, ["arg1"] = name,
["arg2"] = rank, ["arg2"] = rank
} }
local key = t.modifier .. t.button local key = t.modifier .. t.button
@@ -291,11 +279,11 @@ function Clique:ApplyClickSet(name, frame)
local set = self.clicksets[name] or name local set = self.clicksets[name] or name
if frame then if frame then
for modifier,entry in pairs(set) do for modifier, entry in pairs(set) do
self:SetAttribute(entry, frame) self:SetAttribute(entry, frame)
end end
else else
for modifier,entry in pairs(set) do for modifier, entry in pairs(set) do
self:SetAction(entry) self:SetAction(entry)
end end
end end
@@ -305,11 +293,11 @@ function Clique:RemoveClickSet(name, frame)
local set = self.clicksets[name] or name local set = self.clicksets[name] or name
if frame then if frame then
for modifier,entry in pairs(set) do for modifier, entry in pairs(set) do
self:DeleteAttribute(entry, frame) self:DeleteAttribute(entry, frame)
end end
else else
for modifier,entry in pairs(set) do for modifier, entry in pairs(set) do
self:DeleteAction(entry) self:DeleteAction(entry)
end end
end end
@@ -317,8 +305,8 @@ end
function Clique:UnregisterFrame(frame) function Clique:UnregisterFrame(frame)
assert(not InCombatLockdown(), "An addon attempted to unregister a frame from Clique while in combat.") assert(not InCombatLockdown(), "An addon attempted to unregister a frame from Clique while in combat.")
for name,set in pairs(self.clicksets) do for name, set in pairs(self.clicksets) do
for modifier,entry in pairs(set) do for modifier, entry in pairs(set) do
self:DeleteAttribute(entry, frame) self:DeleteAttribute(entry, frame)
end end
end end
@@ -330,7 +318,7 @@ function Clique:DONGLE_PROFILE_CHANGED(event, db, parent, svname, profileKey)
self:PrintF(L.PROFILE_CHANGED, profileKey) self:PrintF(L.PROFILE_CHANGED, profileKey)
end end
for name,set in pairs(self.clicksets) do for name, set in pairs(self.clicksets) do
self:RemoveClickSet(set) self:RemoveClickSet(set)
end end
self:RemoveClickSet(self.ooc) self:RemoveClickSet(self.ooc)
@@ -352,7 +340,7 @@ end
function Clique:DONGLE_PROFILE_RESET(event, db, parent, svname, profileKey) function Clique:DONGLE_PROFILE_RESET(event, db, parent, svname, profileKey)
if db == self.db then if db == self.db then
for name,set in pairs(self.clicksets) do for name, set in pairs(self.clicksets) do
self:RemoveClickSet(set) self:RemoveClickSet(set)
end end
self:RemoveClickSet(self.ooc) self:RemoveClickSet(self.ooc)
@@ -373,7 +361,6 @@ function Clique:DONGLE_PROFILE_RESET(event, db, parent, svname, profileKey)
end end
end end
function Clique:DONGLE_PROFILE_DELETED(event, db, parent, svname, profileKey) function Clique:DONGLE_PROFILE_DELETED(event, db, parent, svname, profileKey)
if db == self.db then if db == self.db then
self:PrintF(L.PROFILE_DELETED, profileKey) self:PrintF(L.PROFILE_DELETED, profileKey)
@@ -392,31 +379,31 @@ function Clique:SetAttribute(entry, frame)
end end
-- Set up any special attributes -- Set up any special attributes
local type,button,value local type, button, value
if not tonumber(entry.button) then if not tonumber(entry.button) then
type,button = select(3, string.find(entry.button, "(%a+)button(%d+)")) type, button = select(3, string.find(entry.button, "(%a+)button(%d+)"))
frame:SetAttribute(entry.modifier..entry.button, type..button) frame:SetAttribute(entry.modifier .. entry.button, type .. button)
assert(frame:GetAttribute(entry.modifier..entry.button, type..button)) assert(frame:GetAttribute(entry.modifier .. entry.button, type .. button))
button = string.format("-%s%s", type, button) button = string.format("-%s%s", type, button)
end end
button = button or entry.button button = button or entry.button
if entry.type == "actionbar" then if entry.type == "actionbar" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."action"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "action" .. button, entry.arg1)
elseif entry.type == "action" then elseif entry.type == "action" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."action"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "action" .. button, entry.arg1)
if entry.arg2 then if entry.arg2 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg2) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg2)
end end
elseif entry.type == "pet" then elseif entry.type == "pet" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."action"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "action" .. button, entry.arg1)
if entry.arg2 then if entry.arg2 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg2) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg2)
end end
elseif entry.type == "spell" then elseif entry.type == "spell" then
local rank = entry.arg2 local rank = entry.arg2
@@ -433,59 +420,59 @@ function Clique:SetAttribute(entry, frame)
cast = entry.arg1 cast = entry.arg1
end end
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."spell"..button, cast) frame:SetAttribute(entry.modifier .. "spell" .. button, cast)
frame:SetAttribute(entry.modifier.."bag"..button, entry.arg2) frame:SetAttribute(entry.modifier .. "bag" .. button, entry.arg2)
frame:SetAttribute(entry.modifier.."slot"..button, entry.arg3) frame:SetAttribute(entry.modifier .. "slot" .. button, entry.arg3)
frame:SetAttribute(entry.modifier.."item"..button, entry.arg4) frame:SetAttribute(entry.modifier .. "item" .. button, entry.arg4)
if entry.arg5 then if entry.arg5 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg5) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg5)
end end
elseif entry.type == "item" then elseif entry.type == "item" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."bag"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "bag" .. button, entry.arg1)
frame:SetAttribute(entry.modifier.."slot"..button, entry.arg2) frame:SetAttribute(entry.modifier .. "slot" .. button, entry.arg2)
frame:SetAttribute(entry.modifier.."item"..button, entry.arg3) frame:SetAttribute(entry.modifier .. "item" .. button, entry.arg3)
if entry.arg4 then if entry.arg4 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg4) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg4)
end end
elseif entry.type == "macro" then elseif entry.type == "macro" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
if entry.arg1 then if entry.arg1 then
frame:SetAttribute(entry.modifier.."macro"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "macro" .. button, entry.arg1)
else else
local unit = SecureButton_GetModifiedUnit(frame, entry.modifier.."unit"..button) local unit = SecureButton_GetModifiedUnit(frame, entry.modifier .. "unit" .. button)
local macro = tostring(entry.arg2) local macro = tostring(entry.arg2)
if unit and macro then if unit and macro then
macro = macro:gsub("target%s*=%s*clique", "target="..unit) macro = macro:gsub("target%s*=%s*clique", "target=" .. unit)
end end
frame:SetAttribute(entry.modifier.."macro"..button, nil) frame:SetAttribute(entry.modifier .. "macro" .. button, nil)
frame:SetAttribute(entry.modifier.."macrotext"..button, macro) frame:SetAttribute(entry.modifier .. "macrotext" .. button, macro)
end end
elseif entry.type == "stop" then elseif entry.type == "stop" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
elseif entry.type == "target" then elseif entry.type == "target" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
if entry.arg1 then if entry.arg1 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg1)
end end
elseif entry.type == "focus" then elseif entry.type == "focus" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
if entry.arg1 then if entry.arg1 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg1)
end end
elseif entry.type == "assist" then elseif entry.type == "assist" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
if entry.arg1 then if entry.arg1 then
frame:SetAttribute(entry.modifier.."unit"..button, entry.arg1) frame:SetAttribute(entry.modifier .. "unit" .. button, entry.arg1)
end end
elseif entry.type == "click" then elseif entry.type == "click" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
frame:SetAttribute(entry.modifier.."clickbutton"..button, getglobal(entry.arg1)) frame:SetAttribute(entry.modifier .. "clickbutton" .. button, getglobal(entry.arg1))
elseif entry.type == "menu" then elseif entry.type == "menu" then
frame:SetAttribute(entry.modifier.."type"..button, entry.type) frame:SetAttribute(entry.modifier .. "type" .. button, entry.type)
end end
end end
@@ -495,11 +482,11 @@ function Clique:DeleteAttribute(entry, frame)
return return
end end
local type,button,value local type, button, value
if not tonumber(entry.button) then if not tonumber(entry.button) then
type,button = select(3, string.find(entry.button, "(%a+)button(%d+)")) type, button = select(3, string.find(entry.button, "(%a+)button(%d+)"))
frame:SetAttribute(entry.modifier..entry.button, nil) frame:SetAttribute(entry.modifier .. entry.button, nil)
button = string.format("-%s%s", type, button) button = string.format("-%s%s", type, button)
end end
@@ -507,12 +494,12 @@ function Clique:DeleteAttribute(entry, frame)
entry.delete = true entry.delete = true
frame:SetAttribute(entry.modifier.."type"..button, nil) frame:SetAttribute(entry.modifier .. "type" .. button, nil)
frame:SetAttribute(entry.modifier..entry.type..button, nil) frame:SetAttribute(entry.modifier .. entry.type .. button, nil)
end end
function Clique:SetAction(entry) function Clique:SetAction(entry)
for frame,enabled in pairs(self.ccframes) do for frame, enabled in pairs(self.ccframes) do
if enabled then if enabled then
self:SetAttribute(entry, frame) self:SetAttribute(entry, frame)
end end
@@ -527,7 +514,9 @@ end
function Clique:ShowAttributes() function Clique:ShowAttributes()
self:Print("Enabled enhanced debugging.") self:Print("Enabled enhanced debugging.")
PlayerFrame:SetScript("OnAttributeChanged", function(...) self:Print(...) end) PlayerFrame:SetScript("OnAttributeChanged", function(...)
self:Print(...)
end)
self:UnregisterFrame(PlayerFrame) self:UnregisterFrame(PlayerFrame)
self:RegisterFrame(PlayerFrame) self:RegisterFrame(PlayerFrame)
end end
@@ -543,44 +532,64 @@ function Clique:UpdateTooltip()
local harm = self.clicksets[L.CLICKSET_HARMFUL] local harm = self.clicksets[L.CLICKSET_HARMFUL]
local help = self.clicksets[L.CLICKSET_HELPFUL] 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_ooc) do
for k,v in pairs(tt_help) do tt_help[k] = nil end tt_ooc[k] = nil
for k,v in pairs(tt_harm) do tt_harm[k] = nil end end
for k,v in pairs(tt_default) do tt_default[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 -- Build the ooc lines, which includes both helpful and harmful
for k,v in pairs(ooc) do for k, v in pairs(ooc) do
local button = self:GetButtonText(v.button) local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button) local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type) 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 end
-- Build the default lines -- Build the default lines
for k,v in pairs(default) do for k, v in pairs(default) do
local button = self:GetButtonText(v.button) local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button) local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type) 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 end
-- Build the harm lines -- Build the harm lines
for k,v in pairs(harm) do for k, v in pairs(harm) do
local button = self:GetButtonText(v.button) local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button) local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type) 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 end
-- Build the help lines -- Build the help lines
for k,v in pairs(help) do for k, v in pairs(help) do
local button = self:GetButtonText(v.button) local button = self:GetButtonText(v.button)
local mod = string.format("%s%s", v.modifier or "", button) local mod = string.format("%s%s", v.modifier or "", button)
local action = string.format("%s (%s)", v.arg1 or "", v.type) 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 end
local function sort(a,b) local function sort(a, b)
return a.mod < b.mod return a.mod < b.mod
end end
@@ -591,39 +600,45 @@ function Clique:UpdateTooltip()
end end
function Clique:AddTooltipLines() function Clique:AddTooltipLines()
if not self.profile.tooltips then return end if not self.profile.tooltips then
return
end
local frame = GetMouseFocus() local frame = GetMouseFocus()
if not frame then return end if not frame then
if not self.ccframes[frame] then return end return
end
if not self.ccframes[frame] then
return
end
-- Add a buffer line -- Add a buffer line
GameTooltip:AddLine(" ") GameTooltip:AddLine(" ")
if UnitAffectingCombat("player") then if UnitAffectingCombat("player") then
if #tt_default ~= 0 then if #tt_default ~= 0 then
GameTooltip:AddLine("Default bindings:") GameTooltip:AddLine("Default bindings:")
for k,v in ipairs(tt_default) do for k, v in ipairs(tt_default) do
GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
if #tt_help ~= 0 and not UnitCanAttack("player", "mouseover") then if #tt_help ~= 0 and not UnitCanAttack("player", "mouseover") then
GameTooltip:AddLine("Helpful bindings:") GameTooltip:AddLine("Helpful bindings:")
for k,v in ipairs(tt_help) do for k, v in ipairs(tt_help) do
GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
if #tt_harm ~= 0 and UnitCanAttack("player", "mouseover") then if #tt_harm ~= 0 and UnitCanAttack("player", "mouseover") then
GameTooltip:AddLine("Hostile bindings:") GameTooltip:AddLine("Hostile bindings:")
for k,v in ipairs(tt_harm) do for k, v in ipairs(tt_harm) do
GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
else else
if #tt_ooc ~= 0 then if #tt_ooc ~= 0 then
GameTooltip:AddLine("Out of combat bindings:") GameTooltip:AddLine("Out of combat bindings:")
for k,v in ipairs(tt_ooc) do for k, v in ipairs(tt_ooc) do
GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) GameTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
@@ -632,8 +647,7 @@ end
function Clique:ToggleTooltip() function Clique:ToggleTooltip()
self.profile.tooltips = not self.profile.tooltips self.profile.tooltips = not self.profile.tooltips
self:PrintF("Listing of bindings in tooltips has been %s", self:PrintF("Listing of bindings in tooltips has been %s", self.profile.tooltips and "Enabled" or "Disabled")
self.profile.tooltips and "Enabled" or "Disabled")
end end
function Clique:ShowBindings() function Clique:ShowBindings()
@@ -655,7 +669,8 @@ function Clique:ShowBindings()
CliqueTooltip:SetMovable() CliqueTooltip:SetMovable()
CliqueTooltip:SetPadding(16) CliqueTooltip:SetPadding(16)
CliqueTooltip:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b); 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:RegisterForDrag("LeftButton")
CliqueTooltip:SetScript("OnDragStart", function(self) CliqueTooltip:SetScript("OnDragStart", function(self)
@@ -678,7 +693,7 @@ function Clique:ShowBindings()
if #tt_default > 0 then if #tt_default > 0 then
CliqueTooltip:AddLine(" ") CliqueTooltip:AddLine(" ")
CliqueTooltip:AddLine("Default bindings:") CliqueTooltip:AddLine("Default bindings:")
for k,v in ipairs(tt_default) do for k, v in ipairs(tt_default) do
CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
@@ -686,7 +701,7 @@ function Clique:ShowBindings()
if #tt_help > 0 then if #tt_help > 0 then
CliqueTooltip:AddLine(" ") CliqueTooltip:AddLine(" ")
CliqueTooltip:AddLine("Helpful bindings:") CliqueTooltip:AddLine("Helpful bindings:")
for k,v in ipairs(tt_help) do for k, v in ipairs(tt_help) do
CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
@@ -694,7 +709,7 @@ function Clique:ShowBindings()
if #tt_harm > 0 then if #tt_harm > 0 then
CliqueTooltip:AddLine(" ") CliqueTooltip:AddLine(" ")
CliqueTooltip:AddLine("Hostile bindings:") CliqueTooltip:AddLine("Hostile bindings:")
for k,v in ipairs(tt_harm) do for k, v in ipairs(tt_harm) do
CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
@@ -702,7 +717,7 @@ function Clique:ShowBindings()
if #tt_ooc > 0 then if #tt_ooc > 0 then
CliqueTooltip:AddLine(" ") CliqueTooltip:AddLine(" ")
CliqueTooltip:AddLine("Out of combat bindings:") CliqueTooltip:AddLine("Out of combat bindings:")
for k,v in ipairs(tt_ooc) do for k, v in ipairs(tt_ooc) do
CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1) CliqueTooltip:AddDoubleLine(v.mod, v.action, 1, 1, 1, 1, 1, 1)
end end
end end
@@ -710,16 +725,13 @@ function Clique:ShowBindings()
CliqueTooltip:Show() CliqueTooltip:Show()
end end
function Clique:COMMENTATOR_SKIRMISH_QUEUE_REQUEST(event, typeName, newGroup) function Clique:ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED(event, newGroup)
if typeName ~= "ASCENSION_CA_SPECIALIZATION_ACTIVE_ID_CHANGED" then return end
if self.db.char.switchSpec then if self.db.char.switchSpec then
self:Print("Detected a talent spec change, changing profile") self:Print("Detected a talent spec change, changing profile")
-- self:Print("Detected "..typeName..", changing profile to "..newGroup) -- self:Print("Detected "..typeName..", changing profile to "..newGroup)
newGroup = newGroup + 1 if self.db.char["spec" .. newGroup .. "Profile"] then
if self.db.char["spec"..newGroup.."Profile"] then self.db:SetProfile(self.db.char["spec" .. newGroup .. "Profile"])
self.db:SetProfile(self.db.char["spec"..newGroup.."Profile"])
end end
if CliqueFrame then if CliqueFrame then
@@ -742,15 +754,9 @@ function Clique:SetClickType(frame)
end end
function Clique:EnableArenaFrames() function Clique:EnableArenaFrames()
local arenaFrames = { local arenaFrames = {ArenaEnemyFrame1, ArenaEnemyFrame2, ArenaEnemyFrame3, ArenaEnemyFrame4, ArenaEnemyFrame5}
ArenaEnemyFrame1,
ArenaEnemyFrame2,
ArenaEnemyFrame3,
ArenaEnemyFrame4,
ArenaEnemyFrame5,
}
for idx,frame in ipairs(arenaFrames) do for idx, frame in ipairs(arenaFrames) do
rawset(self.ccframes, frame, true) rawset(self.ccframes, frame, true)
end end
end end