RynthSuite/Plugins/RynthCore.Plugin.RynthOracle/Views/OracleView.cs
BlankenshipG 7797901d69 feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the
2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only
changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays
0.5.0-legacy-ui on sk.

Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into
the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level,
RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist,
RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
2026-10-18 16:22:40 -04:00

206 lines
8.4 KiB
C#

using System;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.RynthOracle.Ui;
namespace RynthCore.Plugin.RynthOracle.Views;
/// <summary>
/// The main RynthOracle window: a row of tabs and the selected tab's page. Each tab is a
/// partial of this class (Views\*Tab.cs). Recorded on the pump thread, replayed by the engine.
/// </summary>
internal sealed partial class OracleView
{
public const string TabQuests = "Quests", TabCharacter = "Character",
TabSkills = "Skills", TabAttributes = "Attributes", TabProgress = "Progress",
TabAugs = "Augs", TabSociety = "Society",
TabTitles = "Titles", TabVoid = "Void", TabFellowship = "Fellowship",
TabBoards = "Leaderboards", TabConquest = "Conquest", TabBreeding = "Pet Breeding",
TabAbout = "About";
// The Markers, Legendary and Dynamic Stamps tabs (and RynthILT's Temple guardians) are rows of
// the Quests tab since 2026-10-18 (QuestsTab.cs, ShowTrackers); a saved tab name of theirs falls
// back to Quests.
/// <summary>A tab: shown where any of its server tags matches the server; no tags = everywhere (retail).</summary>
private sealed record TabDef(string Name, string[] Servers, Action<UiWindow> Draw, bool LiveTimers);
private readonly OracleContext _c;
private readonly TabDef[] _tabs;
/// <summary>Last SkillsFace embed tab signalled to the engine (-2 = never).</summary>
private int _lastSkillsEmbed = -2;
/// <summary>Asks the plugin to show or hide the Void window (the Void tab's button).</summary>
public Action<bool>? SetVoidWindow;
public Func<bool>? VoidWindowVisible;
public OracleView(OracleContext c)
{
_c = c;
string[] any = Array.Empty<string>();
_tabs = new TabDef[]
{
new(TabQuests, any, DrawQuests, true),
new(TabCharacter, any, DrawCharacter, true),
// Skills / Attributes / Progress: engine SkillsFace body embedded by ScriptWindowFace.
new(TabSkills, any, DrawSkillsEmbed, true),
new(TabAttributes, any, DrawAttributesEmbed, true),
new(TabProgress, any, DrawProgressEmbed, true),
new(TabAugs, any, DrawAugs, true),
new(TabSociety, any, DrawSociety, true),
new(TabTitles, any, DrawTitles, false),
new(TabVoid, any, DrawVoid, true),
new(TabFellowship, any, DrawFellowship, false),
// Server-specific: each parser and its commands only exist on its own server.
new(TabBoards, new[] { Data.ServerTags.Conquest, Data.ServerTags.Aelrynth }, DrawBoards, false),
new(TabConquest, new[] { Data.ServerTags.Conquest }, DrawConquest, true),
new(TabBreeding, new[] { Data.ServerTags.InfiniteLeaftide }, DrawBreeding, false),
new(TabAbout, any, DrawAbout, false),
};
}
private bool Visible(TabDef t)
{
if (t.Servers.Length == 0) return true;
foreach (string s in t.Servers) if (_c.Server.Is(s)) return true;
return false;
}
/// <summary>The selected tab's name; a tab not available on this server falls back to Quests.</summary>
public string Tab
{
get
{
foreach (TabDef t in _tabs)
if (t.Name == _c.Settings.TabName && Visible(t)) return t.Name;
return TabQuests;
}
set
{
_c.Settings.TabName = value;
_c.Settings.Save();
}
}
/// <summary>Tabs whose content changes by the second (timers), so the window re-records often.</summary>
public bool TabHasLiveTimers
{
get
{
string tab = Tab;
foreach (TabDef t in _tabs) if (t.Name == tab) return t.LiveTimers;
return false;
}
}
/// <summary>For tests: the names of the tabs this server shows.</summary>
internal string[] VisibleTabs() => Array.ConvertAll(Array.FindAll(_tabs, Visible), t => t.Name);
public void Draw(UiWindow w)
{
string tab = Tab;
bool first = true;
TabDef? current = null;
foreach (TabDef t in _tabs)
{
if (!Visible(t)) continue;
if (!first) w.SameLine();
first = false;
string name = t.Name;
w.ToggleButton(name, "tab." + name, tab == name, () => Tab = name, small: true);
if (tab == name) current = t;
}
w.Separator();
// Keep the engine SkillsFace embed in sync with the selected Oracle tab.
int embed = tab switch
{
TabSkills => 0,
TabAttributes => 1,
TabProgress => 2,
_ => -1,
};
if (embed != _lastSkillsEmbed)
{
_lastSkillsEmbed = embed;
_c.SkillsEmbedChanged(embed);
}
if (!_c.InWorld && tab != TabAbout)
{
w.TextDisabled("Log in to a character to see this page.");
return;
}
// Skills-family tabs: leave the body empty so ScriptWindowFace can paint SkillsFace
// into the remaining content region after the script tab strip.
if (embed >= 0)
{
(current?.Draw ?? DrawSkillsEmbed)(w);
return;
}
w.BeginChild("page." + tab, 0f, 0f, border: false);
(current?.Draw ?? DrawAbout)(w);
w.EndChild();
}
// ── Shared helpers ──────────────────────────────────────────────────────
/// <summary>"Done" in green or "--" in grey, the status column most lists start with.</summary>
private static void DoneMark(UiWindow w, bool done) =>
w.TextColored(done ? UiColors.Green : UiColors.Grey, done ? "done" : "--");
private static string Cut(string s, int max) => s.Length <= max ? s : s.Substring(0, Math.Max(0, max - 3)) + "...";
/// <summary>"Label value" with the value at a fixed column.</summary>
private static void Field(UiWindow w, string label, string value, float x, float valueX)
{
if (x > 0f) w.SameLine(x);
w.TextDisabled(label);
w.SameLine(valueX);
w.Text(value);
}
/// <summary>Prints a quest's name, status, notes and wiki link in chat (upstream "thinks" them).</summary>
private void PrintEntry(string name, string flag, string status, string details, string url)
{
_c.Print(flag.Length > 0 ? $"{name} ({flag}){(status.Length > 0 ? " - " + status : "")}" : name);
if (details.Length > 0) _c.Print(details);
if (url.Length > 0) _c.Print(url);
}
/// <summary>
/// The quest trackers' refresh row (Society, Augs, Conquest):
/// a small Refresh (the same /myquests read as the Quests tab's) and how fresh the flags are,
/// or why they can't be read. <paramref name="what"/> names what the flags show ("stamps").
/// </summary>
private void QuestFlagsBar(UiWindow w, string id, string what)
{
QuestFlagStore flags = _c.Flags;
w.SmallButton("Refresh", id + ".refresh", _c.RequestQuests);
w.Tooltip("Reads your quest flags again (/myquests), as the Quests tab's Refresh does.");
w.SameLine();
int wait = flags.ThrottleSecondsLeft(_c.NowMs);
if (flags.ServerDisabled)
w.TextColored(UiColors.Red, "This server has /myquests turned off, so " + what + " can't be read.");
else if (flags.Loading)
w.TextColored(UiColors.Yellow, "Reading your quest flags...");
else if (flags.LastReadUtc == DateTime.MinValue)
w.TextDisabled("Quest flags not read yet: Refresh to see your " + what + ".");
else
w.TextDisabled($"Flags read at {flags.LastReadUtc.ToLocalTime():HH:mm}" + (wait > 0 ? $" (Refresh again in {wait}s)" : ""));
}
/// <summary>Previous / page n of m / next, with the page kept in range.</summary>
private static int Pager(UiWindow w, string id, int page, int count, int pageSize, Action<int> setPage)
{
int pages = Math.Max(1, (count + pageSize - 1) / pageSize);
page = Math.Clamp(page, 0, pages - 1);
int p = page;
w.SmallButton("<", id + ".prev", () => setPage(Math.Max(0, p - 1)));
w.SameLine();
w.Text($"Page {page + 1} of {pages}");
w.SameLine();
w.SmallButton(">", id + ".next", () => setPage(Math.Min(pages - 1, p + 1)));
return page;
}
}