diff --git a/Changelog/2026-10-13-ilt-hub-into-rynthilt.md b/Changelog/2026-10-13-ilt-hub-into-rynthilt.md new file mode 100644 index 0000000..a6c5527 --- /dev/null +++ b/Changelog/2026-10-13-ilt-hub-into-rynthilt.md @@ -0,0 +1,58 @@ +# RynthILT 0.2.0: the ILT Hub moves out of RynthAi + +SilentKelpie's ILT Hub (the Infinite Leaftide / ACECustom features) is now part of the RynthILT +plugin. RynthAi keeps the Mini Remote and the parts every server has. Pairs with RynthCore +`refactor/ilt-into-plugin` (the Guardian panel, the Progression tab and the ILT menus read +RynthILT). + +## What changed + +- **RynthILT has the ILT features** (`Plugins/RynthCore.Plugin.RynthILT/Hub`): the Mini Remote's + Character, Banking, Gear, Charms and Games tabs, the Guardian panel, the Skills panel's + Progression data and the attribute raiser, server feature detection, the `/qb` list and the + `/pets` and `/shinies` logs. They run only on an ILT world (its server list, or the + character's "Treat this world as ILT"), as before. +- **RynthAi keeps** the Mini Remote, its Quests and Pets tabs (every server; settings now in + `miniremote.json`, read once from the old `ilt-hub.json`) and the VirindiTank `.usd` importer + (it edits RynthAi's rules; it still shows in the Gear tab). +- **The two plugins talk through two interfaces** (`Plugins/Shared`): `RynthILT.Hub` (the ILT tabs, + sections, feature bits and verbs the Mini Remote shows) and `RynthAi.Hub` (the Mini Remote, + `/myquests`, spell names, VTank loot matching, the importer and the session stats RynthILT + borrows). Without RynthILT the Mini Remote has no ILT tabs and the ILT verbs say so; without + RynthAi, RynthILT's panels and `/ilt` commands still work (suits, dispel names, `/myquests` + rows and the XP rows need RynthAi). +- **Saved data is copied over** on each character's first login with RynthILT: `ilt-hub.json`, + `ilt-hub-transactions.json`, `ilt-hub-profiles\`, the shared `IltHubProfiles\` and + `ilt-aug-costs.json` go to `%APPDATA%\RynthCore\RynthILT`, and the RynthAi profile's Server + Features list and "Force enable" are folded into RynthILT's settings. Nothing is deleted. +- **Failed saves and copies say so** (as RynthAi's do since 2026.10.13.1; `DataWriteGuard` moved to + `Plugins/Shared` and is linked into both plugins): the Hub state, bank log, Hub profiles, + settings, aug costs, the bounty list and every file copied from RynthAi are logged with the + reason when they fail, and said in chat once per folder (with the fix) on an ILT world only. + A shared file that couldn't be copied is tried again at the next login; the originals in the + RynthAi folder are never touched. +- **An unfinished character copy is never shadowed:** if one of a character's files can't be + copied, the character is marked pending (in RynthILT's `settings.json`, so it survives a + restart). Until the copy completes the Hub saves no `hub.json`, bank log or per-character + profile for it, running from the RynthAi originals read-only where they can be read (else the + defaults). The copy is retried every 2 minutes and at each login; once it works the Hub + restarts on the copied files. +- **Commands:** `/ra hub|quests|pets` work as before; the ILT verbs (`/ra hub bank|attr|suit| + profile|force|refresh|status|clap|open `, `/ra guardian`, `/ra bounty`) go on to + RynthILT. New: `/ra hub servers [list||default]` (the old Settings > Misc list), + `/ilt hub ...`, `/ilt guardian ...`, `/ilt servers`, `/ilt trace`, `/ilt debug`. +- The ILT trace categories leave RynthAi's log; RynthILT writes its own + (`%APPDATA%\RynthCore\RynthILT\Logs`). + +## Not carried + +- Hub profiles hold only the ILT settings now (the Pets tab's settings stay per character). +- `RynthPluginGetCharmsJson` (the Charms Tracking tab of engines up to 2026.10.5.35) is gone. + +## Tests + +- `Tools/RynthILT.Tests` runs the raiser, aug cost, bank and sigil tests (moved from the RynthAi + host tests) and new migration, interface and routing tests (failed copies and saves reported, + the VTank hotkey verbs stay RynthAi's); `RynthCore.RynthAiHostTests` covers the Mini Remote side. + +Not yet tested in game. diff --git a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs index c3bcecd..779dc16 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Combat/PetManager.cs @@ -92,20 +92,20 @@ internal sealed class PetManager private static long NowMs => Clock(); /// - /// Optional ILT Hub hook: when it returns true an EMPTY essence is used anyway, because - /// the server's Summon Essence Refill Charm refills it from banked pyreals on use. + /// Optional Mini Remote Pets-tab hook: when it returns true an EMPTY essence is used anyway, because + /// the server's Summon Essence Refill Charm (ACECustom) refills it from banked pyreals on use. /// Null (default) keeps the retail behaviour (spirit refill or park). /// public Func? AllowSummonOnEmpty { get; set; } /// - /// Optional ILT Hub hook: while it returns true no combat summon is started (e.g. the + /// Optional Pets-tab hook: while it returns true no combat summon is started (e.g. the /// healing-pet helper has its heal pet out). Null (default) never holds. /// public Func? HoldSummons { get; set; } /// - /// Optional ILT Hub hook, called when a pet already holds the slot and monsters are near. + /// Optional Pets-tab hook, called when a pet already holds the slot and monsters are near. /// Returns true after dismissing a non-combat (cosmetic) pet so a combat pet can follow. /// Null (default) leaves whatever pet is out alone. /// diff --git a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs index 6d62f4b..9309e16 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/RynthLog.cs @@ -42,19 +42,8 @@ internal enum LogCat Remote, Chat, Huds, - - // ── ILT Hub (IltHub/) ────────────────────────────────────────────────── - IltHub, - IltOptions, - IltChat, - IltStore, - IltBanking, - IltPets, - IltQuests, - IltProgression, - IltRates, - IltGear, - IltGames, + // The ILT Hub's categories (IltHub, IltOptions, ...) went with it to the RynthILT plugin + // (2026-10-13), which keeps its own log ("/ilt trace"). } /// @@ -117,7 +106,7 @@ internal enum LogEventLevel /// internal sealed class LogEventSetting { - /// Stable event id, e.g. "IltHub.Login". + /// Stable event id, e.g. "Area.Event". public string Key = string.Empty; /// "Info", "Trace" or "Off" (case-insensitive; anything else falls back to the default). @@ -158,16 +147,8 @@ internal sealed class LogCategorySetting /// internal static class LogEvents { - // ── ILT Hub ──────────────────────────────────────────────────────────── - public const string IltLogin = "IltHub.Login"; - public const string IltWorldCheck = "IltHub.WorldCheck"; - public const string IltOptionsRefreshStart = "IltHub.OptionsRefreshStart"; - public const string IltOptionsRefreshed = "IltHub.OptionsRefreshed"; - public const string IltWindowShown = "IltHub.WindowShown"; - public const string IltWindowHidden = "IltHub.WindowHidden"; - public const string IltCommand = "IltHub.Command"; - public const string IltConfirmation = "IltHub.Confirmation"; - public const string IltLogout = "IltHub.Logout"; + // The ILT Hub's events (IltHub.Login, ...) went with it to the RynthILT plugin (2026-10-13); + // none of RynthAi's own are cataloged yet. /// Catalog entry: key, owning category, default level, launcher description. internal readonly record struct Definition(string Key, LogCat Category, LogEventLevel Default, string Description); @@ -175,15 +156,6 @@ internal static class LogEvents /// Every known event, in launcher display order. internal static readonly Definition[] Catalog = { - new(IltLogin, LogCat.IltHub, LogEventLevel.Info, "ILT Hub: character logged in (character and world)."), - new(IltWorldCheck, LogCat.IltOptions, LogEventLevel.Info, "ILT Hub: login world check (ILT-like world or skipped)."), - new(IltOptionsRefreshStart, LogCat.IltOptions, LogEventLevel.Trace, "ILT Hub: server options refresh started."), - new(IltOptionsRefreshed, LogCat.IltOptions, LogEventLevel.Info, "ILT Hub: server options refreshed (source and on/off counts)."), - new(IltWindowShown, LogCat.IltHub, LogEventLevel.Info, "ILT: a Mini Remote ILT tab shown."), - new(IltWindowHidden, LogCat.IltHub, LogEventLevel.Trace, "ILT: Mini Remote hidden."), - new(IltCommand, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: /ra hub and /ra quests commands."), - new(IltConfirmation, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: chat confirmations requested, confirmed or expired."), - new(IltLogout, LogCat.IltHub, LogEventLevel.Trace, "ILT Hub: logout (features stopped)."), }; /// Launcher description for each trace category. @@ -213,17 +185,6 @@ internal static class LogEvents LogCat.Remote => "Remote control (launcher/Avalonia commands).", LogCat.Chat => "Chat parsing and chat diagnostics.", LogCat.Huds => "Floating HUDs: item counts, Mini Remote, icons.", - LogCat.IltHub => "ILT Hub: window, login/logout, commands.", - LogCat.IltOptions => "ILT Hub: server options.", - LogCat.IltChat => "ILT Hub: chat parsing.", - LogCat.IltStore => "ILT Hub: store.", - LogCat.IltBanking => "ILT Hub: banking.", - LogCat.IltPets => "ILT Hub: pets.", - LogCat.IltQuests => "ILT Hub: quests.", - LogCat.IltProgression => "ILT Hub: progression.", - LogCat.IltRates => "ILT Hub: rates.", - LogCat.IltGear => "ILT Hub: gear.", - LogCat.IltGames => "ILT Hub: games.", _ => cat.ToString(), }; } @@ -686,7 +647,6 @@ internal static class RynthLog if (Starts(message, "[ChatDiag") || Starts(message, "[RynthChat")) return LogCat.Chat; if (Starts(message, "[Reclassify") || Starts(message, "[Classify")) return LogCat.WorldCache; if (Starts(message, "[RynthAi navstate") || Starts(message, "[Nav")) return LogCat.Navigation; - if (Starts(message, "[IltHub")) return LogCat.IltHub; return LogCat.General; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/HubInterface.cs b/Plugins/RynthCore.Plugin.RynthAi/HubInterface.cs new file mode 100644 index 0000000..08cb945 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/HubInterface.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using RynthCore.Loot.VTank; +using RynthCore.Plugin.RynthAi.Loot; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthAi; + +/// +/// RynthAi's side of the "RynthAi.Hub" interface (Shared/RynthAiHubApi.cs): what the RynthILT +/// plugin (the Infinite Leaftide features, moved out of RynthAi 2026-10-13) borrows from RynthAi: +/// the Mini Remote that hosts its tabs, the /myquests tracker, spell names, VTank loot-profile +/// matching, the .usd importer drawn in its Gear tab, and the Mini Remote's session stats. +/// Unlike RynthAi.Status the table is never freed: RynthILT's render thread may still hold it +/// while plugins shut down (a plugin DLL is never unloaded, so the functions stay callable), so +/// Release only sets Version to 0 and every function answers "nothing" from then on. +/// +internal static unsafe class HubInterface +{ + private static RynthAiHubApiV1* _table; + private static volatile bool _released; + + private static RynthAiPlugin? Plugin => _released ? null : PluginExports.Runtime.Plugin; + + public static IntPtr Query(string iface, uint version) + { + if (iface != RynthAiHubApiV1.InterfaceName || version == 0 || version > RynthAiHubApiV1.InterfaceVersion || _released) + return IntPtr.Zero; + if (_table == null) + { + var t = (RynthAiHubApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthAiHubApiV1)); + t->StructSize = (uint)sizeof(RynthAiHubApiV1); + t->MiniRemoteTab = &MiniRemoteTab; + t->MiniRemoteVisible = &MiniRemoteVisible; + t->QuestFlag = &QuestFlag; + t->QuestStatus = &QuestStatus; + t->QuestRefresh = &QuestRefresh; + t->SpellName = &SpellName; + t->LootKeeps = &LootKeeps; + t->RenderSection = &RenderSection; + t->SessionStats = &SessionStats; + t->SessionReset = &SessionReset; + t->Version = RynthAiHubApiV1.InterfaceVersion; + _table = t; + } + return (IntPtr)_table; + } + + /// Plugin shutdown: Version 0 (callers re-query); the table itself stays allocated. + public static void Release() + { + _released = true; + if (_table != null) _table->Version = 0; + } + + private static string? Utf8(byte* p) => p == null ? null : Marshal.PtrToStringUTF8((IntPtr)p); + + /// Writes as NUL-terminated UTF-8 (truncated to fit); returns the bytes written. + private static int WriteUtf8(string s, byte* dest, int capacity) + { + if (dest == null || capacity <= 0) return 0; + byte[] bytes = Encoding.UTF8.GetBytes(s ?? string.Empty); + int n = Math.Min(bytes.Length, capacity - 1); + for (int i = 0; i < n; i++) dest[i] = bytes[i]; + dest[n] = 0; + return n; + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int MiniRemoteTab(byte* tabId, byte* mode, byte* reply, int replyCapacity) + { + try + { + var plugin = Plugin; + string? text = plugin?.MiniRemoteTabForIlt(Utf8(tabId) ?? string.Empty, Utf8(mode) ?? "show"); + if (text == null) { WriteUtf8("The Mini Remote is not available yet (log in first).", reply, replyCapacity); return 0; } + WriteUtf8(text, reply, replyCapacity); + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int MiniRemoteVisible() + { + try { return Plugin?.MiniRemoteVisibleForIlt == true ? 1 : 0; } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int QuestFlag(byte* key, QuestFlagV1* flag) + { + try + { + var tracker = Plugin?.QuestTrackerForIlt; + string? k = Utf8(key); + if (tracker == null || string.IsNullOrWhiteSpace(k) || flag == null || !tracker.TryGetFlag(k, out var rec)) return 0; + flag->Solves = rec.Solves; + flag->MaxSolves = rec.MaxSolves; + flag->CompletedOnUtcTicks = rec.CompletedOn.Ticks; + flag->RepeatSeconds = (long)rec.RepeatTime.TotalSeconds; + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int QuestStatus(QuestStatusV1* status) + { + try + { + var tracker = Plugin?.QuestTrackerForIlt; + if (tracker == null || status == null) return 0; + status->Disabled = tracker.Disabled ? 1 : 0; + status->Count = tracker.Count; + status->Generation = tracker.RefreshGeneration; + status->Refreshing = tracker.IsRefreshing ? 1 : 0; + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int QuestRefresh(byte* reply, int replyCapacity) + { + try + { + var remote = Plugin?.MiniRemoteForIlt; + if (remote == null) { WriteUtf8("Quest tracker not ready.", reply, replyCapacity); return 0; } + string text = remote.RefreshQuests(); + WriteUtf8(text, reply, replyCapacity); + return text.StartsWith("Refreshing", StringComparison.Ordinal) ? 1 : 0; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int SpellName(uint spellId, byte* buffer, int capacity) + { + try + { + if (_released || spellId == 0) return 0; + string name = SpellDatabase.GetSpellName(unchecked((int)spellId)); + return string.IsNullOrEmpty(name) ? 0 : WriteUtf8(name, buffer, capacity); + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int LootKeeps(byte* utlPath, uint* ids, int count, byte* keep, byte* error, int errorCapacity) + { + try + { + var plugin = Plugin; + string? path = Utf8(utlPath); + if (plugin == null || string.IsNullOrWhiteSpace(path) || count < 0 || (count > 0 && (ids == null || keep == null))) + { + WriteUtf8("RynthAi isn't ready (log in first).", error, errorCapacity); + return 0; + } + VTankLootProfile profile; + try { profile = VTankLootParser.Load(path); } + catch (Exception ex) { WriteUtf8("could not read profile: " + ex.Message, error, errorCapacity); return 0; } + var cache = plugin.ObjectCacheForIlt; + var host = plugin.HostForIlt; + var ctx = new VTankLootContext(host, host.GetPlayerId()) { Cache = cache }; + for (int i = 0; i < count; i++) + { + keep[i] = 0; + WorldObject? wo = cache?[unchecked((int)ids[i])]; + if (wo == null) continue; + foreach (var rule in profile.Rules) + { + if (!VTankLootEvaluator.Match(rule, wo, ctx)) continue; + if (rule.Action == VTankLootAction.Keep) keep[i] = 1; + break; + } + } + return 1; + } + catch (Exception ex) + { + WriteUtf8("loot match failed: " + ex.Message, error, errorCapacity); + return 0; + } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int RenderSection(byte* id) + { + try + { + var remote = Plugin?.MiniRemoteForIlt; + if (remote == null || Utf8(id) != RynthAiHub.SectionVTankImport) return 0; + remote.Usd.Render(); + return 1; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.UI, ex, "RynthAi.Hub RenderSection"); + return 0; + } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int SessionStats(SessionStatsV1* stats) + { + try + { + var tracker = Plugin?.SessionStatsForIlt; + if (tracker == null || stats == null) return 0; + var v = tracker.View; + stats->StartUtcTicks = v.SessionStartUtc.Ticks; + stats->SessionSeconds = v.SessionSeconds; + stats->Xp = v.Xp; + stats->XpPerHour = v.XpPerHour; + stats->Lum = v.Lum; + stats->LumPerHour = v.LumPerHour; + stats->LumLast5Min = v.LumLast5Min; + stats->PassUpTracked = v.PassUpTracked ? 1 : 0; + stats->LumPassUp = v.LumPassUp; + stats->PassUpPerHour = v.PassUpPerHour; + stats->Kills = v.Kills; + stats->KillsPerHour = v.KillsPerHour; + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static void SessionReset() + { + try { Plugin?.SessionStatsForIlt?.RequestReset(); } + catch { } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs index 5520909..b646f40 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudController.cs @@ -22,7 +22,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; -using RynthCore.Plugin.RynthAi.IltHub; +using RynthCore.Plugin.RynthAi.MiniRemote; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.PluginSdk; @@ -83,7 +83,7 @@ internal sealed class HudController private volatile string _assignCandidate = string.Empty; public HudController(RynthCoreHost host, string charFolder, Func cache, - LegacyDashboardRenderer dashboard, Func hub, HudIconCache icons, Func attackTargetId) + LegacyDashboardRenderer dashboard, Func remote, HudIconCache icons, Func attackTargetId) { _host = host; _cache = cache; @@ -91,7 +91,7 @@ internal sealed class HudController State = _store.Load(); Icons = icons; Dashboard = dashboard; - Hub = hub; + Remote = remote; _itemHud = new ItemCountHud(this); _miniRemote = new MiniRemoteHud(this); _setup = new HudSetupUi(this); @@ -101,7 +101,7 @@ internal sealed class HudController public HudState State { get; } public HudIconCache Icons { get; } public LegacyDashboardRenderer Dashboard { get; } - public Func Hub { get; } + public Func Remote { get; } public RynthCoreHost Host => _host; /// The Mini Remote's session stats (the same SessionStats code as RynthTracker); null if it failed to start. @@ -510,7 +510,7 @@ internal sealed class HudController } /// - /// Puts the Mini Remote on tab ("" = the remote itself, else an ILT tab + /// Puts the Mini Remote on tab ("" = the remote itself, else a tab id: its own or RynthILT's /// id). Modes: "show" selects it and shows the Mini Remote (the floating one, unless RynthCore's /// window hosts it); "hide" goes back to the remote tab when this tab is the one selected; /// "toggle" does whichever undoes the current state; "select" only switches tabs (RynthCore's diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs index eaabf0d..5d4618f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/HudState.cs @@ -54,8 +54,8 @@ public sealed class HudState /// public float MiniRemoteSlotSize = DefaultMiniRemoteSlotSize; /// - /// The Mini Remote's selected tab: "" for the remote itself, else an ILT tab id - /// (IltSections.TabId: character, quests, pets, banking, gear, charms, games). + /// The Mini Remote's selected tab: "" for the remote itself, else a tab id: its own + /// (quests, pets) or RynthILT's (character, banking, gear, charms, games). /// public string MiniRemoteTab = string.Empty; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs index a4d2aa9..570f446 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/MiniRemoteHud.cs @@ -1,10 +1,11 @@ // MiniRemoteHud.cs — The Mini Remote (UtilityBelt-style) for RynthAi. Render thread only. // // One window with tabs: Remote (the sections below), the universal tabs Quests and Pets (every -// world), and on ILT worlds the ILT tabs Character, Banking, Gear and Games (IltHubUi draws -// their bodies; an ILT tab shows once the server reports its feature on). The tab bar's +// world, MiniRemote/), and on Infinite Leaftide the RynthILT plugin's ILT tabs (Character, +// Banking, Gear, Charms, Games: RynthILT.Hub GetTabs / RenderTab through IltClient; an ILT tab +// shows once the server reports its feature on, and never without RynthILT). The tab bar's // selection is saved (HudState.MiniRemoteTab) and "/ra hub open
" or RynthCore's -// dashboard switch it (RequestTab). The Guardian (ILT only) and Bounties are RynthCore ILT +// dashboard switch it (RequestTab). The Guardian and Bounties are RynthILT's RynthCore ILT // panels (the bar's ILT button). // Right-click on the remote: "Character" (Spells, Quests, Pets, Skills, Inventory, Item Count, // Inventory HUDs: windows every server has), then "Server: ", i.e. the installed server @@ -13,7 +14,7 @@ // The V/H button stacks the sections (vertical) or lays them out in three columns (horizontal). // // Remote sections (each can be hidden from the Options menu): -// Stats session time and per-hour XP / luminance / kills / coins / pyreals (ILT rates) +// Stats session time and per-hour XP / luminance / kills, plus coins / pyreals (RynthILT's rates on ILT) // Target the creature combat is attacking: name, health bar, distance // Pet the summon that is out (health bar, time left), else the next combat essence and // whether it is ready @@ -22,10 +23,10 @@ // inventory or the RynthCore Inventory window drop straight into a slot. Ctrl+wheel // over the grid (or Options > Slot size) grows / shrinks the boxes. // Toggles macro and subsystem switches (same as the dashboard buttons; not in the drawer) -// Bank ILT bank balances (pyreals, luminance, keys, coins) +// Bank ILT bank balances (pyreals, luminance, keys, coins; drawn by RynthILT) // Rebuff force rebuff / cancel rebuff // Translate chat translator on/off and the receive <-> send language swap -// Guardian the last Temple guardian answer with a Give button (only while it is recent) +// Guardian the last Temple guardian answer with a Give button (only while it is recent; RynthILT) // All game actions are posted to the pump thread. // // RenderEmbedded draws the same sections and Options menu inside the engine's RynthAi dashboard @@ -41,8 +42,9 @@ using System.Linq; using System.Numerics; using System.Threading; using ImGuiNET; -using RynthCore.Plugin.RynthAi.IltHub; using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.MiniRemote; +using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthAi.Huds; @@ -77,8 +79,11 @@ internal sealed class MiniRemoteHud private bool _onRemoteTab = true; // The Options button was clicked this frame (the popup opens at window level). private bool _openOptions; - // The ILT tabs offered this frame (reused, so a frame doesn't allocate). - private readonly List _tabs = new(); + /// One tab after Remote: a universal one (drawn here) or RynthILT's. + private readonly record struct TabEntry(string Id, string Label, Vector2 Size, bool Ilt); + + // The tabs offered this frame (reused, so a frame doesn't allocate). + private readonly List _tabs = new(); public MiniRemoteHud(HudController hud) => _hud = hud; @@ -86,7 +91,7 @@ internal sealed class MiniRemoteHud public void OnHidden() => _rescueChecked = false; /// - /// Switches to tab ("" = the remote, else an ILT tab id) on the next + /// Switches to tab ("" = the remote, else a tab id) on the next /// frame the tab bar draws. Any thread. /// public void RequestTab(string tab) @@ -113,7 +118,7 @@ internal sealed class MiniRemoteHud if (!visible) { ImGui.End(); return; } UiPlacement.RescueOncePerShow(ref _rescueChecked); - RenderBody(s, _hud.Hub(), allowTabs: true); + RenderBody(s, _hud.Remote(), allowTabs: true); // Right-click on the remote opens the Character / server menu, unless a slot's own menu is // open (the ILT tabs have their own right-click menus). @@ -141,7 +146,7 @@ internal sealed class MiniRemoteHud ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(4, 3)); try { - float width = RenderBody(s, _hud.Hub(), allowTabs: !InDrawer); + float width = RenderBody(s, _hud.Remote(), allowTabs: !InDrawer); if (_onRemoteTab && _slotMenuIndex < 0 && ImGui.IsWindowHovered(ImGuiHoveredFlags.ChildWindows) && ImGui.IsMouseReleased(ImGuiMouseButton.Right)) ImGui.OpenPopup(MenuPopup); @@ -163,22 +168,24 @@ internal sealed class MiniRemoteHud // ── Tabs ──────────────────────────────────────────────────────────────── /// - /// The tab bar (when : the universal tabs on every world, the ILT - /// tabs on ILT worlds) and the selected tab: the remote, or a tab's body in a child of its + /// The tab bar (when : the universal tabs on every world, RynthILT's + /// tabs on Infinite Leaftide) and the selected tab: the remote, or a tab's body in a child of its /// fixed size. Returns the width the content wants (never narrower than the tab bar's labels). /// - private float RenderBody(HudState s, IltHubController? hub, bool allowTabs) + private float RenderBody(HudState s, MiniRemoteController? remote, bool allowTabs) { _onRemoteTab = true; _tabs.Clear(); - if (allowTabs && hub != null) + if (allowTabs && remote != null) { - foreach (IltSection section in IltSections.Tabs) - if (hub.TabShown(section)) _tabs.Add(section); + foreach (string id in MiniRemoteTabs.Universal) + _tabs.Add(new TabEntry(id, MiniRemoteTabs.Label(id), MiniRemoteTabs.Size(id), Ilt: false)); + foreach (IltTabInfo t in remote.Ilt.Tabs()) + if (t.Shown) _tabs.Add(new TabEntry(t.Id, t.Label, new Vector2(t.Width, t.Height), Ilt: true)); } if (_tabs.Count == 0) { - RenderRemote(s, hub); + RenderRemote(s, remote); return EmbeddedWidth(s); } @@ -192,25 +199,24 @@ internal sealed class MiniRemoteHud _onRemoteTab = false; if (ImGui.BeginTabBar("##mrtabs", ImGuiTabBarFlags.FittingPolicyScroll | ImGuiTabBarFlags.NoTooltip)) { - if (BeginTab(RemoteTabLabel, TabFlags(IltSections.RemoteTab, pending))) + if (BeginTab(RemoteTabLabel, TabFlags(MiniRemoteTabs.Remote, pending))) { _onRemoteTab = true; - s.MiniRemoteTab = IltSections.RemoteTab; - RenderRemote(s, hub); + s.MiniRemoteTab = MiniRemoteTabs.Remote; + RenderRemote(s, remote); width = Math.Max(width, EmbeddedWidth(s)); ImGui.EndTabItem(); } - foreach (IltSection section in _tabs) + foreach (TabEntry tab in _tabs) { - string id = IltSections.TabId(section); - if (!BeginTab(TabLabels[(int)section], TabFlags(id, pending))) continue; - s.MiniRemoteTab = id; - Vector2 size = IltHubUi.TabSize(section); + if (!BeginTab(TabLabel(tab), TabFlags(tab.Id, pending))) continue; + s.MiniRemoteTab = tab.Id; // The tab draws into a child of its own size; tables in it scroll inside it. - ImGui.BeginChild(TabBodyIds[(int)section], size, ImGuiChildFlags.None, ImGuiWindowFlags.None); - hub!.RenderTab(section); + ImGui.BeginChild(TabBodyId(tab.Id), tab.Size, ImGuiChildFlags.None, ImGuiWindowFlags.None); + bool drawn = tab.Ilt ? remote!.Ilt.RenderTab(tab.Id) : remote!.RenderTab(tab.Id); + if (!drawn) ImGui.TextDisabled(tab.Ilt ? "RynthILT isn't drawing this tab (not loaded, or not ready yet)." : "Not ready."); ImGui.EndChild(); - width = Math.Max(width, size.X); + width = Math.Max(width, tab.Size.X); ImGui.EndTabItem(); } ImGui.EndTabBar(); @@ -218,17 +224,23 @@ internal sealed class MiniRemoteHud return width; } - // Tab labels as NUL-terminated UTF-8 and the tab body child ids, indexed by (int)IltSection, - // built once so the tab bar doesn't allocate per frame. + // Tab labels as NUL-terminated UTF-8 and the tab body child ids, built once per tab so the tab + // bar doesn't allocate per frame (RynthILT's tabs arrive by id at run time). private static readonly byte[] RemoteTabLabel = Utf8Z("Remote##mrtab"); - private static readonly byte[][] TabLabels = BuildPerSection(s => Utf8Z(IltSections.Label(s) + "##mrtab")); - private static readonly string[] TabBodyIds = BuildPerSection(s => "##mrtabbody_" + IltSections.TabId(s)); + private readonly Dictionary _tabLabels = new(StringComparer.Ordinal); + private readonly Dictionary _tabBodyIds = new(StringComparer.Ordinal); - private static T[] BuildPerSection(Func make) + private byte[] TabLabel(TabEntry tab) { - var result = new T[(int)IltSection.Guardian + 1]; - foreach (IltSection section in IltSections.Tabs) result[(int)section] = make(section); - return result; + string key = tab.Label + "##mrtab"; + if (!_tabLabels.TryGetValue(key, out byte[]? label)) _tabLabels[key] = label = Utf8Z(key); + return label; + } + + private string TabBodyId(string id) + { + if (!_tabBodyIds.TryGetValue(id, out string? body)) _tabBodyIds[id] = body = "##mrtabbody_" + id; + return body; } private static byte[] Utf8Z(string text) @@ -258,17 +270,17 @@ internal sealed class MiniRemoteHud { var style = ImGui.GetStyle(); float w = ImGui.CalcTextSize("Remote").X + style.FramePadding.X * 2f; - foreach (IltSection section in _tabs) - w += style.ItemInnerSpacing.X + ImGui.CalcTextSize(IltSections.Label(section)).X + style.FramePadding.X * 2f; + foreach (TabEntry tab in _tabs) + w += style.ItemInnerSpacing.X + ImGui.CalcTextSize(tab.Label).X + style.FramePadding.X * 2f; return w; } /// The Remote tab: the [V/H] [Options] row, then the sections in the chosen layout. - private void RenderRemote(HudState s, IltHubController? hub) + private void RenderRemote(HudState s, MiniRemoteController? remote) { RenderHeaderRow(s); - if (s.MiniRemoteHorizontal) RenderHorizontal(s, hub); - else RenderVertical(s, hub); + if (s.MiniRemoteHorizontal) RenderHorizontal(s, remote); + else RenderVertical(s, remote); } /// In the dashboard drawer (not the floating window or the engine's Mini Remote window). @@ -308,11 +320,11 @@ internal sealed class MiniRemoteHud if (ImGui.IsItemHovered()) ImGui.SetTooltip("Mini Remote settings: sections, layout, slot size.\nRight-click the remote for the Character and server windows."); } - private void RenderVertical(HudState s, IltHubController? hub) + private void RenderVertical(HudState s, MiniRemoteController? remote) { - RenderStatusSections(s, hub); + RenderStatusSections(s, remote); RenderActionSections(s); - RenderEconomySections(s, hub); + RenderEconomySections(s, remote); } /// @@ -321,14 +333,14 @@ internal sealed class MiniRemoteHud /// height; widgets sized from the available width would otherwise make the auto-resizing /// window grow every frame. /// - private void RenderHorizontal(HudState s, IltHubController? hub) + private void RenderHorizontal(HudState s, MiniRemoteController? remote) { float colW = ColumnWidth(s); _columnOpen = false; if (s.MiniShowStats || s.MiniShowTarget || s.MiniShowPet) { BeginColumn("##mrcolstatus", colW); - RenderStatusSections(s, hub); + RenderStatusSections(s, remote); ImGui.EndChild(); } if (s.MiniShowGems || ShowToggles(s)) @@ -340,7 +352,7 @@ internal sealed class MiniRemoteHud if (s.MiniShowBank || s.MiniShowRebuff || s.MiniShowTranslate || s.MiniShowGuardian) { BeginColumn("##mrcoleconomy", colW); - RenderEconomySections(s, hub); + RenderEconomySections(s, remote); ImGui.EndChild(); } } @@ -375,13 +387,13 @@ internal sealed class MiniRemoteHud private static void ResizeSlots(HudState s, float delta) => s.MiniRemoteSlotSize = Math.Clamp(SlotSize(s) + delta, HudState.MinMiniRemoteSlotSize, HudState.MaxMiniRemoteSlotSize); - private void RenderStatusSections(HudState s, IltHubController? hub) + private void RenderStatusSections(HudState s, MiniRemoteController? remote) { var combat = _hud.Combat; - if (s.MiniShowStats) RenderStats(hub); + if (s.MiniShowStats) RenderStats(remote); if (s.MiniShowTarget) RenderTarget(combat); - if (s.MiniShowPet) RenderPet(hub, combat); - if (s.MiniShowStats) RenderStatButtons(hub); + if (s.MiniShowPet) RenderPet(remote, combat); + if (s.MiniShowStats) RenderStatButtons(remote); } private void RenderActionSections(HudState s) @@ -390,17 +402,19 @@ internal sealed class MiniRemoteHud if (ShowToggles(s)) RenderToggles(_hud.Dashboard.Settings); } - private void RenderEconomySections(HudState s, IltHubController? hub) + private void RenderEconomySections(HudState s, MiniRemoteController? remote) { - if (s.MiniShowBank) RenderBank(hub); + // Bank and Guardian are RynthILT's (nothing is drawn off ILT or without it). + if (s.MiniShowBank) remote?.Ilt.RenderSection(RynthIltHub.SectionRemoteBank); if (s.MiniShowRebuff) RenderRebuff(); if (s.MiniShowTranslate && _hud.Translate is { } translate) translate.RenderHubSection(); - if (s.MiniShowGuardian && IltActive(hub)) hub!.Guardian.RenderRemoteLine(); + if (s.MiniShowGuardian) remote?.Ilt.RenderSection(RynthIltHub.SectionRemoteGuardian); } // ── Sections ──────────────────────────────────────────────────────────── - private static bool IltActive(IltHubController? hub) => hub != null && hub.Options.IsIltLikeWorld; + /// An Infinite Leaftide world, as RynthILT sees it (false without RynthILT). + private static bool IltActive(MiniRemoteController? remote) => remote != null && remote.Ilt.IsIltWorld; private static void Stat(string label, string value) { @@ -411,12 +425,12 @@ internal sealed class MiniRemoteHud /// /// Session stats on every world: the shared SessionStats (RynthTracker's code, so these match the - /// Tracker panel), plus ILT coins and pyreals. + /// Tracker panel), plus ILT coins and pyreals (RynthILT's rates). /// - private void RenderStats(IltHubController? hub) + private void RenderStats(MiniRemoteController? remote) { var v = _hud.SessionStats?.View ?? RynthCore.Plugin.Shared.SessionStatsView.Empty; - Stat("Time:", IltParse.Duration(TimeSpan.FromSeconds(SessionClock(v)))); + Stat("Time:", MiniRemoteText.Duration(TimeSpan.FromSeconds(SessionClock(v)))); Stat("XP:", HudDraw.Compact(v.XpPerHour) + "/h"); Stat("Lum:", HudDraw.Compact(v.LumPerHour) + "/h"); Stat("Lum 5m:", HudDraw.Compact(v.LumLast5Min)); @@ -424,15 +438,19 @@ internal sealed class MiniRemoteHud if (v.PassUpTracked) { Stat("Pass-up:", HudDraw.Compact(v.PassUpPerHour) + "/h"); - if (ImGui.IsItemHovered()) ImGui.SetTooltip($"{v.LumPassUp:N0} this session.\n{IltSessionRates.PassUpTooltip}"); + if (ImGui.IsItemHovered()) ImGui.SetTooltip($"{v.LumPassUp:N0} this session.\n{PassUpTooltip}"); } Stat("Kills:", HudDraw.Compact(v.KillsPerHour) + "/h"); - if (!IltActive(hub)) return; - var r = hub!.Rates.Summary; - Stat("Coins:", HudDraw.Compact(r.CoinsPerHour) + "/h"); - Stat("Pyr:", HudDraw.Compact(r.PyrealsPerHour) + "/h"); + if (remote == null || !remote.Ilt.TryGetRates(out double coins, out double pyreals)) return; + Stat("Coins:", HudDraw.Compact(coins) + "/h"); + Stat("Pyr:", HudDraw.Compact(pyreals) + "/h"); } + /// What the pass-up figure is (RynthILT's Character tab says the same). + private const string PassUpTooltip = + "Luminance that reached your bank without a \"You've banked\" line: your vassals' pass-up.\n" + + "Fellowship and Zone Share splits arrive the same silent way and are included."; + /// Seconds since the session started; 0 before it has (no login yet). private static double SessionClock(RynthCore.Plugin.Shared.SessionStatsView v) => ReferenceEquals(v, RynthCore.Plugin.Shared.SessionStatsView.Empty) @@ -452,29 +470,29 @@ internal sealed class MiniRemoteHud HealthBar("##mrtargethp", c.TargetHealth); } - /// The live summon when one is out, else the ILT Hub's next-essence line. - private static void RenderPet(IltHubController? hub, CombatHudSnapshot c) + /// The live summon when one is out, else the Pets tab's next-essence line (ILT worlds). + private static void RenderPet(MiniRemoteController? remote, CombatHudSnapshot c) { if (c.PetId != 0) { - RenderSummon(hub, c); + RenderSummon(remote, c); return; } - if (!IltActive(hub)) { ImGui.TextDisabled("Summon: none"); return; } - string name = hub!.Pets.HudPetName; - string status = hub.Pets.HudPetStatus; + if (!IltActive(remote)) { ImGui.TextDisabled("Summon: none"); return; } + string name = remote!.Pets.HudPetName; + string status = remote.Pets.HudPetStatus; if (name.Length == 0) { ImGui.TextDisabled("No combat pet set"); return; } ImGui.TextUnformatted(name); var col = status switch { "Ready" => ColReady, "Out" => ColOut, "Healing" => ColBusy, _ => ColEmpty }; ImGui.TextColored(col, status); } - private static void RenderSummon(IltHubController? hub, CombatHudSnapshot c) + private static void RenderSummon(MiniRemoteController? remote, CombatHudSnapshot c) { ImGui.TextColored(ColLabel, "Summon:"); ImGui.SameLine(); ImGui.TextUnformatted(c.PetName); - if (IltActive(hub) && hub!.Pets.HudPetStatus == "Healing") + if (IltActive(remote) && remote!.Pets.HudPetStatus == "Healing") { ImGui.SameLine(); ImGui.TextColored(ColBusy, "Healing"); @@ -528,7 +546,7 @@ internal sealed class MiniRemoteHud ImGui.PopStyleColor(); } - private void RenderStatButtons(IltHubController? hub) + private void RenderStatButtons(MiniRemoteController? remote) { float w = (ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X) * 0.5f; w = Math.Max(w, 70f); @@ -536,7 +554,7 @@ internal sealed class MiniRemoteHud _hud.Post(() => { _hud.SessionStats?.RequestReset(); - _hud.Hub()?.Rates.Reset(); + _hud.Remote()?.Ilt.Command("rates reset"); // RynthILT's coin / pyreal session too }); if (ImGui.IsItemHovered()) ImGui.SetTooltip("Start the session stats over (the Tracker panel keeps its own session)."); ImGui.SameLine(); @@ -548,17 +566,13 @@ internal sealed class MiniRemoteHud private void ReportToChat() { var v = _hud.SessionStats?.View ?? RynthCore.Plugin.Shared.SessionStatsView.Empty; - string time = IltParse.Duration(TimeSpan.FromSeconds(SessionClock(v))); + string time = MiniRemoteText.Duration(TimeSpan.FromSeconds(SessionClock(v))); string line = $"[RynthAi] Session {time}: XP {HudDraw.Compact(v.XpPerHour)}/h, Lum {HudDraw.Compact(v.LumPerHour)}/h " + $"({HudDraw.Compact(v.LumLast5Min)} last 5m)"; if (v.PassUpTracked) line += $", Pass-up {HudDraw.Compact(v.PassUpPerHour)}/h"; line += $", Kills {HudDraw.Compact(v.KillsPerHour)}/h ({v.Kills:N0})"; - var hub = _hud.Hub(); - if (IltActive(hub)) - { - var r = hub!.Rates.Summary; - line += $", Coins {HudDraw.Compact(r.CoinsPerHour)}/h, Pyr {HudDraw.Compact(r.PyrealsPerHour)}/h"; - } + if (_hud.Remote()?.Ilt.TryGetRates(out double coins, out double pyreals) == true) + line += $", Coins {HudDraw.Compact(coins)}/h, Pyr {HudDraw.Compact(pyreals)}/h"; _hud.Chat(line); } @@ -694,23 +708,6 @@ internal sealed class MiniRemoteHud if (ImGui.Checkbox(label + "##mrt", ref v)) _hud.Post(() => apply(v)); } - private static void RenderBank(IltHubController? hub) - { - if (!IltActive(hub) || hub!.Options.IsOff(IltFeature.Bank)) return; - var b = hub.State.Bank; - if (b.LastUpdated == DateTime.MinValue) { ImGui.TextDisabled("Bank: not loaded (Options > Banking)"); return; } - Stat("P:", HudDraw.Compact(b.Pyreals)); - Stat("Lum:", HudDraw.Compact(b.Luminance)); - if (!ImGui.BeginTable("##mrbank", 2, ImGuiTableFlags.SizingStretchSame)) return; - ImGui.TableNextColumn(); Stat("LK:", HudDraw.Compact(b.LegendaryKeys)); - ImGui.TableNextColumn(); Stat("MK:", HudDraw.Compact(b.MythicalKeys)); - ImGui.TableNextColumn(); Stat("EC:", HudDraw.Compact(b.EnlightenedCoins)); - ImGui.TableNextColumn(); Stat("WE:", HudDraw.Compact(b.WeaklyEnlightenedCoins)); - // Prestige Coins (ACECustom 2026-10-04): only once the server has reported some. - if (b.PrestigeCoins > 0) { ImGui.TableNextColumn(); Stat("PC:", HudDraw.Compact(b.PrestigeCoins)); } - ImGui.EndTable(); - } - private void RenderRebuff() { var dash = _hud.Dashboard; @@ -787,7 +784,7 @@ internal sealed class MiniRemoteHud // ── Right-click menu: Character, then this server's plugin windows ───────── - /// RynthCore's server id for Infinite Leaftide (UI/ServerMenus.cs), the one RynthAi has features for. + /// RynthCore's server id for Infinite Leaftide (UI/ServerMenus.cs), the one RynthILT has tabs for. private const string IltServerId = "ilt"; /// @@ -802,7 +799,7 @@ internal sealed class MiniRemoteHud try { RenderCharacterMenu(s); - RenderServerMenu(_hud.Hub()); + RenderServerMenu(_hud.Remote()); } finally { ImGui.EndPopup(); } } @@ -818,11 +815,9 @@ internal sealed class MiniRemoteHud if (ImGui.MenuItem("Spells##mrspells", "/ra spells", settings.ShowSpellsWindow)) settings.ShowSpellsWindow = !settings.ShowSpellsWindow; if (ImGui.IsItemHovered()) ImGui.SetTooltip("The spell catalog and buff profiles."); - foreach (IltSection section in IltSections.Tabs) + foreach (string id in MiniRemoteTabs.Universal) { - if (!IltSections.IsUniversal(section)) continue; - string id = IltSections.TabId(section); - if (ImGui.MenuItem(IltSections.Label(section) + "##mrchar_" + id, "/ra hub open " + id)) + if (ImGui.MenuItem(MiniRemoteTabs.Label(id) + "##mrchar_" + id, "/ra hub open " + id)) _hud.HandleTabCommand(id, "show"); } if (_hud.Host.HasInvokeChatParser) @@ -836,15 +831,15 @@ internal sealed class MiniRemoteHud /// /// The server section. Each section RynthCore marks active is listed, and so is Infinite - /// Leaftide while this character's "Treat this world as ILT" is on (RynthAi's own override). - /// Without RynthCore's list it falls back to RynthAi's ILT entries. + /// Leaftide while this character's "Treat this world as ILT" is on (RynthILT's override). + /// Without RynthCore's list it falls back to RynthILT's own ILT entries. /// - private void RenderServerMenu(IltHubController? hub) + private void RenderServerMenu(MiniRemoteController? remote) { ServerMenuGroup[]? groups = ServerMenuModel.Groups; if (groups == null) { - RenderLocalIltMenu(hub); + remote?.Ilt.RenderSection(RynthIltHub.SectionServerMenu); return; } if (groups.Length == 0) return; // no server plugin installed @@ -853,7 +848,7 @@ internal sealed class MiniRemoteHud foreach (ServerMenuGroup g in groups) { bool ilt = g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase); - bool forcedHere = ilt && hub?.ForceIltWorld == true; + bool forcedHere = ilt && remote?.Ilt.ForceIlt == true; if (!g.Active && !forcedHere) continue; any = true; ImGui.Separator(); @@ -862,14 +857,14 @@ internal sealed class MiniRemoteHud { string? tab = ServerMenuModel.TabOf(item.Feature); // Universal tabs are under Character; RynthCore 2026.10.5.30 and older list them here too. - if (tab != null && IltSections.TryParse(tab, out IltSection listed) && IltSections.IsUniversal(listed)) continue; - bool enabled = tab == null || TabAvailable(hub, tab); + if (tab != null && MiniRemoteTabs.Parse(tab) != null) continue; + bool enabled = tab == null || TabAvailable(remote, tab); if (ImGui.MenuItem(item.Label + "##mrsrv_" + g.Id, item.Command, false, enabled)) RunServerItem(item, tab); if (item.Tooltip.Length > 0 && ImGui.IsItemHovered(ImGuiHoveredFlags.AllowWhenDisabled)) ImGui.SetTooltip(enabled ? item.Tooltip : item.Tooltip + "\nShows once the server reports this feature on."); } - if (ilt) RenderIltStatus(hub); + if (ilt) remote?.Ilt.RenderSection(RynthIltHub.SectionIltStatus); } if (any) return; @@ -879,7 +874,7 @@ internal sealed class MiniRemoteHud { if (g.ForceCommand.Length == 0) continue; if (ImGui.MenuItem("Treat this world as " + g.Name + "##mrforce_" + g.Id, g.ForceCommand)) - ForceServer(g, hub); + ForceServer(g, remote); if (ImGui.IsItemHovered()) ImGui.SetTooltip("Shows this server's windows here anyway. It only says which world this is:\nthe server still decides which features exist."); } @@ -894,55 +889,21 @@ internal sealed class MiniRemoteHud /// /// Forces a server: RynthCore's session override, plus for Infinite Leaftide this character's - /// "Treat this world as ILT" (so RynthAi's tabs come too). + /// "Treat this world as ILT" (so RynthILT's tabs come too). /// - private void ForceServer(ServerMenuGroup g, IltHubController? hub) + private void ForceServer(ServerMenuGroup g, MiniRemoteController? remote) { - if (g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase) && hub != null) hub.ForceIltWorld = true; + if (g.Id.Equals(IltServerId, StringComparison.OrdinalIgnoreCase) && remote != null) remote.Ilt.ForceIlt = true; _hud.RunEngineCommand(g.ForceCommand); } - private static bool TabAvailable(IltHubController? hub, string tab) => - hub != null && IltSections.TryParse(tab, out IltSection section) && IltSections.IsTab(section) && hub.SectionAvailable(section); - - /// - /// RynthAi's own Infinite Leaftide entries, for when RynthCore sends no server list (older - /// RynthCore, or its ImGui layer off): the tabs, and the Guardian / Bounties panels. - /// - private void RenderLocalIltMenu(IltHubController? hub) + /// RynthILT reports that ILT tab's feature on (false without RynthILT). + private static bool TabAvailable(MiniRemoteController? remote, string tab) { - if (hub == null || !hub.OffersTabs) return; - ImGui.Separator(); - ImGui.TextDisabled("Server: Infinite Leaftide"); - foreach (IltSection section in IltSections.Tabs) - { - if (IltSections.IsUniversal(section)) continue; // under Character - if (ImGui.MenuItem(IltSections.Label(section) + "##mrlocal", string.Empty, false, hub.SectionAvailable(section))) - _hud.HandleTabCommand(IltSections.TabId(section), "show"); - } - if (ImGui.MenuItem("Guardian##mrlocal", "/rc guardian", false, hub.SectionAvailable(IltSection.Guardian))) - _hud.Post(() => hub.OpenEnginePanel("guardian", "Guardian", "show")); - if (ImGui.MenuItem("Bounties##mrlocal", "/rc bounties")) - _hud.Post(() => hub.OpenEnginePanel("bounties", "Bounties", "show")); - RenderIltStatus(hub); - } - - /// - /// Under the Infinite Leaftide section while no ILT feature is on: why, this character's - /// "Treat this world as ILT" override and a server-features refresh. - /// - private static void RenderIltStatus(IltHubController? hub) - { - if (hub == null || hub.Available) return; - var o = hub.Options; - ImGui.TextDisabled(!o.IsIltLikeWorld ? "Not an ILT world." - : o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue ? "Checking server features..." - : "No ILT features reported."); - bool force = hub.ForceIltWorld; - if (ImGui.Checkbox("Treat this world as ILT##mrforce", ref force)) hub.ForceIltWorld = force; - if (ImGui.IsItemHovered()) - ImGui.SetTooltip("World-identity override only: RynthAi asks the server which features exist.\nIt never turns a feature on by itself."); - if (ImGui.MenuItem("Refresh server features##mrrefresh")) hub.RequestOptionsRefresh(); + if (remote == null) return false; + foreach (IltTabInfo t in remote.Ilt.Tabs()) + if (string.Equals(t.Id, tab, StringComparison.OrdinalIgnoreCase)) return t.Available; + return false; } private static void Flag(string label, ref bool value) diff --git a/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs b/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs index 875fff0..9b2c0b6 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Huds/ServerMenuModel.cs @@ -7,7 +7,7 @@ // command), then its items ("I", label, command, tooltip, feature). // // Groups stays null until the first push: an older RynthCore, or the ImGui shell off. The menu -// then falls back to RynthAi's own ILT entries. +// then falls back to RynthILT's own ILT entries (RynthILT.Hub section "server-menu"). using System; using System.Collections.Generic; using System.Threading; diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs b/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs deleted file mode 100644 index 05bfb02..0000000 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubUi.cs +++ /dev/null @@ -1,234 +0,0 @@ -// IltHubUi.cs — The ILT sections' ImGui bodies (render thread only). -// -// The ILT sections are tabs of the Mini Remote (MiniRemoteHud draws the tab bar and calls -// RenderTab): Character (world status, Force-ILT, profiles, session rates), Quests (IltQuests), -// Pets, Banking, Gear, Charms and Games. A tab is offered only while the server reports its feature on. -// The Guardian (IltGuardian: Temple riddle translator, hand-in, attribute turn-in tracker) is a -// RynthCore ILT panel instead (the bar's ILT button, next to Bounties), drawn through -// RenderGuardianPanel. Render() keeps the floating extras: the Games HUD, the quest favorites HUD -// and the confirmation modal. Augmentations / Enlightenment / XP planning live on the engine -// Skills panel. All AC actions go through IltHubContext.Post / Confirm so nothing here touches -// the game directly. -using System; -using System.Numerics; -using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; - -namespace RynthCore.Plugin.RynthAi.IltHub; - -internal sealed class IltHubUi -{ - private const string ConfirmPopupId = "Confirm##iltconfirm"; - - private readonly IltHubController _hub; - private readonly IltHubContext _ctx; - private IltConfirmRequest? _confirm; - private bool _confirmOpened; - private string _profileName = string.Empty; - private bool _profileShared; - private string[] _profileList = Array.Empty(); - private int _profileIdx; - // The last tab body drawn (for one shown log event per tab change); -1 = none yet. - private int _lastTabLogged = -1; - - public IltHubUi(IltHubController hub, IltHubContext ctx) - { - _hub = hub; - _ctx = ctx; - } - - /// The floating extras: Games HUD, quest favorites HUD and the confirmation modal. - public void Render() - { - _hub.Games.RenderHud(); - _hub.Quests.RenderFloatingWindows(); - RenderConfirm(); - } - - /// - /// Size of a Mini Remote tab's body (the old section window's default size): the tab draws in a - /// child this big, and the Mini Remote (or the engine window hosting it) fits to it. - /// - public static Vector2 TabSize(IltSection section) => section switch - { - IltSection.Character => new Vector2(520, 440), - IltSection.Quests => new Vector2(700, 500), - IltSection.Pet => new Vector2(560, 580), - IltSection.Banking => new Vector2(560, 520), - IltSection.Gear => new Vector2(560, 520), - IltSection.Charms => new Vector2(560, 520), - IltSection.Games => new Vector2(520, 440), - _ => new Vector2(520, 440), - }; - - /// Draws one Mini Remote ILT tab's body into the current (child) window. - public void RenderTab(IltSection section) - { - if ((int)section != _lastTabLogged) - { - _lastTabLogged = (int)section; - RynthLog.Event(LogEvents.IltWindowShown, $"{IltSections.Label(section)} tab shown (world='{_ctx.Options.WorldName}', available={_hub.Available})"); - } - switch (section) - { - case IltSection.Character: RenderCharacterBody(); break; - case IltSection.Quests: _hub.Quests.RenderTab(); break; - case IltSection.Pet: _hub.Pets.Render(); break; - case IltSection.Banking: _hub.Banking.Render(); break; - case IltSection.Gear: _hub.Gear.Render(); break; - case IltSection.Charms: _hub.CharmsTab.Render(); break; - case IltSection.Games: _hub.Games.Render(); break; - } - } - - /// - /// The Guardian panel's body (RynthCore's ILT Guardian panel, RynthPluginRenderEmbed - /// "guardian"), or why it's idle while the server hasn't reported ILT features. - /// - public void RenderGuardianPanel() - { - if (!_hub.SectionAvailable(IltSection.Guardian)) - { - RenderHeader(); - ImGui.Separator(); - RenderUnavailable(); - return; - } - _hub.Guardian.Render(); - } - - /// Character tab: world / options header, then session rates (or why the ILT tabs are idle). - private void RenderCharacterBody() - { - RenderHeader(); - ImGui.Separator(); - if (!_hub.Available) { RenderUnavailable(); return; } - if (ImGui.CollapsingHeader("Session rates", ImGuiTreeNodeFlags.DefaultOpen)) _hub.Rates.Render(); - ImGui.Spacing(); - ImGui.TextDisabled("XP planner, Augmentations and Enlightenment are on the Skills panel's Progression tab"); - ImGui.TextDisabled("(right-click the dashboard's Char button > Progression)."); - } - - private void RenderHeader() - { - var o = _ctx.Options; - string world = o.WorldName.Length > 0 ? o.WorldName : "unknown world"; - ImGui.TextColored(o.IsIltLikeWorld ? LegacyDashboardRenderer.ColTeal : LegacyDashboardRenderer.ColTextMute, world); - ImGui.SameLine(); - ImGui.TextDisabled(o.IsRefreshing ? "checking server options..." - : o.LastRefreshUtc == DateTime.MinValue ? "server options not checked yet" - : $"options via {o.Source} @ {o.LastRefreshUtc.ToLocalTime():t}"); - ImGui.SameLine(); - if (ImGui.SmallButton("Refresh##opts")) _ctx.Post(() => o.Refresh(manual: true)); - - bool force = _ctx.State.ForceLeaftideFeatures; - if (ImGui.Checkbox("Treat this world as ILT", ref force)) _ctx.State.ForceLeaftideFeatures = force; - if (ImGui.IsItemHovered()) - ImGui.SetTooltip("World-identity override only: the Mini Remote asks the server which ILT features exist.\nIt never turns a feature on by itself."); - ImGui.SameLine(); - if (ImGui.SmallButton("Profiles...")) { ImGui.OpenPopup("##iltprofiles"); _ctx.Post(() => _profileList = _ctx.Store.ListProfiles().ToArray()); } - RenderProfilesPopup(); - } - - private void RenderProfilesPopup() - { - if (!ImGui.BeginPopup("##iltprofiles")) return; - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "ILT profiles (settings only; no balances)"); - ImGui.SetNextItemWidth(180); - ImGui.InputTextWithHint("##profname", "profile name", ref _profileName, 64u); - ImGui.SameLine(); - ImGui.Checkbox("shared", ref _profileShared); - ImGui.SameLine(); - if (ImGui.SmallButton("Save")) - { - string n = _profileName; bool sh = _profileShared; - _ctx.Post(() => - { - _ctx.Chat(_ctx.Store.SaveProfile(_ctx.State, n, sh, out string err) ? $"[Mini Remote] Saved profile '{n}'." : "[Mini Remote] Save failed: " + err); - _profileList = _ctx.Store.ListProfiles().ToArray(); - }); - } - var list = _profileList; - if (list.Length > 0) - { - _profileIdx = Math.Clamp(_profileIdx, 0, list.Length - 1); - ImGui.SetNextItemWidth(180); - ImGui.Combo("##proflist", ref _profileIdx, list, list.Length); - ImGui.SameLine(); - if (ImGui.SmallButton("Load")) - { - string n = list[_profileIdx]; - _ctx.Confirm("Load ILT profile", $"Replace the current ILT settings with profile '{n}'?", - () => _ctx.Chat(_ctx.Store.LoadProfile(_ctx.State, n, out string err) ? $"[Mini Remote] Loaded profile '{n}'." : "[Mini Remote] Load failed: " + err), - "Load"); - } - } - else ImGui.TextDisabled("No saved profiles."); - ImGui.EndPopup(); - } - - private void RenderUnavailable() - { - var o = _ctx.Options; - if (!o.IsIltLikeWorld) - { - ImGui.TextWrapped("This is not an Infinite Leaftide / ACECustom world, so the ILT tabs are idle. " - + "If this shard runs ACECustom under another name, tick 'Treat this world as ILT' and press Refresh."); - } - else if (o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue) - { - ImGui.TextWrapped("Checking which ILT features this server has enabled..."); - } - else - { - ImGui.TextWrapped("The server did not report any ILT features as enabled. Press Refresh to check again."); - } - } - - // ── Confirmation modal ────────────────────────────────────────────────── - - private void RenderConfirm() - { - if (_confirm == null) - { - if (!_ctx.TryTakeConfirm(out var next)) return; - _confirm = next; - _confirmOpened = false; - } - if (!_confirmOpened) - { - ImGui.OpenPopup(ConfirmPopupId); - _confirmOpened = true; - } - - ImGui.SetNextWindowSize(new Vector2(420, 0), ImGuiCond.Appearing); - bool keepOpen = true; - if (ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize)) - { - ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _confirm.Title); - ImGui.Separator(); - ImGui.TextWrapped(_confirm.Message); - ImGui.Spacing(); - if (ImGui.Button(_confirm.YesLabel + "##iltyes", new Vector2(120, 0))) - { - var act = _confirm.OnYes; - if (act != null) _ctx.Post(act); - _confirm = null; - ImGui.CloseCurrentPopup(); - } - ImGui.SameLine(); - if (ImGui.Button("Cancel##iltno", new Vector2(120, 0))) - { - _confirm = null; - ImGui.CloseCurrentPopup(); - } - ImGui.EndPopup(); - } - else - { - // Closed with the title-bar X (or never opened): treat as cancel. - _confirm = null; - } - if (!keepOpen) _confirm = null; - } -} diff --git a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs index e3c4a94..b49f8c9 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/ItemInfo/MagItemDescriber.cs @@ -4,7 +4,7 @@ // Applied: Steel x2, 152-236, 0.35v, +18%a, +12%md, Legendary Blood Thirst, Wield Lvl 180, // Heavy Weapons 375, Diff 270, Craft 8, [D 3, CD 2] // -// The same fields can also print as the pet-roster layout (IltPetStats: identity line, stats +// The same fields can also print as the pet-roster layout (MiniRemote/PetStats: identity line, stats // line, ratings/requirements line), plus a spells line: // // Gold Ornate Long Sword (Slash Sword), Noble Relic Set, Tinks 4, Applied: Steel x2, Craft 8 diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs index 325a6a2..ece73dd 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyAdvancedSettingsUi.cs @@ -12,7 +12,6 @@ internal sealed class LegacyAdvancedSettingsUi // Scratch buffer for the "never attack" name entry box. private string _newBlacklistName = ""; // Server Features list being edited (committed on Enter / focus loss); null = show the saved list. - private string? _serverNamesEdit; private static readonly string[] AttackHeights = { "Low", "Medium", "High" }; private static readonly string[] NavLabelModeNames = { "Off", "Numbers", "Numbers and names" }; @@ -84,35 +83,6 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.End(); } - /// Settings > Misc "Server Features": the world list and the manual override (ServerFeatureGate). - private void RenderServerFeatures() - { - ImGui.Text("Server Features (ILT / infinite attributes)"); - ImGui.TextDisabled(IltHub.ServerFeatureGate.Describe(_settings)); - - string text = _serverNamesEdit ?? IltHub.ServerFeatureGate.FormatList(_settings.FeatureServerNames); - ImGui.SetNextItemWidth(320); - bool enter = ImGui.InputTextWithHint("Servers##featureServers", "InfiniteLeaftide, *Leaftide*", ref text, 512, - ImGuiInputTextFlags.EnterReturnsTrue); - if (ImGui.IsItemActive() || enter) _serverNamesEdit = text; - if ((enter || ImGui.IsItemDeactivatedAfterEdit()) && _serverNamesEdit != null) - { - _settings.FeatureServerNames = IltHub.ServerFeatureGate.ParseList(_serverNamesEdit); - _serverNamesEdit = null; - } - else if (!ImGui.IsItemActive()) _serverNamesEdit = null; - if (ImGui.IsItemHovered()) - ImGui.SetTooltip("Comma-separated world names that turn on the Mini Remote's ILT tabs, the Progression\n" + - "planners and the attribute raiser. * is a wildcard (*Leaftide* matches any\n" + - "name containing Leaftide). Case does not matter."); - - ImGui.Checkbox("Force enable on this server (manual override)", ref _settings.ForceServerFeatures); - if (ImGui.IsItemHovered()) - ImGui.SetTooltip("Turn the features on for whatever world you are on, even if it is not in the list.\n" + - "Each feature still follows what the server reports (for example /xp off keeps\n" + - "the attribute raiser off)."); - } - private void RenderVendoring() { ImGui.Text("AutoVendor (UtilityBelt)"); @@ -324,9 +294,6 @@ internal sealed class LegacyAdvancedSettingsUi ImGui.SetTooltip("When acid or lava hurts you, stop everything (combat, buffs, healing, looting)\nand walk back out the way you came. The spot is remembered so the patrol avoids it.\nTurn off for a character that walks through acid on purpose."); ImGui.Checkbox("Enable Raycasting", ref _settings.EnableRaycasting); - ImGui.Separator(); - ImGui.Spacing(); - RenderServerFeatures(); ImGui.Separator(); ImGui.Spacing(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs index 54bd732..2a5c87a 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.LocalFeatures.cs @@ -1,5 +1,5 @@ // LegacyDashboardRenderer.LocalFeatures.cs — style shared with the plugin's own ImGui windows -// (ILT Hub, floating HUDs, chat translator). +// (the Mini Remote and its tabs, floating HUDs, chat translator). using System.Numerics; using ImGuiNET; diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs index 9e7fe4c..fb8958f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyDashboardRenderer.cs @@ -7,7 +7,6 @@ using System.Numerics; using System.Text.Json; using RynthCore.PluginSdk; using RynthCore.Plugin.RynthAi; -using RynthCore.Plugin.RynthAi.Diagnostics; using RynthCore.Plugin.RynthAi.Meta; using RynthCore.Plugin.Shared; @@ -1003,9 +1002,6 @@ internal sealed partial class LegacyDashboardRenderer StartMacroOnLogin = s.StartMacroOnLogin, PatrolOnLogin = s.PatrolOnLogin, YieldToVTank = s.YieldToVTank, - FeatureServerNames = IltHub.ServerFeatureGate.FormatList(s.FeatureServerNames), - ForceServerFeatures = s.ForceServerFeatures, - ServerFeaturesStatus = IltHub.ServerFeatureGate.Describe(s), EnableRaycasting = s.EnableRaycasting, UseArcs = s.UseArcs, BowArcVelocity = s.BowArcVelocity, @@ -1235,9 +1231,6 @@ internal sealed partial class LegacyDashboardRenderer s.StartMacroOnLogin = p.StartMacroOnLogin; s.PatrolOnLogin = p.PatrolOnLogin; s.YieldToVTank = p.YieldToVTank; - if (p.FeatureServerNames != null) - s.FeatureServerNames = IltHub.ServerFeatureGate.ParseList(p.FeatureServerNames); - s.ForceServerFeatures = p.ForceServerFeatures; s.EnableRaycasting = p.EnableRaycasting; s.UseArcs = p.UseArcs; s.BowArcVelocity = p.BowArcVelocity; @@ -1924,7 +1917,7 @@ internal sealed partial class LegacyDashboardRenderer dst.StartMacroOnLogin = tmp.StartMacroOnLogin; dst.PatrolOnLogin = tmp.PatrolOnLogin; dst.YieldToVTank = tmp.YieldToVTank; - dst.FeatureServerNames = tmp.FeatureServerNames ?? new(IltHub.ServerFeatureGate.DefaultServerNames); + dst.FeatureServerNames = tmp.FeatureServerNames; dst.ForceServerFeatures = tmp.ForceServerFeatures; dst.ShowTerrainPassability = tmp.ShowTerrainPassability; dst.NavLabelMode = NavLabelModes.Clamp(tmp.NavLabelMode); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs index 374c4d4..958ee0d 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyItemInfoUi.cs @@ -156,7 +156,7 @@ internal sealed class LegacyItemInfoUi s.Sanitize(); if (ImGui.IsItemHovered()) ImGui.SetTooltip( - "Pet-style lines (like the ILT Hub pet roster):\n" + + "Pet-style lines (like the Mini Remote's Pets roster):\n" + " 1 Name (type mastery), set, AL, tinks, applied, craft\n" + " 2 imbues, slayer, damage, variance, %a / %md / %mc\n" + " 3 [ratings] wield / activation / diff, value\n" + diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs index 140f3c7..b55ec10 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyMetaUi.cs @@ -1239,7 +1239,7 @@ internal sealed class LegacyMetaUi } lock (_settings.MetaRulesLock) - RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the meta", path, + RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the meta", path, () => AfFileWriter.Save(path, _settings.MetaRules, _settings.EmbeddedNavs)); } catch { } @@ -1260,7 +1260,7 @@ internal sealed class LegacyMetaUi bool saved; string why; lock (_settings.MetaRulesLock) - saved = RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the meta", filePath, + saved = RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the meta", filePath, () => AfFileWriter.Save(filePath, _settings.MetaRules, _settings.EmbeddedNavs), out why); if (!saved) { diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs index 591e743..507ff6f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyNavigationUi.cs @@ -278,7 +278,7 @@ internal sealed class LegacyNavigationUi else { NavRouteParser route = _settings.CurrentRoute; - RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the nav", path, () => route.Save(path)); + RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the nav", path, () => route.Save(path)); } } catch (Exception ex) { _host.Log($"[RynthAi] Nav auto-save to {path} failed: {ex.Message}"); } @@ -319,7 +319,7 @@ internal sealed class LegacyNavigationUi } string target = path; - if (!RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the nav", target, () => route.Save(target), out string why, callerShows: true)) + if (!RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the nav", target, () => route.Save(target), out string why, callerShows: true)) return $"[RynthAi] Nav NOT saved to {target}: {why}"; _settings.CurrentNavPath = path; return $"[RynthAi] Saved {route.Points.Count} waypoints to {Path.GetFileName(path)}."; diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs index 62d76f7..155eefd 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacySpellsUi.cs @@ -698,7 +698,7 @@ internal sealed unsafe class LegacySpellsUi private void SaveTo(string path, bool thenActivate) { - if (!RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.TrySave("the buff profile", path, + if (!RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the buff profile", path, () => BuffProfileStore.Save(_edit, path), out string why)) { SetStatus($"Save failed: {why}", warning: true); diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs index 8f5ff23..e0f2c6f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/LegacyUiSettings.cs @@ -13,8 +13,6 @@ public static class DashWindows public static bool ShowWeapons; public static bool ShowLua; public static bool ShowDungeonMap; - /// ILT Hub window (persisted in ilt-hub.json, not in the combat profile). - public static bool ShowIltHub; } public sealed class LegacyUiSettings @@ -351,12 +349,13 @@ public sealed class LegacyUiSettings public bool YieldToVTank = true; /// - /// Server Features (Settings > Misc): world names that turn on the ILT Hub, the Skills - /// panel's Progression planners and the attribute raiser ('*' wildcard, case-insensitive). - /// See IltHub/ServerFeatureGate. A profile saved before this existed loads the defaults. + /// Legacy (unused by RynthAi since 2026-10-13): the old Settings > Misc "Server Features" list + /// that turned on the ILT Hub. The ILT features moved to the RynthILT plugin, which keeps its + /// own list and reads these two fields once, on a character's first login with it + /// (IltMigration). Kept so a profile still carries them until then; no UI, no bridge. /// - public List FeatureServerNames { get; set; } = new(IltHub.ServerFeatureGate.DefaultServerNames); - /// Manual override: treat the current world as feature-enabled whatever its name. + public List? FeatureServerNames { get; set; } + /// Legacy (see ): the old "Force enable on this server" override. public bool ForceServerFeatures; public int BlacklistAttempts = 3; @@ -963,11 +962,6 @@ public sealed class SettingsBridgePayload public float? DunPatrolLookInSize { get; set; } // Absent from an older engine's payload: must not read as off. public bool YieldToVTank { get; set; } = true; - // Server Features: the list travels as one comma-separated string (the engine's text row). - public string FeatureServerNames { get; set; } = string.Join(", ", IltHub.ServerFeatureGate.DefaultServerNames); - public bool ForceServerFeatures { get; set; } - // Read-only status line for Settings > Misc (ignored when the engine sends it back). - public string ServerFeaturesStatus { get; set; } = string.Empty; public bool EnableRaycasting { get; set; } public bool UseArcs { get; set; } public float BowArcVelocity { get; set; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs index f6ded28..00739cc 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/LegacyUi/RynthAiJsonContext.cs @@ -17,15 +17,14 @@ namespace RynthCore.Plugin.RynthAi; [JsonSerializable(typeof(MetaRuleDto))] [JsonSerializable(typeof(MetaCommand))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Meta.MetaScheduleConfig))] -// UB seed, translation, diagnostics, ILT Hub, HUD and item info files persist through this +// UB seed, translation, diagnostics, Mini Remote, HUD and item info files persist through this // context (NativeAOT cannot reflect). [JsonSerializable(typeof(RynthCore.CreatureSeed.UbMobSeedFile))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Translate.TranslateSettings))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.RynthLogConfig))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.Huds.HudState))] -[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.IltHub.IltHubState))] -[JsonSerializable(typeof(System.Collections.Generic.List), TypeInfoPropertyName = "IltBankTransactionList")] -[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.IltHub.IltAugCostFile))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteState))] +[JsonSerializable(typeof(RynthCore.Plugin.RynthAi.MiniRemote.LegacyIltHubFile))] [JsonSerializable(typeof(RynthCore.Plugin.RynthAi.BuffProfile))] [JsonSourceGenerationOptions( WriteIndented = true, diff --git a/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs b/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs index d9724ee..6196513 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Loot/LootEditorBridge.cs @@ -270,13 +270,13 @@ internal sealed class LootEditorBridge /// /// A save the disk refused (folder not writable, file in use, ...): the editor shows the /// session's message; this adds the chat line (once per folder) and the log line with the - /// reason and the fix (Diagnostics/DataWriteGuard, 2026-10-13). + /// reason and the fix (Plugins/Shared/DataWriteGuard.cs, 2026-10-13). /// private static void ReportWriteError(LootEditSession session) { Exception? error = session.TakeWriteError(); if (error != null) - RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.Report("the loot profile", session.Path, error); + RynthCore.Plugin.Shared.DataWriteGuard.Report("the loot profile", session.Path, error); } private static LootEditItemDraft Refuse(LootEditItemDraft d, string error) diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs index a42f61f..975678b 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/AfFileWriter.cs @@ -29,7 +29,7 @@ internal static class AfFileWriter IReadOnlyDictionary> embeddedNavs) { Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? "."); - RynthCore.Plugin.RynthAi.Diagnostics.DataWriteGuard.PrepareOverwrite(filePath); // a read-only .af can't be overwritten + RynthCore.Plugin.Shared.DataWriteGuard.PrepareOverwrite(filePath); // a read-only .af can't be overwritten using var writer = new StreamWriter(filePath, false); WriteContent(writer, rules, embeddedNavs); } diff --git a/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs b/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs index f7abf81..7c46896 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/Meta/QuestTracker.cs @@ -66,14 +66,18 @@ internal sealed class QuestTracker /// UTC time the last refresh finished with data (MinValue = never). public DateTime LastRefreshUtc { get; private set; } = DateTime.MinValue; - /// Last refresh outcome text for the ILT Hub ("12 flags", "rate limited", ...). + /// Last refresh outcome text for the Mini Remote's Quests tab ("12 flags", "rate limited", ...). public string LastStatus { get; private set; } = "not refreshed"; /// Number of cached flags. public int Count => _flags.Count; - /// Raised on the pump thread when a refresh ends. The ILT Hub reads Disabled and Count. - public event Action? RefreshCompleted; + /// + /// Bumped on the pump thread each time a refresh ends (0 = none yet). RynthILT polls it through + /// RynthAi.Hub QuestStatus to read Disabled and Count (a counter, not an event: nothing to + /// unsubscribe across plugin reloads). + /// + public int RefreshGeneration { get; private set; } public QuestTracker(RynthCoreHost host) => _host = host; @@ -85,7 +89,7 @@ internal sealed class QuestTracker /// /// Issues /myquests. asks to report - /// those lines as eatable so the ILT Hub can hide its own poll. + /// those lines as eatable so the Quests tab can hide its own poll. /// public void Refresh(bool quiet) { @@ -205,11 +209,10 @@ internal sealed class QuestTracker Disabled = false; LastRefreshUtc = DateTime.UtcNow; } - try { RefreshCompleted?.Invoke(); } - catch (Exception ex) { _host.Log($"[RynthAi] QuestTracker RefreshCompleted threw: {ex.Message}"); } + RefreshGeneration++; } - /// Copy of every cached record for the ILT Hub quest list. + /// Copy of every cached record for the Quests tab. public QuestRecord[] Snapshot() => _flags.Values.ToArray(); /// Returns true if the key exists in the cached quest flag list. diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/IltClient.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/IltClient.cs new file mode 100644 index 0000000..6674f07 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/IltClient.cs @@ -0,0 +1,191 @@ +// IltClient.cs - RynthAi's side of the "RynthILT.Hub" interface (Plugins/Shared/RynthIltHubApi.cs): +// the Infinite Leaftide tabs and sections the Mini Remote shows, the server's ILT feature bits +// (the Pets tab's refill / mastery charms, the Quests tab's /myquests bit), the ILT session rates +// and the ILT "/ra" verbs, all from the RynthILT plugin. +// +// Without RynthILT (not installed, too old, not loaded yet) every call answers "not ILT": no ILT +// tab, no ILT section, unknown feature bits, and the ILT verbs say RynthILT is needed. The table is +// looked up on the pump thread (Tick) at most every RecheckMs and kept in a volatile field for the +// render thread; RynthILT never frees it (Version goes to 0 on its shutdown), so reading a stale +// pointer is safe and a Version of 0 means "look again". +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Text; +using RynthCore.Plugin.Shared; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +/// One ILT tab as RynthILT describes it (render thread copy). +internal readonly record struct IltTabInfo(string Id, string Label, float Width, float Height, bool Shown, bool Available); + +internal sealed unsafe class IltClient +{ + public const string NotLoaded = "That's an Infinite Leaftide feature: it comes with the RynthILT plugin, which isn't loaded."; + private const long RecheckMs = 3000; + private const int MaxTabs = 16; + + private readonly RynthCoreHost _host; + private IntPtr _table; // volatile reads/writes: the render thread uses what the pump found + private long _checkedAt = long.MinValue; + private readonly IltTabV1[] _tabBuf = new IltTabV1[MaxTabs]; + private readonly List _tabs = new(); + + public IltClient(RynthCoreHost host) => _host = host; + + /// Pump thread: look the table up again when it's due, missing or shut down. + public void Tick() + { + long now = Environment.TickCount64; + var t = (RynthIltHubApiV1*)System.Threading.Volatile.Read(ref _table); + if (t != null && t->Version >= 1 && now - _checkedAt < RecheckMs) return; + if (t == null && now - _checkedAt < RecheckMs) return; + _checkedAt = now; + IntPtr found = IntPtr.Zero; + if (_host.HasGetPluginInterface) + { + var p = (RynthIltHubApiV1*)_host.GetPluginInterface(RynthIltHub.PluginName, RynthIltHubApiV1.InterfaceName, RynthIltHubApiV1.InterfaceVersion); + if (p != null && p->Version >= 1 && p->StructSize >= (uint)sizeof(RynthIltHubApiV1)) found = (IntPtr)p; + } + System.Threading.Volatile.Write(ref _table, found); + } + + /// Forget the table (login, logout); the next Tick looks again. + public void Reset() + { + System.Threading.Volatile.Write(ref _table, IntPtr.Zero); + _checkedAt = long.MinValue; + } + + private RynthIltHubApiV1* T + { + get + { + var t = (RynthIltHubApiV1*)System.Threading.Volatile.Read(ref _table); + return t != null && t->Version >= 1 ? t : null; + } + } + + /// RynthILT answers (any thread). + public bool Loaded => T != null; + + /// This world is Infinite Leaftide / ACECustom (or forced), as RynthILT sees it. Any thread. + public bool IsIltWorld + { + get + { + var t = T; + return t != null && t->IsIltWorld != null && t->IsIltWorld() != 0; + } + } + + /// The server's bit for a feature: -1 unknown (and always off ILT / without RynthILT), 0 off, 1 on. Any thread. + public int Feature(string key) + { + var t = T; + if (t == null || t->GetFeature == null) return -1; + using var k = new Utf8(key); + return t->GetFeature(k.P); + } + + /// The server positively reported the feature off. + public bool IsOff(string key) => Feature(key) == 0; + + /// The server positively reported the feature on. + public bool IsOn(string key) => Feature(key) == 1; + + /// ILT coin / pyreal rates (false off ILT or without RynthILT). Any thread. + public bool TryGetRates(out double coinsPerHour, out double pyrealsPerHour) + { + coinsPerHour = pyrealsPerHour = 0; + var t = T; + if (t == null || t->GetRates == null) return false; + double c = 0, p = 0; + if (t->GetRates(&c, &p) == 0) return false; + coinsPerHour = c; + pyrealsPerHour = p; + return true; + } + + /// This character's "Treat this world as ILT" (RynthILT's). Any thread. + public bool ForceIlt + { + get + { + var t = T; + return t != null && t->GetForceIlt != null && t->GetForceIlt() != 0; + } + set + { + var t = T; + if (t != null && t->SetForceIlt != null) t->SetForceIlt(value ? 1 : 0); + } + } + + /// Render thread: RynthILT's tabs with their flags (empty without RynthILT). The list is reused. + public IReadOnlyList Tabs() + { + _tabs.Clear(); + var t = T; + if (t == null || t->GetTabs == null) return _tabs; + int n; + fixed (IltTabV1* buf = _tabBuf) n = t->GetTabs(buf, MaxTabs); + n = Math.Min(n, MaxTabs); + for (int i = 0; i < n; i++) + { + ref IltTabV1 tab = ref _tabBuf[i]; + string id, label; + fixed (byte* pid = tab.Id) id = Marshal.PtrToStringUTF8((IntPtr)pid) ?? string.Empty; + fixed (byte* plabel = tab.Label) label = Marshal.PtrToStringUTF8((IntPtr)plabel) ?? string.Empty; + if (id.Length == 0) continue; + _tabs.Add(new IltTabInfo(id, label.Length > 0 ? label : id, tab.Width, tab.Height, + (tab.Flags & RynthIltHub.TabShown) != 0, (tab.Flags & RynthIltHub.TabAvailable) != 0)); + } + return _tabs; + } + + /// Render thread: one ILT tab's body into the current child window; false = nothing drawn. + public bool RenderTab(string id) + { + var t = T; + if (t == null || t->RenderTab == null) return false; + using var s = new Utf8(id); + return t->RenderTab(s.P) != 0; + } + + /// Render thread: an ILT section (RynthIltHub.Section*); false = nothing drawn (not ILT, or no RynthILT). + public bool RenderSection(string id) + { + var t = T; + if (t == null || t->RenderSection == null) return false; + using var s = new Utf8(id); + return t->RenderSection(s.P) != 0; + } + + /// An ILT "/ra" verb ("hub bank", "guardian handin", ...); false when RynthILT doesn't take it. + public bool Command(string text) + { + var t = T; + if (t == null || t->Command == null) return false; + using var s = new Utf8(text); + return t->Command(s.P) != 0; + } + + /// A NUL-terminated UTF-8 copy of a string for one call. + private readonly struct Utf8 : IDisposable + { + public readonly byte* P; + + public Utf8(string? s) + { + s ??= string.Empty; + int n = Encoding.UTF8.GetByteCount(s); + P = (byte*)NativeMemory.Alloc((nuint)(n + 1)); + fixed (char* c = s) Encoding.UTF8.GetBytes(c, s.Length, P, n); + P[n] = 0; + } + + public void Dispose() => NativeMemory.Free(P); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteContext.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteContext.cs new file mode 100644 index 0000000..b47277a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteContext.cs @@ -0,0 +1,146 @@ +// MiniRemoteContext.cs — Shared services for the Mini Remote's universal tabs (Quests, Pets) and +// the VTank .usd importer. The universal half of the ILT Hub's IltHubContext (SilentKelpie's ILT +// Hub; its Infinite Leaftide half went to the RynthILT plugin 2026-10-13, whose feature bits and +// sections come through Ilt). +// +// Threading contract (as before): +// * Tick / OnChat run on the plugin pump thread and may call the host freely. +// * Render runs on the ImGui render thread and must NOT call AC actions directly. It calls +// Post(...) to run work on the next pump tick, or Confirm(...) to ask the player first (the +// confirmed action is then posted). +using System; +using System.Collections.Concurrent; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +/// A yes/no question waiting for the player (a modal over the Mini Remote). +internal sealed class MiniRemoteConfirm +{ + public string Title = "Confirm"; + public string Message = string.Empty; + public string YesLabel = "Yes"; + /// Runs on the pump thread after the player clicks Yes. + public Action? OnYes; +} + +internal sealed class MiniRemoteContext +{ + private readonly ConcurrentQueue _posted = new(); + private readonly ConcurrentQueue _confirms = new(); + private readonly Func _settings; + + public MiniRemoteContext(RynthCoreHost host, MiniRemoteState state, MiniRemoteStore store, MiniRemoteInventory inventory, + IltClient ilt, Func settings) + { + Host = host; + State = state; + Store = store; + Inventory = inventory; + Ilt = ilt; + _settings = settings; + } + + public RynthCoreHost Host { get; } + public MiniRemoteState State { get; } + public MiniRemoteStore Store { get; } + public MiniRemoteInventory Inventory { get; } + + /// RynthILT's view (ILT world, feature bits, ILT sections); "not ILT" without RynthILT. + public IltClient Ilt { get; } + + /// The live combat settings (rule lists the Pets tab / USD importer edit). Null before login. + public LegacyUiSettings? Settings => _settings(); + + /// Set by the controller when combat settings were edited and must be saved. + public Action? SaveCombatSettings; + + /// Logged-in character name (resolved at login). + public string CharName = string.Empty; + + /// + /// Shows the Mini Remote on one of its tabs (tab id; set by the controller). Any thread: it + /// only records the tab and the show request, which the next frame applies. + /// + public Action? ShowTab; + + /// Writes a local chat line (never sent to the server). + public void Chat(string text) + { + if (Host.HasWriteToChat) Host.WriteToChat(text, 1); + } + + /// Queues work for the next pump tick (safe from the render thread). + public void Post(Action action) => _posted.Enqueue(action); + + /// Asks the player to confirm before runs on the pump thread. + public void Confirm(string title, string message, Action onYes, string yesLabel = "Yes") + => _confirms.Enqueue(new MiniRemoteConfirm { Title = title, Message = message, OnYes = onYes, YesLabel = yesLabel }); + + /// Render thread: takes the next pending confirmation, if any. + public bool TryTakeConfirm(out MiniRemoteConfirm request) => _confirms.TryDequeue(out request!); + + /// Pump thread: runs everything posted since the last tick. + public void DrainPosted() + { + int guard = 0; + while (guard++ < 64 && _posted.TryDequeue(out var a)) + { + try { a(); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "[MiniRemote] posted action"); } + } + } + + /// Elapsed-ms clock used for every timer. + public static long NowMs => Environment.TickCount64; +} + +/// Text helpers the universal tabs share (the ILT Hub's IltParse.Duration). +internal static class MiniRemoteText +{ + /// "ready", "45s", "3m 12s", "2h 5m 0s", "1d 4h 30m". + public static string Duration(TimeSpan span) + { + if (span <= TimeSpan.Zero) return "ready"; + if (span.TotalDays >= 1) return $"{(int)span.TotalDays}d {span.Hours}h {span.Minutes}m"; + if (span.TotalHours >= 1) return $"{span.Hours}h {span.Minutes}m {span.Seconds}s"; + if (span.TotalMinutes >= 1) return $"{span.Minutes}m {span.Seconds}s"; + return $"{span.Seconds}s"; + } +} + +/// The Mini Remote's own tab ids (RynthILT supplies the Infinite Leaftide ones). +internal static class MiniRemoteTabs +{ + /// The Remote tab (the remote itself). + public const string Remote = ""; + public const string Quests = "quests"; + public const string Pets = "pets"; + + /// The universal tabs in tab-bar order (after Remote, before RynthILT's tabs). + public static readonly string[] Universal = { Quests, Pets }; + + public static string Label(string id) => id switch + { + Quests => "Quests", + Pets => "Pets", + _ => "Remote", + }; + + /// "quests" / "quest" / "pets" / "pet" → the tab id; null for anything else. + public static string? Parse(string? text) => (text ?? string.Empty).Trim().ToLowerInvariant() switch + { + "quests" or "quest" => Quests, + "pets" or "pet" => Pets, + _ => null, + }; + + /// Size of a universal tab's body (the old section window's default size). + public static System.Numerics.Vector2 Size(string id) => id switch + { + Quests => new System.Numerics.Vector2(700, 500), + Pets => new System.Numerics.Vector2(560, 580), + _ => new System.Numerics.Vector2(520, 440), + }; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteController.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteController.cs new file mode 100644 index 0000000..a5f1b7f --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteController.cs @@ -0,0 +1,292 @@ +// MiniRemoteController.cs — The Mini Remote's universal tabs (Quests, Pets), the VTank .usd +// importer and the "/ra hub|quests|pets" commands. The universal half of the ILT Hub's +// IltHubController (SilentKelpie's ILT Hub; its Infinite Leaftide half went to the RynthILT plugin +// 2026-10-13). +// +// RynthAiPlugin creates one controller per login session and forwards: +// OnTick → Tick() (pump thread) +// OnChatWindowText → OnChat() (pump thread) +// OnRender → Render() (render thread: quest favorites HUD, confirmations) +// /ra hub ..., /ra quests ..., /ra pets ..., /ra guardian ..., /ra bounty ... → HandleCommand() +// OnLogout / teardown → OnLogout() +// The Mini Remote's tab bar (MiniRemoteHud) shows Remote, then Quests and Pets (here, every +// world), then RynthILT's Infinite Leaftide tabs (IltClient). The ILT verbs ("/ra hub bank", +// "/ra hub attr ...", "/ra guardian ...", "/ra bounty", "/ra hub open banking", ...) are forwarded +// to RynthILT (RynthILT.Hub Command); without RynthILT they say so. +using System; +using System.Linq; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.Meta; +using RynthCore.Plugin.Shared; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +internal sealed class MiniRemoteController +{ + private const long SaveIntervalMs = 5000; + private const string ConfirmPopupId = "Confirm##mrconfirm"; + + private readonly MiniRemoteContext _ctx; + private long _lastSaveAt; + private MiniRemoteConfirm? _confirm; // render thread + private bool _confirmOpened; + + public QuestsTab Quests { get; } + public PetsTab Pets { get; } + public VTankUsdImporter Usd { get; } + + public MiniRemoteController(RynthCoreHost host, string charFolder, Func cache, + Func settings, Func quests, Action saveCombatSettings, IltClient ilt) + { + var store = new MiniRemoteStore(charFolder); + var state = store.Load(); + var inventory = new MiniRemoteInventory(host, cache); + _ctx = new MiniRemoteContext(host, state, store, inventory, ilt, settings) { SaveCombatSettings = saveCombatSettings }; + Quests = new QuestsTab(_ctx, quests); + Pets = new PetsTab(_ctx); + Usd = new VTankUsdImporter(_ctx); + _ctx.ShowTab = tab => MiniRemoteTabCommand?.Invoke(tab, "show"); + } + + public MiniRemoteState State => _ctx.State; + + /// RynthILT's side (ILT world, tabs, sections, verbs). + public IltClient Ilt => _ctx.Ilt; + + /// Shows / hides / toggles the Mini Remote ("show", "hide", "toggle"). Set by RynthAiPlugin; returns the chat reply. + public Func? MiniRemoteCommand { get; set; } + + /// + /// Puts the Mini Remote on a tab (tab id, "" = the remote itself; mode "show" / "hide" / + /// "toggle", or "select"). Set by RynthAiPlugin; returns the chat reply. Any thread. + /// + public Func? MiniRemoteTabCommand { get; set; } + + /// True when the cached ILT options already say /myquests is off (skip the login refresh). + public bool SkipLoginQuestRefresh => _ctx.Ilt.IsIltWorld && _ctx.Ilt.IsOff(RynthIltHub.FeatureQuests); + + // ── Lifecycle ─────────────────────────────────────────────────────────── + + /// Login: remember the character and hook PetManager to the Pets tab. + public void OnLoginComplete(string charName, PetManager? petManager) + { + _ctx.CharName = charName ?? string.Empty; + _ctx.Inventory.Reset(); + if (petManager != null) + { + petManager.AllowSummonOnEmpty = Pets.AllowSummonOnEmpty; + petManager.HoldSummons = Pets.HoldCombatSummons; + petManager.YieldPetForCombat = Pets.YieldPetForCombat; + } + } + + /// Pump-thread tick. + public void Tick() + { + long now = MiniRemoteContext.NowMs; + _ctx.DrainPosted(); + try { Pets.Tick(now); } + catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.Tick"); } + if (now - _lastSaveAt >= SaveIntervalMs) + { + _lastSaveAt = now; + _ctx.Store.SaveIfDirty(_ctx.State); + } + } + + /// Pump-thread chat line (the heal pet's heal). Never eats. + public void OnChat(string text) + { + if (string.IsNullOrEmpty(text)) return; + try { Pets.OnChat(text.TrimEnd('\r', '\n')); } + catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnChat"); } + } + + /// Logout / teardown: stop the pet automation and flush to disk. + public void OnLogout() + { + try { Pets.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "PetsTab.OnLogout"); } + _ctx.Store.SaveIfDirty(_ctx.State); + } + + /// "Refresh /myquests" for RynthILT's Temple tracker (RynthAi.Hub QuestRefresh). Pump thread. + public string RefreshQuests() => Quests.RefreshQuests(); + + // ── Rendering (render thread) ─────────────────────────────────────────── + + /// One of the Mini Remote's own tabs ("quests", "pets"); false for anything else. + public bool RenderTab(string id) + { + switch (id) + { + case MiniRemoteTabs.Quests: Quests.RenderTab(); return true; + case MiniRemoteTabs.Pets: Pets.Render(); return true; + default: return false; + } + } + + /// The floating extras: the quest favorites HUD and the confirmation modal. + public void Render() + { + Quests.RenderFloatingWindows(); + RenderConfirm(); + } + + private void RenderConfirm() + { + if (_confirm == null) + { + if (!_ctx.TryTakeConfirm(out var next)) return; + _confirm = next; + _confirmOpened = false; + } + if (!_confirmOpened) + { + ImGui.OpenPopup(ConfirmPopupId); + _confirmOpened = true; + } + + ImGui.SetNextWindowSize(new Vector2(420, 0), ImGuiCond.Appearing); + bool keepOpen = true; + if (ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize)) + { + ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _confirm.Title); + ImGui.Separator(); + ImGui.TextWrapped(_confirm.Message); + ImGui.Spacing(); + if (ImGui.Button(_confirm.YesLabel + "##mryes", new Vector2(120, 0))) + { + var act = _confirm.OnYes; + if (act != null) _ctx.Post(act); + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.SameLine(); + if (ImGui.Button("Cancel##mrno", new Vector2(120, 0))) + { + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.EndPopup(); + } + else + { + // Closed with the title-bar X (or never opened): treat as cancel. + _confirm = null; + } + if (!keepOpen) _confirm = null; + } + + // ── Commands ──────────────────────────────────────────────────────────── + + /// + /// "/ra hub [show|hide|toggle|open quests|pets [show|hide|toggle]|tab quests|pets|remote]", + /// "/ra quests [refresh|check <regex>|window|favhud]", "/ra pets [show|hide|toggle]"; every + /// other "/ra hub ..." verb, "/ra guardian ..." and "/ra bounty|bounties|bountys ..." go to + /// RynthILT. Returns false if not handled. + /// + public bool HandleCommand(string verb, string[] args) + { + if (verb.Equals("quests", StringComparison.OrdinalIgnoreCase)) + { + string sub = args.Length > 0 ? args[0].ToLowerInvariant() : "refresh"; + string mode = args.Length > 1 ? args[1].ToLowerInvariant() : "toggle"; + var qs = _ctx.State.Quests; + switch (sub) + { + case "check" when args.Length > 1: + Quests.CheckCommand(string.Join(" ", args.Skip(1))); + break; + case "window": + OpenTab(MiniRemoteTabs.Quests, mode); + break; + case "favhud": + case "favorites": + qs.ShowQuestFavoritesHud = ResolveToggle(mode, qs.ShowQuestFavoritesHud); + _ctx.Chat(qs.ShowQuestFavoritesHud ? "[Mini Remote] Quest favorites HUD shown." : "[Mini Remote] Quest favorites HUD hidden."); + break; + default: + _ctx.Chat("[Mini Remote] " + Quests.RefreshQuests()); + break; + } + return true; + } + if (verb.Equals("pets", StringComparison.OrdinalIgnoreCase)) + { + // "/ra pets [show|hide|toggle]": same as "/ra hub open pets". + OpenTab(MiniRemoteTabs.Pets, args.Length > 0 ? args[0] : "toggle"); + return true; + } + bool ilt = verb.Equals("guardian", StringComparison.OrdinalIgnoreCase) || IsBountyVerb(verb); + if (!ilt && !verb.Equals("hub", StringComparison.OrdinalIgnoreCase)) return false; + + if (!ilt) + { + string cmd = args.Length > 0 ? args[0].ToLowerInvariant() : "toggle"; + switch (cmd) + { + case "show": + case "hide": + case "toggle": + // The Mini Remote is the Hub's main window. + _ctx.Chat(MiniRemoteCommand != null ? MiniRemoteCommand(cmd) : "[Mini Remote] The Mini Remote is not available yet."); + return true; + case "open" when args.Length > 1 && MiniRemoteTabs.Parse(args[1]) is { } openTab: + OpenTab(openTab, args.Length > 2 ? args[2] : "toggle"); + return true; + case "tab" when args.Length < 2 || MiniRemoteTabs.Parse(args[1]) != null || IsRemoteTabName(args[1]): + // The engine's dashboard: it opens its Mini Remote window itself, so only switch tabs. + MiniRemoteTabCommand?.Invoke(args.Length > 1 ? MiniRemoteTabs.Parse(args[1]) ?? MiniRemoteTabs.Remote : MiniRemoteTabs.Remote, "select"); + return true; + } + } + + // Everything else is an Infinite Leaftide verb: RynthILT's. + string line = (verb + " " + string.Join(" ", args)).Trim(); + if (_ctx.Ilt.Command(line)) return true; + if (verb.Equals("hub", StringComparison.OrdinalIgnoreCase) && args.Length > 0 && args[0].Equals("tab", StringComparison.OrdinalIgnoreCase)) + { + // A tab RynthILT doesn't offer (not loaded): back to the remote rather than nothing. + MiniRemoteTabCommand?.Invoke(MiniRemoteTabs.Remote, "select"); + return true; + } + if (verb.Equals("hub", StringComparison.OrdinalIgnoreCase)) PrintHelp(); + _ctx.Chat("[Mini Remote] " + IltClient.NotLoaded); + return true; + } + + private void PrintHelp() + { + _ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote) /ra hub open quests|pets [show|hide|toggle]"); + _ctx.Chat("[Mini Remote] /ra quests [refresh|check |window [show|hide]|favhud [show|hide]] /ra pets [show|hide]"); + _ctx.Chat("[Mini Remote] Banking, gear, charms, games, the Guardian, bounties, /ra hub attr ...: Infinite Leaftide, the RynthILT plugin."); + } + + private static bool IsRemoteTabName(string text) + => text.Equals("remote", StringComparison.OrdinalIgnoreCase) || text.Length == 0; + + /// "/ra bounty", "/ra bounties" and the "/ra bountys" spelling (RynthILT's Bounties window). + public static bool IsBountyVerb(string verb) + => verb.Equals("bounty", StringComparison.OrdinalIgnoreCase) + || verb.Equals("bounties", StringComparison.OrdinalIgnoreCase) + || verb.Equals("bountys", StringComparison.OrdinalIgnoreCase); + + /// Applies show / hide / toggle to one of the Mini Remote's own tabs. Says what happened. + private void OpenTab(string tab, string mode) + { + string reply = MiniRemoteTabCommand?.Invoke(tab, mode) ?? "The Mini Remote is not available yet."; + _ctx.Chat("[Mini Remote] " + reply); + } + + /// "show"/"on" → true, "hide"/"off" → false, anything else flips . + private static bool ResolveToggle(string mode, bool current) => mode switch + { + "show" or "on" or "true" or "1" => true, + "hide" or "off" or "false" or "0" => false, + _ => !current, + }; +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs new file mode 100644 index 0000000..ff02812 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteInventory.cs @@ -0,0 +1,148 @@ +// MiniRemoteInventory.cs — Item / player-property helper for the Mini Remote's universal tabs (Pets, +// the VTank .usd importer). The universal part of the ILT Hub's IltInventory (SilentKelpie's; the +// ILT Hub went to the RynthILT plugin 2026-10-13, which has its own copy for its ILT features). +// +// One place for: WCID lookups (cached), stack / use counts, "is it equipped", appraisal requests +// (throttled), the Summon Essence Refill / Universal Summoning Mastery charm status (ACECustom +// items the Pets tab's refill path reads; harmless anywhere else) and player int/bool reads. +// Pump-thread only. +using System; +using System.Collections.Generic; +using System.Linq; +using RynthCore.Loot; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +/// Charm ON / OFF read from its appraisal text. +internal enum CharmState { Unknown = -1, Off = 0, On = 1 } + +internal sealed class MiniRemoteInventory +{ + // ── Well-known WCIDs (ACECustom content the Pets tab recognises) ───────── + public const uint WcidEncapsulatedSpirit = 49485; + public const uint WcidSummonRefillCharm = 78780030; + public const uint WcidUniversalMasteryCharm = 78780031; + public static readonly uint[] WcidInfiniteCastingStone = { 777700019, 777700055 }; + + // ── Property ids ──────────────────────────────────────────────────────── + public const uint IntStackSize = 12; + public const uint IntStructure = 92; + public const uint StrUse = 14; + public const uint BoolPyrealRefillActive = 9049; + public const uint BoolUniversalMasteryActive = 50038; + + private readonly RynthCoreHost _host; + private readonly Func _cache; + private readonly Dictionary _wcidCache = new(); + private readonly Dictionary _lastIdRequest = new(); + + /// Don't re-request appraisal for the same object more often than this. + private const long IdRequestThrottleMs = 30_000; + + public MiniRemoteInventory(RynthCoreHost host, Func cache) + { + _host = host; + _cache = cache; + } + + public RynthCoreHost Host => _host; + public WorldObjectCache? Cache => _cache(); + public uint PlayerId => _host.GetPlayerId(); + + // ── Player state ──────────────────────────────────────────────────────── + + /// The client busy hourglass is up (an action is in progress). + public bool IsBusy => _host.HasGetBusyState && _host.GetBusyState() != 0; + + /// Player is in peace mode (combat mode NonCombat). True when the engine can't tell. + public bool InPeaceMode => !_host.HasGetCurrentCombatMode || _host.GetCurrentCombatMode() == CombatMode.NonCombat; + + public bool PlayerBool(uint stype) + => _host.HasGetObjectBoolProperty && _host.TryGetObjectBoolProperty(PlayerId, stype, out bool v) && v; + + /// Current/max health from the engine vitals read (0/0 when unavailable). + public (uint Cur, uint Max) PlayerHealth() + { + if (_host.HasGetPlayerVitals && _host.TryGetPlayerVitals(out uint h, out uint mh, out _, out _, out _, out _)) + return (h, mh); + return (0, 0); + } + + // ── Item facts ────────────────────────────────────────────────────────── + + /// All items the player carries or wears (snapshot). + public IEnumerable Items() => _cache()?.GetInventory() ?? Enumerable.Empty(); + + /// Weenie class id, cached per object (0 when unknown). + public uint Wcid(WorldObject wo) + { + if (_wcidCache.TryGetValue(wo.Id, out uint w) && w != 0) return w; + if (_host.HasGetObjectWcid && _host.TryGetObjectWcid(unchecked((uint)wo.Id), out w)) + _wcidCache[wo.Id] = w; + return w; + } + + public int Int(WorldObject wo, uint stype, int fallback = 0) => wo.Values(unchecked((int)stype), fallback); + + public string Str(WorldObject wo, uint stype) + => _host.HasGetObjectStringProperty && _host.TryGetObjectStringProperty(unchecked((uint)wo.Id), stype, out string v) ? v ?? string.Empty : string.Empty; + + /// Remaining uses on a structure item (essences, kits, salvage bags). + public int Uses(WorldObject wo) => Int(wo, IntStructure, 0); + + public bool HasAppraisal(WorldObject wo) + => !_host.HasHasAppraisalData || _host.HasAppraisalData(unchecked((uint)wo.Id)); + + /// Requests appraisal data, throttled per object. Returns true if a request was sent. + public bool RequestAppraisal(WorldObject wo) + { + if (!_host.HasRequestId) return false; + long now = Environment.TickCount64; + if (_lastIdRequest.TryGetValue(wo.Id, out long last) && now - last < IdRequestThrottleMs) return false; + _lastIdRequest[wo.Id] = now; + return _host.RequestId(unchecked((uint)wo.Id)); + } + + public WorldObject? FindByWcid(params uint[] wcids) + => Items().FirstOrDefault(wo => Array.IndexOf(wcids, Wcid(wo)) >= 0); + + public IEnumerable AllByWcid(params uint[] wcids) + => Items().Where(wo => Array.IndexOf(wcids, Wcid(wo)) >= 0); + + /// + /// True when the player carries spell components or an Infinite Casting Stone that isn't + /// known to be switched OFF (an OFF stone doesn't waive components). + /// + public bool HasCastingSupplies() + => AllByWcid(WcidInfiniteCastingStone).Any(stone => CharmStatus(stone) != CharmState.Off) + || Items().Any(wo => wo.ObjectClass == AcObjectClass.SpellComponent); + + /// + /// ON/OFF/Unknown from the appraisal Use text ("... Status: ON"). Requests appraisal + /// (throttled) when the text isn't loaded yet. + /// + public CharmState CharmStatus(WorldObject charm) + { + string use = Str(charm, StrUse); + if (use.Length == 0) + { + RequestAppraisal(charm); + return CharmState.Unknown; + } + if (use.Contains("Status: ON", StringComparison.OrdinalIgnoreCase)) return CharmState.On; + if (use.Contains("Status: OFF", StringComparison.OrdinalIgnoreCase)) return CharmState.Off; + return CharmState.Unknown; + } + + // ── Actions ───────────────────────────────────────────────────────────── + + public bool Use(WorldObject wo) => _host.HasUseObject && _host.UseObject(unchecked((uint)wo.Id)); + + /// Forgets cached WCIDs / appraisal throttles (logout). + public void Reset() + { + _wcidCache.Clear(); + _lastIdRequest.Clear(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs new file mode 100644 index 0000000..69ce339 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/MiniRemoteState.cs @@ -0,0 +1,192 @@ +// MiniRemoteState.cs — What the Mini Remote's universal tabs remember per character: the Pets +// tab (roster view, healing / cosmetic pets, the refill path) and the Quests tab (filter, +// favorites, the favorites HUD), plus the VTank .usd importer's last file. +// +// Lives in \miniremote.json. These settings were part of the ILT Hub's +// ilt-hub.json (SilentKelpie's ILT Hub, which RynthAi hosted until 2026-10-13). The ILT Hub went +// to the RynthILT plugin; the universal tabs stayed. On the first load without miniremote.json +// the Pets / Quests / import parts of ilt-hub.json are read (field names unchanged, so the old +// file deserializes straight into these classes); ilt-hub.json itself is never written again (it +// is RynthILT's to copy, IltMigration). Serialized with the source-generated RynthAiJsonContext +// (IncludeFields = true), so plain public fields are used throughout. +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; + +namespace RynthCore.Plugin.RynthAi.MiniRemote; + +public sealed class MiniRemoteState +{ + public int SchemaVersion = 1; + public PetTabState Pet = new(); + public QuestsTabState Quests = new(); + /// Last VTank .usd file the importer read (the ILT Hub's Gear.LastUsdPath before). + public string LastUsdPath = string.Empty; +} + +/// The Pets tab's settings (the ILT Hub's IltPetState, without the ILT /pets and /shinies logs). +public sealed class PetTabState +{ + // Healing-pet automation (UB "HealingBuddy" subset). + public bool HealingEnabled; + /// Exact name of the heal-pet essence to use; empty = auto-detect (Healing Buddy / Dule box). + public string HealPetName = string.Empty; + public int HealthThresholdPercent = 80; + /// Do not summon when current HP is below this (summoning mid-death wastes the use). 0 = off. + public int MinHealthPoints = 100; + public bool AutoDespawnAfterHeal = true; + public int RespawnDelaySeconds = 2; + public int PetTimeoutSeconds = 30; + + /// + /// Allow a combat summon from an EMPTY essence when the Summon Essence Refill Charm is + /// active (ACECustom: the server refills from banked pyreals). Still requires the server + /// flag to be on (RynthILT reports it). + /// + public bool UsePyrealRefillPath; + + /// Roster type shown in the Pet tab (PetKind: 0 Combat, 1 Healing, 2 Cosmetic). + public int RosterKind; + /// Roster sort (PetSort: 0 Priority, 1 Bond, 2 Potency, 3 Breed ready, 4 Level, 5 Uses, 6 Name). + public int RosterSort; + /// User type overrides by essence name; essences not listed are auto-classified. + public List Assignments = new(); + + /// Essence name of the chosen cosmetic (display) pet; empty = none. + public string CosmeticPetName = string.Empty; + /// Keep the cosmetic pet summoned while in peace mode; it is dismissed when a combat pet is needed. + public bool KeepCosmeticOut; + /// Seconds to wait before re-summoning the cosmetic pet after it despawns. + public int CosmeticRespawnSeconds = 15; +} + +/// A user's choice of summon type for one essence (matched by name, case-insensitive). +public sealed class PetAssignment +{ + public string Name = string.Empty; + /// PetKind as int (0 Combat, 1 Healing, 2 Cosmetic). + public int Kind; +} + +/// The Quests tab's settings (the quest fields of the ILT Hub's IltCharacterState). +public sealed class QuestsTabState +{ + /// Quest Tracker search box contents. + public string QuestFilter = string.Empty; + /// Starred quest flag keys (lowercase), shown on the floating favorites HUD. + public List QuestFavorites = new(); + /// Quest tracker lists starred quests only. + public bool QuestFavoritesOnly; + /// Floating quest favorites HUD is shown. + public bool ShowQuestFavoritesHud; + public bool QuestFavoritesHudLocked; +} + +/// The parts of an old ilt-hub.json the universal tabs take over (first load only). +public sealed class LegacyIltHubFile +{ + public PetTabState? Pet; + /// The ILT Hub's IltCharacterState: its quest fields have QuestsTabState's names. + public QuestsTabState? Character; + public LegacyIltGear? Gear; +} + +public sealed class LegacyIltGear +{ + public string? LastUsdPath; +} + +/// Loads and saves (dirty-checked like the ILT Hub's store was). +internal sealed class MiniRemoteStore +{ + public const string FileName = "miniremote.json"; + public const string LegacyFileName = "ilt-hub.json"; + + private readonly string _charFolder; + private string _lastJson = string.Empty; + + public MiniRemoteStore(string charFolder) => _charFolder = charFolder ?? string.Empty; + + private string StatePath => Path.Combine(_charFolder, FileName); + + /// The saved state; on the first load the universal parts of ilt-hub.json; else defaults. + public MiniRemoteState Load() + { + try + { + if (_charFolder.Length > 0 && File.Exists(StatePath)) + { + string json = File.ReadAllText(StatePath); + var s = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.MiniRemoteState); + if (s != null) + { + Normalize(s); + _lastJson = json; + return s; + } + } + string legacy = Path.Combine(_charFolder, LegacyFileName); + if (_charFolder.Length > 0 && File.Exists(legacy)) + { + var old = JsonSerializer.Deserialize(File.ReadAllText(legacy), RynthAiJsonContext.Default.LegacyIltHubFile); + if (old != null) + { + var s = FromLegacy(old); + RynthLog.Write(LogCat.General, $"[MiniRemote] Pets / Quests tab settings read from {LegacyFileName} (the ILT Hub went to RynthILT; saved in {FileName} from now on)."); + return s; // _lastJson stays empty: the first save writes miniremote.json + } + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, $"[MiniRemote] load {StatePath}"); } + return new MiniRemoteState(); + } + + /// The universal parts of an old ilt-hub.json as a fresh state. + internal static MiniRemoteState FromLegacy(LegacyIltHubFile old) + { + var s = new MiniRemoteState + { + Pet = old.Pet ?? new PetTabState(), + Quests = old.Character ?? new QuestsTabState(), + LastUsdPath = old.Gear?.LastUsdPath ?? string.Empty, + }; + Normalize(s); + return s; + } + + /// Writes the state only when its JSON differs from the last write. + public void SaveIfDirty(MiniRemoteState state) + { + if (_charFolder.Length == 0) return; + try + { + string json = JsonSerializer.Serialize(state, RynthAiJsonContext.Default.MiniRemoteState); + if (json == _lastJson) return; + Directory.CreateDirectory(_charFolder); + string tmp = StatePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, StatePath, overwrite: true); + _lastJson = json; + } + catch (Exception ex) { RynthLog.Exception(LogCat.General, ex, $"[MiniRemote] save {StatePath}"); } + } + + /// Repairs null collections / out-of-range values after deserialization. + internal static void Normalize(MiniRemoteState s) + { + s.Pet ??= new PetTabState(); + s.Pet.Assignments ??= new(); + s.Pet.Assignments.RemoveAll(a => a == null || string.IsNullOrWhiteSpace(a.Name)); + s.Pet.HealPetName ??= string.Empty; + s.Pet.CosmeticPetName ??= string.Empty; + s.Pet.RosterKind = Math.Clamp(s.Pet.RosterKind, 0, 2); + s.Pet.RosterSort = Math.Clamp(s.Pet.RosterSort, 0, 6); + s.Pet.CosmeticRespawnSeconds = Math.Clamp(s.Pet.CosmeticRespawnSeconds, 5, 600); + s.Quests ??= new QuestsTabState(); + s.Quests.QuestFilter ??= string.Empty; + s.Quests.QuestFavorites ??= new(); + s.Quests.QuestFavorites.RemoveAll(string.IsNullOrWhiteSpace); + s.LastUsdPath ??= string.Empty; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetStats.cs similarity index 86% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs rename to Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetStats.cs index eb58c6c..2b20d43 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPetStats.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetStats.cs @@ -1,4 +1,5 @@ -// IltPetStats.cs — Mag-Tools / UtilityBelt-style stats for one carried pet essence. +// PetStats.cs — Mag-Tools / UtilityBelt-style stats for one carried pet essence (the Pets tab's roster). +// Originally SilentKelpie's IltPetStats (ILT Hub); stayed in RynthAi with the universal Pets tab (2026-10-13). // // Line 1: Name, Bond N, Lvl N, Craft N // Line 2: Sex, Growth, Mut N, Potency S (A act +P%), Mastery, DamageType @@ -13,21 +14,21 @@ using System.Globalization; using System.Text; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthAi.MiniRemote; -/// Pet summon category (UB Pets "Type"). Persisted as int in . -internal enum IltPetKind { Combat = 0, Healing = 1, Cosmetic = 2 } +/// Pet summon category (UB Pets "Type"). Persisted as int in . +internal enum PetKind { Combat = 0, Healing = 1, Cosmetic = 2 } -/// Roster sort modes (persisted as int in ). -internal enum IltPetSort { Priority = 0, Bond = 1, Potency = 2, BreedReady = 3, Level = 4, Uses = 5, Name = 6 } +/// Roster sort modes (persisted as int in ). +internal enum PetSort { Priority = 0, Bond = 1, Potency = 2, BreedReady = 3, Level = 4, Uses = 5, Name = 6 } /// One carried essence with its decoded stats. Built on the pump thread, read by the UI. -internal sealed class IltPetStats +internal sealed class PetStats { public int Id; public string Name = string.Empty; public uint Wcid; - public IltPetKind Kind; + public PetKind Kind; /// Kind came from a user assignment rather than auto-detection. public bool KindAssigned; @@ -59,8 +60,8 @@ internal sealed class IltPetStats public string Line3 = string.Empty; } -/// Reads and formats . Pump thread only (host reads). -internal static class IltPetStatsReader +/// Reads and formats . Pump thread only (host reads). +internal static class PetStatsReader { // ── ACECustom / ACE property ids (UB IltPetAceConstants, PetEssenceItemInfoFormatter) ── private const uint IntDamageType = 45; @@ -106,10 +107,10 @@ internal static class IltPetStatsReader private const int MaleMaxBreedingCharges = 10; /// Decodes every stat for and fills the three display lines. - public static IltPetStats Read(RynthCoreHost host, IltInventory inv, WorldObject wo, long unixNow) + public static PetStats Read(RynthCoreHost host, MiniRemoteInventory inv, WorldObject wo, long unixNow) { uint id = unchecked((uint)wo.Id); - var s = new IltPetStats + var s = new PetStats { Id = wo.Id, Name = wo.Name, @@ -181,7 +182,7 @@ internal static class IltPetStatsReader } /// Builds Line1..Line3 from the decoded fields (Kind/Selected don't affect the text). - public static void FormatLines(IltPetStats s) + public static void FormatLines(PetStats s) { var l1 = new StringBuilder(s.Name); if (s.Bond > 0) l1.Append(", Bond ").Append(s.Bond.ToString(CultureInfo.InvariantCulture)); @@ -211,19 +212,19 @@ internal static class IltPetStatsReader } /// Orders rows for display; ties keep a stable name order. - public static IltPetStats[] Sort(IEnumerable rows, IltPetSort mode) + public static PetStats[] Sort(IEnumerable rows, PetSort mode) { - var list = new List(rows); - Comparison byName = (a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); - Comparison cmp = mode switch + var list = new List(rows); + Comparison byName = (a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); + Comparison cmp = mode switch { // Selected first, then combat priority, then name. - IltPetSort.Priority => (a, b) => Chain(b.Selected.CompareTo(a.Selected), a.Priority.CompareTo(b.Priority), byName(a, b)), - IltPetSort.Bond => (a, b) => Chain(b.Bond.CompareTo(a.Bond), byName(a, b)), - IltPetSort.Potency => (a, b) => Chain(b.StoredPotency.CompareTo(a.StoredPotency), b.ActivePotency.CompareTo(a.ActivePotency), byName(a, b)), - IltPetSort.BreedReady => (a, b) => Chain(b.BreedReady.CompareTo(a.BreedReady), b.Bond.CompareTo(a.Bond), byName(a, b)), - IltPetSort.Level => (a, b) => Chain(b.Level.CompareTo(a.Level), byName(a, b)), - IltPetSort.Uses => (a, b) => Chain(b.UsesCur.CompareTo(a.UsesCur), byName(a, b)), + PetSort.Priority => (a, b) => Chain(b.Selected.CompareTo(a.Selected), a.Priority.CompareTo(b.Priority), byName(a, b)), + PetSort.Bond => (a, b) => Chain(b.Bond.CompareTo(a.Bond), byName(a, b)), + PetSort.Potency => (a, b) => Chain(b.StoredPotency.CompareTo(a.StoredPotency), b.ActivePotency.CompareTo(a.ActivePotency), byName(a, b)), + PetSort.BreedReady => (a, b) => Chain(b.BreedReady.CompareTo(a.BreedReady), b.Bond.CompareTo(a.Bond), byName(a, b)), + PetSort.Level => (a, b) => Chain(b.Level.CompareTo(a.Level), byName(a, b)), + PetSort.Uses => (a, b) => Chain(b.UsesCur.CompareTo(a.UsesCur), byName(a, b)), _ => byName, }; list.Sort(cmp); @@ -276,7 +277,7 @@ internal static class IltPetStatsReader return ("Ready", true); } - private static string RatingsBracket(IltPetStats s) + private static string RatingsBracket(PetStats s) { var sb = new StringBuilder(); void Add(string label, int v) diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs similarity index 84% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs rename to Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs index 7d08ac6..4c108b2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltPets.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/PetsTab.cs @@ -1,4 +1,9 @@ -// IltPets.cs — ILT Hub "Pet" tab. +// PetsTab.cs — The Mini Remote's Pets tab. +// Originally SilentKelpie's IltPets (ILT Hub). Summoning is every server's, so the tab stayed in +// RynthAi when the ILT Hub went to the RynthILT plugin (2026-10-13). The ACECustom bits it reads +// (the refill / mastery charm server flags, whether this is an ILT world) come from RynthILT +// (RynthILT.Hub GetFeature / IsIltWorld; unknown without it, which never spends pyreals); the +// /pets and /shinies logs moved to RynthILT, which draws them at the bottom of this tab. // // * Pet roster (UtilityBelt Pets-tab style): every carried pet essence with three stat // lines (bond / level / craft · sex / mutations / potency / mastery · ratings / uses / @@ -18,17 +23,18 @@ // player bools the server stamps. Feeds PetManager.AllowSummonOnEmpty. // * Healing pet (UB HealingBuddy subset): summons a heal pet when HP drops, dismisses it // after the heal lands, holds PetManager's combat summons while it is out. -// * /pets and /shinies roster capture (read-only display). +// * /pets and /shinies logs: RynthILT's (RynthILT.Hub section "pets-logs", ILT only). using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using ImGuiNET; using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.Shared; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthAi.MiniRemote; -internal sealed class IltPets : IIltFeature +internal sealed class PetsTab { private static readonly string[] KindNames = { "Combat", "Healing", "Cosmetic" }; private static readonly string[] SortNames = { "Priority", "Bond", "Potency", "Breed ready", "Level", "Uses", "Name" }; @@ -36,7 +42,7 @@ internal sealed class IltPets : IIltFeature /// Un-ID'd essences auto-appraised per 2 s scan (keeps the server request rate low). private const int AutoAppraisePerScan = 2; - private readonly IltHubContext _ctx; + private readonly MiniRemoteContext _ctx; // Healing-pet state machine. private enum HealState { Idle, Summoning, Despawning } @@ -49,7 +55,7 @@ internal sealed class IltPets : IIltFeature private string _healStatus = "idle"; // Roster snapshot (rebuilt on the pump thread, read by the render thread). - private volatile IltPetStats[] _pets = Array.Empty(); + private volatile PetStats[] _pets = Array.Empty(); private long _lastPetScan; // Active-pet / cosmetic bookkeeping (pump thread; the ui* copies are for the render thread). @@ -74,14 +80,14 @@ internal sealed class IltPets : IIltFeature // Render-thread only: highlighted row and the sorted view cache. private int _highlightId; - private IltPetStats[]? _viewSource; + private PetStats[]? _viewSource; private int _viewKind = -1; private int _viewSort = -1; - private IltPetStats[] _view = Array.Empty(); + private PetStats[] _view = Array.Empty(); - public IltPets(IltHubContext ctx) => _ctx = ctx; + public PetsTab(MiniRemoteContext ctx) => _ctx = ctx; - private IltPetState S => _ctx.State.Pet; + private PetTabState S => _ctx.State.Pet; // ── Classification ────────────────────────────────────────────────────── @@ -110,7 +116,7 @@ internal sealed class IltPets : IIltFeature public bool IsPetDevice(WorldObject wo) { uint w = _ctx.Inventory.Wcid(wo); - if (w == IltInventory.WcidEncapsulatedSpirit) return false; + if (w == MiniRemoteInventory.WcidEncapsulatedSpirit) return false; if (w is >= 78780030 and <= 78780089) return false; // charm block if (w is >= 78780001 and <= 78780012) return false; // capture devices if (w is >= 787802001 and <= 787802072) return false; // summoned combat pet creatures @@ -167,7 +173,7 @@ internal sealed class IltPets : IIltFeature => IsPetNameCandidate(wo.Name) && !IsPetDevice(wo) && _ctx.Host.HasHasAppraisalData && !_ctx.Inventory.HasAppraisal(wo); - private IltPetAssignment? FindAssignment(string name) + private PetAssignment? FindAssignment(string name) => S.Assignments.FirstOrDefault(a => a.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); /// @@ -175,20 +181,20 @@ internal sealed class IltPets : IIltFeature /// pet. Anything else must be a pet device by type (); its /// naming then picks Healing / Cosmetic, defaulting to Combat. Null = not a pet. /// - private IltPetKind? ClassifyKind(WorldObject wo, out bool assigned) + private PetKind? ClassifyKind(WorldObject wo, out bool assigned) { var a = FindAssignment(wo.Name); if (a != null) { assigned = true; - return (IltPetKind)Math.Clamp(a.Kind, 0, 2); + return (PetKind)Math.Clamp(a.Kind, 0, 2); } assigned = false; - if (NameIs(wo, S.HealPetName)) return IltPetKind.Healing; + if (NameIs(wo, S.HealPetName)) return PetKind.Healing; if (!IsPetDevice(wo)) return null; - if (LooksLikeHealPet(wo.Name)) return IltPetKind.Healing; - if (LooksLikeCosmeticPet(wo.Name)) return IltPetKind.Cosmetic; - return IltPetKind.Combat; + if (LooksLikeHealPet(wo.Name)) return PetKind.Healing; + if (LooksLikeCosmeticPet(wo.Name)) return PetKind.Cosmetic; + return PetKind.Combat; } private static bool NameIs(WorldObject wo, string name) @@ -201,7 +207,7 @@ internal sealed class IltPets : IIltFeature private WorldObject? FindHealEssence() { if (!string.IsNullOrWhiteSpace(S.HealPetName)) return FindCarried(S.HealPetName); - return _ctx.Inventory.Items().FirstOrDefault(wo => ClassifyKind(wo, out _) == IltPetKind.Healing); + return _ctx.Inventory.Items().FirstOrDefault(wo => ClassifyKind(wo, out _) == PetKind.Healing); } // ── Charms / gates ────────────────────────────────────────────────────── @@ -209,17 +215,17 @@ internal sealed class IltPets : IIltFeature /// Summon Essence Refill charm is carried and switched on (or the server stamped the player bool). public bool RefillCharmActive() { - if (_ctx.Inventory.PlayerBool(IltInventory.BoolPyrealRefillActive)) return true; - var charm = _ctx.Inventory.FindByWcid(IltInventory.WcidSummonRefillCharm); - return charm != null && _ctx.Inventory.CharmStatus(charm) == IltTri.On; + if (_ctx.Inventory.PlayerBool(MiniRemoteInventory.BoolPyrealRefillActive)) return true; + var charm = _ctx.Inventory.FindByWcid(MiniRemoteInventory.WcidSummonRefillCharm); + return charm != null && _ctx.Inventory.CharmStatus(charm) == CharmState.On; } public bool MasteryCharmActive() { - if (_ctx.Options.IsOff(IltFeature.UniversalMastery)) return false; - if (_ctx.Inventory.PlayerBool(IltInventory.BoolUniversalMasteryActive)) return true; - var charm = _ctx.Inventory.FindByWcid(IltInventory.WcidUniversalMasteryCharm); - return charm != null && _ctx.Inventory.CharmStatus(charm) == IltTri.On; + if (_ctx.Ilt.IsOff(RynthIltHub.FeatureUniversalMastery)) return false; + if (_ctx.Inventory.PlayerBool(MiniRemoteInventory.BoolUniversalMasteryActive)) return true; + var charm = _ctx.Inventory.FindByWcid(MiniRemoteInventory.WcidUniversalMasteryCharm); + return charm != null && _ctx.Inventory.CharmStatus(charm) == CharmState.On; } /// @@ -230,10 +236,10 @@ internal sealed class IltPets : IIltFeature /// public bool AllowSummonOnEmpty() { - if (!S.UsePyrealRefillPath || !_ctx.Options.IsIltLikeWorld || !RefillCharmActive()) return false; - bool confirmed = _ctx.Options.IsOn(IltFeature.PetRefill) - || _ctx.Inventory.PlayerBool(IltInventory.BoolPyrealRefillActive); - if (!confirmed) RynthLog.Trace(LogCat.IltPets, "summon-on-empty refused: pet_refill not confirmed by the server"); + if (!S.UsePyrealRefillPath || !_ctx.Ilt.IsIltWorld || !RefillCharmActive()) return false; + bool confirmed = _ctx.Ilt.IsOn(RynthIltHub.FeaturePetRefill) + || _ctx.Inventory.PlayerBool(MiniRemoteInventory.BoolPyrealRefillActive); + if (!confirmed) RynthLog.Trace(LogCat.Pets, "summon-on-empty refused: pet_refill not confirmed by the server"); return confirmed; } @@ -254,55 +260,15 @@ internal sealed class IltPets : IIltFeature if (!PetMatchesEssence(pet, essence) && _cosmeticOutEssenceId != essence.Id) return false; if (_ctx.Inventory.IsBusy || !_ctx.Inventory.Use(essence)) return false; - long now = IltHubContext.NowMs; + long now = MiniRemoteContext.NowMs; _cosmeticOutEssenceId = 0; _cosmeticNextAt = now + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; _cosmeticStatus = "dismissed for combat"; - RynthLog.Trace(LogCat.IltPets, $"cosmetic pet '{pet.Name}' dismissed so a combat pet can be summoned"); + RynthLog.Trace(LogCat.Pets, $"cosmetic pet '{pet.Name}' dismissed so a combat pet can be summoned"); return true; } - // ── Rosters ───────────────────────────────────────────────────────────── - - /// Captures /pets or /shinies into the state (quiet). - public void RequestRoster(bool shinies) - { - RynthLog.Trace(LogCat.IltPets, $"RequestRoster(shinies={shinies})"); - string cmd = shinies ? "/shinies" : "/pets"; - if (_ctx.Capture.IsPending(cmd)) return; - string header = shinies ? "Your Shiny Log" : "Your Pet Log"; - _ctx.Capture.Enqueue(new IltChatRequest - { - Command = cmd, - IsResponseLine = t => t.Contains(header, StringComparison.OrdinalIgnoreCase) || IltParse.RosterLine.IsMatch(t), - IsTerminator = t => t.Contains(header + " is empty", StringComparison.OrdinalIgnoreCase), - IdleEndMs = 1500, - FirstLineTimeoutMs = 10000, - Eat = true, - OnComplete = r => - { - if (r.UnknownCommand) { _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.Off); return; } - if (r.Lines.Count == 0) return; - _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.On); - ApplyRoster(shinies, r.Lines); - }, - }); - } - - /// Also used by the login probe tap so the roster fills without a second command. - public void ApplyRoster(bool shinies, List lines) - { - RynthLog.Trace(LogCat.IltPets, $"ApplyRoster(shinies={shinies}, lines={lines.Count})"); - var list = new List(); - foreach (string l in lines) - { - var m = IltParse.RosterLine.Match(l); - if (m.Success) list.Add(m.Groups[2].Value.Trim()); - } - if (shinies) S.ShinyLog = list; else S.PetLog = list; - } - - // ── IIltFeature ───────────────────────────────────────────────────────── + // ── Lifecycle ─────────────────────────────────────────────────────────── public void Tick(long nowMs) { @@ -339,7 +305,7 @@ internal sealed class IltPets : IIltFeature _hudPetStatus = _heal != HealState.Idle ? "Healing" : "Out"; return; } - var next = ChosenEssence(IltPetKind.Combat); + var next = ChosenEssence(PetKind.Combat); if (next == null) { _hudPetName = string.Empty; _hudPetStatus = string.Empty; return; } _hudPetName = next.Name; _hudPetStatus = _ctx.Inventory.Uses(next) == 0 && !AllowSummonOnEmpty() ? "Empty" : "Ready"; @@ -357,12 +323,12 @@ internal sealed class IltPets : IIltFeature if (S.AutoDespawnAfterHeal) { _heal = HealState.Despawning; - _despawnAt = IltHubContext.NowMs + 1000; + _despawnAt = MiniRemoteContext.NowMs + 1000; _healStatus = "heal landed, dismissing"; } else { - EndHealCycle(IltHubContext.NowMs, "heal landed"); + EndHealCycle(MiniRemoteContext.NowMs, "heal landed"); } } return false; @@ -371,7 +337,7 @@ internal sealed class IltPets : IIltFeature public void OnLogout() { _heal = HealState.Idle; - _pets = Array.Empty(); + _pets = Array.Empty(); _uiActivePet = string.Empty; _lastSummonEssenceId = 0; _cosmeticOutEssenceId = 0; @@ -526,13 +492,13 @@ internal sealed class IltPets : IIltFeature // Covers the summon round-trip so the pet isn't re-summoned before it appears. _cosmeticNextAt = now + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; _cosmeticStatus = "summoning"; - RynthLog.Trace(LogCat.IltPets, $"cosmetic pet summon: {essence.Name}"); + RynthLog.Trace(LogCat.Pets, $"cosmetic pet summon: {essence.Name}"); } // ── Manual actions (pump thread) ──────────────────────────────────────── /// Summons from , or the current type's chosen pet when 0. - private void SummonPet(int essenceId, IltPetKind kind) + private void SummonPet(int essenceId, PetKind kind) { if (FindOwnPet() is { } outPet) { _ctx.Chat($"[Mini Remote] {outPet.Name} is already out — Despawn it first."); return; } if (_heal != HealState.Idle) { _ctx.Chat("[Mini Remote] The heal-pet cycle is running."); return; } @@ -545,7 +511,7 @@ internal sealed class IltPets : IIltFeature _lastSummonEssenceId = essence.Id; if (NameIs(essence, S.CosmeticPetName)) _cosmeticOutEssenceId = essence.Id; - RynthLog.Trace(LogCat.IltPets, $"manual summon: {essence.Name}"); + RynthLog.Trace(LogCat.Pets, $"manual summon: {essence.Name}"); } /// Dismisses the pet that is out by using the essence that summoned it again. @@ -559,19 +525,19 @@ internal sealed class IltPets : IIltFeature if (!_ctx.Inventory.Use(essence)) return; // A manual dismiss shouldn't be undone straight away by "Keep cosmetic pet out". - _cosmeticNextAt = IltHubContext.NowMs + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; + _cosmeticNextAt = MiniRemoteContext.NowMs + Math.Max(5, S.CosmeticRespawnSeconds) * 1000L; if (essence.Id == _cosmeticOutEssenceId) _cosmeticOutEssenceId = 0; - RynthLog.Trace(LogCat.IltPets, $"manual despawn: {pet.Name} via {essence.Name}"); + RynthLog.Trace(LogCat.Pets, $"manual despawn: {pet.Name} via {essence.Name}"); } /// The pet the type's tick selects: first combat priority, the heal pet, or the cosmetic pet. - private WorldObject? ChosenEssence(IltPetKind kind) + private WorldObject? ChosenEssence(PetKind kind) { switch (kind) { - case IltPetKind.Healing: + case PetKind.Healing: return FindHealEssence(); - case IltPetKind.Cosmetic: + case PetKind.Cosmetic: return FindCarried(S.CosmeticPetName); default: var rules = PetRules(); @@ -612,7 +578,7 @@ internal sealed class IltPets : IIltFeature } /// Gives the item selected in the game a summon type (pump thread). - private void AddSelectedAs(IltPetKind kind) + private void AddSelectedAs(PetKind kind) { if (!_ctx.Host.HasGetSelectedItemId) { _ctx.Chat("[Mini Remote] This client build can't read the selected item."); return; } int id = unchecked((int)_ctx.Host.GetSelectedItemId()); @@ -626,27 +592,27 @@ internal sealed class IltPets : IIltFeature /// Re-types an essence (null = back to auto classification) and drops it from the other /// types' selections so a pet is only ever chosen under one type. /// - private void SetKind(int id, string name, IltPetKind? kind) + private void SetKind(int id, string name, PetKind? kind) { S.Assignments.RemoveAll(a => a.Name.Equals(name, StringComparison.OrdinalIgnoreCase)); - if (kind is { } k) S.Assignments.Add(new IltPetAssignment { Name = name, Kind = (int)k }); + if (kind is { } k) S.Assignments.Add(new PetAssignment { Name = name, Kind = (int)k }); - if (kind != IltPetKind.Combat && PetRules().Any(r => r.Id == id || r.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) + if (kind != PetKind.Combat && PetRules().Any(r => r.Id == id || r.Name.Equals(name, StringComparison.OrdinalIgnoreCase))) SetCombatSelected(id, name, false); - if (kind != IltPetKind.Healing && S.HealPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) + if (kind != PetKind.Healing && S.HealPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) S.HealPetName = string.Empty; - if (kind != IltPetKind.Cosmetic && S.CosmeticPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) + if (kind != PetKind.Cosmetic && S.CosmeticPetName.Trim().Equals(name, StringComparison.OrdinalIgnoreCase)) S.CosmeticPetName = string.Empty; RebuildPetSnapshot(autoAppraise: false); } /// Applies a roster tick for the row's type (pump thread). - private void SetSelected(int id, string name, IltPetKind kind, bool on) + private void SetSelected(int id, string name, PetKind kind, bool on) { switch (kind) { - case IltPetKind.Healing: S.HealPetName = on ? name : string.Empty; break; - case IltPetKind.Cosmetic: S.CosmeticPetName = on ? name : string.Empty; break; + case PetKind.Healing: S.HealPetName = on ? name : string.Empty; break; + case PetKind.Cosmetic: S.CosmeticPetName = on ? name : string.Empty; break; default: SetCombatSelected(id, name, on); break; } RebuildPetSnapshot(autoAppraise: false); @@ -692,7 +658,7 @@ internal sealed class IltPets : IIltFeature { var rules = PetRules(); long unixNow = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - var rows = new List(); + var rows = new List(); int appraised = 0; foreach (var wo in _ctx.Inventory.Items()) { @@ -706,15 +672,15 @@ internal sealed class IltPets : IIltFeature continue; } - var s = IltPetStatsReader.Read(_ctx.Host, _ctx.Inventory, wo, unixNow); + var s = PetStatsReader.Read(_ctx.Host, _ctx.Inventory, wo, unixNow); s.Kind = kind.Value; s.KindAssigned = assigned; int pri = rules.FindIndex(r => r.Id == wo.Id || r.Name.Equals(wo.Name, StringComparison.OrdinalIgnoreCase)); s.Priority = pri >= 0 ? pri : int.MaxValue; s.Selected = s.Kind switch { - IltPetKind.Healing => NameIs(wo, S.HealPetName), - IltPetKind.Cosmetic => NameIs(wo, S.CosmeticPetName), + PetKind.Healing => NameIs(wo, S.HealPetName), + PetKind.Cosmetic => NameIs(wo, S.CosmeticPetName), _ => pri >= 0, }; rows.Add(s); @@ -735,8 +701,8 @@ internal sealed class IltPets : IIltFeature RenderRosterHeader(settings); RenderRosterTable(); - // The tab is universal; the charms and the /pets and /shinies logs are ILT's. - bool ilt = _ctx.Options.IsIltLikeWorld; + // The tab is universal; the charms and the /pets and /shinies logs are ILT's (the logs RynthILT's). + bool ilt = _ctx.Ilt.IsIltWorld; if (ilt) { ImGui.Separator(); @@ -744,23 +710,19 @@ internal sealed class IltPets : IIltFeature } ImGui.Separator(); RenderHealing(); - if (ilt) - { - ImGui.Separator(); - RenderRosters(); - } + _ctx.Ilt.RenderSection(RynthIltHub.SectionPetLogs); } /// Type / Sort combos, action buttons, the active-summon line and per-type options. private void RenderRosterHeader(LegacyUiSettings settings) { - var kind = (IltPetKind)Math.Clamp(S.RosterKind, 0, 2); + var kind = (PetKind)Math.Clamp(S.RosterKind, 0, 2); ImGui.TextUnformatted("Type"); ImGui.SameLine(); ImGui.SetNextItemWidth(100); int k = (int)kind; - if (ImGui.Combo("##iltpetkind", ref k, KindNames, KindNames.Length)) { S.RosterKind = k; kind = (IltPetKind)k; _highlightId = 0; } + if (ImGui.Combo("##iltpetkind", ref k, KindNames, KindNames.Length)) { S.RosterKind = k; kind = (PetKind)k; _highlightId = 0; } ImGui.SameLine(); ImGui.TextUnformatted("Sort"); ImGui.SameLine(); @@ -788,7 +750,7 @@ internal sealed class IltPets : IIltFeature switch (kind) { - case IltPetKind.Combat: + case PetKind.Combat: { bool summon = settings.SummonPets; if (ImGui.Checkbox("Summon when monsters are near", ref summon)) _ctx.Post(() => { settings.SummonPets = summon; _ctx.SaveCombatSettings?.Invoke(); }); @@ -801,10 +763,10 @@ internal sealed class IltPets : IIltFeature ImGui.TextDisabled("Tick pets to add them to the summon list; with Sort = Priority the arrows set the order."); break; } - case IltPetKind.Healing: + case PetKind.Healing: ImGui.TextDisabled("Tick one heal pet (none ticked = first Healing Buddy / Dule box). Settings are below."); break; - case IltPetKind.Cosmetic: + case PetKind.Cosmetic: { bool keep = S.KeepCosmeticOut; if (ImGui.Checkbox("Keep cosmetic pet out", ref keep)) S.KeepCosmeticOut = keep; @@ -820,14 +782,14 @@ internal sealed class IltPets : IIltFeature } /// Sorted rows of the current type, cached until the snapshot / type / sort changes. - private IltPetStats[] CurrentView() + private PetStats[] CurrentView() { var src = _pets; int kind = Math.Clamp(S.RosterKind, 0, 2); int sort = Math.Clamp(S.RosterSort, 0, SortNames.Length - 1); if (!ReferenceEquals(src, _viewSource) || kind != _viewKind || sort != _viewSort) { - _view = IltPetStatsReader.Sort(src.Where(p => (int)p.Kind == kind), (IltPetSort)sort); + _view = PetStatsReader.Sort(src.Where(p => (int)p.Kind == kind), (PetSort)sort); _viewSource = src; _viewKind = kind; _viewSort = sort; @@ -839,12 +801,12 @@ internal sealed class IltPets : IIltFeature private void RenderRosterTable() { var rows = CurrentView(); - var kind = (IltPetKind)Math.Clamp(S.RosterKind, 0, 2); - bool showArrows = kind == IltPetKind.Combat && S.RosterSort == (int)IltPetSort.Priority; + var kind = (PetKind)Math.Clamp(S.RosterKind, 0, 2); + bool showArrows = kind == PetKind.Combat && S.RosterSort == (int)PetSort.Priority; if (rows.Length == 0) { - ImGui.TextDisabled(kind == IltPetKind.Cosmetic + ImGui.TextDisabled(kind == PetKind.Cosmetic ? "No cosmetic pets yet — select an essence in your pack and press Add sel., or right-click a pet in another type." : $"No {KindNames[(int)kind].ToLowerInvariant()} pet essences carried."); return; @@ -893,7 +855,7 @@ internal sealed class IltPets : IIltFeature } /// Right-click menu on a roster row: summon / move to another type / clear override. - private void RenderRowContextMenu(IltPetStats r) + private void RenderRowContextMenu(PetStats r) { if (!ImGui.BeginPopupContextItem($"##pctx{r.Id}")) return; var row = r; @@ -902,7 +864,7 @@ internal sealed class IltPets : IIltFeature for (int i = 0; i < KindNames.Length; i++) { if (i == (int)r.Kind) continue; - var to = (IltPetKind)i; + var to = (PetKind)i; if (ImGui.MenuItem("Move to " + KindNames[i])) _ctx.Post(() => SetKind(row.Id, row.Name, to)); } if (r.KindAssigned && ImGui.MenuItem("Clear type override")) @@ -924,7 +886,7 @@ internal sealed class IltPets : IIltFeature private void RenderCharms() { ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Pet charms"); - bool refillOff = _ctx.Options.IsOff(IltFeature.PetRefill); + bool refillOff = _ctx.Ilt.IsOff(RynthIltHub.FeaturePetRefill); ImGui.TextUnformatted("Summon Essence Refill: " + (refillOff ? "disabled on this server" : _uiRefillActive ? "ON" : "off / not carried")); ImGui.BeginDisabled(refillOff); bool usePath = S.UsePyrealRefillPath; @@ -932,8 +894,8 @@ internal sealed class IltPets : IIltFeature S.UsePyrealRefillPath = usePath; ImGui.EndDisabled(); ImGui.TextUnformatted("Universal Summoning Mastery: " - + (_ctx.Options.IsOff(IltFeature.UniversalMastery) ? "disabled on this server" : _uiMasteryActive ? "ON" : "off / not carried")); - if (!_ctx.Options.IsOff(IltFeature.RequireComps) && !_uiHasCasting) + + (_ctx.Ilt.IsOff(RynthIltHub.FeatureUniversalMastery) ? "disabled on this server" : _uiMasteryActive ? "ON" : "off / not carried")); + if (!_ctx.Ilt.IsOff(RynthIltHub.FeatureRequireComps) && !_uiHasCasting) ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "No spell components or Infinite Casting Stone carried."); } @@ -961,22 +923,4 @@ internal sealed class IltPets : IIltFeature if (ImGui.InputInt("Heal timeout (s)", ref to)) S.PetTimeoutSeconds = Math.Max(5, to); ImGui.TextDisabled("Status: " + _healStatus); } - - private void RenderRosters() - { - RenderRoster("Pet log", false, IltFeature.Pets, S.PetLog); - RenderRoster("Shiny log", true, IltFeature.Shinies, S.ShinyLog); - } - - private void RenderRoster(string label, bool shinies, string key, List list) - { - if (_ctx.Options.IsOff(key)) return; - var snap = list.ToArray(); - if (ImGui.TreeNode($"{label} ({snap.Length})##{key}")) - { - if (ImGui.SmallButton($"Refresh##{key}")) _ctx.Post(() => RequestRoster(shinies)); - foreach (string s in snap) ImGui.BulletText(s); - ImGui.TreePop(); - } - } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/QuestsTab.cs similarity index 59% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs rename to Plugins/RynthCore.Plugin.RynthAi/MiniRemote/QuestsTab.cs index f9760c3..63fd746 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltQuests.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/QuestsTab.cs @@ -1,4 +1,8 @@ -// IltQuests.cs — Quest Tracker UI and Quest Bonus (/qb) list for the ILT Hub Character tab. +// QuestsTab.cs — The Mini Remote's Quests tab: the /myquests tracker and the floating favorites HUD. +// Originally SilentKelpie's IltQuests (ILT Hub). The tab is universal (every server has /myquests), +// so it stayed in RynthAi when the ILT Hub went to the RynthILT plugin (2026-10-13); its Quest bonus +// (/qb) list is ACECustom's and moved with RynthILT, which draws it at the top of this tab +// (RynthILT.Hub section "quests-qb") on Infinite Leaftide. // // Quest Tracker reuses the meta QuestTracker (the same /myquests cache the meta // expression engine reads) — it never runs a second parser. Friendly names come from: @@ -6,9 +10,6 @@ // 2. the description the server prints in /myquests, // 3. the raw flag key. // UB's bundled quests.xml is NOT embedded (no license on UB content). -// -// QB: "/qb list" prints a completed and an incomplete section; both are tracked -// separately (UB merged them). Server throttles /qb to once per minute. using System; using System.Collections.Generic; using System.IO; @@ -20,37 +21,28 @@ using ImGuiNET; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.Plugin.RynthAi.Meta; using RynthCore.Install; +using RynthCore.Plugin.Shared; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthAi.MiniRemote; -internal sealed class IltQuests : IIltFeature +internal sealed class QuestsTab { /// Optional user quest-name file (UB-style or simple key/name XML). public static readonly string QuestsXmlPath = System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, @"quests.xml"); private static readonly Regex KillTaskRegex = new(@"(killtask|killcount|slayerquest|totalgolem.*dead|(kills$))", RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); - private static readonly Regex QbFlagLine = new(@"^[a-zA-Z0-9_\-!@\(\)?]+$", RegexOptions.Compiled | RegexOptions.CultureInvariant); private const long QuestRefreshCooldownMs = 60_000; - private const long QbCooldownMs = 60_000; - private readonly IltHubContext _ctx; + private readonly MiniRemoteContext _ctx; private readonly Func _tracker; private Dictionary _friendlyNames = new(StringComparer.OrdinalIgnoreCase); private long _lastQuestRefreshAt = -QuestRefreshCooldownMs; - private long _lastQbAt = -QbCooldownMs; - - // QB results (replaced wholesale; read by the render thread). - private volatile string[] _qbCompleted = Array.Empty(); - private volatile string[] _qbIncomplete = Array.Empty(); - private volatile string _qbStatus = "not loaded"; - private long _qbCount = -1; - private volatile int _qbGeneration; // bumped per successful "/qb list"; 0 = never loaded this session // Render-thread UI state. private int _questView; // 0 timed, 1 kill tasks, 2 once, 3 all - public IltQuests(IltHubContext ctx, Func tracker) + public QuestsTab(MiniRemoteContext ctx, Func tracker) { _ctx = ctx; _tracker = tracker; @@ -100,7 +92,7 @@ internal sealed class IltQuests : IIltFeature } } } - catch (Exception ex) { RynthLog.Exception(LogCat.IltQuests, ex, "quests.xml load"); } + catch (Exception ex) { RynthLog.Exception(LogCat.Quests, ex, "quests.xml load"); } _friendlyNames = map; } @@ -109,11 +101,11 @@ internal sealed class IltQuests : IIltFeature /// Quiet /myquests refresh with a 60 s client-side cooldown (server throttle). public string RefreshQuests() { - RynthLog.Trace(LogCat.IltQuests, $"RefreshQuests()"); + RynthLog.Trace(LogCat.Quests, $"RefreshQuests()"); var t = _tracker(); if (t == null) return "Quest tracker not ready."; - if (_ctx.Options.IsOff(IltFeature.Quests) || t.Disabled) return "/myquests is disabled on this server."; - long now = IltHubContext.NowMs; + if (_ctx.Ilt.IsOff(RynthIltHub.FeatureQuests) || t.Disabled) return "/myquests is disabled on this server."; + long now = MiniRemoteContext.NowMs; if (now - _lastQuestRefreshAt < QuestRefreshCooldownMs) return $"Wait {(QuestRefreshCooldownMs - (now - _lastQuestRefreshAt)) / 1000}s (server allows one /myquests per minute)."; _lastQuestRefreshAt = now; @@ -133,125 +125,10 @@ internal sealed class IltQuests : IIltFeature var hits = t.Snapshot().Where(r => rx.IsMatch(r.Key) || rx.IsMatch(FriendlyName(r))).OrderBy(r => r.Key).ToList(); if (hits.Count == 0) { _ctx.Chat($"[Mini Remote] No quest flags match '{pattern}' ({t.Count} cached)."); return; } foreach (var r in hits.Take(5)) - _ctx.Chat($"[Mini Remote] {FriendlyName(r)} [{r.Key}] solves {r.Solves}{(r.MaxSolves > 0 ? "/" + r.MaxSolves : "")} - {IltParse.Duration(r.TimeUntilReady())}"); + _ctx.Chat($"[Mini Remote] {FriendlyName(r)} [{r.Key}] solves {r.Solves}{(r.MaxSolves > 0 ? "/" + r.MaxSolves : "")} - {MiniRemoteText.Duration(r.TimeUntilReady())}"); if (hits.Count > 5) _ctx.Chat($"[Mini Remote] ...and {hits.Count - 5} more."); } - /// Captures "/qb list" (quiet). - public string RefreshQb() - { - RynthLog.Trace(LogCat.IltQuests, $"RefreshQb()"); - if (_ctx.Options.IsOff(IltFeature.Qb)) return "/qb is disabled on this server."; - long now = IltHubContext.NowMs; - if (now - _lastQbAt < QbCooldownMs) - return $"Wait {(QbCooldownMs - (now - _lastQbAt)) / 1000}s (server allows one /qb per minute)."; - if (_ctx.Capture.IsPending("/qb list")) return "Already loading..."; - _lastQbAt = now; - _qbStatus = "loading..."; - - _ctx.Capture.Enqueue(new IltChatRequest - { - Command = "/qb list", - IsResponseLine = IsQbLine, - IsTerminator = t => t.Contains("Quest bonus list is empty", StringComparison.OrdinalIgnoreCase) - || t.Contains("\"qb\" is not currently enabled", StringComparison.OrdinalIgnoreCase) - || t.StartsWith("[QB] This command may only be run once every", StringComparison.OrdinalIgnoreCase), - IdleEndMs = 5000, - FirstLineTimeoutMs = 30000, - Eat = true, - OnComplete = OnQbResult, - }); - return "Loading quest bonus list..."; - } - - private static bool IsQbLine(string t) - { - if (t.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase) - || t.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase) - || t.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) - return true; - if (!QbFlagLine.IsMatch(t)) return false; - if (t.StartsWith("You ", StringComparison.Ordinal) || t.StartsWith("The ", StringComparison.Ordinal)) return false; - return !(t.Contains("You have", StringComparison.OrdinalIgnoreCase) || t.Contains("command", StringComparison.OrdinalIgnoreCase) - || t.Contains("enabled", StringComparison.OrdinalIgnoreCase) || t.Contains("list", StringComparison.OrdinalIgnoreCase)); - } - - private void OnQbResult(IltChatResult r) - { - if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb not available"; return; } - if (r.TerminatorLine != null) - { - if (r.TerminatorLine.Contains("not currently enabled", StringComparison.OrdinalIgnoreCase)) - { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb is disabled on this server"; return; } - if (r.TerminatorLine.Contains("only be run once", StringComparison.OrdinalIgnoreCase)) - { _qbStatus = "rate limited by the server"; return; } - } - if (r.TimedOut) { _qbStatus = "no reply from server"; return; } - _ctx.Options.Set(IltFeature.Qb, IltTri.On); - - var done = new List(); - var todo = new List(); - List? current = null; - foreach (string line in r.Lines) - { - if (line.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = done; continue; } - if (line.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = todo; continue; } - if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) - { - int colon = line.IndexOf(':'); - if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); - continue; - } - if (line.Contains("is empty", StringComparison.OrdinalIgnoreCase)) continue; - (current ?? done).Add(line.Trim()); - } - done.Sort(StringComparer.OrdinalIgnoreCase); - todo.Sort(StringComparer.OrdinalIgnoreCase); - _qbCompleted = done.ToArray(); - _qbIncomplete = todo.ToArray(); - _qbStatus = $"{done.Count} completed, {todo.Count} incomplete"; - _qbGeneration++; - } - - /// Increments each time a "/qb list" reply is parsed (0 = not loaded this session). - public int QbGeneration => _qbGeneration; - - /// True when the last "/qb list" (completed or incomplete) contains the flag. - public bool QbHasFlag(string flag) - { - if (string.IsNullOrWhiteSpace(flag)) return false; - foreach (string f in _qbCompleted) - if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; - foreach (string f in _qbIncomplete) - if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; - return false; - } - - /// Login probe tap: "/qb" (no args) prints the count line. - public void ApplyQbProbe(List lines) - { - RynthLog.Trace(LogCat.IltQuests, $"ApplyQbProbe(lines={lines.Count})"); - foreach (string line in lines) - if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) - { - int colon = line.IndexOf(':'); - if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); - } - } - - // ── IIltFeature ───────────────────────────────────────────────────────── - - public void Tick(long nowMs) { } - public bool OnChat(string text) => false; - public void OnLogout() - { - _qbCompleted = Array.Empty(); - _qbIncomplete = Array.Empty(); - _qbCount = -1; - _qbStatus = "not loaded"; - _qbGeneration = 0; - } - // ── UI (render thread) ────────────────────────────────────────────────── /// Quest tracker body, filling the Mini Remote's Quests tab (the table uses the remaining height). @@ -259,12 +136,12 @@ internal sealed class IltQuests : IIltFeature { var t = _tracker(); if (t == null) { ImGui.TextDisabled("Quest tracker not ready."); return; } - if (_ctx.Options.IsOff(IltFeature.Quests) || t.Disabled) + if (_ctx.Ilt.IsOff(RynthIltHub.FeatureQuests) || t.Disabled) { ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "/myquests is disabled on this server."); return; } - var cs = _ctx.State.Character; + var cs = _ctx.State.Quests; if (ImGui.SmallButton("Refresh##quests")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQuests())); ImGui.SameLine(); @@ -329,7 +206,7 @@ internal sealed class IltQuests : IIltFeature var left = r.TimeUntilReady(); if (Classify(r) == QuestKind.Once) ImGui.TextDisabled("done"); else if (left <= TimeSpan.Zero) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ready"); - else ImGui.TextUnformatted(IltParse.Duration(left)); + else ImGui.TextUnformatted(MiniRemoteText.Duration(left)); ImGui.TableNextColumn(); ImGui.TextDisabled(r.Key); } ImGui.EndTable(); @@ -346,12 +223,12 @@ internal sealed class IltQuests : IIltFeature /// Starred keys as a set (render thread; the list itself is only edited on the pump thread). private HashSet FavoriteSet() - => new(_ctx.State.Character.QuestFavorites.ToArray(), StringComparer.OrdinalIgnoreCase); + => new(_ctx.State.Quests.QuestFavorites.ToArray(), StringComparer.OrdinalIgnoreCase); /// Stars / unstars a quest flag (pump thread). private void ToggleFavorite(string key) { - var list = _ctx.State.Character.QuestFavorites; + var list = _ctx.State.Quests.QuestFavorites; if (list.RemoveAll(k => k.Equals(key, StringComparison.OrdinalIgnoreCase)) == 0) list.Add(key.ToLowerInvariant()); } @@ -359,20 +236,20 @@ internal sealed class IltQuests : IIltFeature /// The floating favorites HUD (the tracker itself is the Mini Remote's Quests tab). Called every frame. public void RenderFloatingWindows() { - var cs = _ctx.State.Character; + var cs = _ctx.State.Quests; if (cs.ShowQuestFavoritesHud) RenderFavoritesHud(cs); } - /// The Mini Remote's Quests tab: the quest bonus (collapsed), then the tracker filling the rest. + /// The Mini Remote's Quests tab: the quest bonus (collapsed; RynthILT's, ILT only), then the tracker filling the rest. public void RenderTab() { - // The tab is universal (/myquests); the quest bonus list (/qb) is ILT's. - if (_ctx.Options.IsIltLikeWorld && ImGui.CollapsingHeader("Quest bonus (/qb)##qbwin")) RenderQb(); + // The tab is universal (/myquests); the quest bonus list (/qb) is ILT's and RynthILT's. + _ctx.Ilt.RenderSection(RynthIltHub.SectionQuestBonus); RenderQuestTracker(); } /// Compact always-on list of starred quests and when each is ready. - private void RenderFavoritesHud(IltCharacterState cs) + private void RenderFavoritesHud(QuestsTabState cs) { var flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoNav; @@ -403,7 +280,7 @@ internal sealed class IltQuests : IIltFeature var left = r.TimeUntilReady(); if (Classify(r) == QuestKind.Once) ImGui.TextDisabled("done"); else if (left <= TimeSpan.Zero) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ready"); - else ImGui.TextUnformatted(IltParse.Duration(left)); + else ImGui.TextUnformatted(MiniRemoteText.Duration(left)); } ImGui.EndTable(); } @@ -414,43 +291,11 @@ internal sealed class IltQuests : IIltFeature { bool locked = cs.QuestFavoritesHudLocked; if (ImGui.Checkbox("Lock position", ref locked)) cs.QuestFavoritesHudLocked = locked; - if (ImGui.MenuItem("Open quest tracker")) _ctx.ShowTab?.Invoke(IltSection.Quests); + if (ImGui.MenuItem("Open quest tracker")) _ctx.ShowTab?.Invoke(MiniRemoteTabs.Quests); if (ImGui.MenuItem("Refresh /myquests")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQuests())); if (ImGui.MenuItem("Hide favorites HUD")) cs.ShowQuestFavoritesHud = false; ImGui.EndPopup(); } ImGui.End(); } - - public void RenderQb() - { - if (_ctx.Options.IsOff(IltFeature.Qb)) - { - ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "/qb is disabled on this server."); - return; - } - if (ImGui.SmallButton("Load /qb list")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQb())); - ImGui.SameLine(); - long count = _qbCount; - ImGui.TextDisabled((count >= 0 ? $"QB count {IltParse.N0(count)} - " : "") + _qbStatus); - - string filter = _ctx.State.Character.QbFilter; - ImGui.SetNextItemWidth(220); - if (ImGui.InputTextWithHint("##qbfilter", "filter flags", ref filter, 64u)) - _ctx.State.Character.QbFilter = filter; - - RenderQbList("Incomplete", _qbIncomplete, filter, LegacyDashboardRenderer.ColAmber); - RenderQbList("Completed", _qbCompleted, filter, LegacyDashboardRenderer.ColGreen); - } - - private static void RenderQbList(string label, string[] items, string filter, Vector4 color) - { - var shown = filter.Length == 0 ? items : items.Where(i => i.Contains(filter, StringComparison.OrdinalIgnoreCase)).ToArray(); - if (ImGui.TreeNode($"{label} ({shown.Length})##qb{label}")) - { - if (ImGui.SmallButton($"Copy##qbc{label}")) ImGui.SetClipboardText(string.Join(Environment.NewLine, shown)); - foreach (string s in shown) ImGui.TextColored(color, s); - ImGui.TreePop(); - } - } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/VTankUsdImporter.cs similarity index 96% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs rename to Plugins/RynthCore.Plugin.RynthAi/MiniRemote/VTankUsdImporter.cs index d444a03..24c645f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltUsdImporter.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/MiniRemote/VTankUsdImporter.cs @@ -1,4 +1,7 @@ -// IltUsdImporter.cs — VirindiTank .usd settings → RynthAi monster / weapon / consumable rules (Gear tab, P2). +// VTankUsdImporter.cs — VirindiTank .usd settings → RynthAi monster / weapon / consumable rules. +// Originally SilentKelpie's IltUsdImporter (ILT Hub, Gear tab). It edits RynthAi's own rules, so it +// stayed in RynthAi when the ILT Hub went to RynthILT (2026-10-13); RynthILT's Gear tab still shows it +// (RynthAi.Hub section "vtank-import"). // // .usd is VTank's line-based table dump. Each table is: // @@ -21,9 +24,9 @@ using ImGuiNET; using RynthCore.Loot; using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthAi.MiniRemote; -internal sealed class IltUsdImporter +internal sealed class VTankUsdImporter { /// Default VTank profile folder when the Decal registry value is unavailable. public const string DefaultVtProfileDir = @"C:\Games\VirindiPlugins\VirindiTank\"; @@ -60,15 +63,15 @@ internal sealed class IltUsdImporter public List Notes = new(); } - private readonly IltHubContext _ctx; + private readonly MiniRemoteContext _ctx; private volatile ImportPlan? _plan; private volatile string _status = string.Empty; private string _pathInput = string.Empty; - public IltUsdImporter(IltHubContext ctx) + public VTankUsdImporter(MiniRemoteContext ctx) { _ctx = ctx; - _pathInput = ctx.State.Gear.LastUsdPath; + _pathInput = ctx.State.LastUsdPath; } /// VTank's profile folder from Decal's registry entry, else the default install path. @@ -215,7 +218,7 @@ internal sealed class IltUsdImporter else if (t.Name.Equals("pets", StringComparison.OrdinalIgnoreCase)) PlanConsumables(t, plan, forceType: "Pet"); else if (ConsumableTables.Contains(t.Name)) PlanConsumables(t, plan, forceType: null); } - _ctx.State.Gear.LastUsdPath = path; + _ctx.State.LastUsdPath = path; _plan = plan; _status = $"Preview: {plan.Monsters.Count} monsters, {plan.Weapons.Count} weapons, {plan.Consumables.Count} consumables."; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs index 634b418..7c40aa0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/PluginExports.cs @@ -16,7 +16,9 @@ public static unsafe class PluginExports // Typed interfaces for other plugins (host GetPluginInterface, API v68): "RynthAi.Script" v1 // for RynthLua, "RynthAi.Status" v1 for RynthNet (the bot state it shares with the other clients), // "RynthAi.Activity" v1 for RynthSort (what the bot is doing, so pack moves stay out of its way), - // "RynthAi.Combat" v1 for RynthLua (a script choosing attack and heal spells, Shared/RynthAiCombatApi.cs). + // "RynthAi.Combat" v1 for RynthLua (a script choosing attack and heal spells, Shared/RynthAiCombatApi.cs), + // "RynthAi.Hub" v1 for RynthILT (the Mini Remote hosting its ILT tabs, /myquests, spell names, loot + // matching, the .usd importer, session stats; Shared/RynthAiHubApi.cs, HubInterface.cs). // Fixed signature: void* (const char* iface, uint version). [UnmanagedCallersOnly(EntryPoint = "RynthPluginQueryInterface", CallConvs = new[] { typeof(CallConvCdecl) })] private static IntPtr QueryInterface(IntPtr ifaceAnsi, uint version) @@ -27,6 +29,7 @@ public static unsafe class PluginExports IntPtr table = ScriptInterface.Query(iface, version); if (table == IntPtr.Zero) table = StatusInterface.Query(iface, version); if (table == IntPtr.Zero) table = ActivityInterface.Query(iface, version); + if (table == IntPtr.Zero) table = HubInterface.Query(iface, version); return table != IntPtr.Zero ? table : CombatHookInterface.Query(iface, version); } catch @@ -50,6 +53,8 @@ public static unsafe class PluginExports catch (Exception ex) { LogShutdownError(plugin, "StatusInterface.Release", ex); } try { ActivityInterface.Release(); } catch (Exception ex) { LogShutdownError(plugin, "ActivityInterface.Release", ex); } + try { HubInterface.Release(); } // Version 0; the table stays (RynthILT's render thread may hold it) + catch (Exception ex) { LogShutdownError(plugin, "HubInterface.Release", ex); } try { CombatHookInterface.Shutdown(); } // the hook goes native at once (RynthLua re-claims after a reload) catch (Exception ex) { LogShutdownError(plugin, "CombatHookInterface.Shutdown", ex); } try @@ -97,7 +102,7 @@ public static unsafe class PluginExports [UnmanagedCallersOnly(EntryPoint = "RynthPluginTick", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Tick() => Runtime.OnTick(); - // Local ImGui windows (ILT Hub, HUDs, translator, item info, nav overlay). The engine + // Local ImGui windows (Mini Remote, HUDs, translator, item info, nav overlay). The engine // calls this when the export exists; the main panels stay on the engine side. [UnmanagedCallersOnly(EntryPoint = "RynthPluginRender", CallConvs = new[] { typeof(CallConvCdecl) })] public static void Render() => Runtime.OnRender(); @@ -113,9 +118,9 @@ public static unsafe class PluginExports /// /// Engine dashboard drawers (RynthCore 2026.10.5.21+): draws the named UTF-8 surface into the /// engine's current ImGui window on the render thread and reports the size it wants. - /// Surfaces: "miniremote" (the RynthAi dashboard's Mini Remote drawer), "miniremote-window" - /// (the engine's Mini Remote window, which hosts the remote with its Toggles and ILT tabs) - /// and "guardian" (RynthCore 2026.10.5.29+: the engine's Guardian ILT panel). + /// Surfaces: "miniremote" (the RynthAi dashboard's Mini Remote drawer) and "miniremote-window" + /// (the engine's Mini Remote window, which hosts the remote with its Toggles, its tabs and + /// RynthILT's ILT tabs). The Guardian ILT panel ("guardian") is RynthILT's since 2026-10-13. /// RynthCore 2026.10.5.30+ adds ":popout" to the name when the panel is popped out into its /// own window, whose ImGui context is not the one in Host.ImGuiContext; the surfaces draw /// in the engine's current context either way (RenderEmbedded*). @@ -131,17 +136,9 @@ public static unsafe class PluginExports if (name.EndsWith(":popout"u8)) name = name[..^":popout"u8.Length]; var plugin = Runtime.Plugin; if (plugin == null) return 0; - System.Numerics.Vector2 want; - if (name.SequenceEqual("guardian"u8)) - { - if (!plugin.RenderEmbeddedGuardian(new System.Numerics.Vector2(width, height), out want)) return 0; - } - else - { - bool window = name.SequenceEqual("miniremote-window"u8); - if (!window && !name.SequenceEqual("miniremote"u8)) return 0; - if (!plugin.RenderEmbeddedMiniRemote(window, out want)) return 0; - } + bool window = name.SequenceEqual("miniremote-window"u8); + if (!window && !name.SequenceEqual("miniremote"u8)) return 0; + if (!plugin.RenderEmbeddedMiniRemote(window, out System.Numerics.Vector2 want)) return 0; if (wantWidth != null) *wantWidth = want.X; if (wantHeight != null) *wantHeight = want.Y; return 1; @@ -720,17 +717,20 @@ public static unsafe class PluginExports private static IntPtr _progressionPtr = IntPtr.Zero; /// - /// Skills panel Progression tab (ILT augmentations / enlightenment). Same contract as - /// RynthPluginGetPatrolInfoJson: one static buffer, valid until the next call; the engine - /// polls it from its pump thread only. + /// The Skills panel's Progression tab for an engine that still asks RynthAi: the planners went + /// to RynthILT (2026-10-13), so this passes on RynthILT's RynthILTGetProgressionJson + /// ({"available":false} without RynthILT). Same contract as before: one static buffer, valid + /// until the next call; the engine polls it from its pump thread only. (The Charms Tracking + /// export, RynthPluginGetCharmsJson, for engines up to 2026.10.5.35 is gone with the charms.) /// [UnmanagedCallersOnly(EntryPoint = "RynthPluginGetProgressionJson", CallConvs = new[] { typeof(CallConvCdecl) })] public static IntPtr GetProgressionJson() { try { - string json = Runtime.Plugin?.BuildProgressionJson() ?? "{\"available\":false}"; - IntPtr newPtr = Marshal.StringToHGlobalAnsi(json); + var host = Runtime.Plugin?.HostForIlt; + string? json = host is { HasGetPluginExportJson: true } h ? h.GetPluginExportJson("RynthILT", "RynthILTGetProgressionJson") : null; + IntPtr newPtr = Marshal.StringToHGlobalAnsi(string.IsNullOrEmpty(json) ? "{\"available\":false}" : json); IntPtr oldPtr = Interlocked.Exchange(ref _progressionPtr, newPtr); if (oldPtr != IntPtr.Zero) Marshal.FreeHGlobal(oldPtr); @@ -742,32 +742,6 @@ public static unsafe class PluginExports } } - private static IntPtr _charmsPtr = IntPtr.Zero; - - /// - /// ACECustom registry charms (acquired / active / server state) for engines up to 2026.10.5.35, - /// whose Settings panel has a Charms Tracking tab; newer engines leave charms to the Mini - /// Remote's Charms tab. Same contract as RynthPluginGetProgressionJson: one static buffer, - /// valid until the next call; the engine polls it from its pump thread only. - /// - [UnmanagedCallersOnly(EntryPoint = "RynthPluginGetCharmsJson", CallConvs = new[] { typeof(CallConvCdecl) })] - public static IntPtr GetCharmsJson() - { - try - { - string json = Runtime.Plugin?.BuildCharmsJson() ?? "{\"available\":false}"; - IntPtr newPtr = Marshal.StringToHGlobalAnsi(json); - IntPtr oldPtr = Interlocked.Exchange(ref _charmsPtr, newPtr); - if (oldPtr != IntPtr.Zero) - Marshal.FreeHGlobal(oldPtr); - return newPtr; - } - catch - { - return IntPtr.Zero; - } - } - // ── Items bridge (engine-side Avalonia ItemsPanel) ────────────────────── private static IntPtr _itemsPtr = IntPtr.Zero; diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs index 8d3ac65..66b5cb0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiCommands.cs @@ -3213,7 +3213,7 @@ public sealed partial class RynthAiPlugin return sb.ToString(); } - // Minimal JSON string escaper for hand-built export JSON (route names, ILT Hub text). + // Minimal JSON string escaper for hand-built export JSON (route names, panel text). internal static string JsonEscape(string s) { var sb = new System.Text.StringBuilder(s.Length + 8); diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs index b65da80..aea0c32 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.DataFolders.cs @@ -2,12 +2,12 @@ using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using RynthCore.Install; -using RynthCore.Plugin.RynthAi.Diagnostics; +using RynthCore.Plugin.Shared; namespace RynthCore.Plugin.RynthAi; // Players reported metas and navs "not saving" and the plugin folders being "read only" -// (2026-10-13). Every save now reports a failure (Diagnostics/DataWriteGuard.cs); this is the +// (2026-10-13). Every save now reports a failure (Plugins/Shared/DataWriteGuard.cs); this is the // startup self-check that finds a folder the client can't write before anything is lost, and // the tick that posts those lines once the character is in game. public sealed partial class RynthAiPlugin diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs index 7a2ddee..6631259 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.LocalFeatures.cs @@ -1,5 +1,7 @@ -// RynthAiPlugin.LocalFeatures.cs — ILT Hub, floating HUDs, chat translation, item info, the nav -// overlay and the UB damage seed. +// RynthAiPlugin.LocalFeatures.cs — the Mini Remote's universal tabs, floating HUDs, chat +// translation, item info, the nav overlay and the UB damage seed. (The ILT Hub moved to the RynthILT +// plugin 2026-10-13: its tabs come through RynthILT.Hub, MiniRemote/IltClient.cs, and RynthILT +// borrows from RynthAi through RynthAi.Hub, HubInterface.cs.) // // The engine draws the main panels. These features draw their own ImGui windows from // RynthPluginRender / RynthPluginRenderOverlay. Lifecycle methods on RynthAiPlugin call into @@ -16,7 +18,9 @@ public sealed partial class RynthAiPlugin { private NavBreadcrumbTracker? _navBreadcrumbs; private NavOverlayRenderer? _navOverlay; - private IltHub.IltHubController? _iltHub; + private MiniRemote.MiniRemoteController? _miniRemote; + // RynthILT's side of the Mini Remote (its ILT tabs, sections, feature bits); lives for the plugin. + private MiniRemote.IltClient? _ilt; private Huds.HudController? _huds; private Huds.HudIconCache? _hudIcons; private Translate.ChatTranslator? _translator; @@ -106,39 +110,55 @@ public sealed partial class RynthAiPlugin } /// - /// ILT Hub and floating HUDs for the loaded character. No-op until the per-character - /// folder exists, so login and the deferred settings load in OnTick both call this. + /// The Mini Remote's universal tabs and the floating HUDs for the loaded character. No-op until + /// the per-character folder exists, so login and the deferred settings load in OnTick both call this. /// - private void CreateIltHub() + private void CreateMiniRemote() { - if (_dashboard == null || string.IsNullOrEmpty(_dashboard.CharFolder) || _iltHub != null) + if (_dashboard == null || string.IsNullOrEmpty(_dashboard.CharFolder) || _miniRemote != null) return; var dash = _dashboard; - // Settings > Misc "Server Features" status line names the current world. - IltHub.ServerFeatureGate.WorldNameProvider ??= - () => Host.HasGetWorldName && Host.TryGetWorldName(out string w) ? w ?? string.Empty : string.Empty; - _iltHub = new IltHub.IltHubController(Host, dash.CharFolder, + _ilt ??= new MiniRemote.IltClient(Host); + _miniRemote = new MiniRemote.MiniRemoteController(Host, dash.CharFolder, () => _objectCache, () => dash.Settings, () => _questTracker, - () => dash.SaveSettings(), _sessionStats); + () => dash.SaveSettings(), _ilt); _hudIcons ??= new Huds.HudIconCache(Host, () => _raycast?.GeometryLoader?.PortalDat); - _huds = new Huds.HudController(Host, dash.CharFolder, () => _objectCache, dash, () => _iltHub, _hudIcons, + _huds = new Huds.HudController(Host, dash.CharFolder, () => _objectCache, dash, () => _miniRemote, _hudIcons, () => _combatManager?.activeTargetId ?? 0) { SessionStats = _sessionStats, }; if (_translateUi != null) _huds.Translate = _translateUi; - // The ILT sections are Mini Remote tabs: "/ra hub [show|hide|toggle]" drives the remote, - // "/ra hub open
" its tabs, and while it is up the Hub keeps its bank / gear data fresh. + // "/ra hub [show|hide|toggle]" drives the remote, "/ra hub open " its tabs. var huds = _huds; - _iltHub.MiniRemoteCommand = mode => "[Mini Remote] " + huds.HandleCommand("remote", mode); - _iltHub.MiniRemoteTabCommand = (tab, mode) => huds.HandleTabCommand(tab, mode); - _iltHub.MiniRemoteVisible = () => huds.MiniRemoteActive; + _miniRemote.MiniRemoteCommand = mode => "[Mini Remote] " + huds.HandleCommand("remote", mode); + _miniRemote.MiniRemoteTabCommand = (tab, mode) => huds.HandleTabCommand(tab, mode); EnsureItemInfoUi(); EnsureSpellsUi(); } + // ── RynthAi.Hub (HubInterface.cs): what RynthILT borrows ──────────────── + + /// The Mini Remote on a tab for RynthILT (any thread): show / hide / toggle the remote for tab "", else the tab. Null before login. + internal string? MiniRemoteTabForIlt(string tab, string mode) + { + var huds = _huds; + if (huds == null) return null; + if (tab.Length == 0 && mode is "show" or "hide" or "toggle") return huds.HandleCommand("remote", mode); + return huds.HandleTabCommand(tab, mode); + } + + /// The Mini Remote is on screen (any thread). + internal bool MiniRemoteVisibleForIlt => _huds?.MiniRemoteActive == true; + + internal RynthCoreHost HostForIlt => Host; + internal Meta.QuestTracker? QuestTrackerForIlt => _questTracker; + internal MiniRemote.MiniRemoteController? MiniRemoteForIlt => _miniRemote; + internal WorldObjectCache? ObjectCacheForIlt => _objectCache; + internal RynthCore.Plugin.Shared.SessionStatsTracker? SessionStatsForIlt => _sessionStats; + /// Item Info window, created once settings exist. private void EnsureItemInfoUi() { @@ -153,9 +173,11 @@ public sealed partial class RynthAiPlugin try { RynthLog.Pump(); } catch (Exception ex) { Host.Log($"[RynthAi] diagnostics pump: {ex.Message}"); } try { _sessionStats?.Tick(); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats tick"); } - try { _iltHub?.Tick(); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "Tick"); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats tick"); } + try { _ilt?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "RynthILT lookup"); } + try { _miniRemote?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote Tick"); } try { _huds?.Tick(); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "Tick"); } try { _translator?.Tick(); } @@ -177,10 +199,10 @@ public sealed partial class RynthAiPlugin _navBreadcrumbs = null; if (_dashboard != null) _dashboard.NavBreadcrumbs = null; _navOverlay = null; - try { _iltHub?.OnLogout(); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "logout"); } - _iltHub = null; - IltHub.ServerFeatureGate.HubForceProvider = null; + try { _miniRemote?.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote logout"); } + _miniRemote = null; + _ilt?.Reset(); try { _huds?.OnLogout(); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "logout"); } _huds = null; @@ -195,14 +217,11 @@ public sealed partial class RynthAiPlugin _translateUi = null; } - /// ILT Hub may eat a server reply; the translator records the line either way. + /// The Pets tab watches for its heal pet's heal; the translator records the line either way. private void OnChatLocalFeatures(string text, int chatType, ref int eat) { - try - { - if (_iltHub?.OnChat(text) == true) eat = 1; - } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnChat"); } + try { _miniRemote?.OnChat(text); } + catch (Exception ex) { RynthLog.Exception(LogCat.Pets, ex, "Mini Remote OnChat"); } try { _translator?.OnChatWindowText(text, chatType); } catch (Exception ex) { RynthLog.Exception(LogCat.Chat, ex, "translator inbound"); } } @@ -235,7 +254,7 @@ public sealed partial class RynthAiPlugin _navOverlay?.Render(); _itemInfoUi?.Render(); _spellsUi?.Render(); - _iltHub?.Render(); + _miniRemote?.Render(); _huds?.Render(); RenderTranslateWindow(); } @@ -269,7 +288,7 @@ public sealed partial class RynthAiPlugin if (!_overlayEnteredLogged) { _overlayEnteredLogged = true; - RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay drawing (iltHub={(_iltHub != null ? "ready" : "null")})."); + RynthLog.Write(LogCat.UI, $"[Overlay] OnRenderOverlay drawing (miniRemote={(_miniRemote != null ? "ready" : "null")})."); } IntPtr previousContext = ImGui.GetCurrentContext(); @@ -278,7 +297,7 @@ public sealed partial class RynthAiPlugin { DetectItemInfoClick(); int pushedColors = LegacyDashboardRenderer.PushDashboardStyle(); - try { _iltHub?.Render(); } + try { _miniRemote?.Render(); } finally { ImGui.PopStyleColor(pushedColors); } _huds?.Render(); RenderTranslateWindow(); @@ -340,40 +359,6 @@ public sealed partial class RynthAiPlugin } } - /// - /// RynthPluginRenderEmbed "guardian": the Temple guardian tools inside RynthCore's Guardian - /// panel (the bar's ILT button), drawn into the engine's current ImGui window at the size it - /// gives ( echoes that size: the panel is user-sized), docked or popped - /// out (). False (nothing drawn) until login and the ILT features - /// exist. Render thread. - /// - public bool RenderEmbeddedGuardian(System.Numerics.Vector2 size, out System.Numerics.Vector2 want) - { - want = size; - var hub = _iltHub; - if (!_initialized || !_loginComplete || Host.ImGuiContext == IntPtr.Zero || hub == null) - return false; - - IntPtr previousContext = ImGui.GetCurrentContext(); - ImGui.SetCurrentContext(EmbedContext()); - int pushedColors = LegacyDashboardRenderer.PushDashboardStyle(); - try - { - hub.RenderGuardianPanel(); - return true; - } - catch (Exception ex) - { - RynthLog.Exception(LogCat.UI, ex, "RenderEmbeddedGuardian"); - return false; - } - finally - { - ImGui.PopStyleColor(pushedColors); - ImGui.SetCurrentContext(previousContext); - } - } - /// Chat Translate window in the dashboard colours (no-op while hidden). private void RenderTranslateWindow() { @@ -391,17 +376,14 @@ public sealed partial class RynthAiPlugin ChatLine("[RynthAi] " + _huds.HandleCommand(which, mode)); } - /// Skills panel Progression tab snapshot (RynthPluginGetProgressionJson). Pump thread. - internal string BuildProgressionJson() => _iltHub?.BuildProgressionJson() ?? "{\"available\":false}"; - - /// Settings panel Charms Tracking tab snapshot (RynthPluginGetCharmsJson). Pump thread. - internal string BuildCharmsJson() => _iltHub?.BuildCharmsJson() ?? "{\"available\":false}"; - - /// "prog ..." remote command from the Skills panel's Progression tab. Pump thread. + /// + /// "prog ..." from an older engine's Skills panel (newer engines send it to RynthILT, which owns + /// the progression planners since 2026-10-13): passed on to RynthILT. Pump thread. + /// private void HandleProgressionRemote(string value) { - if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); return; } - _iltHub.Progression.HandleRemote(value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + if (!Host.HasSendPluginCommand || !Host.SendPluginCommand("RynthILT", "prog", value)) + ChatLine("[RynthAi] Progression is an Infinite Leaftide feature: it comes with the RynthILT plugin."); } /// "/ra itemhud add <name>" and the inventory panel's "Add to item count HUD". Pump thread. @@ -460,12 +442,16 @@ public sealed partial class RynthAiPlugin bool? state = ParseOnOff(action); bool isAll = target.Equals("all", StringComparison.OrdinalIgnoreCase); - bool isIlt = target.Equals("ilt", StringComparison.OrdinalIgnoreCase); - if (isAll || isIlt) + if (target.Equals("ilt", StringComparison.OrdinalIgnoreCase)) + { + ChatLine("[RynthAi] The ILT features trace in RynthILT now: /ilt trace all on|off."); + return; + } + if (isAll) { if (!state.HasValue) { foreach (string l in RynthLog.StatusLines()) ChatLine(l); return; } - int n = RynthLog.SetTracingByPrefix(isIlt ? "Ilt" : string.Empty, state.Value); - ChatLine($"[RynthAi] Tracing {(state.Value ? "enabled" : "disabled")} for {n} {(isIlt ? "ILT Hub " : "")}categories."); + int n = RynthLog.SetTracingByPrefix(string.Empty, state.Value); + ChatLine($"[RynthAi] Tracing {(state.Value ? "enabled" : "disabled")} for {n} categories."); return; } diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs index 90deb60..18c12ce 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthAiPlugin.cs @@ -177,7 +177,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase StartDataFolderCheck(); // RynthAiPlugin.DataFolders.cs: can metas/navs/settings be saved? InitSessionStats(); // The overlay windows (OnRenderOverlay) must draw through the engine's cimgui module. - ImGuiNativeBinding.Ensure(); + RynthCore.Plugin.Shared.ImGuiNativeBinding.Ensure(msg => RynthLog.Write(LogCat.UI, msg)); _dashboard = new LegacyDashboardRenderer(Host); _killClock.MacroRunning = () => _dashboard?.Settings.IsMacroRunning == true; _dashboard.KillClock = _killClock; @@ -281,7 +281,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { Log("RynthAi: logout — tearing down session."); try { _dashboard?.SaveSettings(); } catch { } - try { _sessionStats?.OnLogout(); } catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats logout"); } + try { _sessionStats?.OnLogout(); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats logout"); } Loot.T11ItemSupport.Reset(); // A real logout: the next OnLoginComplete is a fresh login, not a hot reload. ClearInGameMarker(); @@ -590,7 +590,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase // Cache player ID so we can filter self out of creature tracking and update vitals _playerId = Host.GetPlayerId(); try { _sessionStats?.OnLoginComplete(); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats login"); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats login"); } _objectCache?.SetPlayerId(_playerId); _navigationEngine?.SetPlayerId(_playerId); if (_objectCache != null) _dashboard.SetWorldFilter(_objectCache); @@ -732,15 +732,15 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _combatManager.SummonOut = () => _petManager?.CurrentSummon(); } - CreateIltHub(); - if (_iltHub?.SkipLoginQuestRefresh == true) - Log("RynthAi: ILT Hub says /myquests is off on this server; login quest refresh already ran."); + CreateMiniRemote(); + if (_miniRemote?.SkipLoginQuestRefresh == true) + Log("RynthAi: RynthILT says /myquests is off on this server; login quest refresh already ran."); try { string hubChar = CurrentCharacterName(); - _iltHub?.OnLoginComplete(hubChar, _petManager); + _miniRemote?.OnLoginComplete(hubChar, _petManager); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "login"); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote login"); } _salvageManager = new SalvageManager(Host, _dashboard.Settings, _objectCache); // Hand the salvage manager a live accessor for the loot profile's @@ -927,9 +927,10 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "bounties": case "bountys": // Dashboard Char launcher and its right-click menu (hub=tab
switches the - // Mini Remote's tab); value carries the "/ra hub|quests|pets|bounty" arguments. - if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); break; } - _iltHub.HandleCommand(action.ToLowerInvariant(), value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + // Mini Remote's tab); value carries the "/ra hub|quests|pets|bounty" arguments. The + // Infinite Leaftide verbs go on to RynthILT (MiniRemoteController.HandleCommand). + if (_miniRemote == null) { ChatLine("[RynthAi] The Mini Remote isn't ready (log in first)."); break; } + _miniRemote.HandleCommand(action.ToLowerInvariant(), value.Split(' ', StringSplitOptions.RemoveEmptyEntries)); break; case "huds": case "itemhud": @@ -1498,11 +1499,11 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _buffManager?.SetTimerPath(_dashboard.CharFolder); _damageStore?.SetCharacter(_dashboard.CharFolder); _patrolOnLoginPending = _dashboard.Settings.PatrolOnLogin; - if (_iltHub == null) + if (_miniRemote == null) { - CreateIltHub(); - try { _iltHub?.OnLoginComplete(lateName, _petManager); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "late login"); } + CreateMiniRemote(); + try { _miniRemote?.OnLoginComplete(lateName, _petManager); } + catch (Exception ex) { RynthLog.Exception(LogCat.UI, ex, "Mini Remote late login"); } } Log($"RynthAi: per-character settings established late for '{lateName}' (early OnLoginComplete read had failed)."); } @@ -2243,7 +2244,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase public override void OnChatWindowText(string? text, int chatType, ref int eat) { if (string.IsNullOrEmpty(text)) return; - try { _sessionStats?.OnChatWindowText(text); } catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats chat"); } + try { _sessionStats?.OnChatWindowText(text); } catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats chat"); } // The Meta Manager eats the reply to its own /myquests poll (only that). bool mmEat = false; try { mmEat = MetaScheduleChat(text); } catch { } @@ -2262,7 +2263,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase _scrollLearner?.OnChat(text); _metaManager?.HandleChat(text, chatType); _questTracker?.OnChatLine(text); - // The "/aug" reply carries the T11 wield counters (ILT Hub requests it at login). + // The "/aug" reply carries the T11 wield counters (RynthILT's login probe requests it on ILT). try { Loot.T11ItemSupport.OnChat(text); } catch (Exception ex) { RynthLog.Exception(LogCat.Looting, ex, "T11 /aug parse"); } CheckChatForSafetyStops(text); @@ -2277,7 +2278,7 @@ public sealed partial class RynthAiPlugin : RynthPluginBase { // Mini Remote stats count every notice, as RynthTracker does (an empty message is still a kill). try { _sessionStats?.OnKillNotification(deathMessage); } - catch (Exception ex) { RynthLog.Exception(LogCat.IltRates, ex, "session stats kill"); } + catch (Exception ex) { RynthLog.Exception(LogCat.Huds, ex, "session stats kill"); } if (string.IsNullOrEmpty(deathMessage)) return; _killClock.RecordKill(); // the only kill source: KillerNotification goes to the killer alone _combatManager?.OnKillNotification(deathMessage); @@ -3479,8 +3480,8 @@ public sealed partial class RynthAiPlugin : RynthPluginBase case "bounty": case "bounties": case "bountys": - if (_iltHub == null) { ChatLine("[RynthAi] ILT features not ready (log in first)."); break; } - _iltHub.HandleCommand(cmd, parts.Length > 2 ? parts[2..] : Array.Empty()); + if (_miniRemote == null) { ChatLine("[RynthAi] The Mini Remote isn't ready (log in first)."); break; } + _miniRemote.HandleCommand(cmd, parts.Length > 2 ? parts[2..] : Array.Empty()); break; case "itemhud" when parts.Length > 2 && parts[2].Equals("add", StringComparison.OrdinalIgnoreCase): HandleItemHudAdd(string.Join(" ", parts, 3, parts.Length - 3)); diff --git a/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj b/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj index d89e222..60c2d9c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj +++ b/Plugins/RynthCore.Plugin.RynthAi/RynthCore.Plugin.RynthAi.csproj @@ -26,6 +26,8 @@ + + @@ -56,6 +58,13 @@ + + + + + + + diff --git a/Plugins/RynthCore.Plugin.RynthILT/Bounty/BountyTracker.cs b/Plugins/RynthCore.Plugin.RynthILT/Bounty/BountyTracker.cs index b980a45..8880ef2 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/Bounty/BountyTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Bounty/BountyTracker.cs @@ -692,17 +692,23 @@ internal sealed class BountyTracker _lastSaveMs = NowMs; if (!_dirty || _filePath.Length == 0) { _dirty = false; return; } _dirty = false; - try - { - string? dir = Path.GetDirectoryName(_filePath); - if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir); - string tmp = _filePath + ".tmp"; - File.WriteAllText(tmp, JsonSerializer.Serialize(_s, RynthILTJsonContext.Default.BountyState)); - File.Move(tmp, _filePath, overwrite: true); - } + string json; + try { json = JsonSerializer.Serialize(_s, RynthILTJsonContext.Default.BountyState); } catch (Exception ex) { _log($"[RynthILT] Bounties: saving {_filePath} failed: {ex.Message}"); + return; } + // A failed write is said in chat once per folder (on ILT) and logged; it stays dirty so the + // next debounced save tries again. + if (!RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the bounty list", _filePath, () => + { + string? dir = Path.GetDirectoryName(_filePath); + if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir); + string tmp = _filePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, _filePath, overwrite: true); + })) + _dirty = true; } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs similarity index 99% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs index a5d3488..23ac250 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAttributeRaiser.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAttributeRaiser.cs @@ -1,4 +1,5 @@ // IltAttributeRaiser.cs — Infinite attributes: spend unassigned XP with the server's /attr. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // ACECustom (Infinite Leaftide) lets attributes and vitals go past the retail cap, so the // client's XP tables stop applying. The server is the only source of truth: @@ -25,7 +26,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltAttributeRaiser { @@ -571,7 +572,7 @@ internal sealed class IltAttributeRaiser private static void Str(StringBuilder sb, string name, string value, bool first = false) { if (!first) sb.Append(','); - sb.Append('"').Append(name).Append("\":\"").Append(RynthAiPlugin.JsonEscape(value ?? string.Empty)).Append('"'); + sb.Append('"').Append(name).Append("\":\"").Append(IltStyle.JsonEscape(value ?? string.Empty)).Append('"'); } /// "prog attr…" commands from the Skills panel. Returns false when the verb isn't ours. diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAugCosts.cs similarity index 92% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltAugCosts.cs index ca5d654..ae28ac6 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltAugCosts.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltAugCosts.cs @@ -1,4 +1,5 @@ // IltAugCosts.cs — luminance augmentation cost rules, per server (world name). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Defaults are UB's Leaftide Augs tab (correct for InfiniteLeaftide): // level i (1-based) costs (Base + (i-1) * Base * LinearPercent/100) * multiplier(i) @@ -13,7 +14,7 @@ using System.IO; using System.Linq; using System.Text.Json; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// The saved file: one cost profile per world that was changed from the defaults. public sealed class IltAugCostFile @@ -102,7 +103,7 @@ internal sealed class IltAugCosts if (File.Exists(FilePath)) { string json = File.ReadAllText(FilePath); - _file = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltAugCostFile) ?? new IltAugCostFile(); + _file = JsonSerializer.Deserialize(json, IltHubJsonContext.Default.IltAugCostFile) ?? new IltAugCostFile(); _lastJson = json; } } @@ -181,13 +182,16 @@ internal sealed class IltAugCosts { try { - string json = JsonSerializer.Serialize(File_, RynthAiJsonContext.Default.IltAugCostFile); + string json = JsonSerializer.Serialize(File_, IltHubJsonContext.Default.IltAugCostFile); if (json == _lastJson) return; - Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!); - string tmp = FilePath + ".tmp"; - File.WriteAllText(tmp, json); - File.Move(tmp, FilePath, overwrite: true); - _lastJson = json; + if (RynthCore.Plugin.Shared.DataWriteGuard.TrySave("the aug cost table", FilePath, () => + { + Directory.CreateDirectory(Path.GetDirectoryName(FilePath)!); + string tmp = FilePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, FilePath, overwrite: true); + })) + _lastJson = json; } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {FilePath}"); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBankCommands.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltBankCommands.cs index f63c53a..bb4752e 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBankCommands.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBankCommands.cs @@ -1,4 +1,5 @@ // IltBankCommands.cs — The /bank commands the Banking tab sends, and the reply lines it collects. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Server contract (ACECustom PlayerCommands.HandleBank / Player_Bank, upstream 2026-10-11): // /b d [code] deposit everything (no code) or one kind; "Deposited N ", @@ -12,7 +13,7 @@ // /bank balance doesn't touch it. Pure: no host calls, so the host tests cover it. using System; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal static class IltBankCommands { diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs similarity index 96% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs index afa4e55..77be5e2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBanking.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBanking.cs @@ -1,4 +1,5 @@ // IltBanking.cs — ILT Hub "Banking" tab: /bank balances, deposits, withdrawals, confirmed +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // transfers, transaction log. // // Server contract (ACECustom PlayerCommands bank handler, upstream 2026-10-11): @@ -19,9 +20,8 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltBanking : IIltFeature { @@ -369,13 +369,13 @@ internal sealed class IltBanking : IIltFeature { if (!Enabled) { - ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, + ImGui.TextColored(IltStyle.ColTextMute, _ctx.Options.IsOff(IltFeature.Bank) ? "The server reports /bank is not available." : "Waiting for the server options check..."); return; } // Balances - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Balances"); + ImGui.TextColored(IltStyle.ColTeal, "Balances"); ImGui.SameLine(); if (ImGui.SmallButton("Refresh##bank")) _ctx.Post(() => RequestRefresh(quiet: true)); ImGui.SameLine(); @@ -421,7 +421,7 @@ internal sealed class IltBanking : IIltFeature /// Deposit (one kind or everything, luminance tokens included) and withdraw (an amount, or trade notes). private void RenderDepositWithdraw() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Deposit"); + ImGui.TextColored(IltStyle.ColTeal, "Deposit"); int dep = Math.Clamp(Bank.DepositIndex, 0, DepositNames.Length - 1); ImGui.SetNextItemWidth(200); if (ImGui.Combo("##bankdep", ref dep, DepositNames, DepositNames.Length)) Bank.DepositIndex = dep; @@ -435,7 +435,7 @@ internal sealed class IltBanking : IIltFeature ImGui.SetTooltip(IltBankCommands.Deposit(dep) + "\nEverything banks all currencies, notes and luminance tokens." + "\nThe server refuses while you are busy or moving."); - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Withdraw"); + ImGui.TextColored(IltStyle.ColTeal, "Withdraw"); int wd = Math.Clamp(Bank.WithdrawIndex, 0, WithdrawNames.Length - 1); ImGui.SetNextItemWidth(200); if (ImGui.Combo("##bankwd", ref wd, WithdrawNames, WithdrawNames.Length)) Bank.WithdrawIndex = wd; @@ -462,7 +462,7 @@ internal sealed class IltBanking : IIltFeature if (_withdrawText.Length > 0) { ImGui.SameLine(); - if (!ok) ImGui.TextColored(LegacyDashboardRenderer.ColHp, "invalid amount"); + if (!ok) ImGui.TextColored(IltStyle.ColHp, "invalid amount"); else if (notes) ImGui.TextDisabled("= " + IltParse.N0(amount * IltBankCommands.NoteDenominations[denom].Value) + " pyreals"); else ImGui.TextDisabled("= " + IltParse.N0(amount)); } @@ -473,7 +473,7 @@ internal sealed class IltBanking : IIltFeature private void RenderTransferForm() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Transfer"); + ImGui.TextColored(IltStyle.ColTeal, "Transfer"); int idx = Math.Clamp(Bank.TransferCurrencyIndex, 0, Currencies.Length - 1); ImGui.SetNextItemWidth(200); if (ImGui.Combo("Currency##xfer", ref idx, CurrencyNames, CurrencyNames.Length)) @@ -491,7 +491,7 @@ internal sealed class IltBanking : IIltFeature { ImGui.SameLine(); if (amountOk) ImGui.TextDisabled("= " + IltParse.N0(amount)); - else ImGui.TextColored(LegacyDashboardRenderer.ColHp, "invalid amount"); + else ImGui.TextColored(IltStyle.ColHp, "invalid amount"); } ImGui.BeginDisabled(!amountOk || string.IsNullOrWhiteSpace(Bank.TransferTarget)); @@ -516,7 +516,7 @@ internal sealed class IltBanking : IIltFeature private void RenderTransactionLog() { var snap = _txSnapshot; - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, $"Transactions ({snap.Length})"); + ImGui.TextColored(IltStyle.ColTeal, $"Transactions ({snap.Length})"); ImGui.SameLine(); ImGui.SetNextItemWidth(180); ImGui.InputTextWithHint("##txfilter", "filter player / currency", ref _txFilter, 64u); @@ -543,7 +543,7 @@ internal sealed class IltBanking : IIltFeature ImGui.TableNextRow(); ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Timestamp.ToString("g")); ImGui.TableNextColumn(); - ImGui.TextColored(t.Type == "Sent" ? LegacyDashboardRenderer.ColAmber : LegacyDashboardRenderer.ColGreen, t.Type); + ImGui.TextColored(t.Type == "Sent" ? IltStyle.ColAmber : IltStyle.ColGreen, t.Type); ImGui.TableNextColumn(); ImGui.TextUnformatted(IltParse.N0(t.Amount)); ImGui.TableNextColumn(); ImGui.TextUnformatted(t.Currency); ImGui.TableNextColumn(); ImGui.TextUnformatted(t.OtherPlayer); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBuffKeepers.cs similarity index 94% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltBuffKeepers.cs index f897eae..2dd64a8 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltBuffKeepers.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltBuffKeepers.cs @@ -1,7 +1,8 @@ // IltBuffKeepers.cs — Rune-of-Dispel auto-dispel and Surging Strength keeper (Gear tab). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Both read the player's enchantment list once a second (one shared read). -// Dispel: classifies active spells by NAME (SpellDatabase has no debuff flag): +// Dispel: classifies active spells by NAME (RynthAi's SpellDatabase, through RynthAi.Hub; it has no debuff flag): // 1. Mire Foot (3051 / "mire"+"foot") → never (dispelling it is pointless) // 2. user include list → dispel // 3. beneficial pattern → keep @@ -14,9 +15,8 @@ using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltBuffKeepers : IIltFeature { @@ -125,7 +125,8 @@ internal sealed class IltBuffKeepers : IIltFeature for (int i = 0; i < n; i++) { int id = unchecked((int)_ids[i]); - string name = SpellDatabase.GetSpellName(id); + // Spell names are RynthAi's spell table (RynthAi.Hub SpellName); without RynthAi nothing is classified. + string name = _ctx.Ai.SpellName(id); if (string.IsNullOrEmpty(name)) continue; if (name.Contains("Surging Strength", StringComparison.OrdinalIgnoreCase)) surge = true; if (G.AutoDispel && IsHarmful(id, name)) harmful.Add(name); @@ -207,7 +208,7 @@ internal sealed class IltBuffKeepers : IIltFeature public void Render() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Auto-dispel (Rune of Dispel)"); + ImGui.TextColored(IltStyle.ColTeal, "Auto-dispel (Rune of Dispel)"); bool ad = G.AutoDispel; if (ImGui.Checkbox("Use a Rune of Dispel on harmful debuffs", ref ad)) G.AutoDispel = ad; int cd = G.DispelCooldownSeconds; @@ -215,7 +216,7 @@ internal sealed class IltBuffKeepers : IIltFeature if (ImGui.InputInt("Cooldown (s)##disp", ref cd)) G.DispelCooldownSeconds = Math.Max(2, cd); ImGui.TextDisabled("Status: " + _dispelStatus); var harm = _harmfulNow; - if (harm.Length > 0) ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Harmful now: " + string.Join(", ", harm)); + if (harm.Length > 0) ImGui.TextColored(IltStyle.ColAmber, "Harmful now: " + string.Join(", ", harm)); if (ImGui.TreeNode("Always / never dispel lists")) { EditList("Always dispel (name contains)", G.DispelInclusions, ref _newInclude, "inc"); @@ -224,7 +225,7 @@ internal sealed class IltBuffKeepers : IIltFeature } ImGui.Separator(); - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Surging Strength"); + ImGui.TextColored(IltStyle.ColTeal, "Surging Strength"); bool ss = G.SurgingStrength; if (ImGui.Checkbox("Keep Surging Strength up (Empowered Volcanic Ember)", ref ss)) G.SurgingStrength = ss; ImGui.TextDisabled("Status: " + (_surgeActive ? "active" : _surgeStatus)); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharmTracker.cs similarity index 93% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharmTracker.cs index 5f92861..dd1f13e 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharmTracker.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharmTracker.cs @@ -1,4 +1,5 @@ // IltCharmTracker.cs — Every ACECustom registry charm's state: the Mini Remote's Charms tab +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // (IltCharms) and RynthPluginGetCharmsJson (an older engine's Settings "Charms Tracking" tab). // // Per charm it reports: @@ -15,7 +16,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltCharmTracker { @@ -109,7 +110,7 @@ internal sealed class IltCharmTracker var sb = new StringBuilder(4096); bool available = _ctx.Options.IsIltLikeWorld; sb.Append("{\"available\":").Append(available ? "true" : "false"); - sb.Append(",\"world\":\"").Append(RynthAiPlugin.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append('"'); + sb.Append(",\"world\":\"").Append(IltStyle.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append('"'); if (!available) return sb.Append(",\"charms\":[]}").ToString(); var rows = Evaluate(); @@ -121,8 +122,8 @@ internal sealed class IltCharmTracker { var r = rows[i]; if (i > 0) sb.Append(','); - sb.Append("{\"name\":\"").Append(RynthAiPlugin.JsonEscape(r.Def.Name)).Append('"'); - sb.Append(",\"effect\":\"").Append(RynthAiPlugin.JsonEscape(r.Def.Effect)).Append('"'); + sb.Append("{\"name\":\"").Append(IltStyle.JsonEscape(r.Def.Name)).Append('"'); + sb.Append(",\"effect\":\"").Append(IltStyle.JsonEscape(r.Def.Effect)).Append('"'); sb.Append(",\"acquired\":\"").Append(r.Acquired).Append('"'); sb.Append(",\"count\":").Append(r.Count); sb.Append(",\"tier\":").Append(r.Tier); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharms.cs similarity index 88% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharms.cs index e74a59a..c1ff337 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltCharms.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltCharms.cs @@ -1,4 +1,5 @@ // IltCharms.cs — The Mini Remote's "Charms" ILT tab: every ACECustom registry charm in one table. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Per charm (IltCharmTracker): acquired ("carried" now, "stored" = carried before and remembered // per character, or no), status ON / OFF from the charm's appraisal or the player's ability flag, @@ -13,9 +14,8 @@ using System.Collections.Generic; using System.Linq; using System.Numerics; using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltCharms : IIltFeature { @@ -99,7 +99,7 @@ internal sealed class IltCharms : IIltFeature } int acquired = rows.Count(r => r.Acquired != "no"), active = rows.Count(r => r.Active == IltTri.On); - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, $"{acquired} of {rows.Length} acquired, {active} active"); + ImGui.TextColored(IltStyle.ColTeal, $"{acquired} of {rows.Length} acquired, {active} active"); ImGui.SameLine(); if (ImGui.SmallButton("Refresh##charms")) _ctx.Post(() => { _lastScan = 0; }); @@ -133,14 +133,14 @@ internal sealed class IltCharms : IIltFeature ImGui.TableNextColumn(); bool carried = r.Acquired == "carried"; if (carried) ImGui.TextUnformatted(r.Def.Name); - else ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, r.Def.Name); + else ImGui.TextColored(IltStyle.ColTextMute, r.Def.Name); if (ImGui.IsItemHovered() && r.Def.Effect.Length > 0) ImGui.SetTooltip(r.Def.Effect); ImGui.TableNextColumn(); - if (carried) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, r.Count > 1 ? $"Carried x{r.Count}" : "Carried"); + if (carried) ImGui.TextColored(IltStyle.ColGreen, r.Count > 1 ? $"Carried x{r.Count}" : "Carried"); else if (r.Acquired == "seen") { - ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "Stored"); + ImGui.TextColored(IltStyle.ColAmber, "Stored"); if (ImGui.IsItemHovered() && r.LastSeenUtc != default) ImGui.SetTooltip("Last carried " + r.LastSeenUtc.ToString("yyyy-MM-dd")); } @@ -148,11 +148,11 @@ internal sealed class IltCharms : IIltFeature ImGui.TableNextColumn(); if (!carried) ImGui.TextDisabled("-"); - else if (r.Active == IltTri.On) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "ON"); - else if (r.Active == IltTri.Off) ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "OFF"); + else if (r.Active == IltTri.On) ImGui.TextColored(IltStyle.ColGreen, "ON"); + else if (r.Active == IltTri.Off) ImGui.TextColored(IltStyle.ColTextMute, "OFF"); else { - ImGui.TextColored(LegacyDashboardRenderer.ColAmber, "?"); + ImGui.TextColored(IltStyle.ColAmber, "?"); if (ImGui.IsItemHovered()) ImGui.SetTooltip("Waiting for the charm's appraisal."); } @@ -162,10 +162,10 @@ internal sealed class IltCharms : IIltFeature ImGui.TableNextColumn(); if (r.Server == IltTri.Off) { - ImGui.TextColored(LegacyDashboardRenderer.ColHp, "Disabled"); + ImGui.TextColored(IltStyle.ColHp, "Disabled"); if (ImGui.IsItemHovered()) ImGui.SetTooltip("The server refused or reported this charm as disabled."); } - else if (r.Server == IltTri.On) ImGui.TextColored(LegacyDashboardRenderer.ColGreen, "Enabled"); + else if (r.Server == IltTri.On) ImGui.TextColored(IltStyle.ColGreen, "Enabled"); else { ImGui.TextDisabled("-"); @@ -191,8 +191,8 @@ internal sealed class IltCharms : IIltFeature if (h.ServerDisabled) ImGui.TextDisabled($"{h.Name} - disabled on this server"); else { - var col = h.Status == IltTri.On ? LegacyDashboardRenderer.ColGreen - : h.Status == IltTri.Off ? LegacyDashboardRenderer.ColTextMute : LegacyDashboardRenderer.ColAmber; + var col = h.Status == IltTri.On ? IltStyle.ColGreen + : h.Status == IltTri.Off ? IltStyle.ColTextMute : IltStyle.ColAmber; ImGui.TextColored(col, h.Status == IltTri.On ? "ON " : h.Status == IltTri.Off ? "OFF" : " ? "); ImGui.SameLine(); ImGui.TextUnformatted(h.Name); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChatCapture.cs similarity index 98% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltChatCapture.cs index 31da8ca..94faab3 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChatCapture.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChatCapture.cs @@ -1,4 +1,5 @@ // IltChatCapture.cs — Shared "send a server command and collect its reply" helper. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Every ILT Hub feature that talks to ACECustom (/bank, /aug, /qb, /pets, /xp, /pb, // /ilt features, the login probe, ...) goes through this one queue so that: @@ -11,7 +12,7 @@ using System; using System.Collections.Generic; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// Describes one command whose reply should be captured. internal sealed class IltChatRequest diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs index 79edab0..09e8e9f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltChunkClap.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltChunkClap.cs @@ -1,4 +1,5 @@ // IltChunkClap.cs — Lugian-hammer chunking and /clap automation (Gear tab). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Chunk: uses a Lugian (Aetheria) Hammer on eligible items, one at a time: // Aetheria — "Aetheria"/"Coalesced Aetheria" gems, not equipped, appraised, not flagged @@ -14,9 +15,8 @@ using System.Collections.Generic; using System.Linq; using ImGuiNET; using RynthCore.Loot; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltChunkClap : IIltFeature { @@ -249,7 +249,7 @@ internal sealed class IltChunkClap : IIltFeature public void Render() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Chunking (Lugian Hammer)"); + ImGui.TextColored(IltStyle.ColTeal, "Chunking (Lugian Hammer)"); bool a = G.AutoChunkAetheria, c = G.AutoChunkCorrupted, comb = G.ChunkInCombat; if (ImGui.Checkbox("Auto-chunk low aetheria", ref a)) G.AutoChunkAetheria = a; ImGui.SameLine(); @@ -264,10 +264,10 @@ internal sealed class IltChunkClap : IIltFeature ImGui.TextDisabled("Status: " + _chunkStatus); ImGui.Separator(); - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Clap (/clap all)"); + ImGui.TextColored(IltStyle.ColTeal, "Clap (/clap all)"); if (_ctx.Options.IsOff(IltFeature.Clap)) { - ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "Not available (server off or AutoCraftingEnabled stamp missing)."); + ImGui.TextColored(IltStyle.ColTextMute, "Not available (server off or AutoCraftingEnabled stamp missing)."); return; } bool ac = G.AutoClap; diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltEquipSuits.cs similarity index 87% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltEquipSuits.cs index d028917..ca207b2 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltEquipSuits.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltEquipSuits.cs @@ -3,23 +3,23 @@ // A suit is a VTank loot profile: every carried wearable whose first matching rule is // Keep belongs to the suit. Loading a suit: // 1. dequip phase — equipped wearables NOT in the suit go to a pack with a free slot -// (WorldObjectCache.FindPackFor; never into a full pack — that crashes the client); +// (IltObjects.FindPackFor; never into a full pack — that crashes the client); // 2. equip phase — suit items that aren't worn are used (AC equips on use). // One action per 100 ms tick and only while not busy. An item is abandoned after 15 // attempts; the whole load bails after 10 s with no progress. -// Search order: RynthAi EquipProfiles\, EquipProfiles, then UB's equip folders. +// The profile is matched by RynthAi's VTank loot evaluator (RynthAi.Hub LootKeeps), so suits need +// RynthAi. Search order: RynthILT EquipProfiles\, EquipProfiles, the same two in the RynthAi +// folder (where they lived before the move), then UB's equip folders. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. using System; using System.Collections.Generic; using System.IO; using System.Linq; using ImGuiNET; using RynthCore.Loot; -using RynthCore.Loot.VTank; -using RynthCore.Plugin.RynthAi.LegacyUi; -using RynthCore.Plugin.RynthAi.Loot; using RynthCore.Install; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltEquipSuits : IIltFeature { @@ -55,9 +55,12 @@ internal sealed class IltEquipSuits : IIltFeature private IEnumerable SearchDirs() { - string root = Path.Combine(IltHubStore.SharedRoot, "EquipProfiles"); - if (_ctx.CharName.Length > 0) yield return Path.Combine(root, _ctx.CharName); - yield return root; + foreach (string baseDir in new[] { IltHubStore.SharedRoot, RynthInstallPaths.RynthAiDir }) + { + string root = Path.Combine(baseDir, "EquipProfiles"); + if (_ctx.CharName.Length > 0) yield return Path.Combine(root, _ctx.CharName); + yield return root; + } string ub = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Decal Plugins", "UtilityBelt"); string world = _ctx.Options.WorldName; if (world.Length > 0 && _ctx.CharName.Length > 0) yield return Path.Combine(ub, world, _ctx.CharName, "equip"); @@ -93,25 +96,22 @@ internal sealed class IltEquipSuits : IIltFeature return ListProfiles().FirstOrDefault(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase)).Path; } - /// Items the suit wants worn (first matching rule is Keep). + /// Items the suit wants worn (first matching rule is Keep; RynthAi evaluates the profile). private List? SuitItems(string path, out string error) { error = string.Empty; - VTankLootProfile profile; - try { profile = VTankLootParser.Load(path); } - catch (Exception ex) { error = "could not read profile: " + ex.Message; return null; } - - var lootCtx = new VTankLootContext(_ctx.Host, _ctx.Inventory.PlayerId) { Cache = _ctx.Inventory.Cache }; - var list = new List(); + var candidates = new List(); foreach (var wo in _ctx.Inventory.Items()) { if (Array.IndexOf(WearableClasses, wo.ObjectClass) < 0) continue; if (_ctx.Inventory.Int(wo, IltInventory.IntValidLocations) == 0) continue; - VTankLootRule? match = null; - foreach (var rule in profile.Rules) - if (VTankLootEvaluator.Match(rule, wo, lootCtx)) { match = rule; break; } - if (match != null && match.Action == VTankLootAction.Keep) list.Add(wo); + candidates.Add(wo); } + uint[] ids = candidates.Select(w => unchecked((uint)w.Id)).ToArray(); + if (!_ctx.Ai.LootKeeps(path, ids, out bool[] keep, out error)) return null; + var list = new List(); + for (int i = 0; i < candidates.Count; i++) + if (keep[i]) list.Add(candidates[i]); return list; } @@ -192,7 +192,7 @@ internal sealed class IltEquipSuits : IIltFeature var wo = cache[id]; if (wo == null || !_ctx.Inventory.IsEquipped(wo)) { _dequip.Dequeue(); Progress(nowMs); return; } if (!Attempt(id)) { _dequip.Dequeue(); return; } - int pack = WorldObjectCache.FindPackFor(_ctx.Host, cache, includeMainPack: true, requireFree: 1); + int pack = IltObjects.FindPackFor(_ctx.Host, cache, includeMainPack: true, requireFree: 1); if (pack == 0) { Cancel("no free pack slot for dequipped items - stopped"); return; } _ctx.Host.MoveItemInternal(unchecked((uint)id), unchecked((uint)pack), 0, Math.Max(1, _ctx.Inventory.StackSize(wo))); return; @@ -233,12 +233,12 @@ internal sealed class IltEquipSuits : IIltFeature public void Render() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Equipment suits (.utl)"); + ImGui.TextColored(IltStyle.ColTeal, "Equipment suits (.utl)"); if (ImGui.SmallButton("Rescan profiles")) _ctx.Post(RefreshProfileList); var profiles = _profiles; if (profiles.Length == 0) { - ImGui.TextDisabled($"No .utl files found ({System.IO.Path.Combine(RynthInstallPaths.RynthAiDir, "EquipProfiles")} or UtilityBelt equip folders)."); + ImGui.TextDisabled($"No .utl files found ({System.IO.Path.Combine(IltHubStore.SharedRoot, "EquipProfiles")}, the RynthAi folder's EquipProfiles or UtilityBelt equip folders)."); } else { diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGames.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltGames.cs index 3de6d8d..44e5f5b 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGames.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGames.cs @@ -1,4 +1,5 @@ // IltGames.cs — ILT Hub "Games" tab + hand HUD (P2): Blackjack, Fellowship Blackjack, Powerball. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Every bet / ticket purchase spends banked luminance, so each one needs a confirm. // Blackjack is commented out on the current ACECustom build ("Unknown command: @@ -11,9 +12,8 @@ using System.Collections.Generic; using System.Numerics; using System.Text.RegularExpressions; using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltGames : IIltFeature { @@ -159,7 +159,7 @@ internal sealed class IltGames : IIltFeature bool bj = _ctx.Options.IsOn(IltFeature.Blackjack), fbj = _ctx.Options.IsOn(IltFeature.FBlackjack); if (!bj && !fbj && _ctx.Options.IsOff(IltFeature.Powerball)) { - ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "No games are enabled on this server."); + ImGui.TextColored(IltStyle.ColTextMute, "No games are enabled on this server."); return; } bool hud = _ctx.State.GamesHudVisible; @@ -245,7 +245,7 @@ internal sealed class IltGames : IIltFeature bool open = true; if (ImGui.Begin("Blackjack HUD##iltbjhud", ref open, ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoCollapse)) { - ImGui.TextColored(LegacyDashboardRenderer.ColAmber, _fellowshipHand ? "Fellowship Blackjack" : "Blackjack"); + ImGui.TextColored(IltStyle.ColAmber, _fellowshipHand ? "Fellowship Blackjack" : "Blackjack"); RenderHandButtons("hud"); } ImGui.End(); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGear.cs similarity index 73% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltGear.cs index 9d2c15f..c995a13 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGear.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGear.cs @@ -1,11 +1,13 @@ // IltGear.cs — ILT Hub "Gear" tab: the gear tools. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // -// The sections are separate modules (buff keepers, chunk/clap, split arrows, equipment suits, -// VTank import) that this tab just lays out. The charm strip (registry charms and the Guardian +// The sections are separate modules (buff keepers, chunk/clap, split arrows, equipment suits) +// that this tab just lays out, plus RynthAi's VTank .usd importer (it edits RynthAi's own rules, +// so it stayed in RynthAi and is drawn here through RynthAi.Hub RenderSection). The charm strip (registry charms and the Guardian // Hand, with their toggles) is the Charms tab now (IltCharms). using ImGuiNET; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltGear : IIltFeature { @@ -13,7 +15,8 @@ internal sealed class IltGear : IIltFeature public IltChunkClap ChunkClap { get; } public IltSplitArrows Split { get; } public IltEquipSuits Suits { get; } - public IltUsdImporter Usd { get; } + + private readonly IltHubContext _ctx; public IltGear(IltHubContext ctx) { @@ -21,7 +24,7 @@ internal sealed class IltGear : IIltFeature ChunkClap = new IltChunkClap(ctx); Split = new IltSplitArrows(ctx); Suits = new IltEquipSuits(ctx); - Usd = new IltUsdImporter(ctx); + _ctx = ctx; } // ── IIltFeature ───────────────────────────────────────────────────────── @@ -59,7 +62,8 @@ internal sealed class IltGear : IIltFeature if (ImGui.CollapsingHeader("Chunking / Clap")) ChunkClap.Render(); if (ImGui.CollapsingHeader("Split arrows")) Split.Render(); if (ImGui.CollapsingHeader("Equipment suits")) Suits.Render(); - if (ImGui.CollapsingHeader("VirindiTank import")) Usd.Render(); + if (ImGui.CollapsingHeader("VirindiTank import") && !_ctx.Ai.RenderSection(RynthCore.Plugin.Shared.RynthAiHub.SectionVTankImport)) + ImGui.TextDisabled("The VirindiTank .usd import fills RynthAi's rules: it comes with RynthAi, which isn't loaded."); ImGui.TextDisabled("Charms and the Guardian Hand are on the Charms tab."); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardian.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardian.cs index f7d9e1c..15b656d 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardian.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardian.cs @@ -1,4 +1,5 @@ // IltGuardian.cs - Temple of Enlightenment guardians (ILT Hub "Guardian" window). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // * Riddle translator: incoming "Guardian of ... tells you / says" lines (when chat auto-detect // is on) and pasted text go through IltGuardianPhrasebook; the answer shows here and on the @@ -16,12 +17,10 @@ using System.Linq; using System.Numerics; using ImGuiNET; using RynthCore.Loot; -using RynthCore.Plugin.RynthAi.LegacyUi; -using RynthCore.Plugin.RynthAi.Meta; using RynthCore.Plugin.Shared; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltGuardian : IIltFeature { @@ -71,10 +70,10 @@ internal sealed class IltGuardian : IIltFeature // Render-thread UI state. private string _input = string.Empty; - public IltGuardian(IltHubContext ctx, Func tracker, IltQuests quests) + public IltGuardian(IltHubContext ctx, IltQuestBonus quests) { _ctx = ctx; - Attributes = new IltTempleAttributes(ctx, tracker, quests); + Attributes = new IltTempleAttributes(ctx, quests); } public IltTempleAttributes Attributes { get; } @@ -473,7 +472,7 @@ internal sealed class IltGuardian : IIltFeature string answer = _lastAnswer, npc = _lastNpc; if (answer.Length > 0) { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, answer); + ImGui.TextColored(IltStyle.ColTeal, answer); ImGui.SameLine(); ImGui.TextDisabled("-> " + npc); if (HandInRunning) @@ -529,9 +528,9 @@ internal sealed class IltGuardian : IIltFeature ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Npc); ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Count.ToString()); ImGui.TableNextColumn(); - var col = r.Ready ? LegacyDashboardRenderer.ColGreen - : r.Status == "Unknown" ? LegacyDashboardRenderer.ColTextMute - : LegacyDashboardRenderer.ColAmber; + var col = r.Ready ? IltStyle.ColGreen + : r.Status == "Unknown" ? IltStyle.ColTextMute + : IltStyle.ColAmber; ImGui.TextColored(col, r.Status); if (ImGui.IsItemHovered()) ImGui.SetTooltip(r.FromMyQuests ? "From /myquests (exact)." : "From /qb wait stamps (count and timer are estimates)."); @@ -554,9 +553,9 @@ internal sealed class IltGuardian : IIltFeature { string answer = _lastAnswer, npc = _lastNpc; if (answer.Length == 0 || LastAnswerAge > AnswerShownFor) return; - ImGui.TextColored(LegacyDashboardRenderer.ColTextMute, "Guardian:"); + ImGui.TextColored(IltStyle.ColTextMute, "Guardian:"); ImGui.SameLine(); - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, answer); + ImGui.TextColored(IltStyle.ColTeal, answer); if (ImGui.IsItemHovered()) ImGui.SetTooltip($"Give to {npc}\nHand-in: {_handInStatus}"); ImGui.SameLine(); if (HandInRunning) diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardianPhrasebook.cs similarity index 98% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardianPhrasebook.cs index 62491e8..67773c7 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltGuardianPhrasebook.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltGuardianPhrasebook.cs @@ -1,4 +1,5 @@ // IltGuardianPhrasebook.cs - Temple of Enlightenment spell words and Guardian of Attribute +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // Enlightenment riddles mapped to the item each guardian wants (Infinite Leaftide). // // Pure functions only (no host calls), so the Guardian window may translate on the render thread. @@ -9,7 +10,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal static class IltGuardianPhrasebook { diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs similarity index 81% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs index a0f18ba..ced863c 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubContext.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubContext.cs @@ -1,17 +1,17 @@ // IltHubContext.cs — Shared services handed to every ILT Hub feature. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. What the +// features borrowed from RynthAi's internals now comes through Ai (RynthAi.Hub, RynthAiClient). // // Threading contract: // * Feature Tick / OnChat run on the plugin pump thread and may call the host freely. // * Feature Render runs on the ImGui render thread and must NOT call AC actions directly. // It calls Post(...) to run work on the next pump tick, or Confirm(...) to ask the -// player first (the confirmed action is then posted). This mirrors the existing -// DrainMetaCommands pattern in RynthAiPlugin. +// player first (the confirmed action is then posted). using System; using System.Collections.Concurrent; -using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// A yes/no question waiting for the player (a modal over the Mini Remote). internal sealed class IltConfirmRequest @@ -27,10 +27,9 @@ internal sealed class IltHubContext { private readonly ConcurrentQueue _posted = new(); private readonly ConcurrentQueue _confirms = new(); - private readonly Func _settings; public IltHubContext(RynthCoreHost host, IltHubState state, IltHubStore store, IltChatCapture capture, - IltServerOptions options, IltInventory inventory, Func settings) + IltServerOptions options, IltInventory inventory, IltSettings settings, RynthAiClient ai) { Host = host; State = state; @@ -38,7 +37,8 @@ internal sealed class IltHubContext Capture = capture; Options = options; Inventory = inventory; - _settings = settings; + Settings = settings; + Ai = ai; } public RynthCoreHost Host { get; } @@ -48,11 +48,14 @@ internal sealed class IltHubContext public IltServerOptions Options { get; } public IltInventory Inventory { get; } - /// The live combat settings (rule lists the Pet picker / USD importer edit). Null before login. - public LegacyUiSettings? Settings => _settings(); + /// RynthILT's settings (the server list). Edits are saved through . + public IltSettings Settings { get; } - /// Set by the controller when combat settings were edited and must be saved. - public Action? SaveCombatSettings; + /// Saves (pump thread). + public void SaveSettings() => IltSettingsStore.Save(Settings); + + /// RynthAi's services (the Mini Remote, /myquests, spell names, loot matching); each says when RynthAi is missing. + public RynthAiClient Ai { get; } /// Logged-in character name (resolved at login). public string CharName = string.Empty; diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs similarity index 70% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs index e81fbd0..92eb4d0 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubController.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubController.cs @@ -1,26 +1,27 @@ -// IltHubController.cs — Owns the ILT features behind the Mini Remote: state, services, feature -// modules, commands. +// IltHubController.cs — Owns the ILT features behind the Mini Remote's ILT tabs: state, services, +// feature modules, commands. +// Originally SilentKelpie's ILT Hub controller (RynthAi IltHub/); moved to RynthILT 2026-10-13. // -// RynthAiPlugin creates one controller per login session and forwards: -// OnTick → Tick() (pump thread) +// RynthILTPlugin creates one controller per login session and forwards: +// OnTick → Tick() (pump thread) // OnChatWindowText → OnChat() (pump thread; returns true to eat the line) -// OnRender → Render() (render thread: Games HUD, quest favorites HUD, confirmations) -// /ra hub ..., /ra quests ..., /ra guardian ... → HandleCommand() +// OnRender → Render() (render thread: Games HUD, confirmations) +// the ILT "/ra hub ...", "/ra guardian ...", "/ra bounty ..." verbs (RynthAi forwards them +// through RynthILT.Hub Command) and "/ilt ..." → HandleCommand() // OnLogout / teardown → OnLogout() -// The ILT sections are Mini Remote tabs (RenderTab); the Guardian is RynthCore's ILT panel -// (RenderGuardianPanel), and bounties are the RynthILT plugin's (RynthCore's ILT button), so -// "/ra bounty" and "/ra guardian window" open those engine panels. -// The Quests and Pets tabs (and their features) are universal: every world. The ILT tabs only -// appear on ACECustom/ILT worlds where at least one server feature is on; on every other world -// the ILT features stay dormant (no probes, no chat, no tabs). +// The ILT sections are tabs of RynthAi's Mini Remote (RenderTab, through RynthILT.Hub); the +// Guardian is RynthCore's ILT panel (RenderGuardianPanel, RynthPluginRenderEmbed "guardian"), +// and bounties are RynthILT's Bounties window (RynthCore's ILT button), so "/ra bounty" and +// "/ra guardian window" open those engine panels. The Mini Remote's Quests and Pets tabs are +// RynthAi's (every world); RynthILT adds their ILT sections (the /qb list, the /pets and +// /shinies logs). On any world that isn't ILT-like every feature here stays dormant (no probes, +// no chat, no tabs). using System; using System.Collections.Generic; using System.Linq; -using RynthCore.Plugin.RynthAi.LegacyUi; -using RynthCore.Plugin.RynthAi.Meta; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltHubController { @@ -28,92 +29,77 @@ internal sealed class IltHubController private readonly IltHubContext _ctx; private readonly IltHubUi _ui; - private readonly Func _quests; private readonly List _features = new(); private long _lastSaveAt; - private bool _questOutcomeHooked; - private bool _availabilityAnnounced; // "/ra hub to open" hint printed this session + private int _questGeneration; // RynthAi's /myquests refreshes seen (NoteQuestTrackerOutcome) + private bool _availabilityAnnounced; // "open the Mini Remote" hint printed this session + private volatile int _forceRequest = -1; // SetForceIlt from another thread, applied on the next tick public IltBanking Banking { get; } - public IltPets Pets { get; } public IltSessionRates Rates { get; } - public IltQuests Quests { get; } + /// The quest bonus list (/qb): the Quests tab's section and the Temple tracker's stamps. + public IltQuestBonus QuestBonus { get; } + /// The /pets and /shinies logs (the Pets tab's section). + public IltPetLogs PetLogs { get; } public IltProgression Progression { get; } public IltGear Gear { get; } public IltGames Games { get; } - /// Registry charm acquired / active / server state (the Charms tab and RynthPluginGetCharmsJson). + /// Registry charm acquired / active / server state (the Charms tab and RynthILTGetCharmsJson). public IltCharmTracker Charms { get; } /// The Mini Remote's Charms tab (registry charms with toggles, the Guardian Hand). public IltCharms CharmsTab { get; } /// Temple guardians: riddle translator, hand-in, attribute turn-in tracker. public IltGuardian Guardian { get; } - public IltHubController(RynthCoreHost host, string charFolder, Func cache, - Func settings, Func quests, Action saveCombatSettings, - RynthCore.Plugin.Shared.SessionStatsTracker? sessionStats = null) + /// True while this character's copy from RynthAi is unfinished (IltHubStore.WritesBlocked). + /// The character's RynthAi folder while that copy is unfinished (read-only fallback). + public IltHubController(RynthCoreHost host, string charFolder, IltSettings settings, RynthAiClient ai, + Func? writesBlocked = null, string? legacyFolder = null) { var store = new IltHubStore(host, charFolder); + if (writesBlocked != null) store.WritesBlocked = writesBlocked; + store.LegacyFolder = legacyFolder; var state = store.LoadState(); var capture = new IltChatCapture(host); - var inventory = new IltInventory(host, cache); + var inventory = new IltInventory(host, new IltObjects(host)); IltHubContext? ctxRef = null; - var options = new IltServerOptions(host, capture, state, text => ctxRef?.Chat(text), settings); - // Settings > Misc shows whether the per-character Hub override is on too. - ServerFeatureGate.HubForceProvider = () => state.ForceLeaftideFeatures; - _ctx = new IltHubContext(host, state, store, capture, options, inventory, settings) { SaveCombatSettings = saveCombatSettings }; + var options = new IltServerOptions(host, capture, state, text => ctxRef?.Chat(text), () => settings); + _ctx = new IltHubContext(host, state, store, capture, options, inventory, settings, ai); ctxRef = _ctx; - _quests = quests; Banking = new IltBanking(_ctx); - Pets = new IltPets(_ctx); - Rates = new IltSessionRates(_ctx, sessionStats); - Quests = new IltQuests(_ctx, quests); + PetLogs = new IltPetLogs(_ctx); + Rates = new IltSessionRates(_ctx); + QuestBonus = new IltQuestBonus(_ctx); Progression = new IltProgression(_ctx); Gear = new IltGear(_ctx); Games = new IltGames(_ctx); Charms = new IltCharmTracker(_ctx); CharmsTab = new IltCharms(_ctx, Charms); - Guardian = new IltGuardian(_ctx, quests, Quests); - _features.AddRange(new IIltFeature[] { Banking, Pets, Rates, Quests, Progression, Gear, CharmsTab, Games, Guardian }); + Guardian = new IltGuardian(_ctx, QuestBonus); + _features.AddRange(new IIltFeature[] { Banking, PetLogs, Rates, QuestBonus, Progression, Gear, CharmsTab, Games, Guardian }); Banking.BalanceChanged += Rates.OnBankBalanceChanged; Rates.MovingMoney = () => Banking.MovingMoney; options.ProbeReplyTap = OnProbeReply; _ui = new IltHubUi(this, _ctx); - _ctx.ShowTab = section => MiniRemoteTabCommand?.Invoke(IltSections.TabId(section), "show"); + _ctx.ShowTab = section => _ctx.Ai.MiniRemoteTab(IltSections.TabId(section), "show"); } public IltHubState State => _ctx.State; public IltServerOptions Options => _ctx.Options; - - /// - /// Shows / hides / toggles the Mini Remote ("show", "hide", "toggle"). Set by RynthAiPlugin; - /// returns the chat reply. Pump thread. - /// - public Func? MiniRemoteCommand { get; set; } - - /// - /// Puts the Mini Remote on a tab: (tab id from IltSections.TabId, "" = the remote itself; - /// mode "show" / "hide" / "toggle", or "select" to switch tabs without showing it). Set by - /// RynthAiPlugin; returns the chat reply. Any thread (plain field writes). - /// - public Func? MiniRemoteTabCommand { get; set; } - - /// True while the Mini Remote is on screen (set by RynthAiPlugin). - public Func? MiniRemoteVisible { get; set; } + internal IltHubContext Context => _ctx; /// World is ILT-like and the server has at least one ILT feature on. public bool Available => _ctx.Options.IsIltLikeWorld && _ctx.Options.AnyFeatureOn; /// - /// Whether a section can be shown now. The universal tabs (Quests, Pets) and Character always - /// can (Character explains why the ILT tabs are idle and holds the Force-ILT override); the - /// rest need server features. + /// Whether a section can be shown now. Character always can (it explains why the ILT tabs are + /// idle and holds the Force-ILT override); the rest need server features. /// public bool SectionAvailable(IltSection section) => section switch { IltSection.Character => true, - IltSection.Quests or IltSection.Pet => true, IltSection.Banking => Available && !_ctx.Options.IsOff(IltFeature.Bank), IltSection.Games => Available && Games.AnyGameAvailable, _ => Available, @@ -121,56 +107,47 @@ internal sealed class IltHubController /// /// The Mini Remote offers the Infinite Leaftide tabs: an ILT-like world (or the Force-ILT - /// override). The Character tab then always shows; the others follow - /// . The universal tabs don't depend on this. + /// override). The Character tab then always shows; the others follow . /// public bool OffersTabs => _ctx.Options.IsIltLikeWorld; - /// - /// Whether the Mini Remote's tab bar shows : a universal tab always, - /// an Infinite Leaftide tab on an ILT world once . - /// - public bool TabShown(IltSection section) => - IltSections.IsUniversal(section) || (OffersTabs && IltSections.IsTab(section) && SectionAvailable(section)); + /// Whether the Mini Remote's tab bar shows . + public bool TabShown(IltSection section) => OffersTabs && IltSections.IsTab(section) && SectionAvailable(section); - /// Render thread: one Mini Remote ILT tab's body (MiniRemoteHud draws the tab bar). + /// Render thread: one Mini Remote ILT tab's body (RynthAi's MiniRemoteHud draws the tab bar). public void RenderTab(IltSection section) => _ui.RenderTab(section); /// Render thread: the Guardian panel's body (RynthPluginRenderEmbed "guardian"). public void RenderGuardianPanel() => _ui.RenderGuardianPanel(); - /// The Force-ILT world override (world identity only; features still come from the server). + /// Render thread: one of the sections RynthAi draws (RynthILT.Hub RenderSection); false = nothing drawn. + public bool RenderSection(string id) => _ui.RenderSection(id); + + /// The Force-ILT world override (world identity only; features still come from the server). Set from any thread. public bool ForceIltWorld { get => _ctx.State.ForceLeaftideFeatures; - set => _ctx.State.ForceLeaftideFeatures = value; + set => _forceRequest = value ? 1 : 0; } /// Re-asks the server which features are on (safe from the render thread: posted to the pump). public void RequestOptionsRefresh() => _ctx.Post(() => _ctx.Options.Refresh(manual: true)); - /// True when the cached options already say /myquests is off (skip the login refresh). - public bool SkipLoginQuestRefresh => _ctx.Options.IsIltLikeWorld && _ctx.Options.IsOff(IltFeature.Quests); - // ── Lifecycle ─────────────────────────────────────────────────────────── - /// Login: remember the character, hook PetManager, schedule the options check, import UB data once. - public void OnLoginComplete(string charName, PetManager? petManager) + /// + /// Login: remember the character, schedule the options check, import UB data once. + /// : the character's RynthAi profile had "Force enable" ticked. + /// + public void OnLoginComplete(string charName, bool forceFromMigration) { _ctx.CharName = charName ?? string.Empty; + if (forceFromMigration) _ctx.State.ForceLeaftideFeatures = true; RynthLog.Event(LogEvents.IltLogin, $"login: char='{_ctx.CharName}' world='{_ctx.Options.WorldName}'"); _ctx.Options.OnLoginComplete(); _ctx.Inventory.Reset(); Rates.Reset(); - - if (petManager != null) - { - petManager.AllowSummonOnEmpty = Pets.AllowSummonOnEmpty; - petManager.HoldSummons = Pets.HoldCombatSummons; - petManager.YieldPetForCombat = Pets.YieldPetForCombat; - } - - HookQuestOutcome(); + _questGeneration = 0; if (!_ctx.State.UbSidecarsImported && _ctx.CharName.Length > 0) { @@ -180,26 +157,31 @@ internal sealed class IltHubController } } - private void HookQuestOutcome() + /// A RynthAi /myquests refresh ended since the last look: tell the options (the "quests" bit). + private void PollQuestOutcome() { - if (_questOutcomeHooked) return; - var t = _quests(); - if (t == null) return; - t.RefreshCompleted += () => _ctx.Options.NoteQuestTrackerOutcome(t.Disabled, t.Count); - _questOutcomeHooked = true; + if (!_ctx.Ai.TryGetQuestStatus(out var st) || st.Generation == _questGeneration) return; + _questGeneration = st.Generation; + if (st.Generation > 0) _ctx.Options.NoteQuestTrackerOutcome(st.Disabled != 0, st.Count); } /// Pump-thread tick. public void Tick() { long now = IltHubContext.NowMs; + int force = _forceRequest; + if (force >= 0) + { + _forceRequest = -1; + _ctx.State.ForceLeaftideFeatures = force == 1; + } _ctx.DrainPosted(); _ctx.Capture.Tick(); _ctx.Options.Tick(); - HookQuestOutcome(); + PollQuestOutcome(); // "Mini Remote on screen" gates bank auto-refresh and the gear / split-arrow scans. - _ctx.State.WindowVisible = MiniRemoteVisible?.Invoke() ?? false; + _ctx.State.WindowVisible = _ctx.Ai.MiniRemoteVisible; // One hint per session once the server confirms ILT features. The Mini Remote is separate // from the main RynthAi panel, so say how to open it. @@ -210,13 +192,14 @@ internal sealed class IltHubController _ctx.Chat("[Mini Remote] ILT server features detected. Open the Mini Remote (bar button, /rc miniremote) for the ILT tabs."); } - // The ILT features run only on ILT-like worlds; the universal ones (Quests, Pets) everywhere. - bool ilt = _ctx.Options.IsIltLikeWorld; - foreach (var f in _features) + // Every feature here is Infinite Leaftide's: dormant on any other world. + if (_ctx.Options.IsIltLikeWorld) { - if (!ilt && !IsUniversal(f)) continue; - try { f.Tick(now); } - catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.Tick"); } + foreach (var f in _features) + { + try { f.Tick(now); } + catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.Tick"); } + } } // Expire an unanswered chat confirmation so a stale "/ra hub confirm" can't fire it later. @@ -241,26 +224,22 @@ internal sealed class IltHubController string line = text.TrimEnd('\r', '\n'); _ctx.Options.OnChatLine(line); bool eat = _ctx.Capture.OnChatLine(line); - bool ilt = _ctx.Options.IsIltLikeWorld; + if (!_ctx.Options.IsIltLikeWorld) return eat; foreach (var f in _features) { - if (!ilt && !IsUniversal(f)) continue; try { eat |= f.OnChat(line); } catch (Exception ex) { RynthLog.Exception(CategoryOf(f), ex, $"{f.GetType().Name}.OnChat"); } } return eat; } - /// The feature behind a universal tab (Quests, Pets): it runs on every world. - private static bool IsUniversal(IIltFeature f) => f is IltQuests or IltPets; - /// Maps a feature module to its diagnostics category so its trace/exception lines land in its own file. private static LogCat CategoryOf(IIltFeature f) => f switch { IltBanking => LogCat.IltBanking, - IltPets => LogCat.IltPets, + IltPetLogs => LogCat.IltPets, IltSessionRates => LogCat.IltRates, - IltQuests => LogCat.IltQuests, + IltQuestBonus => LogCat.IltQuests, IltProgression => LogCat.IltProgression, IltGear or IltCharms => LogCat.IltGear, IltGames => LogCat.IltGames, @@ -282,23 +261,23 @@ internal sealed class IltHubController } /// - /// JSON for the engine Skills panel's Progression tab (RynthPluginGetProgressionJson). + /// JSON for the engine Skills panel's Progression tab (RynthILTGetProgressionJson). /// "available" is false off ILT-like worlds; the panel then hides the ILT sections. Pump thread. /// public string BuildProgressionJson() { var sb = new System.Text.StringBuilder(2048); sb.Append("{\"available\":").Append(Available ? "true" : "false"); - sb.Append(",\"world\":\"").Append(RynthAiPlugin.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append("\","); + sb.Append(",\"world\":\"").Append(IltStyle.JsonEscape(_ctx.Options.WorldName ?? string.Empty)).Append("\","); Progression.AppendSnapshotJson(sb); sb.Append('}'); return sb.ToString(); } - /// JSON for RynthPluginGetCharmsJson (an older engine's Settings "Charms Tracking" tab). Pump thread. + /// JSON for RynthILTGetCharmsJson / RynthPluginGetCharmsJson (an older engine's Settings "Charms Tracking" tab). Pump thread. public string BuildCharmsJson() => Charms.BuildJson(); - /// Render thread: Games HUD, quest favorites HUD and confirmation popups. + /// Render thread: Games HUD and confirmation popups. public void Render() => _ui.Render(); // ── Probe taps: reuse login-probe replies so tabs fill without extra commands ── @@ -309,9 +288,9 @@ internal sealed class IltHubController switch (key) { case IltFeature.Aug: Progression.ApplyAugLines(r.Lines); break; - case IltFeature.Pets: Pets.ApplyRoster(false, r.Lines); break; - case IltFeature.Shinies: Pets.ApplyRoster(true, r.Lines); break; - case IltFeature.Qb: Quests.ApplyQbProbe(r.Lines); break; + case IltFeature.Pets: PetLogs.ApplyRoster(false, r.Lines); break; + case IltFeature.Shinies: PetLogs.ApplyRoster(true, r.Lines); break; + case IltFeature.Qb: QuestBonus.ApplyQbProbe(r.Lines); break; // Bank lines are parsed passively by IltBanking.OnChat as they arrive. } } @@ -319,50 +298,26 @@ internal sealed class IltHubController // ── Commands ──────────────────────────────────────────────────────────── /// - /// "/ra hub [show|hide|toggle|open <section> [show|hide|toggle]|tab <section|remote>|refresh| - /// bank|status|force on|off|profile save|load|list ...|suit list|test|load ...]" (show/hide/toggle - /// drive the Mini Remote, open puts it on a tab, tab switches tabs without showing it), - /// "/ra quests [refresh|check <regex>|window|favhud]", "/ra pets [show|hide|toggle]", - /// "/ra bounty [show|hide|toggle]" (aliases bounties / bountys: RynthCore's ILT Bounties panel) - /// and "/ra guardian ..." (window: RynthCore's ILT Guardian panel; the rest IltGuardian.HandleCommand). - /// Pump thread. Returns false if not handled. + /// The ILT verbs: "/ra hub [open <ILT tab> [show|hide|toggle]|tab <ILT tab>|refresh|bank|status| + /// force on|off|servers [list]|profile save|load|list ...|suit list|test|load ...|clap|attr ...| + /// confirm|cancel]" (RynthAi keeps show/hide/toggle and its own Quests / Pets tabs, and forwards + /// the rest here; "/ilt hub ..." comes straight here), "/ra bounty [show|hide|toggle]" (aliases + /// bounties / bountys: RynthCore's ILT Bounties panel), "/ra guardian ..." (window: RynthCore's + /// ILT Guardian panel; the rest IltGuardian.HandleCommand) and "rates reset" (the Mini Remote's + /// Reset XP). Pump thread. Returns false if not handled. /// public bool HandleCommand(string verb, string[] args) { RynthLog.Event(LogEvents.IltCommand, $"command: /ra {verb} {string.Join(" ", args)}".TrimEnd()); - if (verb.Equals("quests", StringComparison.OrdinalIgnoreCase)) + if (verb.Equals("rates", StringComparison.OrdinalIgnoreCase)) { - string sub = args.Length > 0 ? args[0].ToLowerInvariant() : "refresh"; - string mode = args.Length > 1 ? args[1].ToLowerInvariant() : "toggle"; - var cs = _ctx.State.Character; - switch (sub) - { - case "check" when args.Length > 1: - Quests.CheckCommand(string.Join(" ", args.Skip(1))); - break; - case "window": - OpenSection(IltSection.Quests, mode); - break; - case "favhud": - case "favorites": - cs.ShowQuestFavoritesHud = ResolveToggle(mode, cs.ShowQuestFavoritesHud); - _ctx.Chat(cs.ShowQuestFavoritesHud ? "[Mini Remote] Quest favorites HUD shown." : "[Mini Remote] Quest favorites HUD hidden."); - break; - default: - _ctx.Chat("[Mini Remote] " + Quests.RefreshQuests()); - break; - } - return true; - } - if (verb.Equals("pets", StringComparison.OrdinalIgnoreCase)) - { - // "/ra pets [show|hide|toggle]": same as "/ra hub open pets". - OpenSection(IltSection.Pet, args.Length > 0 ? args[0] : "toggle"); + // "rates reset": the coin / pyreal session starts over with RynthAi's session stats. + Rates.Reset(); return true; } if (IsBountyVerb(verb)) { - // Bounties are the RynthILT plugin's (RynthCore's ILT button); open that panel. + // Bounties are RynthILT's Bounties window (RynthCore's ILT button); open that panel. OpenEnginePanel("bounties", "Bounties", args.Length > 0 ? args[0] : "toggle"); return true; } @@ -378,16 +333,15 @@ internal sealed class IltHubController } if (!verb.Equals("hub", StringComparison.OrdinalIgnoreCase)) return false; - string cmd = args.Length > 0 ? args[0].ToLowerInvariant() : "toggle"; + string cmd = args.Length > 0 ? args[0].ToLowerInvariant() : "help"; string rest = args.Length > 1 ? string.Join(" ", args.Skip(1)) : string.Empty; switch (cmd) { case "show": case "hide": case "toggle": - // The Mini Remote is the Hub's main window. - if (MiniRemoteCommand != null) _ctx.Chat(MiniRemoteCommand(cmd)); - else _ctx.Chat("[Mini Remote] The Mini Remote is not available yet."); + // The Mini Remote is RynthAi's ("/ilt hub show" lands here). + _ctx.Chat("[Mini Remote] " + _ctx.Ai.MiniRemoteTab(IltSections.RemoteTab, cmd)); break; case "open": if (args.Length > 1 && IsBountyVerb(args[1])) @@ -397,6 +351,8 @@ internal sealed class IltHubController } if (args.Length < 2 || !IltSections.TryParse(args[1], out IltSection section)) { + // Quests and Pets are RynthAi's tabs: not ours to open. + if (args.Length >= 2 && IltSections.IsUniversalTabName(args[1])) return false; _ctx.Chat("[Mini Remote] Usage: /ra hub open character|quests|pets|banking|gear|charms|games|guardian|bounties [show|hide|toggle]"); break; } @@ -405,9 +361,9 @@ internal sealed class IltHubController case "tab": // The engine's dashboard: it opens its Mini Remote window itself, so only switch tabs. if (args.Length > 1 && IltSections.TryParse(args[1], out IltSection tab) && IltSections.IsTab(tab)) - MiniRemoteTabCommand?.Invoke(IltSections.TabId(tab), "select"); + _ctx.Ai.MiniRemoteTab(IltSections.TabId(tab), "select"); else - MiniRemoteTabCommand?.Invoke(IltSections.RemoteTab, "select"); + return false; // the Remote tab or a RynthAi tab: RynthAi's break; case "refresh": _ctx.Options.Refresh(manual: true); break; case "bank": Banking.RequestRefresh(quiet: false); break; @@ -416,6 +372,7 @@ internal sealed class IltHubController _ctx.State.ForceLeaftideFeatures = !rest.Equals("off", StringComparison.OrdinalIgnoreCase); _ctx.Chat($"[Mini Remote] Force ILT world: {(_ctx.State.ForceLeaftideFeatures ? "on" : "off")}. Use /ra hub refresh to re-check the server."); break; + case "servers": HandleServers(rest); break; case "profile": HandleProfile(args.Skip(1).ToArray()); break; case "suit": HandleSuit(args.Skip(1).ToArray()); break; case "clap": Gear.ChunkClap.ClapNow(manual: true); break; @@ -426,18 +383,36 @@ internal sealed class IltHubController ClearPending(); break; default: - _ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote)|refresh|bank|status|force on|off|clap|confirm|cancel"); + _ctx.Chat("[Mini Remote] /ra hub [show|hide|toggle] (Mini Remote)|refresh|bank|status|force on|off|servers [list]|clap|confirm|cancel"); _ctx.Chat("[Mini Remote] /ra hub open character|quests|pets|banking|gear|charms|games [show|hide|toggle] (Mini Remote tabs)"); _ctx.Chat("[Mini Remote] /ra hub profile list|save [shared]|load /ra hub suit list|test|load [name]"); _ctx.Chat("[Mini Remote] /ra hub attr run|stop|costs|status|auto on|off|every |raise (Skills panel > Progression)"); _ctx.Chat("[Mini Remote] /ra quests [refresh|check |window [show|hide]|favhud [show|hide]] /ra pets [show|hide]"); _ctx.Chat("[Mini Remote] /ra guardian [window|translate |handin|stop|chat on|off|auto on|off|buy on|off|refresh|status] (window: ILT button > Guardian)"); _ctx.Chat("[Mini Remote] /ra bounty [show|hide|toggle] (RynthCore's ILT button > Bounties, /rc bounties)"); + _ctx.Chat("[Mini Remote] The ILT verbs also work as /ilt hub ..., /ilt guardian ... (RynthILT)."); break; } return true; } + /// "/ra hub servers [list | <names, comma separated> | default]": which world names count as Infinite Leaftide. + private void HandleServers(string rest) + { + string arg = rest.Trim(); + if (arg.Length > 0 && !arg.Equals("list", StringComparison.OrdinalIgnoreCase)) + { + var list = arg.Equals("default", StringComparison.OrdinalIgnoreCase) + ? new List(ServerFeatureGate.DefaultServerNames) + : ServerFeatureGate.ParseList(arg); + if (list.Count == 0) { _ctx.Chat("[Mini Remote] Usage: /ra hub servers | default | list"); return; } + _ctx.Settings.ServerNames = list; + _ctx.SaveSettings(); + } + _ctx.Chat("[Mini Remote] ILT world names: " + ServerFeatureGate.FormatList(ServerFeatureGate.Patterns(_ctx.Settings))); + _ctx.Chat("[Mini Remote] " + ServerFeatureGate.Describe(_ctx.Options.WorldName, _ctx.Settings, _ctx.State.ForceLeaftideFeatures)); + } + /// "/ra hub attr ...": the attribute raiser from chat (same verbs as the Progression tab). private void HandleAttr(string[] a) { @@ -478,7 +453,7 @@ internal sealed class IltHubController OpenEnginePanel(IltSections.TabId(section), IltSections.Label(section), mode); return; } - string reply = MiniRemoteTabCommand?.Invoke(IltSections.TabId(section), mode) ?? "The Mini Remote is not available yet."; + string reply = _ctx.Ai.MiniRemoteTab(IltSections.TabId(section), mode); if (!SectionAvailable(section) && !mode.Equals("hide", StringComparison.OrdinalIgnoreCase)) reply = $"The {IltSections.Label(section)} tab shows once the server reports that feature on."; _ctx.Chat("[Mini Remote] " + reply); diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubState.cs similarity index 77% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubState.cs index 82581e2..b68e7fd 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubState.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubState.cs @@ -1,13 +1,16 @@ // IltHubState.cs — Persisted per-character state for the ILT Hub (Infinite Leaftide tools). +// Originally SilentKelpie's ILT Hub state in RynthAi; moved to RynthILT 2026-10-13. // -// Lives in \ilt-hub.json, deliberately separate from the combat settings -// profile (Default.json / /ra settings) so ILT data never leaks into combat profiles and -// non-ILT characters stay untouched. Serialized with the NativeAOT source-generated -// RynthAiJsonContext (IncludeFields = true), so plain public fields are used throughout. +// Lives in %APPDATA%\RynthCore\RynthILT\\\hub.json (IltHubStore). The first +// login with RynthILT copies RynthAi's \ilt-hub.json there (IltMigration), so the +// shape stays compatible with that file: the parts that stayed with RynthAi's universal Mini +// Remote tabs (the Pets tab's settings, the quest tracker's filter and favorites, the VTank +// import path) are simply not read here any more. Serialized with the NativeAOT source-generated +// IltHubJsonContext (IncludeFields = true), so plain public fields are used throughout. using System; using System.Collections.Generic; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// Root of everything the Hub remembers between sessions. public sealed class IltHubState @@ -100,49 +103,11 @@ public sealed class IltBankTransaction public sealed class IltPetState { - // Healing-pet automation (UB "HealingBuddy" subset). - public bool HealingEnabled; - /// Exact name of the heal-pet essence to use; empty = auto-detect (Healing Buddy / Dule box). - public string HealPetName = string.Empty; - public int HealthThresholdPercent = 80; - /// Do not summon when current HP is below this (summoning mid-death wastes the use). 0 = off. - public int MinHealthPoints = 100; - public bool AutoDespawnAfterHeal = true; - public int RespawnDelaySeconds = 2; - public int PetTimeoutSeconds = 30; - - /// - /// Allow a combat summon from an EMPTY essence when the Summon Essence Refill Charm is - /// active (server refills from banked pyreals). Still requires the server flag to be on. - /// - public bool UsePyrealRefillPath; - - /// Last captured /pets and /shinies rosters (display only). + /// Last captured /pets and /shinies rosters (display only; the Pets tab's logs). public List PetLog = new(); public List ShinyLog = new(); - - // ── Pet roster (UB Pets-tab style) ── - /// Roster type shown in the Pet tab (IltPetKind: 0 Combat, 1 Healing, 2 Cosmetic). - public int RosterKind; - /// Roster sort (IltPetSort: 0 Priority, 1 Bond, 2 Potency, 3 Breed ready, 4 Level, 5 Uses, 6 Name). - public int RosterSort; - /// User type overrides by essence name; essences not listed are auto-classified. - public List Assignments = new(); - - /// Essence name of the chosen cosmetic (display) pet; empty = none. - public string CosmeticPetName = string.Empty; - /// Keep the cosmetic pet summoned while in peace mode; it is dismissed when a combat pet is needed. - public bool KeepCosmeticOut; - /// Seconds to wait before re-summoning the cosmetic pet after it despawns. - public int CosmeticRespawnSeconds = 15; -} - -/// A user's choice of summon type for one essence (matched by name, case-insensitive). -public sealed class IltPetAssignment -{ - public string Name = string.Empty; - /// IltPetKind as int (0 Combat, 1 Healing, 2 Cosmetic). - public int Kind; + // The Pets tab's own settings (roster, healing / cosmetic pets, refill path) are RynthAi's + // (its miniremote.json); older ilt-hub.json files still carry them, and they are ignored here. } // ── Character ─────────────────────────────────────────────────────────────── @@ -186,17 +151,8 @@ public sealed class IltCharacterState /// /attr abbreviations the raiser may spend on ("Raise now" and auto-raise). public List AttrRaiseStats = new(); - /// Quest Tracker search box contents. - public string QuestFilter = string.Empty; + /// Quest bonus (/qb) list filter. (The /myquests tracker's filter and favorites are RynthAi's.) public string QbFilter = string.Empty; - - /// Starred quest flag keys (lowercase), shown on the floating favorites HUD. - public List QuestFavorites = new(); - /// Quest tracker lists starred quests only. - public bool QuestFavoritesOnly; - /// Floating quest favorites HUD is shown. - public bool ShowQuestFavoritesHud; - public bool QuestFavoritesHudLocked; // The ILT sections are Mini Remote tabs now (HudState.MiniRemoteTab); the old per-section // "window open" flags in older files are ignored on load. @@ -258,9 +214,8 @@ public sealed class IltGearState public int SplitArrowTarget = 3; public bool SplitIgnoreImbued = true; - // Equipment profiles (.utl suits) and VTank .usd import + // Equipment profiles (.utl suits). (The VTank .usd import path is RynthAi's: the importer stayed there.) public string LastEquipProfile = string.Empty; - public string LastUsdPath = string.Empty; } // ── Games ─────────────────────────────────────────────────────────────────── diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubStore.cs similarity index 75% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubStore.cs index 34afbaa..04fb5ef 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltHubStore.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubStore.cs @@ -1,10 +1,13 @@ // IltHubStore.cs — Disk persistence for the ILT Hub. +// Originally SilentKelpie's ILT Hub store in RynthAi; moved to RynthILT 2026-10-13. // -// Files (all under the per-character settings folder the dashboard already uses): -// \ilt-hub.json live Hub state (IltHubState) -// \ilt-hub-transactions.json bank transaction log (capped) -// \ilt-hub-profiles\.json named per-character Hub profiles -// \IltHubProfiles\.json named profiles shared by every character +// Files (RynthILT's folder, %APPDATA%\RynthCore\RynthILT; = \): +// \hub.json live Hub state (IltHubState) +// \bank-transactions.json bank transaction log (capped) +// \profiles\.json named per-character Hub profiles +// Profiles\.json named profiles shared by every character +// They were ilt-hub.json, ilt-hub-transactions.json, ilt-hub-profiles\ (RynthAi's per-character +// settings folder) and RynthAi\IltHubProfiles\; IltMigration copies them over on the first login. // Saves are dirty-checked (the serialized JSON is compared to what was last written) so // the periodic save in Tick costs nothing when nothing changed. A one-time import pulls // UtilityBelt's bankdata sidecars so players keep their balances and history. @@ -13,18 +16,22 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.Json; +using RynthCore.Plugin.Shared; using RynthCore.PluginSdk; -using RynthCore.Install; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltHubStore { /// Maximum bank transactions kept on disk (oldest dropped first). public const int MaxTransactions = 1000; - /// Shared root (\RynthAi) for profiles usable by every character. - public static readonly string SharedRoot = RynthInstallPaths.RynthAiDir; + /// RynthILT's folder: shared profiles, aug costs and equipment suits (overridable for the tests). + public static string SharedRoot = RynthILTPlugin.SettingsRoot; + + public const string StateFile = "hub.json"; + public const string TransactionsFile = "bank-transactions.json"; + public const string ProfilesFolder = "profiles"; private readonly RynthCoreHost _host; private readonly string _charFolder; @@ -37,11 +44,49 @@ internal sealed class IltHubStore _charFolder = charFolder ?? string.Empty; } + /// + /// True while this character's copy from RynthAi is unfinished (IltMigration): the state, the + /// bank log and per-character profiles are not written, so no fresh file shadows a RynthAi + /// original that hasn't been copied yet. Shared profiles still save. + /// + public Func WritesBlocked = static () => false; + + /// + /// The character's RynthAi folder while its copy is unfinished: a file RynthILT doesn't have yet + /// is read from there (read only) when it can be; otherwise the Hub runs from the defaults. + /// + public string? LegacyFolder; + + private bool Blocked() + { + try { return WritesBlocked(); } + catch { return true; } + } + + /// A RynthAi original read without locking it (it may be held open elsewhere). Null when it can't be. + private string? ReadLegacy(string fileName) + { + if (string.IsNullOrEmpty(LegacyFolder)) return null; + string path = Path.Combine(LegacyFolder, fileName); + try + { + if (!File.Exists(path)) return null; + using var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete); + using var sr = new StreamReader(fs); + return sr.ReadToEnd(); + } + catch (Exception ex) + { + RynthLog.Write(LogCat.IltStore, $"RynthAi's {path} can't be read yet ({ex.Message}); running from the defaults until it is copied."); + return null; + } + } + public string CharFolder => _charFolder; - private string StatePath => Path.Combine(_charFolder, "ilt-hub.json"); - private string TxPath => Path.Combine(_charFolder, "ilt-hub-transactions.json"); - private string CharProfileDir => Path.Combine(_charFolder, "ilt-hub-profiles"); - private static string SharedProfileDir => Path.Combine(SharedRoot, "IltHubProfiles"); + private string StatePath => Path.Combine(_charFolder, StateFile); + private string TxPath => Path.Combine(_charFolder, TransactionsFile); + private string CharProfileDir => Path.Combine(_charFolder, ProfilesFolder); + internal static string SharedProfileDir => Path.Combine(SharedRoot, "Profiles"); // ── State ─────────────────────────────────────────────────────────────── @@ -53,7 +98,7 @@ internal sealed class IltHubStore if (_charFolder.Length > 0 && File.Exists(StatePath)) { string json = File.ReadAllText(StatePath); - var s = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltHubState); + var s = JsonSerializer.Deserialize(json, IltHubJsonContext.Default.IltHubState); if (s != null) { Normalize(s); @@ -61,6 +106,11 @@ internal sealed class IltHubStore return s; } } + else if (ReadLegacy("ilt-hub.json") is string legacyJson) + { + var s = JsonSerializer.Deserialize(legacyJson, IltHubJsonContext.Default.IltHubState); + if (s != null) { Normalize(s); return s; } + } } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {StatePath}"); } return new IltHubState(); @@ -72,11 +122,16 @@ internal sealed class IltHubStore if (_charFolder.Length == 0) return; try { - string json = JsonSerializer.Serialize(state, RynthAiJsonContext.Default.IltHubState); + string json = JsonSerializer.Serialize(state, IltHubJsonContext.Default.IltHubState); if (json == _lastStateJson) return; - Directory.CreateDirectory(_charFolder); - WriteAtomic(StatePath, json); - _lastStateJson = json; + if (Blocked()) return; // the copy from RynthAi isn't finished: never shadow its hub.json + // A failure is said in chat once per folder (on ILT) and logged; the next periodic save retries. + if (DataWriteGuard.TrySave("the ILT Hub state", StatePath, () => + { + Directory.CreateDirectory(_charFolder); + WriteAtomic(StatePath, json); + })) + _lastStateJson = json; } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {StatePath}"); } } @@ -90,16 +145,8 @@ internal sealed class IltHubStore s.Pet ??= new IltPetState(); s.Pet.PetLog ??= new(); s.Pet.ShinyLog ??= new(); - s.Pet.Assignments ??= new(); - s.Pet.Assignments.RemoveAll(a => a == null || string.IsNullOrWhiteSpace(a.Name)); - s.Pet.CosmeticPetName ??= string.Empty; - s.Pet.RosterKind = Math.Clamp(s.Pet.RosterKind, 0, 2); - s.Pet.RosterSort = Math.Clamp(s.Pet.RosterSort, 0, 6); - s.Pet.CosmeticRespawnSeconds = Math.Clamp(s.Pet.CosmeticRespawnSeconds, 5, 600); s.Character ??= new IltCharacterState(); s.Character.ItemConversions ??= new(); - s.Character.QuestFavorites ??= new(); - s.Character.QuestFavorites.RemoveAll(string.IsNullOrWhiteSpace); s.Character.AugTargets = new Dictionary(s.Character.AugTargets ?? new(), StringComparer.OrdinalIgnoreCase); s.Character.AttrOrder = IltAttributeRaiser.RepairOrder(s.Character.AttrOrder); s.Character.AttrRaiseStats = IltAttributeRaiser.RepairSelection(s.Character.AttrRaiseStats); @@ -128,9 +175,14 @@ internal sealed class IltHubStore if (_charFolder.Length > 0 && File.Exists(TxPath)) { string json = File.ReadAllText(TxPath); - var list = JsonSerializer.Deserialize(json, RynthAiJsonContext.Default.IltBankTransactionList); + var list = JsonSerializer.Deserialize(json, IltHubJsonContext.Default.IltBankTransactionList); if (list != null) { _lastTxJson = json; return list; } } + else if (ReadLegacy("ilt-hub-transactions.json") is string legacyJson) + { + var list = JsonSerializer.Deserialize(legacyJson, IltHubJsonContext.Default.IltBankTransactionList); + if (list != null) return list; + } } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {TxPath}"); } return new List(); @@ -143,11 +195,15 @@ internal sealed class IltHubStore { if (list.Count > MaxTransactions) list.RemoveRange(0, list.Count - MaxTransactions); - string json = JsonSerializer.Serialize(list, RynthAiJsonContext.Default.IltBankTransactionList); + string json = JsonSerializer.Serialize(list, IltHubJsonContext.Default.IltBankTransactionList); if (json == _lastTxJson) return; - Directory.CreateDirectory(_charFolder); - WriteAtomic(TxPath, json); - _lastTxJson = json; + if (Blocked()) return; // as SaveStateIfDirty + if (DataWriteGuard.TrySave("the bank transaction log", TxPath, () => + { + Directory.CreateDirectory(_charFolder); + WriteAtomic(TxPath, json); + })) + _lastTxJson = json; } catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {TxPath}"); } } @@ -176,14 +232,24 @@ internal sealed class IltHubStore error = string.Empty; string safe = SanitizeName(name); if (safe.Length == 0) { error = "Profile name is empty."; return false; } + if (!shared && Blocked()) + { + error = "this character's Hub data is still being copied from RynthAi (see the log); save it as a shared profile, or try again later."; + return false; + } try { string dir = shared ? SharedProfileDir : CharProfileDir; - Directory.CreateDirectory(dir); var copy = Clone(state); StripRuntime(copy); - WriteAtomic(Path.Combine(dir, safe + ".json"), JsonSerializer.Serialize(copy, RynthAiJsonContext.Default.IltHubState)); - return true; + string json = JsonSerializer.Serialize(copy, IltHubJsonContext.Default.IltHubState); + string path = Path.Combine(dir, safe + ".json"); + // The player asked for this save: the caller shows the reason (and the fix) itself. + return DataWriteGuard.TrySave("the Hub profile", path, () => + { + Directory.CreateDirectory(dir); + WriteAtomic(path, json); + }, out error, callerShows: true); } catch (Exception ex) { error = ex.Message; return false; } } @@ -201,7 +267,7 @@ internal sealed class IltHubStore try { if (!File.Exists(path)) { error = $"Profile not found: {name}"; return false; } - var p = JsonSerializer.Deserialize(File.ReadAllText(path), RynthAiJsonContext.Default.IltHubState); + var p = JsonSerializer.Deserialize(File.ReadAllText(path), IltHubJsonContext.Default.IltHubState); if (p == null) { error = "Profile file is empty."; return false; } Normalize(p); target.Pet = KeepRosters(p.Pet, target.Pet); @@ -224,8 +290,8 @@ internal sealed class IltHubStore } private static IltHubState Clone(IltHubState s) - => JsonSerializer.Deserialize(JsonSerializer.Serialize(s, RynthAiJsonContext.Default.IltHubState), - RynthAiJsonContext.Default.IltHubState) ?? new IltHubState(); + => JsonSerializer.Deserialize(JsonSerializer.Serialize(s, IltHubJsonContext.Default.IltHubState), + IltHubJsonContext.Default.IltHubState) ?? new IltHubState(); /// Removes character-specific runtime data before a profile is written. private static void StripRuntime(IltHubState s) diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubUi.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubUi.cs new file mode 100644 index 0000000..c5bb740 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltHubUi.cs @@ -0,0 +1,369 @@ +// IltHubUi.cs — The ILT sections' ImGui bodies (render thread only). +// Originally SilentKelpie's ILT Hub UI (RynthAi IltHub/); moved to RynthILT 2026-10-13, with the +// ILT parts of RynthAi's Mini Remote (the Remote tab's Bank section and Guardian line, the menu's +// Infinite Leaftide items) that read the Hub's state. +// +// The ILT sections are tabs of RynthAi's Mini Remote (its MiniRemoteHud draws the tab bar and +// calls RenderTab through RynthILT.Hub): Character (world status, Force-ILT, server names, +// profiles, session rates), Banking, Gear, Charms and Games. A tab is offered only while the +// server reports its feature on. RenderSection draws the ILT pieces inside RynthAi's own +// surfaces (the Remote tab, the Quests and Pets tabs, the Mini Remote menu). The Guardian is a +// RynthCore ILT panel (the bar's ILT button, next to Bounties), drawn through +// RenderGuardianPanel. Render() keeps the floating extras: the Games HUD and the confirmation +// modal. Augmentations / Enlightenment / XP planning live on the engine Skills panel. All AC +// actions go through IltHubContext.Post / Confirm so nothing here touches the game directly. +using System; +using System.Numerics; +using ImGuiNET; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthILT.Hub; + +internal sealed class IltHubUi +{ + private const string ConfirmPopupId = "Confirm##iltconfirm"; + private static readonly Vector4 ColLabel = new(0.80f, 0.84f, 0.90f, 1f); + + private readonly IltHubController _hub; + private readonly IltHubContext _ctx; + private IltConfirmRequest? _confirm; + private bool _confirmOpened; + private string _profileName = string.Empty; + private bool _profileShared; + private string[] _profileList = Array.Empty(); + private int _profileIdx; + private string? _serverNamesEdit; + // The last tab body drawn (for one shown log event per tab change); -1 = none yet. + private int _lastTabLogged = -1; + + public IltHubUi(IltHubController hub, IltHubContext ctx) + { + _hub = hub; + _ctx = ctx; + } + + /// The floating extras: Games HUD and the confirmation modal. + public void Render() + { + _hub.Games.RenderHud(); + RenderConfirm(); + } + + /// Draws one Mini Remote ILT tab's body into the current (child) window. + public void RenderTab(IltSection section) + { + if ((int)section != _lastTabLogged) + { + _lastTabLogged = (int)section; + RynthLog.Event(LogEvents.IltWindowShown, $"{IltSections.Label(section)} tab shown (world='{_ctx.Options.WorldName}', available={_hub.Available})"); + } + switch (section) + { + case IltSection.Character: RenderCharacterBody(); break; + case IltSection.Banking: _hub.Banking.Render(); break; + case IltSection.Gear: _hub.Gear.Render(); break; + case IltSection.Charms: _hub.CharmsTab.Render(); break; + case IltSection.Games: _hub.Games.Render(); break; + } + } + + /// + /// One of the ILT pieces RynthAi draws in its own surfaces (RynthIltHub.Section*). False when + /// there is nothing to draw (unknown id, or not an ILT world). + /// + public bool RenderSection(string id) + { + var o = _ctx.Options; + switch (id) + { + case RynthIltHub.SectionRemoteBank: + if (!o.IsIltLikeWorld || o.IsOff(IltFeature.Bank)) return false; + RenderRemoteBank(); + return true; + case RynthIltHub.SectionRemoteGuardian: + if (!o.IsIltLikeWorld) return false; + _hub.Guardian.RenderRemoteLine(); + return true; + case RynthIltHub.SectionQuestBonus: + if (!o.IsIltLikeWorld) return false; + _hub.QuestBonus.RenderSection(); + return true; + case RynthIltHub.SectionPetLogs: + if (!o.IsIltLikeWorld) return false; + _hub.PetLogs.RenderSection(); + return true; + case RynthIltHub.SectionIltStatus: + return RenderIltStatus(); + case RynthIltHub.SectionServerMenu: + return RenderLocalMenu(); + default: + return false; + } + } + + /// + /// The Guardian panel's body (RynthCore's ILT Guardian panel, RynthPluginRenderEmbed + /// "guardian"), or why it's idle while the server hasn't reported ILT features. + /// + public void RenderGuardianPanel() + { + if (!_hub.SectionAvailable(IltSection.Guardian)) + { + RenderHeader(); + ImGui.Separator(); + RenderUnavailable(); + return; + } + _hub.Guardian.Render(); + } + + /// Character tab: world / options header, then session rates (or why the ILT tabs are idle). + private void RenderCharacterBody() + { + RenderHeader(); + ImGui.Separator(); + if (!_hub.Available) { RenderUnavailable(); return; } + if (ImGui.CollapsingHeader("Session rates", ImGuiTreeNodeFlags.DefaultOpen)) _hub.Rates.Render(); + ImGui.Spacing(); + ImGui.TextDisabled("XP planner, Augmentations and Enlightenment are on the Skills panel's Progression tab"); + ImGui.TextDisabled("(right-click the dashboard's Char button > Progression)."); + } + + private void RenderHeader() + { + var o = _ctx.Options; + string world = o.WorldName.Length > 0 ? o.WorldName : "unknown world"; + ImGui.TextColored(o.IsIltLikeWorld ? IltStyle.ColTeal : IltStyle.ColTextMute, world); + ImGui.SameLine(); + ImGui.TextDisabled(o.IsRefreshing ? "checking server options..." + : o.LastRefreshUtc == DateTime.MinValue ? "server options not checked yet" + : $"options via {o.Source} @ {o.LastRefreshUtc.ToLocalTime():t}"); + ImGui.SameLine(); + if (ImGui.SmallButton("Refresh##opts")) _ctx.Post(() => o.Refresh(manual: true)); + + bool force = _ctx.State.ForceLeaftideFeatures; + if (ImGui.Checkbox("Treat this world as ILT", ref force)) _hub.ForceIltWorld = force; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("World-identity override only: the Mini Remote asks the server which ILT features exist.\nIt never turns a feature on by itself."); + ImGui.SameLine(); + if (ImGui.SmallButton("Servers...")) { _serverNamesEdit = null; ImGui.OpenPopup("##iltservers"); } + ImGui.SameLine(); + if (ImGui.SmallButton("Profiles...")) { ImGui.OpenPopup("##iltprofiles"); _ctx.Post(() => _profileList = _ctx.Store.ListProfiles().ToArray()); } + RenderServersPopup(); + RenderProfilesPopup(); + } + + /// + /// The world names that count as Infinite Leaftide (RynthAi's Settings > Misc "Server Features" + /// list before the move; one list for every character now). + /// + private void RenderServersPopup() + { + if (!ImGui.BeginPopup("##iltservers")) return; + ImGui.TextColored(IltStyle.ColTeal, "Infinite Leaftide world names"); + ImGui.TextDisabled(ServerFeatureGate.Describe(_ctx.Options.WorldName, _ctx.Settings, _ctx.State.ForceLeaftideFeatures)); + string text = _serverNamesEdit ?? ServerFeatureGate.FormatList(ServerFeatureGate.Patterns(_ctx.Settings)); + ImGui.SetNextItemWidth(320); + bool enter = ImGui.InputTextWithHint("##iltservernames", "InfiniteLeaftide, *Leaftide*", ref text, 512, ImGuiInputTextFlags.EnterReturnsTrue); + _serverNamesEdit = text; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("Comma-separated world names that turn on the ILT tabs, the Guardian, the Progression\n" + + "planners and the attribute raiser. * is a wildcard (*Leaftide* matches any\n" + + "name containing Leaftide). Case does not matter. Also: /ra hub servers ."); + ImGui.SameLine(); + if (ImGui.SmallButton("Save") || enter) + { + var list = ServerFeatureGate.ParseList(_serverNamesEdit); + if (list.Count > 0) + _ctx.Post(() => { _ctx.Settings.ServerNames = list; _ctx.SaveSettings(); }); + _serverNamesEdit = null; + } + ImGui.SameLine(); + if (ImGui.SmallButton("Default")) + { + _ctx.Post(() => { _ctx.Settings.ServerNames = new(ServerFeatureGate.DefaultServerNames); _ctx.SaveSettings(); }); + _serverNamesEdit = null; + } + ImGui.EndPopup(); + } + + private void RenderProfilesPopup() + { + if (!ImGui.BeginPopup("##iltprofiles")) return; + ImGui.TextColored(IltStyle.ColTeal, "ILT profiles (settings only; no balances)"); + ImGui.SetNextItemWidth(180); + ImGui.InputTextWithHint("##profname", "profile name", ref _profileName, 64u); + ImGui.SameLine(); + ImGui.Checkbox("shared", ref _profileShared); + ImGui.SameLine(); + if (ImGui.SmallButton("Save")) + { + string n = _profileName; bool sh = _profileShared; + _ctx.Post(() => + { + _ctx.Chat(_ctx.Store.SaveProfile(_ctx.State, n, sh, out string err) ? $"[Mini Remote] Saved profile '{n}'." : "[Mini Remote] Save failed: " + err); + _profileList = _ctx.Store.ListProfiles().ToArray(); + }); + } + var list = _profileList; + if (list.Length > 0) + { + _profileIdx = Math.Clamp(_profileIdx, 0, list.Length - 1); + ImGui.SetNextItemWidth(180); + ImGui.Combo("##proflist", ref _profileIdx, list, list.Length); + ImGui.SameLine(); + if (ImGui.SmallButton("Load")) + { + string n = list[_profileIdx]; + _ctx.Confirm("Load ILT profile", $"Replace the current ILT settings with profile '{n}'?", + () => _ctx.Chat(_ctx.Store.LoadProfile(_ctx.State, n, out string err) ? $"[Mini Remote] Loaded profile '{n}'." : "[Mini Remote] Load failed: " + err), + "Load"); + } + } + else ImGui.TextDisabled("No saved profiles."); + ImGui.EndPopup(); + } + + private void RenderUnavailable() + { + var o = _ctx.Options; + if (!o.IsIltLikeWorld) + { + ImGui.TextWrapped("This is not an Infinite Leaftide / ACECustom world, so the ILT tabs are idle. " + + "If this shard runs ACECustom under another name, tick 'Treat this world as ILT' and press Refresh."); + } + else if (o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue) + { + ImGui.TextWrapped("Checking which ILT features this server has enabled..."); + } + else + { + ImGui.TextWrapped("The server did not report any ILT features as enabled. Press Refresh to check again."); + } + } + + // ── RynthAi's Mini Remote: the Remote tab's Bank section ──────────────── + + private void RenderRemoteBank() + { + var b = _ctx.State.Bank; + if (b.LastUpdated == DateTime.MinValue) { ImGui.TextDisabled("Bank: not loaded (Options > Banking)"); return; } + Stat("P:", Compact(b.Pyreals)); + Stat("Lum:", Compact(b.Luminance)); + if (!ImGui.BeginTable("##mrbank", 2, ImGuiTableFlags.SizingStretchSame)) return; + ImGui.TableNextColumn(); Stat("LK:", Compact(b.LegendaryKeys)); + ImGui.TableNextColumn(); Stat("MK:", Compact(b.MythicalKeys)); + ImGui.TableNextColumn(); Stat("EC:", Compact(b.EnlightenedCoins)); + ImGui.TableNextColumn(); Stat("WE:", Compact(b.WeaklyEnlightenedCoins)); + // Prestige Coins (ACECustom 2026-10-04): only once the server has reported some. + if (b.PrestigeCoins > 0) { ImGui.TableNextColumn(); Stat("PC:", Compact(b.PrestigeCoins)); } + ImGui.EndTable(); + } + + private static void Stat(string label, string value) + { + ImGui.TextColored(ColLabel, label); + ImGui.SameLine(); + ImGui.TextUnformatted(value); + } + + /// The Mini Remote's compact numbers (RynthAi's HudDraw.Compact): 12.3k, 4.5m, 1.2b. + private static string Compact(double v) + { + double a = Math.Abs(v); + if (a >= 1e9) return (v / 1e9).ToString("0.0") + "b"; + if (a >= 1e6) return (v / 1e6).ToString("0.0") + "m"; + if (a >= 1e4) return (v / 1e3).ToString("0.0") + "k"; + return v.ToString("0"); + } + + // ── RynthAi's Mini Remote menu: the Infinite Leaftide section ────────── + + /// + /// Under the Infinite Leaftide section while no ILT feature is on: why, this character's + /// "Treat this world as ILT" override and a server-features refresh. False when features are on. + /// + private bool RenderIltStatus() + { + if (_hub.Available) return false; + var o = _ctx.Options; + ImGui.TextDisabled(!o.IsIltLikeWorld ? "Not an ILT world." + : o.IsRefreshing || o.LastRefreshUtc == DateTime.MinValue ? "Checking server features..." + : "No ILT features reported."); + bool force = _hub.ForceIltWorld; + if (ImGui.Checkbox("Treat this world as ILT##mrforce", ref force)) _hub.ForceIltWorld = force; + if (ImGui.IsItemHovered()) + ImGui.SetTooltip("World-identity override only: RynthILT asks the server which features exist.\nIt never turns a feature on by itself."); + if (ImGui.MenuItem("Refresh server features##mrrefresh")) _hub.RequestOptionsRefresh(); + return true; + } + + /// + /// RynthILT's own Infinite Leaftide entries, for when RynthCore sends no server list (older + /// RynthCore, or its ImGui layer off): the tabs, and the Guardian / Bounties panels. + /// + private bool RenderLocalMenu() + { + if (!_hub.OffersTabs) return false; + ImGui.Separator(); + ImGui.TextDisabled("Server: Infinite Leaftide"); + foreach (IltSection section in IltSections.Tabs) + { + if (ImGui.MenuItem(IltSections.Label(section) + "##mrlocal", string.Empty, false, _hub.SectionAvailable(section))) + _ctx.Ai.MiniRemoteTab(IltSections.TabId(section), "show"); + } + if (ImGui.MenuItem("Guardian##mrlocal", "/rc guardian", false, _hub.SectionAvailable(IltSection.Guardian))) + _ctx.Post(() => _hub.OpenEnginePanel("guardian", "Guardian", "show")); + if (ImGui.MenuItem("Bounties##mrlocal", "/rc bounties")) + _ctx.Post(() => _hub.OpenEnginePanel("bounties", "Bounties", "show")); + RenderIltStatus(); + return true; + } + + // ── Confirmation modal ────────────────────────────────────────────────── + + private void RenderConfirm() + { + if (_confirm == null) + { + if (!_ctx.TryTakeConfirm(out var next)) return; + _confirm = next; + _confirmOpened = false; + } + if (!_confirmOpened) + { + ImGui.OpenPopup(ConfirmPopupId); + _confirmOpened = true; + } + + ImGui.SetNextWindowSize(new Vector2(420, 0), ImGuiCond.Appearing); + bool keepOpen = true; + if (ImGui.BeginPopupModal(ConfirmPopupId, ref keepOpen, ImGuiWindowFlags.AlwaysAutoResize)) + { + ImGui.TextColored(IltStyle.ColAmber, _confirm.Title); + ImGui.Separator(); + ImGui.TextWrapped(_confirm.Message); + ImGui.Spacing(); + if (ImGui.Button(_confirm.YesLabel + "##iltyes", new Vector2(120, 0))) + { + var act = _confirm.OnYes; + if (act != null) _ctx.Post(act); + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.SameLine(); + if (ImGui.Button("Cancel##iltno", new Vector2(120, 0))) + { + _confirm = null; + ImGui.CloseCurrentPopup(); + } + ImGui.EndPopup(); + } + else + { + // Closed with the title-bar X (or never opened): treat as cancel. + _confirm = null; + } + if (!keepOpen) _confirm = null; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltInventory.cs similarity index 95% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltInventory.cs index ac77994..9b1874d 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltInventory.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltInventory.cs @@ -1,4 +1,6 @@ // IltInventory.cs — Shared item / player-property helper for every ILT Hub feature. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. Items come +// from RynthILT's host-backed IltObjects instead of RynthAi's WorldObjectCache. // // One place for: WCID lookups (cached — the engine call is cheap but not free), stack // counting, "is it equipped", appraisal requests (throttled), charm ON/OFF status from the @@ -11,7 +13,7 @@ using System.Linq; using RynthCore.Loot; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// /// Registered ACECustom charm (CharmAbilityRegistry): display name, every known WCID (base + @@ -102,21 +104,23 @@ internal sealed class IltInventory }; private readonly RynthCoreHost _host; - private readonly Func _cache; + private readonly IltObjects _cache; + /// AC's CM_Combat value for peace mode (RynthAi's CombatMode.NonCombat). + private const int CombatModeNonCombat = 1; private readonly Dictionary _wcidCache = new(); private readonly Dictionary _lastIdRequest = new(); /// Don't re-request appraisal for the same object more often than this. private const long IdRequestThrottleMs = 30_000; - public IltInventory(RynthCoreHost host, Func cache) + public IltInventory(RynthCoreHost host, IltObjects cache) { _host = host; _cache = cache; } public RynthCoreHost Host => _host; - public WorldObjectCache? Cache => _cache(); + public IltObjects Cache => _cache; public uint PlayerId => _host.GetPlayerId(); // ── Player state ──────────────────────────────────────────────────────── @@ -125,7 +129,7 @@ internal sealed class IltInventory public bool IsBusy => _host.HasGetBusyState && _host.GetBusyState() != 0; /// Player is in peace mode (combat mode NonCombat). True when the engine can't tell. - public bool InPeaceMode => !_host.HasGetCurrentCombatMode || _host.GetCurrentCombatMode() == CombatMode.NonCombat; + public bool InPeaceMode => !_host.HasGetCurrentCombatMode || _host.GetCurrentCombatMode() == CombatModeNonCombat; public int PlayerInt(uint stype, int fallback = 0) => _host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(PlayerId, stype, out int v) ? v : fallback; @@ -147,7 +151,7 @@ internal sealed class IltInventory // ── Item facts ────────────────────────────────────────────────────────── /// All items the player carries or wears (snapshot). - public IEnumerable Items() => _cache()?.GetInventory() ?? Enumerable.Empty(); + public IEnumerable Items() => _cache.GetInventory(); /// Weenie class id, cached per object (0 when unknown). public uint Wcid(WorldObject wo) @@ -225,10 +229,9 @@ internal sealed class IltInventory /// Free main-pack slots (best effort: capacity minus direct children; -1 when unknown). public int FreeMainPackSlots() { - var cache = _cache(); - if (cache == null) return -1; + var cache = _cache; int player = unchecked((int)PlayerId); - int capacity = PlayerInt((uint)LongValueKey.ItemsCapacity, 102); + int capacity = PlayerInt(IltObjects.IntItemsCapacity, 102); int used = cache.GetDirectInventory() .Count(wo => wo.Container == player && wo.WieldedLocation <= 0 && wo.ObjectClass != AcObjectClass.Container); return Math.Max(0, capacity - used); @@ -311,5 +314,6 @@ internal sealed class IltInventory { _wcidCache.Clear(); _lastIdRequest.Clear(); + _cache.Clear(); } } diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltLog.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltLog.cs new file mode 100644 index 0000000..4d01937 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltLog.cs @@ -0,0 +1,193 @@ +// IltLog.cs - RynthILT's diagnostics log: the ILT features' trace categories and key events, +// written to %APPDATA%\RynthCore\RynthILT\Logs\RynthILT_yyyy-MM-dd.txt. +// +// The ILT Hub logged through RynthAi's RynthLog (LogCat.Ilt*, LogEvents.Ilt*) while it lived in +// RynthAi; the moved code keeps the same calls (RynthLog.Write / Trace / Exception / Event), so +// this is a small RynthLog of RynthILT's own: +// Write file (always) and the engine log +// Trace file, only while that category is traced ("/ilt trace on|off") +// Exception file and the engine log, always +// Event as Write for the key events (login, options refreshed, ...); trace-only events +// as Trace +// "/ilt debug on" echoes trace and exception lines to chat (local only). Lines are queued on any +// thread and written by Pump() on the plugin pump. +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Text; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthILT; + +/// One trace category per ILT feature (the names RynthAi's ILT Hub used). +internal enum LogCat +{ + IltHub, + IltOptions, + IltChat, + IltStore, + IltBanking, + IltPets, + IltQuests, + IltProgression, + IltRates, + IltGear, + IltGames, +} + +/// Named key events (the ILT Hub's catalogue in RynthAi's RynthLog). +internal static class LogEvents +{ + public const string IltLogin = "IltHub.Login"; + public const string IltWorldCheck = "IltHub.WorldCheck"; + public const string IltOptionsRefreshStart = "IltHub.OptionsRefreshStart"; + public const string IltOptionsRefreshed = "IltHub.OptionsRefreshed"; + public const string IltWindowShown = "IltHub.WindowShown"; + public const string IltWindowHidden = "IltHub.WindowHidden"; + public const string IltCommand = "IltHub.Command"; + public const string IltConfirmation = "IltHub.Confirmation"; + public const string IltLogout = "IltHub.Logout"; + + /// Events written as a normal log line; the rest only while their category is traced. + internal static readonly Dictionary Catalog = new(StringComparer.Ordinal) + { + [IltLogin] = (LogCat.IltHub, true), + [IltWorldCheck] = (LogCat.IltOptions, true), + [IltOptionsRefreshStart] = (LogCat.IltOptions, false), + [IltOptionsRefreshed] = (LogCat.IltOptions, true), + [IltWindowShown] = (LogCat.IltHub, true), + [IltWindowHidden] = (LogCat.IltHub, false), + [IltCommand] = (LogCat.IltHub, false), + [IltConfirmation] = (LogCat.IltHub, false), + [IltLogout] = (LogCat.IltHub, false), + }; +} + +internal static class RynthLog +{ + private static readonly ConcurrentQueue Pending = new(); + private static readonly ConcurrentQueue PendingChat = new(); + private static readonly bool[] Traced = new bool[Enum.GetValues().Length]; + private static RynthCoreHost _host; + private static bool _hasHost; + private static string _directory = string.Empty; + + /// Echo trace and exception lines to the chat window ("/ilt debug on"). + public static volatile bool DebugToChat; + + /// Where the daily files go (tests point it at a scratch folder). + public static string Directory => _directory; + + public static void Init(RynthCoreHost host, string? directory = null) + { + _host = host; + _hasHost = true; + _directory = directory ?? Path.Combine(RynthILTPlugin.SettingsRoot, "Logs"); + } + + /// Drops the host (plugin shutdown): nothing is written to it afterwards. + public static void Shutdown() + { + Pump(); + _hasHost = false; + } + + public static void Write(LogCat cat, string message) + { + Enqueue(cat, message); + HostLog(message); + } + + public static void Trace(LogCat cat, string message) + { + if (!IsTracing(cat)) return; + Enqueue(cat, message); + if (DebugToChat) Chat($"[RynthILT {cat}] {message}"); + } + + public static void Exception(LogCat cat, Exception ex, string context = "") + { + string line = $"EXCEPTION {(context.Length > 0 ? context + ": " : "")}{ex.GetType().Name}: {ex.Message}"; + Enqueue(cat, line + Environment.NewLine + ex.StackTrace); + HostLog(line); + if (DebugToChat) Chat($"[RynthILT {cat}] {line}"); + } + + public static void Event(string eventKey, string message) + { + if (!LogEvents.Catalog.TryGetValue(eventKey, out var e)) { Write(LogCat.IltHub, $"[{eventKey}] {message}"); return; } + if (e.Info) Write(e.Cat, $"[{eventKey}] {message}"); + else Trace(e.Cat, $"[{eventKey}] {message}"); + } + + /// True when would record the event (an Info event, or a traced Trace one). + public static bool IsEventEnabled(string eventKey) + => !LogEvents.Catalog.TryGetValue(eventKey, out var e) || e.Info || IsTracing(e.Cat); + + public static bool IsTracing(LogCat cat) => (int)cat >= 0 && (int)cat < Traced.Length && Traced[(int)cat]; + + public static void SetTracing(LogCat cat, bool on) + { + if ((int)cat >= 0 && (int)cat < Traced.Length) Traced[(int)cat] = on; + } + + /// Every category on or off; returns how many. + public static int SetTracingAll(bool on) + { + for (int i = 0; i < Traced.Length; i++) Traced[i] = on; + return Traced.Length; + } + + public static bool TryParseCategory(string name, out LogCat cat) + { + if (Enum.TryParse(name, ignoreCase: true, out cat)) return true; + return Enum.TryParse("Ilt" + name, ignoreCase: true, out cat); + } + + public static string TracedList() + { + var on = new List(); + foreach (LogCat c in Enum.GetValues()) if (IsTracing(c)) on.Add(c.ToString()); + return on.Count == 0 ? "none" : string.Join(", ", on); + } + + /// Writes the queued lines (plugin pump). + public static void Pump() + { + int lines = 0; + while (lines++ < 20 && PendingChat.TryDequeue(out string? chat)) + { + if (!_hasHost) continue; + try { if (_host.HasWriteToChat) _host.WriteToChat(chat, 1); } catch { } + } + if (Pending.IsEmpty || _directory.Length == 0) return; + var sb = new StringBuilder(); + int n = 0; + while (n++ < 2000 && Pending.TryDequeue(out string? line)) sb.Append(line).Append(Environment.NewLine); + try + { + System.IO.Directory.CreateDirectory(_directory); + File.AppendAllText(Path.Combine(_directory, $"RynthILT_{DateTime.Now:yyyy-MM-dd}.txt"), sb.ToString()); + } + catch { /* a log that can't be written must never break a feature */ } + } + + private static void Enqueue(LogCat cat, string message) + { + if (Pending.Count > 20000) return; // nothing is draining (no pump): don't grow forever + Pending.Enqueue($"{DateTime.Now:HH:mm:ss.fff} [{cat}] {message}"); + } + + private static void HostLog(string message) + { + if (!_hasHost) return; + try { _host.Log("[RynthILT] " + message); } catch { } + } + + /// Queued for the pump (trace lines can come from the render thread). + private static void Chat(string text) + { + if (PendingChat.Count < 200) PendingChat.Enqueue(text); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltMigration.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltMigration.cs new file mode 100644 index 0000000..636bd7a --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltMigration.cs @@ -0,0 +1,249 @@ +// IltMigration.cs - Carries the ILT Hub's saved data over from RynthAi (2026-10-13). +// +// While the ILT Hub lived in RynthAi it saved per character in RynthAi's settings folder +// (\SettingsProfiles\\\: ilt-hub.json, +// ilt-hub-transactions.json, ilt-hub-profiles\) and for every character in the RynthAi folder +// (IltHubProfiles\, ilt-aug-costs.json); the server list and the "Force enable" override were +// fields of each RynthAi profile (FeatureServerNames, ForceServerFeatures). +// +// RynthILT keeps its own files (IltHubStore, IltSettingsStore). On a character's first login +// with RynthILT (no hub.json yet) the old files are COPIED, never moved or deleted: RynthAi no +// longer reads them, and a rollback to an older RynthAi still finds them. Existing RynthILT files +// are never overwritten. The character's active RynthAi profile adds its world names to +// RynthILT's list and, when it had "Force enable" ticked, ticks this character's "Treat this world +// as ILT". The shared files are copied once (IltSettings.SharedFilesMigrated). Pump thread. +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json; +using RynthCore.Install; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthILT.Hub; + +/// The two Server Features fields of a RynthAi profile (the rest of the file is ignored). +public sealed class IltLegacyProfileFlags +{ + public List? FeatureServerNames; + public bool ForceServerFeatures; +} + +internal static class IltMigration +{ + /// RynthAi's per-server profile folders (overridable for the tests). + public static string LegacyProfilesBase = Path.Combine(RynthInstallPaths.RynthAiDir, "SettingsProfiles"); + + /// RynthAi's folder (shared profiles, aug costs; overridable for the tests). + public static string LegacySharedRoot = RynthInstallPaths.RynthAiDir; + + /// RynthAi's folder for profiles saved before they went per server. + private const string LegacyServerFolder = "ACEmulator"; + + /// RynthAi's file-name sanitizer (LegacyDashboardRenderer.SanitizeFileName). + internal static string RynthAiSafeName(string name) + { + var sb = new StringBuilder(name.Length); + foreach (char c in name) + sb.Append(char.IsLetterOrDigit(c) || c == '\'' || c == '-' ? c : '_'); + return sb.ToString(); + } + + /// RynthAi's settings folder for this character: the world's, else the pre-per-server one. Null when neither exists. + public static string? FindLegacyCharFolder(string world, string charName) + { + if (string.IsNullOrWhiteSpace(charName)) return null; + string safeChar = RynthAiSafeName(charName.Trim()); + var candidates = new List(); + if (!string.IsNullOrWhiteSpace(world)) + { + string safeWorld = RynthAiSafeName(world.Trim()); + if (safeWorld.Length > 0) candidates.Add(Path.Combine(LegacyProfilesBase, safeWorld, safeChar)); + } + candidates.Add(Path.Combine(LegacyProfilesBase, LegacyServerFolder, safeChar)); + foreach (string dir in candidates) + if (Directory.Exists(dir) && (File.Exists(Path.Combine(dir, "ilt-hub.json")) + || File.Exists(Path.Combine(dir, "ilt-hub-transactions.json")) + || Directory.Exists(Path.Combine(dir, "ilt-hub-profiles")) + || File.Exists(Path.Combine(dir, "active_profile.txt")) + || File.Exists(Path.Combine(dir, "Default.json")))) + return dir; + return null; + } + + /// Whether 's copy from RynthAi failed and hasn't been finished yet. + public static bool IsPending(IltSettings settings, string charFolder) + { + if (string.IsNullOrEmpty(charFolder)) return false; + foreach (string f in settings.PendingCharacterMigrations ?? new List()) + if (string.Equals(f, charFolder, StringComparison.OrdinalIgnoreCase)) return true; + return false; + } + + private static void SetPending(IltSettings settings, string charFolder, bool pending) + { + settings.PendingCharacterMigrations ??= new List(); + settings.PendingCharacterMigrations.RemoveAll(f => string.Equals(f, charFolder, StringComparison.OrdinalIgnoreCase)); + if (pending) settings.PendingCharacterMigrations.Add(charFolder); + } + + /// + /// First login of a character with RynthILT: copies its RynthAi ILT Hub files into + /// (only when it has no hub.json yet, or an earlier copy failed + /// part-way) and folds its RynthAi Server Features into . + /// says whether the profile had "Force enable" ticked. Returns what + /// was done (for the log), empty when nothing. When a file can't be copied the folder is marked + /// pending in (save them): the Hub then writes nothing there and the + /// next call copies what is still missing (never overwriting). + /// + public static List MigrateCharacter(string newFolder, string world, string charName, IltSettings settings, out bool forceIlt) + { + forceIlt = false; + var done = new List(); + if (string.IsNullOrEmpty(newFolder)) return done; + bool wasPending = IsPending(settings, newFolder); + if (!wasPending && File.Exists(Path.Combine(newFolder, IltHubStore.StateFile))) return done; + string? legacy = FindLegacyCharFolder(world, charName); + if (legacy == null) + { + // The RynthAi files are gone: nothing left to wait for. + if (wasPending) { SetPending(settings, newFolder, false); done.Add("the RynthAi files of an unfinished copy are gone; RynthILT's own files are used from now on"); } + return done; + } + + int failed = 0; + if (CopyIfMissing(Path.Combine(legacy, "ilt-hub.json"), Path.Combine(newFolder, IltHubStore.StateFile), ref failed)) + done.Add("ilt-hub.json"); + if (CopyIfMissing(Path.Combine(legacy, "ilt-hub-transactions.json"), Path.Combine(newFolder, IltHubStore.TransactionsFile), ref failed)) + done.Add("ilt-hub-transactions.json"); + int profiles = CopyFolder(Path.Combine(legacy, "ilt-hub-profiles"), Path.Combine(newFolder, IltHubStore.ProfilesFolder), ref failed); + if (profiles > 0) done.Add($"{profiles} Hub profile(s)"); + if (failed > 0) + { + SetPending(settings, newFolder, true); + done.Add($"{failed} file(s) NOT copied (see the lines above; the originals in {legacy} are untouched). " + + "The Hub saves nothing for this character until they are; tried again every few minutes and at each login"); + } + else if (wasPending) + { + SetPending(settings, newFolder, false); + done.Add("the earlier unfinished copy is complete"); + } + + if (ReadProfileFlags(legacy, out IltLegacyProfileFlags flags)) + { + int added = MergeServerNames(settings, flags.FeatureServerNames); + if (added > 0) done.Add($"{added} server name(s) from the RynthAi profile"); + if (flags.ForceServerFeatures) + { + forceIlt = true; + done.Add("\"Force enable\" -> Treat this world as ILT"); + } + } + return done; + } + + /// + /// Once for every character: RynthAi's shared Hub profiles and aug-cost table into + /// (never over a file RynthILT already has). Returns what was done. + /// Marked done only when every copy worked: a failed one is tried again at the next login. + /// + public static List MigrateShared(IltSettings settings, string newRoot) + { + var done = new List(); + if (settings.SharedFilesMigrated) return done; + int failed = 0; + int profiles = CopyFolder(Path.Combine(LegacySharedRoot, "IltHubProfiles"), Path.Combine(newRoot, "Profiles"), ref failed); + if (profiles > 0) done.Add($"{profiles} shared Hub profile(s)"); + if (CopyIfMissing(Path.Combine(LegacySharedRoot, "ilt-aug-costs.json"), Path.Combine(newRoot, "ilt-aug-costs.json"), ref failed)) + done.Add("ilt-aug-costs.json"); + if (failed == 0) settings.SharedFilesMigrated = true; + else done.Add($"{failed} shared file(s) NOT copied; tried again at the next login"); + return done; + } + + /// The character's active RynthAi profile's Server Features fields. + internal static bool ReadProfileFlags(string legacyCharFolder, out IltLegacyProfileFlags flags) + { + flags = new IltLegacyProfileFlags(); + try + { + string active = "Default"; + string marker = Path.Combine(legacyCharFolder, "active_profile.txt"); + if (File.Exists(marker)) + { + string name = File.ReadAllText(marker).Trim(); + if (name.Length > 0) active = name; + } + string path = Path.Combine(legacyCharFolder, active + ".json"); + if (!File.Exists(path)) return false; + var f = JsonSerializer.Deserialize(File.ReadAllText(path), IltHubJsonContext.Default.IltLegacyProfileFlags); + if (f == null) return false; + flags = f; + return true; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltStore, ex, "migration: RynthAi profile read"); + return false; + } + } + + /// Adds the names the list doesn't have yet (case-insensitive); returns how many. + internal static int MergeServerNames(IltSettings settings, IEnumerable? names) + { + if (names == null) return 0; + int added = 0; + foreach (string n in ServerFeatureGate.ParseList(string.Join(",", names))) + { + if (settings.ServerNames.Any(have => have.Equals(n, StringComparison.OrdinalIgnoreCase))) continue; + settings.ServerNames.Add(n); + added++; + } + return added; + } + + /// + /// Copies to unless the source is missing or the + /// target exists. A failed copy is never silent: it is logged and said in chat once per folder + /// (DataWriteGuard, on ILT), with the reason and the fix and where the original still is, and + /// counted in . + /// + private static bool CopyIfMissing(string from, string to, ref int failed) + { + try + { + if (!File.Exists(from) || File.Exists(to)) return false; + } + catch { return false; } + string fromDir = Path.GetDirectoryName(from) ?? from; + bool ok = DataWriteGuard.TrySave($"{Path.GetFileName(from)} carried over from RynthAi (the original is still in {fromDir})", to, () => + { + Directory.CreateDirectory(Path.GetDirectoryName(to)!); + File.Copy(from, to); + }); + if (!ok) failed++; + return ok; + } + + private static int CopyFolder(string from, string to, ref int failed) + { + int n = 0; + string[] files; + try + { + if (!Directory.Exists(from)) return 0; + files = Directory.GetFiles(from, "*.json"); + } + catch (Exception ex) + { + failed++; + RynthLog.Exception(LogCat.IltStore, ex, $"migration: list {from}"); + return 0; + } + foreach (string f in files) + if (CopyIfMissing(f, Path.Combine(to, Path.GetFileName(f)), ref failed)) n++; + return n; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltParse.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltParse.cs index fcc90e5..f0a7c00 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltParse.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltParse.cs @@ -1,4 +1,5 @@ // IltParse.cs — Shared parsing / formatting helpers for ILT Hub server output. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Centralised so every feature uses the same number parsing (commas, k/m/b/t suffixes), // the same compact K/M/B display, and the same regexes. Regexes are static and built once; @@ -7,7 +8,7 @@ using System; using System.Globalization; using System.Text.RegularExpressions; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal static class IltParse { diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltPetLogs.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltPetLogs.cs new file mode 100644 index 0000000..55b456b --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltPetLogs.cs @@ -0,0 +1,85 @@ +// IltPetLogs.cs — The ACECustom /pets and /shinies logs, shown in RynthAi's universal Pets tab +// (RynthILT.Hub section "pets-logs"). +// Originally the roster-capture part of SilentKelpie's IltPets (ILT Hub, RynthAi); split out and +// moved to RynthILT 2026-10-13. The Pets tab itself (essence roster, combat / healing / cosmetic +// pets, the refill charm path) stayed in RynthAi (MiniRemote/PetsTab.cs): summoning is every +// server's, these two commands are ACECustom's. +using System; +using System.Collections.Generic; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthILT.Hub; + +internal sealed class IltPetLogs : IIltFeature +{ + private readonly IltHubContext _ctx; + + public IltPetLogs(IltHubContext ctx) => _ctx = ctx; + + private IltPetState S => _ctx.State.Pet; + + /// Captures /pets or /shinies into the state (quiet). + public void RequestRoster(bool shinies) + { + RynthLog.Trace(LogCat.IltPets, $"RequestRoster(shinies={shinies})"); + string cmd = shinies ? "/shinies" : "/pets"; + if (_ctx.Capture.IsPending(cmd)) return; + string header = shinies ? "Your Shiny Log" : "Your Pet Log"; + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = cmd, + IsResponseLine = t => t.Contains(header, StringComparison.OrdinalIgnoreCase) || IltParse.RosterLine.IsMatch(t), + IsTerminator = t => t.Contains(header + " is empty", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 1500, + FirstLineTimeoutMs = 10000, + Eat = true, + OnComplete = r => + { + if (r.UnknownCommand) { _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.Off); return; } + if (r.Lines.Count == 0) return; + _ctx.Options.Set(shinies ? IltFeature.Shinies : IltFeature.Pets, IltTri.On); + ApplyRoster(shinies, r.Lines); + }, + }); + } + + /// Also used by the login probe tap so the roster fills without a second command. + public void ApplyRoster(bool shinies, List lines) + { + RynthLog.Trace(LogCat.IltPets, $"ApplyRoster(shinies={shinies}, lines={lines.Count})"); + var list = new List(); + foreach (string l in lines) + { + var m = IltParse.RosterLine.Match(l); + if (m.Success) list.Add(m.Groups[2].Value.Trim()); + } + if (shinies) S.ShinyLog = list; else S.PetLog = list; + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) { } + public bool OnChat(string text) => false; + public void OnLogout() { } + + // ── UI (render thread): the Pets tab's last section ───────────────────── + + public void RenderSection() + { + ImGui.Separator(); + RenderRoster("Pet log", false, IltFeature.Pets, S.PetLog); + RenderRoster("Shiny log", true, IltFeature.Shinies, S.ShinyLog); + } + + private void RenderRoster(string label, bool shinies, string key, List list) + { + if (_ctx.Options.IsOff(key)) return; + var snap = list.ToArray(); + if (ImGui.TreeNode($"{label} ({snap.Length})##{key}")) + { + if (ImGui.SmallButton($"Refresh##{key}")) _ctx.Post(() => RequestRoster(shinies)); + foreach (string s in snap) ImGui.BulletText(s); + ImGui.TreePop(); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltProgression.cs similarity index 99% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltProgression.cs index 11b11f5..7e45198 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltProgression.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltProgression.cs @@ -1,4 +1,5 @@ // IltProgression.cs — Augmentation and Enlightenment planners, drawn by the engine's +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // Skills panel (Progression tab) from AppendSnapshotJson; edits arrive via HandleRemote. // // Augs : "/aug" levels + the per-server cost rules in IltAugCosts (UB's ILT model by default: @@ -15,7 +16,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltProgression : IIltFeature { @@ -697,14 +698,14 @@ internal sealed class IltProgression : IIltFeature private static void Str(StringBuilder sb, string name, string value, bool first = false) { if (!first) sb.Append(','); - sb.Append('"').Append(name).Append("\":\"").Append(RynthAiPlugin.JsonEscape(value ?? string.Empty)).Append('"'); + sb.Append('"').Append(name).Append("\":\"").Append(IltStyle.JsonEscape(value ?? string.Empty)).Append('"'); } private static void StrItem(StringBuilder sb, string value, ref bool first) { if (!first) sb.Append(','); first = false; - sb.Append('"').Append(RynthAiPlugin.JsonEscape(value)).Append('"'); + sb.Append('"').Append(IltStyle.JsonEscape(value)).Append('"'); } /// diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltQuestBonus.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltQuestBonus.cs new file mode 100644 index 0000000..38203d9 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltQuestBonus.cs @@ -0,0 +1,202 @@ +// IltQuestBonus.cs — The ACECustom quest bonus list ("/qb list"), shown in RynthAi's universal +// Quests tab (RynthILT.Hub section "quests-qb") and read by the Temple attribute tracker. +// Originally the /qb half of SilentKelpie's IltQuests (ILT Hub, RynthAi); split out and moved to +// RynthILT 2026-10-13. The /myquests tracker half stayed in RynthAi (MiniRemote/QuestsTab.cs): +// /myquests is every server's, /qb is ACECustom's. +// +// "/qb list" prints a completed and an incomplete section; both are tracked separately (UB +// merged them). Server throttles /qb to once per minute. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text.RegularExpressions; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthILT.Hub; + +internal sealed class IltQuestBonus : IIltFeature +{ + private static readonly Regex KillTaskRegex = new(@"(killtask|killcount|slayerquest|totalgolem.*dead|(kills$))", + RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + private static readonly Regex QbFlagLine = new(@"^[a-zA-Z0-9_\-!@\(\)?]+$", RegexOptions.Compiled | RegexOptions.CultureInvariant); + + private const long QbCooldownMs = 60_000; + + private readonly IltHubContext _ctx; + private long _lastQbAt = -QbCooldownMs; + + // QB results (replaced wholesale; read by the render thread). + private volatile string[] _qbCompleted = Array.Empty(); + private volatile string[] _qbIncomplete = Array.Empty(); + private volatile string _qbStatus = "not loaded"; + private long _qbCount = -1; + private volatile int _qbGeneration; // bumped per successful "/qb list"; 0 = never loaded this session + + public IltQuestBonus(IltHubContext ctx) => _ctx = ctx; + + /// The /myquests flag kinds (RynthAi's QuestsTab.Classify, which the Temple tracker reads by). + public enum QuestKind { Timed, KillTask, Once } + + public static QuestKind Classify(QuestRecord r) + { + if (KillTaskRegex.IsMatch(r.Key) && r.MaxSolves >= 0) return QuestKind.KillTask; + if (r.MaxSolves == 1 && r.Solves <= 1) return QuestKind.Once; + return QuestKind.Timed; + } + + /// Captures "/qb list" (quiet). + public string RefreshQb() + { + RynthLog.Trace(LogCat.IltQuests, $"RefreshQb()"); + if (_ctx.Options.IsOff(IltFeature.Qb)) return "/qb is disabled on this server."; + long now = IltHubContext.NowMs; + if (now - _lastQbAt < QbCooldownMs) + return $"Wait {(QbCooldownMs - (now - _lastQbAt)) / 1000}s (server allows one /qb per minute)."; + if (_ctx.Capture.IsPending("/qb list")) return "Already loading..."; + _lastQbAt = now; + _qbStatus = "loading..."; + + _ctx.Capture.Enqueue(new IltChatRequest + { + Command = "/qb list", + IsResponseLine = IsQbLine, + IsTerminator = t => t.Contains("Quest bonus list is empty", StringComparison.OrdinalIgnoreCase) + || t.Contains("\"qb\" is not currently enabled", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("[QB] This command may only be run once every", StringComparison.OrdinalIgnoreCase), + IdleEndMs = 5000, + FirstLineTimeoutMs = 30000, + Eat = true, + OnComplete = OnQbResult, + }); + return "Loading quest bonus list..."; + } + + private static bool IsQbLine(string t) + { + if (t.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase) + || t.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + return true; + if (!QbFlagLine.IsMatch(t)) return false; + if (t.StartsWith("You ", StringComparison.Ordinal) || t.StartsWith("The ", StringComparison.Ordinal)) return false; + return !(t.Contains("You have", StringComparison.OrdinalIgnoreCase) || t.Contains("command", StringComparison.OrdinalIgnoreCase) + || t.Contains("enabled", StringComparison.OrdinalIgnoreCase) || t.Contains("list", StringComparison.OrdinalIgnoreCase)); + } + + private void OnQbResult(IltChatResult r) + { + if (r.UnknownCommand) { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb not available"; return; } + if (r.TerminatorLine != null) + { + if (r.TerminatorLine.Contains("not currently enabled", StringComparison.OrdinalIgnoreCase)) + { _ctx.Options.Set(IltFeature.Qb, IltTri.Off); _qbStatus = "/qb is disabled on this server"; return; } + if (r.TerminatorLine.Contains("only be run once", StringComparison.OrdinalIgnoreCase)) + { _qbStatus = "rate limited by the server"; return; } + } + if (r.TimedOut) { _qbStatus = "no reply from server"; return; } + _ctx.Options.Set(IltFeature.Qb, IltTri.On); + + var done = new List(); + var todo = new List(); + List? current = null; + foreach (string line in r.Lines) + { + if (line.StartsWith("Your completed quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = done; continue; } + if (line.StartsWith("Your incomplete quest bonus list", StringComparison.OrdinalIgnoreCase)) { current = todo; continue; } + if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + { + int colon = line.IndexOf(':'); + if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); + continue; + } + if (line.Contains("is empty", StringComparison.OrdinalIgnoreCase)) continue; + (current ?? done).Add(line.Trim()); + } + done.Sort(StringComparer.OrdinalIgnoreCase); + todo.Sort(StringComparer.OrdinalIgnoreCase); + _qbCompleted = done.ToArray(); + _qbIncomplete = todo.ToArray(); + _qbStatus = $"{done.Count} completed, {todo.Count} incomplete"; + _qbGeneration++; + } + + /// Increments each time a "/qb list" reply is parsed (0 = not loaded this session). + public int QbGeneration => _qbGeneration; + + /// True when the last "/qb list" (completed or incomplete) contains the flag. + public bool QbHasFlag(string flag) + { + if (string.IsNullOrWhiteSpace(flag)) return false; + foreach (string f in _qbCompleted) + if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; + foreach (string f in _qbIncomplete) + if (f.Equals(flag, StringComparison.OrdinalIgnoreCase)) return true; + return false; + } + + /// Login probe tap: "/qb" (no args) prints the count line. + public void ApplyQbProbe(List lines) + { + RynthLog.Trace(LogCat.IltQuests, $"ApplyQbProbe(lines={lines.Count})"); + foreach (string line in lines) + if (line.StartsWith("Your current quest bonus count", StringComparison.OrdinalIgnoreCase)) + { + int colon = line.IndexOf(':'); + if (colon > 0) _qbCount = IltParse.ParseLeadingLong(line.Substring(colon + 1)); + } + } + + // ── IIltFeature ───────────────────────────────────────────────────────── + + public void Tick(long nowMs) { } + public bool OnChat(string text) => false; + public void OnLogout() + { + _qbCompleted = Array.Empty(); + _qbIncomplete = Array.Empty(); + _qbCount = -1; + _qbStatus = "not loaded"; + _qbGeneration = 0; + } + + // ── UI (render thread) ────────────────────────────────────────────────── + + /// The Quests tab's "Quest bonus (/qb)" section (collapsed header; ILT worlds only). + public void RenderSection() + { + if (ImGui.CollapsingHeader("Quest bonus (/qb)##qbwin")) RenderQb(); + } + + public void RenderQb() + { + if (_ctx.Options.IsOff(IltFeature.Qb)) + { + ImGui.TextColored(IltStyle.ColTextMute, "/qb is disabled on this server."); + return; + } + if (ImGui.SmallButton("Load /qb list")) _ctx.Post(() => _ctx.Chat("[Mini Remote] " + RefreshQb())); + ImGui.SameLine(); + long count = _qbCount; + ImGui.TextDisabled((count >= 0 ? $"QB count {IltParse.N0(count)} - " : "") + _qbStatus); + + string filter = _ctx.State.Character.QbFilter; + ImGui.SetNextItemWidth(220); + if (ImGui.InputTextWithHint("##qbfilter", "filter flags", ref filter, 64u)) + _ctx.State.Character.QbFilter = filter; + + RenderQbList("Incomplete", _qbIncomplete, filter, IltStyle.ColAmber); + RenderQbList("Completed", _qbCompleted, filter, IltStyle.ColGreen); + } + + private static void RenderQbList(string label, string[] items, string filter, Vector4 color) + { + var shown = filter.Length == 0 ? items : items.Where(i => i.Contains(filter, StringComparison.OrdinalIgnoreCase)).ToArray(); + if (ImGui.TreeNode($"{label} ({shown.Length})##qb{label}")) + { + if (ImGui.SmallButton($"Copy##qbc{label}")) ImGui.SetClipboardText(string.Join(Environment.NewLine, shown)); + foreach (string s in shown) ImGui.TextColored(color, s); + ImGui.TreePop(); + } + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSections.cs similarity index 56% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltSections.cs index eb5ea46..9a00675 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSections.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSections.cs @@ -1,54 +1,44 @@ -// IltSections.cs - The Mini Remote's tabs and the Guardian panel. Quests and Pets are universal -// tabs (every server: /myquests and summoning essences aren't ILT's); Character, Banking, Gear, -// Charms and Games are Infinite Leaftide tabs. All are picked from the Mini Remote's tab bar (MiniRemoteHud) -// or "/ra hub open
". Guardian is ILT only and a RynthCore ILT panel instead (the bar's -// ILT button, next to Bounties; "/rc guardian"), drawn by this plugin through -// RynthPluginRenderEmbed("guardian"). +// IltSections.cs - The Infinite Leaftide tabs of RynthAi's Mini Remote and the Guardian panel. +// Originally SilentKelpie's ILT Hub sections (RynthAi IltHub/); moved to RynthILT 2026-10-13. +// +// Character, Banking, Gear, Charms and Games are Mini Remote tabs: RynthAi's MiniRemoteHud draws +// the tab bar (after its Remote, Quests and Pets tabs) and asks RynthILT for each tab's body +// (RynthILT.Hub GetTabs / RenderTab); "/ra hub open
" picks one. Guardian is a RynthCore +// ILT panel instead (the bar's ILT button, next to Bounties; "/rc guardian"), drawn by this +// plugin through RynthPluginRenderEmbed("guardian"). The Quests and Pets tabs are RynthAi's +// (every server: /myquests and summoning essences aren't ILT's). using System; +using System.Numerics; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; -/// ILT sections: the Mini Remote's tabs, then the Guardian panel. +/// ILT sections: the Mini Remote's ILT tabs, then the Guardian panel. internal enum IltSection { Character, - Quests, - Pet, Banking, Gear, Games, /// Registry charms (acquired / status / tier / server) and the Guardian Hand. Charms, - // Keep Guardian last: MiniRemoteHud sizes its per-tab tables by it. + // Keep Guardian last. Guardian, } internal static class IltSections { - /// - /// The Mini Remote's tabs, in tab-bar order (after its own Remote tab): the universal ones - /// first, then the Infinite Leaftide ones. - /// + /// The ILT tabs, in tab-bar order (RynthAi puts them after its own tabs). public static readonly IltSection[] Tabs = { - IltSection.Quests, IltSection.Pet, IltSection.Character, IltSection.Banking, IltSection.Gear, IltSection.Charms, IltSection.Games, }; - /// - /// True for the tabs every server gets (Quests, Pets); the rest are Infinite Leaftide's and - /// show only on an ILT world (or with the Force-ILT override). - /// - public static bool IsUniversal(IltSection s) => s is IltSection.Quests or IltSection.Pet; - /// The Mini Remote's own tab (the remote itself): its tab id. public const string RemoteTab = ""; public static string Label(IltSection s) => s switch { IltSection.Character => "Character", - IltSection.Quests => "Quests", - IltSection.Pet => "Pets", IltSection.Banking => "Banking", IltSection.Gear => "Gear", IltSection.Games => "Games", @@ -58,14 +48,12 @@ internal static class IltSections }; /// - /// The section's tab id: saved as HudState.MiniRemoteTab and sent by the engine's dashboard - /// ("/ra hub tab <id>"). TryParse reads it back. + /// The section's tab id: saved as RynthAi's HudState.MiniRemoteTab and sent by the engine's + /// dashboard ("/ra hub tab <id>", "/rc miniremote tab <id>"). TryParse reads it back. /// public static string TabId(IltSection s) => s switch { IltSection.Character => "character", - IltSection.Quests => "quests", - IltSection.Pet => "pets", IltSection.Banking => "banking", IltSection.Gear => "gear", IltSection.Games => "games", @@ -77,14 +65,19 @@ internal static class IltSections /// True for the sections drawn as Mini Remote tabs (all but the Guardian panel). public static bool IsTab(IltSection s) => s != IltSection.Guardian; + /// "quests" / "pets" (and their aliases): RynthAi's universal tabs, not ILT sections. + public static bool IsUniversalTabName(string text) => (text ?? string.Empty).Trim().ToLowerInvariant() switch + { + "quests" or "quest" or "pets" or "pet" => true, + _ => false, + }; + /// Parses a "/ra hub open" section name (a few aliases accepted). public static bool TryParse(string text, out IltSection section) { switch ((text ?? string.Empty).Trim().ToLowerInvariant()) { case "character": case "char": case "rates": section = IltSection.Character; return true; - case "quests": case "quest": section = IltSection.Quests; return true; - case "pets": case "pet": section = IltSection.Pet; return true; case "banking": case "bank": section = IltSection.Banking; return true; case "gear": section = IltSection.Gear; return true; case "games": case "game": section = IltSection.Games; return true; @@ -94,6 +87,20 @@ internal static class IltSections } } + /// + /// Size of a Mini Remote tab's body (the old section window's default size): the tab draws in a + /// child this big, and the Mini Remote (or the engine window hosting it) fits to it. + /// + public static Vector2 TabSize(IltSection section) => section switch + { + IltSection.Character => new Vector2(520, 440), + IltSection.Banking => new Vector2(560, 520), + IltSection.Gear => new Vector2(560, 520), + IltSection.Charms => new Vector2(560, 520), + IltSection.Games => new Vector2(520, 440), + _ => new Vector2(520, 440), + }; + /// "show" / "hide" / "toggle" (anything else toggles) applied to the current state. public static bool Resolve(string mode, bool current) => (mode ?? string.Empty).ToLowerInvariant() switch { diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltServerOptions.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltServerOptions.cs index 555f63f..90f4544 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltServerOptions.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltServerOptions.cs @@ -1,9 +1,10 @@ // IltServerOptions.cs — Per-feature enable bits for the ILT Hub, read from the server. +// Originally SilentKelpie's ILT Hub (RynthAi); moved to RynthILT 2026-10-13. // // UB gated every Leaftide tool on a single test (WorldName == "InfiniteLeaftide" or a // Force checkbox). That lies on shards where the operator turned Powerball, /myquests or // a charm off. This module instead keeps one tri-state bit per feature: -// * World identity: ServerFeatureGate (Settings > Misc server list, or its manual +// * World identity: ServerFeatureGate (RynthILT's server list, or this character's // override / the Hub's ForceLeaftideFeatures) decides whether we even ASK — it never // switches a feature on by itself. // * Preferred source: a structured "/ilt features" dump (ILTFEATURE key=0|1 lines) once @@ -17,10 +18,9 @@ using System; using System.Collections.Generic; using System.Linq; -using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.PluginSdk; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// Feature keys used by the gate table. internal static class IltFeature @@ -60,7 +60,7 @@ internal sealed class IltServerOptions private readonly IltChatCapture _capture; private readonly IltHubState _state; private readonly Action _chat; - private readonly Func _settings; + private readonly Func _settings; /// Feeds probe replies to features that can reuse them (e.g. /bank → Banking balances). public Action? ProbeReplyTap; @@ -81,7 +81,7 @@ internal sealed class IltServerOptions private const long WorldNameWaitMs = 60000; public IltServerOptions(RynthCoreHost host, IltChatCapture capture, IltHubState state, Action chat, - Func? settings = null) + Func? settings = null) { _host = host; _capture = capture; @@ -105,16 +105,16 @@ internal sealed class IltServerOptions /// /// True when the world is (or is declared to be) an ACECustom/ILT shard: its name is in the - /// Settings > Misc server list, or an override is on (ServerFeatureGate). + /// server list (IltSettings), or this character's override is on (ServerFeatureGate). /// public bool IsIltLikeWorld { get { if (_state.ForceLeaftideFeatures) return true; - LegacyUiSettings? s; + IltSettings? s; try { s = _settings(); } catch { s = null; } - return ServerFeatureGate.IsEnabled(WorldName, s); + return ServerFeatureGate.IsEnabled(WorldName, s, _state.ForceLeaftideFeatures); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSessionRates.cs similarity index 87% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltSessionRates.cs index 820e997..3dff383 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSessionRates.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSessionRates.cs @@ -1,10 +1,12 @@ // IltSessionRates.cs — Session earnings / per-hour rates for the ILT Hub Character tab. +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // Sources (all passive — nothing is sent to the server except the optional bank refresh // the Banking tab already does): -// XP, luminance (total, last 5 min, allegiance pass-up) and kills: the Mini Remote's -// SessionStatsTracker — RynthTracker's SessionStats code (Plugins\Shared), so this +// XP, luminance (total, last 5 min, allegiance pass-up) and kills: RynthAi's Mini Remote +// session stats (RynthAi.Hub SessionStats) — RynthTracker's SessionStats code, so this // table, the Mini Remote and the Tracker panel count them the same way (2026-10-11). +// Without RynthAi those rows are left out. // Coins positive bank Enlightened Coins deltas + carried coin (WCID 300004) gains. // Pyreals positive bank pyreal deltas + carried pyreal (WCID 273) gains; MMD = 250k. // Items gains of each item in the item→coin conversion table (carried count), @@ -15,10 +17,9 @@ using System; using System.Collections.Generic; using System.Linq; using ImGuiNET; -using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.Plugin.Shared; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltSessionRates : IIltFeature { @@ -28,7 +29,6 @@ internal sealed class IltSessionRates : IIltFeature private const string PassUpLabel = " pass-up"; private readonly IltHubContext _ctx; - private readonly SessionStatsTracker? _stats; private DateTime _start = DateTime.UtcNow; private long _coins; @@ -56,11 +56,7 @@ internal sealed class IltSessionRates : IIltFeature /// When the coin / pyreal session (or the last Reset) started. public DateTime SessionStartUtc => _start; - public IltSessionRates(IltHubContext ctx, SessionStatsTracker? stats = null) - { - _ctx = ctx; - _stats = stats; - } + public IltSessionRates(IltHubContext ctx) => _ctx = ctx; /// True while money moves between pack and bank (set by the controller from Banking). Pump thread. public Func? MovingMoney { get; set; } @@ -98,7 +94,7 @@ internal sealed class IltSessionRates : IIltFeature public void ResetAll() { Reset(); - _stats?.RequestReset(); + _ctx.Ai.ResetSessionStats(); } // ── IIltFeature ───────────────────────────────────────────────────────── @@ -147,7 +143,7 @@ internal sealed class IltSessionRates : IIltFeature return d > 0 ? d : 0; } - // Luminance chat goes to the shared session stats (RynthAiPlugin.OnChatWindowText). + // Luminance chat goes to RynthAi's session stats (its OnChatWindowText). public bool OnChat(string text) => false; public void OnLogout() => Reset(); @@ -158,17 +154,17 @@ internal sealed class IltSessionRates : IIltFeature { double hours = Math.Max((DateTime.UtcNow - _start).TotalHours, 1.0 / 3600); _summary = new RateSummary(_coins / hours, _pyreals / hours); - var s = _stats?.View ?? SessionStatsView.Empty; - var rows = new List + var rows = new List(); + if (_ctx.Ai.TryGetSessionStats(out SessionStatsV1 s)) { - new("XP", IltParse.Compact(s.Xp), IltParse.Compact(s.XpPerHour)), - new("Luminance", IltParse.Compact(s.Lum), IltParse.Compact(s.LumPerHour)), + rows.Add(new RateRow("XP", IltParse.Compact(s.Xp), IltParse.Compact(s.XpPerHour))); + rows.Add(new RateRow("Luminance", IltParse.Compact(s.Lum), IltParse.Compact(s.LumPerHour))); // Per hour at the last five minutes' pace. - new(" last 5 min", IltParse.Compact(s.LumLast5Min), IltParse.Compact(s.LumLast5Min * 12.0)), - }; - if (s.PassUpTracked) - rows.Add(new RateRow(PassUpLabel, IltParse.Compact(s.LumPassUp), IltParse.Compact(s.PassUpPerHour))); - rows.Add(new RateRow("Kills", s.Kills.ToString(), s.KillsPerHour.ToString("0"))); + rows.Add(new RateRow(" last 5 min", IltParse.Compact(s.LumLast5Min), IltParse.Compact(s.LumLast5Min * 12.0))); + if (s.PassUpTracked != 0) + rows.Add(new RateRow(PassUpLabel, IltParse.Compact(s.LumPassUp), IltParse.Compact(s.PassUpPerHour))); + rows.Add(new RateRow("Kills", s.Kills.ToString(), s.KillsPerHour.ToString("0"))); + } rows.Add(new RateRow("Enlightened Coins", IltParse.Compact(_coins), IltParse.Compact(_coins / hours))); rows.Add(new RateRow("Pyreals", IltParse.Compact(_pyreals), IltParse.Compact(_pyreals / hours))); rows.Add(new RateRow(" as MMD", (_pyreals / (double)PyrealsPerMmd).ToString("0.0"), (_pyreals / (double)PyrealsPerMmd / hours).ToString("0.0"))); @@ -195,8 +191,9 @@ internal sealed class IltSessionRates : IIltFeature public void Render() { - // The session clock is the shared stats' (it and the coins reset together). - var start = _stats?.View is { } v && v.SessionSeconds > 0 ? v.SessionStartUtc : _start; + // The session clock is RynthAi's session stats' (it and the coins reset together). + var start = _ctx.Ai.TryGetSessionStats(out SessionStatsV1 v) && v.SessionSeconds > 0 && v.StartUtcTicks > 0 + ? new DateTime(v.StartUtcTicks, DateTimeKind.Utc) : _start; ImGui.TextDisabled($"Session {IltParse.Duration(DateTime.UtcNow - start)}"); ImGui.SameLine(); if (ImGui.SmallButton("Reset##rates")) _ctx.Post(ResetAll); @@ -213,7 +210,7 @@ internal sealed class IltSessionRates : IIltFeature ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Label); if (ReferenceEquals(r.Label, PassUpLabel) && ImGui.IsItemHovered()) ImGui.SetTooltip(PassUpTooltip); ImGui.TableNextColumn(); ImGui.TextUnformatted(r.Total); - ImGui.TableNextColumn(); ImGui.TextColored(LegacyDashboardRenderer.ColTeal, r.PerHour); + ImGui.TableNextColumn(); ImGui.TextColored(IltStyle.ColTeal, r.PerHour); } ImGui.EndTable(); } diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSettings.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSettings.cs new file mode 100644 index 0000000..f7a8469 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSettings.cs @@ -0,0 +1,92 @@ +// IltSettings.cs - RynthILT's own settings (every character): which world names are Infinite +// Leaftide. Lives in %APPDATA%\RynthCore\RynthILT\settings.json. +// +// The list was RynthAi's Settings > Misc "Server Features" (FeatureServerNames, saved with each +// RynthAi profile). RynthILT keeps one list for every character; the first time a character +// logs in with RynthILT, IltMigration folds that character's RynthAi list into this one. +// Edited from the Character tab and "/ilt servers ". +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthILT.Hub; + +public sealed class IltSettings +{ + public int SchemaVersion = 1; + + /// World-name patterns that count as Infinite Leaftide ('*' wildcard, case-insensitive). + public List ServerNames = new(ServerFeatureGate.DefaultServerNames); + + /// The shared RynthAi files (Hub profiles, aug costs) were copied over once. + public bool SharedFilesMigrated; + + /// + /// RynthILT character folders whose copy from RynthAi failed part-way (IltMigration). Until it + /// succeeds the Hub writes nothing there (a fresh file would shadow the RynthAi original and + /// stop it ever being copied); the copy is retried at each login and every few minutes. + /// + public List PendingCharacterMigrations = new(); +} + +/// Loads and saves ; a broken or missing file reads as the defaults. +internal static class IltSettingsStore +{ + public const string FileName = "settings.json"; + + /// Overridable for the tests. + public static string Folder = RynthILTPlugin.SettingsRoot; + + public static string FilePath => Path.Combine(Folder, FileName); + + public static IltSettings Load() + { + try + { + if (File.Exists(FilePath)) + { + var s = JsonSerializer.Deserialize(File.ReadAllText(FilePath), IltHubJsonContext.Default.IltSettings); + if (s != null) + { + s.ServerNames = ServerFeatureGate.ParseList(string.Join(",", s.ServerNames ?? new List())); + if (s.ServerNames.Count == 0) s.ServerNames = new List(ServerFeatureGate.DefaultServerNames); + return s; + } + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"load {FilePath}"); } + return new IltSettings(); + } + + public static void Save(IltSettings settings) + { + try + { + string json = JsonSerializer.Serialize(settings, IltHubJsonContext.Default.IltSettings); + DataWriteGuard.TrySave("RynthILT's settings", FilePath, () => + { + Directory.CreateDirectory(Folder); + string tmp = FilePath + ".tmp"; + File.WriteAllText(tmp, json); + File.Move(tmp, FilePath, overwrite: true); + }); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, $"save {FilePath}"); } + } +} + +// Source-generated System.Text.Json only (NativeAOT; never reflection-serialize plugin types: +// the reflection cache keeps the old plugin generation alive across a hot reload). +[JsonSerializable(typeof(IltSettings))] +[JsonSerializable(typeof(IltHubState))] +[JsonSerializable(typeof(List), TypeInfoPropertyName = "IltBankTransactionList")] +[JsonSerializable(typeof(IltAugCostFile))] +[JsonSerializable(typeof(IltLegacyProfileFlags))] +[JsonSourceGenerationOptions( + WriteIndented = true, + IncludeFields = true, + PropertyNameCaseInsensitive = true)] +internal partial class IltHubJsonContext : JsonSerializerContext { } diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSigilChain.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltSigilChain.cs index 4cdbb10..3e41a28 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSigilChain.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSigilChain.cs @@ -1,4 +1,5 @@ // IltSigilChain.cs - The Enlightenment Sigil craft chain for /enl 301-325 (ACECustom tier 5: +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // T - 5 sigils and T x 2B luminance per target level T). Every craft is one plus one makes one: // Enlightened Coin + Ancient Yalani Trinket = Ascension Coin // Life Splitter + Plant = Lifebloom Resin @@ -8,7 +9,7 @@ // EnlightenmentSigilChainPolicy. using System; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// Stack counts of every item in the sigil chain. internal sealed class IltSigilStock diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSplitArrows.cs similarity index 97% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltSplitArrows.cs index 0c56885..219092f 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltSplitArrows.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltSplitArrows.cs @@ -1,4 +1,5 @@ // IltSplitArrows.cs — Split-arrow imbuer (Gear tab, P2). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // ILT missile weapons carry a split-arrow count (int 9031). Each White Quartz salvage // application adds one split and uses one tink. Per weapon: @@ -13,9 +14,8 @@ using System.Linq; using System.Text.RegularExpressions; using ImGuiNET; using RynthCore.Loot; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal sealed class IltSplitArrows : IIltFeature { @@ -172,7 +172,7 @@ internal sealed class IltSplitArrows : IIltFeature public void Render() { - ImGui.TextColored(LegacyDashboardRenderer.ColTeal, "Split arrows (White Quartz)"); + ImGui.TextColored(IltStyle.ColTeal, "Split arrows (White Quartz)"); int tgt = G.SplitArrowTarget; ImGui.SetNextItemWidth(120); if (ImGui.SliderInt("Target splits", ref tgt, 0, 10)) G.SplitArrowTarget = tgt; diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltStyle.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltStyle.cs new file mode 100644 index 0000000..55f7f15 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltStyle.cs @@ -0,0 +1,59 @@ +// IltStyle.cs - The colours the ILT tabs and panels draw with (RynthAi's dashboard palette, so +// the tabs look the same inside RynthAi's Mini Remote as when they lived there), the dashboard +// style for RynthILT's own windows, and a JSON string escaper for the hand-built exports. +using System.Numerics; +using ImGuiNET; + +namespace RynthCore.Plugin.RynthILT.Hub; + +internal static class IltStyle +{ + internal static readonly Vector4 ColTeal = new(0.15f, 0.85f, 0.90f, 1.00f); + internal static readonly Vector4 ColAmber = new(0.91f, 0.70f, 0.20f, 1.00f); + internal static readonly Vector4 ColGreen = new(0.25f, 0.85f, 0.45f, 1.00f); + internal static readonly Vector4 ColTextMute = new(0.55f, 0.65f, 0.75f, 1.00f); + internal static readonly Vector4 ColHp = new(0.85f, 0.20f, 0.20f, 1.00f); + + /// + /// RynthAi's dashboard colours for a window of RynthILT's own (Games HUD, confirmations, the + /// Guardian panel). Returns how many colours to pop. Inside RynthAi's Mini Remote the style + /// is already pushed. + /// + internal static int PushDashboardStyle() + { + ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.18f, 0.22f, 0.28f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.FrameBgHovered, new Vector4(0.24f, 0.30f, 0.38f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.FrameBgActive, new Vector4(0.30f, 0.38f, 0.48f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.CheckMark, new Vector4(0.85f, 0.90f, 1.00f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.PopupBg, new Vector4(0.10f, 0.14f, 0.20f, 0.98f)); + ImGui.PushStyleColor(ImGuiCol.Header, new Vector4(0.20f, 0.28f, 0.36f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.HeaderHovered, new Vector4(0.26f, 0.36f, 0.46f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.HeaderActive, new Vector4(0.32f, 0.44f, 0.58f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBg, new Vector4(0.14f, 0.18f, 0.24f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBgActive, new Vector4(0.22f, 0.30f, 0.40f, 1.00f)); + ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, new Vector4(0.10f, 0.14f, 0.20f, 0.85f)); + return 11; + } + + /// Minimal JSON string escaper for hand-built export JSON. + internal static string JsonEscape(string s) + { + var sb = new System.Text.StringBuilder(s.Length + 8); + foreach (char c in s) + { + switch (c) + { + case '"': sb.Append("\\\""); break; + case '\\': sb.Append("\\\\"); break; + case '\n': sb.Append("\\n"); break; + case '\r': sb.Append("\\r"); break; + case '\t': sb.Append("\\t"); break; + default: + if (c < 0x20) sb.Append("\\u").Append(((int)c).ToString("x4")); + else sb.Append(c); + break; + } + } + return sb.ToString(); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltTempleAttributes.cs similarity index 93% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/IltTempleAttributes.cs index c8c4939..efb6c29 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/IltTempleAttributes.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltTempleAttributes.cs @@ -1,4 +1,5 @@ // IltTempleAttributes.cs - Temple of Enlightenment attribute turn-in tracker (Guardian window). +// Originally SilentKelpie's ILT Hub (RynthAi IltHub/); moved to RynthILT 2026-10-13. // // One row per Fiun attribute NPC plus the Guardian of Attribute Enlightenment riddle. Each row // prefers the timed flag from /myquests (solves + exact cooldown). When /myquests lacks the flag @@ -14,9 +15,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using RynthCore.Install; -using RynthCore.Plugin.RynthAi.Meta; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; /// One tracked turn-in: the NPC, its attribute, the /qb wait flag and the /myquests keys to try. internal sealed class IltTempleAttrRow @@ -80,8 +80,7 @@ internal sealed class IltTempleAttributes }; private readonly IltHubContext _ctx; - private readonly Func _tracker; - private readonly IltQuests _quests; + private readonly IltQuestBonus _quests; private readonly IltTempleAttrRow[] _rows; // Wait-stamp presence per attribute at the previous "/qb list" (session only: a transition // needs two lists in the same session). @@ -92,10 +91,9 @@ internal sealed class IltTempleAttributes private volatile IltTempleAttrStatus[] _snapshot = Array.Empty(); private DateTime _syncedUtc = DateTime.MinValue; - public IltTempleAttributes(IltHubContext ctx, Func tracker, IltQuests quests) + public IltTempleAttributes(IltHubContext ctx, IltQuestBonus quests) { _ctx = ctx; - _tracker = tracker; _quests = quests; _rows = LoadRows(out string source); RynthLog.Write(LogCat.IltHub, $"[IltGuardian] attribute rows: {_rows.Length} from {source}"); @@ -111,11 +109,12 @@ internal sealed class IltTempleAttributes // ── Rows file ─────────────────────────────────────────────────────────── - /// The CSV in the RynthAi folder, else UB's Documents location; built-in rows otherwise. + /// The CSV in RynthILT's folder, the RynthAi folder (where it lived), else UB's Documents location; built-in rows otherwise. private static IltTempleAttrRow[] LoadRows(out string source) { string[] candidates = { + Path.Combine(IltHubStore.SharedRoot, CsvName), Path.Combine(RynthInstallPaths.RynthAiDir, CsvName), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Asheron's Call", CsvName), }; @@ -183,7 +182,7 @@ internal sealed class IltTempleAttributes } /// Re-asks the server for /myquests and "/qb list" (each limited to once a minute). - public string Refresh() => $"{_quests.RefreshQuests()} {_quests.RefreshQb()}"; + public string Refresh() => $"{_ctx.Ai.RefreshQuests()} {_quests.RefreshQb()}"; /// Forgets the counted turn-ins and estimated cooldowns (the /qb fallback only). public void ResetCounts() @@ -203,10 +202,9 @@ internal sealed class IltTempleAttributes private bool TryQuest(IltTempleAttrRow row, out QuestRecord rec) { rec = null!; - var t = _tracker(); - if (t == null) return false; + // /myquests is RynthAi's quest tracker (RynthAi.Hub); without RynthAi the /qb stamps decide. foreach (string key in row.MyQuestsKeys) - if (t.TryGetFlag(key, out rec)) return true; + if (_ctx.Ai.TryGetQuestFlag(key, out rec)) return true; return false; } @@ -274,11 +272,11 @@ internal sealed class IltTempleAttributes /// A row backed by its /myquests flag: exact solves and cooldown. private static IltTempleAttrStatus FromQuest(IltTempleAttrRow row, QuestRecord rec) { - switch (IltQuests.Classify(rec)) + switch (IltQuestBonus.Classify(rec)) { - case IltQuests.QuestKind.KillTask: + case IltQuestBonus.QuestKind.KillTask: return new(row.Attribute, row.Npc, rec.Solves, "Kill task", $"{rec.Solves}/{rec.MaxSolves}", false, true); - case IltQuests.QuestKind.Once: + case IltQuestBonus.QuestKind.Once: return new(row.Attribute, row.Npc, rec.Solves, "Once", rec.Solves >= 1 ? "done" : "-", false, true); default: if (rec.IsReady()) return new(row.Attribute, row.Npc, rec.Solves, "Ready", "now", true, true); diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/IltWorld.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltWorld.cs new file mode 100644 index 0000000..4defa34 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/IltWorld.cs @@ -0,0 +1,294 @@ +// IltWorld.cs - RynthILT's view of the game's objects, read straight from the host. +// +// The ILT Hub read items through RynthAi's WorldObjectCache while it lived in RynthAi. RynthILT +// has no cache of its own events, so this asks the client directly (the way RynthSort's +// InventoryReader does): the player's pack and side packs through GetContainerContents (the +// main pack's list also holds the side packs and the worn and wielded items), everything +// else the client knows through GetLiveObjectIds. Names, classes and container links are taken +// at each scan; property reads (Values) are live. A scan is kept for ScanMs, so the many +// Items() calls of one tick cost one walk; GetDirectInventory(forceRefresh: true) walks again. +// Pump thread only (the render thread only ever sees snapshots the features built). +using System; +using System.Collections.Generic; +using RynthCore.Loot; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthILT.Hub; + +/// One object as RynthILT sees it: identity from the last scan, properties read live. +internal sealed class WorldObject +{ + private readonly IltObjects _owner; + + internal WorldObject(IltObjects owner, int id, string name, AcObjectClass objectClass, int container) + { + _owner = owner; + Id = id; + Name = name ?? string.Empty; + ObjectClass = objectClass; + DirectContainerId = container; + } + + public int Id { get; } + public string Name { get; } + public AcObjectClass ObjectClass { get; } + + /// The container the scan found it in (the player or a side pack); 0 off the player. + public int DirectContainerId { get; } + + /// The container it is in now (live), else where the scan found it. + public int Container => _owner.ContainerOf(Id, DirectContainerId); + + /// Who wields it (live; 0 = nobody). + public int Wielder => _owner.WielderOf(Id); + + /// Where it is wielded (live; 0 = not wielded). + public int WieldedLocation => _owner.WieldedLocationOf(Id); + + /// An int property, read live ( when unknown). + public int Values(int key, int defaultValue) => _owner.IntProperty(Id, unchecked((uint)key), defaultValue); +} + +/// The player's items and the objects around, from host calls. +internal sealed class IltObjects +{ + // Property and type ids (AC's). + internal const uint IntItemsCapacity = 6; + internal const uint IntCurrentWieldedLocation = 10; + internal const uint IntDamageType = 45; + private const uint ItemTypeCreature = 0x00000010; + private const uint ItemTypeContainer = 0x00000200; + private const long ScanMs = 1000; + private const int MainPackSlots = 102; + + private readonly RynthCoreHost _host; + private uint[] _buf = new uint[512]; + private List _inventory = new(); + private Dictionary _byId = new(); + private long _scannedAt = long.MinValue; + private uint _scannedPlayer; + + public IltObjects(RynthCoreHost host) => _host = host; + + /// Forgets the last scan (logout). + public void Clear() + { + _inventory = new List(); + _byId = new Dictionary(); + _scannedAt = long.MinValue; + _scannedPlayer = 0; + } + + // ── Inventory ─────────────────────────────────────────────────────────── + + /// Everything the player carries or wears (a snapshot, at most ScanMs old). + public IEnumerable GetInventory() => Scan(force: false); + + /// The same walk; reads the client again now. + public IReadOnlyList GetDirectInventory(bool forceRefresh = false) => Scan(forceRefresh); + + /// A carried item by id, else any object the client knows by id (null when it knows none). + public WorldObject? this[int id] + { + get + { + Scan(force: false); + if (_byId.TryGetValue(id, out var wo)) return wo; + uint uid = unchecked((uint)id); + if (id == 0 || !_host.HasGetObjectName || !_host.TryGetObjectName(uid, out string name)) return null; + return new WorldObject(this, id, name, Classify(uid), 0); + } + } + + private List Scan(bool force) + { + long now = Environment.TickCount64; + uint player = _host.GetPlayerId(); + if (!force && player == _scannedPlayer && now - _scannedAt < ScanMs) return _inventory; + _scannedAt = now; + _scannedPlayer = player; + if (player == 0 || !_host.HasGetContainerContents) { _inventory = new(); _byId = new(); return _inventory; } + + var list = new List(256); + var byId = new Dictionary(256); + int pid = unchecked((int)player); + foreach (uint id in Contents(player)) + { + if (id == 0) continue; + uint type = ItemType(id); + Add(list, byId, id, type, pid); + // Side packs: containers with room for items (foci hold none). + if ((type & ItemTypeContainer) == 0) continue; + if (!_host.TryGetObjectIntProperty(id, IntItemsCapacity, out int cap) || cap <= 0) continue; + foreach (uint inner in Contents(id)) + if (inner != 0) Add(list, byId, inner, ItemType(inner), unchecked((int)id)); + } + _inventory = list; + _byId = byId; + return list; + } + + private void Add(List list, Dictionary byId, uint id, uint type, int container) + { + int iid = unchecked((int)id); + if (byId.ContainsKey(iid)) return; + string name = _host.HasGetObjectName && _host.TryGetObjectName(id, out string n) ? n ?? string.Empty : string.Empty; + var wo = new WorldObject(this, iid, name, ClassifyByItemType(type), container); + list.Add(wo); + byId[iid] = wo; + } + + private uint[] Contents(uint container) + { + int n = _host.GetContainerContents(container, _buf); + if (n >= _buf.Length) + { + _buf = new uint[Math.Max(n + 64, _buf.Length * 2)]; + n = _host.GetContainerContents(container, _buf); + } + if (n <= 0) return Array.Empty(); + var ids = new uint[Math.Min(n, _buf.Length)]; + Array.Copy(_buf, ids, ids.Length); + return ids; + } + + // ── The world around ──────────────────────────────────────────────────── + + /// Creatures the client knows (monsters, NPCs, vendors, pets), not carried. + public IEnumerable GetLandscape() => Around(creaturesOnly: true); + + /// Every object the client knows that the player doesn't carry. + public IEnumerable GetLandscapeObjects() => Around(creaturesOnly: false); + + private List Around(bool creaturesOnly) + { + var result = new List(); + if (!_host.HasGetLiveObjectIds) return result; + Scan(force: false); + uint player = _host.GetPlayerId(); + foreach (uint id in _host.GetLiveObjectIds()) + { + if (id == 0 || id == player || _byId.ContainsKey(unchecked((int)id))) continue; + uint type = ItemType(id); + if (creaturesOnly && (type & ItemTypeCreature) == 0) continue; + if (!_host.HasGetObjectName || !_host.TryGetObjectName(id, out string name) || string.IsNullOrEmpty(name)) continue; + result.Add(new WorldObject(this, unchecked((int)id), name, ClassifyByItemType(type), 0)); + } + return result; + } + + /// Metres between two objects (double.MaxValue when either position can't be read). + public double Distance(int id1, int id2) + { + if (!_host.TryGetObjectPosition(unchecked((uint)id1), out uint cell1, out float x1, out float y1, out float z1)) return double.MaxValue; + if (!_host.TryGetObjectPosition(unchecked((uint)id2), out uint cell2, out float x2, out float y2, out float z2)) return double.MaxValue; + float gx1 = ((cell1 >> 24) & 0xFF) * 192f + x1; + float gy1 = ((cell1 >> 16) & 0xFF) * 192f + y1; + float gx2 = ((cell2 >> 24) & 0xFF) * 192f + x2; + float gy2 = ((cell2 >> 16) & 0xFF) * 192f + y2; + float dx = gx1 - gx2, dy = gy1 - gy2, dz = z1 - z2; + double d = Math.Sqrt(dx * dx + dy * dy + dz * dz); + return double.IsFinite(d) ? d : double.MaxValue; + } + + // ── Live reads ────────────────────────────────────────────────────────── + + internal int IntProperty(int id, uint stype, int defaultValue) + => _host.HasGetObjectIntProperty && _host.TryGetObjectIntProperty(unchecked((uint)id), stype, out int v) ? v : defaultValue; + + internal int ContainerOf(int id, int scanned) + { + if (_host.HasGetObjectOwnershipInfo && _host.TryGetObjectOwnershipInfo(unchecked((uint)id), out uint container, out _, out _)) + return unchecked((int)container); + return scanned; + } + + internal int WielderOf(int id) + { + if (_host.HasGetObjectOwnershipInfo && _host.TryGetObjectOwnershipInfo(unchecked((uint)id), out _, out uint wielder, out _)) + return unchecked((int)wielder); + return _host.HasGetObjectWielderInfo && _host.TryGetObjectWielderInfo(unchecked((uint)id), out uint w, out _) ? unchecked((int)w) : 0; + } + + internal int WieldedLocationOf(int id) + { + if (_host.HasGetObjectOwnershipInfo && _host.TryGetObjectOwnershipInfo(unchecked((uint)id), out _, out uint wielder, out uint location) && wielder != 0) + return unchecked((int)location); + return Math.Max(0, IntProperty(id, IntCurrentWieldedLocation, 0)); + } + + private uint ItemType(uint id) => _host.HasGetItemType && _host.TryGetItemType(id, out uint t) ? t : 0; + + private AcObjectClass Classify(uint id) => ClassifyByItemType(ItemType(id)); + + // ── Packs ─────────────────────────────────────────────────────────────── + + /// + /// A side pack with at least free slots (the one with the most), + /// else the main pack when and it has a slot, else 0. Foci + /// and packs whose capacity isn't known never qualify (a move into a full pack crashes the + /// client). RynthAi's WorldObjectCache.FindPackFor, on this view. + /// + public static int FindPackFor(RynthCoreHost host, IltObjects? objects, bool includeMainPack, int requireFree) + { + if (objects == null) return 0; + int playerId = unchecked((int)host.GetPlayerId()); + if (playerId == 0) return 0; + if (requireFree < 1) requireFree = 1; + var inv = objects.GetDirectInventory(forceRefresh: true); + int bestPack = 0, bestFree = 0, mainUsed = 0; + foreach (var p in inv) + { + if (p.DirectContainerId != playerId) continue; + bool isPack = p.ObjectClass == AcObjectClass.Container; + bool isFoci = p.ObjectClass == AcObjectClass.Foci || p.Name.IndexOf("Foci", StringComparison.OrdinalIgnoreCase) >= 0; + if (!isPack && !isFoci && p.WieldedLocation <= 0 && p.Wielder == 0) mainUsed++; + if (!isPack || isFoci) continue; + int capacity = p.Values(unchecked((int)IntItemsCapacity), 0); + if (capacity <= 0) continue; + int used = 0; + foreach (var it in inv) + if (it.DirectContainerId == p.Id && it.ObjectClass != AcObjectClass.Container) used++; + int free = capacity - used; + if (free >= requireFree && free > bestFree) { bestFree = free; bestPack = p.Id; } + } + if (bestPack != 0) return bestPack; + if (!includeMainPack) return 0; + return MainPackSlots - mainUsed > 0 ? playerId : 0; + } + + // ── Classification (RynthAi's WorldObjectCache.ClassifyByItemType) ────── + + internal static AcObjectClass ClassifyByItemType(uint t) + { + if (t == 0) return AcObjectClass.Unknown; + if ((t & 0x00000010) != 0) return AcObjectClass.Monster; + if ((t & 0x00040000) != 0) return AcObjectClass.TradeNote; + if ((t & 0x00080000) != 0) return AcObjectClass.ManaStone; + if ((t & 0x00001000) != 0) return AcObjectClass.SpellComponent; + if ((t & 0x00000800) != 0) return AcObjectClass.Gem; + if ((t & 0x00004000) != 0) return AcObjectClass.Key; + if ((t & 0x10000000) != 0) return AcObjectClass.Lifestone; + if ((t & 0x40000000) != 0) return AcObjectClass.Salvage; + if ((t & 0x20000000) != 0) return AcObjectClass.Ust; + if ((t & 0x00400000) != 0) return AcObjectClass.BaseCooking; + if ((t & 0x00800000) != 0) return AcObjectClass.BaseAlchemy; + if ((t & 0x02000000) != 0) return AcObjectClass.BaseFletching; + if ((t & 0x04000000) != 0) return AcObjectClass.CraftedAlchemy; + if ((t & 0x08000000) != 0) return AcObjectClass.CraftedFletching; + if ((t & 0x00100000) != 0) return AcObjectClass.Services; + if ((t & 0x00010000) != 0) return AcObjectClass.Portal; + if ((t & 0x00002000) != 0) return AcObjectClass.Book; + if ((t & 0x00000200) != 0) return AcObjectClass.Container; + if ((t & 0x00008000) != 0) return AcObjectClass.WandStaffOrb; + if ((t & 0x00000100) != 0) return AcObjectClass.MissileWeapon; + if ((t & 0x00000002) != 0) return AcObjectClass.Armor; + if ((t & 0x00000001) != 0) return AcObjectClass.MeleeWeapon; + if ((t & 0x00000004) != 0) return AcObjectClass.Clothing; + if ((t & 0x00000008) != 0) return AcObjectClass.Jewelry; + if ((t & 0x00000020) != 0) return AcObjectClass.Food; + if ((t & 0x00000040) != 0) return AcObjectClass.Money; + if ((t & 0x00000080) != 0) return AcObjectClass.Misc; + return AcObjectClass.Unknown; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs new file mode 100644 index 0000000..be81dd6 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/RynthAiClient.cs @@ -0,0 +1,254 @@ +// RynthAiClient.cs - RynthILT's side of the "RynthAi.Hub" interface (Plugins/Shared/RynthAiHubApi.cs): +// the Mini Remote that hosts the ILT tabs, the /myquests tracker, spell names, VTank loot-profile +// matching, the .usd importer and the Mini Remote's session stats. +// +// The table is looked up through the host (API v68) and kept for RecheckMs; Reset() (login, logout, +// shutdown) and a table whose Version went to 0 (RynthAi shut down) force a fresh lookup, so a +// RynthAi that loads after RynthILT, is reloaded or isn't installed is handled: every call then +// reports "no RynthAi" and the ILT features that need it say so. The pointer is kept in a volatile +// field so the render thread (RenderSection) can use what the pump looked up; the table is never +// freed by RynthAi (its Version is zeroed instead), so a stale pointer is safe to read. +using System; +using System.Runtime.InteropServices; +using System.Text; +using RynthCore.Plugin.Shared; +using RynthCore.PluginSdk; + +namespace RynthCore.Plugin.RynthILT.Hub; + +/// One /myquests flag as RynthAi has it (QuestRecord's fields the Temple tracker reads). +internal sealed class QuestRecord +{ + public string Key = string.Empty; + public int Solves; + public int MaxSolves; + public DateTime CompletedOn = DateTime.MinValue; + public TimeSpan RepeatTime = TimeSpan.Zero; + + /// RynthAi's QuestRecord.IsReady (UB's): the timer ran out and it isn't a once-only flag. + public bool IsReady() + { + if ((CompletedOn + RepeatTime) > DateTime.UtcNow) return false; + return !(MaxSolves == 1 && Solves <= 1); + } + + /// Time until the flag can be solved again (zero when ready). + public TimeSpan TimeUntilReady() + { + var left = (CompletedOn + RepeatTime) - DateTime.UtcNow; + return left > TimeSpan.Zero ? left : TimeSpan.Zero; + } +} + +internal sealed unsafe class RynthAiClient +{ + public const string NotLoaded = "needs RynthAi (not loaded)"; + private const long RecheckMs = 3000; + + private readonly RynthCoreHost _host; + private RynthAiHubApiV1* _t; // pump-thread copy + private IntPtr _renderTable; // what the render thread uses (volatile) + private bool _checked; + private long _checkedAt; + + public RynthAiClient(RynthCoreHost host) => _host = host; + + /// Forget the table; the next call looks it up again (login, logout, RynthAi reload). + public void Reset() + { + _t = null; + _checked = false; + System.Threading.Volatile.Write(ref _renderTable, IntPtr.Zero); + } + + /// The table, looked up at most every RecheckMs (pump thread). + private RynthAiHubApiV1* Table + { + get + { + long now = Environment.TickCount64; + if (_checked && now - _checkedAt < RecheckMs && (_t == null || _t->Version >= 1)) return _t; + _checked = true; + _checkedAt = now; + _t = null; + if (_host.HasGetPluginInterface) + { + var t = (RynthAiHubApiV1*)_host.GetPluginInterface(RynthAiHub.PluginName, RynthAiHubApiV1.InterfaceName, RynthAiHubApiV1.InterfaceVersion); + if (t != null && t->Version >= 1 && t->StructSize >= (uint)sizeof(RynthAiHubApiV1)) _t = t; + } + System.Threading.Volatile.Write(ref _renderTable, (IntPtr)_t); + return _t; + } + } + + /// Pump thread: refreshes the lookup (the render thread only reads what this found). + public void Tick() => _ = Table; + + /// True when RynthAi's interface is there (pump thread). + public bool Available => Table != null; + + /// Any thread: the table the pump last found, if RynthAi hasn't shut down since. + private RynthAiHubApiV1* AnyThreadTable + { + get + { + var t = (RynthAiHubApiV1*)System.Threading.Volatile.Read(ref _renderTable); + return t != null && t->Version >= 1 ? t : null; + } + } + + // ── Mini Remote ───────────────────────────────────────────────────────── + + /// Puts the Mini Remote on a tab (any thread). The reply, or why it couldn't. + public string MiniRemoteTab(string tabId, string mode) + { + var t = AnyThreadTable; + if (t == null || t->MiniRemoteTab == null) return "The Mini Remote is RynthAi's; RynthAi isn't loaded."; + byte* reply = stackalloc byte[256]; + reply[0] = 0; + using var id = new Utf8(tabId); + using var m = new Utf8(mode); + int ok = t->MiniRemoteTab(id.P, m.P, reply, 256); + string text = Marshal.PtrToStringUTF8((IntPtr)reply) ?? string.Empty; + return ok != 0 ? text : (text.Length > 0 ? text : "The Mini Remote is not available yet."); + } + + /// True while the Mini Remote is on screen (any thread). + public bool MiniRemoteVisible + { + get + { + var t = AnyThreadTable; + return t != null && t->MiniRemoteVisible != null && t->MiniRemoteVisible() != 0; + } + } + + // ── Quests (/myquests) ────────────────────────────────────────────────── + + /// A /myquests flag from RynthAi's tracker (pump thread). + public bool TryGetQuestFlag(string key, out QuestRecord rec) + { + rec = null!; + var t = Table; + if (t == null || t->QuestFlag == null || string.IsNullOrWhiteSpace(key)) return false; + QuestFlagV1 f = default; + using var k = new Utf8(key); + if (t->QuestFlag(k.P, &f) == 0) return false; + rec = new QuestRecord + { + Key = key.ToLowerInvariant(), + Solves = f.Solves, + MaxSolves = f.MaxSolves, + CompletedOn = new DateTime(Math.Max(0, f.CompletedOnUtcTicks), DateTimeKind.Utc), + RepeatTime = TimeSpan.FromSeconds(Math.Max(0, f.RepeatSeconds)), + }; + return true; + } + + /// The tracker's state (pump thread); false without RynthAi or before login. + public bool TryGetQuestStatus(out QuestStatusV1 status) + { + status = default; + var t = Table; + if (t == null || t->QuestStatus == null) return false; + QuestStatusV1 s = default; + if (t->QuestStatus(&s) == 0) return false; + status = s; + return true; + } + + /// A quiet /myquests refresh through RynthAi's Quests tab (its cooldown applies). Pump thread. + public string RefreshQuests() + { + var t = Table; + if (t == null || t->QuestRefresh == null) return "The quest tracker " + NotLoaded + "."; + byte* reply = stackalloc byte[256]; + reply[0] = 0; + t->QuestRefresh(reply, 256); + return Marshal.PtrToStringUTF8((IntPtr)reply) ?? string.Empty; + } + + // ── Spells, loot profiles ─────────────────────────────────────────────── + + /// A spell's name from RynthAi's spell table ("" when unknown or no RynthAi). Pump thread. + public string SpellName(int spellId) + { + var t = Table; + if (t == null || t->SpellName == null || spellId <= 0) return string.Empty; + byte* buf = stackalloc byte[160]; + int n = t->SpellName(unchecked((uint)spellId), buf, 160); + return n <= 0 ? string.Empty : Marshal.PtrToStringUTF8((IntPtr)buf) ?? string.Empty; + } + + /// + /// Evaluates a VTank .utl profile on : keep[i] is true when that item's + /// first matching rule is Keep. False (with the reason) when it couldn't. Pump thread. + /// + public bool LootKeeps(string utlPath, uint[] ids, out bool[] keep, out string error) + { + keep = new bool[ids.Length]; + error = string.Empty; + var t = Table; + if (t == null || t->LootKeeps == null) { error = "equipment suits " + NotLoaded; return false; } + byte[] flags = new byte[ids.Length]; + byte* err = stackalloc byte[256]; + err[0] = 0; + int ok; + using (var p = new Utf8(utlPath)) + fixed (uint* pids = ids) + fixed (byte* pf = flags) + ok = t->LootKeeps(p.P, pids, ids.Length, pf, err, 256); + if (ok == 0) { error = Marshal.PtrToStringUTF8((IntPtr)err) ?? "could not read profile"; return false; } + for (int i = 0; i < ids.Length; i++) keep[i] = flags[i] != 0; + return true; + } + + // ── Session stats ─────────────────────────────────────────────────────── + + /// The Mini Remote's session (any thread); false without RynthAi or before login. + public bool TryGetSessionStats(out SessionStatsV1 stats) + { + stats = default; + var t = AnyThreadTable; + if (t == null || t->SessionStats == null) return false; + SessionStatsV1 s = default; + if (t->SessionStats(&s) == 0) return false; + stats = s; + return true; + } + + /// Starts the Mini Remote's session over (any thread). + public void ResetSessionStats() + { + var t = AnyThreadTable; + if (t != null && t->SessionReset != null) t->SessionReset(); + } + + // ── RynthAi's sections drawn in RynthILT's tabs ───────────────────────── + + /// Render thread: draws one of RynthAi's sections; false (nothing drawn) without RynthAi. + public bool RenderSection(string id) + { + var t = AnyThreadTable; + if (t == null || t->RenderSection == null) return false; + using var s = new Utf8(id); + return t->RenderSection(s.P) != 0; + } + + /// A NUL-terminated UTF-8 copy of a string for one call. + private readonly struct Utf8 : IDisposable + { + public readonly byte* P; + + public Utf8(string? s) + { + s ??= string.Empty; + int n = Encoding.UTF8.GetByteCount(s); + P = (byte*)NativeMemory.Alloc((nuint)(n + 1)); + fixed (char* c = s) Encoding.UTF8.GetBytes(c, s.Length, P, n); + P[n] = 0; + } + + public void Dispose() => NativeMemory.Free(P); + } +} diff --git a/Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs b/Plugins/RynthCore.Plugin.RynthILT/Hub/ServerFeatureGate.cs similarity index 54% rename from Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs rename to Plugins/RynthCore.Plugin.RynthILT/Hub/ServerFeatureGate.cs index 15643b5..f9b948d 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/IltHub/ServerFeatureGate.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/Hub/ServerFeatureGate.cs @@ -1,43 +1,29 @@ // ServerFeatureGate.cs — Which worlds get the ILT / infinite-attribute features. +// Originally part of SilentKelpie's ILT Hub in RynthAi; moved to RynthILT 2026-10-13. // -// One gate for everything ILT-shaped: the ILT Hub and Mini Remote, the Skills panel's -// Progression planners and the attribute raiser. A world is "on" when: -// * its name matches one of the server patterns in Settings > Misc (FeatureServerNames, -// '*' wildcard, case-insensitive; defaults cover InfiniteLeaftide), or -// * the manual override is ticked (Settings > Misc ForceServerFeatures, or the older -// per-character ILT Hub "Treat this world as ILT" / "/ra hub force on"). -// The gate only decides whether RynthAi ASKS the server; each feature still follows the +// One gate for everything ILT-shaped: the Mini Remote's ILT tabs, the Guardian, the Skills +// panel's Progression planners and the attribute raiser. A world is "on" when: +// * its name matches one of the server patterns (IltSettings.ServerNames, '*' wildcard, +// case-insensitive; defaults cover InfiniteLeaftide; "/ilt servers" or the Character tab +// edits them — they were RynthAi's Settings > Misc "Server Features" list), or +// * this character's override is on (the Character tab's "Treat this world as ILT", +// "/ra hub force on"; also set by migration from RynthAi's "Force enable" profile flag). +// The gate only decides whether RynthILT ASKS the server; each feature still follows the // server's own report (IltServerOptions bits), so a shard with /xp off keeps the raiser off. using System; using System.Collections.Generic; using System.Linq; -using RynthCore.Plugin.RynthAi.LegacyUi; -namespace RynthCore.Plugin.RynthAi.IltHub; +namespace RynthCore.Plugin.RynthILT.Hub; internal static class ServerFeatureGate { - /// Patterns a fresh profile starts with (the names the old hard-coded check accepted). + /// Patterns a fresh install starts with (the names the old hard-coded check accepted). public static readonly string[] DefaultServerNames = { "InfiniteLeaftide", "*Leaftide*" }; - /// World name of the current session; set by RynthAiPlugin (empty before login). - public static Func? WorldNameProvider; - - /// The per-character ILT Hub override (ilt-hub.json); set by the Hub while it exists. - public static Func? HubForceProvider; - - public static string CurrentWorld - { - get - { - try { return (WorldNameProvider?.Invoke() ?? string.Empty).Trim(); } - catch { return string.Empty; } - } - } - - /// The patterns in force: the profile's list, or the defaults when there is no profile yet. - public static IReadOnlyList Patterns(LegacyUiSettings? settings) - => settings?.FeatureServerNames ?? (IReadOnlyList)DefaultServerNames; + /// The patterns in force (null settings: the defaults). + public static IReadOnlyList Patterns(IltSettings? settings) + => settings?.ServerNames is { Count: > 0 } list ? list : DefaultServerNames; /// True when matches one of . public static bool NameMatches(string world, IEnumerable? patterns, out string matched) @@ -81,17 +67,9 @@ internal static class ServerFeatureGate return true; } - /// Is the override on (Settings > Misc, or the per-character Hub checkbox)? - public static bool ForceOn(LegacyUiSettings? settings) - { - if (settings?.ForceServerFeatures == true) return true; - try { return HubForceProvider?.Invoke() == true; } - catch { return false; } - } - - /// The gate itself. - public static bool IsEnabled(string world, LegacyUiSettings? settings) - => ForceOn(settings) || NameMatches(world, Patterns(settings), out _); + /// The gate itself: the character's override, or the world name in the list. + public static bool IsEnabled(string world, IltSettings? settings, bool forceOn) + => forceOn || NameMatches(world, Patterns(settings), out _); /// "InfiniteLeaftide, *Leaftide*" → trimmed, de-duplicated list (case-insensitive). public static List ParseList(string? text) @@ -109,21 +87,17 @@ internal static class ServerFeatureGate public static string FormatList(IEnumerable? patterns) => patterns == null ? string.Empty : string.Join(", ", patterns.Where(p => !string.IsNullOrWhiteSpace(p))); - /// One status line for Settings > Misc: the world, whether the features are on, and why. - public static string Describe(LegacyUiSettings? settings) + /// One status line: the world, whether the features are on, and why. + public static string Describe(string world, IltSettings? settings, bool forceOn) { - string world = CurrentWorld; + world = (world ?? string.Empty).Trim(); string shown = world.Length > 0 ? $"'{world}'" : "(not logged in)"; - if (settings?.ForceServerFeatures == true) - return $"This world {shown}: ON - manual override."; if (NameMatches(world, Patterns(settings), out string matched)) return $"This world {shown}: ON - matches '{matched}'."; - bool hubForce; - try { hubForce = HubForceProvider?.Invoke() == true; } catch { hubForce = false; } - if (hubForce) - return $"This world {shown}: ON - the Mini Remote's \"Treat this world as ILT\" override."; + if (forceOn) + return $"This world {shown}: ON - \"Treat this world as ILT\" is ticked."; return world.Length > 0 - ? $"This world {shown}: OFF - not in the list. Add it, or tick the override." + ? $"This world {shown}: OFF - not in the list. Add it, or tick \"Treat this world as ILT\"." : "This world: not logged in yet."; } } diff --git a/Plugins/RynthCore.Plugin.RynthILT/HubInterface.cs b/Plugins/RynthCore.Plugin.RynthILT/HubInterface.cs new file mode 100644 index 0000000..657eaa1 --- /dev/null +++ b/Plugins/RynthCore.Plugin.RynthILT/HubInterface.cs @@ -0,0 +1,197 @@ +// HubInterface.cs - RynthILT's side of the "RynthILT.Hub" interface (Plugins/Shared/RynthIltHubApi.cs): +// the table RynthPluginQueryInterface hands RynthAi, and the functions behind it. +// +// The table is allocated once per loaded copy of RynthILT and never freed (a plugin DLL is never +// unloaded, so its functions stay callable): RynthAi's render thread may still hold the pointer +// while plugins shut down, and every function here returns "nothing" once Release() has run +// (Version 0, no plugin). Threads as the interface says: the render-thread functions draw into +// the caller's current ImGui window; the pump-thread Command runs the ILT verb at once. +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using RynthCore.Plugin.RynthILT.Hub; +using RynthCore.Plugin.Shared; + +namespace RynthCore.Plugin.RynthILT; + +internal static unsafe class HubInterface +{ + private static RynthIltHubApiV1* _table; + private static volatile bool _released; + + /// The live controller, or null (before login, after logout, after shutdown). + private static IltHubController? Hub => _released ? null : PluginExports.Runtime.Plugin?.Hub; + + /// The table for (, ), or 0 when it isn't ours. + public static IntPtr Query(string iface, uint version) + { + if (iface != RynthIltHubApiV1.InterfaceName || version < 1 || version > RynthIltHubApiV1.InterfaceVersion || _released) + return IntPtr.Zero; + if (_table == null) + { + var t = (RynthIltHubApiV1*)NativeMemory.AllocZeroed((nuint)sizeof(RynthIltHubApiV1)); + t->StructSize = (uint)sizeof(RynthIltHubApiV1); + t->IsIltWorld = &IsIltWorld; + t->GetFeature = &GetFeature; + t->GetRates = &GetRates; + t->GetForceIlt = &GetForceIlt; + t->SetForceIlt = &SetForceIlt; + t->GetTabs = &GetTabs; + t->RenderTab = &RenderTab; + t->RenderSection = &RenderSection; + t->Command = &Command; + t->Version = RynthIltHubApiV1.InterfaceVersion; + _table = t; + } + return (IntPtr)_table; + } + + /// Plugin shutdown: callers see Version 0 and re-query; the functions answer "nothing". + public static void Release() + { + _released = true; + if (_table != null) _table->Version = 0; + } + + private static string? Utf8(byte* p) => p == null ? null : Marshal.PtrToStringUTF8((IntPtr)p); + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int IsIltWorld() + { + try { return Hub?.Options.IsIltLikeWorld == true ? 1 : 0; } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int GetFeature(byte* key) + { + try + { + var hub = Hub; + string? k = Utf8(key); + if (hub == null || string.IsNullOrEmpty(k) || !hub.Options.IsIltLikeWorld) return -1; + return (int)hub.Options.Get(k); + } + catch { return -1; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int GetRates(double* coinsPerHour, double* pyrealsPerHour) + { + try + { + var hub = Hub; + if (hub == null || !hub.Options.IsIltLikeWorld) return 0; + var r = hub.Rates.Summary; + if (coinsPerHour != null) *coinsPerHour = r.CoinsPerHour; + if (pyrealsPerHour != null) *pyrealsPerHour = r.PyrealsPerHour; + return 1; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int GetForceIlt() + { + try { return Hub?.ForceIltWorld == true ? 1 : 0; } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static void SetForceIlt(int on) + { + try + { + var hub = Hub; + if (hub != null) hub.ForceIltWorld = on != 0; + } + catch { } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int GetTabs(IltTabV1* tabs, int capacity) + { + try + { + var hub = Hub; + if (hub == null) return 0; + var all = IltSections.Tabs; + if (tabs != null) + { + for (int i = 0; i < all.Length && i < capacity; i++) + { + IltSection s = all[i]; + IltTabV1* t = &tabs[i]; + WriteUtf8(IltSections.TabId(s), t->Id, 24); + WriteUtf8(IltSections.Label(s), t->Label, 32); + var size = IltSections.TabSize(s); + t->Width = size.X; + t->Height = size.Y; + uint flags = 0; + if (hub.TabShown(s)) flags |= RynthIltHub.TabShown; + if (hub.SectionAvailable(s)) flags |= RynthIltHub.TabAvailable; + t->Flags = flags; + } + } + return all.Length; + } + catch { return 0; } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int RenderTab(byte* id) + { + try + { + var hub = Hub; + if (hub == null || !IltSections.TryParse(Utf8(id) ?? string.Empty, out IltSection s) || !IltSections.IsTab(s)) return 0; + hub.RenderTab(s); + return 1; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltHub, ex, "RenderTab"); + return 0; + } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int RenderSection(byte* id) + { + try + { + var hub = Hub; + string? s = Utf8(id); + return hub != null && s != null && hub.RenderSection(s) ? 1 : 0; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltHub, ex, "RenderSection"); + return 0; + } + } + + [UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })] + private static int Command(byte* text) + { + try + { + var plugin = _released ? null : PluginExports.Runtime.Plugin; + string? line = Utf8(text); + if (plugin == null || string.IsNullOrWhiteSpace(line) || line.Length > 512) return 0; + return plugin.RunForwardedCommand(line) ? 1 : 0; + } + catch { return 0; } + } + + /// Writes as NUL-terminated UTF-8 into a fixed buffer, truncated to fit. + private static void WriteUtf8(string s, byte* dest, int capacity) + { + byte[] bytes = Encoding.UTF8.GetBytes(s); + int n = Math.Min(bytes.Length, capacity - 1); + for (int i = 0; i < n; i++) dest[i] = bytes[i]; + dest[n] = 0; + } +} diff --git a/Plugins/RynthCore.Plugin.RynthILT/PluginExports.cs b/Plugins/RynthCore.Plugin.RynthILT/PluginExports.cs index f79a97a..099e9b0 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/PluginExports.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/PluginExports.cs @@ -9,13 +9,38 @@ namespace RynthCore.Plugin.RynthILT; public static unsafe class PluginExports { - private static readonly RynthPluginRuntime Runtime = new(); + internal static readonly RynthPluginRuntime Runtime = new(); + + // Typed interface for RynthAi (host GetPluginInterface, API v68): "RynthILT.Hub" v1, the ILT + // tabs and sections its Mini Remote hosts (Plugins/Shared/RynthIltHubApi.cs, HubInterface.cs). + // Fixed signature: void* (const char* iface, uint version). + [UnmanagedCallersOnly(EntryPoint = "RynthPluginQueryInterface", CallConvs = new[] { typeof(CallConvCdecl) })] + private static IntPtr QueryInterface(IntPtr ifaceAnsi, uint version) + { + try + { + string iface = ifaceAnsi == IntPtr.Zero ? "" : Marshal.PtrToStringAnsi(ifaceAnsi) ?? ""; + return HubInterface.Query(iface, version); + } + catch + { + return IntPtr.Zero; + } + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })] private static int Init(RynthCoreApiNative* api) => Runtime.Init(api); [UnmanagedCallersOnly(EntryPoint = "RynthPluginShutdown", CallConvs = new[] { typeof(CallConvCdecl) })] - public static void Shutdown() => Runtime.Shutdown(); + public static void Shutdown() + { + // An exception escaping an UnmanagedCallersOnly export fail-fasts the client under NativeAOT. + try { Runtime.Shutdown(); } catch { } + try { HubInterface.Release(); } catch { } + foreach (IntPtr p in new[] { Interlocked.Exchange(ref _bountiesPtr, IntPtr.Zero), Interlocked.Exchange(ref _progressionPtr, IntPtr.Zero), + Interlocked.Exchange(ref _statusPtr, IntPtr.Zero) }) + if (p != IntPtr.Zero) Marshal.FreeCoTaskMem(p); + } [UnmanagedCallersOnly(EntryPoint = "RynthPluginName", CallConvs = new[] { typeof(CallConvCdecl) })] public static IntPtr GetName() => RynthILTPlugin.NamePointer; @@ -37,6 +62,45 @@ public static unsafe class PluginExports public static void OnChatWindowText(IntPtr textUtf16, int chatType, IntPtr eatFlag) => Runtime.OnChatWindowText(textUtf16, chatType, eatFlag); + // The ILT Hub's floating windows (Games HUD, confirmations) in the engine's ImGui frame. + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRender", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void Render() => Runtime.OnRender(); + + /// The engine calls this instead of RynthPluginRender while its ImGui shell is off. + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderOverlay", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void RenderOverlay() + { + try { Runtime.Plugin?.OnRenderOverlay(); } + catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ } + } + + /// + /// Engine panels drawn by RynthILT (render thread): "guardian" is the engine's Guardian ILT + /// panel (RynthCore's GuardianFace); ":popout" is added when it is popped out into a window of + /// its own, and RynthILT draws in the engine's current context either way. The panel is + /// user-sized: want echoes the size given. 1 = drawn, 0 = not ready / unknown surface. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderEmbed", CallConvs = new[] { typeof(CallConvCdecl) })] + public static int RenderEmbed(byte* surface, float width, float height, float* wantWidth, float* wantHeight) + { + try + { + if (surface == null) return 0; + ReadOnlySpan name = MemoryMarshal.CreateReadOnlySpanFromNullTerminated(surface); + if (name.EndsWith(":popout"u8)) name = name[..^":popout"u8.Length]; + if (!name.SequenceEqual("guardian"u8)) return 0; + var plugin = Runtime.Plugin; + if (plugin == null || !plugin.RenderEmbeddedGuardian()) return 0; + if (wantWidth != null) *wantWidth = width; + if (wantHeight != null) *wantHeight = height; + return 1; + } + catch + { + return 0; + } + } + // "/ilt ..." commands, and noticing a /bounty the player typed (its reply is never eaten). [UnmanagedCallersOnly(EntryPoint = "RynthPluginOnChatBarEnter", CallConvs = new[] { typeof(CallConvCdecl) })] public static void OnChatBarEnter(IntPtr textUtf16, IntPtr eatFlag) @@ -79,6 +143,86 @@ public static unsafe class PluginExports catch { } } + // ── The ILT Hub for the engine (the Skills panel's Progression tab, IltInfo) ───────── + + private static IntPtr _progressionPtr = IntPtr.Zero; + + /// + /// The Skills panel's Progression tab (ILT augmentations / enlightenment / the attribute raiser), + /// as RynthAi's RynthPluginGetProgressionJson was: {"available":false} until the Hub exists and + /// off ILT. UTF-8; the previous reply stays valid until the next call. Engine pump thread only. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthILTGetProgressionJson", CallConvs = new[] { typeof(CallConvCdecl) })] + public static IntPtr GetProgressionJson() + { + try + { + string json = Runtime.Plugin?.Hub?.BuildProgressionJson() ?? "{\"available\":false}"; + return Utf8Swap(ref _progressionPtr, json); + } + catch { return IntPtr.Zero; } + } + + /// + /// One command from the engine (UTF-8): "prog ..." (the Progression tab's edits) or an ILT + /// "/ra" verb without "/ra" ("hub refresh", "guardian handin"). Engine pump thread. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthILTCommand", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void Command(IntPtr utf8Text) + { + try + { + if (utf8Text == IntPtr.Zero) return; + string? text = Marshal.PtrToStringUTF8(utf8Text); + if (string.IsNullOrWhiteSpace(text) || text.Length > 512) return; + Runtime.Plugin?.RunEngineCommand(text); + } + catch { } + } + + /// + /// (action, value) from the engine's plugin-command broker (Host.SendPluginCommand): "prog" with + /// the Progression tab's arguments (RynthAi forwards an older engine's "prog" here), or an ILT + /// verb. Copied and run on RynthILT's next tick. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthPluginApplyRemoteCommand", CallConvs = new[] { typeof(CallConvCdecl) })] + public static void ApplyRemoteCommand(IntPtr actionAnsi, IntPtr valueAnsi) + { + try + { + string action = actionAnsi != IntPtr.Zero ? (Marshal.PtrToStringAnsi(actionAnsi) ?? string.Empty) : string.Empty; + string value = valueAnsi != IntPtr.Zero ? (Marshal.PtrToStringAnsi(valueAnsi) ?? string.Empty) : string.Empty; + if (action.Length == 0 || action.Length + value.Length > 512) return; + Runtime.Plugin?.EnqueueRemoteCommand(action, value); + } + catch { } + } + + private static IntPtr _statusPtr = IntPtr.Zero; + + /// + /// What RynthILT knows about the world (UTF-8 JSON, previous reply valid until the next call): + /// {"loaded":true,"ilt":bool,"forced":bool,"available":bool,"world":"..."}. "ilt" is RynthILT's + /// own verdict (its server list or this character's "Treat this world as ILT"); the engine's + /// IltInfo adds it to its own detection. Engine pump thread. + /// + [UnmanagedCallersOnly(EntryPoint = "RynthILTGetStatusJson", CallConvs = new[] { typeof(CallConvCdecl) })] + public static IntPtr GetStatusJson() + { + try + { + var hub = Runtime.Plugin?.Hub; + string json = hub == null + ? "{\"loaded\":true,\"ilt\":false,\"forced\":false,\"available\":false,\"world\":\"\"}" + : "{\"loaded\":true,\"ilt\":" + (hub.Options.IsIltLikeWorld ? "true" : "false") + + ",\"forced\":" + (hub.ForceIltWorld ? "true" : "false") + + ",\"available\":" + (hub.Available ? "true" : "false") + + ",\"world\":\"" + RynthCore.Plugin.RynthILT.Hub.IltStyle.JsonEscape(hub.Options.WorldName) + "\"}"; + return Utf8Swap(ref _statusPtr, json); + } + catch { return IntPtr.Zero; } + } + private static IntPtr Utf8Swap(ref IntPtr slot, string json) { IntPtr newPtr = Marshal.StringToCoTaskMemUTF8(json); diff --git a/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj b/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj index 64e8661..db5c2d3 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj +++ b/Plugins/RynthCore.Plugin.RynthILT/RynthCore.Plugin.RynthILT.csproj @@ -1,10 +1,16 @@ net10.0-windows @@ -22,16 +28,61 @@ RynthCore.Plugin.RynthILT x86 + highest API use NOT behind a Has*/version check. Nothing above the v66 baseline: every + newer call (plugin interfaces v68, live object ids v69, vendor trade v67, ...) is behind + its Has* check, as it was in RynthAi. --> 66 - Infinite Leaftide (ACECustom) features: the Bounties window. + Infinite Leaftide (ACECustom) features: the ILT Hub (the Mini Remote's ILT tabs: banking, gear, charms, games), the Guardian, bounties, progression and the attribute raiser. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs index 34dff8e..903c6e9 100644 --- a/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs +++ b/Plugins/RynthCore.Plugin.RynthILT/RynthILTPlugin.cs @@ -1,18 +1,30 @@ // RynthILTPlugin.cs - Infinite Leaftide (ACECustom) features, kept out of RynthAi and the engine core. // -// The engine shows RynthILT's panels only on ILT (RynthCore Compatibility/IltInfo.cs: the bar's ILT -// button, /rc bounties). First feature: the Bounties window's tracker (Bounty/BountyTracker.cs). -// Its reads run only while that window polls RynthILTGetBountiesJson, and the engine polls only on -// ILT, so on any other server this plugin sends nothing. +// Two features, both shown only on ILT: +// * Bounties (Bounty/BountyTracker.cs): the engine's Bounties window (the bar's ILT button, +// /rc bounties). Its reads run only while that window polls RynthILTGetBountiesJson, and the +// engine polls only on ILT. +// * The ILT Hub (Hub/, SilentKelpie's, moved here from RynthAi 2026-10-13): the Mini Remote's +// ILT tabs (Character, Banking, Gear, Charms, Games; RynthAi's Mini Remote hosts them through +// RynthILT.Hub, HubInterface.cs), their sections in its Quests / Pets / Remote tabs, the +// Guardian panel (RynthPluginRenderEmbed "guardian"), the Skills panel's Progression data +// (RynthILTGetProgressionJson, "prog ..." through RynthILTCommand), server feature detection. +// Every feature stays dormant off an ILT-like world (IltServerOptions: no probes, no chat). // // Threads: OnTick, OnChatWindowText, OnKillNotification, login/logout and the engine's export calls // run on the plugin pump. OnChatBarEnter runs on AC's main thread (the engine's dispatcher queues it -// there, our own InvokeChatParser too), so it only queues. +// there, our own InvokeChatParser too), and RynthAi forwards its "/ra hub ..." verbs from there too, +// so commands only queue and run on the next tick. OnRender / RenderEmbed and the RynthILT.Hub +// render functions run on the render thread and only read what the pump built. using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; +using ImGuiNET; using RynthCore.Plugin.RynthILT.Bounty; +using RynthCore.Plugin.RynthILT.Hub; +using RynthCore.Plugin.Shared; using RynthCore.PluginCore; namespace RynthCore.Plugin.RynthILT; @@ -20,7 +32,7 @@ namespace RynthCore.Plugin.RynthILT; public sealed class RynthILTPlugin : RynthPluginBase { internal static readonly IntPtr NamePointer = Marshal.StringToHGlobalAnsi("RynthILT"); - internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.1.0"); + internal static readonly IntPtr VersionPointer = Marshal.StringToHGlobalAnsi("0.2.0"); /// Wait this long after login for the character's name before tracking without a save file. private const long NameWaitMs = 30_000; @@ -29,19 +41,50 @@ public sealed class RynthILTPlugin : RynthPluginBase private bool _loginComplete; private long _loginAtMs; private long _nextNameTryMs; + private long _nextHubTryMs; private BountyTracker? _bounties; + private IltHubController? _hub; + // An unfinished copy from RynthAi (IltMigration pending): the Hub writes nothing for this + // character and the copy is retried every MigrationRetryMs; once it works the Hub restarts on + // the copied files. + private const long MigrationRetryMs = 120_000; + private volatile bool _hubWritesBlocked; + private long _nextMigrationRetryMs; + private string _hubFolder = string.Empty, _hubWorld = string.Empty, _hubChar = string.Empty; + private bool _forceOnRestart; + private RynthAiClient? _ai; + private IltSettings _settings = new(); - // "/ilt ..." lines from OnChatBarEnter, run on the next tick. + // "/ilt ..." lines from OnChatBarEnter and RynthAi's forwarded "/ra" verbs, run on the next tick. private readonly ConcurrentQueue _commands = new(); // "/bounty ..." lines from OnChatBarEnter (typed by the player, or our own coming back through // the engine's dispatcher), passed to the tracker before the next chat line or tick. private readonly ConcurrentQueue _typedBounty = new(); + // Engine / plugin commands (RynthPluginApplyRemoteCommand: "prog ..." from RynthAi or an older engine). + private readonly ConcurrentQueue _engineCommands = new(); /// The Bounties window's tracker (PluginExports); null until login. internal BountyTracker? Bounties => _bounties; + /// The ILT Hub for the logged-in character (HubInterface, PluginExports); null until its name is known. + internal IltHubController? Hub => _hub; + public override int Initialize() { + RynthLog.Init(Host); + // The Hub's windows and RynthAi-hosted tabs draw through the engine's cimgui module. + ImGuiNativeBinding.Ensure(msg => RynthLog.Write(LogCat.IltHub, msg)); + // Every use goes through Host.UseFor (Plugins/Shared/UseAudit.cs): one log line each. + UseAudit.Reset("RynthILT", null); + // Saves (Hub state, bank log, profiles, settings, bounty list, the copies from RynthAi) say + // when they fail and why (Plugins/Shared/DataWriteGuard.cs): always in the log, in chat + // once per folder, and only on an ILT world (PostDataWriteProblems). + DataWriteGuard.Reset(); + DataWriteGuard.PluginName = "RynthILT"; + DataWriteGuard.LogSink = msg => RynthLog.Write(LogCat.IltStore, + msg.StartsWith("[RynthILT] ", StringComparison.Ordinal) ? msg.Substring(11) : msg); + _ai = new RynthAiClient(Host); + _settings = IltSettingsStore.Load(); Host.Log("[RynthILT] Plugin initialized."); return 0; } @@ -50,37 +93,74 @@ public sealed class RynthILTPlugin : RynthPluginBase public override void OnLoginComplete() { SaveBounties(); + StopHub(); _bounties = null; _loginComplete = true; _loginAtMs = Environment.TickCount64; _nextNameTryMs = 0; + _nextHubTryMs = 0; + _ai?.Reset(); TryStartBounties(); + TryStartHub(); } public override void OnLogout() { SaveBounties(); _bounties = null; + StopHub(); + _ai?.Reset(); _loginComplete = false; while (_commands.TryDequeue(out _)) { } while (_typedBounty.TryDequeue(out _)) { } } - // Plugin unload (hot reload, update, client closing): keep the list for the next copy. - public override void Shutdown() => SaveBounties(); + // Plugin unload (hot reload, update, client closing): keep the list and the Hub state for the next copy. + public override void Shutdown() + { + SaveBounties(); + StopHub(); + HubInterface.Release(); + RynthLog.Shutdown(); + } public override void OnTick() { + try { RynthLog.Pump(); } catch { } if (!_loginComplete) return; + _ai?.Tick(); if (_bounties == null) TryStartBounties(); + if (_hub == null) TryStartHub(); DrainTypedBounty(); while (_commands.TryDequeue(out string[]? parts)) RunCommand(parts); + while (_engineCommands.TryDequeue(out string? engineCommand)) RunEngineCommand(engineCommand); _bounties?.Tick(); + try { _hub?.Tick(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "Tick"); } + RetryPendingMigration(); + PostDataWriteProblems(); + } + + /// + /// The save failures queued by DataWriteGuard, in chat once the Hub knows this is an ILT world + /// (or "Treat this world as ILT"). Off ILT they stay in the log only: nothing ILT shows there. + /// + private void PostDataWriteProblems() + { + if (DataWriteGuard.PendingCount == 0 || _hub?.OffersTabs != true || !Host.HasWriteToChat) return; + DataWriteGuard.DrainChat(line => Host.WriteToChat(line, 2)); } public override void OnChatWindowText(string? text, int chatType, ref int eat) { - if (_bounties == null || string.IsNullOrEmpty(text)) return; + if (string.IsNullOrEmpty(text)) return; + try + { + // The Hub eats its own probe / capture replies (IltChatCapture). + if (_hub?.OnChat(text) == true) eat = 1; + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnChat"); } + if (_bounties == null) return; DrainTypedBounty(); try { @@ -119,24 +199,217 @@ public sealed class RynthILTPlugin : RynthPluginBase _bounties?.NoteTypedCommand(typed); } + // ── Rendering (render thread) ──────────────────────────────────────────── + + /// The Hub's floating extras (Games HUD, confirmations) in the engine's ImGui frame. + public override void OnRender() + { + var hub = _hub; + if (!_loginComplete || hub == null || Host.ImGuiContext == IntPtr.Zero) return; + IntPtr previous = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(Host.ImGuiContext); + try { hub.Render(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnRender"); } + finally { ImGui.SetCurrentContext(previous); } + } + + /// The same while the engine's ImGui shell is off (RynthPluginRenderOverlay), in the dashboard colours. + internal void OnRenderOverlay() + { + var hub = _hub; + if (!_loginComplete || hub == null || Host.ImGuiContext == IntPtr.Zero) return; + IntPtr previous = ImGui.GetCurrentContext(); + ImGui.SetCurrentContext(Host.ImGuiContext); + int pushed = IltStyle.PushDashboardStyle(); + try { hub.Render(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "OnRenderOverlay"); } + finally + { + ImGui.PopStyleColor(pushed); + ImGui.SetCurrentContext(previous); + } + } + + /// + /// RynthPluginRenderEmbed "guardian": the Temple guardian tools inside RynthCore's Guardian + /// panel (the bar's ILT button), drawn into the engine's current ImGui window and context + /// (a popped-out panel has its own context, not Host.ImGuiContext; switching to the main one + /// there crashed the client, 2026-10-11). False (nothing drawn) until login and the Hub exist. + /// + internal bool RenderEmbeddedGuardian() + { + var hub = _hub; + if (!_loginComplete || hub == null || Host.ImGuiContext == IntPtr.Zero) return false; + IntPtr previous = ImGui.GetCurrentContext(); + if (previous == IntPtr.Zero) ImGui.SetCurrentContext(Host.ImGuiContext); + int pushed = IltStyle.PushDashboardStyle(); + try + { + hub.RenderGuardianPanel(); + return true; + } + catch (Exception ex) + { + RynthLog.Exception(LogCat.IltHub, ex, "RenderEmbeddedGuardian"); + return false; + } + finally + { + ImGui.PopStyleColor(pushed); + if (previous == IntPtr.Zero) ImGui.SetCurrentContext(previous); + } + } + // ── Commands ───────────────────────────────────────────────────────────── + /// + /// RynthILT.Hub Command: an ILT "/ra" verb RynthAi forwards ("hub bank", "guardian handin", + /// "bounty show", "rates reset"). Decides at once whether it is ours (RynthAi answers the rest) + /// and queues it for the next tick. Any thread. + /// + internal bool RunForwardedCommand(string line) + { + string[] words = line.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (words.Length == 0 || !IsIltVerb(words)) return false; + var parts = new string[words.Length + 1]; + parts[0] = "/ra"; + Array.Copy(words, 0, parts, 1, words.Length); + _commands.Enqueue(parts); + return true; + } + + /// + /// The verbs RynthILT answers: the ILT "/ra hub" verbs (not RynthAi's Quests / Pets tabs or its + /// Remote tab), "/ra guardian", "/ra bounty|bounties|bountys" and "rates". + /// + internal static bool IsIltVerb(string[] words) + { + string verb = words[0].ToLowerInvariant(); + switch (verb) + { + case "guardian": case "bounty": case "bounties": case "bountys": case "rates": + return true; + case "hub": + if (words.Length < 2) return false; // "/ra hub" alone toggles RynthAi's Mini Remote + string sub = words[1].ToLowerInvariant(); + if (sub is "open") + return words.Length < 3 || !IltSections.IsUniversalTabName(words[2]); + if (sub is "tab") + return words.Length >= 3 && IltSections.TryParse(words[2], out IltSection t) && IltSections.IsTab(t); + return true; + default: + return false; + } + } + private void RunCommand(string[] parts) { + // RynthAi's forwarded "/ra ..." and "/ilt hub|guardian|bounty ..." reach the Hub alike. + bool fromRa = parts.Length > 0 && parts[0].Equals("/ra", StringComparison.OrdinalIgnoreCase); string verb = parts.Length >= 2 ? parts[1].ToLowerInvariant() : "help"; + string[] args = parts.Length > 2 ? parts[2..] : Array.Empty(); + + if (!fromRa && (verb == "bounty" || verb == "bounties" || verb == "bountys")) + { + // "/ilt bounty [list|refresh]": the tracker's own chat commands ("/ra bounty" opens the window). + if (_bounties == null) ChatLine("[RynthILT] Bounties not ready (not logged in yet)."); + else _bounties.HandleChatCommand(parts); + return; + } switch (verb) { + case "trace": HandleTrace(args); return; + case "debug": + RynthLog.DebugToChat = args.Length > 0 ? args[0].Equals("on", StringComparison.OrdinalIgnoreCase) : !RynthLog.DebugToChat; + ChatLine($"[RynthILT] Debug-to-chat is {(RynthLog.DebugToChat ? "ON" : "off")} (traced: {RynthLog.TracedList()})."); + return; + case "servers": + verb = "hub"; + args = Prepend("servers", args); + break; case "bounty": case "bounties": case "bountys": - if (_bounties == null) ChatLine("[RynthILT] Bounties not ready (not logged in yet)."); - else _bounties.HandleChatCommand(parts); + case "guardian": + case "hub": + case "rates": break; + case "help": + ChatLine("[RynthILT] /ilt hub ... (the Mini Remote's ILT tabs; same as /ra hub ...), /ilt guardian ..., /ilt servers [list||default],"); + ChatLine("[RynthILT] /ilt bounty [list|refresh] - the tracked ACECustom bounties (the Bounties window: the ILT button on the RynthCore bar, or /rc bounties),"); + ChatLine("[RynthILT] /ilt trace [on|off], /ilt debug [on|off]."); + return; default: - ChatLine("[RynthILT] /ilt bounty [list|refresh] - the tracked ACECustom bounties. " - + "The Bounties window: the ILT button on the RynthCore bar, or /rc bounties."); + // "/ilt bank", "/ilt attr run", ...: the Hub's verbs without "hub". + args = Prepend(verb, args); + verb = "hub"; break; } + if (_hub == null) + { + ChatLine("[RynthILT] ILT features not ready (log in first)."); + return; + } + try + { + if (!_hub.HandleCommand(verb, args)) + ChatLine($"[RynthILT] Unknown command: {string.Join(" ", parts)}. /ilt help"); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "command"); } + } + + private static string[] Prepend(string first, string[] rest) + { + var a = new string[rest.Length + 1]; + a[0] = first; + Array.Copy(rest, 0, a, 1, rest.Length); + return a; + } + + /// "/ilt trace <category|all|list> [on|off]". + private void HandleTrace(string[] args) + { + string target = args.Length > 0 ? args[0] : "list"; + bool on = args.Length < 2 || !args[1].Equals("off", StringComparison.OrdinalIgnoreCase); + if (target.Equals("list", StringComparison.OrdinalIgnoreCase) || target.Equals("status", StringComparison.OrdinalIgnoreCase)) + { + ChatLine($"[RynthILT] Traced: {RynthLog.TracedList()}. Categories: {string.Join(", ", Enum.GetNames())}. Log folder: {RynthLog.Directory}"); + return; + } + if (target.Equals("all", StringComparison.OrdinalIgnoreCase) || target.Equals("ilt", StringComparison.OrdinalIgnoreCase)) + { + int n = RynthLog.SetTracingAll(on); + ChatLine($"[RynthILT] Tracing {(on ? "enabled" : "disabled")} for {n} categories."); + return; + } + if (!RynthLog.TryParseCategory(target, out LogCat cat)) + { + ChatLine($"[RynthILT] Unknown trace category '{target}'. /ilt trace list"); + return; + } + RynthLog.SetTracing(cat, on); + ChatLine($"[RynthILT] Trace {cat}: {(on ? "ON" : "off")}"); + } + + /// RynthILTCommand: "prog ..." (the Skills panel's Progression tab) and the Hub verbs, from the engine. Pump thread. + internal void RunEngineCommand(string text) + { + string[] words = text.Split(' ', StringSplitOptions.RemoveEmptyEntries); + if (words.Length == 0) return; + if (words[0].Equals("prog", StringComparison.OrdinalIgnoreCase)) + { + if (_hub == null) { ChatLine("[RynthILT] ILT features not ready (log in first)."); return; } + try { _hub.Progression.HandleRemote(words[1..]); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltProgression, ex, "prog command"); } + return; + } + if (IsIltVerb(words)) RunForwardedCommand(text); + } + + /// RynthPluginApplyRemoteCommand (any thread): "prog" + its arguments, or an ILT verb; run on the next tick. + internal void EnqueueRemoteCommand(string action, string value) + { + if (_engineCommands.Count < 64) _engineCommands.Enqueue((action + " " + value).Trim()); } private void ChatLine(string text) @@ -144,6 +417,102 @@ public sealed class RynthILTPlugin : RynthPluginBase if (Host.HasWriteToChat) Host.WriteToChat(text, 1); } + // ── The ILT Hub ────────────────────────────────────────────────────────── + + /// + /// Starts the Hub once the character's name is known (its files are per character). The first + /// time a character logs in with RynthILT its RynthAi ILT Hub files are copied over (IltMigration). + /// + private void TryStartHub() + { + long now = Environment.TickCount64; + if (now < _nextHubTryMs || _hub != null || _ai == null) return; + _nextHubTryMs = now + NameRetryMs; + + uint me = Host.GetPlayerId(); + if (me == 0 || !Host.HasGetObjectName || !Host.TryGetObjectName(me, out string charName) || string.IsNullOrWhiteSpace(charName)) + return; + string world = Host.HasGetWorldName && Host.TryGetWorldName(out string w) && !string.IsNullOrWhiteSpace(w) ? w.Trim() : string.Empty; + string folder = CharacterFolder(world, charName); + bool force = false; + try + { + var lines = new List(IltMigration.MigrateShared(_settings, SettingsRoot)); + lines.AddRange(IltMigration.MigrateCharacter(folder, world, charName, _settings, out force)); + if (lines.Count > 0) + { + IltSettingsStore.Save(_settings); + RynthLog.Write(LogCat.IltStore, $"Carried the ILT Hub's saved data over from RynthAi for {charName}: {string.Join(", ", lines)}."); + } + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, "migration"); } + + force |= _forceOnRestart; + _forceOnRestart = false; + bool pending = IltMigration.IsPending(_settings, folder); + _hubWritesBlocked = pending; + _hubFolder = folder; + _hubWorld = world; + _hubChar = charName; + _nextMigrationRetryMs = now + MigrationRetryMs; + if (pending) + RynthLog.Write(LogCat.IltStore, $"{charName}'s Hub data isn't all copied from RynthAi yet: the Hub saves nothing for this character " + + "until it is (read from RynthAi's files where it can; retried every 2 minutes and at each login)."); + try + { + _hub = new IltHubController(Host, folder, _settings, _ai, () => _hubWritesBlocked, + pending ? IltMigration.FindLegacyCharFolder(world, charName) : null); + _hub.OnLoginComplete(charName, force); + } + catch (Exception ex) + { + _hub = null; + RynthLog.Exception(LogCat.IltHub, ex, "start"); + } + } + + /// + /// Pump: while this character's copy from RynthAi is unfinished, tries it again every + /// MigrationRetryMs. When it completes the Hub is stopped (still writing nothing, so the copied + /// files stay as they are) and started again on them. + /// + private void RetryPendingMigration() + { + if (_hub == null || !_hubWritesBlocked) return; + long now = Environment.TickCount64; + if (now < _nextMigrationRetryMs) return; + _nextMigrationRetryMs = now + MigrationRetryMs; + try + { + var lines = IltMigration.MigrateCharacter(_hubFolder, _hubWorld, _hubChar, _settings, out bool force); + if (lines.Count > 0) + { + IltSettingsStore.Save(_settings); + RynthLog.Write(LogCat.IltStore, $"Retried copying {_hubChar}'s ILT Hub data from RynthAi: {string.Join(", ", lines)}."); + } + if (IltMigration.IsPending(_settings, _hubFolder)) return; + _forceOnRestart = force; + StopHub(); // _hubWritesBlocked is still true: the logout save writes nothing + _nextHubTryMs = 0; + TryStartHub(); // loads the copied files; saves from now on + RynthLog.Write(LogCat.IltStore, $"{_hubChar}'s ILT Hub data is copied; the Hub restarted on it."); + } + catch (Exception ex) { RynthLog.Exception(LogCat.IltStore, ex, "migration retry"); } + } + + private void StopHub() + { + var hub = _hub; + _hub = null; + if (hub == null) return; + try { hub.OnLogout(); } + catch (Exception ex) { RynthLog.Exception(LogCat.IltHub, ex, "logout"); } + } + + /// %APPDATA%\RynthCore\RynthILT\{world}\{character} (the bounty list's folder too). + internal static string CharacterFolder(string world, string charName) + => Path.Combine(SettingsRoot, SafeName(world.Length > 0 ? world : "UnknownWorld"), SafeName(charName)); + // ── Bounties ───────────────────────────────────────────────────────────── /// Starts the tracker once the character's name is known (its save file is per character). diff --git a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs b/Plugins/Shared/DataWriteGuard.cs similarity index 89% rename from Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs rename to Plugins/Shared/DataWriteGuard.cs index f03c5ae..9f02f57 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/Diagnostics/DataWriteGuard.cs +++ b/Plugins/Shared/DataWriteGuard.cs @@ -2,9 +2,9 @@ using System; using System.Collections.Generic; using System.IO; -namespace RynthCore.Plugin.RynthAi.Diagnostics; +namespace RynthCore.Plugin.Shared; -/// Why a write in RynthAi's data folders failed (see ). +/// Why a write in a plugin's data folders failed (see ). internal enum WriteFailureKind { /// Windows refused: the folder or file isn't writable for this account, or Controlled folder access blocked acclient.exe. @@ -22,7 +22,9 @@ internal enum WriteFailureKind } /// -/// Saves of metas, navs, loot profiles and settings profiles (2026-10-13). Players reported +/// Saves of metas, navs, loot profiles and settings profiles (2026-10-13; RynthAi, and RynthILT for +/// its own files and the copies it migrates from RynthAi; linked into each, so each plugin keeps +/// its own state and says its own name: ). Players reported /// that metas and navs "don't save" and that "the plugin folders are read only": every one of /// those saves swallowed its exception, so a folder the client can't write looked like a save /// that silently did nothing. Now: @@ -50,6 +52,12 @@ internal static class DataWriteGuard private static readonly Dictionary LastLog = new(StringComparer.OrdinalIgnoreCase); private static readonly Queue PendingChat = new(); + /// The plugin's name in chat and log lines ("[RynthAi] ..."); Initialize sets it. + public static string PluginName = "RynthAi"; + + /// What the startup self-check says won't be kept when a folder can't be written. + public static string DataDescription = "Metas, navs, loot and settings"; + /// The plugin's log (Initialize sets it). Null: nothing is logged. public static Action? LogSink; @@ -98,7 +106,7 @@ internal static class DataWriteGuard FileAttributes a = File.GetAttributes(path); if ((a & FileAttributes.ReadOnly) == 0) return false; File.SetAttributes(path, a & ~FileAttributes.ReadOnly); - Log($"[RynthAi] {path} was marked read-only; cleared that so it can be saved."); + Log($"[{PluginName}] {path} was marked read-only; cleared that so it can be saved."); return true; } catch @@ -192,7 +200,7 @@ internal static class DataWriteGuard WriteFailureKind.AccessDenied => "access denied (Windows doesn't let this game client write there: the folder's permissions, " + "or Windows Security's Controlled folder access blocking acclient.exe)", - WriteFailureKind.ReadOnlyFile => "the file is marked read-only and RynthAi couldn't clear that", + WriteFailureKind.ReadOnlyFile => $"the file is marked read-only and {PluginName} couldn't clear that", WriteFailureKind.InUse => "the file is open in another program (an editor, OneDrive or backup sync, antivirus)", WriteFailureKind.DiskFull => "the disk is full", WriteFailureKind.CloudProvider => "the folder is synced by OneDrive (or another cloud app) that isn't running", @@ -230,7 +238,7 @@ internal static class DataWriteGuard if (!LastLog.TryGetValue(folder, out var last) || now - last.At >= LogThrottleMs || chat) { string skipped = last.Skipped > 0 ? $" ({last.Skipped} more failure(s) in this folder since the last line)" : ""; - logLine = $"[RynthAi] Save failed: {what} -> {path}: {reason} [{ex.GetType().Name}: {ex.Message}]{skipped}"; + logLine = $"[{PluginName}] Save failed: {what} -> {path}: {reason} [{ex.GetType().Name}: {ex.Message}]{skipped}"; LastLog[folder] = (now, 0); } else @@ -238,7 +246,7 @@ internal static class DataWriteGuard LastLog[folder] = (last.At, last.Skipped + 1); } if (chat && !callerShows) - PendingChat.Enqueue($"[RynthAi] Couldn't save {what} to {path}: {reason}. {Hint(kind)} " + + PendingChat.Enqueue($"[{PluginName}] Couldn't save {what} to {path}: {reason}. {Hint(kind)} " + "(Shown once per folder; later failures there go to the log.)"); } if (logLine != null) Log(logLine); @@ -259,7 +267,7 @@ internal static class DataWriteGuard foreach (string folder in folders) { if (string.IsNullOrEmpty(folder)) continue; - string probe = Path.Combine(folder, $".rynthai-write-check-{Environment.ProcessId}-{Guid.NewGuid():N}.tmp"); + string probe = Path.Combine(folder, $".{PluginName.ToLowerInvariant()}-write-check-{Environment.ProcessId}-{Guid.NewGuid():N}.tmp"); try { Directory.CreateDirectory(folder); @@ -270,7 +278,7 @@ internal static class DataWriteGuard { WriteFailureKind kind = Classify(ex, null); problems.Add(new FolderProblem(folder, kind, Describe(kind, ex))); - Log($"[RynthAi] Data folder not writable: {folder}: {Describe(kind, ex)} [{ex.GetType().Name}: {ex.Message}]"); + Log($"[{PluginName}] Data folder not writable: {folder}: {Describe(kind, ex)} [{ex.GetType().Name}: {ex.Message}]"); } finally { @@ -286,7 +294,7 @@ internal static class DataWriteGuard string list = problems.Count == 1 ? problems[0].Folder : $"{problems.Count} folders ({string.Join(", ", problems.ConvertAll(p => Path.GetFileName(p.Folder)))})"; - PendingChat.Enqueue($"[RynthAi] Can't write to {list}: {problems[0].Reason}. Metas, navs, loot and settings " + + PendingChat.Enqueue($"[{PluginName}] Can't write to {list}: {problems[0].Reason}. {DataDescription} " + $"saved there will NOT be kept. {Hint(problems[0].Kind)}"); } } diff --git a/Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs b/Plugins/Shared/ImGuiNativeBinding.cs similarity index 70% rename from Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs rename to Plugins/Shared/ImGuiNativeBinding.cs index 9d75b96..28f96f1 100644 --- a/Plugins/RynthCore.Plugin.RynthAi/ImGuiNativeBinding.cs +++ b/Plugins/Shared/ImGuiNativeBinding.cs @@ -1,16 +1,18 @@ // ImGuiNativeBinding.cs - Binds ImGui.NET's "cimgui" P/Invokes to the cimgui module the -// engine already loaded. +// engine already loaded. Linked into every plugin that draws with ImGui.NET (RynthAi, RynthILT). // // The engine ships its own build as RynthCore.cimgui.dll. Without this resolver, Windows -// resolves "cimgui" to a separate cimgui.dll: a second ImGui instance whose windows (ILT Hub, -// Pets, Quests, Mini Remote, Item HUD) are built but never reach the engine's draw data. +// resolves "cimgui" to a separate cimgui.dll: a second ImGui instance whose windows (the Mini +// Remote, its tabs, the Item HUD) are built but never reach the engine's draw data. Both +// plugins bound to the one module share its current context, so one can draw inside a window +// the other has begun (RynthILT's tabs inside RynthAi's Mini Remote). using System; using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using ImGuiNET; -namespace RynthCore.Plugin.RynthAi; +namespace RynthCore.Plugin.Shared; internal static class ImGuiNativeBinding { @@ -19,18 +21,21 @@ internal static class ImGuiNativeBinding private static int _configured; // 1 once the resolver is registered (survives DLL-copy reuse) private static int _resolvedLogged; + private static Action? _log; /// /// Registers the resolver. Call before the first ImGui call (Initialize). The resolver can be /// set only once per assembly, so later calls (a reused plugin DLL copy) are no-ops. + /// gets one line when the resolver is registered and one when it binds. /// - public static void Ensure() + public static void Ensure(Action? log = null) { + if (log != null) _log = log; if (Interlocked.Exchange(ref _configured, 1) != 0) return; try { NativeLibrary.SetDllImportResolver(typeof(ImGui).Assembly, Resolve); - RynthLog.Write(LogCat.UI, "[ImGui] native resolver registered (prefers the engine's " + EngineModule + ")."); + Log("[ImGui] native resolver registered (prefers the engine's " + EngineModule + ")."); } catch (InvalidOperationException) { @@ -38,10 +43,16 @@ internal static class ImGuiNativeBinding } catch (Exception ex) { - RynthLog.Exception(LogCat.UI, ex, "ImGuiNativeBinding.Ensure"); + Log($"[ImGui] ImGuiNativeBinding.Ensure failed: {ex.GetType().Name}: {ex.Message}"); } } + private static void Log(string message) + { + try { _log?.Invoke(message); } + catch { } + } + /// Runs on the first cimgui P/Invoke: the engine's module, else whatever cimgui.dll is loaded. private static IntPtr Resolve(string libraryName, Assembly assembly, DllImportSearchPath? searchPath) { @@ -58,7 +69,7 @@ internal static class ImGuiNativeBinding } if (Interlocked.Exchange(ref _resolvedLogged, 1) == 0) - RynthLog.Write(LogCat.UI, module != IntPtr.Zero + Log(module != IntPtr.Zero ? $"[ImGui] cimgui bound to loaded {bound} (0x{module.ToInt64():X})." : "[ImGui] no loaded cimgui module found; falling back to the default DLL search."); return module; // IntPtr.Zero = default resolution diff --git a/Plugins/Shared/RynthAiHubApi.cs b/Plugins/Shared/RynthAiHubApi.cs new file mode 100644 index 0000000..77de45d --- /dev/null +++ b/Plugins/Shared/RynthAiHubApi.cs @@ -0,0 +1,128 @@ +// ============================================================================ +// RynthSuite - Plugins/Shared/RynthAiHubApi.cs +// The "RynthAi.Hub" interface: what RynthILT (the Infinite Leaftide features) +// borrows from RynthAi. The Mini Remote that hosts the ILT tabs, the /myquests +// tracker (the Temple attribute tracker reads its flags), spell names (the dispel +// keeper), VTank loot-profile matching (equipment suits) and the VTank .usd +// importer (which edits RynthAi's own rules; drawn in RynthILT's Gear tab), and the +// Mini Remote's session stats (the Character tab's rates count the same session). +// Compiled into both plugins (linked source), so the layout can't drift. +// +// Rules: as RynthILT.Hub (Shared/RynthIltHubApi.cs): append-only, UTF-8 strings, +// each function says its thread, no exception crosses, the table lives as long as +// the RynthAi copy (never freed; Version 0 after Shutdown), callers re-query. +// RynthILT works without RynthAi: every feature that needs it says so. +// ============================================================================ + +using System.Runtime.InteropServices; + +namespace RynthCore.Plugin.Shared; + +/// Constants of the "RynthAi.Hub" interface. +public static class RynthAiHub +{ + /// The providing plugin's display name. + public const string PluginName = "RynthAi"; + + /// RenderSection: the VTank .usd settings importer (RynthAi's monster / weapon / consumable rules). + public const string SectionVTankImport = "vtank-import"; +} + +/// One /myquests flag as RynthAi's quest tracker has it. Blittable. +[StructLayout(LayoutKind.Sequential)] +public struct QuestFlagV1 +{ + public int Solves; + /// -1 unlimited (as the server prints it). + public int MaxSolves; + /// Last completion, UTC ticks (DateTime.Ticks); 0 = never / unknown. + public long CompletedOnUtcTicks; + /// Repeat time in seconds (0 = none). + public long RepeatSeconds; +} + +/// The quest tracker's state. Blittable. +[StructLayout(LayoutKind.Sequential)] +public struct QuestStatusV1 +{ + /// 1 when the server said /myquests is disabled. + public int Disabled; + /// Flags cached. + public int Count; + /// Bumped each time a refresh ends (0 = none yet this session). + public int Generation; + /// 1 while a refresh is running. + public int Refreshing; +} + +/// The Mini Remote's session stats (RynthTracker's SessionStats code). Blittable. +[StructLayout(LayoutKind.Sequential)] +public struct SessionStatsV1 +{ + /// Session start, UTC ticks (DateTime.Ticks); 0 = no session yet. + public long StartUtcTicks; + public double SessionSeconds; + public long Xp; + public double XpPerHour; + public long Lum; + public double LumPerHour; + public long LumLast5Min; + /// 1 when the pass-up figures below are tracked. + public int PassUpTracked; + public long LumPassUp; + public double PassUpPerHour; + public long Kills; + public double KillsPerHour; +} + +[StructLayout(LayoutKind.Sequential)] +public unsafe struct RynthAiHubApiV1 +{ + public const string InterfaceName = "RynthAi.Hub"; + public const uint InterfaceVersion = 1; + + public uint Version; // InterfaceVersion of the table RynthAi filled; 0 once it has shut down + public uint StructSize; // sizeof(RynthAiHubApiV1) as RynthAi built it + + /// + /// MiniRemoteTab(tabId, mode, reply, replyCapacity): puts the Mini Remote on a tab (tabId "" = + /// its Remote tab; mode "show" / "hide" / "toggle", or "select" to switch tabs without showing + /// it). Writes the chat-ready reply (UTF-8, truncated to capacity). 1 = done, 0 = no Mini Remote + /// yet (before login). Any thread. + /// + public delegate* unmanaged[Cdecl] MiniRemoteTab; + + /// MiniRemoteVisible(): 1 while the Mini Remote is on screen. Any thread. + public delegate* unmanaged[Cdecl] MiniRemoteVisible; + + /// QuestFlag(key, flag): 1 and the flag filled when /myquests has it (case-insensitive key). Pump thread. + public delegate* unmanaged[Cdecl] QuestFlag; + + /// QuestStatus(status): fills the tracker state; 0 when there is no tracker (before login). Pump thread. + public delegate* unmanaged[Cdecl] QuestStatus; + + /// + /// QuestRefresh(reply, replyCapacity): a quiet /myquests refresh, with the Quests tab's one-a-minute + /// cooldown. Writes what happened ("Refreshing quests...", "Wait 40s ..."). 1 = sent. Pump thread. + /// + public delegate* unmanaged[Cdecl] QuestRefresh; + + /// SpellName(spellId, buffer, capacity): the spell's name from RynthAi's spell table; its length, 0 unknown. Any thread. + public delegate* unmanaged[Cdecl] SpellName; + + /// + /// LootKeeps(utlPath, ids, count, keep, error, errorCapacity): evaluates the VTank loot profile at + /// utlPath (.utl) against each object id; keep[i] = 1 when that item's first matching rule is Keep. + /// 1 = evaluated; 0 = the profile couldn't be read (error says why). Pump thread. + /// + public delegate* unmanaged[Cdecl] LootKeeps; + + /// RenderSection(id): draws a RynthAiHub.Section* into the current window; 1 = drawn. Render thread. + public delegate* unmanaged[Cdecl] RenderSection; + + /// SessionStats(stats): the Mini Remote's session (XP, luminance, kills); 0 before login. Any thread. + public delegate* unmanaged[Cdecl] SessionStats; + + /// SessionReset(): starts the Mini Remote's session over (as its Reset XP button). Any thread. + public delegate* unmanaged[Cdecl] SessionReset; +} diff --git a/Plugins/Shared/RynthIltHubApi.cs b/Plugins/Shared/RynthIltHubApi.cs new file mode 100644 index 0000000..75b4631 --- /dev/null +++ b/Plugins/Shared/RynthIltHubApi.cs @@ -0,0 +1,118 @@ +// ============================================================================ +// RynthSuite - Plugins/Shared/RynthIltHubApi.cs +// The "RynthILT.Hub" interface: RynthILT's Infinite Leaftide features as RynthAi's +// Mini Remote shows them. The Mini Remote stays RynthAi's (its window, tab bar, +// Remote tab, Quests and Pets tabs); RynthILT supplies the ILT tabs (Character, +// Banking, Gear, Charms, Games), a few ILT sections drawn inside RynthAi's +// surfaces, the server's ILT feature bits and the "/ra hub ..." ILT verbs. +// Compiled into both plugins (linked source), so the layout can't drift. +// +// Rules (as the RynthAi.* interfaces, Shared/RynthAiScriptApi.cs): +// - Append-only: new functions go at the end, and Version goes up. +// - Strings are UTF-8, NUL-terminated. +// - Threads: each function says where it may be called. The render-thread ones +// draw into the caller's current ImGui window and context (the engine's cimgui, +// shared by both plugins). +// - Every function returns safely (no exception crosses the boundary), and returns +// 0 / "unknown" once RynthILT has shut down. +// - The table is allocated once per loaded copy of RynthILT and never freed: its +// functions stay callable from the render thread while plugins shut down (a +// plugin DLL is never unloaded, see the engine's PluginManager.PluginsUnloaded). +// Shutdown sets Version to 0; a caller re-queries (host GetPluginInterface) +// when it sees that, after a plugin reload, or every few seconds. +// ============================================================================ + +using System.Runtime.InteropServices; + +namespace RynthCore.Plugin.Shared; + +/// Constants of the "RynthILT.Hub" interface. +public static class RynthIltHub +{ + /// The providing plugin's display name. + public const string PluginName = "RynthILT"; + + /// Tab flag: the Mini Remote shows this tab now (an ILT world, or forced, and the tab is usable). + public const uint TabShown = 1; + /// Tab flag: the server reports the tab's feature on (Character is always available). + public const uint TabAvailable = 2; + + // Sections RynthAi draws through RenderSection (each draws nothing off ILT). + /// Remote tab, Bank section: the ILT bank balances. + public const string SectionRemoteBank = "remote-bank"; + /// Remote tab, Guardian line: the Temple guardian's last answer. + public const string SectionRemoteGuardian = "remote-guardian"; + /// Quests tab: the "Quest bonus (/qb)" list. + public const string SectionQuestBonus = "quests-qb"; + /// Pets tab: the /pets and /shinies logs. + public const string SectionPetLogs = "pets-logs"; + /// Mini Remote menu, under Infinite Leaftide: why no ILT feature is on, the Force-ILT override, Refresh. + public const string SectionIltStatus = "ilt-status"; + /// Mini Remote menu without RynthCore's server list: RynthILT's own Infinite Leaftide items. + public const string SectionServerMenu = "server-menu"; + + /// Feature keys RynthAi reads (GetFeature). + public const string FeatureQuests = "quests"; + public const string FeaturePetRefill = "pet_refill"; + public const string FeatureUniversalMastery = "universal_mastery"; + public const string FeatureRequireComps = "require_spell_comps"; +} + +/// One ILT tab as GetTabs hands it out. Blittable. +[StructLayout(LayoutKind.Sequential)] +public unsafe struct IltTabV1 +{ + /// The tab id (UTF-8, NUL-terminated): saved as the Mini Remote's tab, "/ra hub open <id>". + public fixed byte Id[24]; + /// The tab bar label (UTF-8, NUL-terminated). + public fixed byte Label[32]; + /// The size of the tab body (the child it draws in). + public float Width; + public float Height; + /// RynthIltHub.Tab* bits. + public uint Flags; +} + +[StructLayout(LayoutKind.Sequential)] +public unsafe struct RynthIltHubApiV1 +{ + public const string InterfaceName = "RynthILT.Hub"; + public const uint InterfaceVersion = 1; + + public uint Version; // InterfaceVersion of the table RynthILT filled; 0 once it has shut down + public uint StructSize; // sizeof(RynthIltHubApiV1) as RynthILT built it + + /// IsIltWorld(): 1 when this world is Infinite Leaftide / ACECustom (or forced). Any thread. + public delegate* unmanaged[Cdecl] IsIltWorld; + + /// GetFeature(key): the server's bit for a feature, -1 unknown, 0 off, 1 on (-1 off ILT). Any thread. + public delegate* unmanaged[Cdecl] GetFeature; + + /// GetRates(coinsPerHour, pyrealsPerHour): ILT session rates; 0 (nothing written) off ILT. Any thread. + public delegate* unmanaged[Cdecl] GetRates; + + /// GetForceIlt(): this character's "Treat this world as ILT" override (1 on). Any thread. + public delegate* unmanaged[Cdecl] GetForceIlt; + + /// SetForceIlt(on): sets that override. Any thread (applied and saved on RynthILT's next tick). + public delegate* unmanaged[Cdecl] SetForceIlt; + + /// + /// GetTabs(tabs, capacity): every ILT tab in tab-bar order with its flags. Writes up to + /// capacity, returns how many there are (tabs null: just the count). Render thread. + /// + public delegate* unmanaged[Cdecl] GetTabs; + + /// RenderTab(id): draws that tab's body into the current (child) window; 1 = drawn. Render thread. + public delegate* unmanaged[Cdecl] RenderTab; + + /// RenderSection(id): draws a RynthIltHub.Section* into the current window; 1 = drawn. Render thread. + public delegate* unmanaged[Cdecl] RenderSection; + + /// + /// Command(text): one of the ILT "/ra" verbs, as typed after "/ra" ("hub bank", "hub attr run", + /// "guardian handin", "bounty show", "rates reset"). RynthILT answers in chat itself. + /// 1 = handled, 0 = not an ILT verb. Pump thread. + /// + public delegate* unmanaged[Cdecl] Command; +} diff --git a/Tools/RynthCore.RynthAiHostTests/Fakes/FakeHost.cs b/Tools/RynthCore.RynthAiHostTests/Fakes/FakeHost.cs index 35401d5..fa979b6 100644 --- a/Tools/RynthCore.RynthAiHostTests/Fakes/FakeHost.cs +++ b/Tools/RynthCore.RynthAiHostTests/Fakes/FakeHost.cs @@ -253,9 +253,11 @@ internal static unsafe class FakeHost VTankFlags = -1; VTankSeq = 0; LogCostMicros = 0; ServerGates = false; UseDoneSeq = 0; CastBusy = 0; LastUseDoneError = 0; LastUseDoneCalls = false; WeenieErrorCalls = false; WeenieErrSeq = 0; WeenieErrCode = WeenieErrEvent = WeenieErrObject = 0; +#if !RYNTHILT_TESTS // Spell mana costs "unknown" (no reserve beyond Get Mana At, no cost gate), so a portal.dat on // the PC doesn't change results; the mana reserve tests set their own costs. RynthCore.Plugin.RynthAi.BuffManager.ManaCostOverride = _ => 0; +#endif WieldCalls = false; Wields.Clear(); SalvageCalls = false; ExternalMoves.Clear(); SalvageAdds.Clear(); SalvageExecutes.Clear(); RefuseSalvageAdd.Clear(); OnSalvageExecute = null; Wielded.Clear(); _panelItems.Clear(); @@ -426,6 +428,7 @@ internal static unsafe class FakeHost return new RynthCoreHost(api); } +#if !RYNTHILT_TESTS /// /// A WorldObjectCache that knows the given objects: each id must have a name in /// . Ids with a entry land on the landscape @@ -445,6 +448,7 @@ internal static unsafe class FakeHost } return cache; } +#endif private static IntPtr Ansi(string s) { diff --git a/Tools/RynthCore.RynthAiHostTests/Program.cs b/Tools/RynthCore.RynthAiHostTests/Program.cs index c9491aa..79818f0 100644 --- a/Tools/RynthCore.RynthAiHostTests/Program.cs +++ b/Tools/RynthCore.RynthAiHostTests/Program.cs @@ -36,7 +36,6 @@ internal static class Program ExpressionEngine.ItemGiverDir = Path.Combine(TempRoot, "ItemGiver"); // The dungeon map bake writes floor plans under C:\Games\RynthSuite\RynthAi\Maps. RynthCore.Plugin.RynthAi.Maps.DungeonMapBake.CacheDir = Path.Combine(TempRoot, "Maps"); - RynthCore.Plugin.RynthAi.IltHub.IltAugCosts.FilePath = Path.Combine(TempRoot, "ilt-aug-costs.json"); // A sighted lava/acid hotspot is persisted under C:\Games\RynthSuite\RynthAi\DungeonHazards. LiveHazardFolder = RynthCore.Plugin.RynthAi.DungeonHazardStore.Folder; RynthCore.Plugin.RynthAi.DungeonHazardStore.Folder = Path.Combine(TempRoot, "DungeonHazards"); @@ -111,12 +110,10 @@ internal static class Program NavMapEditTests.Register(runner); LootSpeedTests.Register(runner); MeleeStallTests.Register(runner); - AttributeRaiserTests.Register(runner); - SigilChainTests.Register(runner); ServerMenuTests.Register(runner); + MiniRemoteMoveTests.Register(runner); ItemsCleanTests.Register(runner); DeathRecallTests.Register(runner); - BankCommandTests.Register(runner); InventoryAttributeFilterTests.Register(runner); StuckCastTests.Register(runner); PacerEdgeTests.Register(runner); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs new file mode 100644 index 0000000..3daf2e5 --- /dev/null +++ b/Tools/RynthCore.RynthAiHostTests/Tests/MiniRemoteMoveTests.cs @@ -0,0 +1,175 @@ +using System; +using System.IO; +using System.Linq; +using System.Text.Json; +using RynthCore.Plugin.RynthAi; +using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthAi.MiniRemote; +using RynthCore.Plugin.Shared; +using RynthCore.PluginSdk; +using RynthCore.RynthAiHostTests.Fakes; +using RynthCore.RynthAiTests.Harness; + +namespace RynthCore.RynthAiHostTests.Tests; + +// The ILT Hub left RynthAi for the RynthILT plugin (2026-10-13). What stayed: the Mini Remote with its +// universal Quests and Pets tabs (their settings now in miniremote.json, read once from the old +// ilt-hub.json), the "/ra hub|quests|pets" commands (the ILT verbs go to RynthILT, or say it's +// needed), the RynthAi.Hub interface RynthILT borrows from, and the profile's old Server Features +// fields kept for RynthILT's one-time migration. +internal static class MiniRemoteMoveTests +{ + private const uint Player = 0x50000E01; + + private const string LegacyHubJson = """ + { + "Bank": { "Pyreals": 99 }, + "Pet": { "HealingEnabled": true, "HealPetName": "Healing Buddy", "RosterKind": 1, "UsePyrealRefillPath": true, + "Assignments": [ { "Name": "Fire Banshee Essence", "Kind": 2 }, { "Name": "", "Kind": 1 } ], "PetLog": ["x"] }, + "Character": { "QuestFilter": "temple", "QuestFavorites": ["foo", ""], "ShowQuestFavoritesHud": true, "AttrKeepXp": 5 }, + "Gear": { "LastUsdPath": "C:\\vt\\me.usd", "AutoClap": true } + } + """; + + public static void Register(Runner r) + { + r.Add("mini remote: Pets / Quests settings come over from ilt-hub.json once, which is never rewritten", LegacyState); + r.Add("mini remote: without RynthILT there are no ILT tabs, bits or verbs", NoRynthIlt); + r.Add("mini remote: /ra hub|quests|pets stay RynthAi's; ILT verbs say RynthILT is needed", Commands); + r.Add("mini remote: the pyreal refill path never spends without RynthILT's confirmation", RefillNeedsIlt); + r.Add("profile: the old Server Features fields still round-trip (RynthILT migrates them)", LegacyProfileFields); + r.Add("RynthAi.Hub: table, spell names, nothing before login", HubTable); + } + + private static string Folder(string name) + { + string dir = Path.Combine(Program.TempRoot, "miniremote-" + name); + if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); + Directory.CreateDirectory(dir); + return dir; + } + + private static void LegacyState() + { + string dir = Folder("legacy"); + string legacyPath = Path.Combine(dir, MiniRemoteStore.LegacyFileName); + File.WriteAllText(legacyPath, LegacyHubJson); + + var store = new MiniRemoteStore(dir); + var s = store.Load(); + Check.True(s.Pet.HealingEnabled && s.Pet.HealPetName == "Healing Buddy", "healing pet settings"); + Check.Eq(s.Pet.RosterKind, 1, "roster view"); + Check.True(s.Pet.UsePyrealRefillPath, "the refill opt-in"); + Check.Eq(s.Pet.Assignments.Count, 1, "type overrides (the blank one dropped)"); + Check.Eq(s.Quests.QuestFilter, "temple", "quest filter"); + Check.Eq(string.Join(",", s.Quests.QuestFavorites), "foo", "favorites (blanks dropped)"); + Check.True(s.Quests.ShowQuestFavoritesHud, "favorites HUD"); + Check.Eq(s.LastUsdPath, @"C:\vt\me.usd", "the .usd importer's last file"); + + store.SaveIfDirty(s); + Check.True(File.Exists(Path.Combine(dir, MiniRemoteStore.FileName)), "saved as miniremote.json"); + Check.Eq(File.ReadAllText(legacyPath), LegacyHubJson, "ilt-hub.json is left exactly as it was (RynthILT copies it)"); + string saved = File.ReadAllText(Path.Combine(dir, MiniRemoteStore.FileName)); + Check.False(saved.Contains("Pyreals") || saved.Contains("PetLog") || saved.Contains("AttrKeepXp"), "no ILT data in RynthAi's file"); + + s.Quests.QuestFilter = "changed"; + store.SaveIfDirty(s); + var again = new MiniRemoteStore(dir).Load(); + Check.Eq(again.Quests.QuestFilter, "changed", "miniremote.json wins once it exists"); + + var fresh = new MiniRemoteStore(Folder("fresh")).Load(); + Check.False(fresh.Pet.HealingEnabled, "no files at all: defaults"); + } + + private static MiniRemoteController NewController(string folder, out RynthCoreHost host, out LegacyUiSettings settings) + { + FakeHost.Reset(); + host = FakeHost.Create(Player); + var s = new LegacyUiSettings(); + settings = s; + var c = new MiniRemoteController(host, Folder(folder), () => null, () => s, () => null, () => { }, new IltClient(host)); + string? lastTab = null; + c.MiniRemoteCommand = mode => "[Mini Remote] remote " + mode; + c.MiniRemoteTabCommand = (tab, mode) => { lastTab = tab + ":" + mode; return "tab " + lastTab; }; + return c; + } + + private static void NoRynthIlt() + { + var c = NewController("noilt", out var host, out _); + var ilt = c.Ilt; + ilt.Tick(); + Check.False(ilt.Loaded, "no RynthILT (no plugin interfaces on this host)"); + Check.False(ilt.IsIltWorld, "so never an ILT world"); + Check.Eq(ilt.Feature(RynthIltHub.FeaturePetRefill), -1, "feature bits unknown"); + Check.False(ilt.IsOff(RynthIltHub.FeatureQuests), "unknown is not off (/myquests still refreshes)"); + Check.Eq(ilt.Tabs().Count, 0, "no ILT tabs"); + Check.False(ilt.RenderSection(RynthIltHub.SectionQuestBonus), "no ILT sections"); + Check.False(ilt.Command("hub bank"), "no ILT verbs taken"); + Check.False(ilt.TryGetRates(out _, out _), "no ILT rates"); + Check.False(c.SkipLoginQuestRefresh, "the login /myquests refresh isn't skipped"); + } + + private static void Commands() + { + var c = NewController("cmds", out _, out _); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("hub", new[] { "show" }), "hub show"); + Check.True(FakeHost.Chat.Any(x => x.Contains("remote show")), "hub show drives the Mini Remote"); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("hub", new[] { "open", "pets" }), "hub open pets"); + Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:toggle")), "opens RynthAi's Pets tab"); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("pets", new[] { "show" }), "pets show"); + Check.True(FakeHost.Chat.Any(x => x.Contains("tab pets:show")), "same tab"); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("hub", new[] { "bank" }), "hub bank is handled (answered)"); + Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "it says the ILT verbs come with RynthILT"); + Check.True(FakeHost.Chat.Any(x => x.Contains("/ra hub open quests|pets")), "and lists what RynthAi still has"); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("guardian", new[] { "handin" }), "guardian is answered"); + Check.True(FakeHost.Chat.Any(x => x.Contains("RynthILT")), "with the RynthILT note"); + FakeHost.Chat.Clear(); + Check.True(c.HandleCommand("bountys", Array.Empty()), "the bountys spelling too"); + Check.False(c.HandleCommand("start", Array.Empty()), "other verbs aren't the Mini Remote's"); + } + + private static void RefillNeedsIlt() + { + var c = NewController("refill", out _, out _); + c.State.Pet.UsePyrealRefillPath = true; + FakeHost.Bools[(Player, MiniRemoteInventory.BoolPyrealRefillActive)] = true; // the server's player bool + Check.False(c.Pets.AllowSummonOnEmpty(), "not an ILT world (no RynthILT): an empty essence is never summoned on pyreals"); + } + + private static void LegacyProfileFields() + { + var s = JsonSerializer.Deserialize("{\"FeatureServerNames\":[\"MyShard\"],\"ForceServerFeatures\":true}", + RynthAiJsonContext.Default.LegacyUiSettings)!; + string json = JsonSerializer.Serialize(s, RynthAiJsonContext.Default.LegacyUiSettings); + Check.True(json.Contains("MyShard"), "the old server list is written back unchanged"); + Check.True(json.Contains("\"ForceServerFeatures\": true"), "and the old override"); + var fresh = JsonSerializer.Serialize(new LegacyUiSettings(), RynthAiJsonContext.Default.LegacyUiSettings); + Check.False(fresh.Contains("InfiniteLeaftide"), "a fresh profile no longer gets an ILT server list"); + } + + private static unsafe void HubTable() + { + Check.Eq(HubInterface.Query("RynthILT.Hub", 1), IntPtr.Zero, "not ours"); + var t = (RynthAiHubApiV1*)HubInterface.Query(RynthAiHubApiV1.InterfaceName, 1); + Check.True(t != null && t->Version == 1 && t->StructSize == (uint)sizeof(RynthAiHubApiV1), "v1 served"); + Check.True(t->MiniRemoteTab != null && t->MiniRemoteVisible != null && t->QuestFlag != null && t->QuestStatus != null + && t->QuestRefresh != null && t->SpellName != null && t->LootKeeps != null && t->RenderSection != null + && t->SessionStats != null && t->SessionReset != null, "every function filled in"); + + byte* buf = stackalloc byte[64]; + int n = t->SpellName(1, buf, 64); + Check.Eq(System.Runtime.InteropServices.Marshal.PtrToStringUTF8((IntPtr)buf, n), "Strength Other I", "spell names from RynthAi's table"); + Check.Eq(t->SpellName(0, buf, 64), 0, "spell 0 has no name"); + QuestStatusV1 st; + Check.Eq(t->QuestStatus(&st), 0, "no quest tracker before login"); + Check.Eq(t->MiniRemoteVisible(), 0, "no Mini Remote before login"); + SessionStatsV1 ss; + Check.Eq(t->SessionStats(&ss), 0, "no session before login"); + } +} diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/SaveFailureTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/SaveFailureTests.cs index de55ab0..2a68a07 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/SaveFailureTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/SaveFailureTests.cs @@ -4,7 +4,7 @@ using System.IO; using System.Reflection; using RynthCore.Loot.Editing; using RynthCore.Plugin.RynthAi; -using RynthCore.Plugin.RynthAi.Diagnostics; +using RynthCore.Plugin.Shared; using RynthCore.Plugin.RynthAi.LegacyUi; using RynthCore.Plugin.RynthAi.Meta; using RynthCore.RynthAiHostTests.Fakes; @@ -15,7 +15,7 @@ namespace RynthCore.RynthAiHostTests.Tests; // 2026-10-13: players reported metas and navs "not saving" and the plugin folders being // "read only". Every save of a meta, nav, settings profile (and the loot editor's autosave // path) swallowed its exception, so a folder the client can't write looked like a save that did -// nothing. Diagnostics/DataWriteGuard.cs now: +// nothing. Plugins/Shared/DataWriteGuard.cs now: // - clears the ReadOnly attribute on our own file before overwriting it; // - reports a failed save in chat once per folder (path, reason, fix) and logs every one // (throttled per folder); diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs b/Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs index 6218969..ecc70ad 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs +++ b/Tools/RynthCore.RynthAiHostTests/Tests/ServerMenuTests.cs @@ -13,21 +13,19 @@ internal static class ServerMenuTests r.Add("server menu: sections and items parse in order", ParsesSections); r.Add("server menu: malformed lines are skipped, never thrown", SkipsMalformed); r.Add("server menu: tab features name the Mini Remote tab", TabFeature); - r.Add("mini remote tabs: Quests and Pets are universal and first; Guardian is ILT's panel", UniversalTabs); + r.Add("mini remote tabs: Quests and Pets are RynthAi's and first; the ILT tabs come from RynthILT", UniversalTabs); } private static void UniversalTabs() { - var tabs = RynthCore.Plugin.RynthAi.IltHub.IltSections.Tabs; - Check.Eq(tabs[0], RynthCore.Plugin.RynthAi.IltHub.IltSection.Quests, "Quests leads the tab bar"); - Check.Eq(tabs[1], RynthCore.Plugin.RynthAi.IltHub.IltSection.Pet, "Pets second"); - int universal = 0; - foreach (var t in tabs) - if (RynthCore.Plugin.RynthAi.IltHub.IltSections.IsUniversal(t)) universal++; - Check.Eq(universal, 2, "only Quests and Pets are universal"); - Check.True(!RynthCore.Plugin.RynthAi.IltHub.IltSections.IsUniversal(RynthCore.Plugin.RynthAi.IltHub.IltSection.Guardian), "Guardian is ILT only"); - Check.True(!RynthCore.Plugin.RynthAi.IltHub.IltSections.IsTab(RynthCore.Plugin.RynthAi.IltHub.IltSection.Guardian), "Guardian is a panel, not a tab"); - Check.True(!RynthCore.Plugin.RynthAi.IltHub.IltSections.IsUniversal(RynthCore.Plugin.RynthAi.IltHub.IltSection.Character), "the Character tab is ILT's"); + var tabs = RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Universal; + Check.Eq(tabs.Length, 2, "RynthAi's own tabs: Quests and Pets (the ILT tabs are RynthILT's)"); + Check.Eq(tabs[0], "quests", "Quests leads the tab bar"); + Check.Eq(tabs[1], "pets", "Pets second"); + Check.Eq(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("Pet"), "pets", "aliases parse"); + Check.Null(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("banking"), "an ILT tab isn't RynthAi's"); + Check.Null(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Parse("guardian"), "nor the Guardian panel"); + Check.Eq(RynthCore.Plugin.RynthAi.MiniRemote.MiniRemoteTabs.Remote, "", "the Remote tab's id is empty"); } private static void ParsesSections() diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/AttributeRaiserTests.cs b/Tools/RynthILT.Tests/AttributeRaiserTests.cs similarity index 91% rename from Tools/RynthCore.RynthAiHostTests/Tests/AttributeRaiserTests.cs rename to Tools/RynthILT.Tests/AttributeRaiserTests.cs index d391540..2a24847 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/AttributeRaiserTests.cs +++ b/Tools/RynthILT.Tests/AttributeRaiserTests.cs @@ -3,17 +3,16 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading; -using RynthCore.Plugin.RynthAi.IltHub; -using RynthCore.Plugin.RynthAi.LegacyUi; +using RynthCore.Plugin.RynthILT.Hub; using RynthCore.PluginSdk; using RynthCore.RynthAiHostTests.Fakes; using RynthCore.RynthAiTests.Harness; -namespace RynthCore.RynthAiHostTests.Tests; +namespace RynthILT.Tests; -// Server Features gate + the infinite-attribute raiser (2026-10-06). The gate decides from -// Settings > Misc (world-name patterns, manual override) whether the ILT features ask the -// server at all; the raiser reads "/xp all" costs and spends unassigned XP with "/attr 1" +// Server Features gate + the infinite-attribute raiser (2026-10-06; RynthAi's ILT Hub, in RynthILT +// since 2026-10-13). The gate decides from RynthILT's server list (world-name patterns) and the +// character's "Treat this world as ILT" whether the ILT features ask the server at all; the raiser reads "/xp all" costs and spends unassigned XP with "/attr 1" // on the ticked stats, in the chosen order, never below the reserve. internal static class AttributeRaiserTests { @@ -72,7 +71,7 @@ internal static class AttributeRaiserTests { string file = IltAugCosts.FilePath; if (File.Exists(file)) File.Delete(file); - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("InfiniteLeaftide", settings, "aug-costs", out _); var prog = hub.Progression; prog.ApplyAugLines(new List { "War: 1700" }); @@ -122,7 +121,7 @@ internal static class AttributeRaiserTests Check.Eq(IltAttributeRaiser.ProjectCost(0, 10), 0L, "unknown cost projects nothing"); Check.Eq(IltAttributeRaiser.ProjectCost(long.MaxValue / 2, 10), long.MaxValue, "saturates instead of overflowing"); - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("InfiniteLeaftide", settings, "attr-byhand", out _); var raiser = hub.Progression.Attributes; FakeHost.Quads[(Player, IltInventory.QuadAvailableXp)] = 5_000; @@ -161,7 +160,7 @@ internal static class AttributeRaiserTests private static void AugPlanner() { - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("InfiniteLeaftide", settings, "aug-planner", out _); var prog = hub.Progression; @@ -219,17 +218,17 @@ internal static class AttributeRaiserTests Check.Eq(string.Join("|", list), "InfiniteLeaftide|*Leaftide*|Aelrynth", "trimmed, split on , and ;, de-duplicated ignoring case"); Check.Eq(ServerFeatureGate.FormatList(list), "InfiniteLeaftide, *Leaftide*, Aelrynth", "formatted back for the text box"); - var s = new LegacyUiSettings(); - Check.True(s.FeatureServerNames.Contains("InfiniteLeaftide"), "a fresh profile starts with the defaults"); - Check.True(ServerFeatureGate.IsEnabled("InfiniteLeaftide", s), "the default list covers InfiniteLeaftide"); - Check.False(ServerFeatureGate.IsEnabled("Aelrynth", s), "another world is off by default"); - s.ForceServerFeatures = true; - Check.True(ServerFeatureGate.IsEnabled("Aelrynth", s), "the manual override turns it on anywhere"); - s.ForceServerFeatures = false; - s.FeatureServerNames = new List { "Aelrynth" }; - Check.True(ServerFeatureGate.IsEnabled("aelrynth", s), "a world added to the list is on"); - Check.False(ServerFeatureGate.IsEnabled("InfiniteLeaftide", s), "a world removed from the list is off"); - Check.True(ServerFeatureGate.IsEnabled("InfiniteLeaftide", null), "no profile yet: the defaults apply"); + var s = new IltSettings(); + Check.True(s.ServerNames.Contains("InfiniteLeaftide"), "fresh settings start with the defaults"); + Check.True(ServerFeatureGate.IsEnabled("InfiniteLeaftide", s, forceOn: false), "the default list covers InfiniteLeaftide"); + Check.False(ServerFeatureGate.IsEnabled("Aelrynth", s, forceOn: false), "another world is off by default"); + Check.True(ServerFeatureGate.IsEnabled("Aelrynth", s, forceOn: true), "the character's override turns it on anywhere"); + s.ServerNames = new List { "Aelrynth" }; + Check.True(ServerFeatureGate.IsEnabled("aelrynth", s, forceOn: false), "a world added to the list is on"); + Check.False(ServerFeatureGate.IsEnabled("InfiniteLeaftide", s, forceOn: false), "a world removed from the list is off"); + Check.True(ServerFeatureGate.IsEnabled("InfiniteLeaftide", null, forceOn: false), "no settings yet: the defaults apply"); + s.ServerNames = new List(); + Check.True(ServerFeatureGate.IsEnabled("InfiniteLeaftide", s, forceOn: false), "an emptied list falls back to the defaults"); } private static readonly string[] Order = { "coo", "qui", "str", "end", "foc", "sel", "hea", "sta", "man" }; @@ -302,14 +301,15 @@ internal static class AttributeRaiserTests // ── The loop on the fake host ───────────────────────────────────────────── - private static IltHubController NewHub(string world, LegacyUiSettings settings, string folder, out RynthCoreHost host) + private static IltHubController NewHub(string world, IltSettings settings, string folder, out RynthCoreHost host) { FakeHost.Reset(); FakeHost.WorldName = world; host = FakeHost.Create(Player); string dir = Path.Combine(Program.TempRoot, folder); Directory.CreateDirectory(dir); - return new IltHubController(host, dir, () => null, () => settings, () => null, () => { }); + // No RynthAi here (the fake host has no GetPluginInterface): RynthILT runs on its own. + return new IltHubController(host, dir, settings, new RynthAiClient(host)); } /// Ticks the hub until or the timeout (the chat queue spaces sends by real time). @@ -332,7 +332,7 @@ internal static class AttributeRaiserTests private static void FullRun() { - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("InfiniteLeaftide", settings, "attr-run", out _); var c = hub.State.Character; c.AttrRaiseStats = new List { "coo", "qui" }; @@ -391,7 +391,7 @@ internal static class AttributeRaiserTests private static void Safety() { - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("InfiniteLeaftide", settings, "attr-safety", out _); var c = hub.State.Character; var raiser = hub.Progression.Attributes; @@ -418,11 +418,11 @@ internal static class AttributeRaiserTests FakeHost.ChatCommands.Clear(); raiser.Start(auto: false); Check.True(TickUntil(hub, () => FakeHost.ChatCommands.Contains("/xp all")), "second run reads costs"); - settings.FeatureServerNames = new List { "SomewhereElse" }; + settings.ServerNames = new List { "SomewhereElse" }; Reply(hub, "[XP] Your XP cost for next 1 Coordination level is: 100"); Check.True(TickUntil(hub, () => !raiser.Running), "the run stops once the world is off"); Check.False(FakeHost.ChatCommands.Any(x => x.StartsWith("/attr", StringComparison.Ordinal)), "no raise after the gate closed"); - settings.FeatureServerNames = new List(ServerFeatureGate.DefaultServerNames); + settings.ServerNames = new List(ServerFeatureGate.DefaultServerNames); // Another XP spender running: neither Raise now nor +N starts. bool spending = true; @@ -437,7 +437,7 @@ internal static class AttributeRaiserTests private static void GatedOff() { - var settings = new LegacyUiSettings(); + var settings = new IltSettings(); var hub = NewHub("Aelrynth", settings, "attr-gated", out _); var raiser = hub.Progression.Attributes; hub.State.Character.AttrRaiseStats = new List { "coo" }; @@ -446,10 +446,10 @@ internal static class AttributeRaiserTests TickUntil(hub, () => false, 600); Check.False(FakeHost.ChatCommands.Any(), "nothing is sent off a feature world"); - settings.FeatureServerNames.Add("Aelrynth"); - Check.Null(raiser.Blocker(), "adding the world to Server Features unblocks it"); - settings.FeatureServerNames.Remove("Aelrynth"); - settings.ForceServerFeatures = true; - Check.Null(raiser.Blocker(), "so does the manual override"); + settings.ServerNames.Add("Aelrynth"); + Check.Null(raiser.Blocker(), "adding the world to the server list unblocks it"); + settings.ServerNames.Remove("Aelrynth"); + hub.State.ForceLeaftideFeatures = true; + Check.Null(raiser.Blocker(), "so does the character's override"); } } diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/BankCommandTests.cs b/Tools/RynthILT.Tests/BankCommandTests.cs similarity index 97% rename from Tools/RynthCore.RynthAiHostTests/Tests/BankCommandTests.cs rename to Tools/RynthILT.Tests/BankCommandTests.cs index 9d73cba..c641d82 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/BankCommandTests.cs +++ b/Tools/RynthILT.Tests/BankCommandTests.cs @@ -1,7 +1,7 @@ -using RynthCore.Plugin.RynthAi.IltHub; +using RynthCore.Plugin.RynthILT.Hub; using RynthCore.RynthAiTests.Harness; -namespace RynthCore.RynthAiHostTests.Tests; +namespace RynthILT.Tests; // Banking tab (IltBankCommands): the deposit / withdraw commands match ACECustom's /bank handler // (upstream 2026-10-11), and only the bank's own reply lines count as a deposit / withdraw result. diff --git a/Tools/RynthILT.Tests/MoveTests.cs b/Tools/RynthILT.Tests/MoveTests.cs new file mode 100644 index 0000000..609088c --- /dev/null +++ b/Tools/RynthILT.Tests/MoveTests.cs @@ -0,0 +1,450 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using RynthCore.Loot; +using RynthCore.Plugin.RynthILT; +using RynthCore.Plugin.RynthILT.Hub; +using RynthCore.Plugin.Shared; +using RynthCore.RynthAiTests.Harness; + +namespace RynthILT.Tests; + +// The ILT Hub's move out of RynthAi into RynthILT (2026-10-13): the saved data carried over from +// RynthAi's folders (copied, never moved), the RynthILT.Hub interface table RynthAi's Mini Remote +// reads, which "/ra" verbs RynthILT takes from RynthAi, and the host-backed object view that +// replaced RynthAi's WorldObjectCache. +internal static class MoveTests +{ + public static void Register(Runner r) + { + r.Add("move: a character's RynthAi ILT Hub files are copied, the RynthAi copies left alone", MigratesCharacter); + r.Add("move: migration never overwrites RynthILT's files and runs once", MigrationIdempotent); + r.Add("move: the pre-per-server ACEmulator folder is found too", MigratesFromAceEmulatorFolder); + r.Add("move: shared Hub profiles and aug costs are copied once", MigratesShared); + r.Add("move: a migration copy that fails is reported (log + chat) and the shared ones retried", MigrationFailuresReported); + r.Add("move: a failed Hub save is reported once and retried", StoreSaveFailureReported); + r.Add("move: an unfinished copy blocks the character's Hub writes until the retry copies the original", PendingMigrationNeverShadowed); + r.Add("move: an old ilt-hub.json loads into RynthILT's state (ILT parts kept)", LegacyStateLoads); + r.Add("move: RynthAi's \"/ra\" verbs RynthILT takes (and the ones it leaves)", VerbRouting); + r.Add("move: item classes from the client's item type (the gear tools' checks)", Classification); + r.Add("move: the interface structs have the agreed layout", InterfaceLayout); + r.Add("move: server-list status lines", DescribeLines); + r.Add("move: off ILT nothing is sent, no tab or section shows; on ILT the login probe runs", DormantOffIlt); + // Last: Release() switches the table off for the rest of the process. + r.Add("move: the RynthILT.Hub table: query, functions, release", HubTable); + } + + private static string Root(string name) + { + string dir = Path.Combine(Program.TempRoot, "move-" + name); + if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); + Directory.CreateDirectory(dir); + IltMigration.LegacyProfilesBase = Path.Combine(dir, "RynthAi", "SettingsProfiles"); + IltMigration.LegacySharedRoot = Path.Combine(dir, "RynthAi"); + return dir; + } + + private const string LegacyHubJson = """ + { + "SchemaVersion": 1, + "ForceLeaftideFeatures": false, + "UbSidecarsImported": true, + "Bank": { "Pyreals": 1234567, "Luminance": 89, "EnlightenedCoins": 42, "AutoRefreshSeconds": 300 }, + "Pet": { "HealingEnabled": true, "HealPetName": "Healing Buddy", "PetLog": ["Fire Banshee"], "ShinyLog": [] }, + "Character": { + "QuestFilter": "temple", "QbFilter": "wait", "QuestFavorites": ["foo"], + "AttrOrder": ["qui","coo","str","end","foc","sel","hea","sta","man"], "AttrRaiseStats": ["qui"], + "AugTargets": { "war": 1800 } + }, + "Gear": { "AutoClap": true, "LastUsdPath": "C:\\vt\\x.usd", "LastEquipProfile": "Melee" }, + "Guardian": { "AutoHandIn": true, "TurnInCounts": { "Strength": 3 } } + } + """; + + private static string MakeLegacyChar(string world, string charName, bool withProfile = true) + { + string dir = Path.Combine(IltMigration.LegacyProfilesBase, IltMigration.RynthAiSafeName(world), IltMigration.RynthAiSafeName(charName)); + Directory.CreateDirectory(Path.Combine(dir, "ilt-hub-profiles")); + File.WriteAllText(Path.Combine(dir, "ilt-hub.json"), LegacyHubJson); + File.WriteAllText(Path.Combine(dir, "ilt-hub-transactions.json"), "[{\"Type\":\"Received\",\"Currency\":\"Pyreals\",\"Amount\":5}]"); + File.WriteAllText(Path.Combine(dir, "ilt-hub-profiles", "farm.json"), "{\"SchemaVersion\":1}"); + if (withProfile) + { + File.WriteAllText(Path.Combine(dir, "active_profile.txt"), "Melee"); + File.WriteAllText(Path.Combine(dir, "Melee.json"), + "{\"MetaDebug\":false,\"FeatureServerNames\":[\"InfiniteLeaftide\",\"*Leaftide*\",\"MyShard\"],\"ForceServerFeatures\":true}"); + File.WriteAllText(Path.Combine(dir, "Default.json"), "{\"FeatureServerNames\":[\"Unused\"]}"); + } + return dir; + } + + private static void MigratesCharacter() + { + string root = Root("char"); + string legacy = MakeLegacyChar("Infinite Leaftide", "Sir Tester"); + string before = File.ReadAllText(Path.Combine(legacy, "ilt-hub.json")); + var settings = new IltSettings(); + string dest = Path.Combine(root, "RynthILT", "Infinite Leaftide", "Sir Tester"); + + var done = IltMigration.MigrateCharacter(dest, "Infinite Leaftide", "Sir Tester", settings, out bool force); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.StateFile)), "ilt-hub.json -> hub.json"); + Check.Eq(File.ReadAllText(Path.Combine(dest, IltHubStore.StateFile)), before, "copied byte for byte"); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.TransactionsFile)), "transactions copied"); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.ProfilesFolder, "farm.json")), "per-character Hub profiles copied"); + Check.True(File.Exists(Path.Combine(legacy, "ilt-hub.json")) && File.Exists(Path.Combine(legacy, "ilt-hub-transactions.json")), + "RynthAi's files are still there (copy, not move)"); + Check.True(settings.ServerNames.Contains("MyShard"), "the active profile's server names are added"); + Check.False(settings.ServerNames.Contains("Unused"), "only the ACTIVE profile is read"); + Check.Eq(settings.ServerNames.Count(n => n.Equals("InfiniteLeaftide", StringComparison.OrdinalIgnoreCase)), 1, "no duplicates"); + Check.True(force, "\"Force enable\" carries over as Treat this world as ILT"); + Check.True(done.Count >= 4, "the log line lists what was carried over: " + string.Join(", ", done)); + } + + private static void MigrationIdempotent() + { + string root = Root("idem"); + string legacy = MakeLegacyChar("InfiniteLeaftide", "Again", withProfile: false); + string dest = Path.Combine(root, "RynthILT", "InfiniteLeaftide", "Again"); + Directory.CreateDirectory(dest); + File.WriteAllText(Path.Combine(dest, IltHubStore.TransactionsFile), "[]"); // RynthILT already has one + var settings = new IltSettings(); + + IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Again", settings, out bool force); + Check.Eq(File.ReadAllText(Path.Combine(dest, IltHubStore.TransactionsFile)), "[]", "an existing RynthILT file is never overwritten"); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.StateFile)), "the missing hub.json is still copied"); + Check.False(force, "no profile, no override"); + + File.WriteAllText(Path.Combine(legacy, "ilt-hub.json"), "{\"Bank\":{\"Pyreals\":1}}"); + var second = IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Again", settings, out _); + Check.Eq(second.Count, 0, "once hub.json exists the character is never migrated again"); + Check.False(File.ReadAllText(Path.Combine(dest, IltHubStore.StateFile)).Contains("\"Pyreals\":1}"), "later RynthAi edits don't overwrite RynthILT's state"); + + var none = IltMigration.MigrateCharacter(Path.Combine(root, "RynthILT", "X", "Nobody"), "X", "Nobody", settings, out _); + Check.Eq(none.Count, 0, "a character RynthAi never saw: nothing to do"); + Check.False(Directory.Exists(Path.Combine(root, "RynthILT", "X", "Nobody")), "and no folder is made for it"); + } + + private static void MigratesFromAceEmulatorFolder() + { + string root = Root("ace"); + MakeLegacyChar("ACEmulator", "Old Timer", withProfile: false); + var settings = new IltSettings(); + string dest = Path.Combine(root, "RynthILT", "InfiniteLeaftide", "Old Timer"); + Check.NotNull(IltMigration.FindLegacyCharFolder("InfiniteLeaftide", "Old Timer"), "the world folder is missing, ACEmulator\\ is used"); + IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Old Timer", settings, out _); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.StateFile)), "copied from the ACEmulator folder"); + Check.Eq(IltMigration.RynthAiSafeName("Sir O'Neil-Smith"), "Sir_O'Neil-Smith", "RynthAi's folder names keep ' and - only"); + } + + private static void MigratesShared() + { + string root = Root("shared"); + Directory.CreateDirectory(Path.Combine(IltMigration.LegacySharedRoot, "IltHubProfiles")); + File.WriteAllText(Path.Combine(IltMigration.LegacySharedRoot, "IltHubProfiles", "team.json"), "{}"); + File.WriteAllText(Path.Combine(IltMigration.LegacySharedRoot, "ilt-aug-costs.json"), "{\"x\":1}"); + var settings = new IltSettings(); + string dest = Path.Combine(root, "RynthILT"); + + var done = IltMigration.MigrateShared(settings, dest); + Check.True(File.Exists(Path.Combine(dest, "Profiles", "team.json")), "shared profiles copied"); + Check.True(File.Exists(Path.Combine(dest, "ilt-aug-costs.json")), "aug costs copied"); + Check.True(settings.SharedFilesMigrated, "marked done in the settings"); + Check.Eq(done.Count, 2, "both reported"); + File.Delete(Path.Combine(dest, "ilt-aug-costs.json")); + Check.Eq(IltMigration.MigrateShared(settings, dest).Count, 0, "once only"); + Check.False(File.Exists(Path.Combine(dest, "ilt-aug-costs.json")), "a file deleted afterwards isn't brought back"); + } + + // A copy that fails (here: the RynthAi file held open by another program) is never silent: it + // is logged and queued for chat with the reason, the rest still copies, and the shared files + // aren't marked done so the next login tries again. + private static void MigrationFailuresReported() + { + string root = Root("fail"); + DataWriteGuard.Reset(); + string legacy = MakeLegacyChar("InfiniteLeaftide", "Locked Out"); + string dest = Path.Combine(root, "RynthILT", "InfiniteLeaftide", "Locked Out"); + var settings = new IltSettings(); + List done; + using (new FileStream(Path.Combine(legacy, "ilt-hub-transactions.json"), FileMode.Open, FileAccess.Read, FileShare.None)) + done = IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Locked Out", settings, out _); + Check.True(File.Exists(Path.Combine(dest, IltHubStore.StateFile)), "the other files are still copied"); + Check.False(File.Exists(Path.Combine(dest, IltHubStore.TransactionsFile)), "the held file isn't"); + Check.True(done.Any(l => l.Contains("NOT copied") && l.Contains(legacy)), "the log line says so and where the originals are: " + string.Join(", ", done)); + Check.Eq(DataWriteGuard.PendingCount, 1, "one chat line queued (shown on ILT)"); + var lines = new List(); + DataWriteGuard.DrainChat(lines.Add); + Check.True(lines.Count == 1 && lines[0].StartsWith("[RynthILT]", StringComparison.Ordinal) + && lines[0].Contains("ilt-hub-transactions.json") && lines[0].Contains("another program"), + "it names the file and the reason: " + string.Join(" | ", lines)); + + DataWriteGuard.Reset(); + Directory.CreateDirectory(Path.Combine(IltMigration.LegacySharedRoot, "IltHubProfiles")); + File.WriteAllText(Path.Combine(IltMigration.LegacySharedRoot, "IltHubProfiles", "team.json"), "{}"); + string aug = Path.Combine(IltMigration.LegacySharedRoot, "ilt-aug-costs.json"); + File.WriteAllText(aug, "{\"x\":1}"); + string sharedDest = Path.Combine(root, "RynthILT"); + using (new FileStream(aug, FileMode.Open, FileAccess.Read, FileShare.None)) + done = IltMigration.MigrateShared(settings, sharedDest); + Check.False(settings.SharedFilesMigrated, "a failed shared copy isn't marked done"); + Check.True(done.Any(l => l.Contains("NOT copied")), "and is reported: " + string.Join(", ", done)); + Check.True(DataWriteGuard.PendingCount >= 1, "in chat too"); + done = IltMigration.MigrateShared(settings, sharedDest); + Check.True(File.Exists(Path.Combine(sharedDest, "ilt-aug-costs.json")), "the next login copies it"); + Check.True(settings.SharedFilesMigrated, "then it is marked done"); + Check.Eq(done.Count, 1, "only the missing file is copied the second time: " + string.Join(", ", done)); + DataWriteGuard.Reset(); + } + + // A character whose ilt-hub.json couldn't be copied (held open by another program): the Hub + // runs from the RynthAi original read-only (or the defaults), writes no hub.json, bank log or + // per-character profile there, the pending mark survives a restart, and the next attempt copies + // the original byte for byte - never shadowed by a fresh file. + private static void PendingMigrationNeverShadowed() + { + string root = Root("pending"); + DataWriteGuard.Reset(); + string legacy = MakeLegacyChar("InfiniteLeaftide", "Held Open"); + string legacyHub = Path.Combine(legacy, "ilt-hub.json"); + string dest = Path.Combine(root, "RynthILT", "InfiniteLeaftide", "Held Open"); + string hubJson = Path.Combine(dest, IltHubStore.StateFile); + var settings = new IltSettings(); + + // Held open by another program: neither copied nor readable. + using (var held = new FileStream(legacyHub, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) + { + var done = IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Held Open", settings, out _); + Check.False(File.Exists(hubJson), "the held ilt-hub.json isn't copied"); + Check.True(IltMigration.IsPending(settings, dest), "the character is marked pending"); + Check.True(done.Any(l => l.Contains("NOT copied")), "and the log says so: " + string.Join(", ", done)); + + var store = new IltHubStore(default, dest) + { + WritesBlocked = () => IltMigration.IsPending(settings, dest), + LegacyFolder = legacy, + }; + IltHubState state = store.LoadState(); + Check.Eq(state.Bank.Pyreals, 0L, "unreadable: the Hub runs from the defaults"); + state.Bank.Pyreals = 1; + store.SaveStateIfDirty(state); + Check.False(File.Exists(hubJson), "no hub.json is written while the copy is unfinished"); + Check.False(store.SaveProfile(state, "mine", shared: false, out string why), "nor a per-character profile"); + Check.True(why.Contains("RynthAi"), "with the reason: " + why); + Check.True(store.SaveProfile(state, "team-" + Guid.NewGuid().ToString("N"), shared: true, out _), "shared profiles still save"); + + // A second login while still held: still pending, still nothing written. + IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Held Open", settings, out _); + Check.True(IltMigration.IsPending(settings, dest) && !File.Exists(hubJson), "still pending, still no hub.json"); + } + + // Readable again but not yet retried: a Hub started now reads the original, still writes nothing. + var readOnly = new IltHubStore(default, dest) + { + WritesBlocked = () => IltMigration.IsPending(settings, dest), + LegacyFolder = legacy, + }; + IltHubState fromLegacy = readOnly.LoadState(); + Check.Eq(fromLegacy.Bank.Pyreals, 1234567L, "the Hub runs from the RynthAi original, read only"); + fromLegacy.Bank.Pyreals = 2; + readOnly.SaveStateIfDirty(fromLegacy); + Check.False(File.Exists(hubJson), "and still writes no hub.json"); + + // The mark is in settings.json, so a client restart still knows the copy is unfinished. + IltSettingsStore.Save(settings); + IltSettings reloaded = IltSettingsStore.Load(); + Check.True(IltMigration.IsPending(reloaded, dest), "pending survives a restart"); + + var finished = IltMigration.MigrateCharacter(dest, "InfiniteLeaftide", "Held Open", reloaded, out bool force); + Check.True(File.Exists(hubJson), "the next attempt copies it"); + Check.Eq(File.ReadAllText(hubJson), File.ReadAllText(legacyHub), "byte for byte: the original, not a fresh file"); + Check.False(IltMigration.IsPending(reloaded, dest), "no longer pending"); + Check.True(force, "the profile's Force enable still carries over on the retry"); + Check.True(finished.Any(l => l.Contains("complete")), "the log says it finished: " + string.Join(", ", finished)); + + var after = new IltHubStore(default, dest) { WritesBlocked = () => IltMigration.IsPending(reloaded, dest) }; + IltHubState loaded = after.LoadState(); + Check.Eq(loaded.Bank.Pyreals, 1234567L, "the restarted Hub loads the copied file"); + loaded.Bank.Pyreals = 7; + after.SaveStateIfDirty(loaded); + Check.True(File.ReadAllText(hubJson).Contains("\"Pyreals\": 7"), "and saves normally from then on"); + File.Delete(Path.Combine(IltSettingsStore.Folder, IltSettingsStore.FileName)); + DataWriteGuard.Reset(); + } + + // RynthILT's own saves report a failure (DataWriteGuard) and try again on the next save. + private static void StoreSaveFailureReported() + { + string root = Root("storefail"); + DataWriteGuard.Reset(); + string blocker = Path.Combine(root, "NotAFolder"); + File.WriteAllText(blocker, "a file where the character folder should be"); + var store = new IltHubStore(default, blocker); + var state = new IltHubState(); + store.SaveStateIfDirty(state); + Check.Eq(DataWriteGuard.PendingCount, 1, "the failed Hub save is queued for chat"); + store.SaveStateIfDirty(state); + Check.Eq(DataWriteGuard.PendingCount, 1, "once per folder, not every retry"); + File.Delete(blocker); + store.SaveStateIfDirty(state); + Check.True(File.Exists(Path.Combine(blocker, IltHubStore.StateFile)), "the next save retries and works"); + DataWriteGuard.Reset(); + } + + private static void LegacyStateLoads() + { + string root = Root("state"); + string dir = Path.Combine(root, "char"); + Directory.CreateDirectory(dir); + File.WriteAllText(Path.Combine(dir, IltHubStore.StateFile), LegacyHubJson); + var store = new IltHubStore(default, dir); + var s = store.LoadState(); + Check.Eq(s.Bank.Pyreals, 1234567L, "bank balances"); + Check.Eq(s.Bank.AutoRefreshSeconds, 300, "bank settings"); + Check.Eq(s.Pet.PetLog.FirstOrDefault(), "Fire Banshee", "the /pets log (an ILT part of the Pet section)"); + Check.Eq(s.Character.QbFilter, "wait", "the /qb filter"); + Check.Eq(s.Character.AttrOrder.FirstOrDefault(), "qui", "the attribute raiser's order"); + Check.Eq(s.Character.AugTargets["war"], 1800, "aug targets"); + Check.True(s.Gear.AutoClap && s.Gear.LastEquipProfile == "Melee", "gear settings"); + Check.True(s.Guardian.AutoHandIn && s.Guardian.TurnInCounts["Strength"] == 3, "guardian settings"); + Check.True(s.UbSidecarsImported, "the UB import isn't redone"); + + store.SaveStateIfDirty(s); + string saved = File.ReadAllText(Path.Combine(dir, IltHubStore.StateFile)); + Check.False(saved.Contains("HealPetName"), "the Pets tab's settings (RynthAi's now) aren't written back here"); + Check.False(saved.Contains("QuestFavorites"), "nor the Quests tab's"); + } + + private static void VerbRouting() + { + static bool Takes(string line) => RynthILTPlugin.IsIltVerb(line.Split(' ', StringSplitOptions.RemoveEmptyEntries)); + Check.True(Takes("hub bank"), "hub bank"); + Check.True(Takes("hub attr run"), "hub attr run"); + Check.True(Takes("hub refresh"), "hub refresh"); + Check.True(Takes("hub help"), "hub help (RynthILT prints the whole list)"); + Check.True(Takes("hub open banking show"), "hub open "); + Check.True(Takes("hub open guardian"), "hub open guardian (the engine panel)"); + Check.True(Takes("hub open bounties"), "hub open bounties"); + Check.False(Takes("hub open pets"), "hub open pets is RynthAi's"); + Check.False(Takes("hub open quests hide"), "hub open quests is RynthAi's"); + Check.True(Takes("hub tab gear"), "hub tab "); + Check.False(Takes("hub tab quests"), "hub tab quests is RynthAi's"); + Check.False(Takes("hub tab remote"), "the Remote tab is RynthAi's"); + Check.False(Takes("hub"), "bare /ra hub toggles RynthAi's Mini Remote"); + Check.True(Takes("guardian handin"), "guardian"); + Check.True(Takes("bounty show") && Takes("bounties") && Takes("bountys"), "bounty, bounties, bountys"); + Check.True(Takes("rates reset"), "rates reset (the Mini Remote's Reset XP)"); + Check.False(Takes("quests refresh"), "/ra quests is RynthAi's"); + Check.False(Takes("pets show"), "/ra pets is RynthAi's"); + Check.False(Takes("start"), "anything else is RynthAi's"); + // The VTank hotkey verbs (RynthAi 2026-10-13, RynthAiPlugin.VTankHotkeys.cs) stay RynthAi's. + foreach (string vt in new[] { "vtkeys", "targetlock", "recharge", "lootthis", "meleelow", "navprio", "lootprio", "navlootprio", "setmetastate Default", "testitem", "propertydump" }) + Check.False(Takes(vt), $"{vt} is RynthAi's (VTank hotkeys)"); + } + + private static void Classification() + { + Check.Eq(IltObjects.ClassifyByItemType(0x00000800), AcObjectClass.Gem, "gem (aetheria)"); + Check.Eq(IltObjects.ClassifyByItemType(0x00000001), AcObjectClass.MeleeWeapon, "melee weapon"); + Check.Eq(IltObjects.ClassifyByItemType(0x00000100), AcObjectClass.MissileWeapon, "missile weapon"); + Check.Eq(IltObjects.ClassifyByItemType(0x00008000), AcObjectClass.WandStaffOrb, "caster"); + Check.Eq(IltObjects.ClassifyByItemType(0x40000000), AcObjectClass.Salvage, "salvage (white quartz)"); + Check.Eq(IltObjects.ClassifyByItemType(0x00001000), AcObjectClass.SpellComponent, "spell component"); + Check.Eq(IltObjects.ClassifyByItemType(0x00000200), AcObjectClass.Container, "pack"); + Check.Eq(IltObjects.ClassifyByItemType(0x00000010), AcObjectClass.Monster, "creature"); + Check.Eq(IltObjects.ClassifyByItemType(0x00000002 | 0x00000004), AcObjectClass.Armor, "armor wins over clothing"); + Check.Eq(IltObjects.ClassifyByItemType(0), AcObjectClass.Unknown, "no type yet"); + } + + private static unsafe void InterfaceLayout() + { + Check.Eq(sizeof(IltTabV1), 24 + 32 + 4 + 4 + 4, "IltTabV1: id, label, width, height, flags"); + Check.Eq((int)Marshal.OffsetOf(nameof(IltTabV1.Flags)), 64, "IltTabV1.Flags offset"); + Check.Eq(sizeof(RynthIltHubApiV1), 8 + 9 * IntPtr.Size, "RynthIltHubApiV1: header + 9 functions"); + Check.Eq(sizeof(RynthAiHubApiV1), 8 + 10 * IntPtr.Size, "RynthAiHubApiV1: header + 10 functions"); + Check.Eq(sizeof(QuestFlagV1), 24, "QuestFlagV1"); + Check.Eq(sizeof(QuestStatusV1), 16, "QuestStatusV1"); + Check.Eq(RynthIltHubApiV1.InterfaceName, "RynthILT.Hub", "interface name"); + Check.Eq(RynthAiHubApiV1.InterfaceName, "RynthAi.Hub", "RynthAi's interface name"); + } + + private static void DescribeLines() + { + var s = new IltSettings(); + Check.True(ServerFeatureGate.Describe("InfiniteLeaftide", s, false).Contains("ON - matches 'InfiniteLeaftide'"), "on by name"); + Check.True(ServerFeatureGate.Describe("Aelrynth", s, true).Contains("Treat this world as ILT"), "on by the override"); + Check.True(ServerFeatureGate.Describe("Aelrynth", s, false).Contains("OFF"), "off"); + Check.True(ServerFeatureGate.Describe("", s, false).Contains("not logged in"), "before login"); + } + + private static IltHubController NewHub(string world, string folder) + { + RynthCore.RynthAiHostTests.Fakes.FakeHost.Reset(); + RynthCore.RynthAiHostTests.Fakes.FakeHost.WorldName = world; + var host = RynthCore.RynthAiHostTests.Fakes.FakeHost.Create(0x50000F01); + string dir = Path.Combine(Program.TempRoot, "move-" + folder); + Directory.CreateDirectory(dir); + return new IltHubController(host, dir, new IltSettings(), new RynthAiClient(host)); + } + + private static void TickFor(IltHubController hub, int ms) + { + var until = DateTime.UtcNow.AddMilliseconds(ms); + while (DateTime.UtcNow < until) { hub.Tick(); System.Threading.Thread.Sleep(50); } + } + + private static void DormantOffIlt() + { + var off = NewHub("Aeshnidae", "dormant"); + off.OnLoginComplete("Tester", forceFromMigration: false); + foreach (string line in new[] { "Your Pet Log:", "[BANK] Pyreals: 5", "Guardian of Strength tells you, \"x\"" }) off.OnChat(line); + TickFor(off, 6800); // past the 6 s login delay + Check.Eq(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Count, 0, "off ILT: no probe, no command at all"); + Check.False(off.Options.IsIltLikeWorld, "not an ILT world"); + foreach (var s in IltSections.Tabs) Check.False(off.TabShown(s), $"no {IltSections.Label(s)} tab"); + Check.False(off.RenderSection(RynthIltHub.SectionRemoteBank) || off.RenderSection(RynthIltHub.SectionQuestBonus) + || off.RenderSection(RynthIltHub.SectionPetLogs) || off.RenderSection(RynthIltHub.SectionRemoteGuardian) + || off.RenderSection(RynthIltHub.SectionServerMenu), "no ILT section draws (checked before any ImGui call)"); + Check.True(off.BuildProgressionJson().StartsWith("{\"available\":false"), "Progression: not available"); + off.OnLogout(); + + var on = NewHub("InfiniteLeaftide", "awake"); + on.OnLoginComplete("Tester", forceFromMigration: false); + TickFor(on, 6800); + Check.True(on.Options.IsIltLikeWorld, "InfiniteLeaftide is ILT"); + Check.True(RynthCore.RynthAiHostTests.Fakes.FakeHost.ChatCommands.Count > 0, "on ILT the login probe asks the server"); + Check.True(on.TabShown(IltSection.Character), "and the Character tab shows"); + on.OnLogout(); + + var forced = NewHub("Aeshnidae", "forced"); + forced.OnLoginComplete("Tester", forceFromMigration: true); + Check.True(forced.Options.IsIltLikeWorld, "a migrated \"Force enable\" makes the world ILT for this character"); + forced.OnLogout(); + } + + private static unsafe void HubTable() + { + Check.Eq(HubInterface.Query("RynthAi.Hub", 1), IntPtr.Zero, "another interface's name: not ours"); + Check.Eq(HubInterface.Query(RynthIltHubApiV1.InterfaceName, 2), IntPtr.Zero, "a newer version than we have: none"); + var t = (RynthIltHubApiV1*)HubInterface.Query(RynthIltHubApiV1.InterfaceName, 1); + Check.True(t != null, "v1 is served"); + Check.Eq(t->Version, 1u, "Version 1"); + Check.Eq(t->StructSize, (uint)sizeof(RynthIltHubApiV1), "StructSize"); + Check.True(t->IsIltWorld != null && t->GetFeature != null && t->GetRates != null && t->GetForceIlt != null && t->SetForceIlt != null + && t->GetTabs != null && t->RenderTab != null && t->RenderSection != null && t->Command != null, "every function is filled in"); + Check.Eq((IntPtr)t, HubInterface.Query(RynthIltHubApiV1.InterfaceName, 1), "the same table each time"); + + // No plugin instance here (not logged in): every function answers "nothing". + Check.Eq(t->IsIltWorld(), 0, "not ILT before login"); + byte* key = stackalloc byte[] { (byte)'b', (byte)'a', (byte)'n', (byte)'k', 0 }; + Check.Eq(t->GetFeature(key), -1, "feature unknown before login"); + Check.Eq(t->GetTabs(null, 0), 0, "no tabs before login"); + Check.Eq(t->Command(key), 0, "no command taken before login"); + + HubInterface.Release(); + Check.Eq(t->Version, 0u, "Release zeroes Version (callers re-query)"); + Check.Eq(HubInterface.Query(RynthIltHubApiV1.InterfaceName, 1), IntPtr.Zero, "and nothing is served after shutdown"); + Check.Eq(t->IsIltWorld(), 0, "the old table stays callable and answers nothing"); + } +} diff --git a/Tools/RynthILT.Tests/Program.cs b/Tools/RynthILT.Tests/Program.cs index c7ec3bf..23c2f72 100644 --- a/Tools/RynthILT.Tests/Program.cs +++ b/Tools/RynthILT.Tests/Program.cs @@ -5,8 +5,9 @@ using RynthCore.RynthAiTests.Harness; namespace RynthILT.Tests; // Offline tests for the RynthILT plugin: the ACECustom bounty tracker (parsing, merging, the -// quiet /bounty list read loop on a fake clock, persistence, the bridge JSON). Each test prints -// PASS / FAIL. +// quiet /bounty list read loop on a fake clock, persistence, the bridge JSON) and the ILT Hub +// (attribute raiser, aug costs, bank commands, sigil chain, and the move out of RynthAi: data +// migration, the RynthILT.Hub table, verb routing, the object view). Each test prints PASS / FAIL. // // Run: dotnet run -c Release (all tests) // dotnet run -c Release -- window (tests whose name contains "window") @@ -20,9 +21,23 @@ internal static class Program if (Directory.Exists(TempRoot)) Directory.Delete(TempRoot, recursive: true); Directory.CreateDirectory(TempRoot); + // SAFETY: every file the ILT Hub would write under %APPDATA%\RynthCore\RynthILT or read from + // the RynthAi folder points at the scratch folder before any test runs. + RynthCore.Plugin.RynthILT.Hub.IltAugCosts.FilePath = Path.Combine(TempRoot, "ilt-aug-costs.json"); + RynthCore.Plugin.RynthILT.Hub.IltHubStore.SharedRoot = Path.Combine(TempRoot, "RynthILT"); + RynthCore.Plugin.RynthILT.Hub.IltSettingsStore.Folder = Path.Combine(TempRoot, "RynthILT"); + RynthCore.Plugin.RynthILT.Hub.IltMigration.LegacyProfilesBase = Path.Combine(TempRoot, "RynthAi", "SettingsProfiles"); + RynthCore.Plugin.RynthILT.Hub.IltMigration.LegacySharedRoot = Path.Combine(TempRoot, "RynthAi"); + RynthCore.Plugin.RynthILT.RynthLog.Init(default, Path.Combine(TempRoot, "Logs")); + RynthCore.Plugin.Shared.DataWriteGuard.PluginName = "RynthILT"; // as RynthILTPlugin.Initialize sets it + var runner = new Runner(); BountyTests.Register(runner); BountyReviewTests.Register(runner); + AttributeRaiserTests.Register(runner); + SigilChainTests.Register(runner); + BankCommandTests.Register(runner); + MoveTests.Register(runner); return runner.Run("RynthILT tests", args.Length > 0 ? args[0] : null); } } diff --git a/Tools/RynthILT.Tests/RynthILT.Tests.csproj b/Tools/RynthILT.Tests/RynthILT.Tests.csproj index 2263da6..12399d4 100644 --- a/Tools/RynthILT.Tests/RynthILT.Tests.csproj +++ b/Tools/RynthILT.Tests/RynthILT.Tests.csproj @@ -1,28 +1,44 @@ Exe - net10.0 + net10.0-windows + x86 + win-x86 + false enable + true true RynthILT.Tests + RynthILT.Tests + x86 + $(DefineConstants);RYNTHILT_TESTS + $(NoWarn);CS1591 - - - - + + + + + + + + + + diff --git a/Tools/RynthCore.RynthAiHostTests/Tests/SigilChainTests.cs b/Tools/RynthILT.Tests/SigilChainTests.cs similarity index 98% rename from Tools/RynthCore.RynthAiHostTests/Tests/SigilChainTests.cs rename to Tools/RynthILT.Tests/SigilChainTests.cs index ae69f1c..4641eab 100644 --- a/Tools/RynthCore.RynthAiHostTests/Tests/SigilChainTests.cs +++ b/Tools/RynthILT.Tests/SigilChainTests.cs @@ -1,7 +1,7 @@ -using RynthCore.Plugin.RynthAi.IltHub; +using RynthCore.Plugin.RynthILT.Hub; using RynthCore.RynthAiTests.Harness; -namespace RynthCore.RynthAiHostTests.Tests; +namespace RynthILT.Tests; // Enlightenment 301-325 sigil craft chain (2026-10-07). Each target level T costs T - 5 sigils and // T x 2B luminance (ACECustom tier 5). Sigil = Lifeblood Elixir + Ascension Coin; Ascension Coin =