From 8e8d7da8fc6f8bddc01caca5bdd98e85b10d2b7b Mon Sep 17 00:00:00 2001 From: John Coffey Date: Mon, 16 Nov 2026 22:00:24 -0700 Subject: [PATCH] Detect existing progress and redesign the tracker and guide Progress detection: - Quests you passed by (not in the log, not done, three later quests started) no longer hold up a zone's checklist. Only a quest's first row counts, follow-ups of quests in the log are never flagged, and nothing is flagged when it would cover more than 40% of a plan. - When the quest log and current zone show you're further along, the tracker offers to jump there. Earlier steps are skipped, class quests and mounts are put off, and Undo restores both. - Class quests and mounts 8+ levels behind stop blocking the route and stay on a "still open" reminder. - A welcome panel on each new character sums up what was detected. Tracker and guide: - Compact, standard and detailed tracker layouts; real checkboxes on objectives; the panel grows downward and no longer changes height on a timer; optional fading in combat, until mouseover, and in instances. - Flat theme with a class-color or gold accent, line-drawn buttons, slim scrollbars and short fade-ins. - Resizable guide window with search on every tab, Talents and Spec Guide merged into one tab, the Route tab opening at the current step, and grouped settings that are also under Options > AddOns. - Key bindings, a confirmation before resetting progress (which now also clears manual checkmarks), fewer chat messages, a draggable level-up popup, adjustable text size, and a colorblind-friendly palette. Step and plan state is cached per refresh, since one refresh used to work it out several times over for the whole route. --- Bindings.xml | 9 + CoffeyGuide.toc | 4 +- Core.lua | 117 +++++++++-- Detect.lua | 231 +++++++++++++++++++++ Gear.lua | 7 +- History.lua | 18 +- Init.lua | 26 +++ Plans.lua | 83 +++++++- README.md | 27 ++- UI/Extras.lua | 38 +++- UI/Guide.lua | 448 +++++++++++++++++++++++++++------------ UI/Tracker.lua | 518 +++++++++++++++++++++++++++++++++++----------- UI/Welcome.lua | 144 +++++++++++++ UI/Widgets.lua | 472 ++++++++++++++++++++++++++++++++++++++---- Waypoints.lua | 9 + tools/harness.lua | 64 ++++++ 16 files changed, 1900 insertions(+), 315 deletions(-) create mode 100644 Bindings.xml create mode 100644 Detect.lua create mode 100644 UI/Welcome.lua diff --git a/Bindings.xml b/Bindings.xml new file mode 100644 index 0000000..fcd65b9 --- /dev/null +++ b/Bindings.xml @@ -0,0 +1,9 @@ + + CoffeyGuide_Binding("toggle") + CoffeyGuide_Binding("guide") + CoffeyGuide_Binding("check") + CoffeyGuide_Binding("next") + CoffeyGuide_Binding("prev") + CoffeyGuide_Binding("waypoint") + CoffeyGuide_Binding("compact") + diff --git a/CoffeyGuide.toc b/CoffeyGuide.toc index 4cd8c01..7dd8f13 100644 --- a/CoffeyGuide.toc +++ b/CoffeyGuide.toc @@ -1,7 +1,7 @@ ## Interface: 16001 ## Title: Coffey's Leveling Guide ## Notes: Leveling guide for WoW Forever: route for every race/class, talents, spec guides, gear & pre-raid BiS, professions, gold and extras. /cguide -## Version: 3.0.1 +## Version: 3.1.0 ## Author: Coffey Labs LLC ## X-Website: https://coffeylabs.org ## X-Copyright: Copyright (c) 2026 Coffey Labs LLC @@ -45,6 +45,7 @@ Data\plans_alliance_48_60.lua Core.lua Plans.lua +Detect.lua History.lua Waypoints.lua Gear.lua @@ -53,3 +54,4 @@ UI\Widgets.lua UI\Tracker.lua UI\Guide.lua UI\Extras.lua +UI\Welcome.lua diff --git a/Core.lua b/Core.lua index 1d448aa..3b30a66 100644 --- a/Core.lua +++ b/Core.lua @@ -4,10 +4,14 @@ local Print = ns.Print local DEFAULTS = { arrow = true, pins = true, autoWaypoint = true, toasts = true, lock = false, scale = 1.0, - autoSkip = true, useTomTom = true, showOptional = true, talentGlow = true, minimized = false, + autoSkip = true, useTomTom = true, showOptional = true, talentGlow = true, gearAdvisor = true, rewardHints = true, autoAccept = false, autoTurnIn = false, sellGreys = false, autoRepair = false, minimap = { hide = false }, + -- Tracker layout: density is "standard" or "detailed"; compact collapses it to the next action. + density = "standard", compact = false, fontScale = 1.0, bgAlpha = 0.90, + combatFade = true, instanceHide = true, mouseoverFade = false, + suggest = true, quiet = true, colorblind = false, accentGold = false, } ns.player = {} @@ -17,9 +21,18 @@ ns.logIDs = {} -- questID -> title (in quest log) ns.talents = { byName = {}, tabs = {}, total = 0 } ns.profs = {} +-- Step and plan state is worked out many times per refresh (progress bar, current step, +-- next-step preview, suggestions, the Route tab). It is cached per "generation": anything +-- that can change it calls ns.Invalidate(), and every Refresh starts a new generation. The +-- cache is also keyed on the frame time, so a missed Invalidate can never outlive a frame. +ns.gen = 0 +function ns.Invalidate() ns.gen = ns.gen + 1 end +function ns.MemoKey() return ns.gen .. ":" .. tostring(GetTime and GetTime() or 0) end + local listeners = {} function ns.On(name, fn) listeners[name] = listeners[name] or {}; table.insert(listeners[name], fn) end function ns.Fire(name, ...) + if name == "Refresh" or name == "SettingsChanged" then ns.Invalidate() end for _, fn in ipairs(listeners[name] or {}) do local ok, err = pcall(fn, ...) if not ok then geterrorhandler()(err) end @@ -99,8 +112,22 @@ function ns.IsQuestActive(q) return (id and ns.logIDs[id]) or (name and ns.activeQuests[name]) or false end --- Returns nil (not done) or one of "done", "skipped", "outleveled". +local stateMemo, stateKey = {}, nil +local ComputeState + +-- Returns nil (not done) or one of "done", "skipped", "outleveled", "behind". +-- "behind" is a class quest or mount step left 8+ levels behind: it stops holding up the +-- route (someone who installs the guide at 50 shouldn't be parked on a level-10 quest) +-- but stays on the list as a reminder, since those rewards matter at any level. function ns.StepState(step) + local key = ns.MemoKey() + if stateKey ~= key then wipe(stateMemo); stateKey = key end + local m = stateMemo[step] + if m == nil then m = ComputeState(step) or false; stateMemo[step] = m end + return m or nil +end + +ComputeState = function(step) local c = ns.char if c.done[step.id] then return "done" end if c.skip[step.id] then return "skipped" end @@ -123,9 +150,13 @@ function ns.StepState(step) local plan, first = ns.PlanProgress(step) if plan and #plan > 0 and not first then return "done" end end - if ns.db.autoSkip and step.max and level > step.max + 3 and step.kind ~= "class" and step.kind ~= "mount" then + local keep = step.kind == "class" or step.kind == "mount" + if ns.db.autoSkip and step.max and level > step.max + 3 and not keep then return "outleveled" end + if ns.db.autoSkip and step.max and keep and level > step.max + 8 then return "behind" end + -- Put off by a jump ahead: still open, but not holding up the route. + if keep and c.defer and c.defer[step.id] then return "behind" end return nil end @@ -141,7 +172,8 @@ function ns.Progress() for _, step in ipairs(ns.route) do if not step.optional then total = total + 1 - if ns.StepState(step) then done = done + 1 end + local st = ns.StepState(step) + if st and st ~= "behind" then done = done + 1 end end end return done, total @@ -160,21 +192,35 @@ function ns.SetView(i) end function ns.ToggleDone(step) - if ns.char.done[step.id] or ns.char.skip[step.id] then - ns.char.done[step.id], ns.char.skip[step.id] = nil, nil + local c = ns.char + if c.done[step.id] or c.skip[step.id] then + c.done[step.id], c.skip[step.id] = nil, nil else - ns.char.done[step.id] = true + c.done[step.id] = true end - ns.char.view = nil + if c.defer then c.defer[step.id] = nil end + c.view = nil + ns.Invalidate() ns.Fire("Refresh") end function ns.Skip(step) ns.char.skip[step.id] = true + if ns.char.defer then ns.char.defer[step.id] = nil end ns.char.view = nil + ns.Invalidate() ns.Fire("Refresh") end +-- Class quests and mount steps the character has left behind (see StepState). +function ns.StillOpen() + local out = {} + for i, step in ipairs(ns.route) do + if ns.StepState(step) == "behind" then out[#out + 1] = i end + end + return out +end + -- Tips for the current level band (gold / extras / professions). function ns.TipsForLevel(level) local out = {} @@ -185,6 +231,7 @@ function ns.TipsForLevel(level) end local function ScanQuestLog() + ns.Invalidate() wipe(ns.activeQuests); wipe(ns.logIDs) local num = (GetNumQuestLogEntries and GetNumQuestLogEntries()) or (C_QuestLog and C_QuestLog.GetNumQuestLogEntries and C_QuestLog.GetNumQuestLogEntries()) or 0 @@ -581,6 +628,11 @@ events:SetScript("OnEvent", function(_, event, ...) local c = CoffeyGuideCharDB c.done, c.skip, c.questNames, c.plan = c.done or {}, c.skip or {}, c.questNames or {}, c.plan or {} if CoffeyGuideDB.useQuestie == nil then CoffeyGuideDB.useQuestie = true end + -- 3.1.0: "minimized" became the compact tracker. + if CoffeyGuideDB.minimized ~= nil then + CoffeyGuideDB.compact = CoffeyGuideDB.minimized and true or false + CoffeyGuideDB.minimized = nil + end ns.db, ns.char = CoffeyGuideDB, CoffeyGuideCharDB end ns.Fire("AddonLoaded", name) @@ -593,8 +645,12 @@ events:SetScript("OnEvent", function(_, event, ...) ns.ScanProfessions() ns.Fire("Login") ns.Fire("Refresh") - Print(("%s %s %s detected - %d route steps. /cguide to toggle, /cguide guide for the full guide.") - :format(ns.player.raceName or "?", ns.player.className or "?", ns.player.faction or "", #ns.route)) + -- Say hello once per character; after that only when quiet mode is off. + if not ns.char.greeted or not ns.db.quiet then + Print(("%s %s %s detected - %d route steps. /cguide to toggle, /cguide guide for the full guide.") + :format(ns.player.raceName or "?", ns.player.className or "?", ns.player.faction or "", #ns.route)) + ns.char.greeted = true + end elseif event == "PLAYER_ENTERING_WORLD" then ns.ScanTalents() @@ -613,6 +669,7 @@ events:SetScript("OnEvent", function(_, event, ...) local level = ... local before = ns.CurrentIndex() ns.player.level = level + ns.Invalidate() ns.ScanTalents() ns.char.view = nil ns.Fire("LevelUp", level, before) @@ -627,6 +684,7 @@ events:SetScript("OnEvent", function(_, event, ...) local title = TitleForQuest(id) local before = ns.CurrentIndex() if title then ns.char.questNames[title] = true end + ns.Invalidate() ns.Fire("QuestTurnedIn", id, title) C_Timer.After(0.5, function() ScanQuestLog() @@ -646,6 +704,36 @@ events:SetScript("OnEvent", function(_, event, ...) end end) +-- Clear this character's guide progress. Quest history comes from the game, so steps +-- you have really finished tick themselves off again; manual marks and skips are gone. +function ns.ResetProgress() + local c = ns.char + wipe(c.done); wipe(c.skip); wipe(c.questNames); wipe(c.plan) + c.view, c.lastJump, c.defer = nil, nil, nil + ns.Invalidate() + Print("progress reset."); ns.Fire("Refresh") +end + +-- Check off the current quest-plan objective (key binding and /cguide check). +function ns.CheckCurrent() + local step = ns.route[ns.ViewIndex()] + if not step then return end + local plan, first = ns.PlanProgress(step) + if plan and first then ns.MarkSub(step, plan[first], true) + elseif not ns.StepState(step) then ns.ToggleDone(step) end +end + +function CoffeyGuide_Binding(action) + if not ns.char then return end + if action == "toggle" then ns.Fire("ToggleTracker") + elseif action == "guide" then ns.Fire("OpenGuide") + elseif action == "check" then ns.CheckCurrent() + elseif action == "next" then ns.SetView(ns.ViewIndex() + 1) + elseif action == "prev" then ns.SetView(ns.ViewIndex() - 1) + elseif action == "waypoint" then ns.Fire("WaypointCurrent") + elseif action == "compact" then ns.Fire("ToggleCompact") end +end + --------------------------------------------------------------------------- -- Slash commands --------------------------------------------------------------------------- @@ -664,15 +752,18 @@ SlashCmdList.COFFEYGUIDE = function(msg) elseif msg == "sync" then ns.SyncHistory(true) elseif msg == "wp" or msg == "way" then ns.Fire("SetWaypoints", ns.route[ns.ViewIndex()], true) elseif msg == "reset" then - wipe(ns.char.done); wipe(ns.char.skip); wipe(ns.char.questNames); ns.char.view = nil - Print("progress reset."); ns.Fire("Refresh") + ns.ResetProgress() elseif msg == "resetpos" then ns.char.pos = nil; ns.Fire("ResetPosition") elseif msg == "talentdebug" then ns.TalentDebug() + elseif msg == "welcome" then ns.Fire("ShowWelcome", true) + elseif msg == "compact" then ns.Fire("ToggleCompact") + elseif msg == "check" then ns.CheckCurrent() elseif msg == "support" or msg == "donate" then Print("Coffey's Leveling Guide is free. To support Coffey Labs: " .. ns.SUPPORT); ns.ShowLink(ns.SUPPORT) else Print("/cguide - show/hide tracker /cguide guide | talents | spec | gear | prof | quests | gold | dungeons | settings") - Print("/cguide next | prev /cguide wp - waypoints for this step /cguide sync /cguide reset /cguide resetpos /cguide talentdebug /cguide support") + Print("/cguide next | prev | check | compact /cguide wp - waypoints for this step /cguide sync /cguide welcome") + Print("/cguide reset /cguide resetpos /cguide talentdebug /cguide support") end end diff --git a/Detect.lua b/Detect.lua new file mode 100644 index 0000000..df0d848 --- /dev/null +++ b/Detect.lua @@ -0,0 +1,231 @@ +-- Coffey's Leveling Guide progress detection: works out where a character really is when that differs +-- from the first unfinished route step. This happens to anyone who installs the guide mid-way, levels +-- off-route for a while, or follows a different zone order. Evidence comes from the quest log, the +-- completed-quest history and the zone the player is standing in. The guide never jumps on its own; +-- it offers the jump in the tracker, and a jump can be undone. +local ADDON, ns = ... + +local D = {} +ns.Detect = D + +local LOOKAHEAD = 15 -- how many route steps past the current one to consider +local dismissed = {} -- step id -> true: "Not now" for this session + +local SUGGEST_KINDS = { zone = true, quest = true, travel = true } + +--------------------------------------------------------------------------- +-- Where is the player? +--------------------------------------------------------------------------- +local function PlayerMap() + if C_Map and C_Map.GetBestMapForUnit then return C_Map.GetBestMapForUnit("player") end +end + +-- The player's map and its parents (a city or sub-zone counts as the zone around it). +local function MapChain(mapID) + local chain = {} + local id = mapID + for _ = 1, 4 do + if not id or id == 0 then break end + chain[id] = true + local info = C_Map and C_Map.GetMapInfo and C_Map.GetMapInfo(id) + id = info and info.parentMapID + end + return chain +end + +-- Maps a route step covers: its own map plus every map its quest plan points at. +local stepMaps = {} +local function StepMaps(step) + local m = stepMaps[step.id] + if m then return m end + m = {} + if step.map then m[step.map] = true end + for _, s in ipairs(ns.PlanFor(step) or {}) do + if s.wp and s.wp[1] then m[s.wp[1]] = true end + end + stepMaps[step.id] = m + return m +end + +function D.IsHere(step, chain) + chain = chain or MapChain(PlayerMap()) + for map in pairs(StepMaps(step)) do + if chain[map] then return true end + end + return false +end + +--------------------------------------------------------------------------- +-- Evidence for one step +--------------------------------------------------------------------------- +-- Returns { inLog, ready, done, total, here } for the quests a step names (its own list and its plan). +function D.Evidence(step, chain) + local e = { inLog = 0, ready = 0, done = 0, total = 0, here = false } + local seen = {} + local function count(q) + local name, id = q, nil + if type(q) == "table" then name, id = q[1], q[2] end + local key = id or name + if not key or seen[key] then return end + seen[key] = true + e.total = e.total + 1 + if ns.IsQuestActive(q) then + e.inLog = e.inLog + 1 + if id and ns.logComplete and ns.logComplete[id] then e.ready = e.ready + 1 end + elseif ns.IsQuestDone(q) then + e.done = e.done + 1 + end + end + for _, q in ipairs(step.quests or {}) do count(q) end + for _, s in ipairs(ns.PlanFor(step) or {}) do if s.quest then count(s.quest) end end + e.here = D.IsHere(step, chain) + return e +end + +local function Score(e) + return e.inLog * 3 + e.ready * 2 + (e.here and 4 or 0) + math.min(e.done, 6) +end + +--------------------------------------------------------------------------- +-- Suggestion +--------------------------------------------------------------------------- +local function Reason(step, e) + local zone = step.zone or step.title or "this step" + if e.here and e.inLog > 0 then + return ("You're in %s with %d of its quests in your log."):format(zone, e.inLog) + elseif e.inLog > 0 then + return ("You have %d quests for %s in your log."):format(e.inLog, zone) + end + return ("You're in %s and have already done %d of its quests."):format(zone, e.done) +end + +-- Returns index, step, reason when a later step fits better than the current one. +-- The tracker asks on every refresh; quest-log updates come in bursts while fighting, +-- so the answer is kept for a couple of seconds. +local cache = { t = -10 } +local Compute +function D.Suggestion() + local now = GetTime and GetTime() or 0 + local cur = ns.route and ns.CurrentIndex and ns.CurrentIndex() + if cache.cur == cur and now - cache.t < 2 then return cache.i, cache.step, cache.reason end + local i, step, reason = Compute() + cache.t, cache.cur, cache.i, cache.step, cache.reason = now, cur, i, step, reason + return i, step, reason +end +function D.Invalidate() cache.t = -10 end + +Compute = function() + if not ns.db or not ns.db.suggest or not ns.route or #ns.route == 0 then return end + local cur = ns.CurrentIndex() + local curStep = ns.route[cur] + if not curStep then return end + local chain = MapChain(PlayerMap()) + local ce = D.Evidence(curStep, chain) + -- Busy on the current step (its quests in the log and standing in its zone): never interrupt. + if ce.here and ce.inLog > 0 then return end + local level = ns.player.level or UnitLevel("player") or 1 + local best, bestScore, bestE + for i = cur + 1, math.min(#ns.route, cur + LOOKAHEAD) do + local st = ns.route[i] + if not st.optional and SUGGEST_KINDS[st.kind] and not dismissed[st.id] and not ns.StepState(st) + and (st.min or 1) <= level + 2 then + local e = D.Evidence(st, chain) + local strong = e.inLog >= 2 or (e.here and (e.inLog >= 1 or e.done >= 2)) + if strong then + local sc = Score(e) + if not bestScore or sc > bestScore then best, bestScore, bestE = i, sc, e end + end + end + end + if not best or bestScore <= Score(ce) + 2 then return end + return best, ns.route[best], Reason(ns.route[best], bestE) +end + +function D.Dismiss(step) + if step then dismissed[step.id] = true end + D.Invalidate() + ns.Fire("Refresh") +end + +-- Jump to route step i: earlier unfinished steps are marked skipped (and remembered, for Undo). +-- Class quests and mounts are put off instead of skipped: they stop holding up the route but +-- stay in the "still open" reminder, because their rewards matter at any level. +function D.JumpTo(i) + local target = ns.route[i] + if not target then return end + local c = ns.char + local prev = D.RecentJump() + local skipped = prev and prev.ids or {} + local deferred = prev and prev.deferred or {} + c.defer = c.defer or {} + for j = 1, i - 1 do + local st = ns.route[j] + if not st.optional and not ns.StepState(st) then + if st.kind == "class" or st.kind == "mount" then + c.defer[st.id] = true + deferred[#deferred + 1] = st.id + else + c.skip[st.id] = true + skipped[#skipped + 1] = st.id + end + end + end + ns.Invalidate() + c.lastJump = { ids = skipped, deferred = deferred, to = target.id, t = time and time() or 0 } + D.Invalidate() + ns.char.view = nil + ns.Print(("Jumped to |cffffd100%s|r. %d earlier step(s) marked skipped; Undo in the tracker.") + :format(target.title or "?", #skipped)) + ns.Fire("Refresh") +end + +function D.UndoJump() + local j = ns.char.lastJump + if not j then return end + for _, id in ipairs(j.ids or {}) do ns.char.skip[id] = nil end + for _, id in ipairs(j.deferred or {}) do if ns.char.defer then ns.char.defer[id] = nil end end + ns.char.lastJump = nil + ns.Invalidate() + ns.char.view = nil + D.Invalidate() + ns.Fire("Refresh") +end + +-- The Undo offer stays for a few minutes after a jump. +function D.RecentJump() + local j = ns.char and ns.char.lastJump + if not j or not j.ids or (#j.ids + #(j.deferred or {})) == 0 then return nil end + if time and j.t and time() - j.t > 300 then return nil end + return j +end + +--------------------------------------------------------------------------- +-- Catch-up summary (welcome panel and the first history sync) +--------------------------------------------------------------------------- +function D.Summary() + local s = { done = 0, outleveled = 0, behind = 0, total = 0, completed = 0 } + for _, st in ipairs(ns.route) do + if not st.optional then + s.total = s.total + 1 + local state = ns.StepState(st) + if state == "outleveled" then s.outleveled = s.outleveled + 1 + elseif state == "behind" then s.behind = s.behind + 1 + elseif state then s.done = s.done + 1 end + end + end + for _ in pairs(ns.completed or {}) do s.completed = s.completed + 1 end + s.current = ns.route[ns.CurrentIndex()] + local i, step, reason = D.Suggestion() + if i then s.suggestIndex, s.suggestStep, s.suggestReason = i, step, reason end + return s +end + +--------------------------------------------------------------------------- +-- Wiring: zone changes can change the suggestion. +--------------------------------------------------------------------------- +local ev = CreateFrame("Frame") +pcall(ev.RegisterEvent, ev, "ZONE_CHANGED_NEW_AREA") +ev:SetScript("OnEvent", function() + D.Invalidate() + if ns.char and ns.QueueRefresh then ns.QueueRefresh() end +end) diff --git a/Gear.lua b/Gear.lua index 607e4e1..e98facf 100644 --- a/Gear.lua +++ b/Gear.lua @@ -187,7 +187,7 @@ local function OnItemTooltip(tooltip) tooltip:AddLine("|TInterface\\RaidFrame\\ReadyCheck-Ready:14|t Coffey's Guide: recommended quest reward", 0.3, 0.9, 0.3) end if pct >= 1 then - tooltip:AddLine(("Coffey's Guide: |cff4ce64c+%d%% upgrade|r for %s"):format(pct, spec), 1, 0.82, 0) + tooltip:AddLine(("Coffey's Guide: " .. ns.C("good") .. "+%d%% upgrade|r for %s"):format(pct, spec), 1, 0.82, 0) elseif pct <= -1 then tooltip:AddLine(("Coffey's Guide: %d%% vs equipped (%s)"):format(pct, spec), 0.6, 0.6, 0.6) end @@ -223,12 +223,13 @@ local function CreatePopup() popup.title = UI.Text(popup, "GameFontNormal"); popup.title:SetPoint("TOPLEFT", popup.icon, "TOPRIGHT", 8, 0) popup.title:SetWidth(240) popup.sub = UI.Text(popup, "GameFontHighlightSmall"); popup.sub:SetPoint("TOPLEFT", popup.title, "BOTTOMLEFT", 0, -2) + UI.FadeIn(popup, 10) popup.equip = UI.Button(popup, "Equip", 60, function() if InCombatLockdown() then ns.Print("Can't equip in combat."); return end if popup.bag and C_Container and C_Container.UseContainerItem then C_Container.UseContainerItem(popup.bag, popup.slot) elseif popup.bag and UseContainerItem then UseContainerItem(popup.bag, popup.slot) end popup:Hide() - end) + end, "primary") popup.equip:SetPoint("BOTTOMRIGHT", -70, 6) popup.ignore = UI.Button(popup, "Ignore", 60, function() popup:Hide() end) popup.ignore:SetPoint("LEFT", popup.equip, "RIGHT", 4, 0) @@ -272,7 +273,7 @@ function G.ScanBags() popup.icon:SetTexture(select(10, GetItemInfo(best)) or "Interface\\Icons\\INV_Misc_QuestionMark") popup.title:SetText("Upgrade: " .. best) local _, spec = G.Weights() - popup.sub:SetText(("|cff4ce64c+%d%%|r for %s"):format(bestPct, spec)) + popup.sub:SetText((ns.C("good") .. "+%d%%|r for %s"):format(bestPct, spec)) popup:Show() end end diff --git a/History.lua b/History.lua index bd5539b..61a5b24 100644 --- a/History.lua +++ b/History.lua @@ -33,6 +33,7 @@ end -- Completed quests --------------------------------------------------------------------------- function ns.LoadCompleted() + ns.Invalidate() wipe(ns.completed) if C_QuestLog and C_QuestLog.GetAllCompletedQuestIDs then for _, id in ipairs(C_QuestLog.GetAllCompletedQuestIDs() or {}) do ns.completed[id] = true end @@ -58,7 +59,7 @@ function ns.ResolveCompletedNames(onDone) end i = stop + 1 if i <= #ids then C_Timer.After(0.05, batch) - else resolved = true; if onDone then onDone() end end + else resolved = true; ns.Invalidate(); if onDone then onDone() end end end if #ids > 0 then batch() else resolved = true; if onDone then onDone() end end end @@ -116,10 +117,20 @@ function ns.SyncHistory(announce) ns.char.view = nil ns.Fire("Refresh") if announce then + local sum = ns.Detect and ns.Detect.Summary() local step = ns.route[ns.CurrentIndex()] - ns.Print(("Synced %d completed quests from your quest history. Current step: |cffffd100%s|r") - :format(n, step and step.title or "?")) + if sum and sum.done + sum.outleveled > 0 then + ns.Print(("Synced %d completed quests: %d of %d route steps already done. Current step: |cffffd100%s|r") + :format(n, sum.done + sum.outleveled, sum.total, step and step.title or "?")) + else + ns.Print(("Synced %d completed quests from your quest history. Current step: |cffffd100%s|r") + :format(n, step and step.title or "?")) + end + if sum and sum.suggestStep then + ns.Print(sum.suggestReason .. " The tracker offers to jump to |cffffd100" .. (sum.suggestStep.title or "?") .. "|r.") + end end + ns.Fire("HistoryReady") end) end @@ -130,6 +141,7 @@ ns.On("Login", function() end) ns.On("QuestTurnedIn", function(id, title) + ns.Invalidate() if id then ns.completed[id] = true end if title then ns.completedNames[title] = true end wipe(zoneStatsCache) diff --git a/Init.lua b/Init.lua index 5f381f9..b424cd8 100644 --- a/Init.lua +++ b/Init.lua @@ -71,6 +71,32 @@ ns.COLORS = { border = { 0.55, 0.45, 0.25, 1.00 }, } +-- Status colors as chat escape codes. The colorblind palette (Okabe-Ito) swaps green and red +-- for blue and vermillion; status icons differ in shape too, so color is never the only cue. +local PALETTES = { + standard = { good = "4ce64c", warn = "ff8040", bad = "ff4040", skip = "cc4444", cur = "ffd100", dim = "808080", info = "8080ff" }, + colorblind = { good = "56b4e9", warn = "e69f00", bad = "d55e00", skip = "d55e00", cur = "f0e442", dim = "808080", info = "cc79a7" }, +} +function ns.C(key) + local pal = PALETTES[(ns.db and ns.db.colorblind) and "colorblind" or "standard"] + return "|cff" .. (pal[key] or "ffffff") +end +-- Same color as r, g, b (0-1), for textures and font strings. +function ns.RGB(key) + local hex = ns.C(key):sub(5) + return tonumber(hex:sub(1, 2), 16) / 255, tonumber(hex:sub(3, 4), 16) / 255, tonumber(hex:sub(5, 6), 16) / 255 +end + +-- Key bindings (Bindings.xml). Shown under Options > Keybindings > AddOns. +BINDING_HEADER_COFFEYGUIDE = "Coffey's Leveling Guide" +BINDING_NAME_COFFEYGUIDE_TOGGLE = "Show or hide the tracker" +BINDING_NAME_COFFEYGUIDE_GUIDE = "Open the full guide" +BINDING_NAME_COFFEYGUIDE_CHECK = "Check off the current objective" +BINDING_NAME_COFFEYGUIDE_NEXT = "View the next step" +BINDING_NAME_COFFEYGUIDE_PREV = "View the previous step" +BINDING_NAME_COFFEYGUIDE_WAYPOINT = "Set waypoints for the current objective" +BINDING_NAME_COFFEYGUIDE_COMPACT = "Switch the tracker between compact and full" + local PREFIX = "|cffffd100Coffey's Guide:|r " function ns.Print(msg) DEFAULT_CHAT_FRAME:AddMessage(PREFIX .. tostring(msg)) end diff --git a/Plans.lua b/Plans.lua index b3539f2..ade5fe6 100644 --- a/Plans.lua +++ b/Plans.lua @@ -103,18 +103,90 @@ end function ns.MarkSub(step, s, value) ns.char.plan[step.id] = ns.char.plan[step.id] or {} ns.char.plan[step.id][s._i] = value or nil + ns.Invalidate() ns.Fire("Refresh") end --- Returns plan list, index of first undone sub-step (or nil when finished), done count. +-- How many different quests past a sub-step must show progress before an untouched +-- quest is treated as passed by (never picked up, or abandoned). +local MISSED_AFTER = 3 + +-- Returns plan list, index of the first open sub-step (nil when finished), done count, and a +-- set of indexes the player has moved past. +-- +-- A quest counts as passed by when it is untouched (not in the log, not completed) and at +-- least MISSED_AFTER other quests whose *first* row comes later in the plan have been picked +-- up or finished. Only a quest's first row counts: the objectives and turn-ins of quests you +-- accepted earlier always sit further down the list, and counting those would flag the next +-- hub's quests while you're simply following the plan. An accept that comes after the turn-in +-- of a quest still in your log is never flagged either, since it may be that quest's follow-up. +-- If more than 40% of the plan would be passed by, nothing is: that's a different route +-- through the zone, not a few skipped quests, so the plan is followed as written. +-- Passed-by rows stay listed (dimmed) but no longer hold the cursor. +local memo = {} +local Compute function ns.PlanProgress(step) + if not step then return nil end + local key = ns.MemoKey() + local m = memo[step.id] + if m and m.key == key then return m.plan, m.first, m.done, m.missed end + local plan, first, done, missed = Compute(step) + memo[step.id] = { key = key, plan = plan, first = first, done = done, missed = missed } + return plan, first, done, missed +end + +Compute = function(step) local plan = ns.PlanFor(step) if not plan then return nil end - local first, done = nil, 0 + local n = #plan + local doneAt, keyAt, firstPos, touched = {}, {}, {}, {} + local done = 0 for i, s in ipairs(plan) do - if ns.SubDone(step, s) then done = done + 1 elseif not first then first = i end + if ns.SubDone(step, s) then doneAt[i] = true; done = done + 1 end + local k = s.quest and (s.quest[2] or s.quest[1]) + if k then + keyAt[i] = k + if not firstPos[k] then + firstPos[k] = i + touched[k] = (ns.IsQuestActive(s.quest) or ns.IsQuestDone(s.quest)) and true or false + end + end end - return plan, first, done + -- Open turn-ins of quests in the log, by position: accepts after them may be follow-ups. + local openTurninBefore, open = {}, false + for i, s in ipairs(plan) do + openTurninBefore[i] = open + if s.act == "turnin" and s.quest and not doneAt[i] and ns.IsQuestActive(s.quest) then open = true end + end + local missed, missedKey, ahead = {}, {}, 0 + for i = n, 1, -1 do + local k = keyAt[i] + if k and firstPos[k] == i then + if touched[k] then + ahead = ahead + 1 + elseif not doneAt[i] and ahead >= MISSED_AFTER and not openTurninBefore[i] then + missedKey[k] = true + end + elseif not k and not doneAt[i] and (plan[i].act == "fp" or plan[i].act == "hs") and ahead >= MISSED_AFTER + 1 then + missed[i] = true + end + end + -- Every row of a passed-by quest goes together (accept, objectives and turn-in). + for i = 1, n do + if keyAt[i] and missedKey[keyAt[i]] and not doneAt[i] then missed[i] = true end + end + if ns.MissedCount(missed) > n * 0.4 then missed = {} end + local first + for i = 1, n do + if not doneAt[i] and not missed[i] then first = i; break end + end + return plan, first, done, missed +end + +function ns.MissedCount(missed) + local c = 0 + for _ in pairs(missed or {}) do c = c + 1 end + return c end function ns.SubText(s) @@ -171,6 +243,7 @@ function ns.QuestLogSnapshot() end function ns.ScanLogCompletion() + ns.Invalidate() wipe(ns.logComplete) local num = (GetNumQuestLogEntries and GetNumQuestLogEntries()) or 0 for i = 1, num do @@ -212,12 +285,14 @@ local function IsHearthTo(s) return s.act == "hs" and Lower(s.text):find("^heart local function Mark(step, s) ns.char.plan[step.id] = ns.char.plan[step.id] or {} ns.char.plan[step.id][s._i] = true + ns.Invalidate() end local function NodeShort(name) return Lower((name or ""):match("^%s*([^,]+)")):gsub("%s+$", "") end -- Remember every flight path the taxi map lists as known. function ns.RecordTaxiNodes() + ns.Invalidate() ns.char.taxi = ns.char.taxi or {} local known, n = ns.char.taxi, 0 if NumTaxiNodes and TaxiNodeName then diff --git a/README.md b/README.md index dd8ba5c..1a55c63 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,16 @@ uses that name and the `/fg` command. steps follow the quest chains and quest-giver locations, and some objectives there have no waypoint. If a step looks wrong, skip it and open an issue. - **Tracker** panel with the current step, zone progress, live objectives and the next - talent point. + talent point. Three layouts: compact (just the next action, with a checkbox), standard + and detailed. It fades in combat, goes compact in dungeons and hides in raids and + battlegrounds (all optional). +- **Picks up where you are.** It reads your completed quests, quest log and current zone. + Quests you walked past no longer hold up a zone's checklist. If your quest log shows + you're further along than the route thinks, the tracker offers to jump there; earlier + steps are marked skipped, and Undo puts them back. Class quests and mounts you've + outleveled stop blocking the route but stay listed as "still open". +- A **welcome panel** on each new character sums up what was detected and lets you pick + a layout and the automation you want. - **Talents**: two or three leveling builds per class, detected from the points you have spent, with the next talent highlighted in the talent window. - **Spec guides** for all 27 specs. @@ -31,6 +40,9 @@ uses that name and the `/fg` command. - **Gold and extras**: gold-making tips, mounts, attunements and dungeon notes. - Optional quality-of-life settings (auto accept, auto turn-in, sell gray items, auto repair). All are off by default; hold Shift to bypass them. +- A resizable guide window with search on every tab, settings grouped by topic (also + under Options > AddOns), key bindings, adjustable tracker and text size, a class-color + or gold accent, and a colorblind-friendly palette. Coffey's Leveling Guide needs no other addons. When TomTom, Questie or ForeverDungeonJournal are installed it uses them for waypoints and NPC locations, and never changes their @@ -55,9 +67,12 @@ Cloning this repository straight into `AddOns/` works too. | `/cguide talents`, `/cguide spec`, `/cguide gear`, `/cguide prof` | Open those tabs | | `/cguide gold`, `/cguide dungeons`, `/cguide settings` | Open those tabs | | `/cguide next`, `/cguide prev` | Move between route steps | +| `/cguide check` | Check off the current objective | +| `/cguide compact` | Switch the tracker between compact and full | +| `/cguide welcome` | Show the welcome panel again | | `/cguide wp` | Set a waypoint for the current step | | `/cguide sync` | Re-read completed quests | -| `/cguide reset` | Clear this character's guide progress | +| `/cguide reset` | Clear this character's guide progress (manual checkmarks and skips) | | `/cguide resetpos` | Reset window positions | | `/cguide talentdebug` | Print what the game's talent API returns, for bug reports | | `/cguide support` | Show the link to our funding options | @@ -67,6 +82,10 @@ Cloning this repository straight into `AddOns/` works too. The minimap button and the addon compartment open the guide (left-click) or toggle the tracker (right-click). +Key bindings are under Options > Keybindings > AddOns > Coffey's Leveling Guide: show +or hide the tracker, open the guide, check off the current objective, next and previous +step, waypoint, and compact mode. + ## Development `tools/harness.lua` loads the addon against a mock game API and runs the main flows: @@ -78,6 +97,10 @@ exposes the classic global talent functions; `TALENT_API` swaps them for `id`, ` `tier` (how WoW Forever does it) or `traits`. `TALENT_LATE=1` keeps talent data empty until after login, as on a slow client. +It also runs a progress-detection scenario: quests from a later zone in the log, the +jump and its undo, and a quest that should count as passed by. In zsh, quote-split the +arguments (`${=args}`) if you loop over several characters. + `tools/validate_plans.lua` checks a quest-plan data file: lua5.1 tools/validate_plans.lua Data/plans_horde_10_26.lua h_tirisfal_late,h_silverpine diff --git a/UI/Extras.lua b/UI/Extras.lua index f1b8cc1..9127390 100644 --- a/UI/Extras.lua +++ b/UI/Extras.lua @@ -76,16 +76,35 @@ local toast local function CreateToast() toast = UI.Panel("CoffeyGuideToast", UIParent, 360, 120) - toast:SetPoint("TOP", UIParent, "TOP", 0, -180) + local tp = ns.db.toastPos + if tp then toast:SetPoint("TOP", UIParent, "BOTTOMLEFT", tp[1], tp[2]) + else toast:SetPoint("TOP", UIParent, "TOP", 0, -180) end toast:SetFrameStrata("DIALOG") toast:Hide() + UI.FadeIn(toast, 16) toast.title = UI.Text(toast, "GameFontNormalHuge") toast.title:SetPoint("TOP", 0, -12); toast.title:SetJustifyH("CENTER"); toast.title:SetWidth(340) toast.lines = UI.Text(toast, "GameFontHighlight") toast.lines:SetPoint("TOP", toast.title, "BOTTOM", 0, -8); toast.lines:SetWidth(330); toast.lines:SetJustifyH("CENTER") toast.lines:SetSpacing(3) + -- Click to dismiss; drag (when not locked) to move it somewhere out of the way. toast:EnableMouse(true) - toast:SetScript("OnMouseUp", function(self) self:Hide() end) + toast:SetMovable(true); toast:SetClampedToScreen(true); toast:RegisterForDrag("LeftButton") + toast:SetScript("OnDragStart", function(self) + if ns.db.lock then return end + self.dragged = true; self.anim:Stop(); self:SetAlpha(1); self:StartMoving() + end) + toast:SetScript("OnDragStop", function(self) + self:StopMovingOrSizing() + local l, t, w = self:GetLeft(), self:GetTop(), self:GetWidth() + if l and t and w then ns.db.toastPos = { l + w / 2, t } end + self.anim:Play() + end) + toast:SetScript("OnMouseUp", function(self) + if self.dragged then self.dragged = nil; return end + self:Hide() + end) + UI.Tooltip(toast, "Coffey's Leveling Guide", "Click to dismiss. Drag to move it.") local ag = toast:CreateAnimationGroup() local fade = ag:CreateAnimation("Alpha") @@ -97,7 +116,7 @@ end local function ShowToast(title, lines) if not ns.db.toasts then return end if not toast then CreateToast() end - toast.title:SetText(title) + toast.title:SetText(UI.AccentHex() .. title .. "|r") toast.lines:SetText(table.concat(lines, "\n")) toast:SetHeight(46 + toast.lines:GetStringHeight() + 14) toast.anim:Stop(); toast:SetAlpha(1); toast:Show(); toast.anim:Play() @@ -105,17 +124,19 @@ end ns.On("LevelUp", function(level) local lines = {} + -- The popup already says all this; repeat it in chat only when popups are off or quiet mode is. + local chatty = not ns.db.toasts or not ns.db.quiet local build = ns.GetActiveBuild() local plan = build and build.talents and build.talents[level] if plan then local info = ns.talents.byName[plan[1]] lines[#lines + 1] = ("|T%s:16|t |cffffd100Talent:|r %s"):format(info and info.icon or "Interface\\Icons\\INV_Misc_QuestionMark", ns.TalentText(plan)) - ns.Print(("Level %d talent: |cffffd100%s|r (%s)"):format(level, ns.TalentText(plan), plan[3] or "")) + if chatty then ns.Print(("Level %d talent: |cffffd100%s|r (%s)"):format(level, ns.TalentText(plan), plan[3] or "")) end end local spells = ns.SPELLS[ns.player.class] if spells and spells[level] then lines[#lines + 1] = "|TInterface\\Icons\\INV_Misc_Book_09:16|t |cffffd100Train:|r " .. spells[level] - ns.Print(("Level %d - visit your trainer: %s"):format(level, spells[level])) + if chatty then ns.Print(("Level %d - visit your trainer: %s"):format(level, spells[level])) end elseif level % 2 == 0 then lines[#lines + 1] = "|TInterface\\Icons\\INV_Misc_Book_09:16|t Visit your class trainer" end @@ -127,7 +148,7 @@ ns.On("LevelUp", function(level) end) ns.On("StepAdvanced", function(_, nextStep) - if nextStep then ns.Print(("Step done! Next: |cffffd100%s|r (%s)"):format(nextStep.title or "?", ns.BandText(nextStep))) end + if nextStep and not ns.db.quiet then ns.Print(("Step done! Next: |cffffd100%s|r (%s)"):format(nextStep.title or "?", ns.BandText(nextStep))) end end) --------------------------------------------------------------------------- @@ -158,6 +179,11 @@ ns.On("Login", function() DBIcon:Register("CoffeyGuide", obj, ns.db.minimap) end) +ns.On("ResetPosition", function() + ns.db.toastPos = nil + if toast then toast:ClearAllPoints(); toast:SetPoint("TOP", UIParent, "TOP", 0, -180) end +end) + ns.On("MinimapChanged", function() if not DBIcon then return end if ns.db.minimap.hide then DBIcon:Hide("CoffeyGuide") else DBIcon:Show("CoffeyGuide") end diff --git a/UI/Guide.lua b/UI/Guide.lua index 30cfeca..3469d10 100644 --- a/UI/Guide.lua +++ b/UI/Guide.lua @@ -8,8 +8,7 @@ local sel = {} -- per-tab selector choice local TABS = { { key = "route", label = "Route", icon = "Interface\\Icons\\INV_Misc_Map_01" }, { key = "questlog", label = "Quest Log", icon = "Interface\\Icons\\INV_Misc_Note_06" }, - { key = "talents", label = "Talents", icon = "Interface\\Icons\\Ability_Marksmanship" }, - { key = "spec", label = "Spec Guide", icon = "Interface\\Icons\\INV_Misc_Book_11" }, + { key = "class", label = "Talents & Spec", icon = "Interface\\Icons\\Ability_Marksmanship" }, { key = "gear", label = "Gear & BiS", icon = "Interface\\Icons\\INV_Chest_Plate06" }, { key = "professions", label = "Professions", icon = "Interface\\Icons\\Trade_BlackSmithing" }, { key = "extras", label = "Gold & Extras", icon = "Interface\\Icons\\INV_Misc_Coin_01" }, @@ -20,29 +19,36 @@ local TABS = { --------------------------------------------------------------------------- -- Selector row (pooled small buttons) --------------------------------------------------------------------------- -local selButtons = {} -local function SetSelector(options, current, onPick) - for _, b in ipairs(selButtons) do b:Hide() end - local x = 0 +-- Up to two rows of option buttons above the list (e.g. view, then build or spec). +local selButtons = { {}, {} } +local function SelectorRow(row, options, current, onPick) + local pool = selButtons[row] + for _, b in ipairs(pool) do b:Hide() end + local x, y = 0, -46 - (row - 1) * 26 for i, opt in ipairs(options or {}) do - local b = selButtons[i] + local b = pool[i] if not b then - b = CreateFrame("Button", nil, g.content, "UIPanelButtonTemplate") - b:SetHeight(22) - selButtons[i] = b + b = UI.Button(g.content, "", 70, nil) + pool[i] = b end b:SetText(opt.label) - b:SetWidth(math.max(70, b:GetFontString():GetStringWidth() + 24)) + b:SetWidth(math.max(70, b.text:GetStringWidth() + 26)) b:ClearAllPoints() - b:SetPoint("TOPLEFT", g.content, "TOPLEFT", x, -46) + b:SetPoint("TOPLEFT", g.content, "TOPLEFT", x, y) x = x + b:GetWidth() + 4 - local active = opt.value == current - b:GetFontString():SetTextColor(active and 1 or 0.7, active and 0.82 or 0.7, active and 0 or 0.7) + b:SetActive(opt.value == current) b:SetScript("OnClick", function() onPick(opt.value) end) b:Show() end + return options and #options > 0 +end + +local function SetSelector(options, current, onPick, options2, current2, onPick2) + local rows = 0 + if SelectorRow(1, options, current, onPick) then rows = 1 end + if SelectorRow(2, options2, current2, onPick2) then rows = 2 end g.listHolder:ClearAllPoints() - g.listHolder:SetPoint("TOPLEFT", g.content, "TOPLEFT", 0, (options and #options > 0) and -74 or -48) + g.listHolder:SetPoint("TOPLEFT", g.content, "TOPLEFT", 0, -48 - rows * 26) g.listHolder:SetPoint("BOTTOMRIGHT", g.content, "BOTTOMRIGHT", 0, 0) end @@ -82,22 +88,31 @@ function render.route(list) list:Add({ header = true, title = ("Levels %d - %d"):format(math.max(1, band), band + 9) }) end local state = ns.StepState(step) - local status = state == "skipped" and UI.STATUS.skipped or state and UI.STATUS.done - or (i == cur and UI.STATUS.current or UI.STATUS.todo) + local status = state == "skipped" and UI.STATUS.skipped or state == "behind" and UI.STATUS.current + or state and UI.STATUS.done or (i == cur and UI.STATUS.current or UI.STATUS.todo) + if i == cur then g.list:Mark("current") end local icon, coords = ns.KIND_ICONS[step.kind] or ns.KIND_ICONS.quest, nil if step.kind == "class" then icon = "Interface\\TargetingFrame\\UI-Classes-Circles" local c = CLASS_ICON_TCOORDS and CLASS_ICON_TCOORDS[ns.player.class] if c then coords = { c[1], c[2], c[3], c[4] } end end + local manual = ns.char.done[step.id] or ns.char.skip[step.id] list:Add({ - status = status, icon = icon, iconCoords = coords, dim = state ~= nil, - title = (step.title or "?") .. (step.optional and " |cff8080ff(optional)|r" or ""), + status = status, icon = icon, iconCoords = coords, dim = state ~= nil and state ~= "behind", + onCheck = function() ns.ToggleDone(step) end, + checkTip = manual and "Undo: put this step back on the route" or "Mark this step done", + title = (step.title or "?") .. (step.optional and (" " .. ns.C("info") .. "(optional)|r") or ""), sub = ns.BandText(step) .. " |cffaaaaaa" .. (step.zone or "") .. "|r" .. ZoneStatText(step) .. "\n" .. (step.text or ""), - right = i == cur and "|cffffd100CURRENT|r" or (i == view and "|cff8080ffviewing|r" or nil), + search = step.zone, + right = i == cur and (ns.C("cur") .. "CURRENT|r") or (i == view and (ns.C("info") .. "viewing|r") + or (state == "behind" and (ns.C("warn") .. "still open|r")) or nil), rightWidth = 70, highlight = i == cur, - onClick = function() ns.SetView(i); ns.Fire("ToggleTracker", true); ns.char.view = i; ns.Fire("Refresh") end, + onClick = function() + if IsShiftKeyDown() and i > cur and ns.Detect then ns.Detect.JumpTo(i); return end + ns.Fire("ToggleTracker", true); ns.char.view = i; ns.Fire("Refresh") + end, onEnter = function(self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT") GameTooltip:AddLine(step.title or "", 1, 0.82, 0) @@ -105,9 +120,11 @@ function render.route(list) for _, q in ipairs(step.quests or {}) do local name = type(q) == "table" and q[1] or q local d = ns.IsQuestDone(q) - GameTooltip:AddLine((d and "|cff4ce64c[done]|r " or "|cff808080[todo]|r ") .. name, 1, 1, 1) + GameTooltip:AddLine((d and (ns.C("good") .. "[done]|r ") or "|cff808080[todo]|r ") .. name, 1, 1, 1) end - GameTooltip:AddLine("Click to show this step in the tracker.", 0.5, 0.5, 0.5) + GameTooltip:AddLine("Click: show this step in the tracker.", 0.5, 0.5, 0.5) + if i > cur then GameTooltip:AddLine("Shift-click: start from here (earlier unfinished steps are skipped; undo in the tracker).", 0.5, 0.5, 0.5, true) end + GameTooltip:AddLine("Checkbox: mark done, or undo a done or skipped step.", 0.5, 0.5, 0.5) GameTooltip:Show() end, }) @@ -121,32 +138,28 @@ function render.questlog(list) for _, gr in ipairs(groups) do for _, q in ipairs(gr.quests) do total = total + 1; if q.complete then ready = ready + 1 end end end - Header("Quest Log", ("%d quests, |cff4ce64c%d ready to turn in|r. Click a quest for a waypoint%s.") - :format(total, ready, (QuestieLoader and ns.db.useQuestie) and " (turn-in NPC via Questie)" or "")) + local questie = QuestieLoader and ns.db.useQuestie + Header("Quest Log", ("%d quests, %s%d ready to turn in|r. %s") + :format(total, ns.C("good"), ready, questie and "Click a finished quest for an arrow to its turn-in NPC." + or "Install Questie to get arrows to turn-in NPCs.")) SetSelector(nil) -- Ready-to-turn-in first, then by zone. local readyList = {} for _, gr in ipairs(groups) do for _, q in ipairs(gr.quests) do if q.complete then readyList[#readyList + 1] = q end end end local function addQuest(q) local objs = {} - for _, o in ipairs(q.objectives) do objs[#objs + 1] = (o.done and "|cff4ce64c" or "|cffcccccc") .. (o.text or "") .. "|r" end + for _, o in ipairs(q.objectives) do objs[#objs + 1] = (o.done and ns.C("good") or "|cffcccccc") .. (o.text or "") .. "|r" end local diff = GetQuestDifficultyColor and GetQuestDifficultyColor(q.level or 1) or { r = 1, g = 1, b = 1 } + local wp = q.complete and q.id and ns.QuestieWaypoint(q.id, "finish") list:Add({ status = q.complete and UI.STATUS.done or (q.failed and UI.STATUS.skipped or UI.STATUS.current), icon = q.complete and ns.ACT_ICONS.turnin or ns.ACT_ICONS.accept, title = ("|cff%02x%02x%02x[%d]|r %s"):format(diff.r * 255, diff.g * 255, diff.b * 255, q.level or 0, q.title), - sub = q.complete and "|cff4ce64cReady to turn in|r" or table.concat(objs, "\n"), + sub = q.complete and (ns.C("good") .. "Ready to turn in|r") or table.concat(objs, "\n"), + right = q.complete and (wp and (ns.C("cur") .. "click: arrow|r") or "|cff808080no NPC location|r") or nil, + rightWidth = 90, highlight = q.complete, - onClick = function() - local wp = q.id and ns.QuestieWaypoint(q.id, "finish") - if q.complete and wp then - ns.Fire("SetWaypoints", { id = "ql:" .. q.id, title = q.title, wp = { wp } }, true) - elseif not q.complete then - ns.Print("Objective locations need Questie (or check your map). Turn-in arrow appears once it's complete.") - else - ns.Print("No turn-in location known for " .. q.title .. ".") - end - end, + onClick = wp and function() ns.Fire("SetWaypoints", { id = "ql:" .. q.id, title = q.title, wp = { wp } }, true) end or nil, }) end if #readyList > 0 then @@ -167,22 +180,37 @@ function render.questlog(list) local plan, first = ns.PlanProgress(step) if plan then list:Add({ header = true, title = "Quest plan: " .. (step.title or "") }) + local _, _, _, missed = ns.PlanProgress(step) for i, s in ipairs(plan) do local done = ns.SubDone(step, s) + local m = missed and missed[i] list:Add({ status = done and UI.STATUS.done or (i == first and UI.STATUS.current or UI.STATUS.todo), - icon = ns.ACT_ICONS[s.act] or ns.ACT_ICONS.note, title = ns.SubText(s), dim = done, highlight = i == first, - onClick = function() ns.MarkSub(step, s, not done) end }) + icon = ns.ACT_ICONS[s.act] or ns.ACT_ICONS.note, + title = ns.SubText(s) .. (m and " |cff808080(passed by)|r" or ""), dim = done or m, highlight = i == first, + onCheck = function() ns.MarkSub(step, s, not done) end, checkTip = done and "Mark not done" or "Mark done", + onClick = function() + local wps = ns.SubWaypoints(s) + if wps then ns.Fire("SetWaypoints", { id = step.id .. ":ql" .. i, title = ns.SubText(s), wp = wps }, true) end + end }) end end end -function render.talents(list) +local CLASS_VIEWS = { { label = "Talent plan", value = "talents" }, { label = "Spec guide", value = "spec" } } +local function PickClassView(v) sel.classView = v; ns.Fire("RefreshGuide") end + +local renderTalents, renderSpec +function render.class(list) + if (sel.classView or "talents") == "spec" then renderSpec(list) else renderTalents(list) end +end + +function renderTalents(list) ns.EnsureTalents() local builds = ns.GetBuilds() local build, auto = ns.GetActiveBuild() local opts = { { label = "Auto-detect", value = "__auto" } } for _, b in ipairs(builds) do opts[#opts + 1] = { label = b.name, value = b.key } end - SetSelector(opts, ns.char.build or "__auto", function(v) + SetSelector(CLASS_VIEWS, "talents", PickClassView, opts, ns.char.build or "__auto", function(v) ns.char.build = (v ~= "__auto") and v or nil ns.Fire("Refresh") end) @@ -203,8 +231,8 @@ function render.talents(list) status = status, icon = info and info.icon or "Interface\\Icons\\INV_Misc_QuestionMark", title = ("|cffffd100Lv %d|r %s"):format(L, ns.TalentText(plan)), - sub = (plan[3] or "") .. ((L == build.respecAt) and " |cffff8040RESPEC here (see summary)|r" or "") - .. (info and "" or " |cffff4040(talent name not found in your talent tree)|r"), + sub = (plan[3] or "") .. ((L == build.respecAt) and (" " .. ns.C("warn") .. "RESPEC here (see summary)|r") or "") + .. (info and "" or (" " .. ns.C("bad") .. "(talent name not found in your talent tree)|r")), dim = L > level, highlight = L == pendingL, onEnter = info and function(self) GameTooltip:SetOwner(self, "ANCHOR_RIGHT") @@ -227,21 +255,21 @@ function render.talents(list) if build.source then list:Add({ title = "|cff808080Source: " .. build.source .. "|r" }) end end -function render.spec(list) +function renderSpec(list) local guides = ns.SPECGUIDES[ns.player.class] or {} local opts = {} for name in pairs(guides) do opts[#opts + 1] = { label = name, value = name } end table.sort(opts, function(a, b) return a.label < b.label end) local chosen = sel.spec or ns.MatchSpec(guides, ns.ActiveSpec()) if not guides[chosen] and opts[1] then chosen = opts[1].value end - SetSelector(opts, chosen, function(v) sel.spec = v; ns.Fire("RefreshGuide") end) + SetSelector(CLASS_VIEWS, "spec", PickClassView, opts, chosen, function(v) sel.spec = v; ns.Fire("RefreshGuide") end) local sg = guides[chosen] if not sg then Header("Spec Guide", "No spec guide data for your class."); return end local best = {} for k, v in pairs(sg.best or {}) do if v then best[#best + 1] = k end end table.sort(best) Header(chosen .. " |cffaaaaaa" .. (sg.role or "") .. "|r", - #best > 0 and ("Best for: |cff4ce64c" .. table.concat(best, ", ") .. "|r") or "") + #best > 0 and ("Best for: " .. ns.C("good") .. table.concat(best, ", ") .. "|r") or "") list:Add({ icon = "Interface\\Icons\\INV_Misc_Book_11", title = "Overview", sub = sg.summary or "" }) list:Add({ icon = "Interface\\Icons\\INV_Misc_Gem_Pearl_04", title = "Stat priority", sub = sg.stats or "" }) list:Add({ header = true, title = "Rotation (priority order)" }) @@ -293,7 +321,7 @@ local function AddItemRow(list, it) title = title, sub = "|cffffd100" .. (it.slot or "") .. "|r " .. (it.source or "") .. (#alts > 0 and ("\n|cff808080Alternatives: " .. table.concat(alts, ", ") .. "|r") or ""), - right = have and "|cff4ce64cowned|r" or nil, rightWidth = 50, + right = have and (ns.C("good") .. "owned|r") or nil, rightWidth = 50, onEnter = function(self) if not it.id then return end GameTooltip:SetOwner(self, "ANCHOR_RIGHT") @@ -327,7 +355,7 @@ function render.gear(list) if it.phase == phase and show(it) then if not any then list:Add({ header = true, title = ("Leveling upgrades - around level %d%s"):format(phase, - (level >= phase - 5 and level < phase + 10) and " |cff4ce64c(your level)|r" or "") }) + (level >= phase - 5 and level < phase + 10) and (" " .. ns.C("good") .. "(your level)|r") or "") }) any = true end AddItemRow(list, it) @@ -375,7 +403,7 @@ function render.professions(list) end if p and p.maxRank > 0 and p.rank >= p.maxRank and p.maxRank < 300 then list:Add({ icon = "Interface\\Icons\\Spell_Holy_SealOfWisdom", highlight = true, - title = "|cffff8040Skill capped - visit a trainer to raise your max skill.|r" }) + title = ns.C("warn") .. "Skill capped - visit a trainer to raise your max skill.|r" }) end if guide.gather and #guide.gather > 0 then list:Add({ header = true, title = "Where to gather" }) @@ -421,7 +449,7 @@ function render.extras(list) local hidden = ns.char.done[t.id] list:Add({ icon = ns.KIND_ICONS[t.kind], status = hidden and UI.STATUS.done or nil, - title = (t.title or "") .. (inRange and " |cff4ce64c(now)|r" or ""), + title = (t.title or "") .. (inRange and (" " .. ns.C("good") .. "(now)|r") or ""), sub = ns.BandText(t) .. " " .. (t.text or ""), dim = hidden or (not inRange), highlight = inRange and not hidden, onClick = function() ns.char.done[t.id] = not ns.char.done[t.id] or nil; ns.Fire("Refresh") end, @@ -452,113 +480,242 @@ function render.dungeons(list) for _, s in ipairs(ns.route) do if s.kind == "dungeon" then local inRange = (s.min or 1) <= level and level <= (s.max or 60) - list:Add({ icon = ns.KIND_ICONS.dungeon, title = (s.title or "") .. (inRange and " |cff4ce64c(your level)|r" or ""), + list:Add({ icon = ns.KIND_ICONS.dungeon, title = (s.title or "") .. (inRange and (" " .. ns.C("good") .. "(your level)|r") or ""), sub = ns.BandText(s) .. " |cffaaaaaa" .. (s.zone or "") .. "|r\n" .. (s.text or ""), dim = level > (s.max or 60) + 3, highlight = inRange, onClick = function() if s.wp then ns.Fire("SetWaypoints", s, true) end end }) end end end +--------------------------------------------------------------------------- +-- Settings (grouped, scrollable). Built into the guide's Settings tab and into the +-- game's Options > AddOns page; both copies read the same saved values when shown. +--------------------------------------------------------------------------- +StaticPopupDialogs["COFFEYGUIDE_RESET"] = { + text = "Clear this character's guide progress?\n\nSteps you have really finished tick themselves off again from your quest history. Manual checkmarks and skipped steps are lost.", + button1 = "Reset", button2 = CANCEL or "Cancel", + OnAccept = function() ns.ResetProgress() end, + timeout = 0, whileDead = true, hideOnEscape = true, preferredIndex = 3, +} ---------------------------------------------------------------------------- --- Settings tab (separate frame, not a list) ---------------------------------------------------------------------------- -local settingsFrame -local function BuildSettings() - settingsFrame = CreateFrame("Frame", nil, g.content) - settingsFrame:SetPoint("TOPLEFT", 0, -50) - settingsFrame:SetPoint("BOTTOMRIGHT") - local opts = { - { "arrow", "Show the built-in direction arrow (when TomTom isn't used)" }, - { "pins", "Show waypoints on the world map and minimap" }, - { "autoWaypoint", "Automatically set waypoints for the current step" }, - { "useTomTom", "Use TomTom's arrow and waypoints when installed" }, - { "toasts", "Show level-up popups (talent, spells, next step)" }, - { "talentGlow", "Highlight the next talent in the talent window" }, +local function ConfirmReset() + if StaticPopup_Show then StaticPopup_Show("COFFEYGUIDE_RESET") else ns.ResetProgress() end +end + +local SECTIONS = { + { "Tracker", { + { "combatFade", "Fade the tracker in combat" }, + { "instanceHide", "Compact in dungeons, hidden in raids and battlegrounds" }, + { "mouseoverFade", "Fade the tracker until you mouse over it" }, + { "toasts", "Level-up popups (talent, new spells, next step)" }, + { "lock", "Lock the tracker, arrow and popup in place" }, + } }, + { "Route and detection", { + { "suggest", "Offer to jump ahead when your quest log shows you're further along", + "Looks at your quest log, completed quests and current zone. The guide only asks; a jump can be undone." }, { "autoSkip", "Treat steps you've outleveled by 4+ levels as done" }, { "showOptional", "Show optional steps (dungeons, side content)" }, - { "lock", "Lock tracker and arrow position" }, - { "gearAdvisor", "Gear advisor: upgrade % on tooltips + popup for bag upgrades" }, + } }, + { "Waypoints", { + { "autoWaypoint", "Set waypoints for the current objective automatically" }, + { "arrow", "Show the built-in direction arrow (when TomTom isn't used)" }, + { "pins", "Show waypoints on the world map and minimap" }, + { "useTomTom", "Use TomTom's arrow and waypoints when installed" }, + } }, + { "Talents and gear", { + { "talentGlow", "Highlight the next talent in the talent window" }, + { "gearAdvisor", "Upgrade % in item tooltips and a popup for bag upgrades" }, { "rewardHints", "Recommend the best quest reward (upgrade, else highest sell value)" }, - { "autoAccept", "Auto-accept quests (hold Shift to skip) - off if you use DialogueUI/Immersion automation" }, + } }, + { "Automation (hold Shift to bypass)", { + { "autoAccept", "Auto-accept quests", "Leave this off if DialogueUI or Immersion already automates quests." }, { "autoTurnIn", "Auto turn in completed quests when there's no reward choice" }, - { "sellGreys", "Auto-sell grey items at vendors" }, - { "autoRepair", "Auto-repair at vendors" }, + { "sellGreys", "Sell gray items at vendors" }, + { "autoRepair", "Repair at vendors" }, + } }, + { "Accessibility, chat and add-ons", { + { "accentGold", "Gold accent color instead of your class color" }, + { "colorblind", "Colorblind-friendly colors (blue for done, orange for problems)" }, + { "quiet", "Fewer chat messages (no login line, no level-up text when popups are on)" }, { "useQuestie", "Use Questie's database (if installed) for quest NPC locations" }, - } + } }, +} + +function ns.BuildSettings(parent) + local scroll = CreateFrame("ScrollFrame", nil, parent, "UIPanelScrollFrameTemplate") + scroll:SetPoint("TOPLEFT", 0, 0) + scroll:SetPoint("BOTTOMRIGHT", -26, 0) + local c = CreateFrame("Frame", nil, scroll) + c:SetSize(560, 900) + scroll:SetScrollChild(c) + + local function changed() ns.Fire("SettingsChanged") end local y = 0 - local perCol = math.ceil(#opts / 2) - for i, o in ipairs(opts) do - local cb = UI.Check(settingsFrame, o[2], function() return ns.db[o[1]] end, - function(v) ns.db[o[1]] = v; ns.Fire("SettingsChanged") end) - cb.label:SetWidth(245); cb.label:SetFontObject("GameFontHighlightSmall") - local col, row = (i > perCol) and 1 or 0, (i - 1) % perCol - cb:SetPoint("TOPLEFT", col * 285, -row * 32) + + -- Tracker layout first: it's the setting people look for. + local t = UI.Section(c, "Tracker layout"); t:SetPoint("TOPLEFT", 0, -y); y = y + 24 + local seg = UI.Segmented(c, { + { label = "Standard", value = "standard", tip = "The step, your next few objectives and the buttons. Talent hints only when there's a point to spend." }, + { label = "Detailed", value = "detailed", tip = "Everything: step text, quest checklist, a longer objective list and level tips." }, + }, function() return ns.db.density end, function(v) ns.db.density = v; changed() end) + seg:SetPoint("TOPLEFT", 0, -y) + local compact = UI.Check(c, "Compact (just the next action)", function() return ns.db.compact end, + function(v) ns.db.compact = v; changed() end, "The minus button on the tracker and a key binding switch this too.") + compact:SetPoint("LEFT", seg, "RIGHT", 16, 0) + y = y + 32 + local scale = UI.Slider(c, "Tracker size", 170, 0.6, 1.6, 0.05, function() return ns.db.scale or 1 end, + function(v) ns.db.scale = v; changed() end, function(v) return ("%d%%"):format(v * 100 + 0.5) end) + scale:SetPoint("TOPLEFT", 4, -y) + local font = UI.Slider(c, "Text size", 170, 0.8, 1.4, 0.05, function() return ns.db.fontScale or 1 end, + function(v) ns.db.fontScale = v; changed() end, function(v) return ("%d%%"):format(v * 100 + 0.5) end) + font:SetPoint("TOPLEFT", 194, -y) + local bg = UI.Slider(c, "Background", 170, 0, 1, 0.05, function() return ns.db.bgAlpha or 0.9 end, + function(v) ns.db.bgAlpha = v; changed() end, function(v) return ("%d%%"):format(v * 100 + 0.5) end) + bg:SetPoint("TOPLEFT", 384, -y) + y = y + 48 + + for _, sec in ipairs(SECTIONS) do + local h = UI.Section(c, sec[1]); h:SetPoint("TOPLEFT", 0, -y); y = y + 22 + for i, o in ipairs(sec[2]) do + local cb = UI.Check(c, o[2], function() return ns.db[o[1]] end, function(v) ns.db[o[1]] = v; changed() end, o[3]) + cb.label:SetFontObject(UI.Font("GameFontHighlightSmall")); cb:SetLabelWidth(240) + local col = (i - 1) % 2 + cb:SetPoint("TOPLEFT", col * 285, -y) + if col == 1 or i == #sec[2] then y = y + 30 end + end + if sec[1] == "Accessibility, chat and add-ons" then + local mm = UI.Check(c, "Minimap button", function() return not ns.db.minimap.hide end, + function(v) ns.db.minimap.hide = not v; ns.Fire("MinimapChanged") end) + mm.label:SetFontObject(UI.Font("GameFontHighlightSmall")) + mm:SetPoint("TOPLEFT", 0, -y); y = y + 30 + end + y = y + 6 end - y = perCol * 32 + 6 - local mm = UI.Check(settingsFrame, "Show minimap button", function() return not ns.db.minimap.hide end, - function(v) ns.db.minimap.hide = not v; ns.Fire("MinimapChanged") end) - mm:SetPoint("TOPLEFT", 0, -y); y = y + 36 - local scaleText = UI.Text(settingsFrame, "GameFontHighlight") - scaleText:SetPoint("TOPLEFT", 4, -y) - local function upd() scaleText:SetText(("Tracker scale: %.0f%%"):format((ns.db.scale or 1) * 100)) end - upd() - local minus = UI.Button(settingsFrame, "-", 26, function() ns.db.scale = math.max(0.6, (ns.db.scale or 1) - 0.1); upd(); ns.Fire("SettingsChanged") end) - minus:SetPoint("LEFT", scaleText, "RIGHT", 10, 0) - local plus = UI.Button(settingsFrame, "+", 26, function() ns.db.scale = math.min(1.6, (ns.db.scale or 1) + 0.1); upd(); ns.Fire("SettingsChanged") end) - plus:SetPoint("LEFT", minus, "RIGHT", 2, 0) - y = y + 40 - - local reset = UI.Button(settingsFrame, "Reset route progress", 170, function() SlashCmdList.COFFEYGUIDE("reset") end) - reset:SetPoint("TOPLEFT", 0, -y) - local site = UI.Button(settingsFrame, "coffeylabs.org", 120, function() ns.ShowLink(ns.WEBSITE) end) - local pos = UI.Button(settingsFrame, "Reset tracker position", 170, function() SlashCmdList.COFFEYGUIDE("resetpos") end) - pos:SetPoint("LEFT", reset, "RIGHT", 8, 0) - site:SetPoint("LEFT", pos, "RIGHT", 8, 0) - y = y + 30 - local support = UI.Button(settingsFrame, "Support Coffey Labs", 170, function() ns.ShowLink(ns.SUPPORT) end) - support:SetPoint("TOPLEFT", 0, -y) + local h = UI.Section(c, "Progress and help"); h:SetPoint("TOPLEFT", 0, -y); y = y + 24 + local welcome = UI.Button(c, "Show welcome", 120, function() ns.Fire("ShowWelcome", true) end) + welcome:SetPoint("TOPLEFT", 0, -y) + local sync = UI.Button(c, "Re-read quest history", 160, function() ns.SyncHistory(true) end) + sync:SetPoint("LEFT", welcome, "RIGHT", 6, 0) + local reset = UI.Button(c, "Reset route progress...", 170, ConfirmReset) + reset:SetPoint("LEFT", sync, "RIGHT", 6, 0) + y = y + 28 + local pos = UI.Button(c, "Reset window positions", 170, function() SlashCmdList.COFFEYGUIDE("resetpos") end) + pos:SetPoint("TOPLEFT", 0, -y) + local site = UI.Button(c, "coffeylabs.org", 120, function() ns.ShowLink(ns.WEBSITE) end) + site:SetPoint("LEFT", pos, "RIGHT", 6, 0) + local support = UI.Button(c, "Support Coffey Labs", 150, function() ns.ShowLink(ns.SUPPORT) end) + support:SetPoint("LEFT", site, "RIGHT", 6, 0) UI.Tooltip(support, "Support Coffey Labs", "Coffey's Leveling Guide is free. Click to copy the link to our funding options (" .. ns.SUPPORT .. ").") - y = y + 36 - local info = UI.Text(settingsFrame, "GameFontDisableSmall") - info:SetPoint("TOPLEFT", 0, -y); info:SetWidth(520) - info:SetText("Coffey's Leveling Guide by Coffey Labs LLC - " .. ns.WEBSITE .. "\nCommands: /cguide (toggle tracker), /cguide guide, /cguide quests, /cguide talents, /cguide spec, /cguide gear, /cguide prof, /cguide gold, /cguide dungeons, /cguide sync, /cguide wp, /cguide next, /cguide prev, /cguide reset, /cguide resetpos, /cguide talentdebug, /cguide support.\nData: wowhandbook.com, icy-veins.com, warcrafttavern.com, warcraftmaps.com, topbuilds.gg (Nov 2026). Level bands are approximate.") + y = y + 34 + local info = UI.Text(c, "GameFontDisableSmall") + info:SetPoint("TOPLEFT", 0, -y); info:SetWidth(540) + info:SetText("Coffey's Leveling Guide by Coffey Labs LLC - " .. ns.WEBSITE .. + "\nKey bindings: Options > Keybindings > AddOns > Coffey's Leveling Guide." .. + "\nCommands: /cguide (toggle tracker), /cguide guide, quests, talents, spec, gear, prof, gold, dungeons, settings, next, prev, check, compact, wp, sync, welcome, reset, resetpos, talentdebug, support." .. + "\nData: wowhandbook.com, icy-veins.com, warcrafttavern.com, warcraftmaps.com, topbuilds.gg and Blizzard's hotfix notes (Nov 2026). Level bands are approximate.") + y = y + info:GetStringHeight() + 20 + c:SetHeight(y) + return scroll +end + +-- Options > AddOns page. +local function RegisterOptions() + local panel = CreateFrame("Frame") + panel.name = "Coffey's Leveling Guide" + local title = UI.Text(panel, "GameFontNormalLarge") + title:SetPoint("TOPLEFT", 16, -16); title:SetText("Coffey's Leveling Guide") + local open = UI.Button(panel, "Open the full guide", 150, function() + if SettingsPanel and SettingsPanel.Close then pcall(SettingsPanel.Close, SettingsPanel, true) + elseif HideUIPanel and SettingsPanel then HideUIPanel(SettingsPanel) end + ns.Fire("OpenGuide", "route") + end) + open:SetPoint("TOPRIGHT", -16, -14) + local body = CreateFrame("Frame", nil, panel) + body:SetPoint("TOPLEFT", 16, -48); body:SetPoint("BOTTOMRIGHT", -10, 10) + panel:SetScript("OnShow", function(self) + if not self.built then self.built = true; ns.BuildSettings(body) end + end) + if Settings and Settings.RegisterCanvasLayoutCategory and Settings.RegisterAddOnCategory then + local cat = Settings.RegisterCanvasLayoutCategory(panel, panel.name) + Settings.RegisterAddOnCategory(cat) + ns.optionsCategory = cat + elseif InterfaceOptions_AddCategory then + InterfaceOptions_AddCategory(panel) + end +end + +local settingsFrame +local function ShowSettingsTab() + if not settingsFrame then + settingsFrame = CreateFrame("Frame", nil, g.content) + settingsFrame:SetPoint("TOPLEFT", 0, -50) + settingsFrame:SetPoint("BOTTOMRIGHT") + ns.BuildSettings(settingsFrame) + end + settingsFrame:Show() end --------------------------------------------------------------------------- -- Window --------------------------------------------------------------------------- +local scrollToCurrent = false + local function Render() if not g or not g:IsShown() then return end + local ar, ag, ab = UI.Accent() for _, t in ipairs(g.tabButtons) do local on = t.key == currentTab - t.bg:SetColorTexture(1, 0.82, 0, on and 0.18 or 0) - t.text:SetTextColor(on and 1 or 0.85, on and 0.82 or 0.85, on and 0 or 0.85) + t.bg:SetColorTexture(ar, ag, ab, on and 0.16 or 0) + t.bar:SetColorTexture(ar, ag, ab, 1); t.bar:SetShown(on) + t.text:SetTextColor(on and 1 or 0.72, on and 1 or 0.72, on and 1 or 0.72) + t.icon:SetDesaturated(not on); t.icon:SetAlpha(on and 1 or 0.75) end local isSettings = currentTab == "settings" g.listHolder:SetShown(not isSettings) + g.search:SetShown(not isSettings) if isSettings then - for _, b in ipairs(selButtons) do b:Hide() end - Header("Settings", "") - if not settingsFrame then BuildSettings() end - settingsFrame:Show() + for _, pool in ipairs(selButtons) do for _, b in ipairs(pool) do b:Hide() end end + Header("Settings", "Changes apply right away. The same page is under Options > AddOns.") + ShowSettingsTab() return end if settingsFrame then settingsFrame:Hide() end g.list:Clear() + g.list:SetFilter(g.search:GetText()) render[currentTab](g.list) g.list:Done() + if scrollToCurrent then + scrollToCurrent = false + if currentTab == "route" and not g.list.filter then + local list = g.list + C_Timer.After(0, function() list:ScrollToMark("current", 80) end) + else + g.list.scroll:SetVerticalScroll(0) + end + end +end + +local function SaveGuideLayout() + local left, top = g:GetLeft(), g:GetTop() + if left and top then ns.db.guidePos = { left, top } end + local w, h = g:GetWidth(), g:GetHeight() + if w and h and w > 0 then ns.db.guideSize = { w, h } end end local function Create() - g = UI.Panel("CoffeyGuideWindow", UIParent, 760, 580) - g:SetPoint("CENTER") + local size = ns.db.guideSize + g = UI.Panel("CoffeyGuideWindow", UIParent, size and size[1] or 760, size and size[2] or 580) + if ns.db.guidePos then g:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", ns.db.guidePos[1], ns.db.guidePos[2]) + else g:SetPoint("CENTER") end g:SetFrameStrata("HIGH") g:SetClampedToScreen(true) g:SetMovable(true); g:EnableMouse(true); g:RegisterForDrag("LeftButton") g:SetScript("OnDragStart", g.StartMoving) - g:SetScript("OnDragStop", g.StopMovingOrSizing) + g:SetScript("OnDragStop", function(self) self:StopMovingOrSizing(); SaveGuideLayout() end) + g:SetResizable(true) + if g.SetResizeBounds then g:SetResizeBounds(760, 460, 1600, 1200) + elseif g.SetMinResize then g:SetMinResize(760, 460) end g:Hide() tinsert(UISpecialFrames, "CoffeyGuideWindow") -- close with Escape @@ -576,8 +733,21 @@ local function Create() credit:SetSize(credit.text:GetStringWidth() + 4, 16) credit:SetScript("OnClick", function() ns.ShowLink(ns.WEBSITE) end) UI.Tooltip(credit, "Coffey Labs LLC", "Click to copy the website link (" .. ns.WEBSITE .. ").") - local close = CreateFrame("Button", nil, g, "UIPanelCloseButton") - close:SetPoint("TOPRIGHT", 2, 2) + UI.CloseButton(g) + UI.FadeIn(g) + + -- Search: filters the rows of whichever tab is open. + local ok, box = pcall(CreateFrame, "EditBox", "CoffeyGuideSearch", g, "SearchBoxTemplate") + if not ok or not box then box = CreateFrame("EditBox", "CoffeyGuideSearch", g, "InputBoxTemplate") end + box:SetSize(190, 20) + box:SetPoint("TOPRIGHT", g, "TOPRIGHT", -36, -15) + box:SetAutoFocus(false) + if type(box.Instructions) == "table" then box.Instructions:SetText("Search this tab") end + box:HookScript("OnTextChanged", function() scrollToCurrent = true; Render() end) + box:HookScript("OnEscapePressed", function(self) self:ClearFocus() end) + box:HookScript("OnEnterPressed", function(self) self:ClearFocus() end) + UI.Tooltip(box, "Search", "Filter steps, quests, talents, items and tips on this tab.") + g.search = box -- Left navigation. g.tabButtons = {} @@ -586,32 +756,34 @@ local function Create() b:SetSize(150, 30) b:SetPoint("TOPLEFT", 10, -56 - (i - 1) * 32) b.bg = b:CreateTexture(nil, "BACKGROUND"); b.bg:SetAllPoints() - b:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD") - b.icon = UI.Icon(b, 24, t.icon); b.icon:SetPoint("LEFT", 4, 0) + UI.Hover(b, 0.05) + b.bar = b:CreateTexture(nil, "BORDER"); b.bar:SetPoint("TOPLEFT"); b.bar:SetPoint("BOTTOMLEFT"); b.bar:SetWidth(3) + b.icon = UI.Icon(b, 22, t.icon); b.icon:SetPoint("LEFT", 10, 0) + UI.IconBorder(b.icon) b.text = UI.Text(b, "GameFontNormal"); b.text:SetPoint("LEFT", b.icon, "RIGHT", 8, 0); b.text:SetText(t.label) b.key = t.key - b:SetScript("OnClick", function() currentTab = t.key; Render() end) + b:SetScript("OnClick", function() currentTab = t.key; scrollToCurrent = true; Render() end) g.tabButtons[i] = b end -- Header divider: the title bar keeps its own strip above the tabs and content. local headerLine = g:CreateTexture(nil, "ARTWORK") - headerLine:SetColorTexture(0.55, 0.45, 0.25, 0.6) + headerLine:SetColorTexture(1, 1, 1, 0.08) headerLine:SetPoint("TOPLEFT", g, "TOPLEFT", 10, -48); headerLine:SetPoint("TOPRIGHT", g, "TOPRIGHT", -10, -48) headerLine:SetHeight(1) -- Content area. g.content = CreateFrame("Frame", nil, g) g.content:SetPoint("TOPLEFT", 172, -56) - g.content:SetPoint("BOTTOMRIGHT", -12, 12) + g.content:SetPoint("BOTTOMRIGHT", -12, 18) local sep = g:CreateTexture(nil, "ARTWORK") - sep:SetColorTexture(0.55, 0.45, 0.25, 0.6) + sep:SetColorTexture(1, 1, 1, 0.08) sep:SetPoint("TOPLEFT", g, "TOPLEFT", 166, -52); sep:SetPoint("BOTTOMLEFT", g, "BOTTOMLEFT", 166, 12); sep:SetWidth(1) g.title = UI.Text(g.content, "GameFontNormalLarge") - g.title:SetPoint("TOPLEFT", 0, 0); g.title:SetWidth(540) + g.title:SetPoint("TOPLEFT", 0, 0); g.title:SetPoint("RIGHT", g.content, "RIGHT", 0, 0) g.sub = UI.Text(g.content, "GameFontHighlightSmall") - g.sub:SetPoint("TOPLEFT", g.title, "BOTTOMLEFT", 0, -4); g.sub:SetWidth(550) + g.sub:SetPoint("TOPLEFT", g.title, "BOTTOMLEFT", 0, -4); g.sub:SetPoint("RIGHT", g.content, "RIGHT", 0, 0) g.listHolder = CreateFrame("Frame", nil, g.content) g.listHolder:SetPoint("TOPLEFT", 0, -48); g.listHolder:SetPoint("BOTTOMRIGHT") @@ -619,7 +791,17 @@ local function Create() g.list.scroll:SetPoint("TOPLEFT", 0, 0) g.list.scroll:SetPoint("BOTTOMRIGHT", -26, 0) - g:SetScript("OnShow", Render) + -- Resize grip. + local grip = CreateFrame("Button", nil, g) + grip:SetSize(16, 16); grip:SetPoint("BOTTOMRIGHT", -4, 4) + grip:SetNormalTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Up") + grip:SetHighlightTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Highlight") + grip:SetPushedTexture("Interface\\ChatFrame\\UI-ChatIM-SizeGrabber-Down") + grip:SetScript("OnMouseDown", function() g:StartSizing("BOTTOMRIGHT") end) + grip:SetScript("OnMouseUp", function() g:StopMovingOrSizing(); SaveGuideLayout(); Render() end) + UI.Tooltip(grip, "Resize", "Drag to resize the guide.") + + g:HookScript("OnShow", function() scrollToCurrent = true; Render() end) -- Item data arrives asynchronously; re-render the gear tab when it does. local pending = false @@ -632,11 +814,21 @@ local function Create() end) end -ns.On("Login", Create) +local TAB_ALIASES = { talents = { "class", "talents" }, spec = { "class", "spec" } } + +ns.On("Login", function() Create(); RegisterOptions() end) ns.On("OpenGuide", function(tab) if not g then return end - if tab then currentTab = tab end + local alias = tab and TAB_ALIASES[tab] + if alias then tab = alias[1]; sel.classView = alias[2] end + if tab then currentTab = tab; scrollToCurrent = true end if g:IsShown() and not tab then g:Hide() else g:Show(); Render() end end) ns.On("Refresh", Render) ns.On("RefreshGuide", Render) +ns.On("SettingsChanged", Render) +ns.On("ResetPosition", function() + if not g then return end + ns.db.guidePos, ns.db.guideSize = nil, nil + g:ClearAllPoints(); g:SetPoint("CENTER"); g:SetSize(760, 580) +end) diff --git a/UI/Tracker.lua b/UI/Tracker.lua index 267490b..5fe8242 100644 --- a/UI/Tracker.lua +++ b/UI/Tracker.lua @@ -1,20 +1,33 @@ --- Coffey's Leveling Guide tracker: the compact always-on panel showing the current step. +-- Coffey's Leveling Guide tracker: the always-on panel showing what to do next. +-- Three layouts: compact (one action line), standard (step, next objectives, actions) and +-- detailed (everything: step text, quest checklist, a longer plan window, tips). The panel +-- grows downward from its top edge, so its title stays put while the content changes. local ADDON, ns = ... local UI = ns.UI local W = 340 local frame +-- Set by instance state. A manual show/compact toggle wins until the next zone change. +local context = { hidden = false, compact = false, override = false } +--------------------------------------------------------------------------- +-- Position +--------------------------------------------------------------------------- local function SavePos(self) self:StopMovingOrSizing() - local p, _, rp, x, y = self:GetPoint() - ns.char.pos = { p, rp, x, y } + local left, top = self:GetLeft(), self:GetTop() + if left and top then + ns.char.pos = { "TOPLEFT", "BOTTOMLEFT", left, top } + else + local p, _, rp, x, y = self:GetPoint() + ns.char.pos = { p, rp, x, y } + end end local function ApplyPos() frame:ClearAllPoints() local p = ns.char.pos if p then frame:SetPoint(p[1], UIParent, p[2], p[3], p[4]) - else frame:SetPoint("RIGHT", UIParent, "RIGHT", -60, 140) end + else frame:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", -60, -230) end end local function KindIcon(step) @@ -22,6 +35,14 @@ local function KindIcon(step) return ns.KIND_ICONS[step.kind] or ns.KIND_ICONS.quest end +local function IsCompact() return ns.db.compact or (context.compact and not context.override) end +local function Detailed() return ns.db.density == "detailed" and not IsCompact() end + +local function Plain(text) return (text or ""):gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") end + +--------------------------------------------------------------------------- +-- Construction +--------------------------------------------------------------------------- local function Create() frame = UI.Panel("CoffeyGuideTracker", UIParent, W, 200) frame:SetFrameStrata("MEDIUM") @@ -30,6 +51,7 @@ local function Create() frame:SetScript("OnDragStart", function(self) if not ns.db.lock then self:StartMoving() end end) frame:SetScript("OnDragStop", SavePos) frame:SetScale(ns.db.scale or 1) + UI.Style(frame, ns.db.bgAlpha) ApplyPos() -- Header: class icon, identity, buttons. @@ -43,30 +65,44 @@ local function Create() frame.spec:SetPoint("TOPLEFT", frame.who, "BOTTOMLEFT", 0, -2) frame.spec:SetWidth(W - 150) - local close = CreateFrame("Button", nil, frame, "UIPanelCloseButton") - close:SetPoint("TOPRIGHT", 2, 2) - close:SetScript("OnClick", function() frame:Hide(); ns.char.hidden = true end) + local close = UI.CloseButton(frame, function() frame:Hide(); ns.char.hidden = true end) + UI.Tooltip(close, "Hide tracker", "Bring it back with /cguide, the minimap button or a key binding.") - frame.minBtn = UI.IconButton(frame, 18, "Interface\\Buttons\\UI-MinusButton-Up", "Minimize", "Collapse to one line.", - function() ns.db.minimized = not ns.db.minimized; ns.Fire("Refresh") end) - frame.minBtn.icon:SetTexCoord(0, 1, 0, 1) - frame.minBtn:SetPoint("RIGHT", close, "LEFT", 0, 0) + frame.minBtn = UI.Glyph(frame, 20, "plus", "Compact", + "Switch between the compact tracker (just the next action) and the full one.", + function() ns.Fire("ToggleCompact") end) + frame.minBtn:SetPoint("RIGHT", close, "LEFT", -2, 0) frame.guideBtn = UI.IconButton(frame, 20, "Interface\\Icons\\INV_Misc_Book_09", "Full guide", - "Route, talents, spec guide, gear, professions, gold & extras.", function() ns.Fire("OpenGuide") end) + "Route, quest log, talents and spec guide, gear, professions, gold and extras.", function() ns.Fire("OpenGuide") end) frame.guideBtn:SetPoint("RIGHT", frame.minBtn, "LEFT", -4, 0) + frame.guideBtn.border = UI.IconBorder(frame.guideBtn.icon) - -- Progress bar. - frame.bar = UI.Bar(frame, W - 20, 12) - frame.bar:SetPoint("TOPLEFT", 10, -42) + -- Progress bar (a thin strip at the bottom in compact mode). + frame.bar = UI.Bar(frame, W - 20, 14) + + -- Suggestion / undo banner. + local bn = CreateFrame("Frame", nil, frame) + bn:SetSize(W - 20, 44) + bn.bg = bn:CreateTexture(nil, "BACKGROUND"); bn.bg:SetAllPoints(); UI.AccentTexture(bn.bg, 0.12) + bn.edge = bn:CreateTexture(nil, "BORDER"); bn.edge:SetPoint("TOPLEFT"); bn.edge:SetPoint("BOTTOMLEFT"); bn.edge:SetWidth(2) + UI.AccentTexture(bn.edge, 0.95) + bn.icon = UI.Icon(bn, 18, "Interface\\Icons\\INV_Misc_Map_01"); bn.icon:SetPoint("TOPLEFT", 8, -5) + UI.IconBorder(bn.icon) + bn.text = UI.Text(bn, "GameFontHighlightSmall") + bn.text:SetPoint("TOPLEFT", bn.icon, "TOPRIGHT", 6, 0); bn.text:SetWidth(W - 52) + bn.yes = UI.Button(bn, "Go there", 80, function() if bn.onYes then bn.onYes() end end, "primary") + bn.no = UI.Button(bn, "Not now", 70, function() if bn.onNo then bn.onNo() end end) + bn.no:SetPoint("BOTTOMRIGHT", -4, 3) + bn.yes:SetPoint("RIGHT", bn.no, "LEFT", -4, 0) + bn.yes:SetHeight(20); bn.no:SetHeight(20) + frame.banner = bn -- Step card. frame.kindIcon = UI.Icon(frame, 36) - frame.kindIcon:SetPoint("TOPLEFT", frame.bar, "BOTTOMLEFT", 0, -8) + frame.kindBorder = UI.IconBorder(frame.kindIcon) frame.title = UI.Text(frame, "GameFontNormalLarge") - frame.title:SetPoint("TOPLEFT", frame.kindIcon, "TOPRIGHT", 8, 0) frame.title:SetWidth(W - 70) frame.band = UI.Text(frame, "GameFontHighlightSmall") - frame.band:SetPoint("TOPLEFT", frame.title, "BOTTOMLEFT", 0, -2) frame.band:SetWidth(W - 70) frame.body = UI.Text(frame, "GameFontHighlight") @@ -93,25 +129,25 @@ local function Create() return { b and (b.name .. " - " .. (b.summary or "")) or "No build data", "Click to open your talents. The next pick glows in the talent window." } end) - -- Tip row. + -- Tip row and next-step preview. frame.tip = UI.Text(frame, "GameFontHighlightSmall") frame.tip:SetWidth(W - 24) - - -- Next step preview. frame.nextLine = UI.Text(frame, "GameFontDisableSmall") frame.nextLine:SetWidth(W - 24) -- Bottom buttons. local function nav(delta) return function() ns.SetView(ns.ViewIndex() + delta) end end - frame.prev = UI.IconButton(frame, 22, "Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up", "Previous step", nil, nav(-1)) - frame.prev.icon:SetTexCoord(0, 1, 0, 1) - frame.nextB = UI.IconButton(frame, 22, "Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up", "Next step", nil, nav(1)) - frame.nextB.icon:SetTexCoord(0, 1, 0, 1) + frame.prev = UI.Glyph(frame, 22, "left", "Previous step", nil, nav(-1)) + frame.nextB = UI.Glyph(frame, 22, "right", "Next step", nil, nav(1)) frame.cur = UI.Button(frame, "Current", 62, function() ns.SetView(nil) end) + UI.Tooltip(frame.cur, "Back to the current step", "Stop browsing and show the step you are on.") frame.done = UI.Button(frame, "Done", 54, function() ns.ToggleDone(ns.route[ns.ViewIndex()]) end) + UI.Tooltip(frame.done, "Mark the whole step done", "Undo puts it back.") frame.skip = UI.Button(frame, "Skip", 46, function() ns.Skip(ns.route[ns.ViewIndex()]) end) + UI.Tooltip(frame.skip, "Skip this step", "Skipped steps stay in the Route tab; click Undo there or here to bring one back.") frame.wp = UI.IconButton(frame, 22, "Interface\\Icons\\INV_Misc_Map_01", "Waypoints", - "Show this step on your map, minimap and arrow.", function() ns.Fire("SetWaypoints", ns.route[ns.ViewIndex()], true) end) + "Show the current objective on your map, minimap and arrow.", function() ns.Fire("WaypointCurrent") end) + UI.IconBorder(frame.wp.icon) frame.prev:SetPoint("BOTTOMLEFT", 10, 9) frame.nextB:SetPoint("LEFT", frame.prev, "RIGHT", 2, 0) @@ -120,6 +156,30 @@ local function Create() frame.skip:SetPoint("LEFT", frame.done, "RIGHT", 2, 0) frame.wp:SetPoint("BOTTOMRIGHT", -10, 9) + -- "Still open" reminder for class quests and mounts left behind. + frame.reminder = CreateFrame("Button", nil, frame) + frame.reminder:SetSize(W - 24, 16) + frame.reminder.text = UI.Text(frame.reminder, "GameFontHighlightSmall") + frame.reminder.text:SetPoint("LEFT"); frame.reminder.text:SetWidth(W - 24) + if frame.reminder.text.SetMaxLines then frame.reminder.text:SetMaxLines(1) end + frame.reminder:SetScript("OnClick", function(self) if self.idx then ns.SetView(self.idx) end end) + UI.Tooltip(frame.reminder, "Still open", "A class quest or mount you've outleveled without doing. It no longer holds up the route. Click to view it; Done or Skip there clears the reminder.") + + -- Compact action line: checkbox + the next objective. + frame.action = CreateFrame("Button", nil, frame) + frame.action:SetSize(W - 20, 18) + frame.action.check = CreateFrame("Button", nil, frame.action) + frame.action.check:SetSize(16, 16); frame.action.check:SetPoint("TOPLEFT", 0, -1) + frame.action.check.tex = frame.action.check:CreateTexture(nil, "ARTWORK"); frame.action.check.tex:SetAllPoints() + UI.Hover(frame.action.check, 0.15) + frame.action.check:SetScript("OnClick", function() ns.CheckCurrent() end) + UI.Tooltip(frame.action.check, "Check off", "Mark this objective done. Key binding: Options > Keybindings > AddOns.") + frame.action.text = UI.Text(frame.action, "GameFontHighlight") + frame.action.text:SetPoint("TOPLEFT", frame.action.check, "TOPRIGHT", 5, 1) + frame.action.text:SetWidth(W - 70) + frame.action:SetScript("OnClick", function() ns.Fire("WaypointCurrent", true) end) + UI.Tooltip(frame.action, "Next objective", "Click for a waypoint. Tick the box when it's done.") + if ns.char.hidden then frame:Hide() end end @@ -139,16 +199,27 @@ local function QuestRow(i) return r end +-- Plan rows: a real checkbox on the left (click to toggle), the row itself sets a waypoint. local function PlanRow(i) local r = frame.prows[i] if not r then r = CreateFrame("Button", nil, frame) r:SetSize(W - 24, 18) r.bg = r:CreateTexture(nil, "BACKGROUND"); r.bg:SetAllPoints() - r.icon = r:CreateTexture(nil, "ARTWORK"); r.icon:SetSize(14, 14); r.icon:SetPoint("TOPLEFT", 0, -2) + r.edge = r:CreateTexture(nil, "BORDER"); r.edge:SetPoint("TOPLEFT", -2, 0); r.edge:SetPoint("BOTTOMLEFT", -2, 0); r.edge:SetWidth(2) + r.box = CreateFrame("Button", nil, r) + r.box:SetSize(14, 14); r.box:SetPoint("TOPLEFT", 0, -2) + r.box.tex = r.box:CreateTexture(nil, "ARTWORK"); r.box.tex:SetAllPoints() + UI.Hover(r.box, 0.15) + r.box:SetScript("OnClick", function() + local step = ns.route[ns.ViewIndex()] + if step and r.s then ns.MarkSub(step, r.s, not ns.SubDone(step, r.s)) end + end) + UI.Tooltip(r.box, "Done?", "Click to mark this objective done or not done.") + r.icon = r:CreateTexture(nil, "ARTWORK"); r.icon:SetSize(14, 14); r.icon:SetPoint("TOPLEFT", r.box, "TOPRIGHT", 3, 0) r.text = UI.Text(r, "GameFontHighlightSmall") r.text:SetPoint("TOPLEFT", r.icon, "TOPRIGHT", 5, 0) - r.text:SetWidth(W - 48) + r.text:SetWidth(W - 66) r:RegisterForClicks("LeftButtonUp", "RightButtonUp") r:SetScript("OnClick", function(self, button) local step = ns.route[ns.ViewIndex()] @@ -156,81 +227,203 @@ local function PlanRow(i) if button == "RightButton" then ns.MarkSub(step, self.s, not ns.SubDone(step, self.s)) else ns.Fire("SetWaypoints", { id = step.id .. ":manual", title = step.title, wp = ns.SubWaypoints(self.s) }, true) end end) - UI.Tooltip(r, function() return r.s and ns.SubText(r.s) or "" end, - { "Left-click: waypoint to this step", "Right-click: mark done / not done" }) + UI.Tooltip(r, function() return r.s and ns.SubText(r.s) or "" end, function() + local lines = { "Click: waypoint to this objective", "Checkbox or right-click: mark done / not done" } + if r.missed then table.insert(lines, 1, ns.C("dim") .. "You seem to have passed this one by (not in your log, later quests started). It no longer holds up the guide.|r") end + return lines + end) frame.prows[i] = r end return r end +--------------------------------------------------------------------------- +-- Banner: "you seem to be further along" or "undo the jump" +--------------------------------------------------------------------------- +local function BannerContent() + local D = ns.Detect + if not D then return nil end + local j = D.RecentJump() + if j then + return { icon = "Interface\\Buttons\\UI-RefreshButton", + text = ("Skipped %d earlier step(s) to get here%s."):format(#j.ids, + #(j.deferred or {}) > 0 and ("; " .. #j.deferred .. " class quest or mount step(s) stay on the reminder list") or ""), + yes = "Undo", onYes = D.UndoJump, no = "OK", onNo = function() ns.char.lastJump = nil; ns.Fire("Refresh") end } + end + if ns.char.view then return nil end -- browsing: don't nag + local i, step, reason = D.Suggestion() + if i then + return { icon = KindIcon(step) or ns.KIND_ICONS.zone, + text = reason .. " " .. ns.C("cur") .. "Jump to " .. (step.title or "?") .. "?|r", + yes = "Go there", onYes = function() D.JumpTo(i) end, no = "Not now", onNo = function() D.Dismiss(step) end } + end +end + +local function LayoutBanner(y) + local b = BannerContent() + local bn = frame.banner + if not b then bn:Hide(); return y end + bn.icon:SetTexture(b.icon); bn.text:SetText(b.text) + bn.yes:SetText(b.yes); bn.no:SetText(b.no) + bn.onYes, bn.onNo = b.onYes, b.onNo + local h = math.max(44, bn.text:GetStringHeight() + 30) + bn:SetHeight(h) + bn:ClearAllPoints(); bn:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -y) + bn:Show() + return y + h + 6 +end + +--------------------------------------------------------------------------- +-- Refresh +--------------------------------------------------------------------------- +local ALL_BODY +local function HideAll() + ALL_BODY = ALL_BODY or { frame.classIcon, frame.who, frame.spec, frame.bar, frame.kindIcon, frame.title, frame.band, + frame.body, frame.planHeader, frame.talentRow, frame.tip, frame.nextLine, frame.prev, frame.nextB, frame.cur, + frame.done, frame.skip, frame.wp, frame.action, frame.banner, frame.reminder } + for _, w in ipairs(ALL_BODY) do w:Hide() end + frame.kindBorder:Hide() + for _, r in ipairs(frame.qrows) do r:Hide() end + for _, r in ipairs(frame.prows) do r:Hide() end +end + +-- The next objective in one line: the first open plan sub-step, else the step text. +local function ActionText(step) + local plan, first = ns.PlanProgress(step) + if plan and first then return ns.SubText(plan[first]), true end + return step.text or step.title or "", false +end + +local function RefreshCompact(step, idx, cur) + local y = 8 + frame.kindIcon:SetSize(18, 18) + frame.kindIcon:ClearAllPoints(); frame.kindIcon:SetPoint("TOPLEFT", 10, -y) + local icon = KindIcon(step) + if icon then frame.kindIcon:SetTexture(icon); frame.kindIcon:SetTexCoord(0.08, 0.92, 0.08, 0.92) + else UI.ClassIcon(frame.kindIcon, ns.player.class) end + frame.kindIcon:Show(); frame.kindBorder:Show() + frame.title:SetFontObject(UI.Font("GameFontNormal")) + frame.title:ClearAllPoints(); frame.title:SetPoint("LEFT", frame.kindIcon, "RIGHT", 6, 0) + frame.title:SetWidth(W - 110) + frame.title:SetText((step.title or step.zone or "?") .. (idx ~= cur and (" " .. ns.C("info") .. "(viewing)|r") or "")) + if frame.title.SetMaxLines then frame.title:SetMaxLines(1) end + frame.title:Show() + y = y + 24 + + y = LayoutBanner(y) + + local text, isPlan = ActionText(step) + frame.action:ClearAllPoints(); frame.action:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -y) + frame.action.text:SetText(text) + if frame.action.text.SetMaxLines then frame.action.text:SetMaxLines(3) end + frame.action.check.tex:SetTexture(UI.STATUS.todo) + frame.action.check:SetShown(isPlan) + local h = math.max(18, frame.action.text:GetStringHeight() + 4) + frame.action:SetHeight(h) + frame.action:Show() + y = y + h + 6 + + -- Thin progress strip along the bottom edge. + frame.bar:SetSize(W - 20, 3) + frame.bar.text:SetText("") + frame.bar:ClearAllPoints(); frame.bar:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 10, 6) + frame.bar:Show() + frame:SetHeight(y + 10) +end + local function Refresh() - if not frame then return end + if not frame or not frame:IsShown() then return end local p = ns.player p.level = UnitLevel("player") - - UI.ClassIcon(frame.classIcon, p.class) - frame.who:SetText(("%s %s |cffffffffLv %d|r"):format(p.raceName or "", p.className or "", p.level or 0)) - local build, auto = ns.GetActiveBuild() - frame.spec:SetText(build and ((auto and "|cff808080auto:|r " or "") .. build.name) or "|cff808080no build data|r") + HideAll() local done, total = ns.Progress() frame.bar:SetMinMaxValues(0, math.max(total, 1)) frame.bar:SetValue(done) - frame.bar.text:SetText(("Route %d / %d steps · %d%%"):format(done, total, total > 0 and math.floor(done * 100 / total) or 0)) local cur = ns.CurrentIndex() local idx = ns.ViewIndex() local step = ns.route[idx] - local minimized = ns.db.minimized + local compact = IsCompact() + frame.minBtn:SetGlyph(compact and "plus" or "minus") if not step then - frame.title:SetText("No route data for your character") - frame.band:SetText(""); frame.body:SetText("") - frame:SetHeight(110) + frame.title:SetFontObject(UI.Font("GameFontNormalLarge")) + frame.title:ClearAllPoints(); frame.title:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -12) + frame.title:SetText("No route for this character yet") + frame.title:Show() + frame.band:ClearAllPoints(); frame.band:SetPoint("TOPLEFT", frame.title, "BOTTOMLEFT", 0, -4) + frame.band:SetText("The guide covers levels 1-60 for every race. Type /cguide sync, or open the full guide for talents, gear and professions.") + frame.band:Show() + frame:SetHeight(80) return end + if compact then RefreshCompact(step, idx, cur); return end + + -- Header. + frame.classIcon:Show(); frame.who:Show(); frame.spec:Show() + UI.ClassIcon(frame.classIcon, p.class) + frame.who:SetText(("|cffffffff%s|r %s%s|r |cff9a9a9aLv|r |cffffffff%d|r"):format(p.raceName or "", UI.AccentHex(), p.className or "", p.level or 0)) + local build, auto = ns.GetActiveBuild() + frame.spec:SetText(build and ((auto and "|cff808080auto:|r " or "") .. build.name) or "|cff808080no build data|r") + + frame.bar:SetSize(W - 20, 14) + frame.bar:ClearAllPoints(); frame.bar:SetPoint("TOPLEFT", 10, -42) + frame.bar.text:SetText(("Route %d / %d steps · %d%%"):format(done, total, total > 0 and math.floor(done * 100 / total) or 0)) + frame.bar:Show() + + local y = LayoutBanner(42 + 14 + 8) + -- Step card. local icon = KindIcon(step) + frame.kindIcon:SetSize(36, 36) + frame.kindIcon:ClearAllPoints(); frame.kindIcon:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -y) if icon then frame.kindIcon:SetTexture(icon); frame.kindIcon:SetTexCoord(0.08, 0.92, 0.08, 0.92) else UI.ClassIcon(frame.kindIcon, p.class) end + frame.kindIcon:Show(); frame.kindBorder:Show() local state = ns.StepState(step) - local status = state == "done" and " |cff4ce64cdone|r" - or state == "skipped" and " |cffcc4444skipped|r" + local status = state == "done" and (" " .. ns.C("good") .. "done|r") + or state == "skipped" and (" " .. ns.C("skip") .. "skipped|r") or state == "outleveled" and " |cff808080outleveled|r" - or (idx == cur and " |cffffd100current|r" or "") - if step.optional then status = status .. " |cff8080ffoptional|r" end + or state == "behind" and (" " .. ns.C("warn") .. "still open|r") + or (idx == cur and (" " .. ns.C("cur") .. "current|r") or "") + if step.optional then status = status .. " " .. ns.C("info") .. "optional|r" end + frame.title:SetFontObject(UI.Font("GameFontNormalLarge")) + if frame.title.SetMaxLines then frame.title:SetMaxLines(0) end + frame.title:SetWidth(W - 70) + frame.title:ClearAllPoints(); frame.title:SetPoint("TOPLEFT", frame.kindIcon, "TOPRIGHT", 8, 0) frame.title:SetText(step.title or step.zone or "?") + frame.title:Show() local zd, zt = ns.ZoneStats(step) local zs = zd and (" · |cffffffff%d/%d|r quests done"):format(zd, zt) or "" + frame.band:ClearAllPoints(); frame.band:SetPoint("TOPLEFT", frame.title, "BOTTOMLEFT", 0, -2) frame.band:SetText(("%s · %s%s%s"):format(ns.BandText(step), step.zone or "", zs, status)) + frame.band:Show() + y = y + math.max(36, frame.title:GetStringHeight() + frame.band:GetStringHeight() + 4) + 8 - -- Collapse everything below the title when minimized. - local showBody = not minimized - for _, w in ipairs({ frame.body, frame.talentRow, frame.tip, frame.nextLine, frame.prev, frame.nextB, - frame.cur, frame.done, frame.skip, frame.wp }) do w:SetShown(showBody) end - for _, r in ipairs(frame.qrows) do r:Hide() end - for _, r in ipairs(frame.prows) do r:Hide() end - frame.planHeader:SetShown(showBody) - frame.minBtn.icon:SetTexture(minimized and "Interface\\Buttons\\UI-PlusButton-Up" or "Interface\\Buttons\\UI-MinusButton-Up") - if minimized then frame:SetHeight(100); return end + local detailed = Detailed() + local qplan, first, pdone, missed = ns.PlanProgress(step) + local hasPlan = qplan and #qplan > 0 - local y = 42 + 12 + 8 + math.max(36, frame.title:GetStringHeight() + frame.band:GetStringHeight() + 4) + 8 - frame.body:ClearAllPoints() - frame.body:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) - frame.body:SetText(step.text or "") - y = y + frame.body:GetStringHeight() + 8 + -- Step text: always in detailed mode; in standard mode only when there's no plan to follow. + if detailed or not hasPlan then + frame.body:ClearAllPoints(); frame.body:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) + frame.body:SetText(step.text or "") + frame.body:Show() + y = y + frame.body:GetStringHeight() + 8 + end - -- Quest checklist. - if step.quests then + -- Quest checklist (detailed, or standard when there's no plan). + if step.quests and (detailed or not hasPlan) then for i, q in ipairs(step.quests) do local name = type(q) == "table" and q[1] or q local r = QuestRow(i) r:ClearAllPoints(); r:SetPoint("TOPLEFT", frame, "TOPLEFT", 14, -y) if ns.IsQuestDone(q) then - r.check:SetTexture(UI.STATUS.done); r.text:SetText("|cff4ce64c" .. name .. "|r") + r.check:SetTexture(UI.STATUS.done); r.text:SetText(ns.C("good") .. name .. "|r") elseif ns.IsQuestActive(q) then - r.check:SetTexture(UI.STATUS.current); r.text:SetText("|cffffd100" .. name .. "|r |cff808080(in log)|r") + r.check:SetTexture(UI.STATUS.current); r.text:SetText(ns.C("cur") .. name .. "|r |cff808080(in log)|r") else r.check:SetTexture(UI.STATUS.todo); r.text:SetText("|cffaaaaaa" .. name .. "|r") end @@ -240,66 +433,78 @@ local function Refresh() y = y + 6 end - -- Quest plan (quest-by-quest checklist): show a window of upcoming sub-steps. - for _, r in ipairs(frame.prows) do r:Hide() end - local qplan, first, pdone = ns.PlanProgress(step) - if qplan and #qplan > 0 then + -- Quest plan window. + if hasPlan then + local nMissed = ns.MissedCount(missed) frame.planHeader:ClearAllPoints(); frame.planHeader:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) - frame.planHeader:SetText(("|cffffd100Quest plan|r %d / %d"):format(pdone, #qplan)); frame.planHeader:Show() + frame.planHeader:SetText(("%sQuest plan|r %d / %d%s"):format(ns.C("cur"), pdone, #qplan, + nMissed > 0 and (" |cff808080· %d passed by|r"):format(nMissed) or "")) + frame.planHeader:Show() y = y + 16 - local startI = math.max(1, (first or #qplan) - 1) + local maxRows = detailed and 6 or 3 + local startI = detailed and math.max(1, (first or #qplan) - 1) or (first or #qplan) local shown = 0 for i = startI, #qplan do - if shown >= 6 then break end + if shown >= maxRows then break end local s = qplan[i] - local r = PlanRow(shown + 1) - shown = shown + 1 - r.s = s - r:ClearAllPoints(); r:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) - r.icon:SetTexture(ns.ACT_ICONS[s.act] or ns.ACT_ICONS.note) - local isDone = ns.SubDone(step, s) - local isCur = (i == first) - local text = ns.SubText(s) - if isDone then text = "|cff4ce64c" .. text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") .. "|r" - elseif not isCur then text = "|cffaaaaaa" .. text:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", "") .. "|r" end - r.text:SetText((isCur and "|TInterface\\ChatFrame\\ChatFrameExpandArrow:12|t " or "") .. text) - r.icon:SetDesaturated(isDone) - r.bg:SetColorTexture(1, 0.82, 0, isCur and 0.12 or 0) - r:SetHeight(math.max(18, r.text:GetStringHeight() + 4)) - r:Show() - y = y + r:GetHeight() + 1 + local isMissed = missed and missed[i] + if not (isMissed and not detailed) then + local r = PlanRow(shown + 1) + shown = shown + 1 + r.s, r.missed = s, isMissed + r:ClearAllPoints(); r:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) + r.icon:SetTexture(ns.ACT_ICONS[s.act] or ns.ACT_ICONS.note) + local isDone = ns.SubDone(step, s) + local isCur = (i == first) + local text = ns.SubText(s) + if isDone then text = ns.C("good") .. Plain(text) .. "|r" + elseif isMissed then text = "|cff707070" .. Plain(text) .. " (passed by)|r" + elseif not isCur then text = "|cffaaaaaa" .. Plain(text) .. "|r" end + r.text:SetText(text) + r.box.tex:SetTexture(isDone and UI.STATUS.done or (isCur and UI.STATUS.current or UI.STATUS.todo)) + r.icon:SetDesaturated(isDone or isMissed) + local ar, ag, ab = UI.Accent() + r.bg:SetColorTexture(ar, ag, ab, isCur and 0.13 or 0) + r.edge:SetColorTexture(ar, ag, ab, 0.95); r.edge:SetShown(isCur) + r:SetHeight(math.max(18, r.text:GetStringHeight() + 4)) + r:Show() + y = y + r:GetHeight() + 1 + end end y = y + 6 - else - frame.planHeader:Hide() end - -- Talent row. + -- Talent row: in standard mode only when there's something to do about it. local L, plan, info, behind = ns.PendingTalent() local unspent = ns.UnspentTalentPoints() - frame.talentRow:ClearAllPoints(); frame.talentRow:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -y) - if plan then - frame.talentIcon:SetTexture(info and info.icon or "Interface\\Icons\\INV_Misc_QuestionMark") - local head = behind and (unspent > 0 and "|cff4ce64cSpend now:|r " or "|cffff8040Missing:|r ") or ("|cffffd100Lv " .. L .. ":|r ") - frame.talentText:SetText(head .. ns.TalentText(plan) .. " |cff808080(" .. (plan[3] or "") .. ")|r" - .. (unspent > 0 and (" |cff4ce64c" .. unspent .. " unspent|r") or "")) - else - frame.talentIcon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark") - frame.talentText:SetText("|cff808080No talent plan for this class yet|r") + local actionable = plan and (unspent > 0 or behind or L == p.level) + if detailed or actionable then + frame.talentRow:ClearAllPoints(); frame.talentRow:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -y) + if plan then + frame.talentIcon:SetTexture(info and info.icon or "Interface\\Icons\\INV_Misc_QuestionMark") + local head = behind and (unspent > 0 and (ns.C("good") .. "Spend now:|r ") or (ns.C("warn") .. "Missing:|r ")) + or (ns.C("cur") .. "Lv " .. L .. ":|r ") + frame.talentText:SetText(head .. ns.TalentText(plan) .. " |cff808080(" .. (plan[3] or "") .. ")|r" + .. (unspent > 0 and (" " .. ns.C("good") .. unspent .. " unspent|r") or "")) + else + frame.talentIcon:SetTexture("Interface\\Icons\\INV_Misc_QuestionMark") + frame.talentText:SetText("|cff808080No talent plan for this class yet|r") + end + frame.talentRow:Show() + y = y + 26 end - y = y + 26 - -- Gold / extras tip for this level. - local tips = ns.TipsForLevel(p.level or 1) - if #tips > 0 then - local t = tips[(math.floor(GetTime() / 60) % #tips) + 1] - frame.tip:ClearAllPoints(); frame.tip:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) - local ic = ns.KIND_ICONS[t.kind] or ns.KIND_ICONS.extra - frame.tip:SetText(("|T%s:14|t |cffffd100%s:|r %s"):format(ic, t.title or "", t.text or "")) - frame.tip:Show() - y = y + frame.tip:GetStringHeight() + 6 - else - frame.tip:Hide() + -- Gold / extras tip for this level (detailed). It changes with your level, not on a timer. + if detailed then + local tips = ns.TipsForLevel(p.level or 1) + if #tips > 0 then + local t = tips[((p.level or 1) % #tips) + 1] + frame.tip:ClearAllPoints(); frame.tip:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) + local ic = ns.KIND_ICONS[t.kind] or ns.KIND_ICONS.extra + frame.tip:SetText(("|T%s:14|t %s%s:|r %s"):format(ic, ns.C("cur"), t.title or "", t.text or "")) + frame.tip:Show() + y = y + frame.tip:GetStringHeight() + 6 + end end -- Next step preview. @@ -307,27 +512,104 @@ local function Refresh() for i = idx + 1, #ns.route do if not ns.StepState(ns.route[i]) and (ns.db.showOptional or not ns.route[i].optional) then nxt = ns.route[i]; break end end - frame.nextLine:ClearAllPoints(); frame.nextLine:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) - frame.nextLine:SetText(nxt and ("Next: " .. (nxt.title or "?") .. " (Lv " .. (nxt.min or "?") .. ")") or "") - y = y + (nxt and 16 or 0) + if nxt then + frame.nextLine:ClearAllPoints(); frame.nextLine:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) + frame.nextLine:SetText("Next: " .. (nxt.title or "?") .. " (Lv " .. (nxt.min or "?") .. ")") + frame.nextLine:Show() + y = y + 16 + end + -- Reminder: class quests or mounts left behind. + local open = ns.StillOpen() + if #open > 0 and frame.reminder then + local first = ns.route[open[1]] + frame.reminder.idx = open[1] + frame.reminder.text:SetText(ns.C("warn") .. "Still open:|r " .. (first.title or "?") + .. (#open > 1 and (" |cff808080+" .. (#open - 1) .. " more|r") or "")) + frame.reminder:ClearAllPoints(); frame.reminder:SetPoint("TOPLEFT", frame, "TOPLEFT", 12, -y) + frame.reminder:Show() + y = y + 18 + end + + for _, w in ipairs({ frame.prev, frame.nextB, frame.cur, frame.done, frame.skip, frame.wp }) do w:Show() end frame.done:SetText((ns.char.done[step.id] or ns.char.skip[step.id]) and "Undo" or "Done") - frame.skip:SetEnabled(not state) + frame.skip:SetEnabled(not state or state == "behind") + frame.cur:SetEnabled(idx ~= cur) frame.prev:SetEnabledState(idx > 1) frame.nextB:SetEnabledState(idx < #ns.route) - frame.wp:SetEnabledState(step.wp ~= nil) + frame.wp:SetEnabledState(step.wp ~= nil or hasPlan) frame:SetHeight(y + 40) end -ns.On("Login", function() Create(); Refresh() end) +--------------------------------------------------------------------------- +-- Context: instances, combat, mouseover +--------------------------------------------------------------------------- +local inCombat = false +local function ApplyContext() + if not frame then return end + local db = ns.db + local itype = IsInInstance and select(2, IsInInstance()) + local wasCompact = context.compact + context.hidden = db.instanceHide and (itype == "raid" or itype == "pvp" or itype == "arena") or false + context.compact = db.instanceHide and itype == "party" or false + if context.hidden and not context.override then frame:Hide() + elseif not ns.char.hidden and not frame:IsShown() then frame:Show(); Refresh() end + if wasCompact ~= context.compact then Refresh() end + local alpha = 1 + if inCombat and db.combatFade then alpha = 0.35 + elseif db.mouseoverFade and not (frame.IsMouseOver and frame:IsMouseOver()) then alpha = 0.4 end + frame:SetAlpha(alpha) +end + +local ctx = CreateFrame("Frame") +for _, e in ipairs({ "PLAYER_ENTERING_WORLD", "ZONE_CHANGED_NEW_AREA", "PLAYER_REGEN_DISABLED", "PLAYER_REGEN_ENABLED" }) do + pcall(ctx.RegisterEvent, ctx, e) +end +ctx:SetScript("OnEvent", function(_, e) + if e == "PLAYER_REGEN_DISABLED" then inCombat = true elseif e == "PLAYER_REGEN_ENABLED" then inCombat = false + else context.override = false end + if ns.db then ApplyContext() end +end) +-- Mouseover fade needs polling; only runs while that option is on. +local acc = 0 +ctx:SetScript("OnUpdate", function(_, elapsed) + acc = acc + elapsed + if acc < 0.2 then return end + acc = 0 + if frame and ns.db and ns.db.mouseoverFade and frame:IsShown() then ApplyContext() end +end) + +--------------------------------------------------------------------------- +-- Wiring +--------------------------------------------------------------------------- +ns.On("Login", function() Create(); Refresh(); ApplyContext() end) ns.On("Refresh", Refresh) ns.On("ToggleTracker", function(forceShow) if not frame then return end if frame:IsShown() and not forceShow then frame:Hide(); ns.char.hidden = true - else frame:Show(); ns.char.hidden = nil; ns.char.view = nil; Refresh() end + else + if context.hidden then context.override = true end + frame:Show(); ns.char.hidden = nil; ns.char.view = nil; Refresh() + end +end) +ns.On("ToggleCompact", function() + -- In a dungeon the tracker is compact by context; the first press expands it for this zone. + if context.compact then + if IsCompact() then ns.db.compact = false; context.override = true else context.override = false end + else + ns.db.compact = not ns.db.compact + end + if frame and not frame:IsShown() and not context.hidden then frame:Show(); ns.char.hidden = nil end + Refresh() end) ns.On("ResetPosition", function() if frame then ApplyPos() end end) ns.On("SettingsChanged", function() - if frame then frame:SetScale(ns.db.scale or 1); Refresh() end + if not frame then return end + frame:SetScale(ns.db.scale or 1) + UI.Style(frame, ns.db.bgAlpha) + UI.ApplyFontScale() + UI.Restyle() + Refresh() + ApplyContext() end) diff --git a/UI/Welcome.lua b/UI/Welcome.lua new file mode 100644 index 0000000..18044ac --- /dev/null +++ b/UI/Welcome.lua @@ -0,0 +1,144 @@ +-- Coffey's Leveling Guide welcome panel: shown once per character after the quest history has been +-- read. It says what the guide detected (character, build, progress already made), lets the player +-- pick a tracker layout and the automation they want, and gets out of the way. +local ADDON, ns = ... +local UI = ns.UI +local panel + +local function Line(parent, font) + local t = UI.Text(parent, font or "GameFontHighlight") + t:SetWidth(400) + return t +end + +local function Create() + panel = UI.Panel("CoffeyGuideWelcome", UIParent, 440, 420) + panel:SetPoint("CENTER", 0, 60) + panel:SetFrameStrata("DIALOG") + panel:SetClampedToScreen(true) + panel:SetMovable(true); panel:EnableMouse(true); panel:RegisterForDrag("LeftButton") + panel:SetScript("OnDragStart", panel.StartMoving) + panel:SetScript("OnDragStop", panel.StopMovingOrSizing) + panel:Hide() + tinsert(UISpecialFrames, "CoffeyGuideWelcome") + + UI.CloseButton(panel) + UI.FadeIn(panel, 12) + + panel.classIcon = panel:CreateTexture(nil, "ARTWORK") + panel.classIcon:SetSize(40, 40); panel.classIcon:SetPoint("TOPLEFT", 18, -18) + UI.IconBorder(panel.classIcon) + panel.head = UI.Text(panel, "GameFontNormalLarge") + panel.head:SetPoint("TOPLEFT", panel.classIcon, "TOPRIGHT", 10, -2) + panel.head:SetText("Welcome to Coffey's Leveling Guide") + panel.who = UI.Text(panel, "GameFontHighlight") + panel.who:SetPoint("TOPLEFT", panel.head, "BOTTOMLEFT", 0, -4) + + panel.found = Line(panel) + panel.found:SetPoint("TOPLEFT", 20, -72) + panel.found:SetSpacing(3) + + panel.layoutHead = UI.Section(panel, "Tracker layout") + panel.layout = UI.Segmented(panel, { + { label = "Compact", value = "compact", tip = "One line: the next thing to do, with a checkbox." }, + { label = "Standard", value = "standard", tip = "The step, your next few objectives and the step buttons." }, + { label = "Detailed", value = "detailed", tip = "Everything, including step notes, the quest checklist and level tips." }, + }, function() return ns.db.compact and "compact" or ns.db.density end, function(v) + if v == "compact" then ns.db.compact = true else ns.db.compact = false; ns.db.density = v end + ns.Fire("SettingsChanged") + end) + + panel.autoHead = UI.Section(panel, "Automation (all optional; hold Shift to bypass)") + panel.checks = {} + for i, o in ipairs({ + { "autoAccept", "Accept quests" }, { "autoTurnIn", "Turn in quests (no reward choice)" }, + { "sellGreys", "Sell gray items" }, { "autoRepair", "Repair at vendors" }, + }) do + local cb = UI.Check(panel, o[2], function() return ns.db[o[1]] end, function(v) ns.db[o[1]] = v; ns.Fire("SettingsChanged") end) + cb.label:SetFontObject(UI.Font("GameFontHighlightSmall")) + panel.checks[i] = cb + end + + panel.keys = Line(panel, "GameFontDisableSmall") + panel.keys:SetText("Tip: bind keys under Options > Keybindings > AddOns (check off the next objective, waypoint, compact). Everything else is in /cguide settings.") + + panel.go = UI.Button(panel, "Let's go", 100, function() + ns.char.welcomed = true; panel:Hide() + ns.Fire("ToggleTracker", true) + end, "primary") + panel.go:SetPoint("BOTTOMRIGHT", -16, 14) + panel.guide = UI.Button(panel, "Open the full guide", 150, function() + ns.char.welcomed = true; panel:Hide(); ns.Fire("OpenGuide", "route") + end) + panel.guide:SetPoint("RIGHT", panel.go, "LEFT", -6, 0) + panel.jump = UI.Button(panel, "Jump there", 100, function() + ns.char.welcomed = true; panel:Hide() + if panel.jumpIndex and ns.Detect then ns.Detect.JumpTo(panel.jumpIndex) end + end, "primary") + panel.jump:SetPoint("BOTTOMLEFT", 16, 14) + panel:SetScript("OnHide", function() ns.char.welcomed = true end) +end + +local function Fill() + local p = ns.player + UI.ClassIcon(panel.classIcon, p.class) + local build, auto = ns.GetActiveBuild() + panel.who:SetText(("Level %d %s %s%s|r |cff9a9a9a%s|r"):format(p.level or UnitLevel("player") or 1, p.raceName or "", + UI.AccentHex(), p.className or "", p.faction or "")) + + local sum = ns.Detect.Summary() + local lines = {} + if build then + lines[#lines + 1] = ("Talent plan: |cffffd100%s|r%s. Change it in the Talents & Spec tab."):format(build.name, auto and " (picked from your talents)" or "") + end + if sum.completed > 0 then + lines[#lines + 1] = ("Found %s%d|r completed quests in your history: %d of %d route steps are already done%s.") + :format(ns.C("good"), sum.completed, sum.done, sum.total, + sum.outleveled > 0 and (", " .. sum.outleveled .. " more you've outleveled") or "") + else + lines[#lines + 1] = ("A fresh start: %d route steps from here to 60."):format(sum.total) + end + if sum.behind > 0 then + lines[#lines + 1] = ("%s%d|r class quest or mount step(s) are still open from earlier levels; the tracker reminds you."):format(ns.C("warn"), sum.behind) + end + if sum.current then + lines[#lines + 1] = ("You're on: %s%s|r (%s)."):format(ns.C("cur"), sum.current.title or "?", ns.BandText(sum.current)) + end + if sum.suggestStep then + lines[#lines + 1] = sum.suggestReason .. " Jump to " .. ns.C("cur") .. (sum.suggestStep.title or "?") .. "|r? Earlier steps get marked skipped, and Undo puts them back." + panel.jumpIndex = sum.suggestIndex + panel.jump:Show() + else + panel.jumpIndex = nil + panel.jump:Hide() + end + panel.found:SetText(table.concat(lines, "\n")) + + -- Lay out below the detection text. + local y = 72 + panel.found:GetStringHeight() + 16 + panel.layoutHead:ClearAllPoints(); panel.layoutHead:SetPoint("TOPLEFT", 20, -y); y = y + 24 + panel.layout:ClearAllPoints(); panel.layout:SetPoint("TOPLEFT", 20, -y); panel.layout:Update(); y = y + 34 + panel.autoHead:ClearAllPoints(); panel.autoHead:SetPoint("TOPLEFT", 20, -y); y = y + 22 + for i, cb in ipairs(panel.checks) do + cb:ClearAllPoints(); cb:SetPoint("TOPLEFT", 18 + ((i - 1) % 2) * 200, -y) + cb:SetChecked(ns.db[({ "autoAccept", "autoTurnIn", "sellGreys", "autoRepair" })[i]] and true or false) + if i % 2 == 0 then y = y + 26 end + end + y = y + 8 + panel.keys:ClearAllPoints(); panel.keys:SetPoint("TOPLEFT", 20, -y) + y = y + panel.keys:GetStringHeight() + 50 + panel:SetHeight(y) +end + +local function Show(force) + if not panel then Create() end + if not force and ns.char.welcomed then return end + Fill() + panel:Show() +end + +ns.On("ShowWelcome", function(force) Show(force) end) +-- First time on each character: wait for the quest history, so the summary is right. +ns.On("HistoryReady", function() + if ns.char and not ns.char.welcomed and not (InCombatLockdown and InCombatLockdown()) then Show(false) end +end) diff --git a/UI/Widgets.lua b/UI/Widgets.lua index fea99f4..fe52653 100644 --- a/UI/Widgets.lua +++ b/UI/Widgets.lua @@ -4,15 +4,104 @@ local UI = {} ns.UI = UI local C = ns.COLORS +--------------------------------------------------------------------------- +-- Fonts: private copies of the stock fonts so the guide's text size can change +-- without touching anything else in the game UI. +--------------------------------------------------------------------------- +local fonts = {} +function UI.Font(base) + base = base or "GameFontHighlightSmall" + if type(base) ~= "string" then return base end + local f = fonts[base] + if f then return f.obj end + local src = _G[base] + if not CreateFont or not src or not src.GetFont then return base end + local obj = CreateFont("CoffeyGuide_" .. base) + obj:CopyFontObject(src) + local path, size, flags = src:GetFont() + fonts[base] = { obj = obj, path = path, size = size, flags = flags } + if path and size then obj:SetFont(path, size * ((ns.db and ns.db.fontScale) or 1), flags) end + return obj +end + +function UI.ApplyFontScale() + local scale = (ns.db and ns.db.fontScale) or 1 + for _, f in pairs(fonts) do + if f.path and f.size then f.obj:SetFont(f.path, f.size * scale, f.flags) end + end +end +--------------------------------------------------------------------------- +-- Theme: flat dark glass panels, hairline borders, a soft shadow and an accent +-- color (your class color, or gold). Everything is drawn from one white pixel +-- texture, so it looks the same on every client and scales cleanly. +--------------------------------------------------------------------------- +local FLAT = "Interface\\Buttons\\WHITE8x8" +UI.FLAT = FLAT + +function UI.Accent() + if ns.db and ns.db.accentGold then return 1, 0.78, 0.18 end + local cls = ns.player and ns.player.class + local c = cls and ((C_ClassColor and C_ClassColor.GetClassColor and C_ClassColor.GetClassColor(cls)) + or (RAID_CLASS_COLORS and RAID_CLASS_COLORS[cls])) + if c and c.r then return c.r, c.g, c.b end + return 1, 0.78, 0.18 +end + +function UI.AccentHex() + local r, g, b = UI.Accent() + return ("|cff%02x%02x%02x"):format(r * 255, g * 255, b * 255) +end + +function UI.Gradient(tex, orient, a, b) + if tex.SetGradient and CreateColor then + pcall(tex.SetGradient, tex, orient, CreateColor(a[1], a[2], a[3], a[4]), CreateColor(b[1], b[2], b[3], b[4])) + elseif tex.SetGradientAlpha then + pcall(tex.SetGradientAlpha, tex, orient, a[1], a[2], a[3], a[4], b[1], b[2], b[3], b[4]) + end +end + +-- Anything tinted with the accent registers here, so changing the accent repaints it. +local accented, painted = {}, {} +function UI.AccentTexture(tex, alpha) + tex.cgAlpha = alpha or 1 + local r, g, b = UI.Accent() + tex:SetColorTexture(r, g, b, tex.cgAlpha) + accented[#accented + 1] = tex + return tex +end + +function UI.Restyle() + local r, g, b = UI.Accent() + for _, t in ipairs(accented) do t:SetColorTexture(r, g, b, t.cgAlpha or 1) end + for _, w in ipairs(painted) do if w.Paint then w:Paint() end end +end + +local function Flat(f, bg, border) + f:SetBackdrop({ bgFile = FLAT, edgeFile = FLAT, edgeSize = 1, insets = { left = 1, right = 1, top = 1, bottom = 1 } }) + f:SetBackdropColor(bg[1], bg[2], bg[3], bg[4]) + f:SetBackdropBorderColor(border[1], border[2], border[3], border[4]) +end +UI.Flat = Flat + function UI.Style(f, alpha) - f:SetBackdrop({ - bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", - edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", - tile = true, tileSize = 16, edgeSize = 14, - insets = { left = 3, right = 3, top = 3, bottom = 3 }, - }) - f:SetBackdropColor(C.bg[1], C.bg[2], C.bg[3], alpha or C.bg[4]) - f:SetBackdropBorderColor(C.border[1], C.border[2], C.border[3], C.border[4]) + Flat(f, { 0.05, 0.055, 0.07, alpha or 0.92 }, { 1, 1, 1, 0.10 }) + if f.cgStyled then return end + f.cgStyled = true + -- Soft shadow just outside the edge. + local sh = CreateFrame("Frame", nil, f, "BackdropTemplate") + sh:SetPoint("TOPLEFT", -3, 3); sh:SetPoint("BOTTOMRIGHT", 3, -3) + sh:SetFrameLevel(math.max(0, (f:GetFrameLevel() or 1) - 1)) + sh:SetBackdrop({ edgeFile = FLAT, edgeSize = 3 }) + sh:SetBackdropBorderColor(0, 0, 0, 0.35) + -- A faint sheen across the top, and the accent stripe. + local sheen = f:CreateTexture(nil, "BORDER") + sheen:SetTexture(FLAT) + sheen:SetPoint("TOPLEFT", 1, -1); sheen:SetPoint("TOPRIGHT", -1, -1); sheen:SetHeight(70) + UI.Gradient(sheen, "VERTICAL", { 1, 1, 1, 0 }, { 1, 1, 1, 0.045 }) + local stripe = f:CreateTexture(nil, "ARTWORK") + stripe:SetPoint("TOPLEFT", 1, -1); stripe:SetPoint("TOPRIGHT", -1, -1); stripe:SetHeight(2) + UI.AccentTexture(stripe, 0.9) + f.cgStripe = stripe end function UI.Panel(name, parent, w, h) @@ -22,23 +111,71 @@ function UI.Panel(name, parent, w, h) return f end +-- Fade (and optionally slide) a frame in whenever it is shown. +function UI.FadeIn(f, slide) + if not f.CreateAnimationGroup then return end + local ag = f:CreateAnimationGroup() + local a = ag:CreateAnimation("Alpha") + a:SetFromAlpha(0); a:SetToAlpha(1); a:SetDuration(0.18) + if a.SetSmoothing then a:SetSmoothing("OUT") end + if slide then + local t = ag:CreateAnimation("Translation") + t:SetOffset(0, slide); t:SetDuration(0.01); t:SetOrder(1) + local t2 = ag:CreateAnimation("Translation") + t2:SetOffset(0, -slide); t2:SetDuration(0.22); t2:SetOrder(2) + if t2.SetSmoothing then t2:SetSmoothing("OUT") end + a:SetOrder(2) + end + f:HookScript("OnShow", function() ag:Stop(); ag:Play() end) + return ag +end + function UI.Text(parent, font, layer) - local fs = parent:CreateFontString(nil, layer or "OVERLAY", font or "GameFontHighlightSmall") + local fs = parent:CreateFontString(nil, layer or "OVERLAY") + fs:SetFontObject(UI.Font(font or "GameFontHighlightSmall")) fs:SetJustifyH("LEFT") fs:SetJustifyV("TOP") return fs end -function UI.Button(parent, text, width, onClick) - local b = CreateFrame("Button", nil, parent, "UIPanelButtonTemplate") +-- Flat button. kind = "primary" fills it with the accent color. +function UI.Button(parent, text, width, onClick, kind) + local b = CreateFrame("Button", nil, parent, "BackdropTemplate") b:SetSize(width, 22) + b.text = b:CreateFontString(nil, "OVERLAY") + b.text:SetFontObject(UI.Font("GameFontHighlightSmall")) + b.text:SetPoint("CENTER", 0, 0) + b:SetFontString(b.text) b:SetText(text) + if b.SetPushedTextOffset then b:SetPushedTextOffset(0, -1) end + b.kind = kind + function b:Paint() + local r, g, bl = UI.Accent() + if self.IsEnabled and not self:IsEnabled() then + Flat(self, { 1, 1, 1, 0.02 }, { 1, 1, 1, 0.06 }); self.text:SetTextColor(0.45, 0.45, 0.45); return + end + if self.kind == "primary" then + Flat(self, { r, g, bl, self.hover and 0.55 or 0.38 }, { r, g, bl, 0.95 }); self.text:SetTextColor(1, 1, 1) + elseif self.active then + Flat(self, { r, g, bl, self.hover and 0.32 or 0.22 }, { r, g, bl, 0.8 }); self.text:SetTextColor(1, 1, 1) + else + Flat(self, { 1, 1, 1, self.hover and 0.10 or 0.045 }, { 1, 1, 1, self.hover and 0.28 or 0.12 }) + self.text:SetTextColor(0.9, 0.9, 0.9) + end + end + function b:SetActive(on) self.active = on and true or nil; self:Paint() end + b:HookScript("OnEnter", function(self) self.hover = true; self:Paint() end) + b:HookScript("OnLeave", function(self) self.hover = nil; self:Paint() end) + b:HookScript("OnEnable", function(self) self:Paint() end) + b:HookScript("OnDisable", function(self) self:Paint() end) b:SetScript("OnClick", onClick) + b:Paint() + painted[#painted + 1] = b return b end function UI.Tooltip(owner, title, lines) - owner:SetScript("OnEnter", function(self) + owner:HookScript("OnEnter", function(self) GameTooltip:SetOwner(self, "ANCHOR_TOP") local t = type(title) == "function" and title() or title GameTooltip:AddLine(t or "", 1, 0.82, 0) @@ -47,9 +184,16 @@ function UI.Tooltip(owner, title, lines) elseif type(l) == "table" then for _, s in ipairs(l) do GameTooltip:AddLine(s, 1, 1, 1, true) end end GameTooltip:Show() end) - owner:SetScript("OnLeave", function() GameTooltip:Hide() end) + owner:HookScript("OnLeave", function() GameTooltip:Hide() end) end +local function Hover(b, alpha) + b:SetHighlightTexture(FLAT) + local h = b.GetHighlightTexture and b:GetHighlightTexture() + if h then h:SetVertexColor(1, 1, 1, alpha or 0.12) end +end +UI.Hover = Hover + function UI.IconButton(parent, size, texture, title, tip, onClick) local b = CreateFrame("Button", nil, parent) b:SetSize(size, size) @@ -57,8 +201,7 @@ function UI.IconButton(parent, size, texture, title, tip, onClick) b.icon:SetAllPoints() b.icon:SetTexture(texture) b.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) - b:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square", "ADD") - b:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress") + Hover(b) b:SetScript("OnClick", onClick) UI.Tooltip(b, title, tip) b.SetEnabledState = function(self, on) @@ -69,6 +212,59 @@ function UI.IconButton(parent, size, texture, title, tip, onClick) return b end +-- Crisp line-drawn glyph buttons: close, minus, plus, left, right. +local function Line(b, w, h, deg, x, y) + local t = b:CreateTexture(nil, "OVERLAY") + t:SetTexture(FLAT); t:SetSize(w, h); t:SetPoint("CENTER", x or 0, y or 0) + if deg ~= 0 and t.SetRotation then t:SetRotation(math.rad(deg)) end + b.lines[#b.lines + 1] = t + return t +end + +function UI.Glyph(parent, size, glyph, title, tip, onClick) + local b = CreateFrame("Button", nil, parent) + b:SetSize(size, size) + b.lines = {} + local l, w = size * 0.55, 1.5 + if glyph == "close" then Line(b, l, w, 45); Line(b, l, w, -45) + elseif glyph == "minus" then Line(b, l, w, 0) + elseif glyph == "plus" then Line(b, l, w, 0); Line(b, w, l, 0) + elseif glyph == "left" or glyph == "right" then + local arm, d = l * 0.62, l * 0.22 + local s = glyph == "left" and 1 or -1 + Line(b, arm, w, 45 * s, 0, d); Line(b, arm, w, -45 * s, 0, -d) + end + b.bg = b:CreateTexture(nil, "BACKGROUND"); b.bg:SetAllPoints(); b.bg:SetColorTexture(1, 1, 1, 0) + function b:Paint() + local on = not self.IsEnabled or self:IsEnabled() + local r, g, bl = UI.Accent() + for _, t in ipairs(self.lines) do + if not on then t:SetVertexColor(0.5, 0.5, 0.5, 0.35) + elseif self.hover then t:SetVertexColor(glyph == "close" and 1 or r, glyph == "close" and 0.35 or g, glyph == "close" and 0.3 or bl, 1) + else t:SetVertexColor(0.85, 0.85, 0.85, 0.9) end + end + self.bg:SetColorTexture(1, 1, 1, (on and self.hover) and 0.08 or 0) + end + b:HookScript("OnEnter", function(self) self.hover = true; self:Paint() end) + b:HookScript("OnLeave", function(self) self.hover = nil; self:Paint() end) + b:SetScript("OnClick", onClick) + if title then UI.Tooltip(b, title, tip) end + b.SetEnabledState = function(self, on) self:SetEnabled(on); self:Paint() end + b.SetGlyph = function(self, g2) + -- minus <-> plus: show or hide the vertical bar. + if self.lines[2] then self.lines[2]:SetShown(g2 == "plus") end + end + b:Paint() + painted[#painted + 1] = b + return b +end + +function UI.CloseButton(parent, onClick) + local b = UI.Glyph(parent, 20, "close", nil, nil, onClick or function() parent:Hide() end) + b:SetPoint("TOPRIGHT", -5, -5) + return b +end + function UI.Icon(parent, size, texture) local t = parent:CreateTexture(nil, "ARTWORK") t:SetSize(size, size) @@ -77,36 +273,176 @@ function UI.Icon(parent, size, texture) return t end +-- A 1px dark outline behind an icon texture (follows the icon wherever it is anchored). +function UI.IconBorder(icon) + local p = icon:GetParent() + local t = p:CreateTexture(nil, "BORDER") + t:SetColorTexture(0, 0, 0, 0.8) + t:SetPoint("TOPLEFT", icon, "TOPLEFT", -1, 1); t:SetPoint("BOTTOMRIGHT", icon, "BOTTOMRIGHT", 1, -1) + return t +end + function UI.ClassIcon(tex, class) tex:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles") local c = CLASS_ICON_TCOORDS and CLASS_ICON_TCOORDS[class] if c then tex:SetTexCoord(c[1], c[2], c[3], c[4]) end end +-- Progress bar: dark track, accent fill with a gentle gradient. function UI.Bar(parent, w, h) local bar = CreateFrame("StatusBar", nil, parent, "BackdropTemplate") bar:SetSize(w, h) - bar:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar") - bar:SetStatusBarColor(0.85, 0.65, 0.1) - bar:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background" }) - bar:SetBackdropColor(0, 0, 0, 0.6) - bar.text = bar:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall") + bar:SetStatusBarTexture(FLAT) + Flat(bar, { 0, 0, 0, 0.45 }, { 1, 1, 1, 0.08 }) + function bar:Paint() + local r, g, b = UI.Accent() + local t = self:GetStatusBarTexture() + if t then + t:SetVertexColor(1, 1, 1, 1) + UI.Gradient(t, "HORIZONTAL", { r * 0.55, g * 0.55, b * 0.55, 0.95 }, { r, g, b, 1 }) + else + self:SetStatusBarColor(r, g, b) + end + end + bar:Paint() + painted[#painted + 1] = bar + bar.text = bar:CreateFontString(nil, "OVERLAY") + bar.text:SetFontObject(UI.Font("GameFontHighlightSmall")) + bar.text:SetShadowOffset(1, -1) bar.text:SetPoint("CENTER") return bar end -function UI.Check(parent, label, get, set) - local cb = CreateFrame("CheckButton", nil, parent, "UICheckButtonTemplate") - cb:SetSize(24, 24) +-- Flat checkbox; the label is part of the click area. +function UI.Check(parent, label, get, set, tip) + local cb = CreateFrame("CheckButton", nil, parent, "BackdropTemplate") + cb:SetSize(16, 16) + local mark = cb:CreateTexture(nil, "ARTWORK") + mark:SetTexture("Interface\\Buttons\\UI-CheckBox-Check") + mark:SetSize(20, 20); mark:SetPoint("CENTER", 1, 0) + cb:SetCheckedTexture(mark) + function cb:Paint() + local r, g, b = UI.Accent() + mark:SetVertexColor(r, g, b) + Flat(self, { 0, 0, 0, 0.45 }, self.hover and { r, g, b, 0.9 } or { 1, 1, 1, 0.25 }) + end cb.label = UI.Text(cb, "GameFontHighlight") - cb.label:SetPoint("LEFT", cb, "RIGHT", 2, 0) + cb.label:SetPoint("LEFT", cb, "RIGHT", 7, 0) cb.label:SetText(label) + -- The label is part of the click area; settings pages call SetLabelWidth once the label's width is final. + function cb:SetLabelWidth(w) + self.label:SetWidth(w) + self:SetHitRectInsets(0, -math.min(w, (self.label:GetStringWidth() or w) + 8), -3, -3) + end + cb:SetHitRectInsets(0, -math.min(260, (cb.label:GetStringWidth() or 100) + 8), -3, -3) + cb:HookScript("OnEnter", function(self) self.hover = true; self:Paint() end) + cb:HookScript("OnLeave", function(self) self.hover = nil; self:Paint() end) cb:SetScript("OnShow", function(self) self:SetChecked(get()) end) cb:SetScript("OnClick", function(self) set(self:GetChecked() and true or false) end) cb:SetChecked(get()) + cb:Paint() + painted[#painted + 1] = cb + if tip then UI.Tooltip(cb, label, tip) end return cb end +-- Slider: a thin track with an accent thumb. +function UI.Slider(parent, label, width, minV, maxV, step, get, set, fmt) + local holder = CreateFrame("Frame", nil, parent) + holder:SetSize(width, 40) + holder.label = UI.Text(holder, "GameFontHighlightSmall") + holder.label:SetPoint("TOPLEFT", 2, 0) + local s = CreateFrame("Slider", nil, holder) + s:SetOrientation("HORIZONTAL") + s:EnableMouse(true) + s:SetSize(width - 10, 14) + s:SetPoint("TOPLEFT", holder.label, "BOTTOMLEFT", 0, -6) + local track = s:CreateTexture(nil, "BACKGROUND") + track:SetColorTexture(1, 1, 1, 0.14); track:SetHeight(3) + track:SetPoint("LEFT"); track:SetPoint("RIGHT") + local thumb = s:CreateTexture(nil, "OVERLAY") + thumb:SetSize(8, 14) + UI.AccentTexture(thumb, 1) + s:SetThumbTexture(thumb) + s:SetMinMaxValues(minV, maxV) + s:SetValueStep(step) + if s.SetObeyStepOnDrag then s:SetObeyStepOnDrag(true) end + local function show(v) holder.label:SetText(label .. ": |cffffffff" .. (fmt and fmt(v) or tostring(v)) .. "|r") end + s:SetScript("OnValueChanged", function(_, v, user) + v = math.floor(v / step + 0.5) * step + show(v) + if user ~= false then set(v) end + end) + holder:SetScript("OnShow", function() local v = get(); s:SetValue(v); show(v) end) + s:SetValue(get()); show(get()) + s:EnableMouseWheel(true) + s:SetScript("OnMouseWheel", function(self, d) + local v = math.max(minV, math.min(maxV, self:GetValue() + d * step)) + self:SetValue(v); set(v) + end) + holder.slider = s + return holder +end + +-- A section title in the accent color with a hairline under it, for settings pages. +function UI.Section(parent, title) + local t = UI.Text(parent, "GameFontNormal") + t:SetText(title) + local line = parent:CreateTexture(nil, "ARTWORK") + line:SetColorTexture(1, 1, 1, 0.10) + line:SetHeight(1) + line:SetPoint("TOPLEFT", t, "BOTTOMLEFT", 0, -4) + line:SetPoint("RIGHT", parent, "RIGHT", -8, 0) + local tick = parent:CreateTexture(nil, "OVERLAY") + tick:SetHeight(1); tick:SetWidth(28) + tick:SetPoint("TOPLEFT", t, "BOTTOMLEFT", 0, -4) + UI.AccentTexture(tick, 1) + return t +end + +-- Segmented control: one flat button per option, the active one filled with the accent. +function UI.Segmented(parent, options, get, set) + local holder = CreateFrame("Frame", nil, parent) + holder.buttons = {} + local x = 0 + for i, opt in ipairs(options) do + local b = UI.Button(holder, opt.label, 70, function() set(opt.value); holder:Update() end) + b:SetWidth(math.max(70, b.text:GetStringWidth() + 26)) + b:SetPoint("LEFT", holder, "LEFT", x, 0) + x = x + b:GetWidth() - 1 + if opt.tip then UI.Tooltip(b, opt.label, opt.tip) end + holder.buttons[i] = b + end + holder:SetSize(math.max(x, 10), 22) + function holder:Update() + local cur = get() + for i, opt in ipairs(options) do self.buttons[i]:SetActive(opt.value == cur) end + end + holder:SetScript("OnShow", function(self) self:Update() end) + holder:Update() + return holder +end + +-- Slim scrollbar: no arrow buttons, a thin track and a soft thumb. +function UI.SkinScroll(scroll) + pcall(function() + local sb = scroll.ScrollBar or (scroll:GetName() and _G[scroll:GetName() .. "ScrollBar"]) + if not sb then return end + for _, key in ipairs({ "ScrollUpButton", "ScrollDownButton" }) do + local btn = sb[key] or (sb:GetName() and _G[sb:GetName() .. key]) + if btn then btn:SetAlpha(0); btn:EnableMouse(false); btn:SetSize(1, 1) end + end + sb:ClearAllPoints() + sb:SetPoint("TOPLEFT", scroll, "TOPRIGHT", 10, 0) + sb:SetPoint("BOTTOMLEFT", scroll, "BOTTOMRIGHT", 10, 0) + sb:SetWidth(6) + local track = sb:CreateTexture(nil, "BACKGROUND") + track:SetAllPoints(); track:SetColorTexture(1, 1, 1, 0.05) + local thumb = sb.ThumbTexture or (sb.GetThumbTexture and sb:GetThumbTexture()) + if thumb then thumb:SetTexture(FLAT); thumb:SetVertexColor(1, 1, 1, 0.28); thumb:SetSize(6, 40) end + end) +end + -- Status icons drawn from stock textures. UI.STATUS = { done = "Interface\\RaidFrame\\ReadyCheck-Ready", @@ -125,19 +461,30 @@ function UI.ScrollList(parent) content:SetSize(10, 10) scroll:SetScrollChild(content) scroll:SetScript("OnSizeChanged", function(self, w) content:SetWidth(w) end) + UI.SkinScroll(scroll) - local list = { scroll = scroll, content = content, rows = {}, used = 0, y = 0 } + local list = { scroll = scroll, content = content, rows = {}, used = 0, y = 0, marks = {} } local function NewRow() local r = CreateFrame("Button", nil, content) - r:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight", "ADD") + Hover(r) r.bg = r:CreateTexture(nil, "BACKGROUND") r.bg:SetAllPoints() + r.bar = r:CreateTexture(nil, "BORDER") + r.bar:SetPoint("TOPLEFT"); r.bar:SetPoint("BOTTOMLEFT"); r.bar:SetWidth(2) r.status = r:CreateTexture(nil, "ARTWORK") r.status:SetSize(16, 16) r.icon = UI.Icon(r, 26) r.icon2 = UI.Icon(r, 18) r.title = UI.Text(r, "GameFontNormal") + r.check = CreateFrame("Button", nil, r) + r.check:SetSize(18, 18) + Hover(r.check) + r.check:SetScript("OnClick", function(self) if self.fn then self.fn() end end) + r.check:SetScript("OnEnter", function(self) + GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); GameTooltip:AddLine(self.tip or "Mark done / not done"); GameTooltip:Show() + end) + r.check:SetScript("OnLeave", function() GameTooltip:Hide() end) r.sub = UI.Text(r, "GameFontHighlightSmall") r.right = UI.Text(r, "GameFontHighlightSmall") r.right:SetJustifyH("RIGHT") @@ -148,9 +495,42 @@ function UI.ScrollList(parent) function list:Clear() for i = 1, self.used do self.rows[i]:Hide() end self.used, self.y = 0, 0 + self.pendingHeader, self.matches = nil, 0 + wipe(self.marks) + end + + -- Filter rows by a search string (headers show only above a matching row). + function list:SetFilter(text) + text = text and text:lower():gsub("^%s+", ""):gsub("%s+$", "") or "" + self.filter = text ~= "" and text or nil + end + + local function Plain(s) return ((s or ""):gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""):gsub("|T.-|t", ""):lower()) end + + -- Remember where a row lands, so the view can scroll to it after Done(). + function list:Mark(key) self.marks[key] = self.y end + + function list:ScrollToMark(key, offset) + local y = self.marks[key] + if not y then return end + local max = self.scroll.GetVerticalScrollRange and self.scroll:GetVerticalScrollRange() or 0 + self.scroll:SetVerticalScroll(math.max(0, math.min(max, y - (offset or 40)))) end function list:Add(o) + if self.filter then + if o.header then self.pendingHeader = o; return end + if not o.always then + local hay = Plain(o.title) .. " " .. Plain(o.sub) .. " " .. Plain(o.search) + if not hay:find(self.filter, 1, true) then return end + end + self.matches = self.matches + 1 + if self.pendingHeader then local h = self.pendingHeader; self.pendingHeader = nil; self:Place(h) end + end + return self:Place(o) + end + + function list:Place(o) self.used = self.used + 1 local r = self.rows[self.used] if not r then r = NewRow(); self.rows[self.used] = r end @@ -161,12 +541,16 @@ function UI.ScrollList(parent) local x = 4 if o.header then - r.status:Hide(); r.icon:Hide(); r.icon2:Hide(); r.sub:SetText(""); r.right:SetText("") - r.title:SetFontObject("GameFontNormalLarge") + r.status:Hide(); r.icon:Hide(); r.icon2:Hide(); r.check:Hide(); r.sub:SetText(""); r.right:SetText("") + r.title:SetFontObject(UI.Font("GameFontNormalLarge")) + r.title:SetAlpha(1); r.sub:SetAlpha(1) r.title:ClearAllPoints(); r.title:SetPoint("TOPLEFT", r, "TOPLEFT", 4, -8) r.title:SetWidth(width - 8) r.title:SetText(o.title or "") - r.bg:SetColorTexture(0.5, 0.4, 0.1, 0.25) + local ar, ag, ab = UI.Accent() + r.bg:SetTexture(FLAT); r.bg:SetVertexColor(1, 1, 1, 1) + UI.Gradient(r.bg, "HORIZONTAL", { ar, ag, ab, 0.16 }, { ar, ag, ab, 0 }) + r.bar:SetColorTexture(ar, ag, ab, 0.9); r.bar:Show() local h = 30 r:SetHeight(h); self.y = self.y + h + 2 r:SetScript("OnClick", nil); r:SetScript("OnEnter", nil) @@ -174,9 +558,19 @@ function UI.ScrollList(parent) return r end - r.title:SetFontObject(o.titleFont or "GameFontNormal") - if o.status then r.status:Show(); r.status:SetTexture(o.status); r.status:SetPoint("TOPLEFT", r, "TOPLEFT", x, -6); x = x + 20 - else r.status:Hide() end + r.title:SetFontObject(UI.Font(o.titleFont or "GameFontNormal")) + -- A status icon with onCheck becomes a real checkbox: click it to toggle. + if o.status and o.onCheck then + r.status:Show(); r.status:SetTexture(o.status) + r.status:ClearAllPoints(); r.status:SetPoint("TOPLEFT", r, "TOPLEFT", x, -6) + r.check:Show(); r.check:ClearAllPoints(); r.check:SetPoint("CENTER", r.status, "CENTER") + r.check.fn, r.check.tip = o.onCheck, o.checkTip + x = x + 20 + elseif o.status then + r.check:Hide() + r.status:Show(); r.status:SetTexture(o.status) + r.status:ClearAllPoints(); r.status:SetPoint("TOPLEFT", r, "TOPLEFT", x, -6); x = x + 20 + else r.status:Hide(); r.check:Hide() end if o.icon then r.icon:Show(); r.icon:SetTexture(o.icon) if o.iconCoords then r.icon:SetTexCoord(unpack(o.iconCoords)) else r.icon:SetTexCoord(0.08, 0.92, 0.08, 0.92) end @@ -199,9 +593,11 @@ function UI.ScrollList(parent) local alpha = o.dim and 0.55 or 1 r.title:SetAlpha(alpha); r.sub:SetAlpha(alpha) - if o.highlight then r.bg:SetColorTexture(1, 0.82, 0, 0.12) - elseif self.used % 2 == 0 then r.bg:SetColorTexture(1, 1, 1, 0.03) - else r.bg:SetColorTexture(0, 0, 0, 0) end + local ar, ag, ab = UI.Accent() + if r.bg.SetGradient and CreateColor then UI.Gradient(r.bg, "HORIZONTAL", { 1, 1, 1, 1 }, { 1, 1, 1, 1 }) end + if o.highlight then r.bg:SetColorTexture(ar, ag, ab, 0.13); r.bar:SetColorTexture(ar, ag, ab, 0.9); r.bar:Show() + elseif self.used % 2 == 0 then r.bg:SetColorTexture(1, 1, 1, 0.025); r.bar:Hide() + else r.bg:SetColorTexture(0, 0, 0, 0); r.bar:Hide() end local h = 8 + r.title:GetStringHeight() + ((o.sub and o.sub ~= "") and (r.sub:GetStringHeight() + 2) or 0) h = math.max(h, o.icon and 32 or 22) @@ -214,6 +610,9 @@ function UI.ScrollList(parent) end function list:Done() + if self.filter and self.matches == 0 then + self:Place({ title = "|cff808080No matches for \"" .. self.filter .. "\".|r", sub = "Clear the search box to see everything." }) + end content:SetHeight(math.max(self.y, 10)) end @@ -239,8 +638,7 @@ function ns.ShowLink(url) eb:SetScript("OnEnterPressed", function() linkBox:Hide() end) eb:SetScript("OnTextChanged", function(self) self:SetText(linkBox.url or ""); self:HighlightText() end) linkBox.eb = eb - local close = CreateFrame("Button", nil, linkBox, "UIPanelCloseButton") - close:SetPoint("TOPRIGHT", 2, 2) + UI.CloseButton(linkBox) end linkBox.url = url linkBox:Show() diff --git a/Waypoints.lua b/Waypoints.lua index 71e6369..fdd2d74 100644 --- a/Waypoints.lua +++ b/Waypoints.lua @@ -186,7 +186,16 @@ ns.On("Refresh", function() if target and target.id ~= lastStepID then W.Set(target, false) end end) +ns.On("ResetPosition", function() + ns.db.arrowPos = nil + if arrow then arrow:ClearAllPoints(); arrow:SetPoint("TOP", UIParent, "TOP", 0, -120) end +end) + ns.On("SetWaypoints", function(step, announce) W.Set(step, announce) end) +ns.On("WaypointCurrent", function(announce) + local target = CurrentTarget() + if target then W.Set(target, announce ~= false) end +end) ns.On("SettingsChanged", function() local step = ns.route[ns.ViewIndex()] W.Set(step, false) diff --git a/tools/harness.lua b/tools/harness.lua index deca7b7..594f541 100644 --- a/tools/harness.lua +++ b/tools/harness.lua @@ -45,6 +45,7 @@ UIParent = mock("UIParent") GameTooltip = mock("GameTooltip") DEFAULT_CHAT_FRAME = { AddMessage = function(_, m) print("CHAT", (m:gsub("|c%x%x%x%x%x%x%x%x", ""):gsub("|r", ""))) end } UISpecialFrames = {} +StaticPopupDialogs = {} tinsert = table.insert function wipe(t) for k in pairs(t) do t[k] = nil end return t end function geterrorhandler() return function(e) error(e, 0) end end @@ -289,4 +290,67 @@ if sp and ns.PlanFor(sp) then end SlashCmdList.COFFEYGUIDE("quests") ns.ShowLink(ns.WEBSITE); print("website:", ns.WEBSITE) + +-- Progress detection: quests from a later step in the log, standing in its zone. +SlashCmdList.COFFEYGUIDE("reset") +completed = {}; ns.completed = {}; wipe(ns.completedNames); questLog = {} +fire("QUEST_LOG_UPDATE") +local cur0 = ns.CurrentIndex() +local target +for i = cur0 + 2, math.min(#ns.route, cur0 + 12) do + local st = ns.route[i] + local plan = ns.PlanFor(st) + if st.kind == "zone" and not st.optional and plan and #plan >= 6 and (st.min or 1) <= P.level + 2 + and not ns.StepState(st) then target = i; break end +end +if target then + local st = ns.route[target] + local seen, log = {}, {} + for _, s in ipairs(ns.PlanFor(st)) do + if s.quest and s.quest[2] and not seen[s.quest[2]] and #log < 3 then seen[s.quest[2]] = true; log[#log + 1] = { s.quest[1], s.quest[2] } end + end + questLog = log; fire("QUEST_LOG_UPDATE") + C_Map = { GetBestMapForUnit = function() return st.map end, GetMapInfo = function() return nil end } + ns.Detect.Invalidate() + local i, sst, reason = ns.Detect.Suggestion() + print("detect: current", cur0, "target", target, "suggested", i, reason) + assert(i == target, "suggestion should point at the step whose quests are in the log") + ns.Fire("Refresh") -- tracker renders the banner + ns.Detect.JumpTo(i) + print("detect: after jump current", ns.CurrentIndex(), "skipped", #ns.char.lastJump.ids) + assert(ns.CurrentIndex() == target, "jump should land on the target") + ns.Fire("Refresh") + ns.Detect.UndoJump() + print("detect: after undo current", ns.CurrentIndex()) + assert(ns.CurrentIndex() == cur0, "undo should restore the original current step") + -- Missed: the first quest of the plan untouched, three later quests in the log. + local plan = ns.PlanFor(st) + local firstKey, firstName, nLater = nil, nil, 0 + questLog = {} + local inLog = {} + for _, s in ipairs(plan) do + if s.quest and s.quest[2] then + if not firstKey then firstKey, firstName = s.quest[2], s.quest[1] + elseif s.quest[2] ~= firstKey and s.quest[1] ~= firstName and not inLog[s.quest[2]] and nLater < 3 then + inLog[s.quest[2]] = true; nLater = nLater + 1 + questLog[#questLog + 1] = { s.quest[1], s.quest[2] } + end + end + end + fire("QUEST_LOG_UPDATE") + local _, first, _, missed = ns.PlanProgress(st) + local firstIdx; for k, s in ipairs(plan) do if s.quest and s.quest[2] == firstKey then firstIdx = k; break end end + print("detect: first quest at", firstIdx, "missed:", missed[firstIdx] and "yes" or "no", "cursor at", first, "passed by", ns.MissedCount(missed)) + assert(missed[firstIdx], "an untouched quest before three active ones should count as passed by") + ns.Fire("Refresh") + ns.db.compact = true; ns.Fire("Refresh"); ns.db.density = "detailed"; ns.db.compact = false; ns.Fire("Refresh") + ns.Fire("ShowWelcome", true) + C_Map = nil +else + print("detect: no later zone step with a plan for this character; skipped") +end +CoffeyGuide_Binding("check"); CoffeyGuide_Binding("compact"); CoffeyGuide_Binding("waypoint") +ns.db.colorblind = true; ns.db.accentGold = true; ns.Fire("SettingsChanged") +SlashCmdList.COFFEYGUIDE("settings"); g_search = _G.CoffeyGuideSearch +if g_search then g_search._text = "a"; SlashCmdList.COFFEYGUIDE("guide") end print("HARNESS_OK") -- 2.54.0