feat: port SK test branch (2026.10.18.24) onto sk
Squash of test/hotbuild-2026-10-16 as merged onto aelrynth main 2026.10.17.1, matching the 2026.10.18.24 test installer. The test branch wins where both changed the same lines; sk-only changes kept; duplicate features cut to the test branch's copy. RynthAi HandWrittenVersion stays 0.5.0-legacy-ui on sk. Highlights: RynthOracle 0.6.0 (Legendary, Markers, Dynamic Stamps and Temple guardians merged into the Quests list, RynthNav Go to), RynthILT 0.2.20 (ub-IT auto-chunk rules, rating level, RynthILT.Data v3), RynthAi ub-IT /ub and VT/MT meta compatibility and the loot attribute checklist, RynthNav destination alternatives. Changelog/2026-10-18-sk-port-test-branch-2026.10.18.24.md.
This commit is contained in:
parent
23efcfee87
commit
7797901d69
287 changed files with 22602 additions and 1090 deletions
78
Plugins/RynthCore.Plugin.RynthInventory/Data/BankRoster.cs
Normal file
78
Plugins/RynthCore.Plugin.RynthInventory/Data/BankRoster.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthInventory.Data;
|
||||
|
||||
/// <summary>One character on the Banking tab: its saved balances (null = never read) and account.</summary>
|
||||
internal sealed record BankRosterEntry(string Name, string Account, bool Current, IltBankRow? Bank);
|
||||
|
||||
/// <summary>
|
||||
/// The Banking tab's character list (2026-10-13; the Mini Remote's Banking tab moved here). Every
|
||||
/// character RynthILT has bank balances for on this server (its saved per-character state, so every
|
||||
/// account played on this PC), plus every character Global Inventory has recorded on the same
|
||||
/// server without a balance yet, so the list covers the same characters as the inventory does.
|
||||
/// Pure: the tests feed it a parsed bank view and an index.
|
||||
/// </summary>
|
||||
internal static class BankRoster
|
||||
{
|
||||
/// <summary>
|
||||
/// The merged list: the logged-in character first, then by name. A name in both lists keeps
|
||||
/// RynthILT's balances and the inventory's account.
|
||||
/// </summary>
|
||||
public static List<BankRosterEntry> Build(IltBankView bank, InventoryIndex? index)
|
||||
{
|
||||
var byName = new Dictionary<string, BankRosterEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (IltBankRow r in bank.Characters)
|
||||
byName[r.Name] = new BankRosterEntry(r.Name, string.Empty, r.Current, r);
|
||||
|
||||
if (index != null)
|
||||
{
|
||||
foreach (CharacterInfo ci in index.Characters)
|
||||
{
|
||||
// Same server only: a bank belongs to one world.
|
||||
if (!SameServer(ci, bank)) continue;
|
||||
string account = !string.IsNullOrEmpty(ci.Account) && ci.Account != "unknown" ? ci.Account : string.Empty;
|
||||
if (byName.TryGetValue(ci.Name, out BankRosterEntry? have))
|
||||
byName[ci.Name] = have with { Account = account, Current = have.Current || ci.IsCurrentCharacter };
|
||||
else
|
||||
byName[ci.Name] = new BankRosterEntry(ci.Name, account, ci.IsCurrentCharacter, null);
|
||||
}
|
||||
}
|
||||
|
||||
var list = new List<BankRosterEntry>(byName.Values);
|
||||
list.Sort((a, b) => a.Current != b.Current ? (a.Current ? -1 : 1) : string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A recorded character is on the bank's server: the world RynthILT names when it gave one,
|
||||
/// otherwise the server Global Inventory says you are on now.
|
||||
/// </summary>
|
||||
private static bool SameServer(CharacterInfo ci, IltBankView bank) =>
|
||||
bank.World.Length > 0 ? InventoryIndex.SameName(ci.Server, bank.World) : ci.IsCurrentServer;
|
||||
|
||||
/// <summary>The sums over every character with a balance (one row of the same shape).</summary>
|
||||
public static IltBankRow Totals(IReadOnlyList<BankRosterEntry> roster)
|
||||
{
|
||||
long py = 0, lum = 0, lk = 0, mk = 0, ec = 0, wec = 0, pc = 0;
|
||||
foreach (BankRosterEntry e in roster)
|
||||
{
|
||||
if (e.Bank is not { } b) continue;
|
||||
py += b.Pyreals; lum += b.Luminance; lk += b.LegendaryKeys; mk += b.MythicalKeys;
|
||||
ec += b.EnlightenedCoins; wec += b.WeaklyEnlightenedCoins; pc += b.PrestigeCoins;
|
||||
}
|
||||
return new IltBankRow("Total", false, py, lum, lk, mk, ec, wec, pc, DateTime.MinValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The withdraw / transfer amount typed in the form: a positive whole number (commas and spaces
|
||||
/// allowed), or 0 when it isn't one.
|
||||
/// </summary>
|
||||
public static long ParseAmount(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text)) return 0;
|
||||
string digits = text.Replace(",", string.Empty).Replace(" ", string.Empty).Trim();
|
||||
return long.TryParse(digits, System.Globalization.NumberStyles.None, System.Globalization.CultureInfo.InvariantCulture, out long n) && n > 0 ? n : 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,13 @@ internal sealed class InventoryContext
|
|||
public bool IconsAvailable;
|
||||
public DateTime UtcNow;
|
||||
|
||||
/// <summary>RynthILT's "RynthILT.Data" (the Banking tab's balances and bank commands).</summary>
|
||||
public readonly RynthCore.Plugin.Shared.RynthIltDataClient IltData = new();
|
||||
/// <summary>The bank RynthILT last reported (None without RynthILT); read while the window shows.</summary>
|
||||
public RynthCore.Plugin.Shared.IltBankView Bank = RynthCore.Plugin.Shared.IltBankView.None;
|
||||
/// <summary>Set by the plugin: queues a bank verb with RynthILT (IltBankView.*Verb); false when refused.</summary>
|
||||
public Func<string, bool> BankCommand = _ => false;
|
||||
|
||||
public Action RequestRescan = () => { };
|
||||
public Action RequestReload = () => { };
|
||||
/// <summary>Forgets a character (moves its file aside). Returns a message for the player.</summary>
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public static unsafe class PluginExports
|
|||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginVersion", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
public static IntPtr GetVersion()
|
||||
{
|
||||
try { return LiteralPointer("0.1.0"u8); }
|
||||
try { return LiteralPointer("0.1.4"u8); } // = RynthInventoryPlugin.Version
|
||||
catch { return IntPtr.Zero; }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@
|
|||
<ItemGroup>
|
||||
<!-- Server signal vs a player's copy of it (VaultFeed). Also linked by RynthInventory.Tests. -->
|
||||
<Compile Include="..\Shared\ChatSource.cs" Link="Shared\ChatSource.cs" />
|
||||
<!-- RynthILT's "RynthILT.Data" interface: the Banking tab's balances for every character on the server. -->
|
||||
<Compile Include="..\Shared\RynthIltDataApi.cs" Link="Shared\RynthIltDataApi.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,14 @@ namespace RynthCore.Plugin.RynthInventory;
|
|||
/// </summary>
|
||||
public sealed class RynthInventoryPlugin : RynthPluginBase
|
||||
{
|
||||
public const string Version = "0.1.2";
|
||||
// Previous release: 0.1.3. Keep in step with PluginExports.GetVersion.
|
||||
public const string Version = "0.1.4";
|
||||
|
||||
// RynthILT's bank JSON: every BankTabReadMs on the Banking tab, every BankIdleReadMs with the
|
||||
// window on another tab (so the Banking button appears on ILT worlds), never with it closed.
|
||||
private const long BankTabReadMs = 2000, BankIdleReadMs = 10_000;
|
||||
private long _nextBankReadMs;
|
||||
private string _bankJson = string.Empty;
|
||||
|
||||
private const long IdentityRetryMs = 1000;
|
||||
private const long AccountWaitMs = 15_000;
|
||||
|
|
@ -86,6 +93,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_c.RequestRescan = () => { _scheduler.RequestFullScan(); _forceWrite = true; };
|
||||
_c.RequestReload = () => { _reloadWanted = true; _files.Clear(); };
|
||||
_c.Forget = ForgetCharacter;
|
||||
_c.BankCommand = SendBankVerb;
|
||||
_ui.Log = msg => Host.Log(msg);
|
||||
_vault = new VaultFeed(text => Host.InvokeChatParser(text));
|
||||
|
||||
|
|
@ -123,9 +131,44 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_carriedIds.Clear();
|
||||
_carriedPacks.Clear();
|
||||
RefreshIconSupport();
|
||||
ClearBank();
|
||||
if (_window != null) { _window.Visible = _c.Settings.MainWindowOpen; _window.NeedsPass = true; }
|
||||
}
|
||||
|
||||
/// <summary>Forgets the last bank read (login, logout): the next character's comes fresh.</summary>
|
||||
private void ClearBank()
|
||||
{
|
||||
_c.Bank = Shared.IltBankView.None;
|
||||
_bankJson = string.Empty;
|
||||
_nextBankReadMs = 0;
|
||||
}
|
||||
|
||||
/// <summary>The Banking tab's actions: a verb line for RynthILT, then a quick re-read for its reply.</summary>
|
||||
private bool SendBankVerb(string verb)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
bool ok = _c.InWorld && _c.IltData.BankCommand(Host, now, verb);
|
||||
_nextBankReadMs = now + 500;
|
||||
if (_window != null) _window.NeedsPass = true;
|
||||
return ok;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads RynthILT's bank JSON while the window is open (more often on the Banking tab) and
|
||||
/// redraws when it changed. Reading is what tells RynthILT someone is looking.
|
||||
/// </summary>
|
||||
private void TickBank(long now)
|
||||
{
|
||||
if (!_c.InWorld || _window == null || _view == null || !_window.Visible) return;
|
||||
if (now < _nextBankReadMs) return;
|
||||
_nextBankReadMs = now + (_view.Tab == InventoryView.TabBanking ? BankTabReadMs : BankIdleReadMs);
|
||||
string json = _c.IltData.ReadBank(Host, now);
|
||||
if (string.Equals(json, _bankJson, StringComparison.Ordinal)) return;
|
||||
_bankJson = json;
|
||||
_c.Bank = Shared.IltBankView.Parse(json);
|
||||
_window.NeedsPass = true;
|
||||
}
|
||||
|
||||
public override void OnLogout()
|
||||
{
|
||||
// Last word for this character: write what it has now (also refreshes its "scanned" time).
|
||||
|
|
@ -138,6 +181,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
_ui.SubmitEmpty(Host);
|
||||
_c.Live = null;
|
||||
_indexDirty = true;
|
||||
ClearBank();
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
|
@ -217,12 +261,6 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
case "":
|
||||
if (_window != null) { _window.Visible = !_window.Visible; _window.NeedsPass = true; }
|
||||
break;
|
||||
// Old Mini Remote "Banking" tab ("/ginv bank"): open Global Inventory (don't search
|
||||
// for "bank"). Storage containers still show when Include Storage is on.
|
||||
case "bank":
|
||||
case "banking":
|
||||
if (_window != null) { _window.Visible = true; _window.NeedsPass = true; }
|
||||
break;
|
||||
case "scan":
|
||||
case "rescan":
|
||||
_scheduler.RequestFullScan();
|
||||
|
|
@ -245,9 +283,17 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
case "status":
|
||||
PrintStatus();
|
||||
break;
|
||||
case "bank":
|
||||
case "banking":
|
||||
// The Banking tab (the Mini Remote's Banking tab moved here 2026-10-13; RynthCore,
|
||||
// RynthAi and RynthILT link here). Shows, never toggles off.
|
||||
_view?.ShowBanking();
|
||||
_nextBankReadMs = 0;
|
||||
if (_window != null) { _window.Visible = true; _window.NeedsPass = true; }
|
||||
break;
|
||||
case "help":
|
||||
case "?":
|
||||
_c.Print("/ginv (window), /ginv bank (same), /ginv <text> (search), /ginv scan (rescan and save now), /ginv keep (record the open container as storage), /ginv vault (read the Aelrynth account vault now), /ginv reload, /ginv status");
|
||||
_c.Print("/ginv (window), /ginv <text> (search), /ginv bank (every character's Infinite Leaftide bank), /ginv scan (rescan and save now), /ginv keep (record the open container as storage), /ginv vault (read the Aelrynth account vault now), /ginv reload, /ginv status");
|
||||
break;
|
||||
default:
|
||||
_view?.SetSearch(arg);
|
||||
|
|
@ -315,6 +361,7 @@ public sealed class RynthInventoryPlugin : RynthPluginBase
|
|||
}
|
||||
TickWrite(now);
|
||||
TickIndex(now);
|
||||
TickBank(now);
|
||||
|
||||
if (!Host.HasUi || _window == null || _view == null) return;
|
||||
Record(_window, now, 2000, _view.Draw);
|
||||
|
|
|
|||
237
Plugins/RynthCore.Plugin.RynthInventory/Views/BankingTab.cs
Normal file
237
Plugins/RynthCore.Plugin.RynthInventory/Views/BankingTab.cs
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using RynthCore.Plugin.RynthInventory.Data;
|
||||
using RynthCore.Plugin.RynthInventory.Ui;
|
||||
using RynthCore.Plugin.Shared;
|
||||
|
||||
namespace RynthCore.Plugin.RynthInventory.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Banking: the Infinite Leaftide bank of every character on this server (the Mini Remote's Banking
|
||||
/// tab moved here 2026-10-13). Balances, form choices and the last reply come from RynthILT's
|
||||
/// "RynthILT.Data" bank JSON; the character list adds the inventory's characters on the same server
|
||||
/// (BankRoster). Deposits, withdrawals, transfers and balance reads go back to RynthILT as verb lines;
|
||||
/// a transfer is confirmed here first (RynthILT doesn't ask again).
|
||||
/// </summary>
|
||||
internal sealed partial class InventoryView
|
||||
{
|
||||
private const int MaxTransactionsShown = 20;
|
||||
private const float ColPyreals = 150f, ColLum = 270f, ColKeys = 380f, ColCoins = 450f, ColUpdated = 560f;
|
||||
|
||||
private int _depositIndex, _withdrawIndex, _withdrawNote, _transferIndex, _transferNote;
|
||||
private string _withdrawAmount = string.Empty, _transferAmount = string.Empty, _transferTo = string.Empty;
|
||||
/// <summary>The transfer waiting for "Yes, send": its verb line and the sentence shown.</summary>
|
||||
private (string Verb, string Text)? _confirmTransfer;
|
||||
private string _bankMessage = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The Banking tab button shows when RynthILT answered on an ILT world, or when the tab was asked
|
||||
/// for (/ginv bank) so it can say what is missing.
|
||||
/// </summary>
|
||||
private bool BankingShown => Tab == TabBanking || (_c.Bank.Loaded && _c.Bank.Available);
|
||||
|
||||
/// <summary>Opens on the Banking tab ("/ginv bank", RynthAi's and RynthILT's bank links).</summary>
|
||||
public void ShowBanking()
|
||||
{
|
||||
Tab = TabBanking;
|
||||
_confirmTransfer = null;
|
||||
}
|
||||
|
||||
private void DrawBanking(UiWindow w)
|
||||
{
|
||||
IltBankView b = _c.Bank;
|
||||
if (!b.Loaded)
|
||||
{
|
||||
w.TextDisabled("The bank comes from RynthILT (Infinite Leaftide). Load RynthILT to see every character's bank here.");
|
||||
return;
|
||||
}
|
||||
if (!b.Available)
|
||||
{
|
||||
w.TextDisabled("This isn't an Infinite Leaftide world, so there is no bank to show.");
|
||||
return;
|
||||
}
|
||||
|
||||
w.Text($"Bank on {(b.World.Length > 0 ? b.World : "this server")}");
|
||||
w.SameLine();
|
||||
w.SmallButton("Refresh", "b.refresh", () => SendBank(IltBankView.RefreshVerb(), "Reading the balance..."));
|
||||
w.Tooltip("A quiet /bank balance read for the character you're on (other characters update when they log in).");
|
||||
if (b.Enabled == 0) w.TextColored(UiColors.Red, "This server has no /bank command.");
|
||||
else if (b.Enabled < 0) w.TextDisabled("Whether this server has /bank isn't known yet.");
|
||||
if (b.Result.Length > 0) w.TextColored(UiColors.Gold, b.Result);
|
||||
if (_bankMessage.Length > 0) w.TextColored(UiColors.Yellow, _bankMessage);
|
||||
|
||||
List<BankRosterEntry> roster = BankRoster.Build(b, _c.Index);
|
||||
DrawBankTable(w, roster);
|
||||
if (b.Enabled != 0)
|
||||
{
|
||||
DrawDeposit(w, b);
|
||||
DrawWithdraw(w, b);
|
||||
DrawTransfer(w, b, roster);
|
||||
}
|
||||
DrawTransactions(w, b);
|
||||
}
|
||||
|
||||
private void DrawBankTable(UiWindow w, List<BankRosterEntry> roster)
|
||||
{
|
||||
w.SeparatorText($"Characters ({roster.Count})");
|
||||
w.TextDisabled("Character");
|
||||
w.SameLine(ColPyreals); w.TextDisabled("Pyreals");
|
||||
w.SameLine(ColLum); w.TextDisabled("Luminance");
|
||||
w.SameLine(ColKeys); w.TextDisabled("Keys L/M");
|
||||
w.SameLine(ColCoins); w.TextDisabled("Coins E/W/P");
|
||||
w.SameLine(ColUpdated); w.TextDisabled("Updated");
|
||||
foreach (BankRosterEntry e in roster)
|
||||
{
|
||||
string name = e.Current ? e.Name + " (you)" : e.Name;
|
||||
if (e.Bank is { } r)
|
||||
{
|
||||
w.Text(name);
|
||||
if (e.Account.Length > 0) w.Tooltip("Account: " + e.Account);
|
||||
BankCells(w, r);
|
||||
w.SameLine(ColUpdated);
|
||||
w.TextDisabled(r.UpdatedUtc == DateTime.MinValue ? "-" : InventoryIndex.Age(r.UpdatedUtc, _c.UtcNow));
|
||||
}
|
||||
else
|
||||
{
|
||||
w.TextDisabled(name);
|
||||
if (e.Account.Length > 0) w.Tooltip("Account: " + e.Account);
|
||||
w.SameLine(ColPyreals);
|
||||
w.TextDisabled("not read yet: log in with RynthILT loaded");
|
||||
}
|
||||
}
|
||||
if (roster.Count == 0) w.TextDisabled("No characters on this server yet.");
|
||||
else
|
||||
{
|
||||
w.TextColored(UiColors.Gold, "Total");
|
||||
BankCells(w, BankRoster.Totals(roster));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The balance columns of one row (Pyreals .. Coins).</summary>
|
||||
private static void BankCells(UiWindow w, IltBankRow r)
|
||||
{
|
||||
w.SameLine(ColPyreals); w.Text(N(r.Pyreals));
|
||||
w.SameLine(ColLum); w.Text(N(r.Luminance));
|
||||
w.SameLine(ColKeys); w.Text($"{N(r.LegendaryKeys)}/{N(r.MythicalKeys)}");
|
||||
w.SameLine(ColCoins); w.Text($"{N(r.EnlightenedCoins)}/{N(r.WeaklyEnlightenedCoins)}/{N(r.PrestigeCoins)}");
|
||||
}
|
||||
|
||||
private void DrawDeposit(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Deposits.Count == 0) return;
|
||||
w.SeparatorText("Deposit");
|
||||
_depositIndex = Math.Clamp(_depositIndex, 0, b.Deposits.Count - 1);
|
||||
w.Combo("What", "b.dep.what", _depositIndex, b.Deposits, i => _depositIndex = i);
|
||||
w.SameLine();
|
||||
int di = _depositIndex;
|
||||
string label = b.Deposits[di];
|
||||
w.SmallButton("Deposit", "b.dep.go", () => SendBank(IltBankView.DepositVerb(di), "Depositing " + label + "..."));
|
||||
}
|
||||
|
||||
private void DrawWithdraw(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Withdrawals.Count == 0) return;
|
||||
w.SeparatorText("Withdraw");
|
||||
_withdrawIndex = Math.Clamp(_withdrawIndex, 0, b.Withdrawals.Count - 1);
|
||||
w.Combo("Currency", "b.wd.what", _withdrawIndex, Labels(b.Withdrawals), i => _withdrawIndex = i);
|
||||
IltBankChoice choice = b.Withdrawals[_withdrawIndex];
|
||||
w.InputText(choice.Notes ? "Notes" : "Amount", "b.wd.amt", _withdrawAmount, 20, v => _withdrawAmount = v);
|
||||
int note = NoteCombo(w, b, choice, "b.wd.note", _withdrawNote, i => _withdrawNote = i);
|
||||
w.SameLine();
|
||||
int wi = _withdrawIndex;
|
||||
w.SmallButton("Withdraw", "b.wd.go", () =>
|
||||
{
|
||||
long amount = BankRoster.ParseAmount(_withdrawAmount);
|
||||
if (amount <= 0) { _bankMessage = "Type a whole number to withdraw."; return; }
|
||||
SendBank(IltBankView.WithdrawVerb(wi, amount, note), $"Withdrawing {N(amount)} {choice.Label}...");
|
||||
});
|
||||
}
|
||||
|
||||
private void DrawTransfer(UiWindow w, IltBankView b, List<BankRosterEntry> roster)
|
||||
{
|
||||
if (b.Transfers.Count == 0) return;
|
||||
w.SeparatorText("Transfer");
|
||||
_transferIndex = Math.Clamp(_transferIndex, 0, b.Transfers.Count - 1);
|
||||
w.Combo("Currency", "b.tx.what", _transferIndex, Labels(b.Transfers), i => { _transferIndex = i; _confirmTransfer = null; });
|
||||
IltBankChoice choice = b.Transfers[_transferIndex];
|
||||
w.InputText(choice.Notes ? "Notes" : "Amount", "b.tx.amt", _transferAmount, 20, v => { _transferAmount = v; _confirmTransfer = null; });
|
||||
int note = NoteCombo(w, b, choice, "b.tx.note", _transferNote, i => { _transferNote = i; _confirmTransfer = null; });
|
||||
w.InputText("To", "b.tx.to", _transferTo, 40, v => { _transferTo = v; _confirmTransfer = null; });
|
||||
|
||||
// The other characters on this server, to fill "To" with one click.
|
||||
var others = new List<string> { "Pick a character..." };
|
||||
foreach (BankRosterEntry e in roster) if (!e.Current) others.Add(e.Name);
|
||||
if (others.Count > 1)
|
||||
{
|
||||
w.SameLine();
|
||||
w.Combo("##pick", "b.tx.pick", 0, others, i => { if (i > 0 && i < others.Count) { _transferTo = others[i]; _confirmTransfer = null; } });
|
||||
}
|
||||
|
||||
if (_confirmTransfer is { } pending)
|
||||
{
|
||||
w.TextColored(UiColors.Red, pending.Text);
|
||||
w.SmallButton("Yes, send", "b.tx.yes", () =>
|
||||
{
|
||||
_confirmTransfer = null;
|
||||
SendBank(pending.Verb, "Transfer sent...");
|
||||
});
|
||||
w.SameLine();
|
||||
w.SmallButton("Cancel", "b.tx.no", () => _confirmTransfer = null);
|
||||
return;
|
||||
}
|
||||
int ti = _transferIndex;
|
||||
w.SmallButton("Transfer...", "b.tx.go", () =>
|
||||
{
|
||||
long amount = BankRoster.ParseAmount(_transferAmount);
|
||||
string to = (_transferTo ?? string.Empty).Trim();
|
||||
if (amount <= 0) { _bankMessage = "Type a whole number to transfer."; return; }
|
||||
if (to.Length == 0) { _bankMessage = "Type (or pick) who gets the transfer."; return; }
|
||||
string what = choice.Notes && note < b.Notes.Count ? $"{N(amount)} x {b.Notes[note].Label}" : $"{N(amount)} {choice.Label}";
|
||||
_confirmTransfer = (IltBankView.TransferVerb(ti, amount, note, to), $"Send {what} to {to}? This can't be undone.");
|
||||
_bankMessage = string.Empty;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The trade-note combo for a choice that counts notes; returns the note index in use (0 when
|
||||
/// the choice isn't notes). A pick arrives as an event and lands in <paramref name="set"/>.
|
||||
/// </summary>
|
||||
private static int NoteCombo(UiWindow w, IltBankView b, IltBankChoice choice, string id, int index, Action<int> set)
|
||||
{
|
||||
if (!choice.Notes || b.Notes.Count == 0) return 0;
|
||||
var labels = new List<string>(b.Notes.Count);
|
||||
foreach (IltBankNote n in b.Notes) labels.Add($"{n.Label} ({N(n.Value)} pyreals)");
|
||||
index = Math.Clamp(index, 0, b.Notes.Count - 1);
|
||||
w.Combo("Note", id, index, labels, set);
|
||||
return index;
|
||||
}
|
||||
|
||||
private void DrawTransactions(UiWindow w, IltBankView b)
|
||||
{
|
||||
if (b.Transactions.Count == 0) return;
|
||||
if (!w.CollapsingHeader($"Recent transfers ({b.Transactions.Count})", "b.txlog")) return;
|
||||
int shown = 0;
|
||||
foreach (IltBankTx t in b.Transactions)
|
||||
{
|
||||
if (shown++ >= MaxTransactionsShown) { w.TextDisabled($"...and {b.Transactions.Count - MaxTransactionsShown} more."); break; }
|
||||
string dir = t.Type.Length > 0 ? t.Type : "?";
|
||||
w.Text($"{t.When} {dir} {N(t.Amount)} {t.Currency}{(t.Player.Length > 0 ? " - " + t.Player : "")}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Hands a verb to RynthILT; says so when it was refused.</summary>
|
||||
private void SendBank(string verb, string sending)
|
||||
{
|
||||
_bankMessage = _c.BankCommand(verb) ? sending : "RynthILT didn't take that (is it loaded, and are you logged in?).";
|
||||
}
|
||||
|
||||
private static List<string> Labels(IReadOnlyList<IltBankChoice> choices)
|
||||
{
|
||||
var list = new List<string>(choices.Count);
|
||||
foreach (IltBankChoice c in choices) list.Add(c.Label);
|
||||
return list;
|
||||
}
|
||||
|
||||
private static string N(long n) => n.ToString("N0", CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
|
@ -8,12 +8,12 @@ namespace RynthCore.Plugin.RynthInventory.Views;
|
|||
|
||||
/// <summary>
|
||||
/// The Global Inventory window: a search page (every character on every server, filters,
|
||||
/// totals, results, details) and a characters page (snapshot ages, forget). Recorded on the
|
||||
/// pump thread, replayed by the engine.
|
||||
/// totals, results, details), a characters page (snapshot ages, forget) and, with RynthILT, a
|
||||
/// Banking page (Views\BankingTab.cs). Recorded on the pump thread, replayed by the engine.
|
||||
/// </summary>
|
||||
internal sealed class InventoryView
|
||||
internal sealed partial class InventoryView
|
||||
{
|
||||
public const int TabSearch = 0, TabCharacters = 1;
|
||||
public const int TabSearch = 0, TabCharacters = 1, TabBanking = 2;
|
||||
private const int PageSize = 100;
|
||||
private const float RowIcon = 18f, DetailIcon = 32f, DetailsHeight = 190f;
|
||||
|
||||
|
|
@ -58,10 +58,21 @@ internal sealed class InventoryView
|
|||
w.SameLine();
|
||||
int chars = _c.Index?.Characters.Count ?? 0;
|
||||
w.ToggleButton($"Characters ({chars})", "tab.chars", Tab == TabCharacters, () => Tab = TabCharacters, small: true);
|
||||
if (BankingShown)
|
||||
{
|
||||
w.SameLine();
|
||||
w.ToggleButton("Banking", "tab.bank", Tab == TabBanking, () => Tab = TabBanking, small: true);
|
||||
}
|
||||
w.SameLine();
|
||||
w.TextDisabled(StatusLine());
|
||||
w.Separator();
|
||||
|
||||
// The bank comes from RynthILT, not the inventory files: it draws before they are read.
|
||||
if (Tab == TabBanking)
|
||||
{
|
||||
DrawBanking(w);
|
||||
return;
|
||||
}
|
||||
if (_c.Index == null)
|
||||
{
|
||||
w.TextDisabled(_c.Loading ? "Reading the inventory files..." : "No inventory read yet.");
|
||||
|
|
|
|||
Loading…
Reference in a new issue