Files

641 lines
36 KiB
Lua

-- [PFUI=1] texlua guidewin.lua <addon> <race> <class> 1 casual
-- The RestedXP-style guide window: step box with badge and tick boxes, banner, step list, footer with cog and grip.
local here = arg[0]:match("^(.*)/") or "."
dofile(here .. "/lib.lua")
local W, ER, S, P, try = H.W, H.ER, H.S, 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
local function marked(r) return r and (r.check:GetChecked() or r.skipMark:IsShown()) and true or false end
local function strip(s) return (L53.gsub(L53.gsub(s or "", "|c%x%x%x%x%x%x%x%x", ""), "|r", "")) end
local PREFIX = os.getenv("PREFIX") or "pfQuest_xpGuide"
local function F(n) return _G[PREFIX .. n] end
local SLASH = os.getenv("SLASH") or "PFQUEST_XPGUIDE"
local function click(f, button) if f and f._scripts.OnClick and not f._off then this = f; arg1 = button or "LeftButton"; f._scripts.OnClick() end end
local function menuItem(text)
for _, it in ipairs(W.menu) do if it.text and L53.match(it.text, text) then return it end end
end
local function menuTexts() local t = {} for _, it in ipairs(W.menu) do table.insert(t, it.text) end return table.concat(t, " | ") end
PLAY(25); W.Tick(0.3, 4)
local f = F("Guide")
check(f and f:IsShown(), "the guide window is up")
check(F("Tracker") == nil and F("Simple") == nil, "the old step window and simple box are gone")
-- the step box
local now = F("GuideNow")
local head = strip(now.title._text) .. " / " .. strip(now.detail._text)
local info0 = S.Info()
check(head:find(strip(info0.title or info0.name):sub(1, 6), 1, true) and L53.match(strip(now.detail._text), " on "), "the step box's heading has the guide's details: " .. head)
local stepOf = 0
local function scan(fr, d) if d > 8 then return end
for _, r in ipairs(fr._regions or {}) do if r._text and L53.match(strip(r._text), "Step %d+ of %d+") then stepOf = stepOf + 1 end end
for _, c in ipairs(fr._children or {}) do scan(c, d + 1) end end
scan(f, 0)
check(stepOf == 0, "no \"Step X of N\" anywhere in the window")
check(F("GuideBanner") == nil and F("GuideNowBadge") == nil and F("GuideSideBadge") == nil, "no banner and no edge badges")
local shown, ticks, icons = 0, 0, 0
for i = 1, 12 do
local b = F("GuideLine" .. i)
if b and b:IsShown() then
shown = shown + 1
if b.tickBox:IsShown() then ticks = ticks + 1
check((b.tickBox:GetChecked() and true or false) == (b.line.done == true), "line " .. i .. "'s tick box matches what the game says") end
if b.icon:IsShown() then icons = icons + 1 end
end
end
check(shown >= 1, shown .. " lines in the step box, " .. ticks .. " with tick boxes, " .. icons .. " with icons")
-- a quest line's tick box is not yours to click: it shows what the game says
local qok = false
for i = 1, 40 do
for j = 1, 12 do local b = F("GuideLine" .. j)
if b:IsShown() and b.tickBox:IsShown() and b.line and b.line.done == false and not S.ByHand(b.line.step) then
local p1 = S.Position(); click(b.tickBox)
check(S.Position() == p1 and not b.tickBox:GetChecked(), "a quest line's tick box stays as the game says when clicked")
qok = true break
end
end
if qok then break end
PLAY(4); W.Tick(0.2, 2)
end
check(qok, "found a quest line with a tick box")
-- the list
local rows, current, curRow, done = 0, 0, nil, 0
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then rows = rows + 1
if r.bar:IsShown() then current = current + 1; curRow = i end
if marked(r) then done = done + 1 end end end
local expect = math.floor((f:GetHeight() - 16 - 10) / 16)
check(rows == expect, "the list shows " .. rows .. " rows (" .. expect .. " fit)")
check(current == 1, "one row is marked as the current step")
check(curRow and curRow <= 4, "the current step sits near the top of the list, under the last done steps (row " .. tostring(curRow) .. ")")
check(F("GuideRow" .. curRow).step.n == S.Position(), "the marked row is the step you are on")
check(done >= 1 and (not marked(F("GuideRow" .. curRow))), "steps behind you are ticked (" .. done .. "), the current one is not")
-- the list follows the guide
local before = F("GuideRow" .. curRow).step.n
S.Next(); W.Tick(0.2, 2)
local now
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.bar:IsShown() then now = r end end
check(now and now.step.n == S.Position() and now.step.n ~= before, "after moving on, the list marks the new step (" .. tostring(now and now.step.n) .. ")")
-- the Skip button on the step box
local skip = F("GuideSkip")
-- on a step whose quest is finished the button says Finished: move to one that is not
if S.Finished(S.Current()) then
local list = S.All()
for i, it in ipairs(list) do
if not S.Finished(it.step) and not S.ByHand(it.step) and list[i + 3] and not S.Finished(list[i + 2].step) then S.Jump(it.step.n) ER.StepsChanged() break end
end
end
check(skip and skip:IsShown() and (strip(skip.text._text) == "Skip step" or strip(skip.text._text) == "Mark done"), "the step box has a one-click button: " .. strip(skip and skip.text._text or "none"))
local sp, srel, srp, sx, sy = skip:GetPoint(1)
check(skip:GetParent() == F("GuideNow") and srel == F("GuideNow") and sp == "TOPRIGHT" and srp == "TOPRIGHT" and sx < 0 and sy < 0, " ...inside the box, top right (" .. sx .. "," .. sy .. "), so no border runs through it")
local p0 = S.Position(); local st0 = S.Current()
click(skip)
check(S.Position() ~= p0 or S.Current() ~= st0, "\"Skip step\" moves on (" .. p0 .. " -> " .. S.Position() .. ")")
-- the list's tick boxes
local function rowFor(n) for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == n then return r end end end
S.Load(S.Key(S.Info()), true); ER.StepsChanged()
do
local list = S.All()
for i, it in ipairs(list) do
if not it.done and list[i + 2] and not list[i + 2].done and not S.Finished(list[i + 2].step) then S.Jump(it.step.n) ER.StepsChanged() break end
end
end
local pos = S.Position()
local all = S.All()
local later
for _, it in ipairs(all) do if it.step.n > pos + 1 and not it.done and not S.Finished(it.step) and rowFor(it.step.n) then later = it.step.n break end end
local r = rowFor(later)
check(r and not marked(r), "a later step's tick box is empty (step " .. tostring(later) .. ")")
click(r.check)
check(S.Passed(later) and rowFor(later) and rowFor(later).skipMark:IsShown() and not rowFor(later).check:GetChecked(),
"ticking a later step marks it skipped: its box shows the skip mark, not a tick")
click(rowFor(later).check)
check(not S.Passed(later) and not marked(rowFor(later)), "clicking it again brings it back")
click(rowFor(later).check)
-- the guide passes over it when it gets there
local guard = 0
while S.Position() < later and guard < 200 do S.Next(); guard = guard + 1 end
check(S.Position() ~= later, "the skipped step is passed over when the guide gets there (now at " .. S.Position() .. ")")
-- unticking a step behind you takes you back to it
W.Tick(0.2, 1); ER.StepsChanged()
local back
for _, it in ipairs(S.All()) do if it.step.n < S.Position() and it.done and S.CanUnskip(it.step.n) then back = it.step.n end end
if not back or not rowFor(back) then
-- none in view: skip the step you are on, which leaves one behind you to take back
for g = 1, 20 do
local st = S.Current()
if st and not S.Finished(st) and not S.ByHand(st) then back = st.n S.Next(true) ER.StepsChanged() break end
S.Next() ER.StepsChanged()
end
end
local rb = rowFor(back)
if not rb then FauxScrollFrame_SetOffset(F("GuideScroll"), 0) ER.StepsChanged() rb = rowFor(back) end
check(rb and marked(rb), "a step behind you is marked (step " .. tostring(back) .. ")")
click(rb.check)
check(S.Position() == back, "unticking a step behind you goes back to it")
-- ticking the current step's box skips it
local cur = rowFor(S.Position())
local p2 = S.Position()
click(cur.check)
check(S.Position() > p2, "ticking the current step's box moves on")
-- scrolling by hand
local list = F("GuideList")
local top = F("GuideRow1").step.n
this = list; arg1 = -1; list._scripts.OnMouseWheel()
check(F("GuideRow1").step.n > top, "the mouse wheel scrolls the list (" .. top .. " -> " .. F("GuideRow1").step.n .. ")")
-- right-click a row: the step menu, "Go to step"
local row = F("GuideRow" .. 5)
local target = row.step.n
click(row, "RightButton")
check(menuItem("^Go to step " .. target .. "$"), "right-click: the step's menu (" .. menuTexts() .. ")")
menuItem("^Go to step ").func()
check(S.Position() == target, "\"Go to step " .. target .. "\" goes there")
-- double-click: the menu too
W.menu = {}
local row2 = F("GuideRow" .. 6)
click(row2); W.Tick(0.1, 1); click(row2)
check(menuItem("^Go to step " .. row2.step.n .. "$"), "double-click: the step's menu")
W.menu = {}
click(F("GuideRow" .. 6)); W.Tick(1, 1); click(F("GuideRow" .. 6))
check(not menuItem("^Go to step"), "two slow clicks are not a double-click")
-- the footer: flat icons, no borders
for _, nm in ipairs({ "GuideCog", "GuideArrow", "GuideClose", "GuideLock", "GuideGrip" }) do
local b = F(nm)
local path = b and b.pic and b.pic._path or ""
check(b and b:IsShown() and L53.match(path, "Media\\Icon") and not b.dots and not b._backdrop and not b._normal,
nm .. " is a smooth texture icon (" .. path .. "), no border")
end
-- nothing in the footer touches the list's border: the list ends a gap above the footer, the icons fit inside it
local _, _, _, _, listY = F("GuideList"):GetPoint(2)
local footH = F("GuideFooter"):GetHeight()
local tallest = 0
for _, nm in ipairs({ "GuideCog", "GuideArrow", "GuideClose", "GuideLock", "GuideGrip" }) do tallest = math.max(tallest, F(nm):GetHeight()) end
check(listY - footH >= 4 and tallest <= footH - 2, "the footer icons keep clear of the list's border (list ends " .. listY .. " px up, footer " .. footH .. ", icons " .. tallest .. ")")
local _, _, _, cx = F("GuideCog"):GetPoint(1); local _, _, _, gx = F("GuideGrip"):GetPoint(1)
check(cx >= 3 and gx <= -3, " ...and clear of the window's left and right edges (" .. cx .. ", " .. gx .. ")")
local _, lrel = F("GuideLock"):GetPoint(1); local _, crel = F("GuideClose"):GetPoint(1)
check(lrel == F("GuideGrip") and crel == F("GuideLock"), "close and lock sit beside the resize grip")
local _, arel = F("GuideArrow"):GetPoint(1)
check(arel == F("GuideCog"), "the arrow icon sits beside the cog")
check(F("GuideFooter") and (function() for _, r in ipairs(F("GuideFooter")._regions or {}) do if r._text and r._text ~= "" then return false end end return true end)(), "no text in the footer")
-- cog: Settings straight away, no menu
W.menu = {}
click(F("GuideCog"))
check(table.getn(W.menu) == 0 and F("Settings") and F("Settings"):IsShown(), "the cog opens Settings directly, no menu")
F("Settings"):Hide()
-- hover tint
this = F("GuideCog"); F("GuideCog")._scripts.OnEnter()
check(F("GuideCog").over, " ...mouse-over lights the icon")
this = F("GuideCog"); F("GuideCog")._scripts.OnLeave()
-- arrow: pfQuest's / own / off
local seenA = {}
for i = 1, 4 do click(F("GuideArrow")); seenA[ER.ArrowChoice()] = (seenA[ER.ArrowChoice()] or 0) + 1 end
check(seenA.own and seenA.off, "the arrow icon goes through the arrows (" .. (seenA.pfquest and "pfquest " or "") .. "own off)")
if ER.PfQuestArrowCan() then check(seenA.pfquest, " ...pfQuest's arrow is one of them") end
while ER.ArrowChoice() == "off" do click(F("GuideArrow")) end
-- lock
click(F("GuideLock"))
check(ER.db.guideLocked and L53.match(F("GuideLock").pic._path, "IconLocked$"), "the padlock locks the window, and shows shut")
local moved = false
local raw = f.StartMoving; f.StartMoving = function() moved = true end
local banner = F("GuideNow")
this = banner; banner._scripts.OnDragStart()
check(not moved, " ...a locked window does not move")
local sized = false
local rawS = f.StartSizing; f.StartSizing = function() sized = true end
this = F("GuideGrip"); F("GuideGrip")._scripts.OnMouseDown()
check(not sized, " ...nor resize")
f.StartSizing = rawS
click(F("GuideLock"))
check(not ER.db.guideLocked, " ...and unlocks it")
this = banner; banner._scripts.OnDragStart()
check(moved, "unlocked, dragging the step box moves it")
f.StartMoving = raw
this = banner; banner._scripts.OnDragStop()
check(type(ER.db.guidePos) == "table" and ER.db.guideSize and ER.db.guideSize.w == math.floor(f:GetWidth() + 0.5), "its place and size are saved")
-- resizing: a taller window lists more steps
f:SetHeight(300)
this = F("GuideGrip"); F("GuideGrip")._scripts.OnMouseUp()
local rows2 = 0
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then rows2 = rows2 + 1 end end
check(rows2 > rows, "a taller window lists more steps (" .. rows .. " -> " .. rows2 .. ")")
check(ER.db.guideSize.h == 300, " ...and the new size is saved")
-- picking a guide is the settings window's Guides page (no separate guide menu)
ER.ShowGuideMenu()
local si = ER.SettingsInfo()
check(F("Settings"):IsShown() and si.pages[si.page].title == "Guides" and not F("GuideMenu"), "Pick a guide opens the settings window on its Guides page (" .. tostring(si.pages[si.page].title) .. ")")
check(si.pages[1].title == "Guides" and si.pages[2].title == "Configuration", " ...the pages are Guides, Configuration, ... (" .. si.pages[1].title .. ", " .. si.pages[2].title .. ")")
local noPick = true
for _, b in ipairs(si.pages[2].buttons) do if b == "Pick a guide" then noPick = false end end
check(noPick, " ...the Configuration page has no Pick a guide button any more")
local groups = S.Groups()
local gshown = 0
for i = 1, 14 do local r = F("GuideMenuGroup" .. i) if r and r:IsShown() and r.grp then gshown = gshown + 1 end end
check(gshown == table.getn(groups), " ...it lists every group (" .. gshown .. ")")
-- the biggest group scrolls: every guide can be reached
local big
for i = 1, 14 do local r = F("GuideMenuGroup" .. i) if r and r.grp and (not big or #r.grp.guides > #big.grp.guides) then big = r end end
click(big)
local seen = {}
local function look() for i = 1, 14 do local r = F("GuideMenuGuide" .. i) if r and r:IsShown() and r.guide then seen[r.guide] = true end end end
look()
for k = 1, 10 do this = F("GuideMenuPanel"); arg1 = -1; F("GuideMenuPanel")._scripts.OnMouseWheel(); look() end
local nseen = 0 for _ in pairs(seen) do nseen = nseen + 1 end
check(nseen == #big.grp.guides, " ...the mouse wheel reaches all " .. #big.grp.guides .. " guides of " .. big.grp.name .. " (" .. nseen .. ")")
-- clicking a guide starts it and closes the window
local row = F("GuideMenuGuide1")
click(row)
if row.guide and row.guide.fast then
check(F("FastSetup") and F("FastSetup"):IsShown(), " ...a Fast guide asks for the rate and professions first")
F("FastSetupStart"):GetScript("OnClick")()
end
check(S.Info() == row.guide and not F("Settings"):IsShown(), " ...clicking a guide starts it (" .. tostring(row.guide and row.guide.title) .. ")")
-- a step you tick by hand: find a guide that has one (the fast routes do)
local ticked, found = false, false
for _, g in ipairs(S.Guides and S.Guides() or {}) do
if not g.route and ER.StartGuide(S.Key(g), true, true) then
for _, it in ipairs(S.All()) do
if S.ByHand(it.step) then
S.Jump(it.step.n); ER.StepsChanged(); found = true
check(strip(F("GuideSkip").text._text) == "Mark done", "on a step you tick by hand the button says \"Mark done\"")
local st, p1 = S.Current(), S.Position()
for j = 1, 12 do local b = F("GuideLine" .. j)
if b:IsShown() and b.tickBox:IsShown() and b.line and (b.line.tick or b.line.kind == "M" or S.ByHand(b.line.step)) then
click(b.tickBox); ticked = true
check(S.Position() ~= p1 or S.Current() ~= st, "ticking a by-hand step's box marks it done (" .. g.name .. ", step " .. p1 .. ")")
break
end
end
break
end
end
end
if found then break end
end
check(found and ticked, "found a step you tick by hand, with its tick box")
-- the side box
local sideSeen = false
for i = 1, 300 do PLAY(1) if F("GuideSide"):IsShown() then sideSeen = true break end end
if sideSeen then
check(strip(F("GuideSide").title._text) == "On the way" and table.getn(S.Side()) > 0, "\"On the way\" box shows the side steps")
else P("note no side steps came up in this run") end
-- the tips box sits under the window
if ER.AddTip then ER.AddTip("test", "A tip", nil, 30); ER.PlaceTips() end
local tips = F("TipsFrame") or F("Tips")
if tips then local p, rel = tips:GetPoint(1) check(rel == f, "the tips box sits under the window") end
-- hide and show
click(F("GuideClose"))
check(not f:IsShown(), "the close icon hides it")
SlashCmdList[SLASH]("")
check(f:IsShown(), "the slash command shows it again")
-- each kind of line gets its icon: go through the guide's steps
local seenIcon, here0 = {}, S.Position()
for _, it in ipairs(S.All()) do
S.Jump(it.step.n); ER.StepsChanged()
for j = 1, 12 do local b = F("GuideLine" .. j)
if b and b:IsShown() and b.line and b.line.kind and not b.line.note and b.icon:IsShown() then seenIcon[b.line.kind] = b.icon._path end end
end
S.Jump(here0); ER.StepsChanged()
local kinds = {} for k in pairs(seenIcon) do table.insert(kinds, k) end table.sort(kinds)
check(seenIcon.A and seenIcon.T and L53.match(seenIcon.A, "AvailableQuestIcon") and L53.match(seenIcon.T, "ActiveQuestIcon"), "pick-ups and hand-ins have the quest icons (kinds with icons: " .. table.concat(kinds, " ") .. ")")
check(seenIcon.I and L53.match(seenIcon.I, "GossipGossipIcon"), "\"Talk to\" lines have the gossip icon")
-- gaps wide enough for pfUI's borders (drawn a few pixels outside each frame): the step box and the list, the two boxes
local stack = F("GuideStack")
local _, srel2, _, _, sgy = stack:GetPoint(1)
check(srel2 == F("GuideList") and sgy >= 10, "the step boxes keep " .. sgy .. " px above the list")
local _, sbrel, _, _, sby = F("GuideSide"):GetPoint(1)
check(sbrel == F("GuideNow") and -sby >= 10, "the \"On the way\" box keeps " .. (-sby) .. " px under the step box")
-- Usage and Features are tabs of the settings window, not a window of their own; no feedback, no welcome
check(F("HelpFrame") == nil and F("HelpOkButton") == nil, "no separate help window")
ER.ShowHelp()
local info = ER.SettingsInfo()
local titles = {}
for _, pg in ipairs(info.pages) do table.insert(titles, pg.title) end
check(table.concat(titles, ",") == "Guides,Configuration,Character,Auto mode,Helpers,Usage,Features", "the settings pages are " .. table.concat(titles, ", "))
check(info.pages[info.page].title == "Usage" and F("Settings"):IsShown(), "/xpg help opens the Usage tab of Settings")
check(table.getn(info.bottom) == 1 and info.bottom[1] == "Close", "the bottom row is only Close (Usage and Features moved to tabs)")
local function viewText(key) local v = F("HelpText" .. key); for _, rg in ipairs(v and v._regions or {}) do if rg._text then return rg._text end end return "" end
local usage = viewText("usage")
check(usage:find("Needs", 1, true) or usage:find("needs", 1, true) or usage:find("Depend", 1, true), "Usage lists what the addon needs")
check(not usage:find("Quest data", 1, true) and not usage:find("Thanks to", 1, true), "Usage has no \"Quest data\" or \"Thanks to\" lines")
ER.ShowHelp("features")
info = ER.SettingsInfo()
check(info.pages[info.page].title == "Features", "/xpg features opens the Features tab")
local feats = viewText("features")
check(feats:find("1.1.2", 1, true) and feats:find("1.1.1", 1, true) and feats:find("1.1.0", 1, true) and feats:find("1.0.0", 1, true) and feats:find("Feature", 1, true), "the Features tab lists features and the change history")
check(ER.ShowWelcome == nil and ER.OpenRate == nil and ER.ShowNotebook == nil and F("WelcomeFrame") == nil and F("RateFrame") == nil, "no welcome window and no rate window")
-- the words scroll when they are taller than the box
local view = F("HelpViewfeatures")
check(view and view.range and view.range > 0, "the Features words are taller than their box (" .. tostring(view and view.range) .. " to scroll)")
local script = view and view._scripts and view._scripts.OnMouseWheel
if script then
this, arg1 = view, -1
script()
check(view:GetVerticalScroll() > 0, "the mouse wheel scrolls the Features words (" .. tostring(view:GetVerticalScroll()) .. ")")
this, arg1 = view, 1
for _ = 1, 40 do script() end
check(view:GetVerticalScroll() == 0, "...and back up to the top, no further")
this, arg1 = view, -1
for _ = 1, 400 do script() end
check(view:GetVerticalScroll() == view.range, "...and down to the end, no further")
view:SetVerticalScroll(0)
else
check(false, "the Features box has a mouse wheel script")
end
F("Settings"):Hide()
-- no redundant lines in the step box: no zone progress (the heading has it), no "Stuck?" line
local function boxText() local t = "" for j = 1, 12 do local b = F("GuideLine" .. j) if b and b:IsShown() then t = t .. strip(b.text._text) .. "\n" end end return t end
for _, it in ipairs(S.All()) do
if it.step.n > S.Position() then S.Jump(it.step.n) break end
end
ER.StepsChanged()
local bt = boxText()
check(not bt:find("Stuck?", 1, true) and not L53.match(bt, "%d+/%d+ done") and not bt:find("pfQuest xpGuide", 1, true), "the step box has no zone progress, \"Stuck?\" or addon name lines")
-- Unskip previous
S.Jump(S.All()[3].step.n); ER.StepsChanged()
local un = F("GuideUnskip")
check(un and not un:IsShown(), "no \"Unskip previous\" before anything is skipped")
local was = S.Position()
click(F("GuideSkip"))
if S.Passed(was) == "skip" then
check(un:IsShown() and strip(un.text._text) == "Unskip previous", "after Skip, \"Unskip previous\" shows beside it")
local _, urel, urp = un:GetPoint(1)
check(urel == F("GuideSkip") and urp == "TOPLEFT", " ...left of the Skip button")
click(un)
check(S.Position() == was and not un:IsShown(), " ...and takes you back to the skipped step")
else P("note the step was marked done, not skipped") end
-- the list does not jump when you click; it follows when the guide moves on by itself, keeping done steps in view
f:SetHeight(300); this = F("GuideGrip"); F("GuideGrip")._scripts.OnMouseUp()
local function curRowIdx() for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.bar:IsShown() then return i end end end
local function topN() return F("GuideRow1").step.n end
-- a guide long enough to scroll
for _, g in ipairs(S.Guides and S.Guides() or {}) do
if not g.route and ER.StartGuide(S.Key(g), true, true) and table.getn(S.All()) >= 60 then break end
end
S.Load(S.Key(S.Info()), true); ER.StepsChanged() -- no skips of yours left from the tests before (they would pin the list)
P("note list tests on " .. S.Info().name .. " (" .. table.getn(S.All()) .. " steps)")
local held, heldTries = 0, 0
for k = 8, 30 do
local it = S.All()[k]
if not it then break end
S.Jump(it.step.n); ER.StepsChanged()
FauxScrollFrame_SetOffset(F("GuideScroll"), 0); G_off = nil
ER.StepsChanged()
local top0 = topN()
local ci = curRowIdx()
local seen = {}
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then seen[r.step.n] = true end end
if ci then
click(F("GuideRow" .. ci).check)
heldTries = heldTries + 1
local all2 = S.All()
local lastShown
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then lastShown = r.step.n end end
local atEnd = all2[table.getn(all2)] and lastShown == all2[table.getn(all2)].step.n
if seen[S.Position()] then
if topN() == top0 or atEnd then held = held + 1 else P("note hold: " .. it.step.n .. " -> " .. S.Position() .. " moved the list " .. top0 .. " -> " .. topN()) end
elseif curRowIdx() then held = held + 1 end
end
end
check(heldTries > 0 and held == heldTries, "ticking a step in the list leaves the list where it was, when the new step is in view (" .. held .. "/" .. heldTries .. ")")
S.Load(S.Key(S.Info()), true); ER.StepsChanged() -- the ticks above were skips of yours (buttons that pin the list)
local pass, tries = 0, 0
for k = 8, 30 do
local it = S.All()[k]
if not it then break end
S.Jump(it.step.n); ER.StepsChanged()
local before = S.Position()
S.Next(); ER.StepsChanged()
local ci2 = curRowIdx()
local idx
for i, x in ipairs(S.All()) do if x.step.n == S.Position() then idx = i end end
if idx and idx > 4 and ci2 and idx < table.getn(S.All()) - 20 then
tries = tries + 1
local doneAbove = 0
for i = 1, ci2 - 1 do if marked(F("GuideRow" .. i)) then doneAbove = doneAbove + 1 end end
if ci2 == 4 and doneAbove == 3 then pass = pass + 1 else P("note follow: row " .. ci2 .. ", " .. doneAbove .. " done above") end
end
end
check(tries > 0 and pass == tries, "moving on by itself, the list keeps 3 done steps above the current one (" .. pass .. "/" .. tries .. ")")
-- completed and skipped steps look different in the list: a tick and a grey title, or the skip mark and an amber title
S.Load(S.Key(S.Info()), true); ER.StepsChanged()
do
local list = S.All()
local doneN, skipN
-- finish one step for real (its work done), skip the next one yourself
for g = 1, 30 do
local st = S.Current()
if st and not S.ByHand(st) and not S.Finished(st) then
for _, e in ipairs(st.elements) do
local id = tonumber(e.id)
if e.kind == "A" and id and not S.InLog(id) then table.insert(W.log, { id = id, title = S.QuestTitle(id), level = S.QuestLevel(id) or 1, objs = { { text = "thing: 0/1", done = false } } }) end
end
W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 4)
if S.Current() ~= st then doneN = st.n break end
end
S.Next(); ER.StepsChanged()
end
for g = 1, 30 do
local st = S.Current()
if st and not S.ByHand(st) and not S.Finished(st) then skipN = st.n click(F("GuideSkip")) break end
S.Next(); ER.StepsChanged()
end
local function row(n) for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == n then return r end end end
FauxScrollFrame_SetOffset(F("GuideScroll"), 0) ER.StepsChanged()
local rd, rs = row(doneN), row(skipN)
if rd and rs then
check(rd.how == "done" and rd.check:GetChecked() and not rd.skipMark:IsShown() and rd.text._text:sub(1, 10) == ER.GREY,
"a completed step: ticked, grey title (step " .. doneN .. ")")
check(rs.how == "skip" and not rs.check:GetChecked() and rs.skipMark:IsShown() and L53.match(rs.skipMark._path or "", "IconSkipped$")
and (rs.regain and rs.btn[1]:IsShown() or L53.match(rs.text._text, "^|cffd9a24a")),
"a skipped step: the skip mark instead of a tick" .. (rs.regain and ", and a button to go back to it" or ", amber title") .. " (step " .. skipN .. ")")
else P("note could not set up a completed and a skipped step (" .. tostring(doneN) .. ", " .. tostring(skipN) .. ")") end
-- take the skip back, so the tests after this start clean
if skipN then S.Jump(skipN) ER.StepsChanged() end
end
-- text size: pfQuest's by default; Settings has left/right arrows with the size between them, as a bag's stack split
check(ER.FontSize() == 12, "text follows pfQuest's size by default (" .. ER.FontSize() .. ")")
local fs = F("GuideLine1").text
check(fs._size == 12, "step lines use it (" .. tostring(fs._size) .. ")")
local rows16 = 0 for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then rows16 = rows16 + 1 end end
ER.ShowSettings("Configuration")
local L, V, R = F("SettingsSizeLeft"), F("SettingsSizeValue"), F("SettingsSizeRight")
check(L and V and R and L._normal and L53.match(L._normal._path, "Arrow%-Left") and L53.match(R._normal._path, "Arrow%-Right"), "Settings shows the size between a left and a right arrow")
local _, lr = V:GetPoint(1); local _, rr = R:GetPoint(1)
check(lr == L and rr == V, " ...left arrow, size, right arrow, in a row")
check(strip(V.text._text):find("12", 1, true) and strip(V.text._text):find("pfQuest", 1, true), " ...the number says 12, following pfQuest (" .. strip(V.text._text) .. ")")
for i = 1, 4 do click(R) end
check(ER.FontSize() == 16 and fs._size == 16 and strip(V.text._text) == "16", "four clicks right: 16, in the step box too (" .. strip(V.text._text) .. ")")
local rowsBig = 0 for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() then rowsBig = rowsBig + 1 end end
check(rowsBig < rows16 and F("GuideRow1"):GetHeight() == 20, " ...the list rows grow with it (" .. rows16 .. " -> " .. rowsBig .. " rows)")
click(L)
check(ER.FontSize() == 15, "one click left: 15")
for i = 1, 30 do click(L) end
check(ER.FontSize() == ER.FONT_MIN and L._off and not R._off, "the left arrow stops at " .. ER.FONT_MIN .. " and greys out")
-- Auto mode and Helpers: ticks grouped under small headings; Auto mode's own ticks cannot be clicked while it is off
local si2 = ER.SettingsInfo()
check(table.getn(si2.pages[4].sections) >= 3 and table.getn(si2.pages[5].sections) >= 3,
"Auto mode and Helpers group their ticks (" .. table.concat(si2.pages[4].sections, ", ") .. " / " .. table.concat(si2.pages[5].sections, ", ") .. ")")
ER.ShowSettings("Auto mode")
local first = #si2.pages[2].checks + #si2.pages[3].checks + 1
local master, part = F("SettingsCheck" .. first), F("SettingsCheck" .. (first + 1))
check(master and part and not part._off, " ...Auto mode's ticks work while it is on")
master:SetChecked(nil); click(master)
check(ER.db.autoOff and part._off, " ...and are greyed and locked while it is off")
master:SetChecked(1); click(master)
check(not ER.db.autoOff and not part._off, " ...and work again when it is back on")
click(V)
check(ER.db.fontSize == nil and ER.FontSize() == 12 and fs._size == 12, "clicking the number goes back to pfQuest's size")
F("Settings"):Hide()
SlashCmdList[SLASH]("font 14")
check(ER.FontSize() == 14, "/xpg font 14 still works")
SlashCmdList[SLASH]("font pfquest")
-- a finished quest cannot be skipped: a hand-in step whose quest is complete in your log
local fin
for _, it in ipairs(S.All()) do
for _, e in ipairs(it.step.elements) do if e.kind == "T" and tonumber(e.id) and S.QuestTitle(e.id) and not S.ByHand(it.step) then fin = fin or { it.step, e.id } end end
end
if fin then
local st, qid = fin[1], fin[2]
S.Jump(st.n); ER.StepsChanged()
for i = table.getn(W.log), 1, -1 do if W.log[i].title == S.QuestTitle(qid) then table.remove(W.log, i) end end
table.insert(W.log, { id = tonumber(qid), title = S.QuestTitle(qid), level = S.QuestLevel(qid) or 1, complete = true, objs = { { text = "thing: 1/1", done = true } } })
W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 3); ER.StepsChanged()
if S.Position() == st.n then
check(S.Finished(st), "a hand-in step with its quest complete counts as finished")
local sk = F("GuideSkip")
check(sk._off and strip(sk.text._text) == "Finished", " ...its button says Finished and cannot be clicked (" .. strip(sk.text._text) .. ")")
local p0 = S.Position()
sk._off = nil; click(sk)
check(S.Position() == p0, " ...and even a click does not skip it")
local cur = nil for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step and r.step.n == p0 then cur = r end end
if cur then click(cur.check) check(S.Position() == p0 and not cur.check:GetChecked(), " ...nor does its tick box in the list") end
else P("note the finished step moved on by itself in this run") end
for i = table.getn(W.log), 1, -1 do if W.log[i].id == tonumber(qid) then table.remove(W.log, i) end end
W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 2)
-- later: a later step whose quest is finished cannot be ticked to skip
local later
for _, it in ipairs(S.All()) do if it.step.n > S.Position() + 1 and not it.done then
for _, e in ipairs(it.step.elements) do if e.kind == "T" and tonumber(e.id) and S.QuestTitle(e.id) and not later then later = { it.step, e.id } end end
end end
if later then
for i = table.getn(W.log), 1, -1 do if W.log[i].title == S.QuestTitle(later[2]) then table.remove(W.log, i) end end
table.insert(W.log, { id = tonumber(later[2]), title = S.QuestTitle(later[2]), level = S.QuestLevel(later[2]) or 1, complete = true, objs = { { text = "thing: 1/1", done = true } } })
W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 2)
if S.Finished(later[1]) then
S.SkipLater(later[1].n, true)
check(not S.Passed(later[1].n), "a later step whose quest is finished cannot be marked skipped")
end
for i = table.getn(W.log), 1, -1 do if W.log[i].id == tonumber(later[2]) then table.remove(W.log, i) end end
W.Fire("QUEST_LOG_UPDATE"); W.Tick(0.4, 2)
end
else P("note no hand-in step to test finished quests on") end
-- chain lines: a chain's line runs unbroken through every visible row from its first step to its last, the chain's
-- shape on the line at its own steps (and only there)
local function rows()
local out = {}
for i = 1, 60 do local r = F("GuideRow" .. i) if r and r:IsShown() and r.step then table.insert(out, r) end end
return out
end
local function chainInView()
local vis = rows()
for l = 1, 5 do
local first, last
for k, r in ipairs(vis) do if r.rail[l].chain then first = first or k last = k end end
if first and last and last - first >= 2 then return l, vis end
end
end
local lane, vis = chainInView()
if not lane then
for _, g in ipairs(S.Guides and S.Guides() or {}) do
if not g.route and ER.StartGuide(S.Key(g), true, true) then
for _, it in ipairs(S.All()) do
S.Jump(it.step.n); ER.StepsChanged()
lane, vis = chainInView()
if lane then break end
end
end
if lane then break end
end
end
if lane then
local root = nil
local broken, between, nodesOk, k0, k1 = 0, 0, true, nil, nil
for k, r in ipairs(vis) do
local rl = r.rail[lane]
if rl.chain then
if root and rl.chain ~= root then root = nil end
root = root or rl.chain
k0 = k0 or k
k1 = k
end
end
for k = k0, k1 do
local r, prev = vis[k], vis[k - 1]
local rl = r.rail[lane]
-- the line reaches the row's middle from above (unless the chain starts here) and leaves it below (unless it ends here)
if k > k0 and not (rl.up:IsShown() and prev.rail[lane].down:IsShown()) then broken = broken + 1 end
local own = false
for _, m in ipairs(r.chains or {}) do if m.root == rl.chain then own = true end end
if not own then between = between + 1 end
-- its shape sits on the line exactly at its own steps
local onLine = false
for kk = 1, 3 do
local t = r.chainMark[kk]
if t:IsShown() then local _, rel, _, x = t:GetPoint(1) if rel == r and math.abs(x - (21 + (lane - 1) * 7)) < 0.5 then onLine = true end end
end
if own ~= onLine then nodesOk = false end
end
check(broken == 0, "a chain's line runs unbroken over " .. (k1 - k0 + 1) .. " rows (lane " .. lane .. ", " .. broken .. " gaps)")
check(nodesOk, " ...with the chain's shape on the line at its own steps only (" .. between .. " other steps passed through)")
local own
for k = k0, k1 do for _, m in ipairs(vis[k].chains or {}) do if m.root == vis[k].rail[lane].chain then own = own or vis[k] end end end
if own then
G_hover = own; own:Hover(true)
local mid = vis[math.floor((k0 + k1) / 2)].rail[lane]
check(mid.up._vc[4] == 1, " ...hovering one of its steps brings its whole line to full strength")
own:Hover(false)
check(mid.up._vc[4] < 1, " ...and back off it")
end
local _, _, _, tx = vis[k0].text:GetPoint(1)
check(tx >= 18 + 7, " ...and the step text starts right of the lines (" .. tx .. " px)")
else P("note no chain in view in the guides tried") end
-- unskipping brings back what the skip left out: the quest marks and the chain steps passed over with it
S.Load(S.Key(S.Info()), true); ER.StepsChanged()
local tried = false
for _, it in ipairs(S.All()) do
local st = it.step
local id = nil
for _, e in ipairs(st.elements) do if e.kind == "A" and tonumber(e.id) and ER.ChainOf and ER.ChainOf(tonumber(e.id)) then id = tonumber(e.id) end end
if id and not S.ByHand(st) then
S.Jump(st.n); ER.StepsChanged()
if S.Position() == st.n and not S.Finished(st) then
tried = true
local openBefore = {}
for i = st.n + 1, st.n + 400 do if not S.Passed(i) then openBefore[i] = true end end
click(F("GuideSkip"))
local marked = ER.LearnedHard(id)
local passedNow = {}
for i = st.n + 1, S.Position() - 1 do if openBefore[i] and S.Passed(i) == "skip" then table.insert(passedNow, i) end end
check(S.SkippedBehind() == st.n and F("GuideUnskip"):IsShown(), "after skipping a chain's step, Unskip previous is offered")
click(F("GuideUnskip"))
local back = 0
for _, i in ipairs(passedNow) do if not S.Passed(i) then back = back + 1 end end
check(S.Position() == st.n and not ER.LearnedHard(id), "Unskip previous takes the skip back, and its quest is no longer left out (was " .. tostring(marked) .. ")")
check(back == table.getn(passedNow), " ...the " .. table.getn(passedNow) .. " steps passed over with it are back too (" .. back .. ")")
break
end
end
end
if not tried then P("note no chain step to skip and unskip") end
P(fails == 0 and "ALL PASSED" or (fails .. " FAILED"))
REPORT()