Close the window when Escape is pressed
Register the main frame ("AmibisMainFrame") in UISpecialFrames so Escape
hides it and suppresses the game menu while it is open, matching the
default UI panels.
Move the stats-retry timer cleanup into the frame's OnHide script so the
close button, Escape, and /amibis all stop the timer.
Tests: the mock now registers named frames in _G and runs OnHide scripts.
The UI suite simulates FrameXML's CloseSpecialWindows() and asserts the
frame hides and the retry timer is cleared. 108 passing.
This commit is contained in:
1 parent
cc3971fe93
commit
d8fefc947e
6 files changed
+77
-9
No files matched your search
@@ -71,7 +71,7 @@ local function makeChild()
|
||||
end
|
||||
|
||||
local function makeFrame()
|
||||
local frame = { fonts = {}, textures = {}, shown = true, width = 0, height = 0 }
|
||||
local frame = { fonts = {}, textures = {}, shown = true, width = 0, height = 0, scripts = {} }
|
||||
return setmetatable(frame, {
|
||||
__index = function(self, key)
|
||||
if key == "CreateFontString" then
|
||||
@@ -86,10 +86,28 @@ local function makeFrame()
|
||||
table.insert(self.textures, tx)
|
||||
return tx
|
||||
end
|
||||
elseif key == "SetScript" then
|
||||
return function(_, event, handler)
|
||||
self.scripts[event] = handler
|
||||
return self
|
||||
end
|
||||
elseif key == "GetScript" then
|
||||
return function(_, event)
|
||||
return self.scripts[event]
|
||||
end
|
||||
elseif key == "Show" then
|
||||
return function() self.shown = true; return self end
|
||||
return function()
|
||||
self.shown = true
|
||||
return self
|
||||
end
|
||||
elseif key == "Hide" then
|
||||
return function() self.shown = false; return self end
|
||||
return function()
|
||||
local wasShown = self.shown
|
||||
self.shown = false
|
||||
local handler = self.scripts["OnHide"]
|
||||
if wasShown and handler then handler(self) end
|
||||
return self
|
||||
end
|
||||
elseif key == "IsShown" then
|
||||
return function() return self.shown end
|
||||
elseif key == "SetSize" then
|
||||
@@ -112,11 +130,15 @@ local function makeFrame()
|
||||
end
|
||||
|
||||
_G.MockFrames = {}
|
||||
function CreateFrame()
|
||||
function CreateFrame(frameType, name, parent, template)
|
||||
local f = makeFrame()
|
||||
if name then
|
||||
_G[name] = f
|
||||
end
|
||||
table.insert(_G.MockFrames, f)
|
||||
return f
|
||||
end
|
||||
|
||||
_G.GameTooltip = makeFrame()
|
||||
_G.SlashCmdList = {}
|
||||
_G.UISpecialFrames = { "GameMenuFrame", "StaticPopup1" }
|
||||
Reference in new issue
Block a user