Skip to content

Commit f7babbd

Browse files
committed
Fixed an issue with the Island Expedition result frame hiding as soon as it shows
1 parent 222d409 commit f7babbd

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

NoAutoclose.lua

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
local addonName, ns = ...;
22

3-
--- @type { [ string ] : { checkFit: boolean, checkFitExtraWidth: number, checkFitExtraHeight: number } }
3+
--- @type table<string, { checkFit: boolean, checkFitExtraWidth: number, checkFitExtraHeight: number }>
44
ns.hookedFrames = {};
5+
--- @type table<string, boolean> # true if hooked, false if pending
6+
ns.ignoreControlLostFrames = {};
57
ns.ignore = {
68
BarberShopFrame = true, -- barbershop frame, better to allow it to hide the UI
79
CinematicFrame = true, -- cinematic frame, better to allow it to hide the UI
@@ -145,7 +147,7 @@ function ns:OnHideUIPanel(frame)
145147
end
146148
end
147149

148-
function ns:DetectStaleUiPanels()
150+
function ns:DetectStaleUIPanels()
149151
local inCombat = InCombatLockdown();
150152
local shownFrames = {};
151153
for position, _ in pairs(FRAME_POSITION_KEYS) do
@@ -206,11 +208,15 @@ function ns:HandleUIPanel(name, info, flippedUiSpecialFrames)
206208
flippedUiSpecialFrames[name] = true;
207209
tinsert(UISpecialFrames, name);
208210
end
211+
local panelInfo = UIPanelWindows[name];
209212
self.hookedFrames[name] = {
210-
checkFit = UIPanelWindows[name] and UIPanelWindows[name].checkFit,
211-
checkFitExtraWidth = UIPanelWindows[name] and UIPanelWindows[name].checkFitExtraWidth or CHECK_FIT_DEFAULT_EXTRA_WIDTH,
212-
checkFitExtraHeight = UIPanelWindows[name] and UIPanelWindows[name].checkFitExtraHeight or CHECK_FIT_DEFAULT_EXTRA_HEIGHT,
213+
checkFit = panelInfo and panelInfo.checkFit,
214+
checkFitExtraWidth = panelInfo and panelInfo.checkFitExtraWidth or CHECK_FIT_DEFAULT_EXTRA_WIDTH,
215+
checkFitExtraHeight = panelInfo and panelInfo.checkFitExtraHeight or CHECK_FIT_DEFAULT_EXTRA_HEIGHT,
213216
};
217+
if panelInfo and panelInfo.ignoreControlLost then
218+
self.ignoreControlLostFrames[name] = false;
219+
end
214220
setNil(UIPanelWindows, name);
215221
if frame.SetAttribute then
216222
frame:SetAttribute('UIPanelLayout-defined', nil);
@@ -232,7 +238,7 @@ function ns:AddToCombatLockdownQueue(func, ...)
232238
end
233239

234240
function ns:PLAYER_REGEN_ENABLED()
235-
self:DetectStaleUiPanels();
241+
self:DetectStaleUIPanels();
236242

237243
if #self.combatLockdownQueue == 0 then return; end
238244

@@ -243,7 +249,7 @@ function ns:PLAYER_REGEN_ENABLED()
243249
end
244250

245251
function ns:PLAYER_REGEN_DISABLED()
246-
self:DetectStaleUiPanels();
252+
self:DetectStaleUIPanels();
247253

248254
-- if any frame has become protected since it was last shown, we need to configure the secure esc handler
249255
for frameName, _ in pairs(self.hookedFrames) do
@@ -325,6 +331,16 @@ function ns:ADDON_LOADED(loadedAddon)
325331
for name, info in pairs(UIPanelWindows) do
326332
self:HandleUIPanel(name, info, flippedUiSpecialFrames);
327333
end
334+
for name, isHooked in pairs(self.ignoreControlLostFrames) do
335+
if not isHooked and _G[name] and type(_G[name]) == 'table' then
336+
self.ignoreControlLostFrames[name] = true;
337+
_G[name]:HookScript('OnHide', function(f)
338+
if debugstack(3):find("in function .CloseAllWindows_WithExceptions.") then
339+
ShowUIPanel(f);
340+
end
341+
end);
342+
end
343+
end
328344
if InCombatLockdown() and WorldMapFrame:IsProtected() then
329345
self:AddToCombatLockdownQueue(function()
330346
WorldMapFrame:SetAttribute('UIPanelLayout-defined', '1');
@@ -369,7 +385,7 @@ function ns:Init()
369385
hooksecurefunc('RegisterUIPanel', function() self:ADDON_LOADED(); end);
370386
hooksecurefunc('DisplayInterfaceActionBlockedMessage', function() self:OnDisplayInterfaceActionBlockedMessage(); end);
371387
hooksecurefunc('RestoreUIPanelArea', function(frame) self:SetDefaultPosition(frame); end);
372-
hooksecurefunc('CloseWindows', function() self:DetectStaleUiPanels(); end);
388+
hooksecurefunc('CloseWindows', function() self:DetectStaleUIPanels(); end);
373389
self:ReworkSettingsOpenAndClose();
374390

375391
self.eventFrame = CreateFrame('Frame');
@@ -472,10 +488,10 @@ end
472488
function ns:GetMoverFrame(onMoveCallback)
473489
local NineSliceLayout =
474490
{
475-
["TopRightCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x=8, y=8 },
476-
["TopLeftCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x=-8, y=8 },
477-
["BottomLeftCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x=-8, y=-8 },
478-
["BottomRightCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x=8, y=-8 },
491+
["TopRightCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x = 8, y = 8 },
492+
["TopLeftCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x = -8, y = 8 },
493+
["BottomLeftCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x = -8, y = -8 },
494+
["BottomRightCorner"] = { atlas = "%s-NineSlice-Corner", mirrorLayout = true, x = 8, y = -8 },
479495
["TopEdge"] = { atlas = "_%s-NineSlice-EdgeTop" },
480496
["BottomEdge"] = { atlas = "_%s-NineSlice-EdgeBottom" },
481497
["LeftEdge"] = { atlas = "!%s-NineSlice-EdgeLeft" },

0 commit comments

Comments
 (0)