RynthSuite as of 2026-11-29 (internal 46bae49): release 2026.11.28.1

This commit is contained in:
Tom Bohar 2026-11-29 00:38:53 -05:00
commit 598f49c899
131 changed files with 11825 additions and 329 deletions

View file

@ -0,0 +1,640 @@
// The Guide tab (2026-11-27): wiki quests with their steps. The list on the left with where each quest stands, the
// opened quest on the right: its timer, where it starts (Go), its steps with their coordinates (Go) and the stamps each
// gives (ticked when held), its loot and rewards. Lists: All / Story / Dailies / Weekly, Kill Tasks, Society, Contracts.
// The quests come from the active server plugin's own guide ("RynthServer.QuestGuide") and the AC Community Wiki feed
// (off until the player turns it on). The layout follows SilentKelpie's Guide (Forgejo rynth PR #12); re-implemented
// here, without "Run this quest" (IGuideQuestRunner is the seam for it).
using System;
using System.Collections.Generic;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.RynthOracle.Ui;
using RynthCore.Plugin.Shared;
namespace RynthCore.Plugin.RynthOracle.Views;
/// <summary>The Guide tab's lists.</summary>
internal enum GuideList { All, Story, Dailies, Weekly, KillTasks, Society, Contracts }
internal sealed partial class OracleView
{
private static readonly string[] GuideListNames = { "All", "Story", "Dailies", "Weekly", "Kill Tasks", "Society", "Contracts" };
private const int GuidePageSize = 40;
private const float GuideListWidth = 310f;
private const int GuideMaxSteps = 40;
private const int ColText = 0; // ImGuiCol_Text
private GuideList _gList;
private string _gSearch = "";
private int _gPage;
private string _gSel = "";
private string _gMsg = "";
private GuideSet? _gSet;
private string _gSetKey = "";
private readonly List<GuideRow> _gRows = new();
private string _gRowsKey = "";
private Dictionary<string, Quest> _catalogByName = new(StringComparer.OrdinalIgnoreCase);
private int _catalogByNameRev = -1;
private sealed class GuideRow
{
public string Key = "";
public string Label = "";
public string Status = "";
public string Tip = "";
public uint Color = UiColors.Grey;
/// <summary>"Hide done" leaves it out (done, with nothing to do now).</summary>
public bool Hide;
public string Tag = "";
public string TagTip = "";
public uint TagColor = UiColors.Grey;
public int Order;
public GuideQuest? Q;
public QuestFlag? Flag;
public GuideContract? C;
}
/// <summary>Shows the Guide tab on a list (and a row). Internal for /ro and the tests.</summary>
internal void ShowGuide(GuideList list, string? select = null)
{
_gList = list;
_gPage = 0;
if (select != null) _gSel = select;
Tab = TabGuide;
}
/// <summary>The Kill Tasks list is on screen (kill lines then ask for a fresh /myquests).</summary>
public bool KillTasksShowing => Tab == TabGuide && _gList == GuideList.KillTasks;
/// <summary>The guides in use, merged (rebuilt when either changes). Internal for the tests.</summary>
internal GuideSet GuideSources()
{
string key = $"{_c.ServerGuide.Revision}|{_c.Wiki.Revision}";
if (_gSet == null || key != _gSetKey)
{
_gSetKey = key;
_gSet = new GuideSet(_c.ServerGuide.Guide, _c.Wiki.Guide);
}
return _gSet;
}
/// <summary>The quest list's flag for a quest of this name: done or not; null when the list has no quest of that name.</summary>
private bool? CatalogDone(string title)
{
if (_catalogByNameRev != _c.Catalog.Revision)
{
var map = new Dictionary<string, Quest>(StringComparer.OrdinalIgnoreCase);
foreach (Quest q in _c.Catalog.Quests)
if (!q.IsNew && q.Name.Length > 0) map.TryAdd(q.Name, q);
_catalogByName = map;
_catalogByNameRev = _c.Catalog.Revision;
}
return _catalogByName.TryGetValue(title, out Quest? found) ? found.IsComplete(_c.Flags) : null;
}
private static uint StateColor(GuideState s) => s switch
{
GuideState.Done => UiColors.Green,
GuideState.PartWaiting => UiColors.Yellow,
GuideState.PartReady => UiColors.Gold,
_ => UiColors.Grey,
};
private static uint KillColor(KillState s) => s switch
{
KillState.TurnIn => UiColors.Gold,
KillState.Counting or KillState.Waiting => UiColors.Yellow,
KillState.Ready or KillState.Completed => UiColors.Green,
_ => UiColors.Grey,
};
// ── The page ────────────────────────────────────────────────────────────
private void DrawGuide(UiWindow w)
{
GuideSet set = GuideSources();
DrawGuideSources(w, set);
if (set.IsEmpty)
{
w.Spacing();
w.TextWrapped("No quest guide yet. The AC Community Wiki feed gives one on every server once you turn it on;"
+ " a server plugin can also hand RynthOracle its own server's guide.");
DrawWikiFeedControls(w, "g", full: false);
return;
}
for (int i = 0; i < GuideListNames.Length; i++)
{
var list = (GuideList)i;
if (i > 0) w.SameLine();
w.ToggleButton(GuideListNames[i], "g.list." + i, _gList == list, () => { _gList = list; _gPage = 0; }, small: true);
}
w.Checkbox("Hide done", "g.hide", _c.Settings.GuideHideDone, v => { _c.Settings.GuideHideDone = v; _c.Settings.Save(); _gPage = 0; });
w.Tooltip("Leave out the quests that are done with nothing to do now: one-time quests done, and quests whose timer is running.");
w.SameLine();
w.InputText("Search", "g.search", _gSearch, 64, s => { _gSearch = s; _gPage = 0; });
w.Tooltip("Words to find: a quest's name, who and where it starts, its items or stamps.");
if (_gMsg.Length > 0) w.TextDisabled(_gMsg);
if (_gList == GuideList.KillTasks) DrawKillSummary(w, set);
List<GuideRow> rows = GuideRows(set);
w.BeginChild("g.rows", GuideListWidth, 0f, border: true);
if (rows.Count > GuidePageSize) _gPage = Pager(w, "g.page", _gPage, rows.Count, GuidePageSize, p => _gPage = p);
else _gPage = 0;
bool tags = rows.Exists(r => r.Tag.Length > 0);
float statusX = GuideListWidth - 112f, tagX = statusX - 40f;
float labelEnd = tags ? tagX : statusX;
int chars = Math.Max(16, (int)((labelEnd - 14f) / 6.4f));
int start = _gPage * GuidePageSize;
for (int i = start; i < rows.Count && i < start + GuidePageSize; i++)
{
GuideRow r = rows[i];
string key = r.Key;
w.Selectable(Cut(r.Label, chars), "g.r." + key, key == _gSel, () => _gSel = key, labelEnd - 12f);
if (r.Label.Length > chars) w.Tooltip(r.Label);
if (r.Tag.Length > 0)
{
w.SameLine(tagX);
w.TextColored(r.TagColor, r.Tag);
w.Tooltip(r.TagTip);
}
if (r.Status.Length > 0)
{
w.SameLine(statusX);
w.TextColored(r.Color, r.Status);
if (r.Tip.Length > 0) w.Tooltip(r.Tip);
}
}
if (rows.Count == 0) w.TextDisabled("Nothing here matches.");
w.EndChild();
w.SameLine();
w.BeginChild("g.detail", 0f, 0f, border: true);
GuideRow? sel = rows.Find(r => r.Key == _gSel) ?? FindGuideRow(set, _gSel);
if (sel == null) w.TextDisabled("Pick a quest on the left.");
else if (sel.Q != null) DrawGuideQuest(w, set, sel.Q);
else if (sel.Flag != null) DrawKillFlag(w, sel.Flag);
else if (sel.C != null) DrawGuideContract(w, set, sel.C);
w.EndChild();
}
/// <summary>One line per source: the server plugin's guide (with its own commands) and the AC Community Wiki feed.</summary>
private void DrawGuideSources(UiWindow w, GuideSet set)
{
ServerQuestGuideClient sg = _c.ServerGuide;
if (sg.Available)
{
ServerQuestGuideInfo info = sg.Info!;
w.TextDisabled(Cut($"{sg.Tag} Wiki ({info.Plugin}): {(info.Running ? "reading... " : "")}{sg.Guide.Quests.Count} quests. {info.Status}", 90));
w.Tooltip($"{sg.Tag}'s own quests, from its server plugin; they come first, over the AC Community Wiki's of the same name.");
if (info.Takes(RynthServerQuestGuide.CommandRefresh))
{
w.SameLine();
w.SmallButton("Read it again", "g.sg.refresh", () => _gMsg = sg.Command(RynthServerQuestGuide.CommandRefresh)
? $"Asked {info.Plugin} to read {sg.Tag}'s guide again." : $"{info.Plugin} didn't take the request.");
}
if (info.Takes(RynthServerQuestGuide.CommandSettings))
{
w.SameLine();
w.SmallButton("Its settings", "g.sg.settings", () => _gMsg = sg.Command(RynthServerQuestGuide.CommandSettings)
? $"{info.Plugin}'s guide settings are open." : $"{info.Plugin} didn't take the request.");
}
}
CommunityWikiFeed feed = _c.Wiki;
string line = _c.Settings.WikiFeedOn
? "AC Community Wiki: " + (feed.Running ? "reading... " : "") + feed.Status
: feed.Guide.IsEmpty ? "AC Community Wiki feed: off (nothing is fetched)." : "AC Community Wiki feed: off; the copy saved earlier: " + feed.Status;
w.TextDisabled(Cut(line, 100));
if (!set.IsEmpty && w.CollapsingHeader("AC Community Wiki feed", "g.feed"))
DrawWikiFeedControls(w, "g", full: false);
}
// ── Rows ────────────────────────────────────────────────────────────────
private static bool Matches(string hay, string[] terms)
{
foreach (string t in terms)
if (hay.IndexOf(t, StringComparison.OrdinalIgnoreCase) < 0) return false;
return true;
}
private static string Hay(GuideQuest q) =>
$"{q.Title} {q.StartsWith} {q.StartsAt} {q.Type} {string.Join(" ", q.Loot)} {string.Join(" ", q.AllStamps())}";
private GuideRow GuideQuestRow(GuideQuest q)
{
GuideProgress.Row p = _c.Progress.RowOf(q, _c.UtcNow, CatalogDone(q.Title));
return new GuideRow { Key = "w:" + q.Title, Label = q.Title, Q = q, Status = p.Status, Tip = p.Tip, Color = StateColor(p.State), Hide = p.HideWhenDone };
}
private GuideRow? FindGuideRow(GuideSet set, string key)
{
if (key.StartsWith("w:", StringComparison.Ordinal) && set.Find(key.Substring(2)) is GuideQuest q) return GuideQuestRow(q);
if (key.StartsWith("c:", StringComparison.Ordinal) && set.Contracts.Find(x => x.Title == key.Substring(2)) is GuideContract c) return ContractRow(set, c);
if (key.StartsWith("k:", StringComparison.Ordinal) && _c.Flags.TryGet(key.Substring(2), out QuestFlag f))
return new GuideRow { Key = key, Label = KillFlagLabel(f), Flag = f };
return null;
}
/// <summary>The rows of the list shown (rebuilt when anything they show changes, or each minute for the timers). Internal for the tests.</summary>
private List<GuideRow> GuideRows(GuideSet set)
{
string key = $"{_gList}|{_gSearch}|{_c.Settings.GuideHideDone}|{_gSetKey}|{_c.Flags.Revision}|{_c.SessionStampRevision}|{_c.Kills.Revision}|{_c.Catalog.Revision}|{_c.UtcNow:yyyyMMddHHmm}";
if (key == _gRowsKey) return _gRows;
_gRowsKey = key;
_gRows.Clear();
string[] terms = _gSearch.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
bool hide = _c.Settings.GuideHideDone;
switch (_gList)
{
case GuideList.KillTasks: KillRows(set, terms, hide); break;
case GuideList.Society: SocietyRows(set, terms, hide); break;
case GuideList.Contracts: ContractRows(set, terms, hide); break;
default:
foreach (GuideQuest q in set.Quests)
{
bool inList = _gList switch
{
GuideList.Story => q.IsOneTime,
GuideList.Dailies => q.IsDaily,
GuideList.Weekly => q.IsWeekly,
_ => true,
};
if (!inList || !Matches(Hay(q), terms)) continue;
GuideRow r = GuideQuestRow(q);
if (hide && r.Hide) continue;
_gRows.Add(r);
}
break;
}
return _gRows;
}
private void KillRows(GuideSet set, string[] terms, bool hide)
{
var named = new HashSet<string>(StringComparer.Ordinal);
foreach (GuideQuest q in set.Quests)
{
if (!set.IsKillTask(q)) continue;
GuideProgress.Kill p = _c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title));
if (p.Counter != null) named.Add(GuideStamp.Key(p.Counter.Key));
foreach (string st in q.AllStamps()) named.Add(GuideStamp.Key(st));
if (!Matches(Hay(q), terms)) continue;
bool done = p.State is KillState.Waiting or KillState.Completed;
if (hide && done) continue;
var r = new GuideRow { Key = "w:" + q.Title, Label = q.Title, Q = q, Status = p.Status, Color = KillColor(p.State), Order = (int)p.State };
SetKillTag(r, p.DoneBefore);
_gRows.Add(r);
}
// Counters the server keeps that no guide's kill task names: listed too, so nothing counted is left out.
foreach (QuestFlag f in _c.Flags.Flags.Values)
{
if (!QuestTimer.IsKillTask(f) || named.Contains(GuideStamp.Key(f.Key)) || !Matches(f.Key + " " + f.Description, terms)) continue;
QuestTimerState st = QuestTimer.State(f, true, _c.UtcNow, out string text);
KillState ks = st switch
{
QuestTimerState.InProgress => KillState.Counting,
QuestTimerState.Waiting => KillState.Waiting,
QuestTimerState.Done => KillState.Completed,
_ => KillState.Ready,
};
if (hide && ks is KillState.Waiting or KillState.Completed) continue;
var r = new GuideRow
{
Key = "k:" + f.Key, Label = KillFlagLabel(f), Flag = f, Color = KillColor(ks), Order = (int)ks,
Status = ks switch { KillState.Counting => $"{f.Solves} / {f.MaxSolves}", KillState.Waiting => "Done " + text, KillState.Completed => "Completed", _ => "Ready" },
};
SetKillTag(r, ks != KillState.Counting);
_gRows.Add(r);
}
_gRows.Sort((a, b) => a.Order != b.Order ? a.Order.CompareTo(b.Order) : string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
}
/// <summary>A counter flag's row: the server's description of it, else the flag split into words.</summary>
private static string KillFlagLabel(QuestFlag f) => f.Description.Length > 1 ? f.Description : GuideProgress.FlagLabel(f.Key);
private static void SetKillTag(GuideRow r, bool doneBefore)
{
(r.Tag, r.TagTip) = GuideProgress.KillTag(doneBefore);
r.TagColor = doneBefore ? UiColors.Green : UiColors.Gold;
}
private void SocietyRows(GuideSet set, string[] terms, bool hide)
{
foreach (GuideQuest q in set.Quests)
{
string rank = set.SocietyRankOf(q);
if (rank.Length == 0 || !Matches(rank + " " + Hay(q), terms)) continue;
GuideRow r = GuideQuestRow(q);
if (hide && r.Hide) continue;
r.Label = rank + ": " + q.Title;
r.Order = GuideSet.RankOrder(rank);
_gRows.Add(r);
}
_gRows.Sort((a, b) => a.Order != b.Order ? a.Order.CompareTo(b.Order) : string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
}
private GuideRow ContractRow(GuideSet set, GuideContract c)
{
var r = new GuideRow { Key = "c:" + c.Title, Label = c.Name, C = c };
// The state of the quest it is for (the first one a guide has).
foreach (string t in c.Quests)
if (set.Find(t) is GuideQuest q)
{
GuideRow qr = GuideQuestRow(q);
r.Status = qr.Status;
r.Tip = q.Title + ": " + qr.Tip;
r.Color = qr.Color;
r.Hide = qr.Hide;
return r;
}
if (c.Level.Length > 0) r.Status = "L" + c.Level;
return r;
}
private void ContractRows(GuideSet set, string[] terms, bool hide)
{
foreach (GuideContract c in set.Contracts)
{
if (!Matches($"{c.Name} {c.Description} {c.Where} {string.Join(" ", c.Quests)}", terms)) continue;
GuideRow r = ContractRow(set, c);
if (hide && r.Hide) continue;
_gRows.Add(r);
}
_gRows.Sort((a, b) => string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase));
}
// ── The opened quest ────────────────────────────────────────────────────
private void DrawGuideQuest(UiWindow w, GuideSet set, GuideQuest q)
{
GuideProgress p = _c.Progress;
DateTime now = _c.UtcNow;
w.TextColored(UiColors.Gold, q.Title);
TimeSpan wait = p.Wait(q, now);
w.TextDisabled(GuideProgress.RepeatText(q) + (wait > TimeSpan.Zero ? " - again in " + GuideProgress.Short(wait) : ""));
GuideProgress.Row row = p.RowOf(q, now, CatalogDone(q.Title));
w.TextColored(StateColor(row.State), row.Tip);
var facts = new List<string>();
if (q.Level.Length > 0) facts.Add("Level " + q.Level);
if (q.RecommendedLevel.Length > 0) facts.Add("rec. " + q.RecommendedLevel);
if (q.Type.Length > 0) facts.Add(q.Type);
if (q.TimeToComplete.Length > 0) facts.Add(q.TimeToComplete);
if (set.SocietyRankOf(q) is { Length: > 0 } rank) facts.Add("Society: " + rank);
if (facts.Count > 0) w.TextDisabled(string.Join(" | ", facts));
if (set.IsKillTask(q)) DrawKillLine(w, q);
// Running a quest along its steps comes later; the seam draws nothing until a runner is set.
if (_c.GuideRunner is IGuideQuestRunner runner) DrawRunControls(w, runner, q);
if (q.Url.Length > 0)
{
w.SmallButton("Wiki page", "g.url", () => _c.Print(q.Url));
w.Tooltip("Prints the page's address in chat: " + q.Url);
w.SameLine();
}
w.TextDisabled(set.FromServer(q) ? $"From {_c.ServerGuide.Tag}'s guide" : "From the AC Community Wiki");
if (q.StartsWith.Length > 0 || q.StartsAt.Length > 0)
{
w.Text("Starts" + (q.StartsWith.Length > 0 ? " with " + q.StartsWith : "") + (q.StartsAt.Length > 0 ? " at " + q.StartsAt : ""));
string place = q.StartsAt.Length > 0 ? q.StartsAt : q.StartsWith;
w.SameLine();
w.SmallButton("Go", "g.start.go", () => _gMsg = SendRynthNav("go", new[] { place }));
w.Tooltip("RynthNav goes to " + place + " (a place on its Atlas), walking and taking portals.");
}
if (q.Overview.Length > 0) w.TextWrapped(q.Overview);
DrawStampSummary(w, q);
(bool[] done, bool[] passed, int next) = StepStates(q);
w.SeparatorText(q.Steps.Count > 0 ? "Steps" : "Steps (the page has no walkthrough)");
int current = _c.GuideRunner?.Running == q ? _c.GuideRunner.Step : -1;
for (int i = 0; i < q.Steps.Count && i < GuideMaxSteps; i++) DrawGuideStep(w, q, i, done[i], passed[i], i == next, i == current);
if (q.Steps.Count > GuideMaxSteps) w.TextDisabled($"... {q.Steps.Count - GuideMaxSteps} more steps on the wiki page.");
if (q.ExtraStamps.Count > 0)
{
w.TextDisabled("Also stamps (the page doesn't say which step):");
foreach (string st in q.ExtraStamps) StampLine(w, q, st);
}
if (q.Loot.Count > 0)
{
w.SeparatorText("Loot");
w.TextWrapped(string.Join(", ", q.Loot));
}
if (q.Rewards.Count > 0 && w.CollapsingHeader("Rewards", "g.rewards"))
foreach (string r in q.Rewards)
if (r.EndsWith(':')) w.Text(r); else w.BulletText(r);
}
private void DrawRunControls(UiWindow w, IGuideQuestRunner runner, GuideQuest q)
{
if (runner.Running == q)
{
w.Button("Stop", "g.run.stop", runner.Stop);
w.SameLine();
}
else
{
w.Button("Run this quest", "g.run", () => _gMsg = runner.Start(q, 0));
w.SameLine();
}
}
/// <summary>Each step done (its stamps count now), passed (no stamp of its own, and a later step is done), and the next to do (-1: none).</summary>
private (bool[] Done, bool[] Passed, int Next) StepStates(GuideQuest q)
{
int n = q.Steps.Count, last = -1;
var done = new bool[n];
var passed = new bool[n];
for (int i = 0; i < n; i++)
{
GuideStep s = q.Steps[i];
done[i] = s.Stamps.Count > 0 && s.Stamps.TrueForAll(st => _c.Progress.StateOf(q, st, _c.UtcNow) == StampState.Done);
if (done[i]) last = i;
}
for (int i = 0; i < last; i++)
if (!done[i] && q.Steps[i].Stamps.Count == 0) passed[i] = true;
int next = -1;
for (int i = 0; i < n; i++)
if (!done[i] && !passed[i]) { next = i; break; }
return (done, passed, next);
}
/// <summary>How many stamps count now, and each one still to get with its step.</summary>
private void DrawStampSummary(UiWindow w, GuideQuest q)
{
List<string> all = q.AllStamps();
if (all.Count == 0)
{
w.TextDisabled("The page lists no stamps for this quest, so its steps can't be ticked: they are a guide only.");
return;
}
var stepOf = new Dictionary<string, int>(StringComparer.Ordinal);
for (int i = 0; i < q.Steps.Count; i++)
foreach (string st in q.Steps[i].Stamps) stepOf.TryAdd(GuideStamp.Key(st), i + 1);
int now = 0;
var missing = new List<(string Text, bool Earlier)>();
foreach (string st in all)
{
StampState s = _c.Progress.StateOf(q, st, _c.UtcNow);
if (s == StampState.Done) { now++; continue; }
string where = stepOf.TryGetValue(GuideStamp.Key(st), out int n) ? "step " + n : "no step";
missing.Add(($"{st} ({where}{(s == StampState.Earlier ? ", done on an earlier run: ready again" : "")})", s == StampState.Earlier));
}
string run = q.RepeatSec != 0 ? " this run" : "";
if (missing.Count == 0) { w.TextColored(UiColors.Green, $"All {all.Count} stamps done{run}."); return; }
w.TextColored(now > 0 ? UiColors.Yellow : UiColors.Grey, $"{now} of {all.Count} stamps done{run}. Still to get:");
for (int i = 0; i < missing.Count && i < 12; i++) w.TextColored(missing[i].Earlier ? UiColors.Yellow : UiColors.Red, " - " + missing[i].Text);
if (missing.Count > 12) w.TextDisabled($" ... and {missing.Count - 12} more.");
if (_c.Flags.LastReadUtc == DateTime.MinValue) w.TextDisabled("Your quest flags haven't been read yet: press Refresh.");
}
private void DrawGuideStep(UiWindow w, GuideQuest q, int i, bool done, bool passed, bool isNext, bool isCurrent)
{
GuideStep s = q.Steps[i];
// [x] done, [~] passed (no stamp of its own; a later step is done), [>] the next to do, [ ] still to do.
string mark = done ? "[x]" : passed ? "[~]" : isNext ? "[>]" : "[ ]";
uint color = isCurrent || isNext ? UiColors.Yellow : done ? UiColors.Green : passed ? UiColors.Grey : 0;
if (color != 0) w.PushStyleColor(ColText, color);
w.TextWrapped($"{mark} {i + 1}. {s.Text}");
if (color != 0) w.PopStyleColor();
if (passed) w.Tooltip("No stamp of its own; a step after it is done, so the quest went past it.");
else if (isNext) w.Tooltip("The next step to do.");
for (int k = 0; k < s.Coords.Count && k < 4; k++)
{
string c = s.Coords[k];
if (k > 0) w.SameLine();
w.SmallButton("Go " + c, $"g.s{i}.c{k}", () => _gMsg = SendRynthNav("go", new[] { c }));
w.Tooltip("RynthNav plans the way to " + c + " and walks it.");
}
for (int k = 0; k < s.Notes.Count && k < 4; k++)
{
w.PushStyleColor(ColText, UiColors.Grey);
w.TextWrapped(" " + s.Notes[k]);
w.PopStyleColor();
}
foreach (string st in s.Stamps) StampLine(w, q, st);
}
private void StampLine(UiWindow w, GuideQuest q, string stamp)
{
switch (_c.Progress.StateOf(q, stamp, _c.UtcNow))
{
case StampState.Done: w.TextColored(UiColors.Green, " [x] stamped " + stamp); break;
case StampState.Earlier: w.TextColored(UiColors.Yellow, " [ ] " + stamp + " - done on an earlier run; ready again"); break;
default: w.TextColored(UiColors.Red, " [ ] " + stamp + " - not stamped yet"); break;
}
w.Tooltip(StampWhy(stamp));
}
/// <summary>Why a stamp reads the way it does: the flag it matched and its times, or that none did.</summary>
private string StampWhy(string stamp)
{
if (_c.Progress.StampedThisSession(stamp)) return "Stamped this session (the server said so in chat).";
if (_c.Progress.FlagOf(stamp) is QuestFlag f)
{
string when = f.CompletedOnUtc == DateTime.MinValue ? "" : $", last {f.CompletedOnUtc.ToLocalTime():yyyy-MM-dd HH:mm}";
string timer = f.RepeatTime <= TimeSpan.Zero ? ""
: f.NextAvailableTime(_c.UtcNow) > TimeSpan.Zero ? "; again in " + GuideProgress.Short(f.NextAvailableTime(_c.UtcNow)) : "; its timer is up";
return $"Your quest flag '{f.Key}': {f.Solves} solve(s){when}{timer}.";
}
return _c.Flags.LastReadUtc == DateTime.MinValue
? "Your quest flags haven't been read yet (Refresh)."
: $"No quest flag named like '{stamp}' in your /myquests ({_c.Flags.Flags.Count} flags, read {_c.Flags.LastReadUtc.ToLocalTime():HH:mm}).";
}
// ── Kill tasks ──────────────────────────────────────────────────────────
private void DrawKillSummary(UiWindow w, GuideSet set)
{
int counting = 0, turnIn = 0, ready = 0;
foreach (GuideQuest q in set.Quests)
{
if (!set.IsKillTask(q)) continue;
switch (_c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title)).State)
{
case KillState.Counting: counting++; break;
case KillState.TurnIn: turnIn++; break;
case KillState.Ready: ready++; break;
}
}
string read = _c.Flags.LastReadUtc == DateTime.MinValue ? "not read yet" : "read " + GuideProgress.Short(_c.UtcNow - _c.Flags.LastReadUtc) + " ago";
w.TextDisabled($"Kill tasks: {counting} counting, {turnIn} to turn in, {ready} ready | /myquests {read}");
w.Tooltip("The kills come from your quest flags (/myquests): each task's counter. A kill line in chat moves the count at once,\n"
+ "and with this list open the flags are read again after kills (at most once a minute, the server's limit).");
}
private void DrawKillLine(UiWindow w, GuideQuest q)
{
GuideProgress.Kill p = _c.Progress.KillOf(q, _c.UtcNow, CatalogDone(q.Title));
string goal = p.Goal > 0 ? p.Goal.ToString(System.Globalization.CultureInfo.InvariantCulture) : "?";
string count = p.Counter != null || p.FromChat
? $"Kills: {p.Kills} / {goal}" + (p.Goal > p.Kills ? $" ({p.Goal - p.Kills} left)" : "")
: p.Goal > 0 ? $"Kills: not started (the task is {p.Goal} kills)" : "Kills: not started";
w.TextColored(KillColor(p.State), count + " - " + p.Status);
w.SameLine();
w.TextColored(p.DoneBefore ? UiColors.Green : UiColors.Gold, p.DoneBefore ? "(done before)" : "(first time)");
w.TextDisabled(p.FromChat ? "From the last kill line in chat."
: p.Counter != null ? $"From /myquests: {p.Counter.Key} ({p.Counter.Solves} of {p.Counter.MaxSolves})."
: "No counter flag in /myquests yet" + (q.StartsWith.Length > 0 ? $" (talk to {q.StartsWith} to start it)." : "."));
}
/// <summary>A kill counter only /myquests knows.</summary>
private void DrawKillFlag(UiWindow w, QuestFlag f)
{
w.TextColored(UiColors.Gold, KillFlagLabel(f));
QuestTimerState st = QuestTimer.State(f, true, _c.UtcNow, out string text);
w.Text($"Kills: {f.Solves} / {f.MaxSolves}" + (f.Solves < f.MaxSolves ? $" ({f.MaxSolves - f.Solves} left)" : ""));
w.TextDisabled("State: " + (st == QuestTimerState.Waiting ? "again in " + text : text));
if (f.Description.Length > 0) w.TextWrapped(f.Description);
w.TextDisabled("Flag " + f.Key + ": no guide's kill task names this counter.");
}
// ── Contracts ───────────────────────────────────────────────────────────
private void DrawGuideContract(UiWindow w, GuideSet set, GuideContract c)
{
w.TextColored(UiColors.Gold, c.Name);
if (c.Level.Length > 0) w.TextDisabled("Recommended level " + c.Level);
if (c.Description.Length > 0) w.TextWrapped(c.Description);
if (c.Where.Length > 0) w.TextWrapped("Where: " + c.Where);
if (c.Npc.Length > 0)
{
w.SmallButton("Go to " + Cut(c.Npc, 28), "g.c.go", () => _gMsg = SendRynthNav("go", new[] { c.Npc }));
w.Tooltip("RynthNav goes to " + c.Npc + ".");
}
if (c.Quests.Count > 0)
{
w.SeparatorText(c.Quests.Count == 1 ? "The quest it is for" : "The quests it is for");
for (int i = 0; i < c.Quests.Count && i < 10; i++)
{
string t = c.Quests[i];
if (set.Find(t) is not GuideQuest q) { w.TextDisabled(" " + t + " (no page in the guide)"); continue; }
GuideRow qr = GuideQuestRow(q);
w.SmallButton("Open", "g.c.q." + i, () => ShowGuide(GuideList.All, "w:" + q.Title));
w.Tooltip("Opens the quest in the All list: its steps and where it stands.");
w.SameLine();
w.Text(q.Title);
w.SameLine();
w.TextColored(qr.Color, qr.Status);
}
}
if (c.Url.Length > 0)
{
w.SmallButton("Wiki page", "g.c.url", () => _c.Print(c.Url));
w.Tooltip("Prints the page's address in chat: " + c.Url);
}
}
// ── Refresh ─────────────────────────────────────────────────────────────
/// <summary>The Guide's Refresh: /myquests, the server plugin's guide (when it takes "refresh") and the wiki feed (when on).</summary>
private RefreshResult RefreshGuide()
{
string more = "";
if (_c.ServerGuide.Available && _c.ServerGuide.Info!.Takes(RynthServerQuestGuide.CommandRefresh)
&& _c.ServerGuide.Command(RynthServerQuestGuide.CommandRefresh))
more += $" Asked {_c.ServerGuide.Info.Plugin} to read {_c.ServerGuide.Tag}'s guide again.";
if (_c.Settings.WikiFeedOn && !_c.Wiki.Running && _c.Wiki.Start(on: true)) more += " Reading the AC Community Wiki (only pages edited since).";
RefreshResult r = RefreshQuests();
return r with { What = r.What + more };
}
}