mirror of
https://codeberg.org/Duvelcorp/MetaHunt.git
synced 2026-09-29 02:56:04 +00:00
v1.0.5
This commit is contained in:
@@ -9,6 +9,10 @@ local Engine = MTH_AutoBuyEngine
|
||||
local AB_AMMO_BY_NAME = nil
|
||||
local AB_FOOD_DIET_BY_ITEM_ID = nil
|
||||
|
||||
local function AB_Trace(message)
|
||||
return
|
||||
end
|
||||
|
||||
local function AB_ParseItemIdFromLink(link)
|
||||
if type(link) ~= "string" then
|
||||
return nil
|
||||
@@ -589,15 +593,40 @@ local function AB_EnsureRuleList(bucket)
|
||||
return bucket
|
||||
end
|
||||
|
||||
local function AB_DeepCopy(value)
|
||||
if type(value) ~= "table" then
|
||||
return value
|
||||
end
|
||||
local copy = {}
|
||||
for key, entry in pairs(value) do
|
||||
copy[key] = AB_DeepCopy(entry)
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
function Engine:GetConfigStore()
|
||||
if MTH and MTH.GetModuleSavedVariables then
|
||||
local store = MTH:GetModuleSavedVariables("autobuy")
|
||||
if type(store) == "table" then
|
||||
return store
|
||||
if MTH and MTH.GetModuleCharSavedVariables then
|
||||
local charStore = MTH:GetModuleCharSavedVariables("autobuy")
|
||||
if type(charStore) == "table" then
|
||||
if MTH.GetModuleSavedVariables then
|
||||
local accountStore = MTH:GetModuleSavedVariables("autobuy")
|
||||
if type(accountStore) == "table" and next(charStore) == nil and next(accountStore) ~= nil then
|
||||
for key, value in pairs(accountStore) do
|
||||
charStore[key] = AB_DeepCopy(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
return charStore
|
||||
end
|
||||
end
|
||||
MTH_AutoBuy_Saved = MTH_AutoBuy_Saved or {}
|
||||
return MTH_AutoBuy_Saved
|
||||
if MTH and MTH.GetModuleSavedVariables then
|
||||
local accountStore = MTH:GetModuleSavedVariables("autobuy")
|
||||
if type(accountStore) == "table" then
|
||||
return accountStore
|
||||
end
|
||||
end
|
||||
self._transientStore = self._transientStore or {}
|
||||
return self._transientStore
|
||||
end
|
||||
|
||||
function Engine:EnsureDefaults()
|
||||
@@ -1151,6 +1180,7 @@ end
|
||||
|
||||
function Engine:ExecutePlan(plan)
|
||||
if type(plan) ~= "table" or type(plan.actions) ~= "table" then
|
||||
AB_Trace("ExecutePlan skipped: invalid plan table")
|
||||
return 0, 0
|
||||
end
|
||||
local executedActions = 0
|
||||
@@ -1159,6 +1189,10 @@ function Engine:ExecutePlan(plan)
|
||||
if type(action) == "table" and action.index then
|
||||
local stacksToBuy = math.floor(tonumber(action.quantityStacks) or 0)
|
||||
if stacksToBuy > 0 then
|
||||
AB_Trace("ExecutePlan action index=" .. tostring(action.index)
|
||||
.. " itemId=" .. tostring(action.itemId)
|
||||
.. " stacks=" .. tostring(stacksToBuy)
|
||||
.. " reason=" .. tostring(plan.reason or ""))
|
||||
for i = 1, stacksToBuy do
|
||||
BuyMerchantItem(action.index)
|
||||
end
|
||||
@@ -1167,6 +1201,7 @@ function Engine:ExecutePlan(plan)
|
||||
end
|
||||
end
|
||||
end
|
||||
AB_Trace("ExecutePlan done actions=" .. tostring(executedActions) .. " stacks=" .. tostring(requestedStacks) .. " reason=" .. tostring(plan.reason or ""))
|
||||
return executedActions, requestedStacks
|
||||
end
|
||||
|
||||
@@ -1229,24 +1264,42 @@ local function AB_AnnouncePurchases(actions)
|
||||
end
|
||||
|
||||
function Engine:OnMerchantEvent(eventName)
|
||||
AB_Trace("OnMerchantEvent start event=" .. tostring(eventName)
|
||||
.. " sessionExecuted=" .. tostring(self._merchantSessionExecuted and true or false)
|
||||
.. " engineEnabled=" .. tostring(self:IsEnabled() and true or false))
|
||||
|
||||
if eventName == "MERCHANT_SHOW" then
|
||||
self._merchantSessionExecuted = false
|
||||
AB_Trace("MERCHANT_SHOW resets session execution flag")
|
||||
elseif eventName == "MERCHANT_UPDATE" and self._merchantSessionExecuted then
|
||||
AB_Trace("MERCHANT_UPDATE ignored: already executed this merchant session")
|
||||
return
|
||||
end
|
||||
|
||||
if not self:IsEnabled() then
|
||||
AB_Trace("event ignored: autobuy module disabled")
|
||||
return
|
||||
end
|
||||
|
||||
local snapshot = self:ScanMerchant()
|
||||
AB_Trace("snapshot rows=" .. tostring(snapshot and snapshot.count or 0))
|
||||
local foodPlan = self:BuildFoodPlan(snapshot)
|
||||
local ammoPlan = self:BuildAmmoPlan(snapshot)
|
||||
|
||||
AB_Trace("foodPlan reason=" .. tostring(foodPlan.reason) .. " actions=" .. tostring(table.getn(foodPlan.actions or {})))
|
||||
for i = 1, table.getn(foodPlan.debugLines or {}) do
|
||||
AB_Trace("food#" .. tostring(i) .. " " .. tostring(foodPlan.debugLines[i]))
|
||||
end
|
||||
AB_Trace("ammoPlan reason=" .. tostring(ammoPlan.reason) .. " actions=" .. tostring(table.getn(ammoPlan.actions or {})))
|
||||
for i = 1, table.getn(ammoPlan.debugLines or {}) do
|
||||
AB_Trace("ammo#" .. tostring(i) .. " " .. tostring(ammoPlan.debugLines[i]))
|
||||
end
|
||||
|
||||
local totalRequestedStacks = 0
|
||||
if table.getn(foodPlan.actions or {}) > 0 then
|
||||
local _, requestedStacks = self:ExecutePlan(foodPlan)
|
||||
totalRequestedStacks = totalRequestedStacks + requestedStacks
|
||||
AB_Trace("food plan executed requestedStacks=" .. tostring(requestedStacks))
|
||||
if requestedStacks > 0 then
|
||||
AB_AnnouncePurchases(foodPlan.actions)
|
||||
end
|
||||
@@ -1255,14 +1308,19 @@ function Engine:OnMerchantEvent(eventName)
|
||||
if table.getn(ammoPlan.actions or {}) > 0 then
|
||||
local _, requestedStacks = self:ExecutePlan(ammoPlan)
|
||||
totalRequestedStacks = totalRequestedStacks + requestedStacks
|
||||
AB_Trace("ammo plan executed requestedStacks=" .. tostring(requestedStacks))
|
||||
if requestedStacks > 0 then
|
||||
AB_MoveAmmoStacksToSpecialBags(300)
|
||||
local moved = AB_MoveAmmoStacksToSpecialBags(300)
|
||||
AB_Trace("ammo restack moved=" .. tostring(moved))
|
||||
AB_AnnouncePurchases(ammoPlan.actions)
|
||||
end
|
||||
end
|
||||
|
||||
if totalRequestedStacks > 0 then
|
||||
self._merchantSessionExecuted = true
|
||||
AB_Trace("session marked executed requestedStacks=" .. tostring(totalRequestedStacks))
|
||||
else
|
||||
AB_Trace("no purchases requested in this event")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
+32
-13
@@ -6,7 +6,7 @@
|
||||
local MTH_AutoBuy = {
|
||||
name = "autobuy",
|
||||
enabled = false,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"MERCHANT_SHOW",
|
||||
@@ -39,7 +39,6 @@ local function AB_EnsureBridgeFrame(moduleRef)
|
||||
return nil
|
||||
end
|
||||
|
||||
frame:RegisterEvent("VARIABLES_LOADED")
|
||||
frame:RegisterEvent("MERCHANT_SHOW")
|
||||
frame:RegisterEvent("MERCHANT_UPDATE")
|
||||
frame:RegisterEvent("MERCHANT_CLOSED")
|
||||
@@ -51,14 +50,6 @@ local function AB_EnsureBridgeFrame(moduleRef)
|
||||
return
|
||||
end
|
||||
|
||||
if eventName == "VARIABLES_LOADED" then
|
||||
engine:Init()
|
||||
local store = engine:EnsureDefaults()
|
||||
AB_Trace("bridge VARIABLES_LOADED store.enabled=" .. tostring(store and store.enabled)
|
||||
.. " projectiles.enabled=" .. tostring(store and store.projectiles and store.projectiles.enabled))
|
||||
return
|
||||
end
|
||||
|
||||
if eventName == "MERCHANT_SHOW" or eventName == "MERCHANT_UPDATE" then
|
||||
AB_Trace("bridge " .. tostring(eventName) .. " -> engine")
|
||||
engine:OnMerchantEvent(eventName)
|
||||
@@ -75,6 +66,34 @@ local function AB_EnsureBridgeFrame(moduleRef)
|
||||
return frame
|
||||
end
|
||||
|
||||
local function AB_SetBridgeActive(active)
|
||||
local frame = MTH_AutoBuy._bridgeFrame
|
||||
if active then
|
||||
if not frame then
|
||||
frame = AB_EnsureBridgeFrame(MTH_AutoBuy)
|
||||
end
|
||||
if frame then
|
||||
frame:RegisterEvent("MERCHANT_SHOW")
|
||||
frame:RegisterEvent("MERCHANT_UPDATE")
|
||||
frame:RegisterEvent("MERCHANT_CLOSED")
|
||||
MTH_AutoBuy._bridgeActive = true
|
||||
AB_Trace("bridge active=true")
|
||||
else
|
||||
MTH_AutoBuy._bridgeActive = false
|
||||
AB_Trace("bridge active=false (frame missing)")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if frame then
|
||||
frame:UnregisterEvent("MERCHANT_SHOW")
|
||||
frame:UnregisterEvent("MERCHANT_UPDATE")
|
||||
frame:UnregisterEvent("MERCHANT_CLOSED")
|
||||
end
|
||||
MTH_AutoBuy._bridgeActive = false
|
||||
AB_Trace("bridge active=false")
|
||||
end
|
||||
|
||||
AB_Engine = function()
|
||||
return MTH_AutoBuyEngine
|
||||
end
|
||||
@@ -87,8 +106,8 @@ function MTH_AutoBuy:init()
|
||||
return
|
||||
end
|
||||
engine:Init()
|
||||
AB_EnsureBridgeFrame(self)
|
||||
self.initialized = true
|
||||
AB_SetBridgeActive(self.enabled and true or false)
|
||||
AB_Trace("init done")
|
||||
if self.enabled then
|
||||
AB_Log("module initialized", "debug")
|
||||
@@ -106,7 +125,7 @@ function MTH_AutoBuy:setEnabled(enabled)
|
||||
end
|
||||
local store = engine:EnsureDefaults()
|
||||
store.enabled = enabled and true or false
|
||||
AB_EnsureBridgeFrame(self)
|
||||
AB_SetBridgeActive(store.enabled and true or false)
|
||||
AB_Trace("setEnabled store.enabled=" .. tostring(store.enabled))
|
||||
end
|
||||
|
||||
@@ -125,7 +144,7 @@ function MTH_AutoBuy:onEvent(event)
|
||||
|
||||
if event == "VARIABLES_LOADED" then
|
||||
engine:Init()
|
||||
AB_EnsureBridgeFrame(self)
|
||||
AB_SetBridgeActive(self.enabled and true or false)
|
||||
AB_Log("onEvent VARIABLES_LOADED -> engine init", "debug")
|
||||
local store = engine:EnsureDefaults()
|
||||
AB_Trace("VARIABLES_LOADED module.enabled=" .. tostring(self.enabled)
|
||||
|
||||
@@ -45,7 +45,8 @@ function MTH_ChronometerHunterInstallData(engine)
|
||||
engine:AddTimer(engine.EVENT, BS["Improved Concussive Shot"], 3, 1, 0, 0, { a = 1, cr = "BLUE", xn = BS["Concussive Shot"] })
|
||||
engine:AddTimer(engine.EVENT, BS["Improved Wing Clip"], 5, 1, 0, 0, { a = 1, cr = "YELLOW", xn = BS["Wing Clip"] })
|
||||
engine:AddTimer(engine.EVENT, BS["Piercing Shot"], 8, 1, 0, 1, { a = 1, cr = "PURPLE", tx = "Interface\\Icons\\Ability_Hunter_DisarmingShot" })
|
||||
engine:AddTimer(engine.EVENT, BS["Quick Shots"], 12, 0, 1, 1, { a = 1, cr = "MAROON", tx = "Interface\\Icons\\Ability_Hunter_Quickshot" })
|
||||
engine:AddTimer(engine.EVENT, BS["Quick Shots"], 12, 0, 1, 1, { a = 1, cr = "MAROON", tx = "Interface\\Icons\\Ability_Warrior_InnerRage" })
|
||||
engine:AddTimer(engine.EVENT, BS["Wing Clip"], 10, 1, 0, 1, { a = 1, cr = "YELLOW" })
|
||||
engine:AddTimer(engine.EVENT, BS["Scorpid Poison"], 10, 1, 0, 0, { gr = 3, cr = "PURPLE", a = 1, dn = 1 })
|
||||
engine:AddTimer(engine.EVENT, BS["Devilsaur Fury"], 20, 0, 1, 1, { a = 1, cr = "PURPLE", xn = BS["Devilsaur Eye"], tx = "Interface\\Icons\\Ability_Hunter_Pet_Raptor" })
|
||||
engine:AddTimer(engine.EVENT, BS["Restless Strength"], 20, 0, 1, 1, { a = 1, cr = "PURPLE", xn = BS["Zandalarian Hero Medallion"], tx = "Interface\\Icons\\INV_Jewelry_Necklace_13" })
|
||||
|
||||
@@ -143,12 +143,32 @@ local function shallowCopy(source)
|
||||
return dest
|
||||
end
|
||||
|
||||
local function deepCopyValue(value)
|
||||
if type(value) ~= "table" then
|
||||
return value
|
||||
end
|
||||
local copy = {}
|
||||
for key, entry in pairs(value) do
|
||||
copy[key] = deepCopyValue(entry)
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
local function ensureProfile()
|
||||
if not MTH or not MTH.GetModuleSavedVariables then
|
||||
if not MTH or not MTH.GetModuleCharSavedVariables then
|
||||
return shallowCopy(DEFAULTS)
|
||||
end
|
||||
|
||||
local store = MTH:GetModuleSavedVariables("chronometer")
|
||||
local store = MTH:GetModuleCharSavedVariables("chronometer")
|
||||
if type(store) ~= "table" then
|
||||
return shallowCopy(DEFAULTS)
|
||||
end
|
||||
if type(store.profile) ~= "table" and MTH.GetModuleSavedVariables then
|
||||
local accountStore = MTH:GetModuleSavedVariables("chronometer")
|
||||
if type(accountStore) == "table" and type(accountStore.profile) == "table" then
|
||||
store.profile = deepCopyValue(accountStore.profile)
|
||||
end
|
||||
end
|
||||
if type(store.profile) ~= "table" then
|
||||
store.profile = {}
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local MTH_ChronometerModule = {
|
||||
name = "chronometer",
|
||||
enabled = true,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {},
|
||||
initialized = false,
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
local MTH_FeedOMatic = {
|
||||
name = "feedomatic",
|
||||
enabled = false,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"MERCHANT_SHOW",
|
||||
@@ -137,47 +137,31 @@ local function MTH_FeedOMatic_SyncSavedVariables()
|
||||
moduleStore.legacy = {}
|
||||
end
|
||||
|
||||
if type(FOM_Config) == "table" then
|
||||
moduleStore.legacy.FOM_Config = FOM_Config
|
||||
elseif type(moduleStore.legacy.FOM_Config) == "table" then
|
||||
FOM_Config = moduleStore.legacy.FOM_Config
|
||||
local function bindLegacyTable(globalName)
|
||||
local legacyValue = moduleStore.legacy[globalName]
|
||||
local globalValue = _G and _G[globalName] or nil
|
||||
|
||||
if type(legacyValue) ~= "table" then
|
||||
if type(globalValue) == "table" then
|
||||
legacyValue = globalValue
|
||||
else
|
||||
legacyValue = {}
|
||||
end
|
||||
moduleStore.legacy[globalName] = legacyValue
|
||||
end
|
||||
|
||||
if _G then
|
||||
_G[globalName] = legacyValue
|
||||
end
|
||||
end
|
||||
|
||||
if type(FOM_FoodQuality) == "table" then
|
||||
moduleStore.legacy.FOM_FoodQuality = FOM_FoodQuality
|
||||
elseif type(moduleStore.legacy.FOM_FoodQuality) == "table" then
|
||||
FOM_FoodQuality = moduleStore.legacy.FOM_FoodQuality
|
||||
end
|
||||
|
||||
if type(FOM_AddedFoods) == "table" then
|
||||
moduleStore.legacy.FOM_AddedFoods = FOM_AddedFoods
|
||||
elseif type(moduleStore.legacy.FOM_AddedFoods) == "table" then
|
||||
FOM_AddedFoods = moduleStore.legacy.FOM_AddedFoods
|
||||
end
|
||||
|
||||
if type(FOM_RemovedFoods) == "table" then
|
||||
moduleStore.legacy.FOM_RemovedFoods = FOM_RemovedFoods
|
||||
elseif type(moduleStore.legacy.FOM_RemovedFoods) == "table" then
|
||||
FOM_RemovedFoods = moduleStore.legacy.FOM_RemovedFoods
|
||||
end
|
||||
|
||||
if type(FOM_Cooking) == "table" then
|
||||
moduleStore.legacy.FOM_Cooking = FOM_Cooking
|
||||
elseif type(moduleStore.legacy.FOM_Cooking) == "table" then
|
||||
FOM_Cooking = moduleStore.legacy.FOM_Cooking
|
||||
end
|
||||
|
||||
if type(FOM_QuestFood) == "table" then
|
||||
moduleStore.legacy.FOM_QuestFood = FOM_QuestFood
|
||||
elseif type(moduleStore.legacy.FOM_QuestFood) == "table" then
|
||||
FOM_QuestFood = moduleStore.legacy.FOM_QuestFood
|
||||
end
|
||||
|
||||
if type(FOM_LocaleInfo) == "table" then
|
||||
moduleStore.legacy.FOM_LocaleInfo = FOM_LocaleInfo
|
||||
elseif type(moduleStore.legacy.FOM_LocaleInfo) == "table" then
|
||||
FOM_LocaleInfo = moduleStore.legacy.FOM_LocaleInfo
|
||||
end
|
||||
bindLegacyTable("FOM_Config")
|
||||
bindLegacyTable("FOM_FoodQuality")
|
||||
bindLegacyTable("FOM_AddedFoods")
|
||||
bindLegacyTable("FOM_RemovedFoods")
|
||||
bindLegacyTable("FOM_Cooking")
|
||||
bindLegacyTable("FOM_QuestFood")
|
||||
bindLegacyTable("FOM_LocaleInfo")
|
||||
end
|
||||
|
||||
local function MTH_FeedOMatic_Log(message, severity)
|
||||
@@ -231,6 +215,14 @@ local function MTH_FeedOMatic_DebugMerchantScan(sourceEvent)
|
||||
end
|
||||
|
||||
local function MTH_FeedOMatic_SetMerchantProbeEnabled(enabled)
|
||||
if not enabled then
|
||||
if MTH_FeedOMatic_MerchantProbeFrame then
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_UPDATE")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not MTH_FeedOMatic_MerchantProbeFrame then
|
||||
MTH_FeedOMatic_MerchantProbeFrame = CreateFrame("Frame", "MTH_FeedOMatic_MerchantProbeFrame")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:SetScript("OnEvent", function()
|
||||
@@ -242,14 +234,9 @@ local function MTH_FeedOMatic_SetMerchantProbeEnabled(enabled)
|
||||
end)
|
||||
end
|
||||
|
||||
if enabled then
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_UPDATE")
|
||||
MTH_FeedOMatic_Log("merchant probe enabled", "debug")
|
||||
else
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:UnregisterEvent("MERCHANT_UPDATE")
|
||||
end
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_SHOW")
|
||||
MTH_FeedOMatic_MerchantProbeFrame:RegisterEvent("MERCHANT_UPDATE")
|
||||
MTH_FeedOMatic_Log("merchant probe enabled", "debug")
|
||||
end
|
||||
|
||||
function MTH_FeedOMatic:init()
|
||||
|
||||
@@ -155,7 +155,8 @@ MTH_SA_List = {}
|
||||
|
||||
MTH_SA_LastCheck = 0
|
||||
|
||||
MTH_SA_Tooltip = CreateFrame("GameTooltip", "MTH_SA_Tooltip", nil, "GameTooltipTemplate")
|
||||
MTH_SA_Tooltip = CreateFrame("GameTooltip", "MTH_SA_Scan", nil, "GameTooltipTemplate")
|
||||
MTH_SA_TooltipTextLeft1 = getglobal("MTH_SA_ScanTextLeft1")
|
||||
MTH_SA_Tooltip:Hide()
|
||||
|
||||
local _, class = UnitClass("player")
|
||||
|
||||
@@ -7,7 +7,7 @@ MTH_SA_MANAGED_HOOKS = true
|
||||
local MTH_SmartAmmo = {
|
||||
name = "smartammo",
|
||||
enabled = true,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"PLAYER_ENTERING_WORLD",
|
||||
|
||||
+122
-11
@@ -6,7 +6,7 @@
|
||||
local MTH_Tooltips = {
|
||||
name = "tooltips",
|
||||
enabled = true,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {
|
||||
"UPDATE_MOUSEOVER_UNIT",
|
||||
"UNIT_NAME_UPDATE",
|
||||
@@ -34,14 +34,33 @@ local MTH_Tooltips = {
|
||||
injectFrame = nil,
|
||||
pollFrame = nil,
|
||||
pollElapsed = 0,
|
||||
hintElapsed = 0,
|
||||
lastMouseoverKey = "",
|
||||
}
|
||||
|
||||
local function MTH_TT_CopyValue(value)
|
||||
if type(value) ~= "table" then
|
||||
return value
|
||||
end
|
||||
local copy = {}
|
||||
for key, entry in pairs(value) do
|
||||
copy[key] = MTH_TT_CopyValue(entry)
|
||||
end
|
||||
return copy
|
||||
end
|
||||
|
||||
local function MTH_TT_GetOptionsStore()
|
||||
if MTH and MTH.GetModuleSavedVariables then
|
||||
local store = MTH:GetModuleSavedVariables("tooltips")
|
||||
if MTH and MTH.GetModuleCharSavedVariables then
|
||||
local store = MTH:GetModuleCharSavedVariables("tooltips")
|
||||
if type(store) == "table" then
|
||||
if MTH.GetModuleSavedVariables and next(store) == nil then
|
||||
local accountStore = MTH:GetModuleSavedVariables("tooltips")
|
||||
if type(accountStore) == "table" and next(accountStore) ~= nil then
|
||||
for key, value in pairs(accountStore) do
|
||||
store[key] = MTH_TT_CopyValue(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
if store.beastTooltips == nil then
|
||||
store.beastTooltips = true
|
||||
end
|
||||
@@ -1165,16 +1184,21 @@ local function MTH_TT_EnsureInjectFrame()
|
||||
end
|
||||
local frame = CreateFrame("Frame", "MTH_TooltipsInjectFrame")
|
||||
frame.pending = false
|
||||
frame:SetScript("OnUpdate", function(self)
|
||||
frame.onUpdate = function(self)
|
||||
self = self or this
|
||||
if not self or not self.pending then
|
||||
if not self then
|
||||
return
|
||||
end
|
||||
if not self.pending then
|
||||
self:SetScript("OnUpdate", nil)
|
||||
return
|
||||
end
|
||||
self.pending = false
|
||||
self:SetScript("OnUpdate", nil)
|
||||
if MTH_Tooltips and MTH_Tooltips.enabled then
|
||||
MTH_TT_AddTooltip("mouseover")
|
||||
end
|
||||
end)
|
||||
end
|
||||
MTH_Tooltips.injectFrame = frame
|
||||
return frame
|
||||
end
|
||||
@@ -1183,6 +1207,9 @@ local function MTH_TT_RequestInject()
|
||||
local frame = MTH_TT_EnsureInjectFrame()
|
||||
if frame then
|
||||
frame.pending = true
|
||||
if not frame:GetScript("OnUpdate") then
|
||||
frame:SetScript("OnUpdate", frame.onUpdate)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1197,14 +1224,18 @@ local function MTH_TT_EnsurePollFrame()
|
||||
return
|
||||
end
|
||||
|
||||
if GameTooltip and GameTooltip.IsShown and GameTooltip:IsShown() then
|
||||
MTH_TT_AddOwnPetTooltipHint()
|
||||
if not MTH_TT_HasExistingNotLearnedLine() then
|
||||
MTH_TT_AddPetActionNotLearnedHint()
|
||||
elapsed = elapsed or arg1
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (elapsed or 0)
|
||||
if MTH_Tooltips.hintElapsed >= 0.25 then
|
||||
MTH_Tooltips.hintElapsed = 0
|
||||
if GameTooltip and GameTooltip.IsShown and GameTooltip:IsShown() then
|
||||
MTH_TT_AddOwnPetTooltipHint()
|
||||
if not MTH_TT_HasExistingNotLearnedLine() then
|
||||
MTH_TT_AddPetActionNotLearnedHint()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
elapsed = elapsed or arg1
|
||||
MTH_Tooltips.pollElapsed = (MTH_Tooltips.pollElapsed or 0) + (elapsed or 0)
|
||||
if MTH_Tooltips.pollElapsed < 0.15 then
|
||||
return
|
||||
@@ -1242,6 +1273,75 @@ local function MTH_TT_EnsurePollFrame()
|
||||
return frame
|
||||
end
|
||||
|
||||
local function MTH_TT_SetRuntimeActive(active)
|
||||
local injectFrame = MTH_Tooltips.injectFrame
|
||||
if injectFrame then
|
||||
if not active then
|
||||
injectFrame.pending = false
|
||||
injectFrame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
|
||||
local pollFrame = MTH_Tooltips.pollFrame
|
||||
if pollFrame then
|
||||
if active then
|
||||
pollFrame:SetScript("OnUpdate", pollFrame:GetScript("OnUpdate") or function(_, elapsed)
|
||||
if not (MTH_Tooltips and MTH_Tooltips.enabled) then
|
||||
return
|
||||
end
|
||||
|
||||
elapsed = elapsed or arg1
|
||||
MTH_Tooltips.hintElapsed = (MTH_Tooltips.hintElapsed or 0) + (elapsed or 0)
|
||||
if MTH_Tooltips.hintElapsed >= 0.25 then
|
||||
MTH_Tooltips.hintElapsed = 0
|
||||
if GameTooltip and GameTooltip.IsShown and GameTooltip:IsShown() then
|
||||
MTH_TT_AddOwnPetTooltipHint()
|
||||
if not MTH_TT_HasExistingNotLearnedLine() then
|
||||
MTH_TT_AddPetActionNotLearnedHint()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MTH_Tooltips.pollElapsed = (MTH_Tooltips.pollElapsed or 0) + (elapsed or 0)
|
||||
if MTH_Tooltips.pollElapsed < 0.15 then
|
||||
return
|
||||
end
|
||||
MTH_Tooltips.pollElapsed = 0
|
||||
|
||||
local state = MTH_Tooltips.debugState
|
||||
state.pollTicks = (state.pollTicks or 0) + 1
|
||||
|
||||
if not UnitExists("mouseover") then
|
||||
MTH_Tooltips.lastMouseoverKey = ""
|
||||
return
|
||||
end
|
||||
|
||||
local name = UnitName("mouseover")
|
||||
if not name or name == "" then
|
||||
return
|
||||
end
|
||||
local lvl = UnitLevel and UnitLevel("mouseover") or 0
|
||||
local key = tostring(name) .. "#" .. tostring(lvl)
|
||||
|
||||
if key ~= MTH_Tooltips.lastMouseoverKey then
|
||||
MTH_Tooltips.lastMouseoverKey = key
|
||||
state.pollTriggers = (state.pollTriggers or 0) + 1
|
||||
MTH_TT_RequestInject()
|
||||
return
|
||||
end
|
||||
|
||||
if not MTH_TT_HasExistingTooltipLine() then
|
||||
MTH_TT_RequestInject()
|
||||
end
|
||||
end)
|
||||
else
|
||||
MTH_Tooltips.pollElapsed = 0
|
||||
MTH_Tooltips.hintElapsed = 0
|
||||
pollFrame:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function MTH_TT_InstallTooltipHook()
|
||||
if MTH_Tooltips.hookInstalled then
|
||||
return
|
||||
@@ -1260,9 +1360,15 @@ local function MTH_TT_InstallTooltipHook()
|
||||
MTH_TT_RequestInject()
|
||||
end)
|
||||
GameTooltip:HookScript("OnTooltipSetItem", function()
|
||||
if not (MTH_Tooltips and MTH_Tooltips.enabled) then
|
||||
return
|
||||
end
|
||||
MTH_TT_AddFoodTooltipHint()
|
||||
end)
|
||||
GameTooltip:HookScript("OnTooltipSetSpell", function()
|
||||
if not (MTH_Tooltips and MTH_Tooltips.enabled) then
|
||||
return
|
||||
end
|
||||
MTH_TT_AddPetActionNotLearnedHint()
|
||||
end)
|
||||
end)
|
||||
@@ -1284,6 +1390,7 @@ function MTH_Tooltips:init()
|
||||
MTH_TT_InstallTooltipHook()
|
||||
MTH_TT_EnsureInjectFrame()
|
||||
MTH_TT_EnsurePollFrame()
|
||||
MTH_TT_SetRuntimeActive(self.enabled)
|
||||
MTH_TT_Log("module init complete")
|
||||
end
|
||||
|
||||
@@ -1307,6 +1414,9 @@ function MTH_Tooltips:setEnabled(enabled)
|
||||
elseif self.enabled then
|
||||
MTH_TT_EnsurePollFrame()
|
||||
MTH_TT_EnsureInjectFrame()
|
||||
MTH_TT_SetRuntimeActive(true)
|
||||
else
|
||||
MTH_TT_SetRuntimeActive(false)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1357,6 +1467,7 @@ end
|
||||
|
||||
function MTH_Tooltips:cleanup()
|
||||
self.enabled = false
|
||||
MTH_TT_SetRuntimeActive(false)
|
||||
end
|
||||
|
||||
function MTH_Tooltips:GetDebugSnapshot()
|
||||
|
||||
@@ -11,7 +11,8 @@ BINDING_HEADER_ZMountsHeader = "ZMounts Buttons"
|
||||
BINDING_HEADER_ZCompanionsHeader = "ZCompanions Buttons"
|
||||
BINDING_HEADER_ZToysHeader = "ZToys Buttons"
|
||||
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "ZHunterModTooltip", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltip = CreateFrame("GameTooltip", "ZHunterModScan", nil, "GameTooltipTemplate")
|
||||
ZHunterModTooltipTextLeft1 = getglobal("ZHunterModScanTextLeft1")
|
||||
|
||||
function MTH_ZH_IsModuleEnabled()
|
||||
if not (MTH and MTH.IsModuleEnabled) then
|
||||
|
||||
@@ -8,7 +8,7 @@ MTH_ZH_MANAGED_HOOKS = true
|
||||
local MTH_ZHunter = {
|
||||
name = "zhunter",
|
||||
enabled = true,
|
||||
version = "1.0.4",
|
||||
version = "1.0.5",
|
||||
events = {
|
||||
"VARIABLES_LOADED",
|
||||
"PLAYER_ENTERING_WORLD",
|
||||
@@ -288,6 +288,57 @@ MTH_ZH_SetAuxFramesVisible = function(visible)
|
||||
return
|
||||
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" },
|
||||
}
|
||||
|
||||
local function isFeatureEnabled(getterName)
|
||||
local getter = getglobal(getterName)
|
||||
if type(getter) ~= "function" then
|
||||
return true
|
||||
end
|
||||
local ok, saved = pcall(getter)
|
||||
if not ok or type(saved) ~= "table" then
|
||||
return true
|
||||
end
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
for _, spec in ipairs(frameSpecs) do
|
||||
local frameName = spec.frame
|
||||
local handlerName = spec.handler
|
||||
local frame = getglobal(frameName)
|
||||
if frame and frame.SetScript then
|
||||
if active then
|
||||
if isFeatureEnabled(spec.getter) then
|
||||
local handler = getglobal(handlerName)
|
||||
if type(handler) == "function" then
|
||||
frame:SetScript("OnEvent", handler)
|
||||
else
|
||||
frame:SetScript("OnEvent", nil)
|
||||
end
|
||||
else
|
||||
frame:SetScript("OnEvent", nil)
|
||||
end
|
||||
else
|
||||
frame:SetScript("OnEvent", nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function MTH_ZH_ClearRuntimeFeatureFlags()
|
||||
return
|
||||
end
|
||||
@@ -310,9 +361,11 @@ function MTH_ZHunter:setEnabled(enabled)
|
||||
MTH_ZH_SyncSavedVariables()
|
||||
if enabled then
|
||||
MTH_ZH_EnsureBootstrapRestoreFrame()
|
||||
MTH_ZH_SetAdjustmentHandlersActive(true)
|
||||
MTH_ZH_ApplyEnabledRuntimeState("setEnabled")
|
||||
else
|
||||
MTH_ZH_ClearRuntimeFeatureFlags()
|
||||
MTH_ZH_SetAdjustmentHandlersActive(false)
|
||||
MTH_ZH_SetButtonsVisible(false)
|
||||
MTH_ZH_SetAuxFramesVisible(false)
|
||||
end
|
||||
|
||||
+238
-45
@@ -29,6 +29,69 @@ ZHunterMod_Ammo_Buttons = nil
|
||||
local ZHUNTER_AMMO_MAX_COUNT = math.max(table.getn(MTH_AMMO_ARROWS or {}), table.getn(MTH_AMMO_BULLETS or {}))
|
||||
local zButtonAmmo_Cache = {}
|
||||
local zButtonAmmo_LastCacheSignature = nil
|
||||
local zButtonAmmo_LastRefreshAt = 0
|
||||
local zButtonAmmo_MinRefreshInterval = 0.20
|
||||
local zButtonAmmo_MinBagRefreshInterval = 0.75
|
||||
local zButtonAmmo_KnownAmmoTypes = nil
|
||||
local zButtonAmmo_AmmoBags = {}
|
||||
local zButtonAmmo_LastFullScanAt = 0
|
||||
local zButtonAmmo_MinUnknownBagScanInterval = 5.0
|
||||
local zButtonAmmo_EmptyScanStreak = 0
|
||||
local zButtonAmmo_GetKnownAmmoTypes
|
||||
|
||||
local function zButtonAmmo_BagHasAmmoNow(bagId)
|
||||
local bag = tonumber(bagId)
|
||||
if not bag or bag < 0 or bag > 4 then
|
||||
return false
|
||||
end
|
||||
local knownAmmo = zButtonAmmo_GetKnownAmmoTypes and zButtonAmmo_GetKnownAmmoTypes() or nil
|
||||
for slot = 1, (GetContainerNumSlots(bag) or 0) do
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
local _, _, linkName = string.find(link, "%[(.+)%]")
|
||||
if linkName and knownAmmo and knownAmmo[linkName] then
|
||||
return true
|
||||
end
|
||||
local _, _, id = string.find(link, "Hitem:((%d+).-)")
|
||||
if id then
|
||||
local itemName, _, _, _, _, itemSubtype, _, itemSlot = GetItemInfo(id)
|
||||
if itemSlot == "INVTYPE_AMMO" then
|
||||
return true
|
||||
end
|
||||
if itemName and knownAmmo and knownAmmo[itemName] then
|
||||
return true
|
||||
end
|
||||
if itemSubtype == "Arrow" or itemSubtype == "Bullet" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function zButtonAmmo_UpdateParentCountFast()
|
||||
if zButtonAmmo and not zButtonAmmo.isspell and zButtonAmmo.ammoname then
|
||||
local ammoSlot = 0
|
||||
if GetInventorySlotInfo then
|
||||
local slotId = GetInventorySlotInfo("AmmoSlot")
|
||||
if slotId and slotId > 0 then
|
||||
ammoSlot = slotId
|
||||
end
|
||||
end
|
||||
local slotForCount = ammoSlot and ammoSlot ~= 0 and ammoSlot or 0
|
||||
if GetInventoryItemCount then
|
||||
local liveCount = GetInventoryItemCount("player", slotForCount)
|
||||
local cachedInfo = zButtonAmmo_Cache[zButtonAmmo.ammoname]
|
||||
if liveCount == 0 and cachedInfo and (tonumber(cachedInfo.count) or 0) > 0 then
|
||||
zButtonAmmo.ammocount = cachedInfo.count
|
||||
elseif liveCount ~= nil then
|
||||
zButtonAmmo.ammocount = liveCount
|
||||
end
|
||||
end
|
||||
zButtonAmmo_UpdateButton(zButtonAmmo)
|
||||
end
|
||||
end
|
||||
|
||||
local function zButtonAmmo_GetSaved()
|
||||
local currentRoot = zButtonAmmo_GetRoot()
|
||||
@@ -38,6 +101,21 @@ local function zButtonAmmo_GetSaved()
|
||||
return currentRoot["zButtonAmmo"]
|
||||
end
|
||||
|
||||
zButtonAmmo_GetKnownAmmoTypes = function()
|
||||
if zButtonAmmo_KnownAmmoTypes then
|
||||
return zButtonAmmo_KnownAmmoTypes
|
||||
end
|
||||
local knownAmmo = {}
|
||||
for i = 1, table.getn(MTH_AMMO_ARROWS or {}) do
|
||||
knownAmmo[(MTH_AMMO_ARROWS or {})[i]] = "Arrow"
|
||||
end
|
||||
for i = 1, table.getn(MTH_AMMO_BULLETS or {}) do
|
||||
knownAmmo[(MTH_AMMO_BULLETS or {})[i]] = "Bullet"
|
||||
end
|
||||
zButtonAmmo_KnownAmmoTypes = knownAmmo
|
||||
return knownAmmo
|
||||
end
|
||||
|
||||
local zButtonAmmo_ShortArrowLabels = {
|
||||
[ARROWS_ROUGH] = "Rough",
|
||||
[ARROWS_SHARP] = "Sharp",
|
||||
@@ -164,13 +242,7 @@ local function zButtonAmmo_GetEquippedAmmoLink()
|
||||
end
|
||||
|
||||
local function zButtonAmmo_RebuildCache()
|
||||
local knownAmmo = {}
|
||||
for i = 1, table.getn(MTH_AMMO_ARROWS or {}) do
|
||||
knownAmmo[(MTH_AMMO_ARROWS or {})[i]] = "Arrow"
|
||||
end
|
||||
for i = 1, table.getn(MTH_AMMO_BULLETS or {}) do
|
||||
knownAmmo[(MTH_AMMO_BULLETS or {})[i]] = "Bullet"
|
||||
end
|
||||
local knownAmmo = zButtonAmmo_GetKnownAmmoTypes()
|
||||
|
||||
local equippedAmmo = nil
|
||||
local equippedLink = zButtonAmmo_GetEquippedAmmoLink()
|
||||
@@ -185,11 +257,14 @@ local function zButtonAmmo_RebuildCache()
|
||||
end
|
||||
end
|
||||
|
||||
zButtonAmmo_Cache = {}
|
||||
local newCache = {}
|
||||
local newAmmoBags = {}
|
||||
local scannedLinkCount = 0
|
||||
for bag = 0, 4 do
|
||||
for slot = 1, GetContainerNumSlots(bag) do
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
scannedLinkCount = scannedLinkCount + 1
|
||||
local _, _, id = string.find(link, "Hitem:((%d+).-)")
|
||||
if id then
|
||||
local _, _, linkName = string.find(link, "%[(.+)%]")
|
||||
@@ -208,7 +283,8 @@ local function zButtonAmmo_RebuildCache()
|
||||
end
|
||||
|
||||
if isAmmo and ammoName then
|
||||
local ammoInfo = zButtonAmmo_Cache[ammoName]
|
||||
newAmmoBags[bag] = true
|
||||
local ammoInfo = newCache[ammoName]
|
||||
if not ammoInfo then
|
||||
ammoInfo = {
|
||||
ammo = ammoName,
|
||||
@@ -224,7 +300,7 @@ local function zButtonAmmo_RebuildCache()
|
||||
count = 0,
|
||||
equip = nil,
|
||||
}
|
||||
zButtonAmmo_Cache[ammoName] = ammoInfo
|
||||
newCache[ammoName] = ammoInfo
|
||||
end
|
||||
ammoInfo.count = (ammoInfo.count or 0) + (itemCount or 0)
|
||||
if equippedAmmo and equippedAmmo == ammoName then
|
||||
@@ -235,6 +311,26 @@ local function zButtonAmmo_RebuildCache()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local hasAmmo = next(newCache) ~= nil
|
||||
local previousHadAmmo = next(zButtonAmmo_Cache) ~= nil
|
||||
if hasAmmo then
|
||||
zButtonAmmo_EmptyScanStreak = 0
|
||||
zButtonAmmo_Cache = newCache
|
||||
zButtonAmmo_AmmoBags = newAmmoBags
|
||||
else
|
||||
local reliableEmptyScan = scannedLinkCount > 0 and not equippedAmmo
|
||||
if reliableEmptyScan then
|
||||
zButtonAmmo_EmptyScanStreak = (zButtonAmmo_EmptyScanStreak or 0) + 1
|
||||
else
|
||||
zButtonAmmo_EmptyScanStreak = 0
|
||||
end
|
||||
if not previousHadAmmo or zButtonAmmo_EmptyScanStreak >= 3 then
|
||||
zButtonAmmo_Cache = newCache
|
||||
zButtonAmmo_AmmoBags = newAmmoBags
|
||||
end
|
||||
end
|
||||
zButtonAmmo_LastFullScanAt = GetTime and GetTime() or zButtonAmmo_LastFullScanAt
|
||||
end
|
||||
|
||||
local function zButtonAmmo_AssignButtonFromAmmoInfo(button, ammoInfo)
|
||||
@@ -257,15 +353,41 @@ local function zButtonAmmo_AssignButtonFromAmmoInfo(button, ammoInfo)
|
||||
return true
|
||||
end
|
||||
|
||||
local function zButtonAmmo_GetCacheSignature()
|
||||
local names = {}
|
||||
for ammoName, ammoInfo in pairs(zButtonAmmo_Cache or {}) do
|
||||
if ammoName and ammoInfo and (tonumber(ammoInfo.count) or 0) > 0 then
|
||||
table.insert(names, tostring(ammoName))
|
||||
local function zButtonAmmo_GetCacheSignature(ammoList)
|
||||
local hash = 17
|
||||
local list = ammoList or {}
|
||||
local mod = math.fmod or math.mod
|
||||
for i = 1, table.getn(list) do
|
||||
local ammoName = list[i]
|
||||
local ammoInfo = ammoName and zButtonAmmo_Cache[ammoName] or nil
|
||||
local ammoCount = (ammoInfo and tonumber(ammoInfo.count)) or 0
|
||||
local value = (hash * 131) + ammoCount + (string.len(tostring(ammoName or "")) * 17)
|
||||
if mod then
|
||||
hash = mod(value, 2147483647)
|
||||
else
|
||||
hash = value - (math.floor(value / 2147483647) * 2147483647)
|
||||
end
|
||||
end
|
||||
table.sort(names)
|
||||
return table.concat(names, "|")
|
||||
return hash
|
||||
end
|
||||
|
||||
local function zButtonAmmo_AssignParentFromChild(child)
|
||||
if not (zButtonAmmo and child) then
|
||||
return
|
||||
end
|
||||
zButtonAmmo.id = child.ammoid or child.id
|
||||
zButtonAmmo.icon = child.icon
|
||||
zButtonAmmo.isspell = nil
|
||||
zButtonAmmo.ammoname = child.ammoname
|
||||
zButtonAmmo.ammobrol = child.ammobrol
|
||||
zButtonAmmo.ammoqual = child.ammoqual
|
||||
zButtonAmmo.ammolvl = child.ammolvl
|
||||
zButtonAmmo.ammotype = child.ammotype
|
||||
zButtonAmmo.ammobag = child.ammobag
|
||||
zButtonAmmo.ammoslot = child.ammoslot
|
||||
zButtonAmmo.ammoid = child.ammoid or child.id
|
||||
zButtonAmmo.ammolink = child.ammolink
|
||||
zButtonAmmo.ammocount = child.ammocount
|
||||
end
|
||||
|
||||
local function zButtonAmmo_GetEquippedAmmoInfo()
|
||||
@@ -461,7 +583,7 @@ function zButtonAmmo_SetButtons(parent, ammoList)
|
||||
else
|
||||
parent:Show()
|
||||
end
|
||||
zButtonAmmo_LastCacheSignature = zButtonAmmo_GetCacheSignature()
|
||||
zButtonAmmo_LastCacheSignature = zButtonAmmo_GetCacheSignature(ammoList)
|
||||
return count - 1
|
||||
end
|
||||
|
||||
@@ -685,6 +807,8 @@ function zButtonAmmo_OnEvent()
|
||||
zButtonAmmoAdjustment = CreateFrame("Frame", "zButtonAmmoAdjustment")
|
||||
zButtonAmmoAdjustment:RegisterEvent("UNIT_INVENTORY_CHANGED")
|
||||
zButtonAmmoAdjustment:RegisterEvent("BAG_UPDATE")
|
||||
zButtonAmmoAdjustment:RegisterEvent("PLAYER_ALIVE")
|
||||
zButtonAmmoAdjustment:RegisterEvent("PLAYER_UNGHOST")
|
||||
zButtonAmmoAdjustment:SetScript("OnEvent", zButtonAmmoAdjustment_OnEvent)
|
||||
zButtonAmmo_SetupSizeAndPosition()
|
||||
zButtonAmmo_DeferredStartupSync()
|
||||
@@ -750,11 +874,17 @@ function zButtonAmmo_SetupSizeAndPosition()
|
||||
zButtonAmmo_EnsureSpellOrder(ZHunterMod_Ammo_Buttons or zButtonAmmo_GetAmmoList())
|
||||
local saved = zButtonAmmo_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonAmmoAdjustment and zButtonAmmoAdjustment.SetScript then
|
||||
zButtonAmmoAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAmmo and zButtonAmmo.Hide then
|
||||
zButtonAmmo:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonAmmoAdjustment and zButtonAmmoAdjustment.SetScript then
|
||||
zButtonAmmoAdjustment:SetScript("OnEvent", zButtonAmmoAdjustment_OnEvent)
|
||||
end
|
||||
local ammoList = ZHunterMod_Ammo_Buttons or zButtonAmmo_GetAmmoList()
|
||||
local arrangeCount = zButtonAmmo.found or table.getn(ammoList)
|
||||
if arrangeCount < 0 then
|
||||
@@ -801,14 +931,71 @@ function zButtonAmmoAdjustment_OnEvent()
|
||||
if not zButtonAmmo or not zButtonAmmo.count then
|
||||
return
|
||||
end
|
||||
if event == "UNIT_INVENTORY_CHANGED" and arg1 and arg1 ~= "player" then
|
||||
return
|
||||
end
|
||||
local saved = zButtonAmmo_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonAmmoAdjustment and zButtonAmmoAdjustment.SetScript then
|
||||
zButtonAmmoAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonAmmo and zButtonAmmo.Hide then
|
||||
zButtonAmmo:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if event == "UNIT_INVENTORY_CHANGED" or event == "BAG_UPDATE" then
|
||||
if event == "UNIT_INVENTORY_CHANGED" or event == "BAG_UPDATE" or event == "PLAYER_ALIVE" or event == "PLAYER_UNGHOST" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local bagIsAmmoRelated = false
|
||||
if event == "BAG_UPDATE" and arg1 ~= nil then
|
||||
local bagId = tonumber(arg1)
|
||||
local bagHasAmmoNow = nil
|
||||
if type(zButtonAmmo_BagHasAmmoNow) == "function" then
|
||||
bagHasAmmoNow = zButtonAmmo_BagHasAmmoNow
|
||||
elseif type(_G) == "table" and type(_G["zButtonAmmo_BagHasAmmoNow"]) == "function" then
|
||||
bagHasAmmoNow = _G["zButtonAmmo_BagHasAmmoNow"]
|
||||
end
|
||||
local unknownBagHasAmmo = false
|
||||
if bagId and bagHasAmmoNow then
|
||||
unknownBagHasAmmo = bagHasAmmoNow(bagId) and true or false
|
||||
end
|
||||
if bagId and (zButtonAmmo_AmmoBags[bagId] or unknownBagHasAmmo) then
|
||||
bagIsAmmoRelated = true
|
||||
end
|
||||
if bagId and not zButtonAmmo_AmmoBags[bagId] then
|
||||
if (not unknownBagHasAmmo) and now > 0 and zButtonAmmo_LastFullScanAt > 0 and (now - zButtonAmmo_LastFullScanAt) < zButtonAmmo_MinUnknownBagScanInterval then
|
||||
zButtonAmmo_UpdateParentCountFast()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
local minInterval = zButtonAmmo_MinRefreshInterval
|
||||
if event == "BAG_UPDATE" then
|
||||
if bagIsAmmoRelated then
|
||||
minInterval = 0
|
||||
else
|
||||
minInterval = zButtonAmmo_MinBagRefreshInterval
|
||||
end
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = 1.50
|
||||
if bagIsAmmoRelated then
|
||||
minInterval = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
if now > 0 and zButtonAmmo_LastRefreshAt > 0 and (now - zButtonAmmo_LastRefreshAt) < minInterval then
|
||||
zButtonAmmo_UpdateParentCountFast()
|
||||
return
|
||||
end
|
||||
zButtonAmmo_LastRefreshAt = now
|
||||
|
||||
local ammoList = zButtonAmmo_GetAmmoList()
|
||||
local listChanged = (ZHunterMod_Ammo_Buttons ~= ammoList)
|
||||
ZHunterMod_Ammo_Buttons = ammoList
|
||||
zButtonAmmo_RebuildCache()
|
||||
local cacheSignature = zButtonAmmo_GetCacheSignature()
|
||||
local cacheSignature = zButtonAmmo_GetCacheSignature(ammoList)
|
||||
local rebuiltButtons = false
|
||||
if listChanged or cacheSignature ~= zButtonAmmo_LastCacheSignature then
|
||||
zButtonAmmo_EnsureSpellOrder(ammoList)
|
||||
local info = {}
|
||||
@@ -822,15 +1009,10 @@ function zButtonAmmoAdjustment_OnEvent()
|
||||
end
|
||||
zButtonAmmo.found = ZSpellButton_SetButtons(zButtonAmmo, info)
|
||||
zButtonAmmo_SetupSizeAndPosition()
|
||||
zButtonAmmo_LastCacheSignature = zButtonAmmo_GetCacheSignature()
|
||||
end
|
||||
-- Update ammo counts for child buttons
|
||||
for i=1, zButtonAmmo.count do
|
||||
local button = getglobal("zButtonAmmo"..i)
|
||||
if button and button.ammoname and not button.isspell then
|
||||
zButtonAmmo_UpdateButton(button)
|
||||
end
|
||||
zButtonAmmo_LastCacheSignature = cacheSignature
|
||||
rebuiltButtons = true
|
||||
end
|
||||
|
||||
local equippedAmmoName = zButtonAmmo_GetEquippedAmmoName()
|
||||
local equippedInfo = nil
|
||||
if equippedAmmoName then
|
||||
@@ -839,40 +1021,51 @@ function zButtonAmmoAdjustment_OnEvent()
|
||||
for i=1, zButtonAmmo.count do
|
||||
local child = getglobal("zButtonAmmo"..i)
|
||||
if child and child.ammoname == equippedAmmoName and not child.isspell then
|
||||
equippedInfo = {
|
||||
ammo = child.ammoname,
|
||||
brol = child.ammobrol,
|
||||
quality = child.ammoqual,
|
||||
lvl = child.ammolvl,
|
||||
type = child.ammotype,
|
||||
bag = child.ammobag,
|
||||
slot = child.ammoslot,
|
||||
id = child.ammoid or child.id,
|
||||
link = child.ammolink,
|
||||
icon = child.icon,
|
||||
count = child.ammocount,
|
||||
}
|
||||
zButtonAmmo_AssignParentFromChild(child)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not equippedInfo then
|
||||
if not equippedInfo and event ~= "BAG_UPDATE" then
|
||||
equippedInfo = zButtonAmmo_GetEquippedAmmoInfo()
|
||||
if equippedInfo and equippedInfo.ammo and not equippedAmmoName then
|
||||
equippedAmmoName = equippedInfo.ammo
|
||||
end
|
||||
end
|
||||
|
||||
if not rebuiltButtons then
|
||||
for i=1, zButtonAmmo.count do
|
||||
local child = getglobal("zButtonAmmo"..i)
|
||||
if child and child.ammoname and not child.isspell then
|
||||
local cacheInfo = zButtonAmmo_Cache[child.ammoname]
|
||||
local newCount = cacheInfo and cacheInfo.count or 0
|
||||
if (child.ammocount or 0) ~= (newCount or 0) then
|
||||
if cacheInfo then
|
||||
child.ammobag = cacheInfo.bag
|
||||
child.ammoslot = cacheInfo.slot
|
||||
child.ammoqual = cacheInfo.quality
|
||||
child.ammobrol = cacheInfo.brol
|
||||
child.ammolvl = cacheInfo.lvl
|
||||
child.ammotype = cacheInfo.type
|
||||
child.ammoid = cacheInfo.id
|
||||
child.ammolink = cacheInfo.link
|
||||
child.icon = cacheInfo.icon
|
||||
end
|
||||
child.ammocount = newCount
|
||||
zButtonAmmo_UpdateButton(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if equippedInfo and equippedInfo.ammo and equippedInfo.ammo ~= zButtonAmmo.ammoname then
|
||||
zButtonAmmo_AssignButtonFromAmmoInfo(zButtonAmmo, equippedInfo)
|
||||
end
|
||||
|
||||
-- Also update parent if it's showing ammo (not a spell)
|
||||
if zButtonAmmo and not zButtonAmmo.isspell and zButtonAmmo.ammoname then
|
||||
zButtonAmmo_UpdateButton(zButtonAmmo)
|
||||
end
|
||||
zButtonAmmo_UpdateParentCountFast()
|
||||
|
||||
-- Save the currently equipped ammo for restoration on next reload
|
||||
if equippedAmmoName then
|
||||
|
||||
@@ -32,6 +32,12 @@ ZHunterMod_Aspect_Spells = {
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -158,7 +164,13 @@ function zButtonAspect_OnEvent()
|
||||
zButtonAspectAdjustment:RegisterEvent("CHARACTER_POINTS_CHANGED")
|
||||
zButtonAspectAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonAspectAdjustment:SetScript("OnEvent", zButtonAspectAdjustment_OnEvent)
|
||||
zButtonAspect_Tooltip = CreateFrame("GameTooltip", "zButtonAspect_Tooltip", nil, "GameTooltipTemplate")
|
||||
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
|
||||
@@ -191,11 +203,17 @@ 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
|
||||
@@ -234,6 +252,17 @@ 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()
|
||||
@@ -245,45 +274,78 @@ function zButtonAspectAdjustment_OnEvent()
|
||||
if not zButtonAspect1.id then
|
||||
return
|
||||
end
|
||||
local buttontextures = {}
|
||||
local button
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
button.icon = nil
|
||||
if button.id then
|
||||
buttontextures[GetSpellTexture(button.id, "spell")] = 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
|
||||
zButtonAspect.id = zButtonAspect1.id
|
||||
local newParentId = zButtonAspect1.id
|
||||
while buff do
|
||||
if texture == buff and zButtonAspect2.id then
|
||||
zButtonAspect.id = zButtonAspect2.id
|
||||
newParentId = zButtonAspect2.id
|
||||
end
|
||||
if buttontextures[buff] then
|
||||
zButtonAspect_Tooltip:SetOwner(this, "ANCHOR_NONE")
|
||||
zButtonAspect_Tooltip:SetUnitBuff("player", i)
|
||||
buffname = zButtonAspect_TooltipTextLeft1:GetText()
|
||||
spellname = GetSpellName(buttontextures[buff].id, "spell")
|
||||
if buffname == spellname then
|
||||
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)
|
||||
for i=1, zButtonAspect.count do
|
||||
button = getglobal(zButtonAspect.name..i)
|
||||
if button.id then
|
||||
ZSpellButton_UpdateButton(button)
|
||||
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 GameTooltip:IsOwned(zButtonAspect) then
|
||||
if isParentTooltipOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonAspect)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,6 +22,20 @@ if not root["zButtonCompanions"] then
|
||||
end
|
||||
|
||||
local ZHUNTER_COMPANIONS_BUTTON_MAX = 80
|
||||
local zButtonCompanions_LastSpellSignature = nil
|
||||
local zButtonCompanions_LastRefreshAt = 0
|
||||
local zButtonCompanions_MinRefreshInterval = 0.50
|
||||
|
||||
local function zButtonCompanions_GetSpellSignature(spellIds)
|
||||
if type(spellIds) ~= "table" or table.getn(spellIds) == 0 then
|
||||
return ""
|
||||
end
|
||||
local parts = {}
|
||||
for i = 1, table.getn(spellIds) do
|
||||
parts[i] = tostring(spellIds[i] or "")
|
||||
end
|
||||
return table.concat(parts, ",")
|
||||
end
|
||||
|
||||
local function zButtonCompanions_GetSaved()
|
||||
local currentRoot = zButtonCompanions_GetRoot()
|
||||
@@ -233,11 +247,17 @@ 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)
|
||||
end
|
||||
if zButtonCompanions and zButtonCompanions.Hide then
|
||||
zButtonCompanions:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonCompanionsAdjustment and zButtonCompanionsAdjustment.SetScript then
|
||||
zButtonCompanionsAdjustment:SetScript("OnEvent", zButtonCompanionsAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonCompanions.found or 0
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
@@ -275,6 +295,18 @@ function zButtonCompanionsAdjustment_OnEvent()
|
||||
if not zButtonCompanions then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
if now > 0 and zButtonCompanions_LastRefreshAt > 0 and (now - zButtonCompanions_LastRefreshAt) < zButtonCompanions_MinRefreshInterval then
|
||||
return
|
||||
end
|
||||
local signature = zButtonCompanions_GetSpellSignature(zButtonCompanions_CollectTabSpellIds())
|
||||
if signature == zButtonCompanions_LastSpellSignature and not GameTooltip:IsOwned(zButtonCompanions) then
|
||||
return
|
||||
end
|
||||
zButtonCompanions_LastSpellSignature = signature
|
||||
zButtonCompanions_LastRefreshAt = now
|
||||
end
|
||||
zButtonCompanions_RefreshSpells()
|
||||
zButtonCompanions_SetupSizeAndPosition()
|
||||
if GameTooltip:IsOwned(zButtonCompanions) then
|
||||
|
||||
@@ -22,6 +22,20 @@ if not root["zButtonMounts"] then
|
||||
end
|
||||
|
||||
local ZHUNTER_MOUNTS_BUTTON_MAX = 80
|
||||
local zButtonMounts_LastSpellSignature = nil
|
||||
local zButtonMounts_LastRefreshAt = 0
|
||||
local zButtonMounts_MinRefreshInterval = 0.50
|
||||
|
||||
local function zButtonMounts_GetSpellSignature(spellIds)
|
||||
if type(spellIds) ~= "table" or table.getn(spellIds) == 0 then
|
||||
return ""
|
||||
end
|
||||
local parts = {}
|
||||
for i = 1, table.getn(spellIds) do
|
||||
parts[i] = tostring(spellIds[i] or "")
|
||||
end
|
||||
return table.concat(parts, ",")
|
||||
end
|
||||
|
||||
local function zButtonMounts_GetSaved()
|
||||
local currentRoot = zButtonMounts_GetRoot()
|
||||
@@ -233,11 +247,17 @@ 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)
|
||||
end
|
||||
if zButtonMounts and zButtonMounts.Hide then
|
||||
zButtonMounts:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonMountsAdjustment and zButtonMountsAdjustment.SetScript then
|
||||
zButtonMountsAdjustment:SetScript("OnEvent", zButtonMountsAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonMounts.found or 0
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
@@ -275,6 +295,18 @@ function zButtonMountsAdjustment_OnEvent()
|
||||
if not zButtonMounts then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
if now > 0 and zButtonMounts_LastRefreshAt > 0 and (now - zButtonMounts_LastRefreshAt) < zButtonMounts_MinRefreshInterval then
|
||||
return
|
||||
end
|
||||
local signature = zButtonMounts_GetSpellSignature(zButtonMounts_CollectTabSpellIds())
|
||||
if signature == zButtonMounts_LastSpellSignature and not GameTooltip:IsOwned(zButtonMounts) then
|
||||
return
|
||||
end
|
||||
zButtonMounts_LastSpellSignature = signature
|
||||
zButtonMounts_LastRefreshAt = now
|
||||
end
|
||||
zButtonMounts_RefreshSpells()
|
||||
zButtonMounts_SetupSizeAndPosition()
|
||||
if GameTooltip:IsOwned(zButtonMounts) then
|
||||
|
||||
@@ -43,6 +43,11 @@ ZHunterMod_Pet_Spells = {
|
||||
|
||||
local ZHUNTER_PET_MAX = table.getn(ZHunterMod_Pet_Spells)
|
||||
local zButtonPet_SetButtons
|
||||
local zButtonPet_LastRefreshAt = 0
|
||||
local zButtonPet_MinRefreshInterval = 0.15
|
||||
local zButtonPet_MinCombatRefreshInterval = 0.30
|
||||
local zButtonPet_RuntimeSpellMap = nil
|
||||
local zButtonPet_LastStateKey = nil
|
||||
|
||||
local function zButtonPet_GetSaved()
|
||||
local currentRoot = zButtonPet_GetRoot()
|
||||
@@ -134,6 +139,40 @@ local function zButtonPet_ApplyRuntimeSettings()
|
||||
zButtonPet.hideonclick = saved["children"] and saved["children"]["hideonclick"] and true or false
|
||||
end
|
||||
|
||||
local function zButtonPet_RebuildRuntimeSpellMap()
|
||||
if not zButtonPet or not zButtonPet.count then
|
||||
zButtonPet_RuntimeSpellMap = {}
|
||||
return zButtonPet_RuntimeSpellMap
|
||||
end
|
||||
local spells = {}
|
||||
for i=1, zButtonPet.count do
|
||||
local button = getglobal(zButtonPet.name..i)
|
||||
if button and button.id then
|
||||
local spellName = GetSpellName(button.id, "spell")
|
||||
if spellName and spellName ~= "" then
|
||||
spells[spellName] = button.id
|
||||
end
|
||||
end
|
||||
end
|
||||
zButtonPet_RuntimeSpellMap = spells
|
||||
return spells
|
||||
end
|
||||
|
||||
local function zButtonPet_GetPreferredDefaultParentId(spells)
|
||||
if zButtonPet1 and zButtonPet1.id then
|
||||
return zButtonPet1.id
|
||||
end
|
||||
if zButtonPet and zButtonPet.count then
|
||||
for i = 1, zButtonPet.count do
|
||||
local child = getglobal("zButtonPet" .. i)
|
||||
if child and child.id then
|
||||
return child.id
|
||||
end
|
||||
end
|
||||
end
|
||||
return spells[ZHUNTER_PET_EYES] or spells[ZHUNTER_PET_POSITION] or spells[ZHUNTER_PET_DISMISS]
|
||||
end
|
||||
|
||||
function zButtonPet_OnLoad()
|
||||
this:RegisterEvent("VARIABLES_LOADED")
|
||||
end
|
||||
@@ -161,7 +200,6 @@ function zButtonPet_OnEvent()
|
||||
zButtonPetAdjustment:RegisterEvent("SPELLS_CHANGED")
|
||||
zButtonPetAdjustment:RegisterEvent("LEARNED_SPELL_IN_TAB")
|
||||
zButtonPetAdjustment:SetScript("OnEvent", zButtonPetAdjustment_OnEvent)
|
||||
zButtonPet_Tooltip = CreateFrame("GameTooltip", "zButtonPet_Tooltip", nil, "GameTooltipTemplate")
|
||||
zButtonPet_SetupSizeAndPosition()
|
||||
zButtonPetAdjustment_OnEvent()
|
||||
end
|
||||
@@ -188,16 +226,24 @@ function zButtonPet_CreateButtons()
|
||||
end
|
||||
zButtonPet.found = ZSpellButton_SetButtons(zButtonPet, info)
|
||||
zButtonPet_ApplyRuntimeSettings()
|
||||
zButtonPet_RebuildRuntimeSpellMap()
|
||||
zButtonPet_LastStateKey = nil
|
||||
end
|
||||
|
||||
function zButtonPet_SetupSizeAndPosition()
|
||||
local saved = zButtonPet_GetSaved()
|
||||
if saved["enabled"] == false or saved["enabled"] == 0 then
|
||||
if zButtonPetAdjustment and zButtonPetAdjustment.SetScript then
|
||||
zButtonPetAdjustment:SetScript("OnEvent", nil)
|
||||
end
|
||||
if zButtonPet and zButtonPet.Hide then
|
||||
zButtonPet:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonPetAdjustment and zButtonPetAdjustment.SetScript then
|
||||
zButtonPetAdjustment:SetScript("OnEvent", zButtonPetAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonPet.found or ZHUNTER_PET_MAX
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
@@ -434,20 +480,12 @@ local function zButtonPet_RefreshParentSpell()
|
||||
zButtonPet_RefreshSavedPetState(saved, corePetInfo)
|
||||
|
||||
local status, happiness, dead
|
||||
local spells = {}
|
||||
local name
|
||||
local choice
|
||||
for i=1, zButtonPet.count do
|
||||
local button
|
||||
button = getglobal(zButtonPet.name..i)
|
||||
if button and button.id then
|
||||
name = GetSpellName(button.id, "spell")
|
||||
spells[name] = button
|
||||
if not choice and (name == ZHUNTER_PET_DISMISS or name == ZHUNTER_PET_EYES or name == ZHUNTER_PET_POSITION) then
|
||||
choice = button
|
||||
end
|
||||
end
|
||||
local spells = zButtonPet_RuntimeSpellMap
|
||||
if not spells then
|
||||
spells = zButtonPet_RebuildRuntimeSpellMap()
|
||||
end
|
||||
local name
|
||||
local choiceId = zButtonPet_GetPreferredDefaultParentId(spells)
|
||||
status = saved["pet"]["status"]
|
||||
happiness = saved["pet"]["happiness"]
|
||||
dead = saved["pet"]["dead"]
|
||||
@@ -464,22 +502,34 @@ local function zButtonPet_RefreshParentSpell()
|
||||
name = ZHUNTER_PET_MEND
|
||||
elseif happiness ~= 3 then
|
||||
name = ZHUNTER_PET_FEED
|
||||
elseif choice then
|
||||
id = choice.id
|
||||
elseif choiceId then
|
||||
id = choiceId
|
||||
end
|
||||
|
||||
if name and spells[name] then
|
||||
id = spells[name].id
|
||||
id = spells[name]
|
||||
elseif name then
|
||||
local fallbackId = zButtonPet_FindSpellIdByName(name)
|
||||
if fallbackId then
|
||||
spells[name] = fallbackId
|
||||
id = fallbackId
|
||||
end
|
||||
end
|
||||
local isOwned = GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonPet)
|
||||
local stateKey = tostring(hasCurrentPet and 1 or 0)
|
||||
..":"..tostring(hasLivePet and 1 or 0)
|
||||
..":"..tostring(status or "")
|
||||
..":"..tostring(happiness or "")
|
||||
..":"..tostring(dead or 0)
|
||||
..":"..tostring(id or 0)
|
||||
if zButtonPet.id == id and zButtonPet_LastStateKey == stateKey and not isOwned then
|
||||
return
|
||||
end
|
||||
zButtonPet_LastStateKey = stateKey
|
||||
zButtonPet.id = id
|
||||
ZSpellButton_UpdateButton(zButtonPet)
|
||||
ZSpellButton_UpdateCooldown(zButtonPet)
|
||||
if GameTooltip:IsOwned(zButtonPet) then
|
||||
if isOwned then
|
||||
ZSpellButtonParent_OnEnter(zButtonPet)
|
||||
end
|
||||
end
|
||||
@@ -503,6 +553,21 @@ function zButtonPetAdjustment_OnEvent()
|
||||
if event == "UNIT_PET" and arg1 and arg1 ~= "player" then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" or event == "LEARNED_SPELL_IN_TAB" then
|
||||
zButtonPet_CreateButtons()
|
||||
zButtonPet_SetupSizeAndPosition()
|
||||
end
|
||||
if event == "UNIT_HEALTH" or event == "UNIT_HAPPINESS" or event == "PET_BAR_UPDATE" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local minInterval = zButtonPet_MinRefreshInterval
|
||||
if UnitAffectingCombat and UnitAffectingCombat("player") then
|
||||
minInterval = zButtonPet_MinCombatRefreshInterval
|
||||
end
|
||||
if now > 0 and zButtonPet_LastRefreshAt > 0 and (now - zButtonPet_LastRefreshAt) < minInterval then
|
||||
return
|
||||
end
|
||||
zButtonPet_LastRefreshAt = now
|
||||
end
|
||||
zButtonPet_RefreshParentSpell()
|
||||
end
|
||||
|
||||
|
||||
@@ -27,6 +27,11 @@ ZHunterMod_Ranged_Weapons = ZHunterMod_Ranged_Weapons or {}
|
||||
local ZHUNTER_RANGED_MAX_COUNT = 80
|
||||
local zButtonRanged_Cache = {}
|
||||
local zButtonRanged_TooltipWarmed = false
|
||||
local zButtonRanged_LastRefreshAt = 0
|
||||
local zButtonRanged_MinBagRefreshInterval = 0.75
|
||||
local zButtonRanged_IdleBagRefreshInterval = 3.00
|
||||
local zButtonRanged_BagDirty = false
|
||||
local zButtonRanged_RefreshButtonsFromState
|
||||
|
||||
local function zButtonRanged_GetKnownItemSpeed(itemId)
|
||||
local idNum = tonumber(itemId)
|
||||
@@ -437,6 +442,15 @@ local function zButtonRanged_OnEnter(button)
|
||||
if not button then
|
||||
return
|
||||
end
|
||||
if zButtonRanged_BagDirty then
|
||||
local previousFound = tonumber(zButtonRanged and zButtonRanged.found) or 0
|
||||
zButtonRanged_RefreshButtonsFromState()
|
||||
if (tonumber(zButtonRanged and zButtonRanged.found) or 0) ~= previousFound then
|
||||
zButtonRanged_SetupSizeAndPosition()
|
||||
else
|
||||
zButtonRanged_UpdateButton(zButtonRanged)
|
||||
end
|
||||
end
|
||||
if not (zButtonRanged and zButtonRanged.tooltip) then
|
||||
return
|
||||
end
|
||||
@@ -503,7 +517,7 @@ local function zButtonRanged_BeforeClick(button)
|
||||
return true
|
||||
end
|
||||
|
||||
local function zButtonRanged_RefreshButtonsFromState()
|
||||
zButtonRanged_RefreshButtonsFromState = function()
|
||||
if not zButtonRanged then
|
||||
return
|
||||
end
|
||||
@@ -525,6 +539,7 @@ local function zButtonRanged_RefreshButtonsFromState()
|
||||
end
|
||||
|
||||
zButtonRanged.found = ZSpellButton_SetButtons(zButtonRanged, info)
|
||||
zButtonRanged_BagDirty = false
|
||||
zButtonRanged_ApplyRuntimeSettings()
|
||||
end
|
||||
|
||||
@@ -620,11 +635,17 @@ 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)
|
||||
end
|
||||
if zButtonRanged and zButtonRanged.Hide then
|
||||
zButtonRanged:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonRangedAdjustment and zButtonRangedAdjustment.SetScript then
|
||||
zButtonRangedAdjustment:SetScript("OnEvent", zButtonRangedAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonRanged.found or 0
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
@@ -665,8 +686,32 @@ function zButtonRangedAdjustment_OnEvent()
|
||||
if event == "UNIT_INVENTORY_CHANGED" and arg1 and arg1 ~= "player" then
|
||||
return
|
||||
end
|
||||
if event == "BAG_UPDATE" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
local isInspecting = false
|
||||
if zButtonRanged.children and zButtonRanged.children.IsShown and zButtonRanged.children:IsShown() then
|
||||
isInspecting = true
|
||||
elseif GameTooltip and GameTooltip.IsOwned and GameTooltip:IsOwned(zButtonRanged) then
|
||||
isInspecting = true
|
||||
end
|
||||
if not isInspecting then
|
||||
zButtonRanged_BagDirty = true
|
||||
return
|
||||
end
|
||||
local minInterval = isInspecting and zButtonRanged_MinBagRefreshInterval or zButtonRanged_IdleBagRefreshInterval
|
||||
if now > 0 and zButtonRanged_LastRefreshAt > 0 and (now - zButtonRanged_LastRefreshAt) < minInterval then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
zButtonRanged_LastRefreshAt = GetTime and GetTime() or 0
|
||||
local previousFound = tonumber(zButtonRanged.found) or 0
|
||||
zButtonRanged_RefreshButtonsFromState()
|
||||
zButtonRanged_SetupSizeAndPosition()
|
||||
if (tonumber(zButtonRanged.found) or 0) ~= previousFound then
|
||||
zButtonRanged_SetupSizeAndPosition()
|
||||
else
|
||||
zButtonRanged_UpdateButton(zButtonRanged)
|
||||
end
|
||||
if event == "PLAYER_ENTERING_WORLD" then
|
||||
zButtonRanged_PrewarmTooltipOnce()
|
||||
end
|
||||
|
||||
@@ -22,6 +22,20 @@ if not root["zButtonToys"] then
|
||||
end
|
||||
|
||||
local ZHUNTER_TOYS_BUTTON_MAX = 80
|
||||
local zButtonToys_LastSpellSignature = nil
|
||||
local zButtonToys_LastRefreshAt = 0
|
||||
local zButtonToys_MinRefreshInterval = 0.50
|
||||
|
||||
local function zButtonToys_GetSpellSignature(spellIds)
|
||||
if type(spellIds) ~= "table" or table.getn(spellIds) == 0 then
|
||||
return ""
|
||||
end
|
||||
local parts = {}
|
||||
for i = 1, table.getn(spellIds) do
|
||||
parts[i] = tostring(spellIds[i] or "")
|
||||
end
|
||||
return table.concat(parts, ",")
|
||||
end
|
||||
|
||||
local function zButtonToys_GetSaved()
|
||||
local currentRoot = zButtonToys_GetRoot()
|
||||
@@ -233,11 +247,17 @@ 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)
|
||||
end
|
||||
if zButtonToys and zButtonToys.Hide then
|
||||
zButtonToys:Hide()
|
||||
end
|
||||
return
|
||||
end
|
||||
if zButtonToysAdjustment and zButtonToysAdjustment.SetScript then
|
||||
zButtonToysAdjustment:SetScript("OnEvent", zButtonToysAdjustment_OnEvent)
|
||||
end
|
||||
local displayCount = zButtonToys.found or 0
|
||||
if displayCount < 0 then
|
||||
displayCount = 0
|
||||
@@ -275,6 +295,18 @@ function zButtonToysAdjustment_OnEvent()
|
||||
if not zButtonToys then
|
||||
return
|
||||
end
|
||||
if event == "SPELLS_CHANGED" then
|
||||
local now = GetTime and GetTime() or 0
|
||||
if now > 0 and zButtonToys_LastRefreshAt > 0 and (now - zButtonToys_LastRefreshAt) < zButtonToys_MinRefreshInterval then
|
||||
return
|
||||
end
|
||||
local signature = zButtonToys_GetSpellSignature(zButtonToys_CollectTabSpellIds())
|
||||
if signature == zButtonToys_LastSpellSignature and not GameTooltip:IsOwned(zButtonToys) then
|
||||
return
|
||||
end
|
||||
zButtonToys_LastSpellSignature = signature
|
||||
zButtonToys_LastRefreshAt = now
|
||||
end
|
||||
zButtonToys_RefreshSpells()
|
||||
zButtonToys_SetupSizeAndPosition()
|
||||
if GameTooltip:IsOwned(zButtonToys) then
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -29,6 +29,8 @@ ZHunterMod_Trap_Spells = {
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -150,11 +152,17 @@ 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
|
||||
@@ -193,9 +201,11 @@ 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
|
||||
@@ -215,7 +225,13 @@ function zButtonTrapAdjustment_OnEvent()
|
||||
end
|
||||
end
|
||||
end
|
||||
zButtonTrap.id = nextbutton and nextbutton.id or zButtonTrap1.id
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user