mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-27 18:16:04 +00:00
v1.0.5
This commit is contained in:
@@ -36,6 +36,156 @@ ZHunterMod_Track_Spells = {
|
||||
}
|
||||
|
||||
local ZHUNTER_TRACK_MAX = table.getn(ZHunterMod_Track_Spells)
|
||||
local zButtonTrack_LastTrackingTexture = nil
|
||||
local zButtonTrack_SyncActiveChild
|
||||
|
||||
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
|
||||
|
||||
local function zButtonTrack_GetSaved()
|
||||
local currentRoot = zButtonTrack_GetRoot()
|
||||
@@ -119,11 +269,10 @@ function zButtonTrack_OnEvent()
|
||||
return
|
||||
end
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack.afterclick = zButtonTrack_AfterClick
|
||||
zButtonTrackAdjustment = CreateFrame("Frame", "zButtonTrackAdjustment")
|
||||
zButtonTrackAdjustment:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("MINIMAP_UPDATE_TRACKING")
|
||||
zButtonTrackAdjustment:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
zButtonTrackAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonTrackAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonTrackAdjustment:SetScript("OnEvent", zButtonTrackAdjustment_OnEvent)
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
@@ -156,11 +305,17 @@ 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
|
||||
@@ -171,6 +326,7 @@ function zButtonTrack_SetupSizeAndPosition()
|
||||
ZSpellButton_ArrangeChildren(zButtonTrack, saved["rows"],
|
||||
displayCount, saved["horizontal"],
|
||||
saved["vertical"])
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
|
||||
function zButtonTrack_Reset()
|
||||
@@ -199,25 +355,9 @@ function zButtonTrackAdjustment_OnEvent()
|
||||
if not zButtonTrack or not zButtonTrack.count then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
zButtonTrack_CreateButtons()
|
||||
zButtonTrack_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "PLAYER_AURAS_CHANGED" or event == "PLAYER_ENTERING_WORLD"
|
||||
or event == "SPELLS_CHANGED" or event == "CHARACTER_POINTS_CHANGED" then
|
||||
local i = 1
|
||||
local texture = zButtonTrack1IconTexture:GetTexture()
|
||||
local buff = GetTrackingTexture()
|
||||
if texture == buff and zButtonTrack2.id then
|
||||
zButtonTrack.id = zButtonTrack2.id
|
||||
else
|
||||
zButtonTrack.id = zButtonTrack1.id
|
||||
end
|
||||
ZSpellButton_UpdateButton(zButtonTrack)
|
||||
ZSpellButton_UpdateCooldown(zButtonTrack)
|
||||
if GameTooltip:IsOwned(zButtonTrack) then
|
||||
ZSpellButtonParent_OnEnter(zButtonTrack)
|
||||
end
|
||||
if event == "MINIMAP_UPDATE_TRACKING" or event == "PLAYER_ENTERING_WORLD"
|
||||
then
|
||||
zButtonTrack_RefreshTrackingState()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -229,9 +369,9 @@ function zButtonTrack_KeyBinding(index)
|
||||
local button
|
||||
if index then
|
||||
button = getglobal("zButtonTrack"..index)
|
||||
else
|
||||
else
|
||||
button = zButtonTrack
|
||||
end
|
||||
end
|
||||
if button.id then
|
||||
CastSpell(button.id, "spell")
|
||||
if zButtonTrack.hideonclick then
|
||||
|
||||
Reference in New Issue
Block a user