Fix error on Classic with Hide Party

I neglected to test the new party-hide implementation on pre-10.0. It was not fully implemented. This implementation is from Pitbull4 and is more complicated than I need, but certainly does the job and allows for some future usage if needed.

Fixes wowace ticket #330
This commit is contained in:
Parnic
2022-10-30 23:21:31 -05:00
parent cac0deeb3c
commit acc400de6e
7 changed files with 103 additions and 1 deletions

View File

@ -37,6 +37,9 @@ externals:
libs/AceLocale-3.0: libs/AceLocale-3.0:
url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0 url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0
tag: latest tag: latest
libs/AceHook-3.0:
url: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceHook-3.0
tag: latest
libs/LibRangeCheck-2.0: libs/LibRangeCheck-2.0:
url: https://github.com/WeakAuras/LibRangeCheck-2.0/ url: https://github.com/WeakAuras/LibRangeCheck-2.0/
libs/LibSharedMedia-3.0: libs/LibSharedMedia-3.0:

View File

@ -284,6 +284,8 @@ function IceCore.prototype:Enable(userToggle)
self.IceHUDFrame:RegisterEvent("ZONE_CHANGED") self.IceHUDFrame:RegisterEvent("ZONE_CHANGED")
end end
self.IceHUDFrame:RegisterEvent("UNIT_AURA") self.IceHUDFrame:RegisterEvent("UNIT_AURA")
self.IceHUDFrame:RegisterEvent("PLAYER_REGEN_ENABLED", IceHUD.PLAYER_REGEN_ENABLED)
self.IceHUDFrame:RegisterEvent("PLAYER_REGEN_DISABLED", IceHUD.PLAYER_REGEN_DISABLED)
self.IceHUDFrame:SetScript("OnEvent", function(self, event, ...) self.IceHUDFrame:SetScript("OnEvent", function(self, event, ...)
if (event == "PET_BATTLE_OPENING_START") then if (event == "PET_BATTLE_OPENING_START") then
if IceHUD.IceCore.settings.bHideDuringPetBattles then if IceHUD.IceCore.settings.bHideDuringPetBattles then

View File

@ -1,5 +1,5 @@
local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false) local L = LibStub("AceLocale-3.0"):GetLocale("IceHUD", false)
IceHUD = LibStub("AceAddon-3.0"):NewAddon("IceHUD", "AceConsole-3.0") IceHUD = LibStub("AceAddon-3.0"):NewAddon("IceHUD", "AceConsole-3.0", "AceHook-3.0")
local IceHUD = IceHUD local IceHUD = IceHUD
@ -963,3 +963,53 @@ UIDropDownMenu_Initialize(IceHUD_UnitFrame_DropDown, function()
UnitPopup_ShowMenu(IceHUD_UnitFrame_DropDown, menu, IceHUD.DropdownUnit, nil, id) UnitPopup_ShowMenu(IceHUD_UnitFrame_DropDown, menu, IceHUD.DropdownUnit, nil, id)
end end
end, "MENU", nil) end, "MENU", nil)
function IceHUD:OutOfCombatWrapper(func)
return function(...)
return IceHUD:RunOnLeaveCombat(func, ...)
end
end
do
local in_combat = false
local in_lockdown = false
local actions_to_perform = {}
local pool = setmetatable({}, {__mode='k'})
function IceHUD:PLAYER_REGEN_ENABLED()
in_combat = false
in_lockdown = false
for i, t in ipairs(actions_to_perform) do
t.f(unpack(t, 1, t.n))
actions_to_perform[i] = nil
wipe(t)
pool[t] = true
end
end
function IceHUD:PLAYER_REGEN_DISABLED()
in_combat = true
end
function IceHUD:RunOnLeaveCombat(func, ...)
if not in_combat then
-- out of combat, call right away and return
func(...)
return
end
if not in_lockdown then
in_lockdown = InCombatLockdown() -- still in PLAYER_REGEN_DISABLED
if not in_lockdown then
func(...)
return
end
end
local t = next(pool) or {}
pool[t] = nil
t.f = func
local n = select('#', ...)
t.n = n
for i = 1, n do
t[i] = select(i, ...)
end
actions_to_perform[#actions_to_perform+1] = t
end
end

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
v1.14.1:
- Fix Hide Party feature on pre-10.0 clients.
v1.14.0: v1.14.0:
- 10.0 compatibility - 10.0 compatibility

View File

@ -11,6 +11,7 @@
<Include file="libs\AceConsole-3.0\AceConsole-3.0.xml"/> <Include file="libs\AceConsole-3.0\AceConsole-3.0.xml"/>
<Include file="libs\AceAddon-3.0\AceAddon-3.0.xml"/> <Include file="libs\AceAddon-3.0\AceAddon-3.0.xml"/>
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/> <Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
<Include file="libs\AceHook-3.0\AceHook-3.0.xml"/>
<Include file="libs\LibDogTag-3.0\lib.xml"/> <Include file="libs\LibDogTag-3.0\lib.xml"/>
<Include file="libs\LibDogTag-Unit-3.0\lib.xml"/> <Include file="libs\LibDogTag-Unit-3.0\lib.xml"/>
<Script file="libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua"/> <Script file="libs\LibRangeCheck-2.0\LibRangeCheck-2.0.lua"/>

View File

@ -1418,6 +1418,44 @@ function PlayerHealth.prototype:HideBlizz()
PlayerFrame:SetParent(self.PlayerFrameParent) PlayerFrame:SetParent(self.PlayerFrameParent)
end end
local parents = {}
local hide_frame = IceHUD:OutOfCombatWrapper(function(self) self:Hide() end)
local function hook_frames(...)
for i = 1, select("#", ...) do
local frame = select(i, ...)
frame:UnregisterAllEvents()
if not IceHUD:IsHooked(frame, "OnShow") then
IceHUD:SecureHookScript(frame, "OnShow", hide_frame)
end
frame:Hide()
end
end
local function unhook_frame(frame)
if IceHUD:IsHooked(frame, "OnShow") then
IceHUD:Unhook(frame, "OnShow")
local parent = parents[frame]
if parent then
frame:SetParent(parent)
end
elseif IceHUD:IsHooked(frame, "Show") then
IceHUD:Unhook(frame, "Show")
IceHUD:Unhook(frame, "SetPoint")
end
end
local function unhook_frames(...)
for i = 1, select("#", ...) do
local frame = select(i, ...)
unhook_frame(frame)
local handler = frame:GetScript("OnLoad")
if handler then
handler(frame)
end
end
end
function PlayerHealth.prototype:HideBlizzardParty() function PlayerHealth.prototype:HideBlizzardParty()
if self.combat then if self.combat then
self.pendingBlizzardPartyHide = true self.pendingBlizzardPartyHide = true

View File

@ -1,5 +1,9 @@
# Changelog # Changelog
v1.14.1:
- Fix Hide Party feature on pre-10.0 clients.
v1.14.0: v1.14.0:
- 10.0 compatibility - 10.0 compatibility