mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-10-03 13:00:02 +00:00
v1.2.0
This commit is contained in:
+217
-217
@@ -1,217 +1,217 @@
|
||||
if not ZHunterMod_Saved then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
|
||||
BINDING_HEADER_ZAspectHeader = "ZAspect Buttons"
|
||||
BINDING_HEADER_ZTrackHeader = "ZTrack Buttons"
|
||||
BINDING_HEADER_ZTrapHeader = "ZTrap Buttons"
|
||||
BINDING_HEADER_ZPetHeader = "ZPet Buttons"
|
||||
BINDING_HEADER_ZAmmoHeader = "ZAmmo Buttons"
|
||||
BINDING_HEADER_ZMountsHeader = "ZMounts Buttons"
|
||||
BINDING_HEADER_ZCompanionsHeader = "ZCompanions Buttons"
|
||||
BINDING_HEADER_ZToysHeader = "ZToys Buttons"
|
||||
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "ZHunterModScan", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltipTextLeft1 = getglobal("ZHunterModScanTextLeft1")
|
||||
|
||||
MTH_ZH_TRACE_ENABLED = false
|
||||
|
||||
local function MTH_ZH_DescribePoint(frame)
|
||||
if not (frame and frame.GetPoint) then
|
||||
return "<no-frame>"
|
||||
end
|
||||
local point, relTo, relPoint, x, y = frame:GetPoint()
|
||||
local relName = "nil"
|
||||
if type(relTo) == "table" and relTo.GetName then
|
||||
relName = tostring(relTo:GetName() or "<anon>")
|
||||
elseif relTo then
|
||||
relName = tostring(relTo)
|
||||
end
|
||||
return tostring(point or "nil")
|
||||
.. "->" .. relName
|
||||
.. ":" .. tostring(relPoint or "nil")
|
||||
.. " @(" .. tostring(x) .. "," .. tostring(y) .. ")"
|
||||
end
|
||||
|
||||
function MTH_ZH_Trace(msg)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print("[ZHTRACE] " .. tostring(msg), "debug")
|
||||
elseif DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[ZHTRACE] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceButtonPoint(frame, reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if not frame then
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " frame=nil")
|
||||
return
|
||||
end
|
||||
local name = frame.GetName and frame:GetName() or "<unnamed>"
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " " .. tostring(name) .. " " .. MTH_ZH_DescribePoint(frame))
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceAllButtonPoints(reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
local names = {
|
||||
"zButtonAspect",
|
||||
"zButtonAmmo",
|
||||
"zButtonTrack",
|
||||
"zButtonTrap",
|
||||
"zButtonRanged",
|
||||
"zButtonPet",
|
||||
"zButtonMounts",
|
||||
"zButtonCompanions",
|
||||
"zButtonToys",
|
||||
}
|
||||
MTH_ZH_Trace("snapshot begin reason=" .. tostring(reason or ""))
|
||||
for i = 1, table.getn(names) do
|
||||
local frame = getglobal(names[i])
|
||||
MTH_ZH_TraceButtonPoint(frame, tostring(reason or "") .. ":" .. tostring(names[i]))
|
||||
end
|
||||
MTH_ZH_Trace("snapshot end reason=" .. tostring(reason or ""))
|
||||
end
|
||||
|
||||
function MTH_ZH_IsModuleEnabled()
|
||||
if not (MTH and MTH.IsModuleEnabled) then
|
||||
return true
|
||||
end
|
||||
return MTH:IsModuleEnabled("zhunter", true)
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedRoot()
|
||||
if type(ZHunterMod_Saved) ~= "table" then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
return ZHunterMod_Saved
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedTable(key)
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(key) ~= "string" or key == "" then
|
||||
return root
|
||||
end
|
||||
if type(root[key]) ~= "table" then
|
||||
root[key] = {}
|
||||
end
|
||||
return root[key]
|
||||
end
|
||||
|
||||
local function MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(root) ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
local mapping = {
|
||||
{"ZHunterButtonAspect", "zButtonAspect"},
|
||||
{"ZHunterButtonTrack", "zButtonTrack"},
|
||||
{"ZHunterButtonTrap", "zButtonTrap"},
|
||||
{"ZHunterButtonAmmo", "zButtonAmmo"},
|
||||
{"ZHunterButtonPet", "zButtonPet"},
|
||||
{"ZHunterButtonMounts", "zButtonMounts"},
|
||||
{"ZHunterButtonCompanions", "zButtonCompanions"},
|
||||
{"ZHunterButtonToys", "zButtonToys"},
|
||||
}
|
||||
|
||||
for i = 1, table.getn(mapping) do
|
||||
local oldKey = mapping[i][1]
|
||||
local newKey = mapping[i][2]
|
||||
if root[oldKey] ~= nil then
|
||||
root[newKey] = root[oldKey]
|
||||
root[oldKey] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
|
||||
function MTH_ZH_Print(message, severity)
|
||||
if type(MTH_Log) == "function" then
|
||||
MTH_Log(message, severity)
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print(message, severity)
|
||||
return
|
||||
end
|
||||
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[MetaHunt] " .. tostring(message or ""), 1, 0.9, 0.3)
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_HandleDisabledSlash(message, tableKey, fieldKey)
|
||||
if MTH_ZH_IsModuleEnabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tableKey) == "string" and tableKey ~= "" then
|
||||
if fieldKey then
|
||||
local tbl = MTH_ZH_GetSavedTable(tableKey)
|
||||
tbl[fieldKey] = nil
|
||||
else
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
root[tableKey] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if message then
|
||||
MTH_ZH_Print(message)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ZHunterMod_AlignButtons()
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:before")
|
||||
zButtonAmmo:ClearAllPoints()
|
||||
zButtonAmmo:SetPoint("TOP", zButtonAspect, "BOTTOM", 0, -15)
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("TOP", zButtonAmmo, "BOTTOM", 0, -15)
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("TOP", zButtonTrack, "BOTTOM", 0, -15)
|
||||
zButtonPet:ClearAllPoints()
|
||||
zButtonPet:SetPoint("TOP", zButtonTrap, "BOTTOM", 0, -15)
|
||||
zButtonMounts:ClearAllPoints()
|
||||
zButtonMounts:SetPoint("TOP", zButtonPet, "BOTTOM", 0, -15)
|
||||
zButtonCompanions:ClearAllPoints()
|
||||
zButtonCompanions:SetPoint("TOP", zButtonMounts, "BOTTOM", 0, -15)
|
||||
zButtonToys:ClearAllPoints()
|
||||
zButtonToys:SetPoint("TOP", zButtonCompanions, "BOTTOM", 0, -15)
|
||||
if AutoStripDisplay then
|
||||
AutoStripDisplay:ClearAllPoints()
|
||||
AutoStripDisplay:SetPoint("TOP", zButtonToys, "BOTTOM", 0, -10)
|
||||
end
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:after")
|
||||
end
|
||||
|
||||
function ZMarkTarget()
|
||||
if not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
if not UnitExists("target") then return end
|
||||
for i=1, 40 do
|
||||
if not UnitDebuff("target", i) then break end
|
||||
ZHunterModTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
ZHunterModTooltip:SetUnitDebuff("target", i)
|
||||
local spell = ZHunterModTooltipTextLeft1:GetText()
|
||||
if spell == ZHUNTER_HUNTERSMARK then
|
||||
return
|
||||
end
|
||||
end
|
||||
CastSpellByName(ZHUNTER_HUNTERSMARK)
|
||||
return 1
|
||||
end
|
||||
|
||||
SLASH_ZHunterMod1 = "/zhunter"
|
||||
SlashCmdList["ZHunterMod"] = function(msg)
|
||||
MTH_ZH_Print("Possible Slash Commands: \"/zammo\", \"/zaspect\", \"/ztrack\", \"/ztrap\", \"/zpet\", \"/zmounts\", \"/zcompanions\", \"/zminipets\", \"/ztoys\", \"/zstrip\", \"/zantidaze\"")
|
||||
end
|
||||
if not ZHunterMod_Saved then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
|
||||
BINDING_HEADER_ZAspectHeader = "ZAspect Buttons"
|
||||
BINDING_HEADER_ZTrackHeader = "ZTrack Buttons"
|
||||
BINDING_HEADER_ZTrapHeader = "ZTrap Buttons"
|
||||
BINDING_HEADER_ZPetHeader = "ZPet Buttons"
|
||||
BINDING_HEADER_ZAmmoHeader = "ZAmmo Buttons"
|
||||
BINDING_HEADER_ZMountsHeader = "ZMounts Buttons"
|
||||
BINDING_HEADER_ZCompanionsHeader = "ZCompanions Buttons"
|
||||
BINDING_HEADER_ZToysHeader = "ZToys Buttons"
|
||||
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "MTH_ZH_AbilityProbe", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltipTextLeft1 = getglobal("MTH_ZH_AbilityProbeTextLeft1")
|
||||
|
||||
MTH_ZH_TRACE_ENABLED = false
|
||||
|
||||
local function MTH_ZH_DescribePoint(frame)
|
||||
if not (frame and frame.GetPoint) then
|
||||
return "<no-frame>"
|
||||
end
|
||||
local point, relTo, relPoint, x, y = frame:GetPoint()
|
||||
local relName = "nil"
|
||||
if type(relTo) == "table" and relTo.GetName then
|
||||
relName = tostring(relTo:GetName() or "<anon>")
|
||||
elseif relTo then
|
||||
relName = tostring(relTo)
|
||||
end
|
||||
return tostring(point or "nil")
|
||||
.. "->" .. relName
|
||||
.. ":" .. tostring(relPoint or "nil")
|
||||
.. " @(" .. tostring(x) .. "," .. tostring(y) .. ")"
|
||||
end
|
||||
|
||||
function MTH_ZH_Trace(msg)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print("[ZHTRACE] " .. tostring(msg), "debug")
|
||||
elseif DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[ZHTRACE] " .. tostring(msg))
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceButtonPoint(frame, reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
if not frame then
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " frame=nil")
|
||||
return
|
||||
end
|
||||
local name = frame.GetName and frame:GetName() or "<unnamed>"
|
||||
MTH_ZH_Trace("point " .. tostring(reason or "") .. " " .. tostring(name) .. " " .. MTH_ZH_DescribePoint(frame))
|
||||
end
|
||||
|
||||
function MTH_ZH_TraceAllButtonPoints(reason)
|
||||
if not MTH_ZH_TRACE_ENABLED then
|
||||
return
|
||||
end
|
||||
local names = {
|
||||
"zButtonAspect",
|
||||
"zButtonAmmo",
|
||||
"zButtonTrack",
|
||||
"zButtonTrap",
|
||||
"zButtonRanged",
|
||||
"zButtonPet",
|
||||
"zButtonMounts",
|
||||
"zButtonCompanions",
|
||||
"zButtonToys",
|
||||
}
|
||||
MTH_ZH_Trace("snapshot begin reason=" .. tostring(reason or ""))
|
||||
for i = 1, table.getn(names) do
|
||||
local frame = getglobal(names[i])
|
||||
MTH_ZH_TraceButtonPoint(frame, tostring(reason or "") .. ":" .. tostring(names[i]))
|
||||
end
|
||||
MTH_ZH_Trace("snapshot end reason=" .. tostring(reason or ""))
|
||||
end
|
||||
|
||||
function MTH_ZH_IsModuleEnabled()
|
||||
if not (MTH and MTH.IsModuleEnabled) then
|
||||
return true
|
||||
end
|
||||
return MTH:IsModuleEnabled("zhunter", true)
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedRoot()
|
||||
if type(ZHunterMod_Saved) ~= "table" then
|
||||
ZHunterMod_Saved = {}
|
||||
end
|
||||
return ZHunterMod_Saved
|
||||
end
|
||||
|
||||
function MTH_ZH_GetSavedTable(key)
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(key) ~= "string" or key == "" then
|
||||
return root
|
||||
end
|
||||
if type(root[key]) ~= "table" then
|
||||
root[key] = {}
|
||||
end
|
||||
return root[key]
|
||||
end
|
||||
|
||||
local function MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
if type(root) ~= "table" then
|
||||
return
|
||||
end
|
||||
|
||||
local mapping = {
|
||||
{"ZHunterButtonAspect", "zButtonAspect"},
|
||||
{"ZHunterButtonTrack", "zButtonTrack"},
|
||||
{"ZHunterButtonTrap", "zButtonTrap"},
|
||||
{"ZHunterButtonAmmo", "zButtonAmmo"},
|
||||
{"ZHunterButtonPet", "zButtonPet"},
|
||||
{"ZHunterButtonMounts", "zButtonMounts"},
|
||||
{"ZHunterButtonCompanions", "zButtonCompanions"},
|
||||
{"ZHunterButtonToys", "zButtonToys"},
|
||||
}
|
||||
|
||||
for i = 1, table.getn(mapping) do
|
||||
local oldKey = mapping[i][1]
|
||||
local newKey = mapping[i][2]
|
||||
if root[oldKey] ~= nil then
|
||||
root[newKey] = root[oldKey]
|
||||
root[oldKey] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_MigrateButtonSavedKeys_Replace()
|
||||
|
||||
function MTH_ZH_Print(message, severity)
|
||||
if type(MTH_Log) == "function" then
|
||||
MTH_Log(message, severity)
|
||||
return
|
||||
end
|
||||
if MTH and MTH.Print then
|
||||
MTH:Print(message, severity)
|
||||
return
|
||||
end
|
||||
if DEFAULT_CHAT_FRAME and DEFAULT_CHAT_FRAME.AddMessage then
|
||||
DEFAULT_CHAT_FRAME:AddMessage("[MetaHunt] " .. tostring(message or ""), 1, 0.9, 0.3)
|
||||
end
|
||||
end
|
||||
|
||||
function MTH_ZH_HandleDisabledSlash(message, tableKey, fieldKey)
|
||||
if MTH_ZH_IsModuleEnabled() then
|
||||
return false
|
||||
end
|
||||
|
||||
if type(tableKey) == "string" and tableKey ~= "" then
|
||||
if fieldKey then
|
||||
local tbl = MTH_ZH_GetSavedTable(tableKey)
|
||||
tbl[fieldKey] = nil
|
||||
else
|
||||
local root = MTH_ZH_GetSavedRoot()
|
||||
root[tableKey] = nil
|
||||
end
|
||||
end
|
||||
|
||||
if message then
|
||||
MTH_ZH_Print(message)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function ZHunterMod_AlignButtons()
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:before")
|
||||
zButtonAmmo:ClearAllPoints()
|
||||
zButtonAmmo:SetPoint("TOP", zButtonAspect, "BOTTOM", 0, -15)
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("TOP", zButtonAmmo, "BOTTOM", 0, -15)
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("TOP", zButtonTrack, "BOTTOM", 0, -15)
|
||||
zButtonPet:ClearAllPoints()
|
||||
zButtonPet:SetPoint("TOP", zButtonTrap, "BOTTOM", 0, -15)
|
||||
zButtonMounts:ClearAllPoints()
|
||||
zButtonMounts:SetPoint("TOP", zButtonPet, "BOTTOM", 0, -15)
|
||||
zButtonCompanions:ClearAllPoints()
|
||||
zButtonCompanions:SetPoint("TOP", zButtonMounts, "BOTTOM", 0, -15)
|
||||
zButtonToys:ClearAllPoints()
|
||||
zButtonToys:SetPoint("TOP", zButtonCompanions, "BOTTOM", 0, -15)
|
||||
if AutoStripDisplay then
|
||||
AutoStripDisplay:ClearAllPoints()
|
||||
AutoStripDisplay:SetPoint("TOP", zButtonToys, "BOTTOM", 0, -10)
|
||||
end
|
||||
MTH_ZH_TraceAllButtonPoints("AlignButtons:after")
|
||||
end
|
||||
|
||||
function ZMarkTarget()
|
||||
if not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
if not UnitExists("target") then return end
|
||||
for i=1, 40 do
|
||||
if not UnitDebuff("target", i) then break end
|
||||
ZHunterModTooltip:SetOwner(UIParent, "ANCHOR_NONE")
|
||||
ZHunterModTooltip:SetUnitDebuff("target", i)
|
||||
local spell = ZHunterModTooltipTextLeft1:GetText()
|
||||
if spell == ZHUNTER_HUNTERSMARK then
|
||||
return
|
||||
end
|
||||
end
|
||||
CastSpellByName(ZHUNTER_HUNTERSMARK)
|
||||
return 1
|
||||
end
|
||||
|
||||
SLASH_ZHunterMod1 = "/zhunter"
|
||||
SlashCmdList["ZHunterMod"] = function(msg)
|
||||
MTH_ZH_Print("Possible Slash Commands: \"/zammo\", \"/zaspect\", \"/ztrack\", \"/ztrap\", \"/zpet\", \"/zmounts\", \"/zcompanions\", \"/zminipets\", \"/ztoys\", \"/zstrip\", \"/zantidaze\"")
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+36
-20
@@ -8,10 +8,10 @@ MTH_ZH_MANAGED_HOOKS = true
|
||||
local MTH_ZHunter = {
|
||||
name = "zhunter",
|
||||
enabled = true,
|
||||
version = "1.1.0",
|
||||
version = "1.2.0",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"PLAYER_ENTERING_WORLD",
|
||||
-- PLAYER_ENTERING_WORLD handled by bootstrap frame + adjustment frames
|
||||
"MTH_PET_LIVE_STATE_CHANGED",
|
||||
},
|
||||
features = {
|
||||
@@ -37,7 +37,7 @@ local function MTH_ZH_TraceLocal(msg)
|
||||
end
|
||||
end
|
||||
|
||||
local MTH_ZH_PostLoginRestoreFrame = nil
|
||||
local MTH_ZH_PostLoginRestore = nil
|
||||
local MTH_ZH_BootstrapFrame = nil
|
||||
local MTH_ZH_SyncSavedVariables
|
||||
local MTH_ZH_SetButtonsVisible
|
||||
@@ -116,15 +116,15 @@ function MTH_ZH_OnDeferredInitComplete()
|
||||
end
|
||||
|
||||
MTH_ZH_QueuePostLoginRestore = function(tag)
|
||||
if not MTH_ZH_PostLoginRestoreFrame then
|
||||
MTH_ZH_PostLoginRestoreFrame = CreateFrame("Frame", "MTH_ZH_PostLoginRestoreFrame")
|
||||
if not MTH_ZH_PostLoginRestoreFrame then
|
||||
if not MTH_ZH_PostLoginRestore then
|
||||
MTH_ZH_PostLoginRestore = CreateFrame("Frame", "MTH_ZH_PostLoginRestore")
|
||||
if not MTH_ZH_PostLoginRestore then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
MTH_ZH_PostLoginRestoreFrame._mthElapsed = 0
|
||||
MTH_ZH_PostLoginRestoreFrame:SetScript("OnUpdate", function()
|
||||
MTH_ZH_PostLoginRestore._mthElapsed = 0
|
||||
MTH_ZH_PostLoginRestore:SetScript("OnUpdate", function()
|
||||
this._mthElapsed = (this._mthElapsed or 0) + (arg1 or 0)
|
||||
if this._mthElapsed < 0.2 then
|
||||
return
|
||||
@@ -149,7 +149,7 @@ local function MTH_ZH_EnsureBootstrapRestoreFrame()
|
||||
return MTH_ZH_BootstrapFrame
|
||||
end
|
||||
|
||||
MTH_ZH_BootstrapFrame = CreateFrame("Frame", "MTH_ZH_BootstrapRestoreFrame")
|
||||
MTH_ZH_BootstrapFrame = CreateFrame("Frame", "MTH_ZH_BootstrapRestore")
|
||||
if not MTH_ZH_BootstrapFrame then
|
||||
return nil
|
||||
end
|
||||
@@ -297,10 +297,26 @@ MTH_ZH_SetButtonsVisible = function(visible)
|
||||
if type(MTH_ZH_TraceButtonPoint) == "function" then
|
||||
MTH_ZH_TraceButtonPoint(button, "set-buttons-visible:before:" .. tostring(buttonName))
|
||||
end
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, visible)
|
||||
if visible then
|
||||
button:Show()
|
||||
-- Respect per-button enabled state
|
||||
local getterName = buttonName .. "_GetSaved"
|
||||
local getter = getglobal(getterName)
|
||||
local shouldShow = true
|
||||
if type(getter) == "function" then
|
||||
local ok, saved = pcall(getter)
|
||||
if ok and type(saved) == "table" and (saved["enabled"] == false or saved["enabled"] == 0) then
|
||||
shouldShow = false
|
||||
end
|
||||
end
|
||||
if shouldShow then
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, true)
|
||||
button:Show()
|
||||
else
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, false)
|
||||
button:Hide()
|
||||
end
|
||||
else
|
||||
MTH_ZH_SetChildButtonsVisible(button, buttonName, false)
|
||||
button:Hide()
|
||||
end
|
||||
if type(MTH_ZH_TraceButtonPoint) == "function" then
|
||||
@@ -316,15 +332,15 @@ end
|
||||
|
||||
local function MTH_ZH_SetAdjustmentHandlersActive(active)
|
||||
local frameSpecs = {
|
||||
{ frame = "zButtonAspectAdjustment", handler = "zButtonAspectAdjustment_OnEvent", getter = "zButtonAspect_GetSaved" },
|
||||
{ frame = "zButtonTrackAdjustment", handler = "zButtonTrackAdjustment_OnEvent", getter = "zButtonTrack_GetSaved" },
|
||||
{ frame = "zButtonTrapAdjustment", handler = "zButtonTrapAdjustment_OnEvent", getter = "zButtonTrap_GetSaved" },
|
||||
{ frame = "zButtonRangedAdjustment", handler = "zButtonRangedAdjustment_OnEvent", getter = "zButtonRanged_GetSaved" },
|
||||
{ frame = "zButtonAmmoAdjustment", handler = "zButtonAmmoAdjustment_OnEvent", getter = "zButtonAmmo_GetSaved" },
|
||||
{ frame = "zButtonPetAdjustment", handler = "zButtonPetAdjustment_OnEvent", getter = "zButtonPet_GetSaved" },
|
||||
{ frame = "zButtonMountsAdjustment", handler = "zButtonMountsAdjustment_OnEvent", getter = "zButtonMounts_GetSaved" },
|
||||
{ frame = "zButtonCompanionsAdjustment", handler = "zButtonCompanionsAdjustment_OnEvent", getter = "zButtonCompanions_GetSaved" },
|
||||
{ frame = "zButtonToysAdjustment", handler = "zButtonToysAdjustment_OnEvent", getter = "zButtonToys_GetSaved" },
|
||||
{ frame = "MTH_ZH_AspectAdjust", handler = "MTH_ZH_AspectAdjust_OnEvent", getter = "zButtonAspect_GetSaved" },
|
||||
{ frame = "MTH_ZH_TrackAdjust", handler = "MTH_ZH_TrackAdjust_OnEvent", getter = "zButtonTrack_GetSaved" },
|
||||
{ frame = "MTH_ZH_TrapAdjust", handler = "MTH_ZH_TrapAdjust_OnEvent", getter = "zButtonTrap_GetSaved" },
|
||||
{ frame = "MTH_ZH_RangedAdjust", handler = "MTH_ZH_RangedAdjust_OnEvent", getter = "zButtonRanged_GetSaved" },
|
||||
{ frame = "MTH_ZH_AmmoAdjust", handler = "MTH_ZH_AmmoAdjust_OnEvent", getter = "zButtonAmmo_GetSaved" },
|
||||
{ frame = "MTH_ZH_PetAdjust", handler = "MTH_ZH_PetAdjust_OnEvent", getter = "zButtonPet_GetSaved" },
|
||||
{ frame = "MTH_ZH_MountsAdjust", handler = "MTH_ZH_MountsAdjust_OnEvent", getter = "zButtonMounts_GetSaved" },
|
||||
{ frame = "MTH_ZH_CompanionsAdjust", handler = "MTH_ZH_CompanionsAdjust_OnEvent", getter = "zButtonCompanions_GetSaved" },
|
||||
{ frame = "MTH_ZH_ToysAdjust", handler = "MTH_ZH_ToysAdjust_OnEvent", getter = "zButtonToys_GetSaved" },
|
||||
}
|
||||
|
||||
local function isFeatureEnabled(getterName)
|
||||
|
||||
+1132
-1130
File diff suppressed because it is too large
Load Diff
+392
-390
@@ -1,391 +1,393 @@
|
||||
local function zButtonAspect_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonAspect_GetRoot()
|
||||
if not root["zButtonAspect"] then
|
||||
root["zButtonAspect"] = {}
|
||||
root["zButtonAspect"]["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
root["zButtonAspect"]["rows"] = 1
|
||||
root["zButtonAspect"]["horizontal"] = nil
|
||||
root["zButtonAspect"]["vertical"] = nil
|
||||
root["zButtonAspect"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonAspect"]["enabled"] = 1
|
||||
root["zButtonAspect"]["tooltip"] = 1
|
||||
root["zButtonAspect"]["parent"] = {}
|
||||
root["zButtonAspect"]["parent"]["size"] = 36
|
||||
root["zButtonAspect"]["parent"]["hide"] = nil
|
||||
root["zButtonAspect"]["parent"]["circle"] = 1
|
||||
root["zButtonAspect"]["children"] = {}
|
||||
root["zButtonAspect"]["children"]["size"] = 36
|
||||
root["zButtonAspect"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Aspect_Spells = {
|
||||
ZHUNTER_ASPECT_HAWK,
|
||||
ZHUNTER_ASPECT_MONKEY,
|
||||
ZHUNTER_ASPECT_WOLF,
|
||||
ZHUNTER_ASPECT_CHEETAH,
|
||||
ZHUNTER_ASPECT_PACK,
|
||||
ZHUNTER_ASPECT_WILD,
|
||||
ZHUNTER_ASPECT_BEAST
|
||||
}
|
||||
|
||||
local ZHUNTER_ASPECT_MAX = table.getn(ZHunterMod_Aspect_Spells)
|
||||
local zButtonAspect_LastAuraUpdateAt = 0
|
||||
local zButtonAspect_MinAuraInterval = 0.15
|
||||
local zButtonAspect_MinAuraIntervalCombat = 0.60
|
||||
local zButtonAspect_LastAuraTexture = nil
|
||||
local zButtonAspect_LastParentId = nil
|
||||
local zButtonAspect_AuraProbeTextLeft1 = nil
|
||||
|
||||
local function zButtonAspect_GetSaved()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
if not currentRoot["zButtonAspect"] then
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
end
|
||||
return currentRoot["zButtonAspect"]
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_ASPECT_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonAspect_ApplyRuntimeSettings()
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
zButtonAspect.tooltip = saved["tooltip"] and true or false
|
||||
zButtonAspect.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
local function zButtonAspect_IsKnownAspectSpellId(spellId)
|
||||
if not spellId then
|
||||
return false
|
||||
end
|
||||
local spellName = GetSpellName(spellId, "spell")
|
||||
if not spellName or spellName == "" then
|
||||
return false
|
||||
end
|
||||
for i = 1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if ZHunterMod_Aspect_Spells[i] == spellName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureValidParentId()
|
||||
if not (zButtonAspect and zButtonAspect.count) then
|
||||
return
|
||||
end
|
||||
|
||||
if zButtonAspect_IsKnownAspectSpellId(zButtonAspect.id) then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, zButtonAspect.count do
|
||||
local child = getglobal(zButtonAspect.name .. i)
|
||||
if child and child.id and zButtonAspect_IsKnownAspectSpellId(child.id) then
|
||||
zButtonAspect.id = child.id
|
||||
zButtonAspect.isspell = 1
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonAspect_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonAspect:UnregisterAllEvents()
|
||||
zButtonAspect:Hide()
|
||||
return
|
||||
end
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspectAdjustment = CreateFrame("Frame", "zButtonAspectAdjustment")
|
||||
zButtonAspectAdjustment:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonAspectAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", zButtonAspectAdjustment_OnEvent)
|
||||
zButtonAspect_Tooltip = CreateFrame("GameTooltip", "zButtonAspect_AuraProbeScan", nil, "GameTooltipTemplate")
|
||||
if zButtonAspect_Tooltip and zButtonAspect_Tooltip.GetName then
|
||||
local tooltipName = zButtonAspect_Tooltip:GetName()
|
||||
if tooltipName then
|
||||
zButtonAspect_AuraProbeTextLeft1 = getglobal(tooltipName .. "TextLeft1")
|
||||
end
|
||||
end
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_CreateButtons()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonAspect, "zButtonAspect", ZHUNTER_ASPECT_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Aspect_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Aspect_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonAspect.found = ZSpellButton_SetButtons(zButtonAspect, info)
|
||||
zButtonAspect_ApplyRuntimeSettings()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
|
||||
function zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonAspectAdjustment and zButtonAspectAdjustment.SetScript then
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAspect and zButtonAspect.Hide then
|
||||
zButtonAspect:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonAspectAdjustment and zButtonAspectAdjustment.SetScript then
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", zButtonAspectAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonAspect.found or ZHUNTER_ASPECT_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonAspect, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonAspect, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonAspect_Reset()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonAspect_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonAspectAdjustment_OnEvent()
|
||||
if not zButtonAspect or not zButtonAspect.count then
|
||||
return
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local minInterval = zButtonAspect_MinAuraInterval
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = zButtonAspect_MinAuraIntervalCombat
|
||||
end
|
||||
if now > 0 and zButtonAspect_LastAuraUpdateAt > 0 and (now - zButtonAspect_LastAuraUpdateAt) < minInterval then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraUpdateAt = now
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
if not zButtonAspect1.id then
|
||||
return
|
||||
end
|
||||
local button
|
||||
local isParentTooltipOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonAspect)
|
||||
local childrenShown = zButtonAspect.children and zButtonAspect.children.IsShown and zButtonAspect.children:IsShown()
|
||||
local needChildIconScan = (event ~= "PLAYER_AURAS_CHANGED") or childrenShown or isParentTooltipOwned
|
||||
local buttontextures = nil
|
||||
local hasDuplicateChildTexture = nil
|
||||
if needChildIconScan then
|
||||
buttontextures = {}
|
||||
local textureSeen = {}
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
button.icon = nil
|
||||
if button.id then
|
||||
local btnTexture = GetSpellTexture(button.id, "spell")
|
||||
if btnTexture then
|
||||
if textureSeen[btnTexture] then
|
||||
hasDuplicateChildTexture = true
|
||||
elseif hasDuplicateChildTexture == nil then
|
||||
hasDuplicateChildTexture = false
|
||||
end
|
||||
textureSeen[btnTexture] = 1
|
||||
buttontextures[btnTexture] = button
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local i = 1
|
||||
local texture = GetSpellTexture(zButtonAspect1.id, "spell")
|
||||
local buff = UnitBuff("player", i)
|
||||
local spellname, buffname
|
||||
local newParentId = zButtonAspect1.id
|
||||
while buff do
|
||||
if texture == buff and zButtonAspect2.id then
|
||||
newParentId = zButtonAspect2.id
|
||||
end
|
||||
if needChildIconScan and buttontextures[buff] then
|
||||
if hasDuplicateChildTexture then
|
||||
zButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
zButtonAspect_Tooltip:SetUnitBuff("player", i)
|
||||
if zButtonAspect_AuraProbeTextLeft1 and zButtonAspect_AuraProbeTextLeft1.GetText then
|
||||
buffname = zButtonAspect_AuraProbeTextLeft1:GetText()
|
||||
else
|
||||
buffname = nil
|
||||
end
|
||||
spellname = GetSpellName(buttontextures[buff].id, "spell")
|
||||
if buffname == spellname then
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
else
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
buff = UnitBuff("player", i)
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" and zButtonAspect_LastAuraTexture == texture and zButtonAspect.id == newParentId and zButtonAspect_LastParentId == newParentId and not isParentTooltipOwned then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraTexture = texture
|
||||
zButtonAspect_LastParentId = newParentId
|
||||
zButtonAspect.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
if needChildIconScan then
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
if button.id then
|
||||
ZSpellButton_UpdateButton(button)
|
||||
end
|
||||
end
|
||||
end
|
||||
if isParentTooltipOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonAspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonAspect"..index)
|
||||
else
|
||||
button = zButtonAspect
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonAspect.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonAspect, false)
|
||||
elseif zButtonAspect.children then
|
||||
zButtonAspect.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonAspect1 = "/ZAspect"
|
||||
SlashCmdList["zButtonAspect"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Aspect button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonAspect_Reset()
|
||||
zButtonAspect:ClearAllPoints()
|
||||
zButtonAspect:SetPoint("CENTER", UIParent, "CENTER", -60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Aspect")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonAspect_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonAspect_GetRoot()
|
||||
if not root["zButtonAspect"] then
|
||||
root["zButtonAspect"] = {}
|
||||
root["zButtonAspect"]["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
root["zButtonAspect"]["rows"] = 1
|
||||
root["zButtonAspect"]["horizontal"] = nil
|
||||
root["zButtonAspect"]["vertical"] = nil
|
||||
root["zButtonAspect"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonAspect"]["enabled"] = 1
|
||||
root["zButtonAspect"]["tooltip"] = 1
|
||||
root["zButtonAspect"]["parent"] = {}
|
||||
root["zButtonAspect"]["parent"]["size"] = 36
|
||||
root["zButtonAspect"]["parent"]["hide"] = nil
|
||||
root["zButtonAspect"]["parent"]["circle"] = 1
|
||||
root["zButtonAspect"]["children"] = {}
|
||||
root["zButtonAspect"]["children"]["size"] = 36
|
||||
root["zButtonAspect"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Aspect_Spells = {
|
||||
ZHUNTER_ASPECT_HAWK,
|
||||
ZHUNTER_ASPECT_MONKEY,
|
||||
ZHUNTER_ASPECT_WOLF,
|
||||
ZHUNTER_ASPECT_CHEETAH,
|
||||
ZHUNTER_ASPECT_PACK,
|
||||
ZHUNTER_ASPECT_WILD,
|
||||
ZHUNTER_ASPECT_BEAST
|
||||
}
|
||||
|
||||
local ZHUNTER_ASPECT_MAX = table.getn(ZHunterMod_Aspect_Spells)
|
||||
local zButtonAspect_LastAuraUpdateAt = 0
|
||||
local zButtonAspect_MinAuraInterval = 0.15
|
||||
local zButtonAspect_MinAuraIntervalCombat = 0.60
|
||||
local zButtonAspect_LastAuraTexture = nil
|
||||
local zButtonAspect_LastParentId = nil
|
||||
local zButtonAspect_AuraProbeTextLeft1 = nil
|
||||
|
||||
local function zButtonAspect_GetSaved()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
if not currentRoot["zButtonAspect"] then
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
end
|
||||
return currentRoot["zButtonAspect"]
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_ASPECT_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonAspect_ApplyRuntimeSettings()
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
zButtonAspect.tooltip = saved["tooltip"] and true or false
|
||||
zButtonAspect.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonAspect.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonAspect.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonAspect_IsKnownAspectSpellId(spellId)
|
||||
if not spellId then
|
||||
return false
|
||||
end
|
||||
local spellName = GetSpellName(spellId, "spell")
|
||||
if not spellName or spellName == "" then
|
||||
return false
|
||||
end
|
||||
for i = 1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if ZHunterMod_Aspect_Spells[i] == spellName then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function zButtonAspect_EnsureValidParentId()
|
||||
if not (zButtonAspect and zButtonAspect.count) then
|
||||
return
|
||||
end
|
||||
|
||||
if zButtonAspect_IsKnownAspectSpellId(zButtonAspect.id) then
|
||||
return
|
||||
end
|
||||
|
||||
for i = 1, zButtonAspect.count do
|
||||
local child = getglobal(zButtonAspect.name .. i)
|
||||
if child and child.id and zButtonAspect_IsKnownAspectSpellId(child.id) then
|
||||
zButtonAspect.id = child.id
|
||||
zButtonAspect.isspell = 1
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonAspect_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonAspect then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonAspect:UnregisterAllEvents()
|
||||
zButtonAspect:Hide()
|
||||
return
|
||||
end
|
||||
zButtonAspect_CreateButtons()
|
||||
MTH_ZH_AspectAdjust = CreateFrame("Frame", "MTH_ZH_AspectAdjust")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_AspectAdjust:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", MTH_ZH_AspectAdjust_OnEvent)
|
||||
zButtonAspect_Tooltip = CreateFrame("GameTooltip", "MTH_ZH_AspectProbe", nil, "GameTooltipTemplate")
|
||||
if zButtonAspect_Tooltip and zButtonAspect_Tooltip.GetName then
|
||||
local tooltipName = zButtonAspect_Tooltip:GetName()
|
||||
if tooltipName then
|
||||
zButtonAspect_AuraProbeTextLeft1 = getglobal(tooltipName .. "TextLeft1")
|
||||
end
|
||||
end
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_CreateButtons()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonAspect, "zButtonAspect", ZHUNTER_ASPECT_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Aspect_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Aspect_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Aspect_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonAspect.found = ZSpellButton_SetButtons(zButtonAspect, info)
|
||||
zButtonAspect_ApplyRuntimeSettings()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
|
||||
function zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureConfig()
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_AspectAdjust and MTH_ZH_AspectAdjust.SetScript then
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAspect and zButtonAspect.Hide then
|
||||
zButtonAspect:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_AspectAdjust and MTH_ZH_AspectAdjust.SetScript then
|
||||
MTH_ZH_AspectAdjust:SetScript("OnEvent", MTH_ZH_AspectAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonAspect.found or ZHUNTER_ASPECT_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonAspect, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonAspect, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonAspect, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonAspect_Reset()
|
||||
local currentRoot = zButtonAspect_GetRoot()
|
||||
currentRoot["zButtonAspect"] = {}
|
||||
local saved = zButtonAspect_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonAspect_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_AspectAdjust_OnEvent()
|
||||
if not zButtonAspect or not zButtonAspect.count then
|
||||
return
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local minInterval = zButtonAspect_MinAuraInterval
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = zButtonAspect_MinAuraIntervalCombat
|
||||
end
|
||||
if now > 0 and zButtonAspect_LastAuraUpdateAt > 0 and (now - zButtonAspect_LastAuraUpdateAt) < minInterval then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraUpdateAt = now
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_CreateButtons()
|
||||
zButtonAspect_SetupSizeAndPosition()
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonAspect_EnsureValidParentId()
|
||||
if not zButtonAspect1.id then
|
||||
return
|
||||
end
|
||||
local button
|
||||
local isParentTooltipOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonAspect)
|
||||
local childrenShown = zButtonAspect.children and zButtonAspect.children.IsShown and zButtonAspect.children:IsShown()
|
||||
local needChildIconScan = (event ~= "PLAYER_AURAS_CHANGED") or childrenShown or isParentTooltipOwned
|
||||
local buttontextures = nil
|
||||
local hasDuplicateChildTexture = nil
|
||||
if needChildIconScan then
|
||||
buttontextures = {}
|
||||
local textureSeen = {}
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
button.icon = nil
|
||||
if button.id then
|
||||
local btnTexture = GetSpellTexture(button.id, "spell")
|
||||
if btnTexture then
|
||||
if textureSeen[btnTexture] then
|
||||
hasDuplicateChildTexture = true
|
||||
elseif hasDuplicateChildTexture == nil then
|
||||
hasDuplicateChildTexture = false
|
||||
end
|
||||
textureSeen[btnTexture] = 1
|
||||
buttontextures[btnTexture] = button
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
local i = 1
|
||||
local texture = GetSpellTexture(zButtonAspect1.id, "spell")
|
||||
local buff = UnitBuff("player", i)
|
||||
local spellname, buffname
|
||||
local newParentId = zButtonAspect1.id
|
||||
while buff do
|
||||
if texture == buff and zButtonAspect2.id then
|
||||
newParentId = zButtonAspect2.id
|
||||
end
|
||||
if needChildIconScan and buttontextures[buff] then
|
||||
if hasDuplicateChildTexture then
|
||||
zButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
zButtonAspect_Tooltip:SetUnitBuff("player", i)
|
||||
if zButtonAspect_AuraProbeTextLeft1 and zButtonAspect_AuraProbeTextLeft1.GetText then
|
||||
buffname = zButtonAspect_AuraProbeTextLeft1:GetText()
|
||||
else
|
||||
buffname = nil
|
||||
end
|
||||
spellname = GetSpellName(buttontextures[buff].id, "spell")
|
||||
if buffname == spellname then
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
else
|
||||
buttontextures[buff].icon = "Interface\\Icons\\Spell_Nature_WispSplode"
|
||||
end
|
||||
end
|
||||
i = i + 1
|
||||
buff = UnitBuff("player", i)
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" and zButtonAspect_LastAuraTexture == texture and zButtonAspect.id == newParentId and zButtonAspect_LastParentId == newParentId and not isParentTooltipOwned then
|
||||
return
|
||||
end
|
||||
zButtonAspect_LastAuraTexture = texture
|
||||
zButtonAspect_LastParentId = newParentId
|
||||
zButtonAspect.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonAspect)
|
||||
ZSpellButton_UpdateCooldown(zButtonAspect)
|
||||
if needChildIconScan then
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
if button.id then
|
||||
ZSpellButton_UpdateButton(button)
|
||||
end
|
||||
end
|
||||
end
|
||||
if isParentTooltipOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonAspect)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonAspect_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonAspect"..index)
|
||||
else
|
||||
button = zButtonAspect
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonAspect.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonAspect, false)
|
||||
elseif zButtonAspect.children then
|
||||
zButtonAspect.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonAspect1 = "/ZAspect"
|
||||
SlashCmdList["zButtonAspect"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Aspect button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonAspect_Reset()
|
||||
zButtonAspect:ClearAllPoints()
|
||||
zButtonAspect:SetPoint("CENTER", UIParent, "CENTER", -60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Aspect")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
@@ -93,6 +93,8 @@ local function zButtonCompanions_ApplyRuntimeSettings()
|
||||
local saved = zButtonCompanions_GetSaved()
|
||||
zButtonCompanions.tooltip = saved["tooltip"] and true or false
|
||||
zButtonCompanions.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonCompanions.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonCompanions.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonCompanions_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonCompanions_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonCompanions_CreateButtons()
|
||||
zButtonCompanionsAdjustment = CreateFrame("Frame", "zButtonCompanionsAdjustment")
|
||||
zButtonCompanionsAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonCompanionsAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", zButtonCompanionsAdjustment_OnEvent)
|
||||
MTH_ZH_CompanionsAdjust = CreateFrame("Frame", "MTH_ZH_CompanionsAdjust")
|
||||
MTH_ZH_CompanionsAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_CompanionsAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", MTH_ZH_CompanionsAdjust_OnEvent)
|
||||
zButtonCompanions_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonCompanions_SetupSizeAndPosition()
|
||||
local saved = zButtonCompanions_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonCompanionsAdjustment and zButtonCompanionsAdjustment.SetScript then
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_CompanionsAdjust and MTH_ZH_CompanionsAdjust.SetScript then
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonCompanions and zButtonCompanions.Hide then
|
||||
zButtonCompanions:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonCompanionsAdjustment and zButtonCompanionsAdjustment.SetScript then
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", zButtonCompanionsAdjustment_OnEvent)
|
||||
if MTH_ZH_CompanionsAdjust and MTH_ZH_CompanionsAdjust.SetScript then
|
||||
MTH_ZH_CompanionsAdjust:SetScript("OnEvent", MTH_ZH_CompanionsAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonCompanions.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonCompanions_Reset()
|
||||
zButtonCompanions_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonCompanionsAdjustment_OnEvent()
|
||||
function MTH_ZH_CompanionsAdjust_OnEvent()
|
||||
if not zButtonCompanions then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -93,6 +93,8 @@ local function zButtonMounts_ApplyRuntimeSettings()
|
||||
local saved = zButtonMounts_GetSaved()
|
||||
zButtonMounts.tooltip = saved["tooltip"] and true or false
|
||||
zButtonMounts.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonMounts.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonMounts.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonMounts_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonMounts_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonMounts_CreateButtons()
|
||||
zButtonMountsAdjustment = CreateFrame("Frame", "zButtonMountsAdjustment")
|
||||
zButtonMountsAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonMountsAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", zButtonMountsAdjustment_OnEvent)
|
||||
MTH_ZH_MountsAdjust = CreateFrame("Frame", "MTH_ZH_MountsAdjust")
|
||||
MTH_ZH_MountsAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_MountsAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", MTH_ZH_MountsAdjust_OnEvent)
|
||||
zButtonMounts_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonMounts_SetupSizeAndPosition()
|
||||
local saved = zButtonMounts_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonMountsAdjustment and zButtonMountsAdjustment.SetScript then
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_MountsAdjust and MTH_ZH_MountsAdjust.SetScript then
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonMounts and zButtonMounts.Hide then
|
||||
zButtonMounts:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonMountsAdjustment and zButtonMountsAdjustment.SetScript then
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", zButtonMountsAdjustment_OnEvent)
|
||||
if MTH_ZH_MountsAdjust and MTH_ZH_MountsAdjust.SetScript then
|
||||
MTH_ZH_MountsAdjust:SetScript("OnEvent", MTH_ZH_MountsAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonMounts.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonMounts_Reset()
|
||||
zButtonMounts_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonMountsAdjustment_OnEvent()
|
||||
function MTH_ZH_MountsAdjust_OnEvent()
|
||||
if not zButtonMounts then
|
||||
return
|
||||
end
|
||||
|
||||
+655
-653
File diff suppressed because it is too large
Load Diff
@@ -232,6 +232,8 @@ local function zButtonRanged_ApplyRuntimeSettings()
|
||||
local saved = zButtonRanged_GetSaved()
|
||||
zButtonRanged.tooltip = saved["tooltip"] and true or false
|
||||
zButtonRanged.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonRanged.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonRanged.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonRanged_UpdateDurabilityText(button)
|
||||
@@ -602,11 +604,11 @@ function zButtonRanged_OnEvent()
|
||||
zButtonRanged.customUpdateButton = zButtonRanged_UpdateButton
|
||||
zButtonRanged.beforeclick = zButtonRanged_BeforeClick
|
||||
zButtonRanged_CreateButtons()
|
||||
zButtonRangedAdjustment = CreateFrame("Frame", "zButtonRangedAdjustment")
|
||||
zButtonRangedAdjustment:RegisterEvent("UNIT_INVENTORY_CHANGED")
|
||||
zButtonRangedAdjustment:RegisterEvent("BAG_UPDATE")
|
||||
zButtonRangedAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", zButtonRangedAdjustment_OnEvent)
|
||||
MTH_ZH_RangedAdjust = CreateFrame("Frame", "MTH_ZH_RangedAdjust")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("UNIT_INVENTORY_CHANGED")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("BAG_UPDATE")
|
||||
MTH_ZH_RangedAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", MTH_ZH_RangedAdjust_OnEvent)
|
||||
zButtonRanged_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -635,16 +637,16 @@ end
|
||||
function zButtonRanged_SetupSizeAndPosition()
|
||||
local saved = zButtonRanged_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonRangedAdjustment and zButtonRangedAdjustment.SetScript then
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_RangedAdjust and MTH_ZH_RangedAdjust.SetScript then
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonRanged and zButtonRanged.Hide then
|
||||
zButtonRanged:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonRangedAdjustment and zButtonRangedAdjustment.SetScript then
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", zButtonRangedAdjustment_OnEvent)
|
||||
if MTH_ZH_RangedAdjust and MTH_ZH_RangedAdjust.SetScript then
|
||||
MTH_ZH_RangedAdjust:SetScript("OnEvent", MTH_ZH_RangedAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonRanged.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -679,7 +681,7 @@ function zButtonRanged_Reset()
|
||||
zButtonRanged_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonRangedAdjustment_OnEvent()
|
||||
function MTH_ZH_RangedAdjust_OnEvent()
|
||||
if not zButtonRanged then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -93,6 +93,8 @@ local function zButtonToys_ApplyRuntimeSettings()
|
||||
local saved = zButtonToys_GetSaved()
|
||||
zButtonToys.tooltip = saved["tooltip"] and true or false
|
||||
zButtonToys.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonToys.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonToys.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
local function zButtonToys_NormalizeTabName(value)
|
||||
@@ -225,10 +227,10 @@ function zButtonToys_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonToys_CreateButtons()
|
||||
zButtonToysAdjustment = CreateFrame("Frame", "zButtonToysAdjustment")
|
||||
zButtonToysAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonToysAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonToysAdjustment:SetScript("OnEvent", zButtonToysAdjustment_OnEvent)
|
||||
MTH_ZH_ToysAdjust = CreateFrame("Frame", "MTH_ZH_ToysAdjust")
|
||||
MTH_ZH_ToysAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_ToysAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", MTH_ZH_ToysAdjust_OnEvent)
|
||||
zButtonToys_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
@@ -247,16 +249,16 @@ end
|
||||
function zButtonToys_SetupSizeAndPosition()
|
||||
local saved = zButtonToys_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonToysAdjustment and zButtonToysAdjustment.SetScript then
|
||||
zButtonToysAdjustment:SetScript("OnEvent", nil)
|
||||
if MTH_ZH_ToysAdjust and MTH_ZH_ToysAdjust.SetScript then
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonToys and zButtonToys.Hide then
|
||||
zButtonToys:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonToysAdjustment and zButtonToysAdjustment.SetScript then
|
||||
zButtonToysAdjustment:SetScript("OnEvent", zButtonToysAdjustment_OnEvent)
|
||||
if MTH_ZH_ToysAdjust and MTH_ZH_ToysAdjust.SetScript then
|
||||
MTH_ZH_ToysAdjust:SetScript("OnEvent", MTH_ZH_ToysAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonToys.found or 0
|
||||
if displayCount < 0 then
|
||||
@@ -291,7 +293,7 @@ function zButtonToys_Reset()
|
||||
zButtonToys_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonToysAdjustment_OnEvent()
|
||||
function MTH_ZH_ToysAdjust_OnEvent()
|
||||
if not zButtonToys then
|
||||
return
|
||||
end
|
||||
|
||||
+411
-409
@@ -1,410 +1,412 @@
|
||||
local function zButtonTrack_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrack_GetRoot()
|
||||
if not root["zButtonTrack"] then
|
||||
root["zButtonTrack"] = {}
|
||||
root["zButtonTrack"]["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
root["zButtonTrack"]["rows"] = 1
|
||||
root["zButtonTrack"]["horizontal"] = nil
|
||||
root["zButtonTrack"]["vertical"] = nil
|
||||
root["zButtonTrack"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrack"]["enabled"] = 1
|
||||
root["zButtonTrack"]["tooltip"] = 1
|
||||
root["zButtonTrack"]["parent"] = {}
|
||||
root["zButtonTrack"]["parent"]["size"] = 36
|
||||
root["zButtonTrack"]["parent"]["hide"] = nil
|
||||
root["zButtonTrack"]["parent"]["circle"] = 1
|
||||
root["zButtonTrack"]["children"] = {}
|
||||
root["zButtonTrack"]["children"]["size"] = 36
|
||||
root["zButtonTrack"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Track_Spells = {
|
||||
ZHUNTER_TRACK_HIDDEN,
|
||||
ZHUNTER_TRACK_HUMANOIDS,
|
||||
ZHUNTER_TRACK_UNDEAD,
|
||||
ZHUNTER_TRACK_BEASTS,
|
||||
ZHUNTER_TRACK_DEMONS,
|
||||
ZHUNTER_TRACK_ELEMENTALS,
|
||||
ZHUNTER_TRACK_DRAGONKIN,
|
||||
ZHUNTER_TRACK_GIANTS,
|
||||
ZHUNTER_TRACK_MINERALS,
|
||||
ZHUNTER_TRACK_HERBS,
|
||||
ZHUNTER_TRACK_TREASURE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRACK_MAX = table.getn(ZHunterMod_Track_Spells)
|
||||
local zButtonTrack_LastTrackingTexture = nil
|
||||
local zButtonTrack_SyncActiveChild
|
||||
local zButtonTrack_GetSaved
|
||||
|
||||
local function zButtonTrack_NormalizeTexture(texture)
|
||||
if not texture then
|
||||
return ""
|
||||
end
|
||||
local value = string.lower(tostring(texture))
|
||||
value = string.gsub(value, "\\", "/")
|
||||
local _, _, basename = string.find(value, "([^/]+)$")
|
||||
return basename or value
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingTexture(trackingTexture)
|
||||
if not trackingTexture or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
local wanted = zButtonTrack_NormalizeTexture(trackingTexture)
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellTexture = GetSpellTexture and GetSpellTexture(child.id, "spell") or nil
|
||||
if zButtonTrack_NormalizeTexture(spellTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icon and zButtonTrack_NormalizeTexture(child.icon) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icontexture and child.icontexture.GetTexture then
|
||||
local childTexture = child.icontexture:GetTexture()
|
||||
if zButtonTrack_NormalizeTexture(childTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingName(trackingName)
|
||||
if not trackingName or trackingName == "" or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellName = GetSpellName and GetSpellName(child.id, "spell") or nil
|
||||
if spellName == trackingName then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_GetActiveTrackingSpellId()
|
||||
local activeName = nil
|
||||
local activeTexture = nil
|
||||
if GetNumTrackingTypes and GetTrackingInfo then
|
||||
local numTracking = GetNumTrackingTypes() or 0
|
||||
for i = 1, numTracking do
|
||||
local name, texture, active = GetTrackingInfo(i)
|
||||
if active then
|
||||
activeName = name
|
||||
activeTexture = texture
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local byName = zButtonTrack_FindSpellIdByTrackingName(activeName)
|
||||
if byName then
|
||||
return byName, activeTexture
|
||||
end
|
||||
if activeTexture then
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(activeTexture), activeTexture
|
||||
end
|
||||
local buff = GetTrackingTexture and GetTrackingTexture() or nil
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(buff), buff
|
||||
end
|
||||
|
||||
local function zButtonTrack_AfterClick(button)
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if button and button.id then
|
||||
zButtonTrack.id = button.id
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(button.id)
|
||||
if GetSpellTexture then
|
||||
zButtonTrack_LastTrackingTexture = GetSpellTexture(button.id, "spell") or zButtonTrack_LastTrackingTexture
|
||||
end
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_SyncActiveChild = function(activeId)
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.SetChecked then
|
||||
child:SetChecked((activeId and child.id == activeId) and 1 or 0)
|
||||
end
|
||||
end
|
||||
if zButtonTrack.SetChecked then
|
||||
zButtonTrack:SetChecked(0)
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_RefreshTrackingState()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
local newId, trackingTexture = zButtonTrack_GetActiveTrackingSpellId()
|
||||
local buff = trackingTexture or (GetTrackingTexture and GetTrackingTexture() or nil)
|
||||
if not newId and not buff then
|
||||
if zButtonTrack.id then
|
||||
zButtonTrack_SyncActiveChild(zButtonTrack.id)
|
||||
else
|
||||
zButtonTrack_LastTrackingTexture = nil
|
||||
zButtonTrack_SyncActiveChild(nil)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not newId then
|
||||
newId = zButtonTrack.id or nil
|
||||
end
|
||||
if not newId then
|
||||
return
|
||||
end
|
||||
if zButtonTrack_NormalizeTexture(zButtonTrack_LastTrackingTexture) == zButtonTrack_NormalizeTexture(buff) and zButtonTrack.id == newId then
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
return
|
||||
end
|
||||
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
zButtonTrack_LastTrackingTexture = buff
|
||||
zButtonTrack.id = newId
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_GetSaved = function()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
if not currentRoot["zButtonTrack"] then
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrack"]
|
||||
end
|
||||
|
||||
local function zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRACK_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_ApplyRuntimeSettings()
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
zButtonTrack.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrack.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrack_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrack_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrack:UnregisterAllEvents()
|
||||
zButtonTrack:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack.afterclick = zButtonTrack_AfterClick
|
||||
zButtonTrackAdjustment = CreateFrame("Frame", "zButtonTrackAdjustment")
|
||||
zButtonTrackAdjustment:RegisterEvent("MINIMAP_UPDATE_TRACKING")
|
||||
zButtonTrackAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonTrackAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", zButtonTrackAdjustment_OnEvent)
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_CreateButtons()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrack, "zButtonTrack", ZHUNTER_TRACK_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Track_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Track_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Track_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrack.found = ZSpellButton_SetButtons(zButtonTrack, info)
|
||||
zButtonTrack_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrack_SetupSizeAndPosition()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonTrackAdjustment and zButtonTrackAdjustment.SetScript then
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrack and zButtonTrack.Hide then
|
||||
zButtonTrack:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonTrackAdjustment and zButtonTrackAdjustment.SetScript then
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", zButtonTrackAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrack.found or ZHUNTER_TRACK_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrack, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrack, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
|
||||
function zButtonTrack_Reset()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonTrack_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonTrackAdjustment_OnEvent()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "MINIMAP_UPDATE_TRACKING" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrack"..index)
|
||||
else
|
||||
button = zButtonTrack
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrack.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrack, false)
|
||||
elseif zButtonTrack.children then
|
||||
zButtonTrack.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrack1 = "/ZTrack"
|
||||
SlashCmdList["zButtonTrack"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Track button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
msg = tostring(msg or "")
|
||||
if msg == "reset" then
|
||||
zButtonTrack_Reset()
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Track")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonTrack_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrack_GetRoot()
|
||||
if not root["zButtonTrack"] then
|
||||
root["zButtonTrack"] = {}
|
||||
root["zButtonTrack"]["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
root["zButtonTrack"]["rows"] = 1
|
||||
root["zButtonTrack"]["horizontal"] = nil
|
||||
root["zButtonTrack"]["vertical"] = nil
|
||||
root["zButtonTrack"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrack"]["enabled"] = 1
|
||||
root["zButtonTrack"]["tooltip"] = 1
|
||||
root["zButtonTrack"]["parent"] = {}
|
||||
root["zButtonTrack"]["parent"]["size"] = 36
|
||||
root["zButtonTrack"]["parent"]["hide"] = nil
|
||||
root["zButtonTrack"]["parent"]["circle"] = 1
|
||||
root["zButtonTrack"]["children"] = {}
|
||||
root["zButtonTrack"]["children"]["size"] = 36
|
||||
root["zButtonTrack"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Track_Spells = {
|
||||
ZHUNTER_TRACK_HIDDEN,
|
||||
ZHUNTER_TRACK_HUMANOIDS,
|
||||
ZHUNTER_TRACK_UNDEAD,
|
||||
ZHUNTER_TRACK_BEASTS,
|
||||
ZHUNTER_TRACK_DEMONS,
|
||||
ZHUNTER_TRACK_ELEMENTALS,
|
||||
ZHUNTER_TRACK_DRAGONKIN,
|
||||
ZHUNTER_TRACK_GIANTS,
|
||||
ZHUNTER_TRACK_MINERALS,
|
||||
ZHUNTER_TRACK_HERBS,
|
||||
ZHUNTER_TRACK_TREASURE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRACK_MAX = table.getn(ZHunterMod_Track_Spells)
|
||||
local zButtonTrack_LastTrackingTexture = nil
|
||||
local zButtonTrack_SyncActiveChild
|
||||
local zButtonTrack_GetSaved
|
||||
|
||||
local function zButtonTrack_NormalizeTexture(texture)
|
||||
if not texture then
|
||||
return ""
|
||||
end
|
||||
local value = string.lower(tostring(texture))
|
||||
value = string.gsub(value, "\\", "/")
|
||||
local _, _, basename = string.find(value, "([^/]+)$")
|
||||
return basename or value
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingTexture(trackingTexture)
|
||||
if not trackingTexture or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
local wanted = zButtonTrack_NormalizeTexture(trackingTexture)
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellTexture = GetSpellTexture and GetSpellTexture(child.id, "spell") or nil
|
||||
if zButtonTrack_NormalizeTexture(spellTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icon and zButtonTrack_NormalizeTexture(child.icon) == wanted then
|
||||
return child.id
|
||||
end
|
||||
if child.icontexture and child.icontexture.GetTexture then
|
||||
local childTexture = child.icontexture:GetTexture()
|
||||
if zButtonTrack_NormalizeTexture(childTexture) == wanted then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_FindSpellIdByTrackingName(trackingName)
|
||||
if not trackingName or trackingName == "" or not zButtonTrack or not zButtonTrack.count then
|
||||
return nil
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.id then
|
||||
local spellName = GetSpellName and GetSpellName(child.id, "spell") or nil
|
||||
if spellName == trackingName then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function zButtonTrack_GetActiveTrackingSpellId()
|
||||
local activeName = nil
|
||||
local activeTexture = nil
|
||||
if GetNumTrackingTypes and GetTrackingInfo then
|
||||
local numTracking = GetNumTrackingTypes() or 0
|
||||
for i = 1, numTracking do
|
||||
local name, texture, active = GetTrackingInfo(i)
|
||||
if active then
|
||||
activeName = name
|
||||
activeTexture = texture
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
local byName = zButtonTrack_FindSpellIdByTrackingName(activeName)
|
||||
if byName then
|
||||
return byName, activeTexture
|
||||
end
|
||||
if activeTexture then
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(activeTexture), activeTexture
|
||||
end
|
||||
local buff = GetTrackingTexture and GetTrackingTexture() or nil
|
||||
return zButtonTrack_FindSpellIdByTrackingTexture(buff), buff
|
||||
end
|
||||
|
||||
local function zButtonTrack_AfterClick(button)
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if button and button.id then
|
||||
zButtonTrack.id = button.id
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(button.id)
|
||||
if GetSpellTexture then
|
||||
zButtonTrack_LastTrackingTexture = GetSpellTexture(button.id, "spell") or zButtonTrack_LastTrackingTexture
|
||||
end
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_SyncActiveChild = function(activeId)
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
for i = 1, zButtonTrack.count do
|
||||
local child = getglobal("zButtonTrack" .. i)
|
||||
if child and child.SetChecked then
|
||||
child:SetChecked((activeId and child.id == activeId) and 1 or 0)
|
||||
end
|
||||
end
|
||||
if zButtonTrack.SetChecked then
|
||||
zButtonTrack:SetChecked(0)
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_RefreshTrackingState()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
local newId, trackingTexture = zButtonTrack_GetActiveTrackingSpellId()
|
||||
local buff = trackingTexture or (GetTrackingTexture and GetTrackingTexture() or nil)
|
||||
if not newId and not buff then
|
||||
if zButtonTrack.id then
|
||||
zButtonTrack_SyncActiveChild(zButtonTrack.id)
|
||||
else
|
||||
zButtonTrack_LastTrackingTexture = nil
|
||||
zButtonTrack_SyncActiveChild(nil)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not newId then
|
||||
newId = zButtonTrack.id or nil
|
||||
end
|
||||
if not newId then
|
||||
return
|
||||
end
|
||||
if zButtonTrack_NormalizeTexture(zButtonTrack_LastTrackingTexture) == zButtonTrack_NormalizeTexture(buff) and zButtonTrack.id == newId then
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
return
|
||||
end
|
||||
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonTrack)
|
||||
zButtonTrack_LastTrackingTexture = buff
|
||||
zButtonTrack.id = newId
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
zButtonTrack_SyncActiveChild(newId)
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
end
|
||||
|
||||
zButtonTrack_GetSaved = function()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
if not currentRoot["zButtonTrack"] then
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrack"]
|
||||
end
|
||||
|
||||
local function zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRACK_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrack_ApplyRuntimeSettings()
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
zButtonTrack.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrack.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonTrack.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonTrack.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrack_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrack_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrack then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrack:UnregisterAllEvents()
|
||||
zButtonTrack:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack.afterclick = zButtonTrack_AfterClick
|
||||
MTH_ZH_TrackAdjust = CreateFrame("Frame", "MTH_ZH_TrackAdjust")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("MINIMAP_UPDATE_TRACKING")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_TrackAdjust:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", MTH_ZH_TrackAdjust_OnEvent)
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_CreateButtons()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrack, "zButtonTrack", ZHUNTER_TRACK_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Track_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Track_Spells
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Track_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrack.found = ZSpellButton_SetButtons(zButtonTrack, info)
|
||||
zButtonTrack_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrack_SetupSizeAndPosition()
|
||||
zButtonTrack_EnsureConfig()
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_TrackAdjust and MTH_ZH_TrackAdjust.SetScript then
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrack and zButtonTrack.Hide then
|
||||
zButtonTrack:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_TrackAdjust and MTH_ZH_TrackAdjust.SetScript then
|
||||
MTH_ZH_TrackAdjust:SetScript("OnEvent", MTH_ZH_TrackAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrack.found or ZHUNTER_TRACK_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrack, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrack, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrack, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
|
||||
function zButtonTrack_Reset()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
currentRoot["zButtonTrack"] = {}
|
||||
local saved = zButtonTrack_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}
|
||||
zButtonTrack_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_TrackAdjust_OnEvent()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "MINIMAP_UPDATE_TRACKING" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrack_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrack"..index)
|
||||
else
|
||||
button = zButtonTrack
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrack.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrack, false)
|
||||
elseif zButtonTrack.children then
|
||||
zButtonTrack.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrack1 = "/ZTrack"
|
||||
SlashCmdList["zButtonTrack"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Track button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
msg = tostring(msg or "")
|
||||
if msg == "reset" then
|
||||
zButtonTrack_Reset()
|
||||
zButtonTrack:ClearAllPoints()
|
||||
zButtonTrack:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Track")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
+280
-278
@@ -1,279 +1,281 @@
|
||||
local function zButtonTrap_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrap_GetRoot()
|
||||
if not root["zButtonTrap"] then
|
||||
root["zButtonTrap"] = {}
|
||||
root["zButtonTrap"]["spells"] = {1, 2, 3, 4}
|
||||
root["zButtonTrap"]["rows"] = 1
|
||||
root["zButtonTrap"]["horizontal"] = nil
|
||||
root["zButtonTrap"]["vertical"] = nil
|
||||
root["zButtonTrap"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrap"]["enabled"] = 1
|
||||
root["zButtonTrap"]["tooltip"] = 1
|
||||
root["zButtonTrap"]["parent"] = {}
|
||||
root["zButtonTrap"]["parent"]["size"] = 36
|
||||
root["zButtonTrap"]["parent"]["hide"] = nil
|
||||
root["zButtonTrap"]["parent"]["circle"] = 1
|
||||
root["zButtonTrap"]["children"] = {}
|
||||
root["zButtonTrap"]["children"]["size"] = 36
|
||||
root["zButtonTrap"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Trap_Spells = {
|
||||
ZHUNTER_TRAP_FREEZING,
|
||||
ZHUNTER_TRAP_FROST,
|
||||
ZHUNTER_TRAP_IMMOLATION,
|
||||
ZHUNTER_TRAP_EXPLOSIVE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRAP_MAX = table.getn(ZHunterMod_Trap_Spells)
|
||||
local zButtonTrap_LastParentId = nil
|
||||
local zButtonTrap_LastCombatState = nil
|
||||
|
||||
local function zButtonTrap_GetSaved()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
if not currentRoot["zButtonTrap"] then
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrap"]
|
||||
end
|
||||
|
||||
local function zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRAP_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrap_ApplyRuntimeSettings()
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
zButtonTrap.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrap.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrap_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrap_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrap:UnregisterAllEvents()
|
||||
zButtonTrap:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrapAdjustment = CreateFrame("Frame", "zButtonTrapAdjustment")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
zButtonTrapAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonTrapAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonTrapAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", zButtonTrapAdjustment_OnEvent)
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_CreateButtons()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrap, "zButtonTrap", ZHUNTER_TRAP_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Trap_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Trap_Spells
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Trap_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrap.found = ZSpellButton_SetButtons(zButtonTrap, info)
|
||||
zButtonTrap_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrap_SetupSizeAndPosition()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonTrapAdjustment and zButtonTrapAdjustment.SetScript then
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrap and zButtonTrap.Hide then
|
||||
zButtonTrap:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonTrapAdjustment and zButtonTrapAdjustment.SetScript then
|
||||
zButtonTrapAdjustment:SetScript("OnEvent", zButtonTrapAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrap.found or ZHUNTER_TRAP_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrap, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrap, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonTrap_Reset()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1}
|
||||
zButtonTrap_EnsureConfig()
|
||||
end
|
||||
|
||||
function zButtonTrapAdjustment_OnEvent()
|
||||
if not zButtonTrap or not zButtonTrap.count then
|
||||
return
|
||||
end
|
||||
local rebuild = false
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
rebuild = true
|
||||
end
|
||||
local nextbutton
|
||||
local button
|
||||
local combat = event == "PLAYER_REGEN_DISABLED"
|
||||
for i=1, zButtonTrap.count do
|
||||
button = getglobal(zButtonTrap.name..i)
|
||||
button.customcolor = nil
|
||||
if button.id then
|
||||
if not nextbutton then
|
||||
nextbutton = button
|
||||
end
|
||||
if combat then
|
||||
button.icontexture:SetVertexColor(0.4, 0.4, 0.4)
|
||||
button.customcolor = 1
|
||||
else
|
||||
button.icontexture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
local newParentId = nextbutton and nextbutton.id or zButtonTrap1.id
|
||||
if (not rebuild) and zButtonTrap_LastParentId == newParentId and zButtonTrap_LastCombatState == combat and not GameTooltip:IsOwned(zButtonTrap) then
|
||||
return
|
||||
end
|
||||
zButtonTrap_LastParentId = newParentId
|
||||
zButtonTrap_LastCombatState = combat
|
||||
zButtonTrap.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonTrap)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrap)
|
||||
if GameTooltip:IsOwned(zButtonTrap) then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrap)
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrap"..index)
|
||||
else
|
||||
button = zButtonTrap
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrap.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrap, false)
|
||||
elseif zButtonTrap.children then
|
||||
zButtonTrap.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrap1 = "/ZTrap"
|
||||
SlashCmdList["zButtonTrap"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Trap button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonTrap_Reset()
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("CENTER", UIParent, "CENTER", 60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Trap")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
local function zButtonTrap_GetRoot()
|
||||
return MTH_ZH_GetSavedRoot()
|
||||
end
|
||||
|
||||
local root = zButtonTrap_GetRoot()
|
||||
if not root["zButtonTrap"] then
|
||||
root["zButtonTrap"] = {}
|
||||
root["zButtonTrap"]["spells"] = {1, 2, 3, 4}
|
||||
root["zButtonTrap"]["rows"] = 1
|
||||
root["zButtonTrap"]["horizontal"] = nil
|
||||
root["zButtonTrap"]["vertical"] = nil
|
||||
root["zButtonTrap"]["firstbutton"] = "RIGHT"
|
||||
root["zButtonTrap"]["enabled"] = 1
|
||||
root["zButtonTrap"]["tooltip"] = 1
|
||||
root["zButtonTrap"]["parent"] = {}
|
||||
root["zButtonTrap"]["parent"]["size"] = 36
|
||||
root["zButtonTrap"]["parent"]["hide"] = nil
|
||||
root["zButtonTrap"]["parent"]["circle"] = 1
|
||||
root["zButtonTrap"]["children"] = {}
|
||||
root["zButtonTrap"]["children"]["size"] = 36
|
||||
root["zButtonTrap"]["children"]["hideonclick"] = 1
|
||||
end
|
||||
|
||||
ZHunterMod_Trap_Spells = {
|
||||
ZHUNTER_TRAP_FREEZING,
|
||||
ZHUNTER_TRAP_FROST,
|
||||
ZHUNTER_TRAP_IMMOLATION,
|
||||
ZHUNTER_TRAP_EXPLOSIVE
|
||||
}
|
||||
|
||||
local ZHUNTER_TRAP_MAX = table.getn(ZHunterMod_Trap_Spells)
|
||||
local zButtonTrap_LastParentId = nil
|
||||
local zButtonTrap_LastCombatState = nil
|
||||
|
||||
local function zButtonTrap_GetSaved()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
if not currentRoot["zButtonTrap"] then
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
end
|
||||
return currentRoot["zButtonTrap"]
|
||||
end
|
||||
|
||||
local function zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["count"] = nil
|
||||
if saved["rows"] == nil then
|
||||
saved["rows"] = 1
|
||||
end
|
||||
if saved["firstbutton"] == nil then
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
end
|
||||
if saved["enabled"] == nil then
|
||||
saved["enabled"] = 1
|
||||
end
|
||||
if saved["tooltip"] == nil then
|
||||
saved["tooltip"] = 1
|
||||
end
|
||||
if not saved["parent"] then
|
||||
saved["parent"] = {}
|
||||
end
|
||||
if saved["parent"]["size"] == nil then
|
||||
saved["parent"]["size"] = 36
|
||||
end
|
||||
if saved["parent"]["circle"] == nil then
|
||||
saved["parent"]["circle"] = 1
|
||||
end
|
||||
if not saved["children"] then
|
||||
saved["children"] = {}
|
||||
end
|
||||
if saved["children"]["size"] == nil then
|
||||
saved["children"]["size"] = 36
|
||||
end
|
||||
if saved["children"]["hideonclick"] == nil then
|
||||
saved["children"]["hideonclick"] = 1
|
||||
end
|
||||
if not saved["spells"] then
|
||||
saved["spells"] = {}
|
||||
end
|
||||
if not saved["visible"] then
|
||||
saved["visible"] = {}
|
||||
end
|
||||
for i = 1, ZHUNTER_TRAP_MAX do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
saved["spells"][i] = i
|
||||
end
|
||||
if saved["visible"][i] == nil then
|
||||
saved["visible"][i] = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonTrap_ApplyRuntimeSettings()
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
zButtonTrap.tooltip = saved["tooltip"] and true or false
|
||||
zButtonTrap.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
zButtonTrap.expandonhover = saved["children"] and saved["children"]["expandonhover"] and true or false
|
||||
zButtonTrap.fadetimer = saved["children"] and tonumber(saved["children"]["fadetimer"]) or 0
|
||||
end
|
||||
|
||||
|
||||
function zButtonTrap_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
|
||||
function zButtonTrap_OnEvent()
|
||||
if event == "VARIABLES_LOADED" then
|
||||
if not zButtonTrap then
|
||||
return
|
||||
end
|
||||
if UnitClass("player") ~= ZHUNTER_HUNTER then
|
||||
zButtonTrap:UnregisterAllEvents()
|
||||
zButtonTrap:Hide()
|
||||
return
|
||||
end
|
||||
zButtonTrap_CreateButtons()
|
||||
MTH_ZH_TrapAdjust = CreateFrame("Frame", "MTH_ZH_TrapAdjust")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_REGEN_DISABLED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("SPELLS_CHANGED")
|
||||
MTH_ZH_TrapAdjust:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", MTH_ZH_TrapAdjust_OnEvent)
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_CreateButtons()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
|
||||
ZSpellButton_CreateChildren(zButtonTrap, "zButtonTrap", ZHUNTER_TRAP_MAX)
|
||||
local info = {}
|
||||
local infoIndex = 1
|
||||
for i=1, table.getn(ZHunterMod_Trap_Spells) do
|
||||
if not tonumber(saved["spells"][i]) then
|
||||
info = ZHunterMod_Trap_Spells
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
break
|
||||
end
|
||||
local spellIndex = saved["spells"][i]
|
||||
if saved["visible"][spellIndex] ~= false then
|
||||
info[infoIndex] = ZHunterMod_Trap_Spells[spellIndex]
|
||||
infoIndex = infoIndex + 1
|
||||
end
|
||||
end
|
||||
zButtonTrap.found = ZSpellButton_SetButtons(zButtonTrap, info)
|
||||
zButtonTrap_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
function zButtonTrap_SetupSizeAndPosition()
|
||||
zButtonTrap_EnsureConfig()
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if MTH_ZH_TrapAdjust and MTH_ZH_TrapAdjust.SetScript then
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonTrap and zButtonTrap.Hide then
|
||||
zButtonTrap:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if MTH_ZH_TrapAdjust and MTH_ZH_TrapAdjust.SetScript then
|
||||
MTH_ZH_TrapAdjust:SetScript("OnEvent", MTH_ZH_TrapAdjust_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonTrap.found or ZHUNTER_TRAP_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
end
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["parent"]["size"])
|
||||
ZSpellButton_SetSize(zButtonTrap, saved["children"]["size"], 1)
|
||||
ZSpellButton_SetExpandDirection(zButtonTrap, saved["firstbutton"])
|
||||
ZSpellButton_ArrangeChildren(zButtonTrap, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
end
|
||||
|
||||
function zButtonTrap_Reset()
|
||||
local currentRoot = zButtonTrap_GetRoot()
|
||||
currentRoot["zButtonTrap"] = {}
|
||||
local saved = zButtonTrap_GetSaved()
|
||||
saved["spells"] = {1, 2, 3, 4}
|
||||
saved["rows"] = 1
|
||||
saved["horizontal"] = nil
|
||||
saved["vertical"] = nil
|
||||
saved["firstbutton"] = "RIGHT"
|
||||
saved["enabled"] = 1
|
||||
saved["tooltip"] = 1
|
||||
saved["parent"] = {}
|
||||
saved["parent"]["size"] = 36
|
||||
saved["parent"]["hide"] = nil
|
||||
saved["parent"]["circle"] = 1
|
||||
saved["children"] = {}
|
||||
saved["children"]["size"] = 36
|
||||
saved["children"]["hideonclick"] = 1
|
||||
saved["visible"] = {1, 1, 1, 1}
|
||||
zButtonTrap_EnsureConfig()
|
||||
end
|
||||
|
||||
function MTH_ZH_TrapAdjust_OnEvent()
|
||||
if not zButtonTrap or not zButtonTrap.count then
|
||||
return
|
||||
end
|
||||
local rebuild = false
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
zButtonTrap_CreateButtons()
|
||||
zButtonTrap_SetupSizeAndPosition()
|
||||
rebuild = true
|
||||
end
|
||||
local nextbutton
|
||||
local button
|
||||
local combat = event == "PLAYER_REGEN_DISABLED"
|
||||
for i=1, zButtonTrap.count do
|
||||
button = getglobal(zButtonTrap.name..i)
|
||||
button.customcolor = nil
|
||||
if button.id then
|
||||
if not nextbutton then
|
||||
nextbutton = button
|
||||
end
|
||||
if combat then
|
||||
button.icontexture:SetVertexColor(0.4, 0.4, 0.4)
|
||||
button.customcolor = 1
|
||||
else
|
||||
button.icontexture:SetVertexColor(1.0, 1.0, 1.0)
|
||||
end
|
||||
end
|
||||
end
|
||||
local newParentId = nextbutton and nextbutton.id or zButtonTrap1.id
|
||||
if (not rebuild) and zButtonTrap_LastParentId == newParentId and zButtonTrap_LastCombatState == combat and not GameTooltip:IsOwned(zButtonTrap) then
|
||||
return
|
||||
end
|
||||
zButtonTrap_LastParentId = newParentId
|
||||
zButtonTrap_LastCombatState = combat
|
||||
zButtonTrap.id = newParentId
|
||||
ZSpellButton_UpdateButton(zButtonTrap)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrap)
|
||||
if GameTooltip:IsOwned(zButtonTrap) then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrap)
|
||||
end
|
||||
end
|
||||
|
||||
function zButtonTrap_KeyBinding(index)
|
||||
if MTH_ZH_IsModuleEnabled and not MTH_ZH_IsModuleEnabled() then
|
||||
return
|
||||
end
|
||||
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrap"..index)
|
||||
else
|
||||
button = zButtonTrap
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrap.hideonclick then
|
||||
if type(ZSpellButton_SetChildrenExpanded) == "function" then
|
||||
ZSpellButton_SetChildrenExpanded(zButtonTrap, false)
|
||||
elseif zButtonTrap.children then
|
||||
zButtonTrap.children:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
SLASH_zButtonTrap1 = "/ZTrap"
|
||||
SlashCmdList["zButtonTrap"] = function(msg)
|
||||
if MTH_ZH_HandleDisabledSlash and MTH_ZH_HandleDisabledSlash("Trap button is disabled while module 'zhunter' is disabled.") then
|
||||
return
|
||||
end
|
||||
if msg == "reset" then
|
||||
zButtonTrap_Reset()
|
||||
zButtonTrap:ClearAllPoints()
|
||||
zButtonTrap:SetPoint("CENTER", UIParent, "CENTER", 60, 0)
|
||||
elseif msg == "options" then
|
||||
MTH_OpenOptions("Trap")
|
||||
else
|
||||
MTH_ZH_Print("Possible Commands: \"options\", \"reset\"")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user