Snapshot for release 2026.10.15.2 (internal 2d4b0af)
This commit is contained in:
parent
a89ae04005
commit
d5e0b50de7
224 changed files with 17914 additions and 1182 deletions
|
|
@ -18,24 +18,33 @@ namespace RynthCore.Plugin.RynthOracle;
|
|||
/// </summary>
|
||||
public sealed class RynthOraclePlugin : RynthPluginBase
|
||||
{
|
||||
public const string Version = "0.2.0";
|
||||
// Previous release: 0.2.0.
|
||||
public const string Version = "0.2.1";
|
||||
|
||||
private const long QuestReadDelayMs = 6000; // after login, before the hidden /myquests
|
||||
private const long CharacterReadMs = 1000;
|
||||
// The Character tab's session (RynthAi): read only while that tab is on screen.
|
||||
private const long CharacterExtrasReadMs = 2000;
|
||||
private const long BookWorldWaitMs = 15_000; // how long the quest book waits for the world name
|
||||
|
||||
private readonly OracleContext _c = new();
|
||||
private readonly UiHost _ui = new();
|
||||
private UiWindow? _main, _void;
|
||||
private UiWindow? _main, _void, _timers;
|
||||
private OracleView? _mainView;
|
||||
private VoidView? _voidView;
|
||||
private QuestTimersView? _timersView;
|
||||
private int _seenBookRevision = -1;
|
||||
|
||||
private readonly ConcurrentQueue<string> _commands = new();
|
||||
private long _questReadAtMs = -1;
|
||||
private long _loginMs;
|
||||
private long _nextCharacterReadMs;
|
||||
private long _nextCharacterExtrasMs;
|
||||
private bool _voidAutoDecided;
|
||||
private bool _dailyCheckStarted;
|
||||
private int _seenFlagRevision = -1, _seenCatalogRevision = -1, _seenVoidRevision = -1;
|
||||
// RynthCore's server list (ServerStateClient.Revision) last applied to the server identity.
|
||||
private int _seenServerStateRevision = -1;
|
||||
private bool _noUiLogged;
|
||||
private string? _catalogTag; // the server tag the catalog and server data were loaded for
|
||||
private bool _conquestLoginRead;
|
||||
|
|
@ -49,13 +58,15 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.Settings.Load();
|
||||
_c.RequestQuests = RequestQuests;
|
||||
_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);
|
||||
_voidView = new VoidView(_c);
|
||||
_timersView = new QuestTimersView(_c);
|
||||
_main = _ui.Add(new UiWindow("RynthOracle/Oracle", "Oracle")
|
||||
{
|
||||
DefaultWidth = 620f, DefaultHeight = 560f, MinWidth = 420f, MinHeight = 260f,
|
||||
DefaultWidth = 700f, DefaultHeight = 600f, MinWidth = 420f, MinHeight = 260f,
|
||||
});
|
||||
// The Void window is opened from the Oracle window: no bar button (and no Scripts menu
|
||||
// line, which would bring back the Scripts button just for it).
|
||||
|
|
@ -66,11 +77,34 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
});
|
||||
_mainView.SetVoidWindow = v => { if (_void != null) { _void.Visible = v; _void.NeedsPass = true; } };
|
||||
_mainView.VoidWindowVisible = () => _void?.Visible ?? false;
|
||||
// The Quest Timers window (tracked quests): opened from the Quests tab, /ro timers or the
|
||||
// engine's Character menu; like the Void window it has no bar button of its own.
|
||||
_timers = _ui.Add(new UiWindow("RynthOracle/QuestTimers", "Quest Timers")
|
||||
{
|
||||
DefaultWidth = 310f, DefaultHeight = 220f, MinWidth = 220f, MinHeight = 90f,
|
||||
ShowInBar = false,
|
||||
});
|
||||
_c.SetQuestTimersWindow = SetQuestTimers;
|
||||
_c.QuestTimersWindowVisible = () => _timers?.Visible ?? false;
|
||||
|
||||
Host.Log($"[RynthOracle] {Version} initialized. /ro opens the window. Based on Oracle of Dereth by Advis Eveldan - thank you!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>Shows or hides the Quest Timers window and remembers the choice for the next login.</summary>
|
||||
private void SetQuestTimers(bool visible)
|
||||
{
|
||||
if (_timers == null) return;
|
||||
_timers.Visible = visible;
|
||||
_timers.NeedsPass = true;
|
||||
if (_c.Settings.QuestTimersOpen != visible)
|
||||
{
|
||||
_c.Settings.QuestTimersOpen = visible;
|
||||
_c.Settings.Save();
|
||||
}
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
// The engine calls this on a real login and on a freshly (re)loaded plugin already in game.
|
||||
public override void OnLoginComplete()
|
||||
{
|
||||
|
|
@ -78,7 +112,10 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.Flags.Clear();
|
||||
_c.Void.Clear();
|
||||
_c.Server.Reset();
|
||||
_c.Server.Refresh(Host, Host.GetPlayerId());
|
||||
_c.ServerState.Clear();
|
||||
_c.ServerState.Poll(Host, Environment.TickCount64, force: true);
|
||||
_seenServerStateRevision = _c.ServerState.Revision;
|
||||
_c.Server.Refresh(Host, Host.GetPlayerId(), _c.ServerState.State);
|
||||
_catalogTag = null;
|
||||
ApplyServer();
|
||||
_conquestLoginRead = false;
|
||||
|
|
@ -90,10 +127,15 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_loginMs = now;
|
||||
_questReadAtMs = _c.Settings.ReadQuestsAtLogin ? now + QuestReadDelayMs : -1;
|
||||
_nextCharacterReadMs = now;
|
||||
_nextCharacterExtrasMs = now;
|
||||
ClearCharacterExtras();
|
||||
_voidAutoDecided = false;
|
||||
_dailyCheckStarted = false;
|
||||
if (_main != null) { _main.Visible = _c.Settings.MainWindowOpen; _main.NeedsPass = true; }
|
||||
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();
|
||||
if (_timers != null) { _timers.Visible = _c.Settings.QuestTimersOpen; _timers.NeedsPass = true; }
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
|
|
@ -103,14 +145,51 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
// Closed for character select (the saved "left open" choice is kept for the next login).
|
||||
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; }
|
||||
_ui.SubmitEmpty(Host);
|
||||
_c.Book.Clear(); // saved as it changed
|
||||
_c.Flags.Clear();
|
||||
_c.Void.Clear();
|
||||
_c.Conquest.Clear();
|
||||
_c.Boards.Clear();
|
||||
_c.Server.Reset();
|
||||
_c.ServerState.Clear();
|
||||
_c.TitlesKnown = false;
|
||||
_c.EarnedTitles.Clear();
|
||||
ClearCharacterExtras();
|
||||
}
|
||||
|
||||
/// <summary>Forgets the Character tab's session (login, logout): the next character's comes fresh.</summary>
|
||||
private void ClearCharacterExtras()
|
||||
{
|
||||
_c.Session = default;
|
||||
_c.SessionKnown = false;
|
||||
_c.AiSession.Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// While the Character tab is on screen: RynthAi's session, every <see cref="CharacterExtrasReadMs"/>.
|
||||
/// Nothing is read with the window closed or on another tab.
|
||||
/// </summary>
|
||||
private void ReadCharacterExtras(long now)
|
||||
{
|
||||
if (_main == null || _mainView == null || !_main.Visible || _mainView.Tab != OracleView.TabCharacter) return;
|
||||
if (now < _nextCharacterExtrasMs) return;
|
||||
_nextCharacterExtrasMs = now + CharacterExtrasReadMs;
|
||||
|
||||
bool known = _c.AiSession.TryGet(Host, now, out Shared.SessionStatsV1 s);
|
||||
if (known != _c.SessionKnown || known && (s.Xp != _c.Session.Xp || s.Lum != _c.Session.Lum || s.Kills != _c.Session.Kills))
|
||||
_main.NeedsPass = true;
|
||||
_c.SessionKnown = known;
|
||||
_c.Session = known ? s : default;
|
||||
}
|
||||
|
||||
/// <summary>Shows the main window on a tab (another plugin's link, or a /ro tab command).</summary>
|
||||
private void ShowTab(string tab)
|
||||
{
|
||||
if (_mainView != null) _mainView.Tab = tab;
|
||||
if (_main != null) { _main.Visible = true; _main.NeedsPass = true; }
|
||||
if (tab == OracleView.TabCharacter) _nextCharacterExtrasMs = 0; // read at once
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -215,10 +294,27 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
case "void":
|
||||
if (_void != null) { _void.Visible = !_void.Visible; _void.NeedsPass = true; }
|
||||
break;
|
||||
case "timers":
|
||||
case "timer":
|
||||
if (_timers != null) SetQuestTimers(!_timers.Visible);
|
||||
break;
|
||||
case "quests":
|
||||
case "refresh":
|
||||
RequestQuests();
|
||||
break;
|
||||
case "fellowship":
|
||||
case "fellow":
|
||||
case "fship":
|
||||
// The main window on its Fellowship tab (RynthCore's Char menu and RynthAi's Mini Remote use this).
|
||||
ShowTab(OracleView.TabFellowship);
|
||||
break;
|
||||
case "character":
|
||||
case "char":
|
||||
// The Character tab: the character overview and RynthAi's session (the generic part of
|
||||
// the Mini Remote's old Character tab; Infinite Leaftide's charms stay RynthILT's).
|
||||
// RynthAi, RynthILT and RynthCore's menus link here; it shows, never toggles off.
|
||||
ShowTab(OracleView.TabCharacter);
|
||||
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" : "";
|
||||
|
|
@ -226,13 +322,18 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
+ $"{_c.Flags.Flags.Count} quest flags read, {_c.Catalog.RetailCount} retail quests{pack}, {_c.Void.Dots.Count} Void spells tracked{titles}.");
|
||||
break;
|
||||
case "about":
|
||||
// The About tab (settings, the server RynthCore says this is).
|
||||
_c.Print("Based on Oracle of Dereth by Advis Eveldan - thank you! github.com/advis61/OracleOfDereth (MIT)");
|
||||
ShowTab(OracleView.TabAbout);
|
||||
break;
|
||||
default:
|
||||
_c.Print("Commands: /ro (window), /ro void (Void window), /ro quests (read quest flags), /ro status, /ro about");
|
||||
_c.Print("Commands: /ro (window), /ro character (Character tab: status, session), /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" && !Host.HasUi && !_noUiLogged)
|
||||
if (arg is "" or "void" or "timers" or "timer" or "fellowship" or "fellow" or "fship" or "character" or "char"
|
||||
or "about" && !Host.HasUi && !_noUiLogged)
|
||||
{
|
||||
_noUiLogged = true;
|
||||
_c.Print("This RynthCore engine can't show plugin windows (it needs script windows, API v71, with ImGui on). /ro status still works.");
|
||||
|
|
@ -270,6 +371,13 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_c.Settings.MainWindowOpen = _main.Visible;
|
||||
_c.Settings.Save();
|
||||
}
|
||||
// The same for the Quest Timers window (closed with its X or opened from the engine's menu).
|
||||
if (_c.InWorld && _timers != null && _timers.Visible != _c.Settings.QuestTimersOpen)
|
||||
{
|
||||
_c.Settings.QuestTimersOpen = _timers.Visible;
|
||||
_c.Settings.Save();
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void TickData(long now)
|
||||
|
|
@ -280,11 +388,19 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_seenFlagRevision = _c.Flags.Revision;
|
||||
_c.Catalog.SyncDiscoveries(_c.Flags);
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
if (_timers != null) _timers.NeedsPass = true;
|
||||
}
|
||||
if (_c.Catalog.Revision != _seenCatalogRevision)
|
||||
{
|
||||
_seenCatalogRevision = _c.Catalog.Revision;
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
if (_timers != null) _timers.NeedsPass = true;
|
||||
}
|
||||
if (_c.Book.Revision != _seenBookRevision)
|
||||
{
|
||||
_seenBookRevision = _c.Book.Revision;
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
if (_timers != null) _timers.NeedsPass = true;
|
||||
}
|
||||
|
||||
string? result = _c.Updater.TakeResult(out bool updated);
|
||||
|
|
@ -302,6 +418,18 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
|
||||
if (!_c.InWorld) return;
|
||||
|
||||
ReadCharacterExtras(now);
|
||||
|
||||
// RynthCore's server list (every 2 s): a new pick or override applies now, not at the next character read.
|
||||
_c.ServerState.Poll(Host, now);
|
||||
if (_c.ServerState.Revision != _seenServerStateRevision)
|
||||
{
|
||||
_seenServerStateRevision = _c.ServerState.Revision;
|
||||
_c.Server.Refresh(Host, _c.Character.PlayerId != 0 ? _c.Character.PlayerId : Host.GetPlayerId(), _c.ServerState.State);
|
||||
ApplyServer();
|
||||
if (_main != null) _main.NeedsPass = true;
|
||||
}
|
||||
|
||||
if (_questReadAtMs >= 0 && now >= _questReadAtMs)
|
||||
{
|
||||
_questReadAtMs = -1;
|
||||
|
|
@ -323,8 +451,9 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
_nextCharacterReadMs = now + CharacterReadMs;
|
||||
_c.Character.Read(Host);
|
||||
_c.Void.RemoveExpired(now);
|
||||
_c.Server.Refresh(Host, _c.Character.PlayerId);
|
||||
_c.Server.Refresh(Host, _c.Character.PlayerId, _c.ServerState.State);
|
||||
ApplyServer();
|
||||
LoadQuestBook(now);
|
||||
ReadTitles();
|
||||
TickConquest(now);
|
||||
if (!_voidAutoDecided && _c.Character.Valid)
|
||||
|
|
@ -346,6 +475,19 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
}
|
||||
}
|
||||
|
||||
/// <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
|
||||
/// under "default"), so the file isn't picked before the world name arrives.
|
||||
/// </summary>
|
||||
private void LoadQuestBook(long now)
|
||||
{
|
||||
if (_c.Book.Loaded || !_c.Character.Valid || _c.Character.Name.Length == 0) return;
|
||||
if (_c.Server.WorldName.Length == 0 && now - _loginMs < BookWorldWaitMs) return;
|
||||
_c.Book.Load(_c.Server.WorldName, _c.Character.Name);
|
||||
if (_c.Book.LoadNote.Length > 0) _c.Print(_c.Book.LoadNote);
|
||||
}
|
||||
|
||||
/// <summary>The titles the character holds (engine API v75), re-read each second (cheap; changes are rare).</summary>
|
||||
private void ReadTitles()
|
||||
{
|
||||
|
|
@ -395,6 +537,8 @@ public sealed class RynthOraclePlugin : RynthPluginBase
|
|||
}
|
||||
if (_void != null && _voidView != null)
|
||||
Record(_void, now, 500, _voidView.Draw);
|
||||
if (_timers != null && _timersView != null)
|
||||
Record(_timers, now, 1000, _timersView.Draw);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in a new issue