zAmmo low-ammo flash + usage tracker; zPet unhappy flash; split parent/child tooltips

This commit is contained in:
DuvelCorp
2026-10-08 08:10:17 +02:00
parent 69c6d44b8e
commit 14f33b35ca
5 changed files with 369 additions and 1 deletions
+66
View File
@@ -57,6 +57,68 @@ local function zButtonPet_GetSaved()
return currentRoot["zButtonPet"]
end
-- Persistent "feed me" nudge: pulse the zPet parent while the pet is Unhappy.
local MTH_ZH_PetHappyFlashDriver
local zButtonPet_HappyFlashElapsed = 0
local function zButtonPet_EnsureHappyFlash()
local button = getglobal("zButtonPet")
if not button then
return nil
end
if button.petHappyFlash then
return button.petHappyFlash
end
local tex = button:CreateTexture(nil, "OVERLAY")
tex:SetTexture("Interface\\Buttons\\UI-ActionButton-Border")
tex:SetBlendMode("ADD")
tex:SetVertexColor(1, 0.15, 0.15)
tex:SetPoint("CENTER", button, "CENTER", 0, 0)
tex:SetWidth((button:GetWidth() or 36) * 1.6)
tex:SetHeight((button:GetHeight() or 36) * 1.6)
tex:Hide()
button.petHappyFlash = tex
return tex
end
local function zButtonPet_HappyFlashOnUpdate()
local button = getglobal("zButtonPet")
if not (button and button.petHappyFlash and button.petHappyFlash:IsShown()) then
return
end
zButtonPet_HappyFlashElapsed = zButtonPet_HappyFlashElapsed + (arg1 or 0)
button.petHappyFlash:SetAlpha(0.4 + 0.4 * math.sin(zButtonPet_HappyFlashElapsed * 3))
end
local function zButtonPet_SetHappyFlashRunning(running)
if running and not MTH_ZH_PetHappyFlashDriver then
MTH_ZH_PetHappyFlashDriver = CreateFrame("Frame", "MTH_ZH_PetHappyFlashDriver")
end
if not MTH_ZH_PetHappyFlashDriver then
return
end
MTH_ZH_PetHappyFlashDriver:SetScript("OnUpdate", running and zButtonPet_HappyFlashOnUpdate or nil)
end
local function zButtonPet_UpdateHappyFlash(happiness)
local tex = zButtonPet_EnsureHappyFlash()
if not tex then
return
end
local saved = zButtonPet_GetSaved()
local enabled = saved["unhappyflash"]
if enabled == nil then
enabled = 1
end
if enabled and happiness ~= nil and tonumber(happiness) == 1 then
tex:Show()
zButtonPet_SetHappyFlashRunning(true)
else
tex:Hide()
zButtonPet_SetHappyFlashRunning(false)
end
end
local function zButtonPet_EnsureConfig()
local saved = zButtonPet_GetSaved()
saved["count"] = nil
@@ -131,6 +193,9 @@ local function zButtonPet_EnsureConfig()
saved["visible"][i] = 1
end
end
if saved["unhappyflash"] == nil then
saved["unhappyflash"] = 1
end
end
local function zButtonPet_ApplyRuntimeSettings()
@@ -347,6 +412,7 @@ local function zButtonPet_RefreshSavedPetState(saved, corePetInfo)
end
local prevHappiness = saved["pet"]["happiness"]
saved["pet"]["happiness"] = happiness
zButtonPet_UpdateHappyFlash(happiness)
-- Animations: flash the pet button when happiness or loyalty changes.
if type(MTH_FX_Flash) == "function" and type(MTH_FX_IsEnabled) == "function" then