Compare commits

...

2 Commits

Author SHA1 Message Date
Robin Hüskes 9da511a91b Merge branch 'master' into rewrite_zz2 2022-10-08 15:37:52 +02:00
Robin Hüskes bad41b5bd3 Rewrite for zz2 2022-10-08 15:25:38 +02:00
11 changed files with 480 additions and 364 deletions

15
Clickzz.toc Normal file → Executable file
View File

@ -1,9 +1,6 @@
## Interface: 90207
## Title: Clickzz
## Notes: Clickcasting for Unitframes
## Author: Rilgamon
## X-WoWI-ID: 25674
## SavedVariables: ClickzzDB
## OptionalDeps: Ace3, BrokerPack, zzLibCommon
Libs\embeds.xml
pack.xml
## Interface: 100002
## Title: Clickzz
## OptionalDeps: zzLib, Ace3, BrokerPack
## SavedVariables: ClickzzDB
Libs\embeds.xml
pack.xml

View File

@ -1,4 +1,4 @@
local lib = LibStub:NewLibrary("zzLDB", 4)
local lib = LibStub:NewLibrary("zzLDB", 5)
if not lib then return end
local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
@ -22,11 +22,21 @@ function lib:DefaultOnClick(_, button, addon, childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
if(not InCombatLockdown()) then
if(SettingsPanel) then
if(SettingsPanel:IsVisible()) then
SettingsPanel:Hide()
else
Settings.OpenToCategory(childName)
end
elseif(InterfaceOptionsFrame) then
if(InterfaceOptionsFrame:IsVisible()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
end
end

0
README.md Normal file → Executable file
View File

54
broker.lua Executable file
View File

@ -0,0 +1,54 @@
local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local zzLDB = LibStub:GetLibrary("zzLDB")
local folder = addonName ~= childName and format("Interface\\AddOns\\%s\\%s", addonName, childName) or format("Interface\\AddOns\\%s", childName)
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(not InCombatLockdown()) then
if(SettingsPanel) then
if(SettingsPanel:IsVisible()) then
SettingsPanel:Hide()
else
Settings.OpenToCategory(childName)
end
elseif(InterfaceOptionsFrame) then
if(InterfaceOptionsFrame:IsVisible()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
end
end
local function OnTooltipShow(tip)
tip:AddLine(childName)
end
child['ldb'] = { -- https://github.com/tekkub/libdatabroker-1-1/wiki/Data-Specifications
['type'] = 'data source', -- required: 'data source' or 'launcher'
['text'] = childName, -- required/optional for launcher
['icon'] = format("%s\\icon2.tga", folder), -- optional/required for launcher
['OnClick'] = OnClick, -- optional/required for launcher
['OnTooltipShow'] = OnTooltipShow, -- optional
}
local init = {
Setup = function(self, childName, event)
-- print("setup ldb", childName, event)
if(child['ldb']['type'] == 'data source') then
child.OnText = zzLDB.DefaultOnText
end
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup', childName)

604
core.lua Normal file → Executable file
View File

@ -1,346 +1,258 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "Clickzz"
local eventframe, db
local options
local mouseButtons = {'LEFTBUTTON','RIGHTBUTTON','WHEEL',"BUTTON4","BUTTON5"}
local buffButtons = {'Buff1', 'Buff2', 'Buff3', 'Debuff1', 'Debuff2', 'Debuff3', 'DispelDebuff1', 'DispelDebuff2', 'DispelDebuff3'}
local modifier = {'none','shift','ctrl','alt'}
ClickCastFrames = ClickCastFrames or {}
local castFrames = ClickCastFrames
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
local function unregisterAttrs(frame)
if(InCombatLockdown()) then return end
frame['attrs'] = frame['attrs'] or {}
for key, value in pairs(frame['attrs']) do
frame:SetAttribute(key, nil)
frame['attrs'][key] = nil
end
end
local function registerAttrs(frame, key, value)
if(InCombatLockdown()) then
eventframe:RegisterEvent("PLAYER_REGEN_ENABLED")
else
frame['attrs'] = frame['attrs'] or {}
frame['attrs'][key] = value
frame:SetAttribute(key, value)
end
end
local function buffButtonSwitch(frame, switch)
local fName = frame:GetName()
if(strsub(fName, 1, 7) == 'Compact') then
for i = 1, #buffButtons do
local buffBtn = _G[format("%s%s", fName, buffButtons[i])]
if(buffBtn) then
buffBtn:EnableMouse(switch)
end
end
end
end
local function disableFrame(frame)
if(InCombatLockdown()) then
eventframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
if(frame and frame:GetName()) then
buffButtonSwitch(frame, true)
unregisterAttrs(frame)
registerAttrs(frame, 'type', 'target')
registerAttrs(frame, 'type2', 'togglemenu')
castFrames[frame] = nil
end
end
local function gettype(v, attr)
local r = format("%s%i", attr, v['btn'])
if(v['mod'] ~= 1) then
r = format("%s-%s", v['modName'],r)
end
return r
end
local function regAtt(frame, v)
registerAttrs(frame, gettype(v, 'harmbutton'), format("nuke%i",v['btn']))
registerAttrs(frame, gettype(v, 'helpbutton'), format("heal%i",v['btn']))
registerAttrs(frame, gettype(v, 'type-heal'), 'spell')
registerAttrs(frame, gettype(v, 'type-nuke'), 'spell')
registerAttrs(frame, gettype(v, 'spell-nuke'), v['spell'])
registerAttrs(frame, gettype(v, 'spell-heal'), v['dualSpell'] and v['spellHeal'] or v['spell'])
end
local function enableFrame(frame, force)
if(InCombatLockdown()) then
eventframe:RegisterEvent("PLAYER_REGEN_ENABLED")
if(not force) then return end
end
if(frame['unit'] and strsub(frame['unit'], 1, 9) == 'nameplate') then
-- print('nameplate ignored', frame['unit'])
return
end
if(frame and frame:GetName()) then
-- disableFrame(frame)
buffButtonSwitch(frame, false)
frame:RegisterForClicks('AnyDown')
for k,v in pairs(db['clicks']) do
regAtt(frame, v)
end
castFrames[frame] = true
end
end
local firstRun = true
local function enableAllFrames()
local frames = {
'PlayerFrame', 'TargetFrame', 'TargetFrameToT', 'FocusFrame', 'FocusFrameToT','PetFrame',
}
for n = 1, 8 do
for i = 1, 5 do
if(n==1) then
if(i<5) then
frames[#frames + 1] = format("PartyMemberFrame%i",i)
frames[#frames + 1] = format("PartyMemberFrame%iPetFrame",i)
frames[#frames + 1] = format("Boss%iTargetFrame",i)
end
frames[#frames + 1] = format("CompactPartyFrameMember%i",i)
end
frames[#frames + 1] = format("CompactRaidGroup%iMember%i",n,i)
end
end
for k,v in pairs(castFrames) do
if(v) then
local frame = k:GetName()
local skip = false
for n = 1, #frames do
if(frames[n] == frame) then
skip = true
break
end
end
if(not skip and frame) then
frames[#frames + 1] = frame
end
end
end
for k,frame in ipairs(frames) do
if(_G[frame]) then
enableFrame(_G[frame], firstRun)
else
-- print('skip', frame)
end
end
firstRun = false
end
local function OnText(message)
addon:OnText(childName, message)
end
local racialSpells = {} -- Beta returns the old names with C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
local function isRacialSpell(spellIcon) -- Replace spellIcon with spellName once the bug is fixed
-- local name, rank, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(spellName)
-- print('start',spellIcon)
for k, v in pairs(racialSpells) do
-- local nameR, rankR, iconR, castTimeR, minRangeR, maxRangeR, spellIdR = GetSpellInfo(v)
-- print(' check',v)
if(v == spellIcon) then
return true
end
end
end
local function buildRacialSpells()
local raceName, raceFile, raceID = UnitRace('player')
local res = C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
if(res) then
for k, v in pairs(C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)) do
if(type(v)=='table') then
if(not IsPassiveSpell(v['name']) and not isRacialSpell(v['icon'])) then -- Replace icon with name once the bug is fixed
racialSpells[#racialSpells+1] = v['icon'] -- Replace icon with name once the bug is fixed
end
end
end
end
end
local function buildSpells(self)
if(InCombatLockdown()) then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
local currentSpec = GetSpecialization()
if currentSpec then
local classInfo = C_CreatureInfo.GetClassInfo(select(3,UnitClass('player')))
buildRacialSpells()
local _, currentSpecName = GetSpecializationInfo(currentSpec)
db['spells'] = {}
for tabIndex = 1, GetNumSpellTabs() do
local name, texture, offset, numEntries, isGuild, offspecID = GetSpellTabInfo(tabIndex)
if(name == currentSpecName or name == classInfo['className'] or tabIndex==1) then
if(offspecID==0) then
for spellIndex = offset + 1, offset + numEntries do
local skillType, special = GetSpellBookItemInfo(spellIndex, BOOKTYPE_SPELL)
if(skillType=="SPELL" and not IsPassiveSpell(spellIndex, BOOKTYPE_SPELL)) then
local spellName, spellSubName = GetSpellBookItemName(spellIndex, BOOKTYPE_SPELL)
-- print(spellName,spellSubName,IsPassiveSpell(spellIndex, BOOKTYPE_SPELL), raceSpell)
local _, _, icon = GetSpellInfo(spellName)
if(not IsAttackSpell(spellName)) then
if(spellSubName and spellSubName ~= "" and not isRacialSpell(icon)) then
-- db['spells'][special] = format("%s (%s)",spellName, spellSubName)
db['spells'][special] = spellName -- Fix when C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID) returns a value
else
db['spells'][special] = spellName
end
end
end
end
end
end
end
end
end
local function OnEvent(self, event, ...)
if(event=="PLAYER_REGEN_ENABLED") then
self:UnregisterEvent(event)
elseif(event=="SPELLS_CHANGED") then
if(InCombatLockdown()) then
self:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
end
buildSpells(self)
enableAllFrames(self)
end
local function selectSpell()
local list = {}
for spellId, spellName in pairs(db['spells']) do
list[#list+1] = spellName
end
sort(list)
return list
end
local function remClick(pref)
addon['options']['args'][childName]['args']["activeClickzz"]['args'][pref[#pref-1]] = nil
db['clicks'][strsub(pref[#pref-1],10)] = nil
enableAllFrames()
end
local function buildMenu()
for clickName,v in pairs(db['clicks']) do
local grpName = v['btnName']
if(v['mod'] ~= 1) then
grpName = format("%s-%s",strupper(v['modName']),grpName)
end
local clickNum = format("clickNum-%s", clickName)
local grp = addon:AddConfigEntry(childName,"group",clickNum,grpName,'',1,true,nil,nil,nil,options['args'][childName]['args']["activeClickzz"])
addon:AddConfigEntry(childName,"execute","remClick",'Remove',nil,9,remClick,nil,nil,nil,options['args'][childName]['args']["activeClickzz"]['args'][clickNum])
addon:AddConfigEntry(childName,"toggle","dualSpell",'Dual','Set damage and heal spell on same click',8,nil,nil,nil,nil,options['args'][childName]['args']["activeClickzz"]['args'][clickNum])
addon:AddConfigEntry(childName,"select","selectSpell",'Spell',nil,7,selectSpell,nil,nil,nil,options['args'][childName]['args']["activeClickzz"]['args'][clickNum])
if(v['dualSpell']) then
addon:AddConfigEntry(childName,"select","selectSpell2",'Heal Spell',nil,6,selectSpell,nil,nil,nil,options['args'][childName]['args']["activeClickzz"]['args'][clickNum])
end
end
end
local function getPref(pref)
if(pref[#pref] == 'selectSpell') then
local spells = selectSpell()
for i = 1, #spells do
if(spells[i] == db['clicks'][strsub(pref[#pref-1],10)]['spell']) then
return i
end
end
elseif(pref[#pref] == 'selectSpell2') then
local spells = selectSpell()
for i = 1, #spells do
if(spells[i] == db['clicks'][strsub(pref[#pref-1],10)]['spellHeal']) then
return i
end
end
elseif(pref[#pref] == 'dualSpell') then
return db['clicks'][strsub(pref[#pref-1],10)]['dualSpell']
end
return db[pref[#pref]]
end
local function setPref(pref,value)
if(pref[#pref] == 'selectSpell') then
local spells = selectSpell()
db['clicks'][strsub(pref[#pref-1],10)]['spell'] = spells[value]
enableAllFrames()
return
elseif(pref[#pref] == 'dualSpell') then
db['clicks'][strsub(pref[#pref-1],10)]['dualSpell'] = value
buildMenu()
return
elseif(pref[#pref] == 'selectSpell2') then
local spells = selectSpell()
db['clicks'][strsub(pref[#pref-1],10)]['spellHeal'] = spells[value]
enableAllFrames()
return
end
db[pref[#pref]] = value
end
local function addClick()
local mod = tonumber(db['modType'])
if(modifier[mod]) then
local clickName
local btn = tonumber(db['mouseButton'])
local mf = modifier[mod]
local bf = mouseButtons[btn]
if(mod==1) then
clickName = format("type%i", btn)
else
clickName = format("%s-type%i", mf, btn)
end
db['clicks'][clickName] = db['clicks'][clickName] or {
['btnName'] = bf,
['modName'] = mf,
['btn'] = btn,
['mod'] = mod
}
buildMenu()
enableAllFrames()
end
end
hooksecurefunc("CompactUnitFrame_SetUnit", function(self, unit)
if(InCombatLockdown()) then
eventframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
if(unit and not castFrames[self]) then
enableFrame(self,firstRun)
end
end)
do
addon['preloads'][#addon['preloads'] + 1] = function(...)
db = addon['db']['profile'][childName]
eventframe = addon:RegisterFunc({'SPELLS_CHANGED','GROUP_ROSTER_UPDATE','RAID_ROSTER_UPDATE'},"OnEvent",OnEvent)
enableAllFrames()
end
addon:startup(name, childName, function()
options = addon:InitConfig(childName, true, {
['type'] = "launcher", -- 'data source | launcher'
['OnClick'] = OnClick
}, getPref, setPref)
addon:AddConfigEntry(childName,"select","modType",'Modifier',nil,1,modifier,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"select","mouseButton",'Mousebutton',nil,2,mouseButtons,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"execute","addClick",'Add Click',nil,3,addClick,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"group","activeClickzz","Active Clickzz",'',4,true,nil,nil,nil,options['args'][childName])
buildMenu()
end, nil, {
['spells'] = {},
['clicks'] = {},
['mouseButton'] = 1,
['modType'] = 1
})
end
local addonName, addon = ...
local childName = addon['childName']
local child = addon[childName]
local events = child['events']
local db
local evframe = CreateFrame("FRAME")
local function prepareDB()
db = addon['db']['profile'][childName]
child['db'] = db
addon['callbacks']:Fire(format("Init%s", childName))
end
child['specs'] = {
['name'] = childName,
['sv'] = true,
['cfg'] = true,
['cfgReset'] = prepareDB,
['ldb'] = child['ldb'],
['defaults'] = {
['profile'] = {
[childName] = {
['spells'] = {},
['clicks'] = {},
['mouseButton'] = 1,
['modType'] = 1
}
}
}
}
local buffButtons = {'Buff1', 'Buff2', 'Buff3', 'Debuff1', 'Debuff2', 'Debuff3', 'DispelDebuff1', 'DispelDebuff2', 'DispelDebuff3'}
ClickCastFrames = ClickCastFrames or {}
local castFrames = ClickCastFrames
local function unregisterAttrs(frame)
if(InCombatLockdown()) then return end
frame['attrs'] = frame['attrs'] or {}
for key, value in pairs(frame['attrs']) do
frame:SetAttribute(key, nil)
frame['attrs'][key] = nil
end
end
local function registerAttrs(frame, key, value)
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
else
frame['attrs'] = frame['attrs'] or {}
frame['attrs'][key] = value
frame:SetAttribute(key, value)
end
end
local function buffButtonSwitch(frame, switch)
local fName = frame:GetName()
if(strsub(fName, 1, 7) == 'Compact') then
for i = 1, #buffButtons do
local buffBtn = _G[format("%s%s", fName, buffButtons[i])]
if(buffBtn) then
buffBtn:EnableMouse(switch)
end
end
end
end
local function disableFrame(frame)
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
if(frame and frame:GetName()) then
buffButtonSwitch(frame, true)
unregisterAttrs(frame)
registerAttrs(frame, 'type', 'target')
registerAttrs(frame, 'type2', 'togglemenu')
castFrames[frame] = nil
end
end
local function gettype(v, attr)
local r = format("%s%i", attr, v['btn'])
if(v['mod'] ~= 1) then
r = format("%s-%s", v['modName'],r)
end
return r
end
local function regAtt(frame, v)
registerAttrs(frame, gettype(v, 'harmbutton'), format("nuke%i",v['btn']))
registerAttrs(frame, gettype(v, 'helpbutton'), format("heal%i",v['btn']))
registerAttrs(frame, gettype(v, 'type-heal'), 'spell')
registerAttrs(frame, gettype(v, 'type-nuke'), 'spell')
registerAttrs(frame, gettype(v, 'spell-nuke'), v['spell'])
registerAttrs(frame, gettype(v, 'spell-heal'), v['dualSpell'] and v['spellHeal'] or v['spell'])
end
local function enableFrame(frame, force)
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
if(not force) then return end
end
if(frame['unit'] and strsub(frame['unit'], 1, 9) == 'nameplate') then
-- print('nameplate ignored', frame['unit'])
return
end
if(frame and frame:GetName()) then
-- print("Register ".. frame:GetName())
-- disableFrame(frame)
buffButtonSwitch(frame, false)
frame:RegisterForClicks('AnyDown')
for k,v in pairs(db['clicks']) do
-- print(" Click", v)
regAtt(frame, v)
end
castFrames[frame] = true
end
end
local firstRun = true
function child:enableAllFrames()
local frames = {
'PlayerFrame', 'TargetFrame', 'TargetFrameToT', 'FocusFrame', 'FocusFrameToT','PetFrame',
}
for n = 1, 8 do
for i = 1, 5 do
if(n==1) then
if(i<5) then
frames[#frames + 1] = format("PartyMemberFrame%i",i)
frames[#frames + 1] = format("PartyMemberFrame%iPetFrame",i)
frames[#frames + 1] = format("Boss%iTargetFrame",i)
end
frames[#frames + 1] = format("CompactPartyFrameMember%i",i)
end
frames[#frames + 1] = format("CompactRaidGroup%iMember%i",n,i)
end
end
for k,v in pairs(castFrames) do
if(v) then
local frame = k:GetName()
local skip = false
for n = 1, #frames do
if(frames[n] == frame) then
skip = true
break
end
end
if(not skip and frame) then
frames[#frames + 1] = frame
end
end
end
for k,frame in ipairs(frames) do
if(_G[frame]) then
enableFrame(_G[frame], firstRun)
else
-- print('skip', frame)
end
end
firstRun = false
end
local racialSpells = {} -- Beta returns the old names with C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
local function isRacialSpell(spellIcon) -- Replace spellIcon with spellName once the bug is fixed
-- local name, rank, icon, castTime, minRange, maxRange, spellId = GetSpellInfo(spellName)
-- print('start',spellIcon)
for k, v in pairs(racialSpells) do
-- local nameR, rankR, iconR, castTimeR, minRangeR, maxRangeR, spellIdR = GetSpellInfo(v)
-- print(' check',v)
if(v == spellIcon) then
return true
end
end
end
local function buildRacialSpells()
local raceName, raceFile, raceID = UnitRace('player')
local res = C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)
if(res) then
for k, v in pairs(C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID)) do
if(type(v)=='table') then
if(not IsPassiveSpell(v['name']) and not isRacialSpell(v['icon'])) then -- Replace icon with name once the bug is fixed
racialSpells[#racialSpells+1] = v['icon'] -- Replace icon with name once the bug is fixed
end
end
end
end
end
function child:buildSpells(self)
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
local currentSpec = GetSpecialization()
if currentSpec then
local classInfo = C_CreatureInfo.GetClassInfo(select(3,UnitClass('player')))
buildRacialSpells()
local _, currentSpecName = GetSpecializationInfo(currentSpec)
db['spells'] = {}
for tabIndex = 1, GetNumSpellTabs() do
local name, texture, offset, numEntries, isGuild, offspecID = GetSpellTabInfo(tabIndex)
if(name == currentSpecName or name == classInfo['className'] or tabIndex==1) then
if(offspecID==0) then
for spellIndex = offset + 1, offset + numEntries do
local skillType, special = GetSpellBookItemInfo(spellIndex, BOOKTYPE_SPELL)
if(skillType=="SPELL" and not IsPassiveSpell(spellIndex, BOOKTYPE_SPELL)) then
local spellName, spellSubName = GetSpellBookItemName(spellIndex, BOOKTYPE_SPELL)
-- print(spellName,spellSubName,IsPassiveSpell(spellIndex, BOOKTYPE_SPELL), raceSpell)
local _, _, icon = GetSpellInfo(spellName)
if(not IsAttackSpell(spellName)) then
if(spellSubName and spellSubName ~= "" and not isRacialSpell(icon)) then
-- db['spells'][special] = format("%s (%s)",spellName, spellSubName)
db['spells'][special] = spellName -- Fix when C_AlliedRaces.GetAllRacialAbilitiesFromID(raceID) returns a value
else
db['spells'][special] = spellName
end
end
end
end
end
end
end
end
end
function evframe:PLAYER_REGEN_ENABLED(event)
self:UnregisterEvent(event)
child:buildSpells()
child:enableAllFrames()
end
function events:SPELLS_CHANGED()
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
child:buildSpells()
child:enableAllFrames()
end
function events:PLAYER_ENTERING_WORLD(_, event)
evframe:UnregisterEvent(event)
end
function events:GROUP_ROSTER_UPDATE()
child:buildSpells()
child:enableAllFrames()
end
function events:RAID_ROSTER_UPDATE()
child:buildSpells()
child:enableAllFrames()
end
function events:ADDON_LOADED(_, event, name)
if(name == childName) then
child:enableAllFrames()
child:UnregisterEvent(event)
end
end
evframe:SetScript("OnEvent" , function(self, event)
evframe[event](self, event)
end)
hooksecurefunc("CompactUnitFrame_SetUnit", function(self, unit)
if(InCombatLockdown()) then
evframe:RegisterEvent("PLAYER_REGEN_ENABLED")
return
end
if(unit and not castFrames[self]) then
enableFrame(self,firstRun)
end
end)
child:NewAddOn(...)

0
icon2.tga Normal file → Executable file
View File

12
init.lua Executable file
View File

@ -0,0 +1,12 @@
local addonName, addon = ...
addon['childName'] = "Clickzz"
addon['callbacks'] = addon['callbacks'] or LibStub("CallbackHandler-1.0"):New(addon)
local loaded, finished = IsAddOnLoaded("BrokerPack")
if(finished) then
addonName = "BrokerPack"
end
addon[addon['childName']] = {
['parentName'] = addonName ~= addon['childName'] and addonName or nil,
['events'] = {}
}
LibStub:GetLibrary("zzAddOn"):Embed(addon[addon['childName']])

2
license.txt Normal file → Executable file
View File

@ -1,5 +1,5 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.

6
locale_enUS.lua Executable file
View File

@ -0,0 +1,6 @@
local addonname, addon = ...
local childName = addon['childName']
local L = LibStub("AceLocale-3.0"):NewLocale(childName, "enUS", true)
if L then
L[childName] = childName
end

8
pack.xml Normal file → Executable file
View File

@ -1,3 +1,7 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="core.lua"/>
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="init.lua"/>
<Script file="locale_enUS.lua"/>
<Script file="prefs.lua"/>
<Script file="broker.lua"/>
<Script file="core.lua"/>
</Ui>

121
prefs.lua Executable file
View File

@ -0,0 +1,121 @@
local addonName, addon = ...
local childName = addon['childName']
local db
local child = addon[childName]
local modifier = {'none','shift','ctrl','alt'}
local mouseButtons = {'LEFTBUTTON','RIGHTBUTTON','WHEEL',"BUTTON4","BUTTON5"}
local prefGroupActiveClickzz
local function selectSpell()
local list = {}
for spellId, spellName in pairs(db['spells']) do
list[#list+1] = spellName
end
sort(list)
return list
end
local function remClick(pref)
child['options']['args'][childName]['args']["activeClickzz"]['args'][pref[#pref-1]] = nil
db['clicks'][strsub(pref[#pref-1],10)] = nil
child:enableAllFrames()
end
local function buildMenu()
local config = LibStub:GetLibrary("zzConfig")
local options = child['options']
local main = options['args'][childName]
for clickName,v in pairs(db['clicks']) do
-- print(clickName, v)
local grpName = v['btnName']
if(v['mod'] ~= 1) then
grpName = format("%s-%s",strupper(v['modName']),grpName)
end
local clickNum = format("clickNum-%s", clickName)
local grp = config:AddConfigEntry(prefGroupActiveClickzz, clickNum, "group", grpName, 'Settings', 1, {
['db'] = db,
['func'] = nil,
SetDB = function(self, db) self.db = db end,
GetPref = child.getPref,
SetPref = child.setPref,
})
config:AddConfigEntry(grp, "remClick", "execute", 'Remove', nil, 9, remClick)
config:AddConfigEntry(grp, "dualSpell", "toggle", 'Dual', 'Set damage and heal spell on same click', 8)
config:AddConfigEntry(grp, "selectSpell", "select", 'Spell', nil, 7, selectSpell)
if(v['dualSpell']) then
config:AddConfigEntry(grp, "selectSpell2", "select", 'Heal Spell', nil, 6, selectSpell)
end
end
end
function child:getPref(pref)
if(pref[#pref] == 'selectSpell') then
local spells = selectSpell()
for i = 1, #spells do
if(spells[i] == db['clicks'][strsub(pref[#pref-1],10)]['spell']) then
return i
end
end
elseif(pref[#pref] == 'selectSpell2') then
local spells = selectSpell()
for i = 1, #spells do
if(spells[i] == db['clicks'][strsub(pref[#pref-1],10)]['spellHeal']) then
return i
end
end
elseif(pref[#pref] == 'dualSpell') then
return db['clicks'][strsub(pref[#pref-1],10)]['dualSpell']
end
return db[pref[#pref]]
end
function child:setPref(pref,value)
if(pref[#pref] == 'selectSpell') then
local spells = selectSpell()
db['clicks'][strsub(pref[#pref-1],10)]['spell'] = spells[value]
child:enableAllFrames()
return
elseif(pref[#pref] == 'dualSpell') then
db['clicks'][strsub(pref[#pref-1],10)]['dualSpell'] = value
buildMenu()
return
elseif(pref[#pref] == 'selectSpell2') then
local spells = selectSpell()
db['clicks'][strsub(pref[#pref-1],10)]['spellHeal'] = spells[value]
child:enableAllFrames()
return
end
db[pref[#pref]] = value
end
local function addClick()
local mod = tonumber(db['modType'])
if(modifier[mod]) then
local clickName
local btn = tonumber(db['mouseButton'])
local mf = modifier[mod]
local bf = mouseButtons[btn]
if(mod==1) then
clickName = format("type%i", btn)
else
clickName = format("%s-type%i", mf, btn)
end
db['clicks'][clickName] = db['clicks'][clickName] or {
['btnName'] = bf,
['modName'] = mf,
['btn'] = btn,
['mod'] = mod
}
buildMenu()
child:enableAllFrames()
end
end
local init = {
Setup = function(self)
db = child['db']
local config = LibStub:GetLibrary("zzConfig")
local options = child['options']
local main = options['args'][childName]
-- print("setup prefs", childName)
config:AddConfigEntry(main, "modType", "select", 'Modifier', nil, 1, modifier)
config:AddConfigEntry(main, "mouseButton", "select", 'Mousebutton', nil, 2, mouseButtons)
config:AddConfigEntry(main, "addClick", "execute", 'Add Click', nil, 3, addClick)
prefGroupActiveClickzz = config:AddConfigEntry(main, "activeClickzz", "group", 'Active Clickzz', '', 4)
buildMenu()
end
}
addon.RegisterCallback(init, format("Init%s", childName), 'Setup')