-- [PFUI=1] texlua closecheck.lua 1 casual -- Every close button keeps its centre when it becomes the flat x; the step window's tab sits above the step box. local results = {} local function centre(b) local p, rel, rp, x, y = b:GetPoint(1) local OFF = { TOPLEFT = { 1, -1 }, TOP = { 0, -1 }, TOPRIGHT = { -1, -1 }, LEFT = { 1, 0 }, CENTER = { 0, 0 }, RIGHT = { -1, 0 }, BOTTOMLEFT = { 1, 1 }, BOTTOM = { 0, 1 }, BOTTOMRIGHT = { -1, 1 } } local o = OFF[p or "CENTER"] return rel, rp, x + o[1] * b:GetWidth() / 2, y + o[2] * b:GetHeight() / 2 end function PRE_EVENTS() local raw = pfQuest_xpGuide.Skin.Close pfQuest_xpGuide.Skin.Close = function(b) local r1, rp1, x1, y1 = centre(b) raw(b) local r2, rp2, x2, y2 = centre(b) table.insert(results, { name = b:GetName() or "?", same = (r1 == r2 and rp1 == rp2 and math.abs(x1 - x2) < .01 and math.abs(y1 - y2) < .01), before = string.format("%s %s %.1f,%.1f", tostring(r1 and r1:GetName()), rp1, x1, y1), after = string.format("%s %s %.1f,%.1f", tostring(r2 and r2:GetName()), rp2, x2, y2) }) end end local here = arg[0]:match("^(.*)/") or "." dofile(here .. "/lib.lua") local W, ER, P, try = H.W, H.ER, H.P, H.try local fails = 0 local function check(ok, what) if not ok then fails = fails + 1; P("FAIL " .. what) else P("ok " .. what) end end PLAY(30) for _, fn in ipairs({ "ShowSettings", "ShowWizard", "ShowGuideMenu", "ShowHelp", "ShowExport", "ShowWelcome", "ShowTracker", "ShowWindow" }) do if ER[fn] then try(fn, function() ER[fn]() end) end end W.Tick(0.2, 12) local PF = os.getenv("PFUI") ~= nil if PF then check(#results >= 3, #results .. " close buttons became the flat x") for _, r in ipairs(results) do check(r.same, r.name .. " keeps its centre (" .. r.before .. " -> " .. r.after .. ")") end -- the guide window: nothing straddles a box's border (no edge badge; the Skip button is inside the box) check(_G.pfQuest_xpGuideGuideNowBadge == nil and _G.pfQuest_xpGuideGuideSideBadge == nil, "no edge badges on the step boxes") local sk = _G.pfQuest_xpGuideGuideSkip local p, rel, rp, x, y = sk:GetPoint(1) check(rel == _G.pfQuest_xpGuideGuideNow and p == "TOPRIGHT" and x <= -6 and y <= -6, "the Skip button sits inside the step box (" .. x .. "," .. y .. ")") else check(#results == 0, "without pfUI no close button is touched") check(_G.pfQuest_xpGuideGuideNowBadge == nil, "no edge badges on the step boxes") local p, rel = _G.pfQuest_xpGuideGuideSkip:GetPoint(1) check(rel == _G.pfQuest_xpGuideGuideNow, "the Skip button sits inside the step box") end P(fails == 0 and "ALL PASSED" or (fails .. " FAILED")) REPORT()