Snapshot for release 2026.10.19.1 (internal f0bdcf8)

This commit is contained in:
Tom Bohar 2026-10-19 09:11:22 -04:00
commit 39de36d3af
131 changed files with 11266 additions and 520 deletions

View file

@ -0,0 +1,41 @@
// Ported from Oracle of Dereth by Advis Eveldan (advis61), MIT. See THIRD_PARTY_NOTICES.md.
using System;
using System.Collections.Generic;
namespace RynthCore.Plugin.RynthOracle.Data;
/// <summary>
/// The lines a click on a quest prints in chat. Upstream's quest list "thinks" them to the player:
/// the quest's info and hint text ("{flag}: {details}", or "{flag}: No hint available"), its wiki
/// link ("{flag}: No url available" when there is none), and the flag's own history
/// ("{flag}: {description} CompletedOn:... Solves:... MaxSolves:... RepeatTime:...", or
/// "{flag}: Never completed"). The texts come from the quest list's Info and Hint columns.
/// </summary>
internal static class QuestText
{
public static List<string> Lines(Quest q, QuestFlagStore flags, QuestBook book, DateTime utcNow)
{
string flag = q.Flag;
var lines = new List<string>();
string status = q.IsComplete(flags) ? q.Status(flags, utcNow) : "not done";
string name = q.IsNew ? (q.Name.Length > 0 ? q.Name : "Not in the quest list") : q.DisplayName;
lines.Add($"{name} ({flag}) - {status}");
string details = q.Details();
lines.Add(details.Length > 0 ? $"{flag}: {details}" : $"{flag}: No hint available");
lines.Add(q.Url.Length > 0 ? $"{flag}: {q.Url}" : $"{flag}: No url available");
lines.Add(History(flag, flags));
if (book.TryGetReward(flag, out QuestReward r)) lines.Add("Rewards: " + r.LongSummary());
return lines;
}
/// <summary>Upstream's QuestFlag.ToString(), or "Never completed" for a flag the character doesn't hold.</summary>
public static string History(string flag, QuestFlagStore flags)
{
if (!flags.TryGet(flag, out QuestFlag f)) return $"{flag}: Never completed";
string done = f.CompletedOnUtc == DateTime.MinValue ? "never" : f.CompletedOnUtc.ToLocalTime().ToString("yyyy-MM-dd HH:mm");
return $"{f.Key}: {f.Description} CompletedOn:{done} Solves:{f.Solves} MaxSolves:{f.MaxSolves} RepeatTime:{TimeText.Friendly(f.RepeatTime)}";
}
}

View file

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
namespace RynthCore.Plugin.RynthOracle.Data;
/// <summary>
/// Notices when a quest timer comes up. It remembers which watched quests were on cooldown and
/// reports each one once, the moment its timer runs out. A quest that is simply ready when first
/// seen (the login read) is not reported: only the step from waiting to ready is.
/// </summary>
internal sealed class QuestTimerWatcher
{
private readonly HashSet<string> _waiting = new(StringComparer.OrdinalIgnoreCase);
private readonly HashSet<string> _seen = new(StringComparer.OrdinalIgnoreCase);
private readonly List<Quest> _ready = new();
/// <summary>Forget everything (logout, or a different character).</summary>
public void Reset() => _waiting.Clear();
/// <summary>
/// Checks the watched quests and returns those whose timers came up since the last check (the
/// list is reused: read it before the next call). <paramref name="watch"/> is the flags to
/// watch, or null for every quest the character holds.
/// </summary>
public IReadOnlyList<Quest> Check(QuestFlagStore flags, QuestCatalog catalog, IEnumerable<string>? watch, DateTime utcNow)
{
_ready.Clear();
if (flags.LastReadUtc == DateTime.MinValue) return _ready;
_seen.Clear();
foreach (string flag in watch ?? flags.Flags.Keys)
{
_seen.Add(flag);
Quest q = catalog.TryGet(flag, out Quest known) ? known : new Quest { Flag = flag, IsNew = true };
if (!flags.TryGet(flag, out _)) { _waiting.Remove(flag); continue; }
QuestTimerState state = QuestTimer.State(q, flags, utcNow, out _);
if (state == QuestTimerState.Waiting) _waiting.Add(flag);
else if (state == QuestTimerState.Ready && _waiting.Remove(flag)) _ready.Add(q);
else _waiting.Remove(flag); // in progress, or done for good
}
_waiting.RemoveWhere(k => !_seen.Contains(k)); // no longer watched
return _ready;
}
}

View file

@ -12,6 +12,7 @@ internal sealed class OracleContext
public readonly OracleSettings Settings = new();
public readonly QuestFlagStore Flags = new();
public readonly QuestCatalog Catalog = new();
public readonly QuestTimerWatcher Timers = new();
public readonly QuestCatalogUpdater Updater = new();
/// <summary>This character's tracked quests and recorded rewards (loaded once the name is known).</summary>
public readonly QuestBook Book = new();
@ -42,8 +43,20 @@ internal sealed class OracleContext
/// <summary>The last thing the quest list check said, shown on the About tab.</summary>
public string UpdaterMessage = "";
/// <summary>Set by the plugin: sends /myquests (reply hidden when the setting says so).</summary>
public Action RequestQuests = () => { };
/// <summary>Set by the plugin: sends /myquests (reply hidden when the setting says so). False when nothing was sent (not in world, or one went out moments ago).</summary>
public Func<bool> RequestQuests = () => false;
/// <summary>Set by the plugin (the Refresh buttons): re-reads the character's stats and buffs, and RynthAi's session, at once.</summary>
public Action RereadCharacter = () => { };
/// <summary>Set by the plugin: re-reads the titles the engine holds for the character.</summary>
public Action RereadTitles = () => { };
/// <summary>Set by the plugin: reloads the quest list and server pack from their files and re-asks RynthCore which server this is.</summary>
public Action ReloadQuestList = () => { };
/// <summary>Where <see cref="Print"/> goes instead of the chat window (the offline tests).</summary>
public Action<string>? PrintSink = null;
/// <summary>Set by the plugin: sends a chat command to the server as if typed (the views' buttons).</summary>
public Func<string, bool> Send = _ => false;
@ -61,7 +74,14 @@ internal sealed class OracleContext
/// <summary>A line in the player's chat window only (nothing is sent to the server).</summary>
public void Print(string text)
{
if (PrintSink != null) { PrintSink(text); return; }
if (!Host.WriteToChat("[RynthOracle] " + text, 1))
Host.Log("[RynthOracle] " + text);
}
/// <summary>A click on a quest: its info and hint text, link and flag history in chat (upstream "thinks" them).</summary>
public void PrintQuest(Quest q)
{
foreach (string line in QuestText.Lines(q, Flags, Book, UtcNow)) Print(line);
}
}

View file

@ -29,6 +29,10 @@ internal sealed class OracleSettings
public string TabName = "Quests";
/// <summary>ConquestAC: "/bank deposit" at every ten-minute mark (upstream's auto-deposit; off by default).</summary>
public bool ConquestAutoDeposit;
/// <summary>Say so in chat when a tracked quest's timer comes up.</summary>
public bool AlertTimers = true;
/// <summary>false: only tracked quests are watched; true: every quest the character holds.</summary>
public bool AlertAllTimers;
private static string FilePath => Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RynthCore", "rynthoracle.json");
@ -48,6 +52,8 @@ internal sealed class OracleSettings
MainWindowOpen = Bool(r, "mainWindowOpen", MainWindowOpen);
QuestTimersOpen = Bool(r, "questTimersOpen", QuestTimersOpen);
ConquestAutoDeposit = Bool(r, "conquestAutoDeposit", ConquestAutoDeposit);
AlertTimers = Bool(r, "alertTimers", AlertTimers);
AlertAllTimers = Bool(r, "alertAllTimers", AlertAllTimers);
if (r.TryGetProperty("tabName", out JsonElement t) && t.ValueKind == JsonValueKind.String) TabName = t.GetString() ?? TabName;
if (r.TryGetProperty("lastQuestListCheck", out JsonElement c) && c.ValueKind == JsonValueKind.String
&& DateTime.TryParse(c.GetString(), CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out DateTime when))
@ -73,6 +79,8 @@ internal sealed class OracleSettings
sb.Append(" \"mainWindowOpen\": ").Append(MainWindowOpen ? "true" : "false").Append(",\n");
sb.Append(" \"questTimersOpen\": ").Append(QuestTimersOpen ? "true" : "false").Append(",\n");
sb.Append(" \"conquestAutoDeposit\": ").Append(ConquestAutoDeposit ? "true" : "false").Append(",\n");
sb.Append(" \"alertTimers\": ").Append(AlertTimers ? "true" : "false").Append(",\n");
sb.Append(" \"alertAllTimers\": ").Append(AlertAllTimers ? "true" : "false").Append(",\n");
sb.Append(" \"tabName\": \"").Append(JsonEncodedText.Encode(TabName).ToString()).Append("\"\n");
sb.Append("}\n");
Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!);

View file

@ -38,7 +38,7 @@ public static unsafe class PluginExports
public static IntPtr GetVersion()
{
// Keep in step with RynthOraclePlugin.Version (a u8 literal can't be built from a const string).
try { return LiteralPointer("0.2.1"u8); }
try { return LiteralPointer("0.2.2"u8); }
catch { return IntPtr.Zero; }
}

View file

@ -18,8 +18,8 @@ namespace RynthCore.Plugin.RynthOracle;
/// </summary>
public sealed class RynthOraclePlugin : RynthPluginBase
{
// Previous release: 0.2.0.
public const string Version = "0.2.1";
// Previous release: 0.2.1.
public const string Version = "0.2.2";
private const long QuestReadDelayMs = 6000; // after login, before the hidden /myquests
private const long CharacterReadMs = 1000;
@ -33,6 +33,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
private OracleView? _mainView;
private VoidView? _voidView;
private QuestTimersView? _timersView;
private SkillsEmbed? _skills;
private int _seenBookRevision = -1;
private readonly ConcurrentQueue<string> _commands = new();
@ -57,11 +58,16 @@ public sealed class RynthOraclePlugin : RynthPluginBase
_c.Host = Host;
_c.Settings.Load();
_c.RequestQuests = RequestQuests;
_c.RereadCharacter = RereadCharacter;
_c.RereadTitles = RereadTitles;
_c.ReloadQuestList = ReloadQuestList;
_c.Send = cmd => _c.InWorld && Host.InvokeChatParser(cmd);
_c.RunCommand = cmd => _c.InWorld && Host.InvokeChatParser(cmd);
_ui.Log = msg => Host.Log(msg);
_mainView = new OracleView(_c);
// The Skills / Attributes / Progress tabs: RynthCore draws its Skills panel body in the window.
_skills = new SkillsEmbed(cmd => Host.InvokeChatParser(cmd));
_voidView = new VoidView(_c);
_timersView = new QuestTimersView(_c);
_main = _ui.Add(new UiWindow("RynthOracle/Oracle", "Oracle")
@ -135,6 +141,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
if (_void != null) { _void.Visible = false; _void.NeedsPass = true; }
// The quest book loads once the character's name (and world) are known (TickData).
_c.Book.Clear();
_c.Timers.Reset();
if (_timers != null) { _timers.Visible = _c.Settings.QuestTimersOpen; _timers.NeedsPass = true; }
}
@ -146,8 +153,10 @@ public sealed class RynthOraclePlugin : RynthPluginBase
if (_main != null) { _main.Visible = false; _main.NeedsPass = true; }
if (_void != null) { _void.Visible = false; _void.NeedsPass = true; }
if (_timers != null) { _timers.Visible = false; _timers.NeedsPass = true; }
_skills?.Update(string.Empty, false, false, Environment.TickCount64);
_ui.SubmitEmpty(Host);
_c.Book.Clear(); // saved as it changed
_c.Timers.Reset();
_c.Flags.Clear();
_c.Void.Clear();
_c.Conquest.Clear();
@ -214,6 +223,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
public override void Shutdown()
{
_skills?.Shutdown();
_ui.SubmitEmpty(Host);
_c.Updater.Shutdown();
_c.Settings.Save();
@ -315,6 +325,21 @@ public sealed class RynthOraclePlugin : RynthPluginBase
// RynthAi, RynthILT and RynthCore's menus link here; it shows, never toggles off.
ShowTab(OracleView.TabCharacter);
break;
case "skills":
case "skill":
// The Skills tab: RynthCore's skills panel (raise and train) inside this window.
ShowTab(OracleView.TabSkills);
break;
case "attributes":
case "attrs":
case "attribute":
case "vitals":
ShowTab(OracleView.TabAttributes);
break;
case "progress":
case "progression":
ShowTab(OracleView.TabProgress);
break;
case "status":
string pack = _c.Catalog.PackServer.Length > 0 ? $" + {_c.Catalog.ServerCount} {_c.Catalog.PackServer}" : "";
string titles = _c.TitlesKnown ? $", {_c.EarnedTitles.Count} titles held" : "";
@ -327,12 +352,14 @@ public sealed class RynthOraclePlugin : RynthPluginBase
ShowTab(OracleView.TabAbout);
break;
default:
_c.Print("Commands: /ro (window), /ro character (Character tab: status, session), /ro void (Void window), "
_c.Print("Commands: /ro (window), /ro character (Character tab: status, session), "
+ "/ro skills|attributes|progress (those tabs), /ro void (Void window), "
+ "/ro timers (Quest Timers window), /ro fellowship (Fellowship tab), /ro quests (read quest flags), /ro status, "
+ "/ro about (About tab: settings, server)");
break;
}
if (arg is "" or "void" or "timers" or "timer" or "fellowship" or "fellow" or "fship" or "character" or "char"
or "skills" or "skill" or "attributes" or "attrs" or "attribute" or "vitals" or "progress" or "progression"
or "about" && !Host.HasUi && !_noUiLogged)
{
_noUiLogged = true;
@ -340,11 +367,54 @@ public sealed class RynthOraclePlugin : RynthPluginBase
}
}
private void RequestQuests()
/// <summary>Sends /myquests; false when nothing went out (not in the world, or one was sent moments ago).</summary>
private bool RequestQuests()
{
if (!_c.InWorld) return false;
bool sent = _c.Flags.Request(cmd => Host.InvokeChatParser(cmd), Environment.TickCount64);
if (!sent) Host.Log("[RynthOracle] /myquests was sent moments ago; waiting for that reply.");
if (_main != null) _main.NeedsPass = true;
return sent;
}
// ── The Oracle window's Refresh buttons (the data side; Views\RefreshBar.cs has the rest) ──
/// <summary>Reads the character's stats, buffs and (on the Character tab) RynthAi's session now, not at the next timer.</summary>
private void RereadCharacter()
{
if (!_c.InWorld) return;
if (!_c.Flags.Request(cmd => Host.InvokeChatParser(cmd), Environment.TickCount64))
Host.Log("[RynthOracle] /myquests was sent moments ago; waiting for that reply.");
long now = Environment.TickCount64;
_c.Character.Read(Host);
_c.Void.RemoveExpired(now);
_nextCharacterReadMs = now + CharacterReadMs;
_nextCharacterExtrasMs = 0;
ReadCharacterExtras(now);
if (_main != null) _main.NeedsPass = true;
if (_void != null) _void.NeedsPass = true;
}
/// <summary>Asks the engine for the character's titles again (it keeps them from the login events).</summary>
private void RereadTitles()
{
_titleCount = -2;
ReadTitles();
if (_main != null) _main.NeedsPass = true;
}
/// <summary>
/// Reloads the quest list and the server's pack from their files (a downloaded list, or a pack
/// dropped into %APPDATA%\RynthCore\RynthOracle\packs) and asks RynthCore which server this is.
/// </summary>
private void ReloadQuestList()
{
long now = Environment.TickCount64;
_c.ServerState.Poll(Host, now, force: true);
_seenServerStateRevision = _c.ServerState.Revision;
_c.Server.Refresh(Host, _c.Character.PlayerId != 0 ? _c.Character.PlayerId : Host.GetPlayerId(), _c.ServerState.State);
try { _c.Catalog.Load(_c.Server.Tag, msg => Host.Log(msg)); }
catch (Exception ex) { Host.Log($"[RynthOracle] Couldn't load the quest list: {ex.Message}"); }
_c.Catalog.SyncDiscoveries(_c.Flags);
ApplyServer();
if (_main != null) _main.NeedsPass = true;
}
@ -362,6 +432,9 @@ public sealed class RynthOraclePlugin : RynthPluginBase
TickData(now);
if (!Host.HasUi) return;
// After the poll, so a tab clicked this tick is already selected.
if (_skills != null && _main != null && _mainView != null)
_skills.Update(_mainView.Tab, _main.Visible, _c.InWorld, now);
RecordWindows(now);
_ui.Submit(Host, now);
@ -454,6 +527,7 @@ public sealed class RynthOraclePlugin : RynthPluginBase
_c.Server.Refresh(Host, _c.Character.PlayerId, _c.ServerState.State);
ApplyServer();
LoadQuestBook(now);
AnnounceTimers();
ReadTitles();
TickConquest(now);
if (!_voidAutoDecided && _c.Character.Valid)
@ -475,6 +549,15 @@ public sealed class RynthOraclePlugin : RynthPluginBase
}
}
/// <summary>Says in chat which watched quest timers came up: tracked quests, or every held quest if so set.</summary>
private void AnnounceTimers()
{
if (!_c.Settings.AlertTimers || !_c.Book.Loaded) { _c.Timers.Reset(); return; }
var ready = _c.Timers.Check(_c.Flags, _c.Catalog, _c.Settings.AlertAllTimers ? null : _c.Book.Tracked, _c.UtcNow);
foreach (Quest q in ready)
_c.Print($"Quest ready again: {q.Label}");
}
/// <summary>
/// Loads this character's quest book (tracked quests, rewards) once the name is known and the
/// world has been announced, or after <see cref="BookWorldWaitMs"/> without one (then filed

View file

@ -21,6 +21,9 @@ internal sealed partial class OracleView
w.Checkbox("Hide the replies to RynthOracle's own requests", "o.hide", s.HideOwnQuestReplies, v => { s.HideOwnQuestReplies = v; s.Save(); });
w.Tooltip("/myquests, and on their servers /b, /augs, /top and the like. A command you type yourself always shows its reply.");
w.Checkbox("Show the Void window for characters with Void Magic", "o.void", s.AutoShowVoidWindow, v => { s.AutoShowVoidWindow = v; s.Save(); });
w.Checkbox("Say in chat when a quest timer comes up", "o.alert", s.AlertTimers, v => { s.AlertTimers = v; s.Save(); });
w.Tooltip("Watches the quests you track (the * on the Quests tab) and prints a line the moment a cooldown ends.");
w.Checkbox("...for every quest you hold, not just tracked ones", "o.alertall", s.AlertAllTimers, v => { s.AlertAllTimers = v; s.Save(); });
w.Checkbox("Check once a day for a newer quest list", "o.daily", s.CheckQuestListDaily, v => { s.CheckQuestListDaily = v; s.Save(); });
w.Tooltip("Downloads Oracle of Dereth's master quest list from GitHub, as the original plugin does.");
@ -64,6 +67,7 @@ internal sealed partial class OracleView
w.SeparatorText("Commands");
w.BulletText("/ro open or close this window");
w.BulletText("/ro character the Character tab (status, session)");
w.BulletText("/ro skills the Skills tab (raise and train); /ro attributes, /ro progress likewise");
w.BulletText("/ro timers open or close the Quest Timers window");
w.BulletText("/ro fellowship the Fellowship tab");
w.BulletText("/ro about this tab (settings, server)");

View file

@ -34,9 +34,6 @@ internal sealed partial class OracleView
w.ToggleButton(cq.Boards[i].Label, "cb.tab." + i, i == _conquestBoard, () => _conquestBoard = index, small: true);
}
ConquestBoard b = cq.Boards[_conquestBoard];
w.Button("Refresh", "cb.refresh", () => _c.Send(cq.RequestBoard(b, _c.NowMs)));
w.Tooltip($"Sends {b.Command} and reads the reply.");
w.SameLine();
w.TextDisabled(b.UpdatedUtc == DateTime.MinValue ? "not read yet" : $"read at {b.UpdatedUtc.ToLocalTime():HH:mm}");
if (b.You != null) w.Text($"You: #{b.You.Rank} with {b.You.Value}");
DrawRows(w, "cb.rows", b.Rows);
@ -76,8 +73,6 @@ internal sealed partial class OracleView
if (_aelrynthView == 1)
{
w.Button("Refresh", "ab.me", () => _c.Send(a.RequestTop("me", _c.NowMs)));
w.Tooltip("Sends /top me.");
w.BeginChild("ab.melist", 0f, 0f, border: true);
foreach (AelrynthStanding s in a.Standings)
{
@ -93,9 +88,6 @@ internal sealed partial class OracleView
if (_aelrynthView == 2)
{
w.Button("Refresh", "ab.trials", () => _c.Send(a.RequestTrial("", _c.NowMs)));
w.Tooltip("Sends /trial.");
w.SameLine();
w.InputText("Dungeon", "ab.trialarg", _trialArg, 48, s => _trialArg = s);
w.SameLine();
w.Button("Top 10", "ab.trialtop", () => { if (_trialArg.Trim().Length > 0) _c.Send(a.RequestTrial(_trialArg, _c.NowMs)); });

View file

@ -44,9 +44,6 @@ internal sealed partial class OracleView
private void DrawConquestBank(UiWindow w)
{
ConquestData cq = _c.Conquest;
w.Button("Refresh", "cq.bank.refresh", () => _c.Send(cq.RequestBank(_c.NowMs)));
w.Tooltip("Sends /b and reads your balances.");
w.SameLine();
w.TextDisabled(ReadAt(cq.BankUtc));
foreach (NamedValue b in cq.Bank.OrderBy(b => b.Name, StringComparer.OrdinalIgnoreCase))
{
@ -90,9 +87,6 @@ internal sealed partial class OracleView
private void DrawConquestAugs(UiWindow w)
{
ConquestData cq = _c.Conquest;
w.Button("Refresh", "cq.augs.refresh", () => _c.Send(cq.RequestAugs(_c.NowMs)));
w.Tooltip("Sends /augs.");
w.SameLine();
w.TextDisabled($"{ReadAt(cq.AugsUtc)}, {cq.AugTotal} in total");
w.TextDisabled("Aug"); w.SameLine(120f); w.TextDisabled("Have"); w.SameLine(170f); w.TextDisabled("Next costs"); w.SameLine(330f); w.TextDisabled("Effect now");
foreach (ConquestAug a in cq.Augs)
@ -111,9 +105,6 @@ internal sealed partial class OracleView
private void DrawConquestEnl(UiWindow w)
{
ConquestData cq = _c.Conquest;
w.Button("Refresh", "cq.enl.refresh", () => _c.Send(cq.RequestEnl(_c.NowMs)));
w.Tooltip("Sends /enl augs.");
w.SameLine();
w.TextDisabled(ReadAt(cq.EnlUtc));
foreach (NamedValue a in cq.EnlAugs)
{
@ -157,9 +148,6 @@ internal sealed partial class OracleView
w.Text($"Next costs {TimeText.Number(ConquestData.EnlCoinCost(target))} coins and {(ConquestData.EnlLuminanceCost(target) / 1_000_000.0):0.##}M luminance");
w.SeparatorText("Experience bonuses");
w.Button("Refresh", "cq.bonus.refresh", () => _c.Send(cq.RequestBonus(_c.NowMs)));
w.Tooltip("Sends /bonus.");
w.SameLine();
w.TextDisabled(ReadAt(cq.BonusUtc));
foreach (NamedValue b in cq.Bonuses)
{
@ -172,9 +160,6 @@ internal sealed partial class OracleView
private void DrawConquestFships(UiWindow w)
{
ConquestData cq = _c.Conquest;
w.Button("Refresh", "cq.fship.refresh", () => _c.Send(cq.RequestFships(_c.NowMs)));
w.Tooltip("Sends /fship list.");
w.SameLine();
w.TextDisabled($"{ReadAt(cq.FshipUtc)}, {cq.Fellowships.Count} looking for members");
w.Combo("Sort", "cq.fship.sort", _fshipSort, new[] { "Name", "Leader", "Most members", "Location" }, i => _fshipSort = i);
var list = _fshipSort switch

View file

@ -9,12 +9,18 @@ namespace RynthCore.Plugin.RynthOracle.Views;
/// </summary>
internal sealed partial class OracleView
{
public const string TabQuests = "Quests", TabCharacter = "Character", TabAugs = "Augs", TabSociety = "Society",
public const string TabQuests = "Quests", TabCharacter = "Character",
TabSkills = "Skills", TabAttributes = "Attributes", TabProgress = "Progress",
TabAugs = "Augs", TabSociety = "Society",
TabMarkers = "Markers", TabTitles = "Titles", TabVoid = "Void", TabFellowship = "Fellowship",
TabBoards = "Leaderboards", TabConquest = "Conquest", TabAbout = "About";
/// <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);
/// <summary>
/// A tab: shown where any of its server tags matches the server; no tags = everywhere (retail).
/// Refresh is the page's Refresh button (Views\RefreshBar.cs); Help its tooltip.
/// </summary>
private sealed record TabDef(string Name, string[] Servers, Action<UiWindow> Draw, bool LiveTimers,
Func<RefreshResult> Refresh, Func<string> Help);
private readonly OracleContext _c;
private readonly TabDef[] _tabs;
@ -29,18 +35,35 @@ internal sealed partial class OracleView
string[] any = Array.Empty<string>();
_tabs = new TabDef[]
{
new(TabQuests, any, DrawQuests, true),
new(TabCharacter, any, DrawCharacter, true),
new(TabAugs, any, DrawAugs, true),
new(TabSociety, any, DrawSociety, true),
new(TabMarkers, any, DrawMarkers, false),
new(TabTitles, any, DrawTitles, false),
new(TabVoid, any, DrawVoid, true),
new(TabFellowship, any, DrawFellowship, false),
new(TabQuests, any, DrawQuests, true, () => RefreshQuests(),
() => "Sends /myquests to the server and reads the reply."),
new(TabCharacter, any, DrawCharacter, true, RefreshCharacter,
() => "Re-reads your level, experience, buffs and skills from the game now (and RynthAi's session)."),
// Skills / Attributes / Progress: RynthCore draws its Skills panel body under the tab
// strip (SkillsEmbed). The engine's panel reads the game itself, so there is no Refresh row.
new(TabSkills, any, DrawEmbedded, false, RefreshCharacter,
() => "RynthCore's skills panel: raise and train skills."),
new(TabAttributes, any, DrawEmbedded, false, RefreshCharacter,
() => "RynthCore's skills panel: attributes and vitals."),
new(TabProgress, any, DrawEmbedded, false, RefreshCharacter,
() => "RynthCore's skills panel: progression planners (Infinite Leaftide)."),
new(TabAugs, any, DrawAugs, true, RefreshCharacterAndQuests,
() => "Re-reads your character from the game and sends /myquests for the gem timers."),
new(TabSociety, any, DrawSociety, true, RefreshCharacterAndQuests,
() => "Re-reads your society standing from the game and sends /myquests for today's ribbons and quest timers."),
new(TabMarkers, any, DrawMarkers, false, () => RefreshQuests(),
() => "Sends /myquests: the markers you found are in your quest flags."),
new(TabTitles, any, DrawTitles, false, RefreshTitles,
() => "Re-reads the titles you hold from the game."),
new(TabVoid, any, DrawVoid, true, RefreshVoid,
() => "Re-reads your buffs from the game and drops the spell timers that ran out."),
new(TabFellowship, any, DrawFellowship, false, RefreshFellowship,
() => "Re-reads the fellowship and its members from the game."),
// 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(TabAbout, any, DrawAbout, false),
new(TabBoards, new[] { Data.ServerTags.Conquest, Data.ServerTags.Aelrynth }, DrawBoards, false, RefreshBoards, BoardsHelp),
new(TabConquest, new[] { Data.ServerTags.Conquest }, DrawConquest, true, RefreshConquest, ConquestHelp),
new(TabAbout, any, DrawAbout, false, RefreshAbout,
() => "Loads the quest list and server pack from their files again and asks RynthCore which server this is."),
};
}
@ -103,11 +126,20 @@ internal sealed partial class OracleView
return;
}
// Skills / Attributes / Progress: nothing more is recorded. The rest of the window is
// the region RynthCore fills with its Skills panel body (see SkillsEmbed), so the page
// has no Refresh row and no child of its own to cover it.
if (SkillsEmbed.IsEmbedTab(tab)) return;
if (current != null) DrawRefreshRow(w, current);
w.BeginChild("page." + tab, 0f, 0f, border: false);
(current?.Draw ?? DrawAbout)(w);
w.EndChild();
}
/// <summary>The Skills-family tabs record nothing: <see cref="Draw"/> returns before it would call this.</summary>
private void DrawEmbedded(UiWindow w) { }
// ── Shared helpers ──────────────────────────────────────────────────────
/// <summary>"Done" in green or "--" in grey, the status column most lists start with.</summary>
@ -125,7 +157,7 @@ internal sealed partial class OracleView
w.Text(value);
}
/// <summary>Prints a quest's name, status, notes and wiki link in chat (upstream "thinks" them).</summary>
/// <summary>Prints an entry's name, status, notes and wiki link in chat (upstream "thinks" them). Quests print more: <see cref="OracleContext.PrintQuest"/>.</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);

View file

@ -54,9 +54,10 @@ internal sealed class QuestTimersView
foreach (Quest q in _rows)
{
string flag = q.Flag;
w.Text(Cut(q.Label, 26));
Quest row = q;
w.Selectable(Cut(q.Label, 26), "qt.r." + flag, false, () => _c.PrintQuest(row), StatusX - 10f);
string reward = _c.Book.RewardText(flag);
w.Tooltip(reward.Length > 0 ? $"{q.Label}\n{flag}\nRewards: {reward}" : $"{q.Label}\n{flag}");
w.Tooltip((reward.Length > 0 ? $"{q.Label}\n{flag}\nRewards: {reward}" : $"{q.Label}\n{flag}") + "\nClick: prints its texts in chat.");
w.SameLine(StatusX);
QuestTimerState s = QuestTimer.State(q, flags, now, out string text);
bool held = flags.TryGet(flag, out _);
@ -74,7 +75,7 @@ internal sealed class QuestTimersView
if (flags.Loading) w.TextColored(UiColors.Yellow, "Reading quest flags...");
else if (flags.LastReadUtc == DateTime.MinValue) w.TextDisabled("Quest flags not read yet.");
w.SmallButton("Refresh", "qt.refresh", _c.RequestQuests);
w.SmallButton("Refresh", "qt.refresh", () => _c.RequestQuests());
w.Tooltip("Sends /myquests and reads the reply (timers count down by themselves between reads).");
if (flags.LastReadUtc != DateTime.MinValue)
{

View file

@ -51,9 +51,6 @@ internal sealed partial class OracleView
else
w.Text($"{flags.Flags.Count} quest flags on this character, read at {flags.LastReadUtc.ToLocalTime():HH:mm}.");
w.Button("Refresh", "q.refresh", _c.RequestQuests);
w.Tooltip("Sends /myquests to the server and reads the reply.");
w.SameLine();
bool timersShown = _c.QuestTimersWindowVisible();
w.Button(timersShown ? "Hide quest timers" : "Show quest timers", "q.timers", () => _c.SetQuestTimersWindow(!timersShown));
w.Tooltip("A small window with the quests you track (the * column) and the time left on each.");
@ -125,7 +122,7 @@ internal sealed partial class OracleView
w.SameLine(72f);
Quest row = q;
w.Selectable(Cut(q.Label, 44), "q.r." + flag, flag == _questSel, () => SelectQuest(row), 290f);
w.Tooltip(flag);
w.Tooltip(flag + "\nClick: opens it below and prints its texts in chat.");
w.SameLine(370f);
TimerText(w, q, flags, now, done);
string solves = q.SolvesText(flags);
@ -163,9 +160,14 @@ internal sealed partial class OracleView
// ── The opened quest and its rewards ──────────────────────────────────
/// <summary>
/// A click opens the quest below the list (a second click closes it) and, as upstream's list
/// does, prints its texts in chat: the info and hint, the wiki link and the flag's history.
/// </summary>
private void SelectQuest(Quest q)
{
if (_questSel == q.Flag) { _questSel = ""; return; } // a second click closes it
_c.PrintQuest(q);
if (_questSel == q.Flag) { _questSel = ""; return; }
_questSel = q.Flag;
_rewardMsg = "";
LoadRewardEdit(q.Flag);
@ -208,7 +210,7 @@ internal sealed partial class OracleView
w.Tooltip("List this quest in the Quest Timers window.");
w.SameLine();
Quest print = q;
w.Button("Print in chat", "q.sel.print", () => PrintQuest(print));
w.Button("Print in chat", "q.sel.print", () => _c.PrintQuest(print));
w.SameLine();
w.Button("Close", "q.sel.close", () => _questSel = "");
@ -272,13 +274,6 @@ internal sealed partial class OracleView
_rewardMsg = r.IsEmpty ? "Cleared." : "Saved: " + r.ShortSummary();
}
private void PrintQuest(Quest q)
{
string status = q.IsComplete(_c.Flags) ? q.Status(_c.Flags, _c.UtcNow) : "not done";
PrintEntry(q.IsNew ? (q.Name.Length > 0 ? q.Name : "Not in the quest list") : q.DisplayName, q.Flag, status, q.Details(), q.Url);
if (_c.Book.TryGetReward(q.Flag, out QuestReward r)) _c.Print("Rewards: " + r.LongSummary());
}
// ── Rows ──────────────────────────────────────────────────────────────
/// <summary>The filtered, sorted rows; rebuilt when the filter or data changed (or every 5 s for timers).</summary>

View file

@ -0,0 +1,213 @@
using System;
using System.Collections.Generic;
using RynthCore.Plugin.RynthOracle.Data;
using RynthCore.Plugin.RynthOracle.Ui;
namespace RynthCore.Plugin.RynthOracle.Views;
/// <summary>
/// The Refresh button every page of the Oracle window starts with, and the status line beside it.
/// What "refresh" means depends on where a page's data comes from:
/// - data the server owns (quest flags, ConquestAC's bank and boards, Aelrynth's /top and /trial)
/// is asked for again with the same command the page always used, and the line waits for the
/// reply;
/// - data read from the game client (level, buffs, titles, fellowship) is re-read at once instead
/// of at the next timer;
/// - files (the About page) are loaded again.
/// A page that needs both does both. Nothing here blocks: a request is one chat command, and the
/// same request is refused for <see cref="CooldownMs"/> after it went out (the quest read has its
/// own 5 s gap), so the button can't spam the server.
/// </summary>
internal sealed partial class OracleView
{
private const long CooldownMs = 3000;
private const long ReplyWaitMs = 15_000;
/// <summary>What a Refresh did, and (when it asked the server) how to tell the reply has landed.</summary>
private sealed record RefreshResult(string What, Func<bool>? Done = null);
private string _refreshScope = "", _refreshWhat = "";
private Func<bool>? _refreshDone;
private bool _refreshDoneSeen;
private long _refreshAtMs;
private DateTime _refreshAtUtc, _refreshDoneUtc;
private readonly Dictionary<string, long> _refreshSent = new();
/// <summary>The tab, plus the sub-page a tab has (Conquest's views, the boards), so a status line stays with its own page.</summary>
private string RefreshScope(string tab) => tab switch
{
TabConquest => tab + _conquestView,
TabBoards => tab + _aelrynthView + _conquestBoard,
_ => tab,
};
private void DrawRefreshRow(UiWindow w, TabDef def)
{
string scope = RefreshScope(def.Name);
w.Button("Refresh", "refresh." + scope, () => DoRefresh(def, scope), small: true);
w.Tooltip(def.Help());
if (_refreshScope != scope || _refreshWhat.Length == 0) return;
w.SameLine();
if (_refreshDone != null && !_refreshDoneSeen && _refreshDone())
{
_refreshDoneSeen = true;
_refreshDoneUtc = _c.UtcNow;
}
if (_refreshDone != null && !_refreshDoneSeen)
{
if (_c.NowMs - _refreshAtMs > ReplyWaitMs) w.TextColored(UiColors.Red, "No reply yet. Press Refresh to ask again.");
else w.TextColored(UiColors.Yellow, _refreshWhat + " Waiting for the reply...");
}
else if (_refreshDone != null)
w.TextDisabled($"Updated {_refreshDoneUtc.ToLocalTime():HH:mm:ss}. {_refreshWhat}");
else
w.TextDisabled($"Refreshed {_refreshAtUtc.ToLocalTime():HH:mm:ss}. {_refreshWhat}");
}
private void DoRefresh(TabDef def, string scope)
{
RefreshResult r;
try { r = def.Refresh(); }
catch (Exception ex) { r = new RefreshResult("Couldn't refresh: " + ex.Message); }
_refreshScope = scope;
_refreshWhat = r.What;
_refreshDone = r.Done;
_refreshDoneSeen = false;
_refreshAtMs = _c.NowMs;
_refreshAtUtc = _c.UtcNow;
}
// ── What each page's Refresh does ───────────────────────────────────────
/// <summary>The same request twice within <see cref="CooldownMs"/> is refused.</summary>
private bool CoolingDown(string key)
{
if (_refreshSent.TryGetValue(key, out long t) && _c.NowMs - t < CooldownMs) return true;
_refreshSent[key] = _c.NowMs;
return false;
}
private const string TooSoon = "That was just asked for; wait a few seconds before asking again.";
/// <summary>Sends one chat command (the page's own) and waits for <paramref name="state"/> to change.</summary>
private RefreshResult Ask(string key, Func<long> state, Func<string> command)
{
if (CoolingDown(key)) return new RefreshResult(TooSoon);
long before = state();
string cmd = command();
if (!_c.Send(cmd)) return new RefreshResult($"Couldn't send {cmd} (not in the world).");
return new RefreshResult($"Sent {cmd}.", () => state() != before);
}
/// <summary>/myquests (refused for 5 s after the last one); the line waits for the new flags.</summary>
private RefreshResult RefreshQuests(string before = "")
{
QuestFlagStore f = _c.Flags;
int rev = f.Revision;
if (_c.RequestQuests()) return new RefreshResult(before + "Asked the server for your quest flags (/myquests).", () => f.Revision != rev);
if (f.Loading) return new RefreshResult(before + "Your quest flags are already being read.", () => f.Revision != rev);
return new RefreshResult(before + "Your quest flags were asked for a moment ago; wait a few seconds before asking again.");
}
private RefreshResult RefreshCharacter()
{
_c.RereadCharacter();
return new RefreshResult("Re-read your level, experience, buffs and skills from the game.");
}
/// <summary>Pages built from the character's properties and the quest flags: both are read again.</summary>
private RefreshResult RefreshCharacterAndQuests()
{
_c.RereadCharacter();
return RefreshQuests("Re-read your character from the game. ");
}
private RefreshResult RefreshTitles()
{
_c.RereadTitles();
return new RefreshResult(_c.TitlesKnown
? $"Re-read your titles from the game: {_c.EarnedTitles.Count} held."
: "The game hasn't sent this character's titles yet (they arrive at login).");
}
private RefreshResult RefreshVoid()
{
_c.RereadCharacter();
return new RefreshResult("Re-read your buffs and dropped the spell timers that ran out. Timers on targets are learned from your casts.");
}
private RefreshResult RefreshFellowship()
{
_c.Fellowship.Invalidate();
return new RefreshResult("Re-read the fellowship from the game.");
}
private RefreshResult RefreshAbout()
{
if (CoolingDown("about")) return new RefreshResult(TooSoon);
_c.ReloadQuestList();
QuestCatalog cat = _c.Catalog;
string pack = cat.PackServer.Length > 0 ? $" + {cat.ServerCount} {cat.PackServer}" : "";
return new RefreshResult($"Reloaded the quest list ({cat.RetailCount} retail{pack}) and asked RynthCore which server this is.");
}
private RefreshResult RefreshBoards()
{
if (_c.Server.Is(ServerTags.Conquest))
{
ConquestData cq = _c.Conquest;
ConquestBoard b = cq.Boards[Math.Clamp(_conquestBoard, 0, cq.Boards.Count - 1)];
return Ask("board" + b.Key, () => b.UpdatedUtc.Ticks, () => cq.RequestBoard(b, _c.NowMs));
}
AelrynthBoards a = _c.Boards;
return _aelrynthView switch
{
1 => Ask("top me", () => a.Revision, () => a.RequestTop("me", _c.NowMs)),
2 => Ask("trial", () => a.Revision, () => a.RequestTrial("", _c.NowMs)),
_ => Ask("top " + _aelrynthBoardArg, () => a.Revision,
() => a.RequestTop(a.BoardTitle.Length > 0 ? _aelrynthBoardArg : "", _c.NowMs)),
};
}
private string BoardsHelp()
{
if (_c.Server.Is(ServerTags.Conquest))
{
ConquestBoard b = _c.Conquest.Boards[Math.Clamp(_conquestBoard, 0, _c.Conquest.Boards.Count - 1)];
return $"Sends {b.Command} and reads the reply.";
}
return _aelrynthView switch
{
1 => "Sends /top me and reads the reply.",
2 => "Sends /trial and reads the dungeon list.",
_ => "Sends /top (every board's leader), or asks again for the board that is open.",
};
}
private RefreshResult RefreshConquest()
{
ConquestData cq = _c.Conquest;
switch (_conquestView)
{
case 0: return Ask("bank", () => cq.BankUtc.Ticks, () => cq.RequestBank(_c.NowMs));
case 1: return Ask("augs", () => cq.AugsUtc.Ticks, () => cq.RequestAugs(_c.NowMs));
case 2: return Ask("enl", () => cq.EnlUtc.Ticks, () => cq.RequestEnl(_c.NowMs));
case 3:
_c.RereadCharacter();
return Ask("bonus", () => cq.BonusUtc.Ticks, () => cq.RequestBonus(_c.NowMs));
case 4: return Ask("fship", () => cq.FshipUtc.Ticks, () => cq.RequestFships(_c.NowMs));
default: return RefreshQuests();
}
}
private string ConquestHelp() => _conquestView switch
{
0 => "Sends /b and reads your balances.",
1 => "Sends /augs and reads your advanced augmentations.",
2 => "Sends /enl augs and reads your enlightenment augmentations.",
3 => "Re-reads your level, and sends /bonus for the experience bonuses.",
4 => "Sends /fship list and reads the fellowships looking for members.",
_ => "Sends /myquests: the custom quests' status comes from your quest flags.",
};
}

View file

@ -0,0 +1,90 @@
using System;
namespace RynthCore.Plugin.RynthOracle.Views;
/// <summary>
/// The Skills, Attributes and Progress tabs have no page of their own: RynthCore draws its Skills
/// panel body (raise and train, attributes and vitals, the ILT planners) into the Oracle window,
/// below the tab strip. This class is the plugin's half of that hand-off. It tells the engine
/// which body to draw with "/rc oracle-skills skills|attrs|progress" and to stop with
/// "/rc oracle-skills off".
///
/// It is a small state machine over what the engine was last told, so a command goes out only
/// when the wanted mode changes: never once per frame or per recorded pass. The first command,
/// once a character is in the world, is sent whatever the mode (usually "off"): the engine takes
/// any "/rc oracle-skills" as Oracle announcing that it has these tabs, and only then points the
/// bar's Skills icon and "/rc skills" at them instead of its standalone Skills panel.
/// </summary>
internal sealed class SkillsEmbed
{
/// <summary>The engine's word for "no embedded Skills body".</summary>
public const string Off = "off";
/// <summary>A failed send is tried again no sooner than this.</summary>
public const long RetryMs = 1000;
private readonly Func<string, bool> _send;
private string? _sent; // null until the first command has gone out (the engine knows nothing of us yet)
private long _retryAtMs;
/// <param name="send">Runs a chat command through the engine; false when it didn't go out.</param>
public SkillsEmbed(Func<string, bool> send) => _send = send;
/// <summary>What the engine was last told (and accepted): "skills", "attrs", "progress" or "off"; "off" before any command.</summary>
public string Sent => _sent ?? Off;
/// <summary>True once the engine has been sent a command (it then knows Oracle has these tabs).</summary>
public bool Announced => _sent != null;
/// <summary>The engine mode for an Oracle tab, or null when the tab isn't one of the three.</summary>
public static string? ModeFor(string tab) => tab switch
{
OracleView.TabSkills => "skills",
OracleView.TabAttributes => "attrs",
OracleView.TabProgress => "progress",
_ => null,
};
/// <summary>True for the tabs whose page is drawn by the engine.</summary>
public static bool IsEmbedTab(string tab) => ModeFor(tab) != null;
/// <summary>
/// The mode the engine should be in: the selected tab's while the Oracle window is showing and
/// a character is in the world, otherwise off.
/// </summary>
public static string Wanted(string tab, bool windowVisible, bool inWorld) =>
windowVisible && inWorld ? ModeFor(tab) ?? Off : Off;
/// <summary>
/// Sends the command for the wanted mode if it differs from the last one sent (the first
/// command waits for the world). Returns true when a command went out. A refused send leaves
/// the state as it was and is retried after <see cref="RetryMs"/>.
/// </summary>
public bool Update(string tab, bool windowVisible, bool inWorld, long nowMs)
{
if (_sent == null && !inWorld) return false;
string want = Wanted(tab, windowVisible, inWorld);
if (want == _sent || nowMs < _retryAtMs) return false;
if (!_send("/rc oracle-skills " + want))
{
_retryAtMs = nowMs + RetryMs;
return false;
}
_sent = want;
return true;
}
/// <summary>
/// Unload: leave the engine with no embedded body, whatever was shown. One attempt; nothing is
/// kept to retry. Returns true when a command went out.
/// </summary>
public bool Shutdown()
{
if (_sent == null || _sent == Off) return false;
bool ok;
try { ok = _send("/rc oracle-skills " + Off); }
catch { ok = false; }
if (ok) _sent = Off;
return ok;
}
}