RynthServers as of 2026-11-08 (internal 471970b): release 2026.11.8.1
This commit is contained in:
parent
f9db7bad87
commit
e52923ba5c
40 changed files with 4831 additions and 31 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>AChard</RynthPluginServerName>
|
<RynthPluginServerName>AChard</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>a-chard.ddns.net</RynthPluginServerHosts>
|
<RynthPluginServerHosts>a-chard.ddns.net</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>AChard|A-Chard</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>AChard|A-Chard</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>AChard only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>AChard only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
<RynthPluginServerName>Aelrynth</RynthPluginServerName>
|
<RynthPluginServerName>Aelrynth</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>aelrynth.com|144.217.84.148</RynthPluginServerHosts>
|
<RynthPluginServerHosts>aelrynth.com|144.217.84.148</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Aelrynth*|Aeshnidae*</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Aelrynth*|Aeshnidae*</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Aelrynth only: the server card (its mods, links, account setup), Aelrynth's leaderboards and Trials records in the Mini Remote, the account vault in Global Inventory, the difficulty tier for RynthAi, and Aelrynth's quests in RynthOracle.</RynthPluginDescription>
|
<RynthPluginDescription>Aelrynth only: the server card (its mods, links, account setup), Aelrynth's leaderboards and Trials records in its own window on the RynthCore bar, the account vault in Global Inventory, the difficulty tier for RynthAi, and Aelrynth's quests in RynthOracle.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Coldeve</RynthPluginServerName>
|
<RynthPluginServerName>Coldeve</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>play.coldeve.ac</RynthPluginServerHosts>
|
<RynthPluginServerHosts>play.coldeve.ac</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Coldeve</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Coldeve</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Coldeve only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Coldeve only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
<RynthPluginServerName>Conquest</RynthPluginServerName>
|
<RynthPluginServerName>Conquest</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>acconquest.ddns.net</RynthPluginServerHosts>
|
<RynthPluginServerHosts>acconquest.ddns.net</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Conquest|ConquestAC</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Conquest|ConquestAC</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Conquest only: the server card, and Conquest's bank (with auto-deposit), augmentations, levels past 275, fellowships, custom quests and leaderboards in the Mini Remote, and Conquest's quests in RynthOracle.</RynthPluginDescription>
|
<RynthPluginDescription>Conquest only: the server card, and Conquest's bank (with auto-deposit), augmentations, levels past 275, fellowships, custom quests and leaderboards in its own window on the RynthCore bar, and Conquest's quests in RynthOracle.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Derptide</RynthPluginServerName>
|
<RynthPluginServerName>Derptide</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>ac.derptide.net</RynthPluginServerHosts>
|
<RynthPluginServerHosts>ac.derptide.net</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Derptide</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Derptide</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Derptide only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Derptide only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,146 @@
|
||||||
|
// AttributesTitles.cs - The Attributes and Titles pages of the DreamWeave Skills panel (2026-11-07, Tom:
|
||||||
|
// "build the attributes and titles tabs ... make it complete"): the rows they show, their footer text and
|
||||||
|
// the character's titles as the server sent them. Pure (no ImGui, no host): RynthServerPack.Tests covers it.
|
||||||
|
//
|
||||||
|
// Attributes: the six attributes and three vital maximums, in retail's order, with retail's icons and
|
||||||
|
// hover text (the Character panel's), base and buffed values and raise costs from the engine's training
|
||||||
|
// numbers (GetTrainingInfo, as the skills), and the vitals' current values ("250/300", as retail).
|
||||||
|
//
|
||||||
|
// Titles: the server sends the whole list once, at login (game event 0x0029 CharacterTitle: u32 1, u32 the
|
||||||
|
// displayed title, u32 count, count x u32 title ids) and one title at a time after (0x002B UpdateTitle: u32
|
||||||
|
// title, u32 set-as-displayed). The plugin keeps them per character in its settings, so a hot reload (which
|
||||||
|
// misses the login's list) still has them. Choosing one sends game action 0x002C through "/rc title <id>".
|
||||||
|
using System;
|
||||||
|
using System.Buffers.Binary;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
/// <summary>One attribute (Kind 1, Stype 1..6) or vital maximum (Kind 2, Stype 1 health, 3 stamina, 5 mana).</summary>
|
||||||
|
internal sealed record AttributeLine(int Kind, uint Stype, string Name, uint Icon, int Base, int Buffed,
|
||||||
|
long CostOne, long CostTen, bool Raisable, bool AtTop, uint Ranks, uint XpSpent, int Current = -1)
|
||||||
|
{
|
||||||
|
public int BuffDelta => Buffed - Base;
|
||||||
|
public bool IsVital => Kind == 2;
|
||||||
|
|
||||||
|
/// <summary>The row's value: an attribute's buffed value, a vital's "current/maximum".</summary>
|
||||||
|
public string ValueText => IsVital && Current >= 0
|
||||||
|
? Current.ToString(CultureInfo.InvariantCulture) + "/" + Buffed.ToString(CultureInfo.InvariantCulture)
|
||||||
|
: Buffed.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static class AttributesPage
|
||||||
|
{
|
||||||
|
/// <summary>Retail's rows, in its order: (kind, stype, name, icon, hover text).</summary>
|
||||||
|
public static readonly (int Kind, uint Stype, string Name, uint Icon, string Tip)[] Rows =
|
||||||
|
{
|
||||||
|
(1, 1, "Strength", 0x060002C8u, "Measures your character's muscular power."),
|
||||||
|
(1, 2, "Endurance", 0x060002C4u, "Measures how healthy your character is."),
|
||||||
|
(1, 4, "Coordination", 0x060002C9u, "Measures your character's reflexes"),
|
||||||
|
(1, 3, "Quickness", 0x060002C6u, "Measures how fast your character is."),
|
||||||
|
(1, 5, "Focus", 0x060002C5u, "Measures your character's mind and senses."),
|
||||||
|
(1, 6, "Self", 0x060002C7u, "Measures your character's willpower."),
|
||||||
|
(2, 1, "Health", 0x06004C3Bu, "(Endurance/2)\nIf you run out of health, you will die!"),
|
||||||
|
(2, 3, "Stamina", 0x06004C3Cu, "(Endurance)\nAffects your actions and movement."),
|
||||||
|
(2, 5, "Mana", 0x06004C3Du, "(Self)\nAffects how much magic you can cast."),
|
||||||
|
};
|
||||||
|
|
||||||
|
public static int RowIndex(int kind, uint stype) => Array.FindIndex(Rows, r => r.Kind == kind && r.Stype == stype);
|
||||||
|
|
||||||
|
public static string Tip(AttributeLine a)
|
||||||
|
{
|
||||||
|
int i = RowIndex(a.Kind, a.Stype);
|
||||||
|
return i >= 0 ? Rows[i].Tip : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The footer's title: "Strength: 250" and the buff part (" (+10)").</summary>
|
||||||
|
public static (string Text, string Delta) FooterTitle(AttributeLine? a)
|
||||||
|
{
|
||||||
|
if (a == null) return ("Select an Attribute to Improve", "");
|
||||||
|
int d = a.BuffDelta;
|
||||||
|
return (a.Name + ": " + a.Buffed.ToString(CultureInfo.InvariantCulture), d > 0 ? $" (+{d})" : d < 0 ? $" ({d})" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ((string Label, string Value) One, (string Label, string Value) Two) FooterLines(SkillsSheet sheet, AttributeLine? a)
|
||||||
|
{
|
||||||
|
string credits = sheet.SkillCredits >= 0 ? SkillsSheet.Number(sheet.SkillCredits) : "";
|
||||||
|
string unassigned = sheet.UnassignedXp >= 0 ? SkillsSheet.Xp(sheet.UnassignedXp) : "";
|
||||||
|
if (a == null) return (("Skill Credits Available:", credits), ("Unassigned Experience:", unassigned));
|
||||||
|
return (("Experience To Raise:", a.CostOne > 0 ? SkillsSheet.Xp(a.CostOne) : "Infinity!"), ("Unassigned Experience:", unassigned));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CanRaiseOne(SkillsSheet sheet, AttributeLine a)
|
||||||
|
=> !sheet.Busy && a.Raisable && a.CostOne > 0 && sheet.UnassignedXp >= a.CostOne;
|
||||||
|
|
||||||
|
public static bool CanRaiseTen(SkillsSheet sheet, AttributeLine a)
|
||||||
|
=> !sheet.Busy && a.Raisable && a.CostTen > 0 && sheet.UnassignedXp >= a.CostTen;
|
||||||
|
|
||||||
|
/// <summary>The way through the current rank (0..1) on the attribute or vital chart: the footer's blue bar.</summary>
|
||||||
|
public static float RankProgress(AttributeLine a)
|
||||||
|
{
|
||||||
|
uint[] chart = a.IsVital ? RetailData.VitalXp : RetailData.AttributeXp;
|
||||||
|
if (a.AtTop || a.Ranks + 1 >= chart.Length) return 0f;
|
||||||
|
uint from = chart[a.Ranks], to = chart[a.Ranks + 1];
|
||||||
|
if (to <= from || a.XpSpent <= from) return 0f;
|
||||||
|
if (a.XpSpent >= to) return 1f;
|
||||||
|
return (float)((double)(a.XpSpent - from) / (to - from));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The character's titles: the one displayed and every one earned (ids, CharacterTitleId's numbers).</summary>
|
||||||
|
internal sealed record TitleList(uint Displayed, IReadOnlyList<uint> Earned)
|
||||||
|
{
|
||||||
|
public static readonly TitleList Empty = new(0, Array.Empty<uint>());
|
||||||
|
|
||||||
|
public bool Known => Earned.Count > 0;
|
||||||
|
|
||||||
|
/// <summary>The earned titles' text, sorted as retail's list (by text, then id); unknown ids left out.</summary>
|
||||||
|
public List<(uint Id, string Text)> Sorted()
|
||||||
|
=> Earned.Select(id => (Id: id, Text: SkillsLayout.Title((int)id)))
|
||||||
|
.Where(t => t.Text.Length > 0)
|
||||||
|
.OrderBy(t => t.Text, StringComparer.Ordinal).ThenBy(t => t.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
/// <summary>Game event 0x0029 CharacterTitle's body: u32 1, u32 displayed, u32 count, count x u32.</summary>
|
||||||
|
public static bool TryParseTable(ReadOnlySpan<byte> body, out TitleList list)
|
||||||
|
{
|
||||||
|
list = Empty;
|
||||||
|
if (body.Length < 12) return false;
|
||||||
|
uint displayed = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(4));
|
||||||
|
uint count = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(8));
|
||||||
|
if (count > 10000 || body.Length < 12 + 4 * (long)count) return false;
|
||||||
|
var ids = new List<uint>((int)count);
|
||||||
|
for (int i = 0; i < count; i++) ids.Add(BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(12 + 4 * i)));
|
||||||
|
list = new TitleList(displayed, ids);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Game event 0x002B UpdateTitle's body (u32 title, u32 set as displayed) applied to this list.</summary>
|
||||||
|
public TitleList WithUpdate(ReadOnlySpan<byte> body)
|
||||||
|
{
|
||||||
|
if (body.Length < 8) return this;
|
||||||
|
uint id = BinaryPrimitives.ReadUInt32LittleEndian(body);
|
||||||
|
bool display = BinaryPrimitives.ReadUInt32LittleEndian(body.Slice(4)) != 0;
|
||||||
|
var earned = Earned.Contains(id) || id == 0 ? Earned : Earned.Append(id).ToList();
|
||||||
|
return new TitleList(display ? id : Displayed, earned);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A copy with another displayed title (CharacterTitleId changed, e.g. after Set as Display Title).</summary>
|
||||||
|
public TitleList WithDisplayed(uint id) => id == 0 || id == Displayed ? this : new TitleList(id, Earned);
|
||||||
|
|
||||||
|
/// <summary>"433|1,7,433" for the plugin's settings.</summary>
|
||||||
|
public string Save() => Displayed.ToString(CultureInfo.InvariantCulture) + "|" + string.Join(",", Earned.Select(i => i.ToString(CultureInfo.InvariantCulture)));
|
||||||
|
|
||||||
|
public static TitleList Load(string? saved)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(saved)) return Empty;
|
||||||
|
string[] p = saved.Split('|');
|
||||||
|
if (p.Length != 2 || !uint.TryParse(p[0], NumberStyles.None, CultureInfo.InvariantCulture, out uint shown)) return Empty;
|
||||||
|
var ids = new List<uint>();
|
||||||
|
foreach (string s in p[1].Split(',', StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
if (uint.TryParse(s, NumberStyles.None, CultureInfo.InvariantCulture, out uint id)) ids.Add(id);
|
||||||
|
return new TitleList(shown, ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
// CharacterPage.cs - RynthDreamWeave's "Character" page (2026-11-07, Tom: "add this to the actual Dreamweave
|
||||||
|
// plugin UI. The settings and the ability to open the new skills panel ... to not have to use chat
|
||||||
|
// commands"): a tab of the DreamWeave window on RynthCore's bar (and of the /rserver window) that opens and
|
||||||
|
// closes the Character panel (SkillsPanel), on any of its pages, and holds its setting.
|
||||||
|
using System;
|
||||||
|
using ImGuiNET;
|
||||||
|
using RynthCore.Plugin.ServerPack;
|
||||||
|
using RynthCore.Plugin.Shared;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
/// <summary>The Character page. Render thread; what it changes is saved on the tick.</summary>
|
||||||
|
internal sealed class CharacterPage
|
||||||
|
{
|
||||||
|
private readonly Func<bool> _active;
|
||||||
|
private readonly Func<int> _panelState; // 1 open, 0 closed, -1 this RynthCore can't host it
|
||||||
|
private readonly Action<int> _open; // opens the panel on a page (0 Attributes, 1 Skills, 2 Titles)
|
||||||
|
private readonly Action _close;
|
||||||
|
private readonly Func<bool> _replacesAc;
|
||||||
|
private readonly Action<bool> _setReplacesAc;
|
||||||
|
private readonly Func<bool> _onePanel;
|
||||||
|
private readonly Action<bool> _setOnePanel;
|
||||||
|
|
||||||
|
public CharacterPage(Func<bool> active, Func<int> panelState, Action<int> open, Action close,
|
||||||
|
Func<bool> replacesAc, Action<bool> setReplacesAc, Func<bool> onePanel, Action<bool> setOnePanel)
|
||||||
|
{
|
||||||
|
_active = active;
|
||||||
|
_panelState = panelState;
|
||||||
|
_open = open;
|
||||||
|
_close = close;
|
||||||
|
_replacesAc = replacesAc;
|
||||||
|
_setReplacesAc = setReplacesAc;
|
||||||
|
_onePanel = onePanel;
|
||||||
|
_setOnePanel = setOnePanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerPage Page() => new("character", "Character",
|
||||||
|
"The retail Character window, whose XP for next level keeps reading past level 275 (RynthDreamWeave).", Draw);
|
||||||
|
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (!_active())
|
||||||
|
{
|
||||||
|
SafeImGui.TextWrapped("This page is for DreamWeave. RynthCore doesn't see this world as DreamWeave "
|
||||||
|
+ "(check RynthCore Options > Diagnostics, or /rserver info).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SafeImGui.TextWrapped("AC's Character window (Attributes, Skills and Titles), drawn as retail draws it, with "
|
||||||
|
+ "\"XP for next level\" read from DreamWeave's own chart past level 275, where AC's "
|
||||||
|
+ "own window shows a negative number.");
|
||||||
|
ImGui.Spacing();
|
||||||
|
|
||||||
|
int state = _panelState();
|
||||||
|
if (state < 0)
|
||||||
|
{
|
||||||
|
SafeImGui.TextWrapped("This RynthCore can't show it: it needs plugin windows that draw their own frame "
|
||||||
|
+ "(plugin API v90). Update RynthCore.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == 1)
|
||||||
|
{
|
||||||
|
if (ImGui.Button("Close the Character panel##dw_char_close")) _close();
|
||||||
|
}
|
||||||
|
else if (ImGui.Button("Open the Character panel##dw_char_open")) _open(1);
|
||||||
|
Tooltip("Also on RynthCore's bar (\"DreamWeave Skills\"), and with /rserver skills.");
|
||||||
|
|
||||||
|
SafeImGui.TextDisabled("Open it on:");
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGui.SmallButton("Attributes##dw_char_attr")) _open(0);
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGui.SmallButton("Skills##dw_char_skills")) _open(1);
|
||||||
|
ImGui.SameLine();
|
||||||
|
if (ImGui.SmallButton("Titles##dw_char_titles")) _open(2);
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
bool replace = _replacesAc();
|
||||||
|
if (ImGui.Checkbox("Open it instead of AC's Character window##dw_char_replace", ref replace)) _setReplacesAc(replace);
|
||||||
|
Tooltip("On: AC's toolbar button and key for the Character window open (and close) this panel instead. "
|
||||||
|
+ "AC's Character Information window (the backpack button) stays AC's own.\nOff: AC's own windows "
|
||||||
|
+ "open as usual; open this one from here or from RynthCore's bar.");
|
||||||
|
|
||||||
|
bool one = _onePanel();
|
||||||
|
if (ImGui.Checkbox("One panel at a time, as retail##dw_char_onepanel", ref one)) _setOnePanel(one);
|
||||||
|
Tooltip("On: opening it puts away AC's open panel (inventory, spellbook, social, options, map...), and "
|
||||||
|
+ "opening one of those puts it away, as retail's panels share one frame.\nOff: it stays open beside them.");
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
SafeImGui.TextDisabled("Move it by its gold frame, resize it from its bottom edge, Ctrl+wheel over it for a "
|
||||||
|
+ "bigger or smaller panel. Right-click its tabs for the same setting.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Tooltip(string text)
|
||||||
|
{
|
||||||
|
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
// DreamWeaveBank.cs - DreamWeave's banked luminance, for Lum/hr (2026-11-02). DreamWeave puts the
|
||||||
|
// luminance a character earns in its bank on the server: the client never gets the character's
|
||||||
|
// luminance (PropertyInt64 6) or a bank property, and no "You've banked N Luminance." line, so
|
||||||
|
// RynthSuite's session stats (SessionStats.cs) saw no luminance there. The only reading is the
|
||||||
|
// bank command: "/b" (DreamWeave's /bank, Source/ACE.Server/Command/Handlers/PlayerCommands.cs,
|
||||||
|
// ShowBankBalances) answers with System lines, all "[BANK] ...":
|
||||||
|
// [BANK] Your balances:
|
||||||
|
// [BANK] Pyreals (shared by every character on this account): 1,234
|
||||||
|
// [BANK] Luminance: 8,904,758
|
||||||
|
// [BANK] Legendary Keys: 3
|
||||||
|
// [BANK] Promissory Notes: 0
|
||||||
|
// [BANK] Offline Bonus Time: ... (when the server has offline bonus)
|
||||||
|
// [BANK] Alternate Character Bonus +N% until ... (when the character has it)
|
||||||
|
// [BANK] Type /bank for the full list of commands.
|
||||||
|
// So this sends "/b" every minute while logged in on DreamWeave (not in the first 20 s after
|
||||||
|
// login), reads "[BANK] Luminance: N" and publishes it as the profile value "bankLuminance"
|
||||||
|
// (RynthServerProfile.ValueBankLuminance), whose rises the session stats count as luminance
|
||||||
|
// earned. A /b the player types is read the same way (and its reply always shows).
|
||||||
|
//
|
||||||
|
// Deposits move the character's luminance into the bank without earning it. A single deposit says
|
||||||
|
// how much ("[BANK] Deposited N luminance. Balance: B"); "/b d" (deposit all) only prints the new
|
||||||
|
// balances ("[BANK] Deposited all. Pyreals: ... | Luminance: B | ..."), so what the bank gained since
|
||||||
|
// the last reading is taken as moved in. Both are taken out of the published value, so they never
|
||||||
|
// count as earned. Luminance can't be withdrawn or transferred on DreamWeave; spending it from the
|
||||||
|
// bank (augmentations) is a drop, which readers don't count, and the value never goes below 0.
|
||||||
|
//
|
||||||
|
// Every reply regex is anchored at the start of the line (after an optional chat timestamp), so a
|
||||||
|
// pasted copy in a tell or a chat channel can't set the value.
|
||||||
|
// Threads: everything here runs under Gate (pump; the page draws holding it), except
|
||||||
|
// NoteTypedCommand, which the chat bar calls on AC's thread (it only touches interlocked fields).
|
||||||
|
// Pure: RynthServerPack.Tests covers it.
|
||||||
|
using System;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading;
|
||||||
|
using RynthCore.Plugin.ServerPack;
|
||||||
|
using RynthCore.Plugin.Shared;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
internal sealed class DreamWeaveBank
|
||||||
|
{
|
||||||
|
public const string SettingCheckEveryMinute = "checkBankEveryMinute";
|
||||||
|
/// <summary>The profile value the session stats read ("RynthServer.Profile" values).</summary>
|
||||||
|
public const string LuminanceKey = RynthServerProfile.ValueBankLuminance;
|
||||||
|
/// <summary>The bank command (DreamWeave's /bank with no words: the balances).</summary>
|
||||||
|
public const string Command = "/b";
|
||||||
|
/// <summary>After login, before the first check (login's own chat and the server's welcome first).</summary>
|
||||||
|
public const long FirstCheckDelayMs = 20_000;
|
||||||
|
/// <summary>A check this often; a reading of any kind (a /b typed too) starts the minute again.</summary>
|
||||||
|
public const long CheckIntervalMs = 60_000;
|
||||||
|
|
||||||
|
private const string Ts = @"^\s*(?:\[[^\]]*\][\s:]*)?";
|
||||||
|
private static readonly Regex LuminanceLine = new(Ts + @"\[BANK\]\s+Luminance:\s*([\d,]+)\s*$");
|
||||||
|
// The rest of the /b reply: its header, "Name: value" balances (no digits or '.' in the name, so a
|
||||||
|
// deposit line isn't one), the alt bonus line and the closing hint.
|
||||||
|
private static readonly Regex ReplyLine = new(Ts + @"\[BANK\]\s+(?:Your balances:|[A-Za-z][A-Za-z '()]*:\s*\S.*"
|
||||||
|
+ @"|Alternate Character Bonus\b.*|Type /bank for the full list of commands\.)\s*$");
|
||||||
|
private static readonly Regex DepositLine = new(Ts + @"\[BANK\]\s+Deposited\s+([\d,]+)\s+luminance\.\s*Balance:\s*([\d,]+)", RegexOptions.IgnoreCase);
|
||||||
|
private static readonly Regex DepositAllLine = new(Ts + @"\[BANK\]\s+Deposited all\..*\|\s*Luminance:\s*([\d,]+)\s*\|", RegexOptions.IgnoreCase);
|
||||||
|
|
||||||
|
/// <summary>Held for everything below (pump and render thread).</summary>
|
||||||
|
public readonly object Gate = new();
|
||||||
|
|
||||||
|
/// <summary>Check the bank every minute (Lum/hr). On by default.</summary>
|
||||||
|
public bool CheckEveryMinute = true;
|
||||||
|
|
||||||
|
/// <summary>The luminance in the bank at the last reading (null before one this login).</summary>
|
||||||
|
public long? Luminance { get; private set; }
|
||||||
|
/// <summary>Luminance moved in from the character (deposits) since login, taken out of the published value.</summary>
|
||||||
|
public long MovedIn { get; private set; }
|
||||||
|
public DateTime ReadUtc { get; private set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
/// <summary>What the profile value says: the bank less what deposits moved in. Null before a reading.</summary>
|
||||||
|
public long? Published => Luminance is long l ? l - MovedIn : null;
|
||||||
|
|
||||||
|
private readonly ServerChatRequest _request = new();
|
||||||
|
private long _nextCheckMs = long.MaxValue;
|
||||||
|
private int _selfSends; // our "/b" send not yet seen by the chat bar (0 or 1)
|
||||||
|
private int _typedByPlayer; // the player typed /b (AC's thread sets it)
|
||||||
|
|
||||||
|
public void LoadSettings(ServerPackSettings s) => CheckEveryMinute = s.GetBool(SettingCheckEveryMinute, true);
|
||||||
|
|
||||||
|
public void SaveSettings(ServerPackSettings s)
|
||||||
|
{
|
||||||
|
if (s.SetBool(SettingCheckEveryMinute, CheckEveryMinute)) s.Save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A character logged in (or the plugin loaded in game): the bank is read fresh.</summary>
|
||||||
|
public void Login(long nowMs)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
_nextCheckMs = nowMs + FirstCheckDelayMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Logout()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
_nextCheckMs = long.MaxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Clear()
|
||||||
|
{
|
||||||
|
Luminance = null;
|
||||||
|
MovedIn = 0;
|
||||||
|
ReadUtc = DateTime.MinValue;
|
||||||
|
_request.Clear();
|
||||||
|
Interlocked.Exchange(ref _selfSends, 0);
|
||||||
|
Interlocked.Exchange(ref _typedByPlayer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The every-minute check: "/b" when one is due now (and the setting is on), else null.</summary>
|
||||||
|
public string? CheckDue(long nowMs)
|
||||||
|
{
|
||||||
|
if (!CheckEveryMinute || nowMs < _nextCheckMs) return null;
|
||||||
|
_nextCheckMs = nowMs + CheckIntervalMs;
|
||||||
|
return Request(nowMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A check now (the page's button, or the minute): its reply is ours. Returns the command.</summary>
|
||||||
|
public string Request(long nowMs)
|
||||||
|
{
|
||||||
|
_request.Sent(nowMs);
|
||||||
|
// One at a time: if the engine's chat bar never sees our sends, the count still can't grow.
|
||||||
|
Interlocked.Exchange(ref _selfSends, 1);
|
||||||
|
return Command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The request didn't go out (not logged in, no chat parser).</summary>
|
||||||
|
public void NotSent()
|
||||||
|
{
|
||||||
|
_request.Clear();
|
||||||
|
Interlocked.Exchange(ref _selfSends, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>True for what the player types to see the balances ("/b", "/bank"), not "/b d" and the like.</summary>
|
||||||
|
public static bool IsBalanceCommand(string? text)
|
||||||
|
{
|
||||||
|
string t = (text ?? string.Empty).Trim();
|
||||||
|
return t.Equals("/b", StringComparison.OrdinalIgnoreCase) || t.Equals("/bank", StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>AC's thread (chat bar): a "/b" went through it. Ours, or typed by the player?</summary>
|
||||||
|
public void NoteTypedCommand()
|
||||||
|
{
|
||||||
|
if (Interlocked.Decrement(ref _selfSends) >= 0) return;
|
||||||
|
Interlocked.Exchange(ref _selfSends, 0);
|
||||||
|
Interlocked.Exchange(ref _typedByPlayer, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Pump tick: the player asked too, so the reply is theirs and shows.</summary>
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
if (Interlocked.Exchange(ref _typedByPlayer, 0) != 0) _request.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// An incoming chat line on DreamWeave: reads the bank's luminance and deposits. True when the
|
||||||
|
/// line answers RynthDreamWeave's own "/b" (to keep it out of the chat window).
|
||||||
|
/// </summary>
|
||||||
|
public bool OnChatLine(string? text, long nowMs)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return false;
|
||||||
|
string line = text.TrimEnd('\r', '\n');
|
||||||
|
Match m;
|
||||||
|
if ((m = LuminanceLine.Match(line)).Success)
|
||||||
|
{
|
||||||
|
if (TryNumber(m.Groups[1].Value, out long lum)) Read(lum, nowMs);
|
||||||
|
return Ours(nowMs);
|
||||||
|
}
|
||||||
|
if ((m = DepositLine.Match(line)).Success)
|
||||||
|
{
|
||||||
|
// "Deposited N luminance. Balance: B": N moved in, and B is a reading.
|
||||||
|
if (TryNumber(m.Groups[1].Value, out long moved) && TryNumber(m.Groups[2].Value, out long balance))
|
||||||
|
{
|
||||||
|
MovedIn += moved;
|
||||||
|
Read(balance, nowMs);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ((m = DepositAllLine.Match(line)).Success)
|
||||||
|
{
|
||||||
|
// Deposit all: only the new balance. What the bank gained since the last reading moved in.
|
||||||
|
if (TryNumber(m.Groups[1].Value, out long balance))
|
||||||
|
{
|
||||||
|
if (Luminance is long before && balance > before) MovedIn += balance - before;
|
||||||
|
Read(balance, nowMs);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return ReplyLine.IsMatch(line) && Ours(nowMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Read(long luminance, long nowMs)
|
||||||
|
{
|
||||||
|
Luminance = luminance;
|
||||||
|
// Spent from the bank below what deposits brought: those deposits are gone too (the value stays 0 or more).
|
||||||
|
if (MovedIn > luminance) MovedIn = luminance;
|
||||||
|
ReadUtc = DateTime.UtcNow;
|
||||||
|
// Read just now: the next check is a minute away.
|
||||||
|
if (_nextCheckMs != long.MaxValue) _nextCheckMs = nowMs + CheckIntervalMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Ours(long nowMs)
|
||||||
|
{
|
||||||
|
bool ours = _request.Awaiting(nowMs);
|
||||||
|
_request.Extend(nowMs);
|
||||||
|
return ours;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool TryNumber(string text, out long value)
|
||||||
|
=> long.TryParse(text.Replace(",", string.Empty), System.Globalization.NumberStyles.None,
|
||||||
|
System.Globalization.CultureInfo.InvariantCulture, out value);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
// DreamWeavePages.cs - RynthDreamWeave's Bank page (2026-11-02): the every-minute bank check that gives
|
||||||
|
// Lum/hr its luminance on DreamWeave (DreamWeaveBank.cs), its setting and a Check now button. A tab of
|
||||||
|
// the DreamWeave window on RynthCore's bar (and of the /rserver window).
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using ImGuiNET;
|
||||||
|
using RynthCore.Plugin.ServerPack;
|
||||||
|
using RynthCore.Plugin.Shared;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
/// <summary>The Bank page. Render thread: draws holding the bank's lock, and queues what it sends for the tick.</summary>
|
||||||
|
internal sealed class DreamWeavePages
|
||||||
|
{
|
||||||
|
private readonly DreamWeaveBank _bank;
|
||||||
|
private readonly Func<bool> _active;
|
||||||
|
private readonly Action<Action> _runOnTick;
|
||||||
|
private readonly Action _checkNow;
|
||||||
|
private readonly Action _saveSettings;
|
||||||
|
|
||||||
|
/// <param name="active">RynthDreamWeave's server is this world.</param>
|
||||||
|
/// <param name="runOnTick">Queues work for the plugin tick (ServerPackPlugin.RunOnTick).</param>
|
||||||
|
/// <param name="checkNow">Sends RynthDreamWeave's own /b (pump thread).</param>
|
||||||
|
/// <param name="saveSettings">Writes the bank's settings (pump thread).</param>
|
||||||
|
public DreamWeavePages(DreamWeaveBank bank, Func<bool> active, Action<Action> runOnTick, Action checkNow, Action saveSettings)
|
||||||
|
{
|
||||||
|
_bank = bank;
|
||||||
|
_active = active;
|
||||||
|
_runOnTick = runOnTick;
|
||||||
|
_checkNow = checkNow;
|
||||||
|
_saveSettings = saveSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerPage[] Pages() => new[]
|
||||||
|
{
|
||||||
|
new ServerPage("bank", "Bank", "DreamWeave's bank: the luminance Lum/hr counts (RynthDreamWeave).", DrawBank),
|
||||||
|
};
|
||||||
|
|
||||||
|
private void DrawBank()
|
||||||
|
{
|
||||||
|
if (!_active())
|
||||||
|
{
|
||||||
|
SafeImGui.TextWrapped("This page is for DreamWeave. RynthCore doesn't see this world as DreamWeave "
|
||||||
|
+ "(check RynthCore Options > Diagnostics, or /rserver info).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock (_bank.Gate)
|
||||||
|
{
|
||||||
|
SafeImGui.TextDisabled("Banked luminance");
|
||||||
|
ImGui.SameLine(200f);
|
||||||
|
SafeImGui.Text(_bank.Luminance is long lum ? lum.ToString("N0", CultureInfo.InvariantCulture) : "not read yet");
|
||||||
|
if (_bank.ReadUtc != DateTime.MinValue)
|
||||||
|
{
|
||||||
|
ImGui.SameLine();
|
||||||
|
SafeImGui.TextDisabled($"(read at {_bank.ReadUtc.ToLocalTime():HH:mm:ss})");
|
||||||
|
}
|
||||||
|
if (_bank.MovedIn > 0)
|
||||||
|
{
|
||||||
|
SafeImGui.TextDisabled("Deposited this login");
|
||||||
|
ImGui.SameLine(200f);
|
||||||
|
SafeImGui.Text(_bank.MovedIn.ToString("N0", CultureInfo.InvariantCulture));
|
||||||
|
Tooltip("Luminance moved from the character into the bank: not counted as earned.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.Spacing();
|
||||||
|
bool check = _bank.CheckEveryMinute;
|
||||||
|
if (ImGui.Checkbox("Check the bank every minute (Lum/hr)##dw_bank_check", ref check))
|
||||||
|
{
|
||||||
|
_bank.CheckEveryMinute = check;
|
||||||
|
_runOnTick(_saveSettings);
|
||||||
|
}
|
||||||
|
Tooltip("DreamWeave keeps earned luminance in the bank, where the client can't see it. RynthDreamWeave "
|
||||||
|
+ "sends /b once a minute and hides its reply; the Lum/hr in the Mini Remote and RynthTracker "
|
||||||
|
+ "counts what the bank gains. A /b you type yourself always shows its reply.");
|
||||||
|
|
||||||
|
if (ImGui.Button("Check now##dw_bank_now")) _runOnTick(_checkNow);
|
||||||
|
Tooltip("Sends /b now.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Tooltip(string text)
|
||||||
|
{
|
||||||
|
if (ImGui.IsItemHovered()) SafeImGui.SetTooltip(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,74 @@
|
||||||
|
// DreamWeaveXp.cs - DreamWeave's level chart past retail's 275, for the Skills panel's
|
||||||
|
// "XP for next level".
|
||||||
|
//
|
||||||
|
// The retail client reads the next level's total from portal.dat's XpTable, which ends at level 275,
|
||||||
|
// so on DreamWeave (levels past 275 for enlightened characters) AC's own Character panel subtracts the
|
||||||
|
// player's total from the level-275 total and shows a NEGATIVE number (a level-344 character with
|
||||||
|
// 600,303,541,190 XP reads -409,077,230,943). DreamWeave's server extends the chart itself:
|
||||||
|
// ACE-DreamWeave Source/ACE.Server/Entity/EnlightenmentXpCurve.cs (public, github.com/Awful-Waffle-Rofl/
|
||||||
|
// ACE-DreamWeave, read 2026-11-07) grows each level past 275 by the ratio of the chart's last two steps,
|
||||||
|
// as an exact fraction, until the total would pass long.MaxValue / 2. This is that rule, re-implemented
|
||||||
|
// (no code copied), so the panel reads what the server will ask for.
|
||||||
|
//
|
||||||
|
// Pure: RynthServerPack.Tests checks it against the server's numbers.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
internal static class DreamWeaveXp
|
||||||
|
{
|
||||||
|
/// <summary>The server's ceiling for a chart total: half of long.MaxValue.</summary>
|
||||||
|
public const ulong TotalCap = (ulong)(long.MaxValue / 2);
|
||||||
|
|
||||||
|
private static readonly Lazy<ulong[]> Chart = new(() => Extend(RetailData.LevelTotals, TotalCap), true);
|
||||||
|
|
||||||
|
/// <summary>Total XP to reach each level (index = level), retail's 0..275 then DreamWeave's tail.</summary>
|
||||||
|
public static IReadOnlyList<ulong> Totals => Chart.Value;
|
||||||
|
|
||||||
|
/// <summary>The highest level the chart reaches.</summary>
|
||||||
|
public static int MaxLevel => Chart.Value.Length - 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <paramref name="retail"/> followed by levels whose step grows by last step / step before it (an exact
|
||||||
|
/// fraction; a flat or shrinking tail repeats its last step), never below the step before, until the next
|
||||||
|
/// total would pass <paramref name="cap"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal static ulong[] Extend(IReadOnlyList<ulong> retail, ulong cap)
|
||||||
|
{
|
||||||
|
var chart = new List<ulong>(retail);
|
||||||
|
if (chart.Count < 3) return chart.ToArray();
|
||||||
|
int last = chart.Count - 1;
|
||||||
|
ulong step = chart[last] - chart[last - 1];
|
||||||
|
ulong before = chart[last - 1] - chart[last - 2];
|
||||||
|
ulong num = step, den = before;
|
||||||
|
if (den == 0 || num <= den) num = den = 1;
|
||||||
|
if (step == 0) return chart.ToArray();
|
||||||
|
ulong total = chart[last];
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
ulong next = (ulong)((UInt128)step * num / den);
|
||||||
|
if (next < step) next = step;
|
||||||
|
if (next > cap - total) break;
|
||||||
|
total += next;
|
||||||
|
step = next;
|
||||||
|
chart.Add(total);
|
||||||
|
}
|
||||||
|
return chart.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The XP still needed for the next level, as the panel's "XP for next level" line: null at the
|
||||||
|
/// chart's top (retail's panel says "Infinity!" there) or when the level is unknown. A total already
|
||||||
|
/// past the next level's (the server levels the character on its next award) reads 0.
|
||||||
|
/// </summary>
|
||||||
|
public static long? ToNextLevel(int level, long totalXp) => ToNextLevel(Totals, level, totalXp);
|
||||||
|
|
||||||
|
internal static long? ToNextLevel(IReadOnlyList<ulong> chart, int level, long totalXp)
|
||||||
|
{
|
||||||
|
if (level < 1 || totalXp < 0 || level + 1 >= chart.Count) return null;
|
||||||
|
ulong next = chart[level + 1];
|
||||||
|
ulong have = (ulong)totalXp;
|
||||||
|
return have >= next ? 0 : (long)(next - have);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// OnePanelRule.cs - one main panel at a time, as retail (2026-11-08, Tom: "in retail you can only have one
|
||||||
|
// panel open at a time (skills, inventory, etc.)"). Retail's main panels share one frame, so opening one puts
|
||||||
|
// the other away. The Character panel (SkillsPanel) is drawn by RynthDreamWeave, not AC, so this keeps the
|
||||||
|
// rule between it and AC's own main panels: it opening closes the AC panel that is open, and an AC panel
|
||||||
|
// opening closes it.
|
||||||
|
//
|
||||||
|
// Edges only: AC's open state is read at most 5 times a second, so a panel this rule just asked AC to close
|
||||||
|
// still reads open for a moment; that's not an AC panel opening, and an AC panel that stays open while the
|
||||||
|
// Character panel opens is the Character panel's open (it wins). Pure: the plugin feeds it what it sees each
|
||||||
|
// frame and does what it says (DreamWeaveSkills.ServerRender).
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
internal sealed class OnePanelRule
|
||||||
|
{
|
||||||
|
private bool _seen;
|
||||||
|
private bool _oursWas;
|
||||||
|
private uint _acWas;
|
||||||
|
|
||||||
|
/// <summary>What to do this frame.</summary>
|
||||||
|
public readonly record struct Step(uint CloseAc, bool CloseOurs);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <paramref name="oursOpen"/>: the Character panel is open; <paramref name="acOpen"/>: bit i set = AC's
|
||||||
|
/// main panel i is open (DreamWeaveSkills.MainAcPanels). The first call only learns where things are.
|
||||||
|
/// </summary>
|
||||||
|
public Step Next(bool oursOpen, uint acOpen)
|
||||||
|
{
|
||||||
|
if (!_seen)
|
||||||
|
{
|
||||||
|
_seen = true;
|
||||||
|
_oursWas = oursOpen;
|
||||||
|
_acWas = acOpen;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
uint opened = acOpen & ~_acWas;
|
||||||
|
bool oursOpened = oursOpen && !_oursWas;
|
||||||
|
_oursWas = oursOpen;
|
||||||
|
_acWas = acOpen;
|
||||||
|
// The Character panel just opened: it puts away the AC panels that are open.
|
||||||
|
if (oursOpened) return new Step(acOpen, false);
|
||||||
|
// An AC panel opened while it's open: it goes.
|
||||||
|
// (_oursWas stays true: it still reads open on the next frame, and that isn't it opening again - which
|
||||||
|
// would close the panel that just opened.)
|
||||||
|
if (oursOpen && opened != 0) return new Step(0, true);
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Forget what was seen (the rule turned off, or the world changed).</summary>
|
||||||
|
public void Reset() => _seen = false;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
// RetailData.cs - The shapes of the retail data RetailData.g.cs carries (generated from portal.dat by
|
||||||
|
// Tools/RetailDataGen/gen_retail_data.py): a skill table row and a dat font's glyph table.
|
||||||
|
// Pure (no ImGui, no host): RynthServerPack.Tests covers the lookups.
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A SkillTable row: the skill's id, name, 0x06 icon, whether it is usable untrained (MinLevel 1), and the
|
||||||
|
/// hover tooltip: its formula line ("( Focus + Self ) / 4", empty for a skill with no attribute part) and
|
||||||
|
/// its description.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed record RetailSkill(uint Id, string Name, uint Icon, bool UsableUntrained, string Formula, string Description);
|
||||||
|
|
||||||
|
/// <summary>One glyph of a dat font: where it sits on the sheet and how it advances.</summary>
|
||||||
|
internal readonly record struct RetailGlyph(int SheetX, int SheetY, int Width, int Height, int Before, int After, int Top)
|
||||||
|
{
|
||||||
|
/// <summary>The pen's advance (retail: before + width + after).</summary>
|
||||||
|
public int Advance => Before + Width + After;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A retail dat font (a Font file, 0x40xxxxxx): its glyph sheets (0x06 A8 textures the engine hands over
|
||||||
|
/// as GetIconTexture kind FontSheet), line height and the glyph table for ASCII and Latin-1.
|
||||||
|
/// The outline sheet is set only for the faces the panel draws outlined (the level number).
|
||||||
|
/// </summary>
|
||||||
|
internal sealed class RetailFont
|
||||||
|
{
|
||||||
|
private readonly Dictionary<char, RetailGlyph> _glyphs = new();
|
||||||
|
|
||||||
|
public RetailFont(uint id, int lineHeight, int baseline, int borderX, int borderY,
|
||||||
|
uint sheet, int sheetWidth, int sheetHeight, uint outlineSheet, int outlineWidth, int outlineHeight, short[] glyphs)
|
||||||
|
{
|
||||||
|
Id = id;
|
||||||
|
LineHeight = lineHeight;
|
||||||
|
Baseline = baseline;
|
||||||
|
BorderX = borderX;
|
||||||
|
BorderY = borderY;
|
||||||
|
Sheet = sheet;
|
||||||
|
SheetWidth = sheetWidth;
|
||||||
|
SheetHeight = sheetHeight;
|
||||||
|
OutlineSheet = outlineSheet;
|
||||||
|
OutlineWidth = outlineWidth;
|
||||||
|
OutlineHeight = outlineHeight;
|
||||||
|
for (int i = 0; i + 7 < glyphs.Length; i += 8)
|
||||||
|
_glyphs[(char)glyphs[i]] = new RetailGlyph(glyphs[i + 1], glyphs[i + 2], glyphs[i + 3], glyphs[i + 4],
|
||||||
|
glyphs[i + 5], glyphs[i + 6], glyphs[i + 7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint Id { get; }
|
||||||
|
public int LineHeight { get; }
|
||||||
|
public int Baseline { get; }
|
||||||
|
public int BorderX { get; }
|
||||||
|
public int BorderY { get; }
|
||||||
|
public uint Sheet { get; }
|
||||||
|
public int SheetWidth { get; }
|
||||||
|
public int SheetHeight { get; }
|
||||||
|
public uint OutlineSheet { get; }
|
||||||
|
public int OutlineWidth { get; }
|
||||||
|
public int OutlineHeight { get; }
|
||||||
|
|
||||||
|
public bool TryGlyph(char c, out RetailGlyph glyph) => _glyphs.TryGetValue(c, out glyph);
|
||||||
|
|
||||||
|
/// <summary>Breaks <paramref name="text"/> at spaces into lines no wider than <paramref name="width"/> design px
|
||||||
|
/// (a word wider than that gets a line of its own).</summary>
|
||||||
|
public List<string> Wrap(string? text, int width)
|
||||||
|
{
|
||||||
|
var lines = new List<string>();
|
||||||
|
foreach (string para in (text ?? "").Replace("\r", "").Split('\n'))
|
||||||
|
{
|
||||||
|
string line = "";
|
||||||
|
foreach (string word in para.Split(' ', System.StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
string next = line.Length == 0 ? word : line + " " + word;
|
||||||
|
if (line.Length > 0 && Measure(next) > width) { lines.Add(line); line = word; }
|
||||||
|
else line = next;
|
||||||
|
}
|
||||||
|
if (line.Length > 0) lines.Add(line);
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The width of <paramref name="text"/> in design pixels (characters the font lacks are skipped, as retail).</summary>
|
||||||
|
public int Measure(string? text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return 0;
|
||||||
|
int w = 0;
|
||||||
|
foreach (char c in text)
|
||||||
|
if (_glyphs.TryGetValue(c, out RetailGlyph g)) w += g.Advance;
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static partial class RetailData
|
||||||
|
{
|
||||||
|
private static Dictionary<uint, RetailSkill>? _byId;
|
||||||
|
|
||||||
|
/// <summary>The skill table row for an id, or null.</summary>
|
||||||
|
public static RetailSkill? Skill(uint id)
|
||||||
|
{
|
||||||
|
_byId ??= BuildIndex();
|
||||||
|
return _byId.TryGetValue(id, out RetailSkill? s) ? s : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<uint, RetailSkill> BuildIndex()
|
||||||
|
{
|
||||||
|
var map = new Dictionary<uint, RetailSkill>(Skills.Length);
|
||||||
|
foreach (RetailSkill s in Skills) map[s.Id] = s;
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
1364
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/RetailData.g.cs
Normal file
1364
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/RetailData.g.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,781 @@
|
||||||
|
// SkillsPanel.cs - The DreamWeave Skills panel: retail's Character panel on its Skills page, drawn 1:1,
|
||||||
|
// with "XP for next level" read from DreamWeave's chart past level 275 (DreamWeaveXp) instead of the
|
||||||
|
// client's, which ends at 275 and shows a negative number there.
|
||||||
|
//
|
||||||
|
// Everything is the retail client's own: the positions are LayoutDesc 0x2100002E's (the Character panel,
|
||||||
|
// page 0x1000022C), the pictures its 0x06 textures (GetIconTexture kind UiSprite) and the text its dat
|
||||||
|
// fonts (Palatino_Linotype_14/16/18, Chat_PalatinoLinotype_Large and Stonehenge_36 for the level),
|
||||||
|
// drawn glyph by glyph from their sheets (kind FontSheet) with the glyph tables in RetailData.g.cs.
|
||||||
|
// An engine without those kinds (before 2026-11-07) gets flat stand-ins and ImGui's font, same layout.
|
||||||
|
//
|
||||||
|
// Design pixels: the panel is 300 wide inside a 5-pixel gold frame (retail's 0x0600612A..D); the
|
||||||
|
// window is 310 at 100% and everything scales with its draw size (Ctrl+wheel over it).
|
||||||
|
//
|
||||||
|
// The tabs row is the drag handle; Attributes and Titles open AC's own Character and Character
|
||||||
|
// Information panels; the minimize button closes this one. A row click selects a skill for the footer,
|
||||||
|
// whose arrow raises it one rank (or trains it with credits) and "+10" ten ranks, as retail's do.
|
||||||
|
//
|
||||||
|
// AC's render thread. Reads SkillsReader's snapshot; reads and raises are queued for the tick.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Numerics;
|
||||||
|
using ImGuiNET;
|
||||||
|
using RynthCore.PluginSdk;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
internal sealed class SkillsPanel
|
||||||
|
{
|
||||||
|
// ── LayoutDesc 0x2100002E (design pixels) ───────────────────────────
|
||||||
|
public const int PanelW = 300, Frame = 5;
|
||||||
|
private const int TabW = 92, TabH = 25, CapW = 17, CloseX = 276, CloseW = 24;
|
||||||
|
private const int HeaderH = 105, RuleH = 7, ListTop = 112, FooterH = 55, RowH = 20, BannerW = 280;
|
||||||
|
private const int ScrollX = 281, ScrollW = 16, ScrollBtn = 16, ScrollCap = 3;
|
||||||
|
|
||||||
|
private const uint ArtEdgeTop = 0x0600612Au, ArtEdgeLeft = 0x0600612Bu, ArtEdgeBottom = 0x0600612Cu, ArtEdgeRight = 0x0600612Du,
|
||||||
|
ArtCorner = 0x06006129u, ArtPage = 0x06004CC2u, ArtClose = 0x06001393u, ArtClosePressed = 0x06001394u,
|
||||||
|
ArtHeaderRule = 0x06004CB8u, ArtPlate = 0x060011A6u, ArtXpFill = 0x060011A5u, ArtRankFill = 0x06000F8Au, ArtRule = 0x06004CC7u, ArtRowSelected = 0x06000F93u,
|
||||||
|
ArtTrack = 0x06004C5Fu, ArtThumbTop = 0x06004C60u, ArtThumbMid = 0x06004C63u, ArtThumbBottom = 0x06004C66u,
|
||||||
|
ArtScrollUp = 0x06004C69u, ArtScrollDown = 0x06004C6Cu,
|
||||||
|
ArtRaise = 0x06004CB6u, ArtRaiseGhost = 0x06004CB7u, ArtRaiseTen = 0x0600712Bu, ArtRaiseTenGhost = 0x0600712Cu;
|
||||||
|
// Tab 3-slices: "Open" (the shown page) and "Closed" states.
|
||||||
|
private static readonly uint[] TabOpen = { 0x06005D92u, 0x06005D94u, 0x06005D96u };
|
||||||
|
private static readonly uint[] TabClosed = { 0x06005D93u, 0x06005D95u, 0x06005D97u };
|
||||||
|
|
||||||
|
private static uint Banner(SkillSection s) => s switch
|
||||||
|
{
|
||||||
|
SkillSection.Specialized => 0x06000F90u,
|
||||||
|
SkillSection.Trained => 0x06000F86u,
|
||||||
|
SkillSection.Untrained => 0x06000F98u,
|
||||||
|
_ => 0x06000F89u,
|
||||||
|
};
|
||||||
|
|
||||||
|
// ── Colours (ImGui ABGR) ────────────────────────────────────────────
|
||||||
|
private const uint White = 0xFFFFFFFFu, Black = 0xFF000000u;
|
||||||
|
private static readonly uint Body = Rgb(235, 230, 209); // OpenAC's "parchment" for the footer prompt
|
||||||
|
private static readonly uint TabOn = Rgb(204, 204, 204), TabOff = Rgb(127, 127, 127);
|
||||||
|
private static readonly uint Gold = Rgb(255, 242, 127); // the level number (the layout's 1, .949, .498)
|
||||||
|
private static readonly uint Green = Rgb(0, 255, 0), Red = Rgb(255, 0, 0);
|
||||||
|
|
||||||
|
private static uint Rgb(int r, int g, int b) => 0xFF000000u | ((uint)b << 16) | ((uint)g << 8) | (uint)r;
|
||||||
|
|
||||||
|
private readonly RynthCoreHost _host;
|
||||||
|
private readonly SkillsReader _reader;
|
||||||
|
private readonly Action<Action> _onTick;
|
||||||
|
private readonly Action<string> _chat;
|
||||||
|
private readonly string _title;
|
||||||
|
|
||||||
|
private int _tab = 1; // 0 Attributes, 1 Skills, 2 Titles
|
||||||
|
private uint _selected; // the skill selected on the Skills page
|
||||||
|
private int _attrSelected = -1; // the row selected on the Attributes page (AttributesPage.Rows)
|
||||||
|
private uint _titleSelected; // the title selected on the Titles page
|
||||||
|
private float _scroll; // rows scrolled (fractional while the thumb is dragged)
|
||||||
|
private float _attrScroll, _titleScroll;
|
||||||
|
private readonly Func<bool> _replacesAc;
|
||||||
|
private readonly Action<bool> _setReplacesAc;
|
||||||
|
private bool _thumbDrag;
|
||||||
|
private float _thumbGrab;
|
||||||
|
// Resizing from the bottom edge (retail's Character window: height only). Design px, frame included.
|
||||||
|
private bool _resizing;
|
||||||
|
private float _resizeStartH, _resizeStartY, _dragH;
|
||||||
|
private float _wantH; // the height asked for after a resize, until the window has it
|
||||||
|
private long _wantSince;
|
||||||
|
private ImDrawListPtr _dl;
|
||||||
|
private Vector2 _origin; // the content's top-left (inside the frame), screen pixels
|
||||||
|
private float _k = 1f; // screen pixels per design pixel
|
||||||
|
|
||||||
|
public SkillsPanel(RynthCoreHost host, SkillsReader reader, string title, Action<Action> onTick, Action<string> chat,
|
||||||
|
Func<bool> replacesAc, Action<bool> setReplacesAc)
|
||||||
|
{
|
||||||
|
_host = host;
|
||||||
|
_reader = reader;
|
||||||
|
_title = title;
|
||||||
|
_onTick = onTick;
|
||||||
|
_chat = chat;
|
||||||
|
_replacesAc = replacesAc;
|
||||||
|
_setReplacesAc = setReplacesAc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Logout: nothing selected, back to the top.</summary>
|
||||||
|
public void Reset()
|
||||||
|
{
|
||||||
|
_selected = 0;
|
||||||
|
_attrSelected = -1;
|
||||||
|
_titleSelected = 0;
|
||||||
|
_scroll = _attrScroll = _titleScroll = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Opens on a page (0 Attributes, 1 Skills, 2 Titles): AC's own Character window asked for (the replace option).</summary>
|
||||||
|
public void ShowPage(int tab) => _tab = Math.Clamp(tab, 0, 2);
|
||||||
|
|
||||||
|
/// <summary>The page shown (0 Attributes, 1 Skills, 2 Titles).</summary>
|
||||||
|
public int CurrentPage => _tab;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the panel into the host's frameless window (its body, edge to edge) and returns the size it
|
||||||
|
/// wants (the host fits the window to it). <paramref name="popped"/>: popped out (the engine draws no
|
||||||
|
/// retail pictures there).
|
||||||
|
/// </summary>
|
||||||
|
public Vector2 Draw(bool popped)
|
||||||
|
{
|
||||||
|
if (_reader.ReadDue()) _onTick(() => _reader.Read(_host));
|
||||||
|
SkillsSheet sheet = _reader.Sheet;
|
||||||
|
|
||||||
|
Vector2 start = ImGui.GetCursorScreenPos();
|
||||||
|
Vector2 avail = ImGui.GetContentRegionAvail();
|
||||||
|
if (avail.X < 60 || avail.Y < 60) return new Vector2(0, Math.Max(60, avail.Y));
|
||||||
|
// The scale is the window's own draw size (Ctrl+wheel on it, 30-250%; Settings > UI > Toolbar), 100% =
|
||||||
|
// retail's own pixels until it's set: never the window's width, Windows' display scaling or the text
|
||||||
|
// size, which every panel follows ("All panels"; Tom's is 160%). Retail's panel is a fixed 300 wide and
|
||||||
|
// isn't scaled, and the window is fitted to the panel (2026-11-07: the window's width, the DPI-scaled UI
|
||||||
|
// font, then the text size drew it 1.4-1.6x: "still massive").
|
||||||
|
int pct = _host.PanelScale(_title);
|
||||||
|
_k = pct > 0 ? Math.Clamp(pct / 100f, 0.3f, 2.5f) : 1f;
|
||||||
|
_dl = ImGui.GetWindowDrawList();
|
||||||
|
_origin = new Vector2(MathF.Round(start.X + Frame * _k), MathF.Round(start.Y + Frame * _k));
|
||||||
|
|
||||||
|
// The height drawn: the window's, or while the bottom edge is dragged the dragged one (drawn past the
|
||||||
|
// window's edge, the way retail's frame follows the mouse), and after the release the asked-for one
|
||||||
|
// until the host has fitted the window to it ("fitHeight").
|
||||||
|
float windowH = avail.Y / _k;
|
||||||
|
if (_wantH > 0 && (MathF.Abs(windowH - _wantH) < 1f || Environment.TickCount64 - _wantSince > 2000)) _wantH = 0;
|
||||||
|
float panelH = MathF.Floor(_resizing ? _dragH : _wantH > 0 ? _wantH : windowH);
|
||||||
|
panelH = Math.Max(panelH, MinPanelH);
|
||||||
|
float contentH = panelH - 2 * Frame;
|
||||||
|
int pageH = (int)contentH - TabH;
|
||||||
|
|
||||||
|
float panelW = (PanelW + 2 * Frame) * _k;
|
||||||
|
_dl.PushClipRect(start, start + new Vector2(Math.Max(avail.X, panelW), Math.Max(avail.Y, panelH * _k)), false);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DrawPanel(sheet, pageH, popped);
|
||||||
|
}
|
||||||
|
finally { _dl.PopClipRect(); }
|
||||||
|
|
||||||
|
ImGui.SetCursorScreenPos(start);
|
||||||
|
ImGui.Dummy(new Vector2(avail.X, avail.Y));
|
||||||
|
return new Vector2(MathF.Ceiling(panelW), MathF.Ceiling(panelH * _k));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The smallest panel retail allows: header, three rows, footer (design px, frame included).</summary>
|
||||||
|
private const int MinPanelH = TabH + ListTop + 3 * RowH + RuleH + 3 + FooterH + 2 * Frame;
|
||||||
|
|
||||||
|
private void DrawPanel(SkillsSheet sheet, int pageH, bool popped)
|
||||||
|
{
|
||||||
|
Page(pageH);
|
||||||
|
Tabs();
|
||||||
|
_tipKey = 0;
|
||||||
|
if (_tab == 2) TitlesPage(sheet, pageH);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Header(sheet);
|
||||||
|
if (_tab == 0) AttributesPageDraw(sheet, pageH);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<SkillRow> rows = SkillsLayout.Rows(sheet.Skills);
|
||||||
|
SkillLine? selected = Find(sheet, _selected);
|
||||||
|
if (selected == null) _selected = 0;
|
||||||
|
SkillList(sheet, rows, pageH);
|
||||||
|
Footer(sheet, selected, pageH);
|
||||||
|
}
|
||||||
|
if (!sheet.HasNumbers)
|
||||||
|
{
|
||||||
|
string wait = _reader.Message.Length > 0 ? _reader.Message : "Reading your character...";
|
||||||
|
Text(RetailData.Pal16, wait, 0, TabH + ListTop, BannerW, RowH * 2, White, center: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UpdateTooltip();
|
||||||
|
FrameArt(TabH + pageH);
|
||||||
|
FrameHandles(TabH + pageH, popped);
|
||||||
|
OptionsMenu();
|
||||||
|
Tooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The Attributes page (the header and footer are the Skills page's) ──
|
||||||
|
|
||||||
|
private void AttributesPageDraw(SkillsSheet sheet, int pageH)
|
||||||
|
{
|
||||||
|
IReadOnlyList<AttributeLine> rows = sheet.AttributeRows;
|
||||||
|
int top = TabH + ListTop;
|
||||||
|
int listH = pageH - ListTop - FooterH - RuleH - 3;
|
||||||
|
int visible = Math.Max(1, listH / RowH);
|
||||||
|
float maxScroll = Math.Max(0, rows.Count - visible);
|
||||||
|
|
||||||
|
ImGui.SetCursorScreenPos(P(0, top));
|
||||||
|
ImGui.InvisibleButton("##dw_attr_list", S(BannerW, listH));
|
||||||
|
bool listHovered = ImGui.IsItemHovered();
|
||||||
|
bool clicked = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||||
|
if (listHovered && !ImGui.GetIO().KeyCtrl) _attrScroll -= ImGui.GetIO().MouseWheel * 3;
|
||||||
|
_attrScroll = Math.Clamp(_attrScroll, 0, maxScroll);
|
||||||
|
int first = (int)MathF.Round(_attrScroll);
|
||||||
|
|
||||||
|
_dl.PushClipRect(P(0, top), P(BannerW, top + listH), true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH)
|
||||||
|
{
|
||||||
|
AttributeLine a = rows[i];
|
||||||
|
int row = AttributesPage.RowIndex(a.Kind, a.Stype);
|
||||||
|
if (row == _attrSelected) SpriteCropped(ArtRowSelected, 0, y, BannerW, RowH, 282, 20, 0x60206080u);
|
||||||
|
Icon(a.Icon, 0, y, 20);
|
||||||
|
Text(RetailData.Pal18, a.Name, 25, y, 150, RowH, White);
|
||||||
|
uint color = a.Buffed > a.Base ? Green : a.Buffed < a.Base ? Red : White;
|
||||||
|
Text(RetailData.Pal18, a.ValueText, 125, y, 149, RowH, color, right: true);
|
||||||
|
if (clicked && Hit(0, y, BannerW, RowH)) _attrSelected = row;
|
||||||
|
if (listHovered && Hit(0, y, BannerW, RowH)) Hover(1000u + (uint)row, AttributesPage.Tip(a));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally { _dl.PopClipRect(); }
|
||||||
|
if (rows.Count > visible) ScrollBar("attr", ref _attrScroll, top, listH, visible, rows.Count, maxScroll);
|
||||||
|
|
||||||
|
AttributeLine? sel = null;
|
||||||
|
foreach (AttributeLine a in rows) if (AttributesPage.RowIndex(a.Kind, a.Stype) == _attrSelected) sel = a;
|
||||||
|
(string title, string delta) = AttributesPage.FooterTitle(sel);
|
||||||
|
var (one, two) = AttributesPage.FooterLines(sheet, sel);
|
||||||
|
FooterBox(pageH, title, delta, sel?.BuffDelta ?? 0, one, two, sel != null,
|
||||||
|
sel != null ? AttributesPage.RankProgress(sel) : 0,
|
||||||
|
sel != null && AttributesPage.CanRaiseOne(sheet, sel), sel != null && AttributesPage.CanRaiseTen(sheet, sel), showTen: true,
|
||||||
|
sel == null ? null : () => _onTick(() => _reader.Raise(_host, sel, ten: false, _chat)),
|
||||||
|
sel == null ? null : () => _onTick(() => _reader.Raise(_host, sel, ten: true, _chat)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The Titles page (0x10000539) ────────────────────────────────────
|
||||||
|
|
||||||
|
private const uint ArtTitleRule = 0x06001420u;
|
||||||
|
// The red button, a 3-slice: left 32, a stretched 15-wide middle, right 32; pressed -1, ghosted -2.
|
||||||
|
private static readonly uint[] ArtRedButton = { 0x06004C96u, 0x06004C99u, 0x06004C9Cu };
|
||||||
|
private const int TitleRowH = 24;
|
||||||
|
|
||||||
|
private void TitlesPage(SkillsSheet sheet, int pageH)
|
||||||
|
{
|
||||||
|
int y = TabH;
|
||||||
|
TitleList book = sheet.TitleBook;
|
||||||
|
Text(RetailData.Pal18, "Current Display Title:", 8, y + 20, 270, 18, White);
|
||||||
|
string current = book.Displayed != 0 ? SkillsLayout.Title((int)book.Displayed) : "";
|
||||||
|
Text(RetailData.Pal18, current.Length > 0 ? current : "None", 8, y + 40, 270, 18, Gold, center: true);
|
||||||
|
if (Hit(8, y + 40, 270, 18))
|
||||||
|
Hover(2u, "This is the title that all other players will see when they examine your character.");
|
||||||
|
Sprite(ArtTitleRule, 0, y + 60, PanelW, 9, 0xFF54788Fu);
|
||||||
|
Text(RetailData.Pal18, "All Available Titles:", 8, y + 70, 270, 18, White);
|
||||||
|
|
||||||
|
// The button anchors to the bottom (retail: 200x32 at the page's foot), the rule 10 above it.
|
||||||
|
int buttonY = y + pageH - 37;
|
||||||
|
int ruleY = buttonY - 10;
|
||||||
|
int top = y + 90, listH = Math.Max(TitleRowH, ruleY - 4 - top);
|
||||||
|
List<(uint Id, string Text)> titles = book.Sorted();
|
||||||
|
int visible = Math.Max(1, listH / TitleRowH);
|
||||||
|
float maxScroll = Math.Max(0, titles.Count - visible);
|
||||||
|
|
||||||
|
ImGui.SetCursorScreenPos(P(8, top));
|
||||||
|
ImGui.InvisibleButton("##dw_title_list", S(270, listH));
|
||||||
|
bool listHovered = ImGui.IsItemHovered();
|
||||||
|
bool clicked = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||||
|
if (listHovered && !ImGui.GetIO().KeyCtrl) _titleScroll -= ImGui.GetIO().MouseWheel * 3;
|
||||||
|
_titleScroll = Math.Clamp(_titleScroll, 0, maxScroll);
|
||||||
|
int first = (int)MathF.Round(_titleScroll);
|
||||||
|
|
||||||
|
_dl.PushClipRect(P(8, top), P(278, top + listH), true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!book.Known)
|
||||||
|
Text(RetailData.Pal16, "Your titles show here after your next login.", 8, top, 270, TitleRowH * 2, White, center: true);
|
||||||
|
for (int i = first, ry = top; i < titles.Count && ry < top + listH; i++, ry += TitleRowH)
|
||||||
|
{
|
||||||
|
(uint id, string text) = titles[i];
|
||||||
|
if (id == _titleSelected) SpriteCropped(ArtRowSelected, 8, ry, 270, TitleRowH, 282, 20, 0x60206080u);
|
||||||
|
Text(RetailData.Pal16, text, 12, ry, 262, TitleRowH, id == book.Displayed ? Gold : White);
|
||||||
|
if (clicked && Hit(8, ry, 270, TitleRowH)) _titleSelected = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally { _dl.PopClipRect(); }
|
||||||
|
if (titles.Count > visible) ScrollBar("title", ref _titleScroll, top, listH, visible, titles.Count, maxScroll);
|
||||||
|
|
||||||
|
Sprite(ArtTitleRule, 0, ruleY, PanelW, 9, 0xFF54788Fu);
|
||||||
|
// "Set as Display Title": ghosted until another title than the displayed one is selected.
|
||||||
|
bool can = _titleSelected != 0 && _titleSelected != book.Displayed;
|
||||||
|
ImGui.SetCursorScreenPos(P(53, buttonY));
|
||||||
|
bool pressed = ImGui.InvisibleButton("##dw_set_title", S(200, 32));
|
||||||
|
bool held = ImGui.IsItemActive();
|
||||||
|
uint d = !can ? 2u : held ? 1u : 0u;
|
||||||
|
Sprite(ArtRedButton[0] - d, 53, buttonY, 32, 32, 0xFF20208Cu);
|
||||||
|
Sprite(ArtRedButton[1] - d, 85, buttonY, 136, 32, 0xFF20208Cu);
|
||||||
|
Sprite(ArtRedButton[2] - d, 221, buttonY, 32, 32, 0xFF20208Cu);
|
||||||
|
Text(RetailData.Pal18, "Set as Display Title", 53, buttonY, 200, 32, can ? White : TabOff, center: true);
|
||||||
|
if (pressed && can)
|
||||||
|
{
|
||||||
|
uint id = _titleSelected;
|
||||||
|
_onTick(() => _reader.SetDisplayTitle(_host, id, _chat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Options (right-click the frame or the tabs) ─────────────────────
|
||||||
|
|
||||||
|
private void OptionsMenu()
|
||||||
|
{
|
||||||
|
if (ImGui.IsMouseClicked(ImGuiMouseButton.Right) && Hit(-Frame, -Frame, PanelW + 2 * Frame, TabH + Frame))
|
||||||
|
ImGui.OpenPopup("##dw_skills_options");
|
||||||
|
if (!ImGui.BeginPopup("##dw_skills_options")) return;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool replace = _replacesAc();
|
||||||
|
if (ImGui.Checkbox("Open this instead of AC's Character window", ref replace)) _setReplacesAc(replace);
|
||||||
|
if (ImGui.IsItemHovered())
|
||||||
|
ImGui.SetTooltip("AC's toolbar button and key for the Character window open this panel instead.");
|
||||||
|
}
|
||||||
|
finally { ImGui.EndPopup(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retail's window handling: the gold frame moves the window (an 8 px band round the edge, as AC's
|
||||||
|
/// window border), and the bottom edge and its corners resize it, height only, as AC's Character window.
|
||||||
|
/// The cursor shows which.
|
||||||
|
/// </summary>
|
||||||
|
private void FrameHandles(int contentH, bool popped)
|
||||||
|
{
|
||||||
|
const int Band = 8; // retail's border band: the frame and 3 px inside it
|
||||||
|
int inside = Band - Frame;
|
||||||
|
|
||||||
|
// Resize first: the bottom edge (and its corners) belong to the resize, as in retail.
|
||||||
|
ImGui.SetCursorScreenPos(P(-Frame, contentH - inside));
|
||||||
|
ImGui.InvisibleButton("##dw_resize", S(PanelW + 2 * Frame, Band));
|
||||||
|
bool resizeHot = ImGui.IsItemHovered() || ImGui.IsItemActive();
|
||||||
|
if (!popped)
|
||||||
|
{
|
||||||
|
float mouseY = ImGui.GetMousePos().Y / _k;
|
||||||
|
if (ImGui.IsItemActivated())
|
||||||
|
{
|
||||||
|
_resizing = true;
|
||||||
|
_resizeStartH = contentH + 2 * Frame;
|
||||||
|
_resizeStartY = mouseY;
|
||||||
|
_dragH = _resizeStartH;
|
||||||
|
}
|
||||||
|
if (_resizing && ImGui.IsItemActive())
|
||||||
|
{
|
||||||
|
float screenH = ImGui.GetIO().DisplaySize.Y / _k;
|
||||||
|
_dragH = Math.Clamp(_resizeStartH + (mouseY - _resizeStartY), MinPanelH, Math.Max(MinPanelH, screenH));
|
||||||
|
}
|
||||||
|
if (_resizing && !ImGui.IsItemActive())
|
||||||
|
{
|
||||||
|
_resizing = false;
|
||||||
|
_wantH = MathF.Floor(_dragH);
|
||||||
|
_wantSince = Environment.TickCount64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resizeHot && !popped) ImGui.SetMouseCursor(ImGuiMouseCursor.ResizeNS);
|
||||||
|
|
||||||
|
// Move: the top band and the two sides.
|
||||||
|
bool moveHot = false;
|
||||||
|
void MoveBand(string id, int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
ImGui.SetCursorScreenPos(P(x, y));
|
||||||
|
ImGui.InvisibleButton(id, S(w, h));
|
||||||
|
_host.PanelDragWithLastItem();
|
||||||
|
moveHot |= ImGui.IsItemHovered() || ImGui.IsItemActive();
|
||||||
|
}
|
||||||
|
MoveBand("##dw_move_top", -Frame, -Frame, PanelW + 2 * Frame, Frame);
|
||||||
|
MoveBand("##dw_move_left", -Frame, 0, Band, contentH - inside);
|
||||||
|
MoveBand("##dw_move_right", PanelW - inside, 0, Band, contentH - inside);
|
||||||
|
if (moveHot && !resizeHot) ImGui.SetMouseCursor(ImGuiMouseCursor.ResizeAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Frame, page, tabs ───────────────────────────────────────────────
|
||||||
|
|
||||||
|
private void FrameArt(int contentH)
|
||||||
|
{
|
||||||
|
int w = PanelW;
|
||||||
|
Sprite(ArtEdgeTop, -Frame, -Frame, w + 2 * Frame, Frame, 0xFF54788Fu);
|
||||||
|
Sprite(ArtEdgeBottom, -Frame, contentH, w + 2 * Frame, Frame, 0xFF54788Fu);
|
||||||
|
Sprite(ArtEdgeLeft, -Frame, -Frame, Frame, contentH + 2 * Frame, 0xFF54788Fu);
|
||||||
|
Sprite(ArtEdgeRight, w, -Frame, Frame, contentH + 2 * Frame, 0xFF54788Fu);
|
||||||
|
Sprite(ArtCorner, -Frame, -Frame, Frame, Frame, 0xFF6B95B1u);
|
||||||
|
Sprite(ArtCorner, w, -Frame, Frame, Frame, 0xFF6B95B1u);
|
||||||
|
Sprite(ArtCorner, -Frame, contentH, Frame, Frame, 0xFF6B95B1u);
|
||||||
|
Sprite(ArtCorner, w, contentH, Frame, Frame, 0xFF6B95B1u);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Page(int pageH)
|
||||||
|
{
|
||||||
|
// The page background is a 48x48 black at alpha 175, tiled: the world shows through, as retail.
|
||||||
|
// It runs under the tab row too (retail's slanted tab corners show it, not the world).
|
||||||
|
IntPtr t = Tex(RynthIconKind.UiSprite, ArtPage);
|
||||||
|
int fullH = TabH + pageH;
|
||||||
|
for (int y = 0; y < fullH; y += 48)
|
||||||
|
for (int x = 0; x < PanelW; x += 48)
|
||||||
|
{
|
||||||
|
int w = Math.Min(48, PanelW - x), h = Math.Min(48, fullH - y);
|
||||||
|
if (t != IntPtr.Zero)
|
||||||
|
_dl.AddImage(t, P(x, y), P(x + w, y + h), Vector2.Zero, new Vector2(w / 48f, h / 48f));
|
||||||
|
else
|
||||||
|
_dl.AddRectFilled(P(x, y), P(x + w, y + h), 0xAF000000u);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Tabs()
|
||||||
|
{
|
||||||
|
string[] names = { "Attributes", "Skills", "Titles" };
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
bool open = i == _tab;
|
||||||
|
uint[] art = open ? TabOpen : TabClosed;
|
||||||
|
int x0 = i * TabW;
|
||||||
|
// Left cap, a stretched middle, then the right cap: the layout puts it at 83 in a 92-wide tab,
|
||||||
|
// so only its first 9 columns show (the slant), as retail.
|
||||||
|
Sprite(art[0], x0, 0, CapW, TabH, open ? 0xFF161E24u : Black);
|
||||||
|
Sprite(art[1], x0 + CapW, 0, TabW - 2 * CapW + 8, TabH, open ? 0xFF161E24u : Black);
|
||||||
|
SpriteCropped(art[2], x0 + TabW - 9, 0, 9, TabH, 17, 25, open ? 0xFF161E24u : Black);
|
||||||
|
Text(RetailData.Pal16, names[i], x0, 0, TabW, TabH, open ? TabOn : TabOff, center: true);
|
||||||
|
// Tabs only switch the page, as retail's (the window moves by its frame).
|
||||||
|
ImGui.SetCursorScreenPos(P(x0, 0));
|
||||||
|
if (ImGui.InvisibleButton("##dw_tab" + i, S(TabW, TabH))) _tab = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.SetCursorScreenPos(P(CloseX, 0));
|
||||||
|
bool closed = ImGui.InvisibleButton("##dw_close", S(CloseW, TabH));
|
||||||
|
bool held = ImGui.IsItemActive();
|
||||||
|
Sprite(held ? ArtClosePressed : ArtClose, CloseX, 0, CloseW, TabH, 0xFF20282Eu);
|
||||||
|
if (closed) _host.SetPanelOpen(_title, RynthPanelOpen.Close);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The header (0x10000230, shared with the Attributes page) ─────────
|
||||||
|
|
||||||
|
private void Header(SkillsSheet s)
|
||||||
|
{
|
||||||
|
int y = TabH;
|
||||||
|
Text(RetailData.Pal18, s.Name, 0, y, 230, 20, White, center: true);
|
||||||
|
Text(RetailData.Pal14, s.Identity, 0, y + 20, 230, 15, White, center: true);
|
||||||
|
Text(RetailData.Pal14, s.PkStatus, 0, y + 35, 230, 15, White, center: true);
|
||||||
|
if (s.LuminanceMax is long max)
|
||||||
|
{
|
||||||
|
Text(RetailData.Pal16, "Luminance:", 0, y + 52, 110, 18, White);
|
||||||
|
Text(RetailData.Pal16, $"{SkillsSheet.Xp(s.LuminanceAvailable ?? 0)} / {SkillsSheet.Xp(max)}", 110, y + 52, 120, 18, White, right: true);
|
||||||
|
}
|
||||||
|
Text(RetailData.Pal16, "Total Experience (XP):", 0, y + 70, 130, 18, White);
|
||||||
|
Text(RetailData.Pal16, s.TotalXp >= 0 ? SkillsSheet.Xp(s.TotalXp) : "", 130, y + 70, 100, 18, White, right: true);
|
||||||
|
Sprite(ArtPlate, 0, y + 88, 230, 17, 0xFF1E2A4Au);
|
||||||
|
// The plate's red inset (the layout's child at (0,1) 230x15) is a bar: it fills with the way
|
||||||
|
// through the current level, on DreamWeave's chart past 275.
|
||||||
|
float progress = SkillsLayout.LevelProgress(s.Level, s.TotalXp);
|
||||||
|
if (progress > 0)
|
||||||
|
{
|
||||||
|
IntPtr fill = Tex(RynthIconKind.UiSprite, ArtXpFill);
|
||||||
|
float w = 230 * progress;
|
||||||
|
if (fill != IntPtr.Zero) _dl.AddImage(fill, P(0, y + 89), P(w, y + 104), Vector2.Zero, new Vector2(progress, 1));
|
||||||
|
else _dl.AddRectFilled(P(0, y + 89), P(w, y + 104), Rgb(160, 30, 10));
|
||||||
|
}
|
||||||
|
Text(RetailData.Pal16, "XP for next level:", 0, y + 88, 130, 17, White);
|
||||||
|
Text(RetailData.Pal16, s.NextLevelText, 130, y + 88, 100, 17, White, right: true);
|
||||||
|
Sprite(ArtHeaderRule, 230, y, 5, HeaderH, 0xFF54788Fu);
|
||||||
|
Text(RetailData.Pal16, "Character", 235, y + 1, 65, 17, White, center: true);
|
||||||
|
Text(RetailData.Pal16, "Level", 235, y + 18, 65, 17, White, center: true);
|
||||||
|
if (s.Level > 0)
|
||||||
|
Text(RetailData.Stone36, SkillsSheet.Number(s.Level), 235, y + 35, 65, 50, Gold, center: true, outline: true);
|
||||||
|
Sprite(ArtRule, 0, y + HeaderH, PanelW, RuleH, 0xFF54788Fu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The list (0x1000023D) and its scrollbar (0x1000023E) ────────────
|
||||||
|
|
||||||
|
private void SkillList(SkillsSheet sheet, List<SkillRow> rows, int pageH)
|
||||||
|
{
|
||||||
|
int top = TabH + ListTop;
|
||||||
|
int listH = pageH - ListTop - FooterH - RuleH - 3;
|
||||||
|
int visible = Math.Max(1, listH / RowH);
|
||||||
|
float maxScroll = Math.Max(0, rows.Count - visible);
|
||||||
|
|
||||||
|
// Wheel over the list scrolls it (Ctrl+wheel is the host's draw size).
|
||||||
|
ImGui.SetCursorScreenPos(P(0, top));
|
||||||
|
ImGui.InvisibleButton("##dw_list", S(BannerW, listH));
|
||||||
|
bool listHovered = ImGui.IsItemHovered();
|
||||||
|
bool clicked = ImGui.IsItemClicked(ImGuiMouseButton.Left);
|
||||||
|
if (listHovered && !ImGui.GetIO().KeyCtrl) _scroll -= ImGui.GetIO().MouseWheel * 3;
|
||||||
|
_scroll = Math.Clamp(_scroll, 0, maxScroll);
|
||||||
|
int first = (int)MathF.Round(_scroll);
|
||||||
|
|
||||||
|
Vector2 clipMin = P(0, top), clipMax = P(BannerW, top + listH);
|
||||||
|
_dl.PushClipRect(clipMin, clipMax, true);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = first, y = top; i < rows.Count && y < top + listH; i++, y += RowH)
|
||||||
|
{
|
||||||
|
SkillRow row = rows[i];
|
||||||
|
if (row.IsBanner)
|
||||||
|
{
|
||||||
|
SpriteCropped(Banner(row.Section), 0, y, BannerW, RowH, 282, 20, 0xFF3A1E2Au);
|
||||||
|
Text(RetailData.Pal18, SkillsLayout.Title(row.Section), 4, y, BannerW - 8, RowH, White);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SkillLine s = row.Skill!;
|
||||||
|
if (s.Id == _selected) SpriteCropped(ArtRowSelected, 0, y, BannerW, RowH, 282, 20, 0x60206080u);
|
||||||
|
Icon(s.Icon, 0, y, 20);
|
||||||
|
// The list's rows are Palatino 18 (retail's skill rows), the header and footer 16.
|
||||||
|
Text(RetailData.Pal18, s.Name, 25, y, 150, RowH, White);
|
||||||
|
uint color = s.Buffed > s.Base ? Green : s.Buffed < s.Base ? Red : White;
|
||||||
|
Text(RetailData.Pal18, SkillsSheet.Number(s.Buffed), 175, y, 99, RowH, color, right: true);
|
||||||
|
if (clicked && Hit(0, y, BannerW, RowH)) _selected = s.Id;
|
||||||
|
if (listHovered && Hit(0, y, BannerW, RowH) && RetailData.Skill(s.Id) is RetailSkill info)
|
||||||
|
Hover(s.Id, info.Formula.Length > 0 ? info.Formula + "\n" + info.Description : info.Description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_dl.PopClipRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rows.Count > visible) ScrollBar("skills", ref _scroll, top, listH, visible, rows.Count, maxScroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The tooltip (drawn last, over everything) ───────────────────────
|
||||||
|
// Hovering a row a moment shows retail's tooltip: a skill's formula and description, an attribute's
|
||||||
|
// or vital's text, the displayed title's explanation.
|
||||||
|
|
||||||
|
private const long TooltipDelayMs = 400;
|
||||||
|
private const int TooltipWrap = 230; // design px: retail breaks the description at about this width
|
||||||
|
private static readonly uint TooltipBorder = Rgb(196, 164, 92), TooltipBack = 0xE0000000u;
|
||||||
|
private uint _hoverId, _tipKey;
|
||||||
|
private long _hoverSince;
|
||||||
|
private string _tipCandidate = "";
|
||||||
|
private string? _tipText;
|
||||||
|
|
||||||
|
/// <summary>This frame, the mouse is on something with a tooltip (<paramref name="key"/> tells one row from another).</summary>
|
||||||
|
private void Hover(uint key, string text)
|
||||||
|
{
|
||||||
|
_tipKey = key;
|
||||||
|
_tipCandidate = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateTooltip()
|
||||||
|
{
|
||||||
|
long now = Environment.TickCount64;
|
||||||
|
if (_tipKey != _hoverId) { _hoverId = _tipKey; _hoverSince = now; }
|
||||||
|
_tipText = _tipKey != 0 && now - _hoverSince >= TooltipDelayMs && _tipCandidate.Length > 0 ? _tipCandidate : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Tooltip()
|
||||||
|
{
|
||||||
|
if (_tipText == null) return;
|
||||||
|
RetailFont f = RetailData.Pal14;
|
||||||
|
List<string> lines = f.Wrap(_tipText, TooltipWrap);
|
||||||
|
if (lines.Count == 0) return;
|
||||||
|
int w = 0;
|
||||||
|
foreach (string l in lines) w = Math.Max(w, f.Measure(l));
|
||||||
|
int boxW = w + 8, boxH = lines.Count * f.LineHeight + 6;
|
||||||
|
|
||||||
|
// Below and right of the cursor, kept on screen. Design px from the panel's origin.
|
||||||
|
Vector2 mouse = ImGui.GetMousePos(), screen = ImGui.GetIO().DisplaySize;
|
||||||
|
float x = (mouse.X - _origin.X) / _k + 14, y = (mouse.Y - _origin.Y) / _k + 16;
|
||||||
|
float maxX = (screen.X - _origin.X) / _k - boxW - 2, maxY = (screen.Y - _origin.Y) / _k - boxH - 2;
|
||||||
|
int bx = (int)MathF.Round(Math.Max(-_origin.X / _k, Math.Min(x, maxX)));
|
||||||
|
int by = (int)MathF.Round(Math.Max(-_origin.Y / _k, Math.Min(y, maxY)));
|
||||||
|
|
||||||
|
ImDrawListPtr saved = _dl;
|
||||||
|
_dl = ImGui.GetForegroundDrawList();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_dl.AddRectFilled(P(bx, by), P(bx + boxW, by + boxH), TooltipBack);
|
||||||
|
_dl.AddRect(P(bx, by), P(bx + boxW, by + boxH), TooltipBorder, 0, ImDrawFlags.None, Math.Max(1f, _k));
|
||||||
|
for (int i = 0; i < lines.Count; i++)
|
||||||
|
Text(f, lines[i], bx + 4, by + 3 + i * f.LineHeight, boxW - 8, f.LineHeight, White);
|
||||||
|
}
|
||||||
|
finally { _dl = saved; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void ScrollBar(string id, ref float scroll, int top, int h, int visible, int total, float maxScroll)
|
||||||
|
{
|
||||||
|
// The track: a chain of 16x32 links, tiled.
|
||||||
|
IntPtr track = Tex(RynthIconKind.UiSprite, ArtTrack);
|
||||||
|
for (int y = top + ScrollBtn; y < top + h - ScrollBtn; y += 32)
|
||||||
|
{
|
||||||
|
int th = Math.Min(32, top + h - ScrollBtn - y);
|
||||||
|
if (track != IntPtr.Zero) _dl.AddImage(track, P(ScrollX, y), P(ScrollX + ScrollW, y + th), Vector2.Zero, new Vector2(1, th / 32f));
|
||||||
|
else _dl.AddRectFilled(P(ScrollX + 6, y), P(ScrollX + 10, y + th), 0xFF3C6A8Au);
|
||||||
|
}
|
||||||
|
// The arrows.
|
||||||
|
if (Button("##dw_up_" + id, ArtScrollUp, ScrollX, top, ScrollW, ScrollBtn)) scroll = Math.Max(0, scroll - 1);
|
||||||
|
if (Button("##dw_dn_" + id, ArtScrollDown, ScrollX, top + h - ScrollBtn, ScrollW, ScrollBtn)) scroll = Math.Min(maxScroll, scroll + 1);
|
||||||
|
|
||||||
|
// The thumb: caps and a stretched blue middle, sized to the share of the list that shows.
|
||||||
|
int trackTop = top + ScrollBtn, trackH = h - 2 * ScrollBtn;
|
||||||
|
if (trackH <= 8) return;
|
||||||
|
int thumbH = Math.Clamp((int)(trackH * visible / (float)total), 16, trackH);
|
||||||
|
int thumbY = trackTop + (int)((trackH - thumbH) * (maxScroll > 0 ? scroll / maxScroll : 0));
|
||||||
|
ImGui.SetCursorScreenPos(P(ScrollX, trackTop));
|
||||||
|
ImGui.InvisibleButton("##dw_track_" + id, S(ScrollW, trackH));
|
||||||
|
float mouseY = (ImGui.GetMousePos().Y - _origin.Y) / _k;
|
||||||
|
if (ImGui.IsItemActivated())
|
||||||
|
{
|
||||||
|
if (mouseY >= thumbY && mouseY < thumbY + thumbH) { _thumbDrag = true; _thumbGrab = mouseY - thumbY; }
|
||||||
|
else scroll = Math.Clamp(scroll + (mouseY < thumbY ? -visible : visible), 0, maxScroll);
|
||||||
|
}
|
||||||
|
if (_thumbDrag && ImGui.IsItemActive() && trackH > thumbH)
|
||||||
|
scroll = Math.Clamp((mouseY - _thumbGrab - trackTop) / (trackH - thumbH) * maxScroll, 0, maxScroll);
|
||||||
|
if (!ImGui.IsItemActive()) _thumbDrag = false;
|
||||||
|
Sprite(ArtThumbTop, ScrollX, thumbY, ScrollW, ScrollCap, 0xFF8C5A1Eu);
|
||||||
|
Sprite(ArtThumbMid, ScrollX, thumbY + ScrollCap, ScrollW, thumbH - 2 * ScrollCap, 0xFF8C3A10u);
|
||||||
|
Sprite(ArtThumbBottom, ScrollX, thumbY + thumbH - ScrollCap, ScrollW, ScrollCap, 0xFF8C5A1Eu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── The footer (0x10000240 with nothing selected, 0x10000247 with a row), shared by both pages ──
|
||||||
|
|
||||||
|
private void Footer(SkillsSheet sheet, SkillLine? s, int pageH)
|
||||||
|
{
|
||||||
|
(string title, string delta) = SkillsLayout.FooterTitle(s);
|
||||||
|
var (one, two) = SkillsLayout.FooterLines(sheet, s);
|
||||||
|
// The arrow raises one rank (trains an untrained skill); +10 shows for trained and specialized.
|
||||||
|
FooterBox(pageH, title, delta, s?.BuffDelta ?? 0, one, two, s != null,
|
||||||
|
s != null ? SkillsLayout.RankProgress(s) : 0,
|
||||||
|
s != null && SkillsLayout.CanRaiseOne(sheet, s), s != null && SkillsLayout.CanRaiseTen(sheet, s),
|
||||||
|
showTen: s != null && s.Class >= SkillClass.Trained,
|
||||||
|
s == null ? null : () => _onTick(() => _reader.Raise(_host, s, ten: false, _chat)),
|
||||||
|
s == null ? null : () => _onTick(() => _reader.Raise(_host, s, ten: true, _chat)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The footer: the selected row's title ("Salvaging: 303 (+45)", the buff part green or red), then two
|
||||||
|
/// label/value lines; with a row selected the first sits on the plate whose blue inset fills with the way
|
||||||
|
/// through the rank, and the raise arrow and +10 stand at the right. With nothing selected, the prompt.
|
||||||
|
/// </summary>
|
||||||
|
private void FooterBox(int pageH, string title, string delta, int buffDelta,
|
||||||
|
(string Label, string Value) one, (string Label, string Value) two, bool selected, float rank,
|
||||||
|
bool canOne, bool canTen, bool showTen, Action? raiseOne, Action? raiseTen)
|
||||||
|
{
|
||||||
|
int ruleY = TabH + pageH - FooterH - RuleH - 3;
|
||||||
|
int y = TabH + pageH - FooterH;
|
||||||
|
Sprite(ArtRule, 0, ruleY, PanelW, RuleH, 0xFF54788Fu);
|
||||||
|
if (!selected)
|
||||||
|
{
|
||||||
|
Text(RetailData.Pal20, title, 0, y, PanelW, 20, Body, center: true);
|
||||||
|
Text(RetailData.Pal16, one.Label, 5, y + 20, 195, 17, White);
|
||||||
|
Text(RetailData.Pal16, one.Value, 200, y + 20, 95, 17, White, right: true);
|
||||||
|
Text(RetailData.Pal16, two.Label, 5, y + 37, 195, 18, White);
|
||||||
|
Text(RetailData.Pal16, two.Value, 200, y + 37, 95, 18, White, right: true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = RetailData.Pal20.Measure(title) + RetailData.Pal20.Measure(delta);
|
||||||
|
int x = (PanelW - w) / 2;
|
||||||
|
Text(RetailData.Pal20, title, x, y, PanelW, 20, White);
|
||||||
|
if (delta.Length > 0)
|
||||||
|
Text(RetailData.Pal20, delta, x + RetailData.Pal20.Measure(title), y, PanelW, 20, buffDelta > 0 ? Green : Red);
|
||||||
|
Sprite(ArtPlate, 5, y + 20, 240, 17, 0xFF1E2A4Au);
|
||||||
|
// The plate's blue inset (the layout's child at (0,1) 240x15) is a bar: the way through the rank
|
||||||
|
// (a skill's fills by itself from use).
|
||||||
|
if (rank > 0)
|
||||||
|
{
|
||||||
|
IntPtr fill = Tex(RynthIconKind.UiSprite, ArtRankFill);
|
||||||
|
float fw = 240 * rank;
|
||||||
|
if (fill != IntPtr.Zero) _dl.AddImage(fill, P(5, y + 21), P(5 + fw, y + 36), Vector2.Zero, new Vector2(rank, 1));
|
||||||
|
else _dl.AddRectFilled(P(5, y + 21), P(5 + fw, y + 36), Rgb(21, 66, 160));
|
||||||
|
}
|
||||||
|
Text(RetailData.Pal16, one.Label, 5, y + 20, 145, 17, White);
|
||||||
|
Text(RetailData.Pal16, one.Value, 150, y + 20, 95, 17, White, right: true);
|
||||||
|
Text(RetailData.Pal16, two.Label, 5, y + 37, 145, 18, White);
|
||||||
|
Text(RetailData.Pal16, two.Value, 150, y + 37, 95, 18, White, right: true);
|
||||||
|
|
||||||
|
if (Button("##dw_raise", canOne ? ArtRaise : ArtRaiseGhost, 260, y + 26, 30, 26) && canOne) raiseOne?.Invoke();
|
||||||
|
if (showTen && Button("##dw_raise10", canTen ? ArtRaiseTen : ArtRaiseTenGhost, 260, y, 30, 26) && canTen) raiseTen?.Invoke();
|
||||||
|
}
|
||||||
|
// ── Drawing helpers (design pixels in, screen pixels out) ───────────
|
||||||
|
|
||||||
|
private Vector2 P(float x, float y) => new(_origin.X + x * _k, _origin.Y + y * _k);
|
||||||
|
private Vector2 S(float w, float h) => new(Math.Max(1, w * _k), Math.Max(1, h * _k));
|
||||||
|
|
||||||
|
private bool Hit(int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
Vector2 m = ImGui.GetMousePos(), a = P(x, y), b = P(x + w, y + h);
|
||||||
|
return m.X >= a.X && m.X < b.X && m.Y >= a.Y && m.Y < b.Y;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntPtr Tex(RynthIconKind kind, uint id) => id == 0 ? IntPtr.Zero : _host.GetIconTexture(kind, id);
|
||||||
|
|
||||||
|
/// <summary>A retail picture stretched over the box (a flat stand-in until the engine has made it).</summary>
|
||||||
|
private void Sprite(uint id, int x, int y, int w, int h, uint fallback)
|
||||||
|
{
|
||||||
|
if (w <= 0 || h <= 0) return;
|
||||||
|
IntPtr t = Tex(RynthIconKind.UiSprite, id);
|
||||||
|
if (t == IntPtr.Zero) { _dl.AddRectFilled(P(x, y), P(x + w, y + h), fallback); return; }
|
||||||
|
_dl.AddImage(t, P(x, y), P(x + w, y + h));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The top-left <paramref name="w"/> x <paramref name="h"/> of a <paramref name="texW"/> x <paramref name="texH"/> picture, unscaled.</summary>
|
||||||
|
private void SpriteCropped(uint id, int x, int y, int w, int h, int texW, int texH, uint fallback)
|
||||||
|
{
|
||||||
|
IntPtr t = Tex(RynthIconKind.UiSprite, id);
|
||||||
|
if (t == IntPtr.Zero) { _dl.AddRectFilled(P(x, y), P(x + w, y + h), fallback); return; }
|
||||||
|
_dl.AddImage(t, P(x, y), P(x + w, y + h), Vector2.Zero, new Vector2(Math.Min(1f, w / (float)texW), Math.Min(1f, h / (float)texH)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Icon(uint id, int x, int y, int size)
|
||||||
|
{
|
||||||
|
IntPtr t = Tex(RynthIconKind.Icon, id);
|
||||||
|
if (t != IntPtr.Zero) _dl.AddImage(t, P(x, y), P(x + size, y + size));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A retail button: its picture, and true when clicked.</summary>
|
||||||
|
private bool Button(string imguiId, uint art, int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
ImGui.SetCursorScreenPos(P(x, y));
|
||||||
|
bool clicked = ImGui.InvisibleButton(imguiId, S(w, h));
|
||||||
|
Sprite(art, x, y, w, h, 0xFF3C8A3Cu);
|
||||||
|
return clicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Text in a retail dat font, left-aligned (or <paramref name="right"/> / <paramref name="center"/>)
|
||||||
|
/// in the box and centred down it, glyph by glyph from the font's sheet; <paramref name="outline"/>
|
||||||
|
/// draws the font's outline sheet in black under it (the level number). ImGui's font stands in on an
|
||||||
|
/// engine without font sheets.
|
||||||
|
/// </summary>
|
||||||
|
private void Text(RetailFont font, string? text, int x, int y, int w, int h, uint color,
|
||||||
|
bool right = false, bool center = false, bool outline = false)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(text)) return;
|
||||||
|
int width = font.Measure(text);
|
||||||
|
float left = right ? x + w - width : center ? x + (w - width) / 2f : x;
|
||||||
|
float top = y + (h - font.LineHeight) / 2f;
|
||||||
|
IntPtr sheet = Tex(RynthIconKind.FontSheet, font.Sheet);
|
||||||
|
if (sheet == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
Vector2 sz = ImGui.CalcTextSize(text);
|
||||||
|
float fx = right ? P(x + w, 0).X - sz.X : center ? P(x + w / 2f, 0).X - sz.X / 2 : P(x, 0).X;
|
||||||
|
_dl.AddText(new Vector2(fx, P(0, y + h / 2f).Y - sz.Y / 2), color, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
left = MathF.Round(left);
|
||||||
|
top = MathF.Round(top);
|
||||||
|
if (outline && font.OutlineSheet != 0)
|
||||||
|
{
|
||||||
|
IntPtr back = Tex(RynthIconKind.FontSheet, font.OutlineSheet);
|
||||||
|
if (back != IntPtr.Zero) Glyphs(font, text, left, top, back, font.OutlineWidth, font.OutlineHeight, Black, font.BorderX, font.BorderY);
|
||||||
|
}
|
||||||
|
Glyphs(font, text, left, top, sheet, font.SheetWidth, font.SheetHeight, color, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Glyphs(RetailFont font, string text, float x, float y, IntPtr sheet, int sheetW, int sheetH, uint color, int bx, int by)
|
||||||
|
{
|
||||||
|
float pen = x;
|
||||||
|
foreach (char c in text)
|
||||||
|
{
|
||||||
|
if (!font.TryGlyph(c, out RetailGlyph g)) continue;
|
||||||
|
if (g.Width > 0 && g.Height > 0)
|
||||||
|
{
|
||||||
|
float gx = pen + g.Before - bx, gy = y + g.Top - by;
|
||||||
|
int sx = g.SheetX - bx, sy = g.SheetY - by, gw = g.Width + 2 * bx, gh = g.Height + 2 * by;
|
||||||
|
if (sx < 0) { gx -= sx; gw += sx; sx = 0; }
|
||||||
|
if (sy < 0) { gy -= sy; gh += sy; sy = 0; }
|
||||||
|
if (gw > 0 && gh > 0)
|
||||||
|
_dl.AddImage(sheet, P(gx, gy), P(gx + gw, gy + gh),
|
||||||
|
new Vector2(sx / (float)sheetW, sy / (float)sheetH),
|
||||||
|
new Vector2((sx + gw) / (float)sheetW, (sy + gh) / (float)sheetH), color);
|
||||||
|
}
|
||||||
|
pen += g.Advance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SkillLine? Find(SkillsSheet sheet, uint id)
|
||||||
|
{
|
||||||
|
if (id == 0) return null;
|
||||||
|
foreach (SkillLine s in sheet.Skills) if (s.Id == id) return s;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,224 @@
|
||||||
|
// SkillsReader.cs - Reads the character for the Skills panel and spends XP for it, on the plugin tick.
|
||||||
|
//
|
||||||
|
// Reading: while the panel is drawn it asks for a read about four times a second (RequestRead, render
|
||||||
|
// thread); the tick then reads the engine's training numbers (GetTrainingInfo, v79: the engine refreshes
|
||||||
|
// them every 2 s while asked, and at once after a raise) and the header's properties, and publishes one
|
||||||
|
// SkillsSheet. Nothing is read while the panel is closed.
|
||||||
|
//
|
||||||
|
// Spending: the panel's raise arrow and "+10" queue a Raise (or a train, for an untrained skill) with the
|
||||||
|
// cost the player saw; the engine refuses it when the cost changed meanwhile (RaiseResult.CostChanged),
|
||||||
|
// so a click never spends more than the footer said. Like retail's arrow there is no confirm.
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using RynthCore.PluginSdk;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
internal sealed class SkillsReader
|
||||||
|
{
|
||||||
|
private const uint IntGender = 113, IntHeritage = 188, IntPkStatus = 134, IntAllegianceRank = 30, IntCharacterTitleId = 261;
|
||||||
|
private const uint QuadAvailableLuminance = 6, QuadMaximumLuminance = 7;
|
||||||
|
private const long ReadEveryMs = 250;
|
||||||
|
|
||||||
|
private readonly TrainingEntryNative[] _entries = new TrainingEntryNative[128];
|
||||||
|
private SkillsSheet _sheet = SkillsSheet.Empty;
|
||||||
|
private long _lastAsk;
|
||||||
|
private int _readQueued;
|
||||||
|
private string _message = "";
|
||||||
|
|
||||||
|
/// <summary>The newest snapshot (any thread).</summary>
|
||||||
|
public SkillsSheet Sheet => Volatile.Read(ref _sheet);
|
||||||
|
|
||||||
|
/// <summary>The last raise's refusal, for the footer ("" when none). Any thread.</summary>
|
||||||
|
public string Message => Volatile.Read(ref _message);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Render thread, each frame the panel draws: true when a read is due (the caller queues
|
||||||
|
/// <see cref="Read"/> for the tick). At most four a second, one in flight.
|
||||||
|
/// </summary>
|
||||||
|
public bool ReadDue()
|
||||||
|
{
|
||||||
|
long now = Environment.TickCount64;
|
||||||
|
if (now - Volatile.Read(ref _lastAsk) < ReadEveryMs) return false;
|
||||||
|
if (Interlocked.Exchange(ref _readQueued, 1) == 1) return false;
|
||||||
|
Volatile.Write(ref _lastAsk, now);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Logout: forget the character.</summary>
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _sheet, SkillsSheet.Empty);
|
||||||
|
Volatile.Write(ref _message, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Plugin tick: reads the numbers and publishes a new sheet when they are in.</summary>
|
||||||
|
public void Read(RynthCoreHost host)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!host.HasTraining) { Volatile.Write(ref _message, "This RynthCore is too old for the Skills panel (needs plugin API v79)."); return; }
|
||||||
|
if (!host.TryGetTrainingInfo(out TrainingInfoNative info, _entries, out int count)) return;
|
||||||
|
var skills = new System.Collections.Generic.List<SkillLine>(64);
|
||||||
|
var attrs = new AttributeLine?[AttributesPage.Rows.Length];
|
||||||
|
uint health = 0, stam = 0, mana = 0;
|
||||||
|
bool haveVitals = host.TryGetPlayerVitals(out health, out _, out stam, out _, out mana, out _);
|
||||||
|
for (int i = 0; i < Math.Min(count, _entries.Length); i++)
|
||||||
|
{
|
||||||
|
TrainingEntryNative e = _entries[i];
|
||||||
|
if (e.Kind is TrainingKind.Attribute or TrainingKind.Vital)
|
||||||
|
{
|
||||||
|
int kind = e.Kind == TrainingKind.Attribute ? 1 : 2;
|
||||||
|
int row = AttributesPage.RowIndex(kind, e.Stype);
|
||||||
|
if (row < 0) continue;
|
||||||
|
var r = AttributesPage.Rows[row];
|
||||||
|
int current = kind == 2 && haveVitals ? (int)(e.Stype switch { 1 => health, 3 => stam, _ => mana }) : -1;
|
||||||
|
attrs[row] = new AttributeLine(kind, e.Stype, r.Name, r.Icon, e.Base, e.Buffed, e.CostOne, e.CostTen,
|
||||||
|
e.Raisable, e.AtTop, e.Ranks, e.XpSpent, current);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (e.Kind != TrainingKind.Skill || e.Class is < 1 or > 3) continue;
|
||||||
|
RetailSkill? table = RetailData.Skill(e.Stype);
|
||||||
|
if (table == null) continue; // a skill the retail table doesn't list (retired): retail doesn't show it either
|
||||||
|
bool usable = (e.Flags & TrainingEntryFlags.UsableUntrained) != 0 || e.Class >= 2 || table.UsableUntrained;
|
||||||
|
skills.Add(new SkillLine(e.Stype, table.Name, table.Icon, (SkillClass)e.Class, usable,
|
||||||
|
e.Base, e.Buffed, e.CostOne, e.CostTen, e.TrainCredits, e.Raisable, e.Trainable, e.AtTop,
|
||||||
|
e.Ranks, e.XpSpent));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint me = host.GetPlayerId();
|
||||||
|
string name = me != 0 && host.HasGetObjectName && host.TryGetObjectName(me, out string n) ? n : "";
|
||||||
|
int gender = Int(host, me, IntGender), heritage = Int(host, me, IntHeritage), pk = Int(host, me, IntPkStatus);
|
||||||
|
// Retail's header: the allegiance rank's title before the name ("Yeoman Drakkon"), and the
|
||||||
|
// character title chosen in the Titles tab ("Obviously Bored") after sex and heritage.
|
||||||
|
name = SkillsLayout.NameLine(name, gender, heritage, Int(host, me, IntAllegianceRank));
|
||||||
|
int titleId = Int(host, me, IntCharacterTitleId);
|
||||||
|
string title = SkillsLayout.Title(titleId);
|
||||||
|
long? lumMax = Quad(host, me, QuadMaximumLuminance);
|
||||||
|
long? lumAvail = Quad(host, me, QuadAvailableLuminance);
|
||||||
|
TitleList titles = TitlesFor(me).WithDisplayed((uint)Math.Max(0, titleId));
|
||||||
|
|
||||||
|
var attrList = new System.Collections.Generic.List<AttributeLine>(attrs.Length);
|
||||||
|
foreach (AttributeLine? a in attrs) if (a != null) attrList.Add(a);
|
||||||
|
var sheet = new SkillsSheet(name, SkillsLayout.Identity(gender, heritage, title), SkillsLayout.PkStatus(pk),
|
||||||
|
info.Level, info.TotalXp, info.UnassignedXp, info.SkillCredits,
|
||||||
|
lumMax is > 0 ? lumAvail ?? 0 : null, lumMax is > 0 ? lumMax : null,
|
||||||
|
skills, info.Busy, info.SnapshotVersion, attrList, titles);
|
||||||
|
Volatile.Write(ref _sheet, sheet);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _readQueued, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin tick: the raise arrow (<paramref name="ten"/> false: one rank, or train an untrained skill
|
||||||
|
/// with credits) or "+10", at the cost the footer showed. The answer comes back in the numbers;
|
||||||
|
/// a refusal is said in the footer and chat.
|
||||||
|
/// </summary>
|
||||||
|
public void Raise(RynthCoreHost host, SkillLine skill, bool ten, Action<string> chat)
|
||||||
|
{
|
||||||
|
RaiseResult r;
|
||||||
|
if (skill.Class < SkillClass.Trained)
|
||||||
|
r = host.TrainSkill(skill.Id, skill.TrainCredits);
|
||||||
|
else
|
||||||
|
r = host.Raise(TrainingKind.Skill, skill.Id, ten ? 10u : 1u, ten ? skill.CostTen : skill.CostOne, out _);
|
||||||
|
string why = r switch
|
||||||
|
{
|
||||||
|
RaiseResult.Sent => "",
|
||||||
|
RaiseResult.CostChanged or RaiseResult.Stale or RaiseResult.NotReady or RaiseResult.Busy
|
||||||
|
=> "The numbers changed; look again and press once more.",
|
||||||
|
RaiseResult.NotEnough => skill.Class < SkillClass.Trained ? "Not enough skill credits." : "Not enough unassigned experience.",
|
||||||
|
RaiseResult.NotRaisable => $"{skill.Name} can't be raised any further.",
|
||||||
|
RaiseResult.Unavailable => "This client can't raise skills from a plugin.",
|
||||||
|
RaiseResult.EngineTooOld => "This RynthCore is too old to raise skills (needs plugin API v79).",
|
||||||
|
_ => $"{skill.Name} wasn't raised ({r}).",
|
||||||
|
};
|
||||||
|
Volatile.Write(ref _message, why);
|
||||||
|
Volatile.Write(ref _lastAsk, 0); // read again at once
|
||||||
|
if (why.Length > 0) chat(why);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Titles (the server's list, kept per character: AttributesTitles.cs) ──
|
||||||
|
|
||||||
|
private readonly object _titlesGate = new();
|
||||||
|
private readonly System.Collections.Generic.Dictionary<uint, TitleList> _titles = new();
|
||||||
|
private Func<uint, string?>? _loadTitles;
|
||||||
|
private Action<uint, string>? _saveTitles;
|
||||||
|
|
||||||
|
/// <summary>Where the titles are kept between sessions (the plugin's settings, by character id).</summary>
|
||||||
|
public void SetTitleStore(Func<uint, string?> load, Action<uint, string> save)
|
||||||
|
{
|
||||||
|
_loadTitles = load;
|
||||||
|
_saveTitles = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TitleList TitlesFor(uint me)
|
||||||
|
{
|
||||||
|
if (me == 0) return TitleList.Empty;
|
||||||
|
lock (_titlesGate)
|
||||||
|
{
|
||||||
|
if (_titles.TryGetValue(me, out TitleList? t)) return t;
|
||||||
|
t = TitleList.Load(_loadTitles?.Invoke(me));
|
||||||
|
_titles[me] = t;
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Pump thread: game event 0x0029 (the whole list, at login) or 0x002B (one title) for <paramref name="me"/>.</summary>
|
||||||
|
public void OnTitleEvent(uint me, uint eventType, ReadOnlySpan<byte> body)
|
||||||
|
{
|
||||||
|
if (me == 0) return;
|
||||||
|
TitleList next;
|
||||||
|
lock (_titlesGate)
|
||||||
|
{
|
||||||
|
TitleList now = _titles.TryGetValue(me, out TitleList? t) ? t : TitleList.Load(_loadTitles?.Invoke(me));
|
||||||
|
if (eventType == 0x0029) { if (!TitleList.TryParseTable(body, out next)) return; }
|
||||||
|
else next = now.WithUpdate(body);
|
||||||
|
_titles[me] = next;
|
||||||
|
}
|
||||||
|
_saveTitles?.Invoke(me, next.Save());
|
||||||
|
Volatile.Write(ref _lastAsk, 0); // show it at once
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Plugin tick: show <paramref name="titleId"/> as the character's title (retail's "Set as Display Title").</summary>
|
||||||
|
public void SetDisplayTitle(RynthCoreHost host, uint titleId, Action<string> chat)
|
||||||
|
{
|
||||||
|
if (titleId == 0) return;
|
||||||
|
if (!host.HasInvokeChatParser || !host.InvokeChatParser("/rc title " + titleId.ToString(System.Globalization.CultureInfo.InvariantCulture)))
|
||||||
|
chat("Couldn't set the title: this RynthCore can't send it (needs the engine from 2026-11-07).");
|
||||||
|
Volatile.Write(ref _lastAsk, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin tick: raises an attribute (Kind 1) or vital maximum (Kind 2) one or ten ranks at the cost the
|
||||||
|
/// footer showed, as the skills' arrows do.
|
||||||
|
/// </summary>
|
||||||
|
public void Raise(RynthCoreHost host, AttributeLine a, bool ten, Action<string> chat)
|
||||||
|
{
|
||||||
|
RaiseResult r = host.Raise(a.IsVital ? TrainingKind.Vital : TrainingKind.Attribute, a.Stype, ten ? 10u : 1u,
|
||||||
|
ten ? a.CostTen : a.CostOne, out _);
|
||||||
|
string why = r switch
|
||||||
|
{
|
||||||
|
RaiseResult.Sent => "",
|
||||||
|
RaiseResult.CostChanged or RaiseResult.Stale or RaiseResult.NotReady or RaiseResult.Busy
|
||||||
|
=> "The numbers changed; look again and press once more.",
|
||||||
|
RaiseResult.NotEnough => "Not enough unassigned experience.",
|
||||||
|
RaiseResult.NotRaisable => $"{a.Name} can't be raised any further.",
|
||||||
|
RaiseResult.Unavailable => "This client can't raise attributes from a plugin.",
|
||||||
|
RaiseResult.EngineTooOld => "This RynthCore is too old to raise attributes (needs plugin API v79).",
|
||||||
|
_ => $"{a.Name} wasn't raised ({r}).",
|
||||||
|
};
|
||||||
|
Volatile.Write(ref _message, why);
|
||||||
|
Volatile.Write(ref _lastAsk, 0);
|
||||||
|
if (why.Length > 0) chat(why);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Int(RynthCoreHost host, uint id, uint stype)
|
||||||
|
=> id != 0 && host.HasGetObjectIntProperty && host.TryGetObjectIntProperty(id, stype, out int v) ? v : 0;
|
||||||
|
|
||||||
|
|
||||||
|
private static long? Quad(RynthCoreHost host, uint id, uint stype)
|
||||||
|
=> id != 0 && host.TryGetObjectQuadProperty(id, stype, out long v) ? v : null;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,258 @@
|
||||||
|
// SkillsSheet.cs - What the DreamWeave Skills panel shows: one immutable snapshot of the character,
|
||||||
|
// read on the plugin tick (SkillsReader) and drawn on the render thread (SkillsPanel).
|
||||||
|
//
|
||||||
|
// The numbers are the engine's (plugin API v79 GetTrainingInfo: level, total and unassigned XP, skill
|
||||||
|
// credits, and per skill its class, base and buffed values and the XP for +1 and +10, priced from the
|
||||||
|
// client's own tables), the header's words the player object's properties. The one number the client
|
||||||
|
// can't give past level 275 is the next level's total: that comes from DreamWeaveXp.
|
||||||
|
//
|
||||||
|
// Building the rows from that snapshot is pure (Build), so RynthServerPack.Tests covers the sections,
|
||||||
|
// their order and the footer's text.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
/// <summary>A skill's training: untrained 1, trained 2, specialized 3 (the training API's Class).</summary>
|
||||||
|
internal enum SkillClass { None = 0, Untrained = 1, Trained = 2, Specialized = 3 }
|
||||||
|
|
||||||
|
/// <summary>One skill as the engine reported it.</summary>
|
||||||
|
internal sealed record SkillLine(uint Id, string Name, uint Icon, SkillClass Class, bool Usable,
|
||||||
|
int Base, int Buffed, long CostOne, long CostTen, int TrainCredits, bool Raisable, bool Trainable, bool AtTop,
|
||||||
|
uint Ranks = 0, uint XpSpent = 0)
|
||||||
|
{
|
||||||
|
/// <summary>The buff part of the value (buffed - base).</summary>
|
||||||
|
public int BuffDelta => Buffed - Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The character as the panel shows it.</summary>
|
||||||
|
internal sealed record SkillsSheet(
|
||||||
|
string Name, string Identity, string PkStatus,
|
||||||
|
int Level, long TotalXp, long UnassignedXp, int SkillCredits,
|
||||||
|
long? LuminanceAvailable, long? LuminanceMax,
|
||||||
|
IReadOnlyList<SkillLine> Skills, bool Busy, uint Version,
|
||||||
|
IReadOnlyList<AttributeLine>? Attributes = null, TitleList? Titles = null)
|
||||||
|
{
|
||||||
|
public static readonly SkillsSheet Empty = new("", "", "", 0, -1, -1, -1, null, null, Array.Empty<SkillLine>(), false, 0);
|
||||||
|
|
||||||
|
/// <summary>The Attributes page's rows (retail's order); empty until read.</summary>
|
||||||
|
public IReadOnlyList<AttributeLine> AttributeRows => Attributes ?? Array.Empty<AttributeLine>();
|
||||||
|
|
||||||
|
/// <summary>The Titles page's list; empty until the server's list has been seen once.</summary>
|
||||||
|
public TitleList TitleBook => Titles ?? TitleList.Empty;
|
||||||
|
|
||||||
|
public bool HasNumbers => Skills.Count > 0;
|
||||||
|
|
||||||
|
/// <summary>"XP for next level": DreamWeave's chart past 275, retail's below it.</summary>
|
||||||
|
public string NextLevelText
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (TotalXp < 0 || Level <= 0) return "";
|
||||||
|
long? need = DreamWeaveXp.ToNextLevel(Level, TotalXp);
|
||||||
|
return need is long n ? Xp(n) : "Infinity!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string Xp(long value) => value.ToString("N0", CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
public static string Number(int value) => value.ToString(CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>A row of the skills list: a section banner, or a skill.</summary>
|
||||||
|
internal readonly record struct SkillRow(SkillSection Section, SkillLine? Skill)
|
||||||
|
{
|
||||||
|
public bool IsBanner => Skill == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The page's four sections, in order, with their banner art (LayoutDesc 0x2100002E's).</summary>
|
||||||
|
internal enum SkillSection { Specialized, Trained, Untrained, Unusable }
|
||||||
|
|
||||||
|
internal static class SkillsLayout
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The list as retail draws it: Specialized, Trained, Untrained (usable untrained) and Unusable
|
||||||
|
/// Skills, each a banner then its skills by name; a section with no skills is left out.
|
||||||
|
/// </summary>
|
||||||
|
public static List<SkillRow> Rows(IReadOnlyList<SkillLine> skills)
|
||||||
|
{
|
||||||
|
var rows = new List<SkillRow>(skills.Count + 4);
|
||||||
|
foreach (SkillSection section in new[] { SkillSection.Specialized, SkillSection.Trained, SkillSection.Untrained, SkillSection.Unusable })
|
||||||
|
{
|
||||||
|
var members = new List<SkillLine>();
|
||||||
|
foreach (SkillLine s in skills)
|
||||||
|
if (SectionOf(s) == section) members.Add(s);
|
||||||
|
if (members.Count == 0) continue;
|
||||||
|
members.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
|
||||||
|
rows.Add(new SkillRow(section, null));
|
||||||
|
foreach (SkillLine s in members) rows.Add(new SkillRow(section, s));
|
||||||
|
}
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillSection? SectionOf(SkillLine s) => s.Class switch
|
||||||
|
{
|
||||||
|
SkillClass.Specialized => SkillSection.Specialized,
|
||||||
|
SkillClass.Trained => SkillSection.Trained,
|
||||||
|
SkillClass.Untrained => s.Usable ? SkillSection.Untrained : SkillSection.Unusable,
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
public static string Title(SkillSection section) => section switch
|
||||||
|
{
|
||||||
|
SkillSection.Specialized => "Specialized Skills",
|
||||||
|
SkillSection.Trained => "Trained Skills",
|
||||||
|
SkillSection.Untrained => "Untrained Skills",
|
||||||
|
_ => "Unusable Skills",
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>The footer's title: "Salvaging: 303" then the buff part ("(+45)") drawn green or red.</summary>
|
||||||
|
public static (string Text, string Delta) FooterTitle(SkillLine? s)
|
||||||
|
{
|
||||||
|
if (s == null) return ("Select a Skill to Improve", "");
|
||||||
|
if (s.Class < SkillClass.Trained) return (s.Name, "");
|
||||||
|
string text = s.Name + ": " + SkillsSheet.Number(s.Buffed);
|
||||||
|
int d = s.BuffDelta;
|
||||||
|
return (text, d > 0 ? $" (+{d})" : d < 0 ? $" ({d})" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The footer's two label/value lines (retail's words).</summary>
|
||||||
|
public static ((string Label, string Value) One, (string Label, string Value) Two) FooterLines(SkillsSheet sheet, SkillLine? s)
|
||||||
|
{
|
||||||
|
string credits = sheet.SkillCredits >= 0 ? SkillsSheet.Number(sheet.SkillCredits) : "";
|
||||||
|
string unassigned = sheet.UnassignedXp >= 0 ? SkillsSheet.Xp(sheet.UnassignedXp) : "";
|
||||||
|
if (s == null)
|
||||||
|
return (("Skill Credits Available:", credits), ("Unassigned Experience:", unassigned));
|
||||||
|
if (s.Class < SkillClass.Trained)
|
||||||
|
return (("Skill Credits To Raise:", s.TrainCredits > 0 ? SkillsSheet.Number(s.TrainCredits) : "Infinity!"),
|
||||||
|
("Skill Credits Available:", credits));
|
||||||
|
return (("Experience To Raise:", s.CostOne > 0 ? SkillsSheet.Xp(s.CostOne) : "Infinity!"),
|
||||||
|
("Unassigned Experience:", unassigned));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Whether the raise arrow (+1, or train for an untrained skill) can be pressed now.</summary>
|
||||||
|
public static bool CanRaiseOne(SkillsSheet sheet, SkillLine s)
|
||||||
|
{
|
||||||
|
if (sheet.Busy) return false;
|
||||||
|
if (s.Class >= SkillClass.Trained) return s.Raisable && s.CostOne > 0 && sheet.UnassignedXp >= s.CostOne;
|
||||||
|
return s.Trainable && s.TrainCredits > 0 && sheet.SkillCredits >= s.TrainCredits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Whether "+10" can be pressed now (trained or specialized, ten ranks left and affordable).</summary>
|
||||||
|
public static bool CanRaiseTen(SkillsSheet sheet, SkillLine s)
|
||||||
|
=> !sheet.Busy && s.Class >= SkillClass.Trained && s.Raisable && s.CostTen > 0 && sheet.UnassignedXp >= s.CostTen;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retail's header line one: the allegiance rank's title for the heritage and sex, then the name
|
||||||
|
/// ("Yeoman Drakkon"); the name alone with no rank (0) or no title for the heritage.
|
||||||
|
/// </summary>
|
||||||
|
public static string NameLine(string name, int gender, int heritage, int rank)
|
||||||
|
{
|
||||||
|
string? title = RankTitle(gender, heritage, rank);
|
||||||
|
return string.IsNullOrEmpty(title) || string.IsNullOrEmpty(name) ? name : title + " " + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allegiance rank titles 1..10 by heritage (male; female where it differs). Game text, as the client shows it.
|
||||||
|
private static readonly string[] AluvianM = { "Yeoman", "Baronet", "Baron", "Reeve", "Thane", "Ealdor", "Duke", "Aetheling", "King", "High King" };
|
||||||
|
private static readonly string[] AluvianF = { "Yeoman", "Baronet", "Baroness", "Reeve", "Thane", "Ealdor", "Duchess", "Aetheling", "Queen", "High Queen" };
|
||||||
|
private static readonly string[] GharuM = { "Sayyid", "Shayk", "Maulan", "Mu'allim", "Naquib", "Qadi", "Mushir", "Amir", "Malik", "Sultan" };
|
||||||
|
private static readonly string[] GharuF = { "Sayyida", "Shayka", "Maulana", "Mu'allima", "Naquiba", "Qadiya", "Mushira", "Amira", "Malika", "Sultana" };
|
||||||
|
private static readonly string[] ShoM = { "Jinin", "Jo-chueh", "Nan-chueh", "Shi-chueh", "Ta-chueh", "Kun-chueh", "Kou", "Taikou", "Ou", "Koutei" };
|
||||||
|
private static readonly string[] ShoF = { "Jinin", "Jo-chueh", "Nan-chueh", "Shi-chueh", "Ta-chueh", "Kun-chueh", "Kou", "Taikou", "Jo-ou", "Koutei" };
|
||||||
|
private static readonly string[] ViaM = { "Squire", "Banner", "Baron", "Viscount", "Count", "Marquis", "Duke", "Grand Duke", "King", "High King" };
|
||||||
|
private static readonly string[] ViaF = { "Dame", "Banner", "Baroness", "Viscountess", "Countess", "Marquise", "Duchess", "Grand Duchess", "Queen", "High Queen" };
|
||||||
|
private static readonly string[] ShadowM = { "Tenebrous", "Shade", "Squire", "Knight", "Void Knight", "Void Lord", "Duke", "Archduke", "Highborn", "King" };
|
||||||
|
private static readonly string[] ShadowF = { "Tenebrous", "Shade", "Squire", "Knight", "Void Knight", "Void Lady", "Duchess", "Archduchess", "Highborn", "Queen" };
|
||||||
|
private static readonly string[] Tumerok = { "Xutua", "Tuona", "Ona", "Nuona", "Turea", "Rea", "Nurea", "Kauh", "Sutah", "Tah" };
|
||||||
|
private static readonly string[] Gearknight = { "Tribunus", "Praefectus", "Optio", "Centurion", "Principes", "Legatus", "Consul", "Dux", "Secondus", "Primus" };
|
||||||
|
private static readonly string[] Lugian = { "Laigus", "Raigus", "Amploth", "Arintoth", "Obeloth", "Lithos", "Kantos", "Gigas", "Extas", "Tiatus" };
|
||||||
|
private static readonly string[] EmpyreanM = { "Ensign", "Corporal", "Lieutenant", "Commander", "Captain", "Commodore", "Admiral", "Warlord", "Ipharsin", "Aulin" };
|
||||||
|
private static readonly string[] EmpyreanF = { "Ensign", "Corporal", "Lieutenant", "Commander", "Captain", "Commodore", "Admiral", "Warlord", "Ipharsia", "Aulia" };
|
||||||
|
private static readonly string[] UndeadM = { "Neophyte", "Acolyte", "Adept", "Esquire", "Squire", "Knight", "Count", "Viscount", "Highness", "Annointed" };
|
||||||
|
private static readonly string[] UndeadF = { "Neophyte", "Acolyte", "Adept", "Esquire", "Squire", "Knight", "Countess", "Viscountess", "Highness", "Annointed" };
|
||||||
|
|
||||||
|
/// <summary>The allegiance rank's title (rank 1..10) for a sex (1 male, 2 female) and heritage, or null.</summary>
|
||||||
|
public static string? RankTitle(int gender, int heritage, int rank)
|
||||||
|
{
|
||||||
|
if (rank is < 1 or > 10 || gender is not (1 or 2)) return null;
|
||||||
|
bool f = gender == 2;
|
||||||
|
string[]? t = heritage switch
|
||||||
|
{
|
||||||
|
1 => f ? AluvianF : AluvianM,
|
||||||
|
2 => f ? GharuF : GharuM,
|
||||||
|
3 => f ? ShoF : ShoM,
|
||||||
|
4 => f ? ViaF : ViaM,
|
||||||
|
5 or 10 => f ? ShadowF : ShadowM,
|
||||||
|
6 => Gearknight,
|
||||||
|
7 => Tumerok,
|
||||||
|
8 => Lugian,
|
||||||
|
9 => f ? EmpyreanF : EmpyreanM,
|
||||||
|
11 => f ? UndeadF : UndeadM,
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
return t?[rank - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The character title for CharacterTitleId (string table 0x2300000E), or "".</summary>
|
||||||
|
public static string Title(int titleId) => RetailData.Titles.TryGetValue(titleId, out string? t) ? t : "";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How far through the current level the character is (0..1), for the red fill of the "XP for next
|
||||||
|
/// level" bar: DreamWeave's chart past 275. 0 when unknown, 1 at the chart's top.
|
||||||
|
/// </summary>
|
||||||
|
public static float LevelProgress(int level, long totalXp)
|
||||||
|
{
|
||||||
|
IReadOnlyList<ulong> chart = DreamWeaveXp.Totals;
|
||||||
|
if (level < 1 || totalXp < 0 || level >= chart.Count) return 0f;
|
||||||
|
if (level + 1 >= chart.Count) return 1f;
|
||||||
|
ulong from = chart[level], to = chart[level + 1];
|
||||||
|
if (to <= from) return 1f;
|
||||||
|
ulong have = (ulong)totalXp;
|
||||||
|
if (have <= from) return 0f;
|
||||||
|
if (have >= to) return 1f;
|
||||||
|
return (float)((double)(have - from) / (to - from));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// How far a trained or specialized skill is through its current rank (0..1), for the blue fill of the
|
||||||
|
/// footer's "Experience To Raise" bar. Skills earn XP from use (the server's proficiency points: a
|
||||||
|
/// successful use adds a little to the skill, up to a full share every 15 minutes) and go up a rank by
|
||||||
|
/// themselves when it fills, until the last rank. 0 untrained, at the last rank, or unknown.
|
||||||
|
/// </summary>
|
||||||
|
public static float RankProgress(SkillLine s)
|
||||||
|
{
|
||||||
|
uint[] chart = s.Class switch
|
||||||
|
{
|
||||||
|
SkillClass.Specialized => RetailData.SpecializedSkillXp,
|
||||||
|
SkillClass.Trained => RetailData.TrainedSkillXp,
|
||||||
|
_ => System.Array.Empty<uint>(),
|
||||||
|
};
|
||||||
|
if (s.Ranks + 1 >= chart.Length || s.AtTop) return 0f;
|
||||||
|
uint from = chart[s.Ranks], to = chart[s.Ranks + 1];
|
||||||
|
if (to <= from || s.XpSpent <= from) return 0f;
|
||||||
|
if (s.XpSpent >= to) return 1f;
|
||||||
|
return (float)((double)(s.XpSpent - from) / (to - from));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Retail's header line two: "Male Aluvian Obviously Bored" (sex, heritage, title).</summary>
|
||||||
|
public static string Identity(int gender, int heritage, string? title)
|
||||||
|
{
|
||||||
|
var parts = new List<string>(3);
|
||||||
|
string? g = gender switch { 1 => "Male", 2 => "Female", _ => null };
|
||||||
|
string? h = heritage switch
|
||||||
|
{
|
||||||
|
1 => "Aluvian", 2 => "Gharu'ndim", 3 => "Sho", 4 => "Viamontian", 5 => "Umbraen", 6 => "Gearknight",
|
||||||
|
7 => "Tumerok", 8 => "Lugian", 9 => "Empyrean", 10 => "Penumbraen", 11 => "Undead", 12 or 13 => "Olthoi",
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
if (g != null) parts.Add(g);
|
||||||
|
if (h != null) parts.Add(h);
|
||||||
|
if (!string.IsNullOrWhiteSpace(title)) parts.Add(title.Trim());
|
||||||
|
return string.Join(" ", parts);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Retail's header line three, from PlayerKillerStatus (0x04 PK, 0x40 PK Lite).</summary>
|
||||||
|
public static string PkStatus(int status)
|
||||||
|
=> (status & 0x04) != 0 ? "Player Killer" : (status & 0x40) != 0 ? "Player Killer Lite" : "Non-Player Killer";
|
||||||
|
}
|
||||||
96
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeavePlugin.cs
Normal file
96
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeavePlugin.cs
Normal file
|
|
@ -0,0 +1,96 @@
|
||||||
|
// DreamWeavePlugin.cs - RynthDreamWeave's own features, through the shared server plugin's hooks
|
||||||
|
// (Plugins/Shared/ServerPack/ServerPackPlugin.cs): the every-minute bank check that gives Lum/hr its
|
||||||
|
// luminance on DreamWeave (DreamWeave/DreamWeaveBank.cs, 2026-11-02), published as the profile value
|
||||||
|
// "bankLuminance" for the session stats, and its Bank page (DreamWeave/DreamWeavePages.cs).
|
||||||
|
using System;
|
||||||
|
using RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.ServerPack;
|
||||||
|
|
||||||
|
public sealed partial class ServerPackPlugin
|
||||||
|
{
|
||||||
|
private readonly DreamWeaveBank _bank = new();
|
||||||
|
|
||||||
|
partial void ServerPages(System.Collections.Generic.List<ServerPage> pages)
|
||||||
|
{
|
||||||
|
var bankPages = new DreamWeavePages(_bank, () => Active, RunOnTick, CheckBankNow, SaveDreamWeaveSettings);
|
||||||
|
pages.AddRange(bankPages.Pages());
|
||||||
|
AddCharacterPage(pages); // DreamWeaveSkills.cs: the Character panel's page
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerInitialize()
|
||||||
|
{
|
||||||
|
lock (_bank.Gate) _bank.LoadSettings(Settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveDreamWeaveSettings()
|
||||||
|
{
|
||||||
|
lock (_bank.Gate) _bank.SaveSettings(Settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerLoginComplete()
|
||||||
|
{
|
||||||
|
lock (_bank.Gate) _bank.Login(Environment.TickCount64);
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerLogout()
|
||||||
|
{
|
||||||
|
lock (_bank.Gate) _bank.Logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerShutdown() => SaveDreamWeaveSettings();
|
||||||
|
|
||||||
|
partial void ServerChatText(string text, int chatType, ref bool eat)
|
||||||
|
{
|
||||||
|
if (!Active) return;
|
||||||
|
bool ours;
|
||||||
|
long? value;
|
||||||
|
lock (_bank.Gate)
|
||||||
|
{
|
||||||
|
ours = _bank.OnChatLine(text, Environment.TickCount64);
|
||||||
|
value = _bank.Published;
|
||||||
|
}
|
||||||
|
if (value is long v) SetProfileValue(DreamWeaveBank.LuminanceKey, v);
|
||||||
|
if (ours) eat = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerChatBar(string text)
|
||||||
|
{
|
||||||
|
// The player's own /b: its reply shows (DreamWeaveBank tells it from RynthDreamWeave's).
|
||||||
|
if (DreamWeaveBank.IsBalanceCommand(text)) _bank.NoteTypedCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerTick(bool active)
|
||||||
|
{
|
||||||
|
if (!active) return;
|
||||||
|
string? check;
|
||||||
|
lock (_bank.Gate)
|
||||||
|
{
|
||||||
|
_bank.Tick();
|
||||||
|
check = _bank.CheckDue(Environment.TickCount64);
|
||||||
|
}
|
||||||
|
if (check != null && !Send(check)) lock (_bank.Gate) _bank.NotSent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The page's Check now (on the tick).</summary>
|
||||||
|
private void CheckBankNow()
|
||||||
|
{
|
||||||
|
if (!Active) return;
|
||||||
|
string command;
|
||||||
|
lock (_bank.Gate) command = _bank.Request(Environment.TickCount64);
|
||||||
|
if (!Send(command))
|
||||||
|
{
|
||||||
|
lock (_bank.Gate) _bank.NotSent();
|
||||||
|
ChatFail($"[{RynthPluginInfo.Name}] Couldn't send {command}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerInfoLines(Action<string> line)
|
||||||
|
{
|
||||||
|
lock (_bank.Gate)
|
||||||
|
{
|
||||||
|
string lum = _bank.Luminance is long l ? l.ToString("N0", System.Globalization.CultureInfo.InvariantCulture) : "not read yet";
|
||||||
|
line($"Bank check every minute {(_bank.CheckEveryMinute ? "on" : "off")}; banked luminance {lum}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
270
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeaveSkills.cs
Normal file
270
Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeaveSkills.cs
Normal file
|
|
@ -0,0 +1,270 @@
|
||||||
|
// DreamWeaveSkills.cs - RynthDreamWeave's Character panel (2026-11-07), through the shared server plugin's
|
||||||
|
// hooks (Plugins/Shared/ServerPack/ServerPackPlugin.cs): retail's Character window, Attributes, Skills and
|
||||||
|
// Titles, drawn 1:1 (DreamWeave/SkillsPanel.cs), whose "XP for next level" keeps reading past level 275 on
|
||||||
|
// DreamWeave's own chart (DreamWeave/DreamWeaveXp.cs) where AC's panel goes negative.
|
||||||
|
//
|
||||||
|
// It is a window of its own on RynthCore's bar ("DreamWeave Skills", only on DreamWeave, frameless, drawn
|
||||||
|
// under AC's own UI like a native window), also opened with "/rserver skills". With "Open this instead of
|
||||||
|
// AC's Character window" (on by default; the panel's right-click menu, or /rserver skills replace on|off)
|
||||||
|
// AC's own Character window (toolbar button or key) opens this one instead. AC's Character Information
|
||||||
|
// window (the mini bar's backpack button) stays AC's own (2026-11-08), one of the main panels.
|
||||||
|
//
|
||||||
|
// Titles come from the server's game events 0x0029 (the list, at login) and 0x002B (one title), kept per
|
||||||
|
// character in the plugin's settings so a hot reload still has them; "Set as Display Title" sends
|
||||||
|
// "/rc title <id>" (the engine calls AC's own sender).
|
||||||
|
//
|
||||||
|
// Hooks used: ServerWindows, ServerCommandVerbs, ServerChatCommand, ServerMessageInterest, ServerMessage,
|
||||||
|
// ServerRender - none of the other DreamWeave features' (the bank check's), so they sit side by side.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Threading;
|
||||||
|
using RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
using RynthCore.PluginSdk;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.ServerPack;
|
||||||
|
|
||||||
|
public sealed partial class ServerPackPlugin
|
||||||
|
{
|
||||||
|
internal const string SkillsWindowId = "skills";
|
||||||
|
internal const string SkillsWindowTitle = "DreamWeave Skills";
|
||||||
|
private const string ReplaceAcSetting = "skillsReplaceAcCharacter";
|
||||||
|
private const string OnePanelSetting = "skillsOnePanelAtATime";
|
||||||
|
private const uint EventCharacterTitle = 0x0029, EventUpdateTitle = 0x002B;
|
||||||
|
|
||||||
|
private readonly SkillsReader _skillsReader = new();
|
||||||
|
private SkillsPanel? _skillsPanel;
|
||||||
|
private int _replaceAc = -1; // -1 not read yet (the settings are the pump's), 0 off, 1 on
|
||||||
|
private int _onePanel = 1; // one main panel at a time (OnePanelRule); read with _replaceAc
|
||||||
|
private readonly OnePanelRule _onePanelRule = new();
|
||||||
|
private bool _skillsStoreSet;
|
||||||
|
|
||||||
|
partial void ServerWindows(List<ServerWindow> windows)
|
||||||
|
{
|
||||||
|
int w = RynthCore.Plugin.RynthDreamWeave.SkillsPanel.PanelW + 2 * RynthCore.Plugin.RynthDreamWeave.SkillsPanel.Frame;
|
||||||
|
// fitHeight: the panel resizes itself from its bottom edge, as retail's Character window (SkillsPanel).
|
||||||
|
// underUi: AC's own windows cover it, as they cover each other.
|
||||||
|
// DrawScale: its size is its own (Ctrl+wheel, 30-250%), 100% = retail's pixels, not the text size.
|
||||||
|
// The minimums are small on purpose: the window is in RynthCore's DPI-scaled units, and the panel (retail's
|
||||||
|
// own pixels at 100%) fits it to itself; a 310 minimum held it 1.6x wide at 160% display scaling.
|
||||||
|
windows.Add(new ServerWindow(SkillsWindowId, SkillsWindowTitle, "", w, 610, 120, 120, Frameless: true, DrawSkills,
|
||||||
|
FitHeight: true, UnderUi: true, DrawScale: true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private RynthCore.Plugin.RynthDreamWeave.SkillsPanel Panel()
|
||||||
|
{
|
||||||
|
if (!_skillsStoreSet)
|
||||||
|
{
|
||||||
|
_skillsStoreSet = true;
|
||||||
|
// Pump thread (the reader's tick and the server messages): the plugin's settings, one key per character.
|
||||||
|
_skillsReader.SetTitleStore(
|
||||||
|
id => Settings.GetString(TitlesKey(id), ""),
|
||||||
|
(id, saved) => { Settings.SetString(TitlesKey(id), saved); Settings.Save(); });
|
||||||
|
}
|
||||||
|
return _skillsPanel ??= new SkillsPanel(Host, _skillsReader, SkillsWindowTitle, RunOnTick, ChatLine,
|
||||||
|
() => Volatile.Read(ref _replaceAc) != 0, SetReplaceAc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string TitlesKey(uint characterId) => "titles." + characterId.ToString("X8", CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
private System.Numerics.Vector2 DrawSkills(bool popped) => Panel().Draw(popped);
|
||||||
|
|
||||||
|
// ── The DreamWeave window's Character page (open it, its setting: no chat commands needed) ──
|
||||||
|
|
||||||
|
/// <remarks>
|
||||||
|
/// The bank check (DreamWeavePlugin.cs) implements ServerPages and calls this for the Character page.
|
||||||
|
/// </remarks>
|
||||||
|
private void AddCharacterPage(List<ServerPage> pages)
|
||||||
|
{
|
||||||
|
var page = new CharacterPage(
|
||||||
|
active: () => Active,
|
||||||
|
panelState: () => Host.HasSetPanelOpen ? Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Ask) : -1,
|
||||||
|
open: tab =>
|
||||||
|
{
|
||||||
|
Panel().ShowPage(tab);
|
||||||
|
Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Open);
|
||||||
|
},
|
||||||
|
close: () => Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Close),
|
||||||
|
replacesAc: () => Volatile.Read(ref _replaceAc) != 0,
|
||||||
|
setReplacesAc: SetReplaceAc,
|
||||||
|
onePanel: () => Volatile.Read(ref _onePanel) != 0,
|
||||||
|
setOnePanel: SetOnePanel);
|
||||||
|
pages.Add(page.Page());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Opening it instead of AC's Character window ─────────────────────
|
||||||
|
|
||||||
|
private void SetReplaceAc(bool on)
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _replaceAc, on ? 1 : 0);
|
||||||
|
RunOnTick(() => { Settings.SetBool(ReplaceAcSetting, on); Settings.Save(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>AC's main panels, the ones that share retail's panel frame (not the Character window: that is this panel).
|
||||||
|
/// The Character Information window (the mini bar's backpack button) stays AC's own and is one of them.</summary>
|
||||||
|
private static readonly RynthAcPanel[] MainAcPanels =
|
||||||
|
{
|
||||||
|
RynthAcPanel.Book, RynthAcPanel.HelpfulSpells, RynthAcPanel.HarmfulSpells, RynthAcPanel.Inventory,
|
||||||
|
RynthAcPanel.LinkStatus, RynthAcPanel.Options, RynthAcPanel.Social, RynthAcPanel.Spellbook,
|
||||||
|
RynthAcPanel.Help, RynthAcPanel.Vitae, RynthAcPanel.Map, RynthAcPanel.Quests, RynthAcPanel.CharacterInfo,
|
||||||
|
};
|
||||||
|
|
||||||
|
private void SetOnePanel(bool on)
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _onePanel, on ? 1 : 0);
|
||||||
|
RunOnTick(() => { Settings.SetBool(OnePanelSetting, on); Settings.Save(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Every frame (AC's thread): one main panel at a time, as retail - this panel opening closes AC's open main
|
||||||
|
/// panel (inventory, spellbook, social, options, map...), and one of those opening closes this panel.
|
||||||
|
/// </summary>
|
||||||
|
private void OnePanelAtATime()
|
||||||
|
{
|
||||||
|
if (Volatile.Read(ref _onePanel) == 0 || !Active || !Host.HasAcPanels || !Host.HasSetPanelOpen)
|
||||||
|
{
|
||||||
|
_onePanelRule.Reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int ours = Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Ask);
|
||||||
|
if (ours < 0) return; // the window isn't there (older engine)
|
||||||
|
uint ac = 0;
|
||||||
|
RynthAcPanel[] main = MainAcPanels;
|
||||||
|
for (int i = 0; i < main.Length; i++)
|
||||||
|
if (Host.IsAcPanelOpen(main[i]) == true) ac |= 1u << i;
|
||||||
|
OnePanelRule.Step step = _onePanelRule.Next(ours == 1, ac);
|
||||||
|
for (int i = 0; i < main.Length; i++)
|
||||||
|
if ((step.CloseAc & (1u << i)) != 0) Host.AcPanel(main[i], RynthAcPanelOp.Close);
|
||||||
|
if (step.CloseOurs) Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Close);
|
||||||
|
}
|
||||||
|
|
||||||
|
// AC's own Character windows claimed (engine 2026-11-07, "/rc panels replace"): the engine holds back AC's
|
||||||
|
// open, so AC's window never shows, and runs these instead. Sent when the setting is read or changes; an
|
||||||
|
// engine reload reloads the plugins too, so a new engine hears it again.
|
||||||
|
private const string PressCharacter = "/rserver skills press character", PressTitles = "/rserver skills press titles";
|
||||||
|
private int _claimed = -1; // what was last sent: -1 nothing, 0 off, 1 on
|
||||||
|
|
||||||
|
private bool _infoReleased;
|
||||||
|
|
||||||
|
private void ClaimAcPanels(int replace)
|
||||||
|
{
|
||||||
|
bool on = replace == 1 && Active && Host.HasSetPanelOpen;
|
||||||
|
int want = on ? 1 : 0;
|
||||||
|
if (want == _claimed || (_claimed < 0 && !on) || !Host.HasInvokeChatParser) return; // never claimed: nothing to drop
|
||||||
|
_claimed = want;
|
||||||
|
string id = ((int)RynthAcPanel.Character).ToString(CultureInfo.InvariantCulture);
|
||||||
|
Host.InvokeChatParser($"/rc panels replace {id} {(on ? PressCharacter : "off")}");
|
||||||
|
// AC's Character Information window (the mini bar's backpack button) is AC's own again (2026-11-08, Tom:
|
||||||
|
// it "used to open up an information panel for the character, now it opens the titles panel"). It was
|
||||||
|
// claimed as a "Titles window"; an engine still holding that claim from the build before lets it go
|
||||||
|
// (quiet when it holds none).
|
||||||
|
if (!_infoReleased)
|
||||||
|
{
|
||||||
|
_infoReleased = true;
|
||||||
|
string info = ((int)RynthAcPanel.CharacterInfo).ToString(CultureInfo.InvariantCulture);
|
||||||
|
Host.InvokeChatParser($"/rc panels replace {info} off");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// AC's Character button or key (<paramref name="page"/> 1), or its Character Titles window (2): as retail's
|
||||||
|
/// button, it toggles this panel; Titles turns an open panel to its Titles page first. AC's thread.
|
||||||
|
/// </summary>
|
||||||
|
private void PressAcButton(int page)
|
||||||
|
{
|
||||||
|
int ours = Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Ask);
|
||||||
|
if (ours < 0) return; // the window isn't there (older engine)
|
||||||
|
RynthCore.Plugin.RynthDreamWeave.SkillsPanel panel = Panel();
|
||||||
|
if (ours == 1 && !(page == 2 && panel.CurrentPage != 2))
|
||||||
|
{
|
||||||
|
Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Close);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (page == 2) panel.ShowPage(2);
|
||||||
|
Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Open);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Every frame (AC's thread): AC's Character or Character Titles window opened -> this panel instead;
|
||||||
|
/// one main panel at a time.</summary>
|
||||||
|
partial void ServerRender()
|
||||||
|
{
|
||||||
|
int replace = Volatile.Read(ref _replaceAc);
|
||||||
|
if (replace < 0)
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _replaceAc, 2); // asked for once
|
||||||
|
RunOnTick(() =>
|
||||||
|
{
|
||||||
|
Volatile.Write(ref _onePanel, Settings.GetBool(OnePanelSetting, true) ? 1 : 0);
|
||||||
|
Volatile.Write(ref _replaceAc, Settings.GetBool(ReplaceAcSetting, true) ? 1 : 0);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (replace == 2) return;
|
||||||
|
ClaimAcPanels(replace);
|
||||||
|
OnePanelAtATime();
|
||||||
|
// An engine without the claim (before 2026-11-07): AC's window opened, close it and open this one. It
|
||||||
|
// shows for a moment (AC's open state is read at most 5 times a second).
|
||||||
|
if (replace != 1 || !Active || !Host.HasAcPanels || !Host.HasSetPanelOpen) return;
|
||||||
|
if (Host.IsAcPanelOpen(RynthAcPanel.Character) != true) return;
|
||||||
|
// AC's close is queued: one swap per press.
|
||||||
|
long now = Environment.TickCount64;
|
||||||
|
bool fresh = now >= _replaceHoldUntil;
|
||||||
|
Host.AcPanel(RynthAcPanel.Character, RynthAcPanelOp.Close);
|
||||||
|
if (!fresh) return;
|
||||||
|
_replaceHoldUntil = now + 700;
|
||||||
|
PressAcButton(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long _replaceHoldUntil;
|
||||||
|
|
||||||
|
// ── Titles from the server ──────────────────────────────────────────
|
||||||
|
|
||||||
|
partial void ServerMessageInterest(List<uint> gameEvents)
|
||||||
|
{
|
||||||
|
gameEvents.Add(EventCharacterTitle);
|
||||||
|
gameEvents.Add(EventUpdateTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
partial void ServerMessage(uint opcode, ReadOnlySpan<byte> body)
|
||||||
|
{
|
||||||
|
var msg = new RynthCore.PluginSdk.Net.ServerMessage(opcode, body);
|
||||||
|
if (!msg.IsGameEvent || (msg.EventType != EventCharacterTitle && msg.EventType != EventUpdateTitle)) return;
|
||||||
|
Panel(); // the title store is wired
|
||||||
|
_skillsReader.OnTitleEvent(msg.EventObjectId, msg.EventType, msg.EventBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── /rserver skills ─────────────────────────────────────────────────
|
||||||
|
|
||||||
|
partial void ServerCommandVerbs(List<string> verbs) => verbs.Add("skills");
|
||||||
|
|
||||||
|
partial void ServerChatCommand(string[] parts, ref bool handled)
|
||||||
|
{
|
||||||
|
if (parts.Length < 2 || !parts[1].Equals("skills", StringComparison.OrdinalIgnoreCase)) return;
|
||||||
|
handled = true;
|
||||||
|
// "press character|titles": what AC's own Character button or Titles window does now (the engine runs it
|
||||||
|
// in their place, ClaimAcPanels). Quiet: it's a button, not a command.
|
||||||
|
if (parts.Length >= 4 && parts[2].Equals("press", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
if (Active && Host.HasSetPanelOpen)
|
||||||
|
PressAcButton(parts[3].Equals("titles", StringComparison.OrdinalIgnoreCase) ? 2 : 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parts.Length >= 4 && parts[2].Equals("replace", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
bool on = parts[3].Equals("on", StringComparison.OrdinalIgnoreCase);
|
||||||
|
if (!on && !parts[3].Equals("off", StringComparison.OrdinalIgnoreCase)) { Reply.Fail("Usage: /rserver skills replace on|off"); return; }
|
||||||
|
SetReplaceAc(on);
|
||||||
|
Reply.Ok(on ? "AC's Character window now opens the DreamWeave panel." : "AC's Character window opens as usual.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Host.HasSetPanelOpen || Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Ask) < 0)
|
||||||
|
{
|
||||||
|
Reply.Fail(Active
|
||||||
|
? "The Skills panel needs a RynthCore with plugin windows that draw their own frame (plugin API v90)."
|
||||||
|
: "The Skills panel is for DreamWeave only.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool open = Host.SetPanelOpen(SkillsWindowTitle, RynthPanelOpen.Toggle) == 1;
|
||||||
|
Reply.Ok(open ? "Skills panel open." : "Skills panel closed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<!-- RynthDreamWeave: the DreamWeave server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
<!-- RynthDreamWeave: the DreamWeave server plugin. The build is shared (..\Shared\ServerPack\ServerPlugin.props);
|
||||||
ServerData.cs holds what is known about the server. -->
|
ServerData.cs holds what is known about the server. Its own feature (DreamWeavePlugin.cs, DreamWeave\,
|
||||||
|
2026-11-02): the bank check every minute that gives Lum/hr its luminance there, and its Bank page. -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<AssemblyName>RynthCore.Plugin.RynthDreamWeave</AssemblyName>
|
<AssemblyName>RynthCore.Plugin.RynthDreamWeave</AssemblyName>
|
||||||
<Version>0.1.0</Version>
|
<Version>0.2.0</Version>
|
||||||
<RynthPluginServerId>dreamweave</RynthPluginServerId>
|
<RynthPluginServerId>dreamweave</RynthPluginServerId>
|
||||||
<RynthPluginServerName>DreamWeave</RynthPluginServerName>
|
<RynthPluginServerName>DreamWeave</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>play.acdreamweave.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>play.acdreamweave.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>DreamWeave|Dream Weave</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>DreamWeave|Dream Weave</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>DreamWeave only: the server card (rules, server features, player commands, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>DreamWeave only: the server card (rules, server features, player commands, links, account setup) in its own window on the RynthCore bar, the retail Character panel whose XP for next level keeps reading past level 275, and the bank check every minute that gives Lum/hr its luminance.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Eversong</RynthPluginServerName>
|
<RynthPluginServerName>Eversong</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>eversong.abrdns.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>eversong.abrdns.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Eversong</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Eversong</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Eversong only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Eversong only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>FrostACE</RynthPluginServerName>
|
<RynthPluginServerName>FrostACE</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>172.111.230.127</RynthPluginServerHosts>
|
<RynthPluginServerHosts>172.111.230.127</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>FrostACE|FrostfACE</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>FrostACE|FrostfACE</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>FrostACE only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>FrostACE only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Frostcull</RynthPluginServerName>
|
<RynthPluginServerName>Frostcull</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>frostcull.ddns.net</RynthPluginServerHosts>
|
<RynthPluginServerHosts>frostcull.ddns.net</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Frostcull</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Frostcull</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Frostcull only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Frostcull only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>LeafDawn</RynthPluginServerName>
|
<RynthPluginServerName>LeafDawn</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>leafdawn.hopto.org</RynthPluginServerHosts>
|
<RynthPluginServerHosts>leafdawn.hopto.org</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>LeafDawn</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>LeafDawn</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>LeafDawn only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>LeafDawn only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Leafdawning</RynthPluginServerName>
|
<RynthPluginServerName>Leafdawning</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>leafdawning.duckdns.org</RynthPluginServerHosts>
|
<RynthPluginServerHosts>leafdawning.duckdns.org</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Leafdawning</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Leafdawning</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Leafdawning only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Leafdawning only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<RynthPluginServerName>Levistras</RynthPluginServerName>
|
<RynthPluginServerName>Levistras</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>levistras.acportalstorm.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>levistras.acportalstorm.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Levistras</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Levistras</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Levistras only: the server card (rules, account limits, botting policy, account setup) in the Mini Remote, and Levistras's quests in RynthOracle.</RynthPluginDescription>
|
<RynthPluginDescription>Levistras only: the server card (rules, account limits, botting policy, account setup) in its own window on the RynthCore bar, and Levistras's quests in RynthOracle.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>PortalStorm</RynthPluginServerName>
|
<RynthPluginServerName>PortalStorm</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>ac.portalstorm.us.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>ac.portalstorm.us.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>PortalStorm|Portal Storm</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>PortalStorm|Portal Storm</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>PortalStorm only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>PortalStorm only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Reefcull</RynthPluginServerName>
|
<RynthPluginServerName>Reefcull</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>reefcull.gdleac.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>reefcull.gdleac.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Reefcull</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Reefcull</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Reefcull only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Reefcull only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Sundering</RynthPluginServerName>
|
<RynthPluginServerName>Sundering</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>ace.sunderingac.com</RynthPluginServerHosts>
|
<RynthPluginServerHosts>ace.sunderingac.com</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Sundering|The Sundering</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Sundering|The Sundering</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Sundering only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Sundering only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<RynthPluginServerName>Thistlecrown</RynthPluginServerName>
|
<RynthPluginServerName>Thistlecrown</RynthPluginServerName>
|
||||||
<RynthPluginServerHosts>thistlecrown.ddns.net</RynthPluginServerHosts>
|
<RynthPluginServerHosts>thistlecrown.ddns.net</RynthPluginServerHosts>
|
||||||
<RynthPluginServerWorldNames>Thistlecrown</RynthPluginServerWorldNames>
|
<RynthPluginServerWorldNames>Thistlecrown</RynthPluginServerWorldNames>
|
||||||
<RynthPluginDescription>Thistlecrown only: the server card (rules, account limits, botting policy, links, account setup) in the Mini Remote.</RynthPluginDescription>
|
<RynthPluginDescription>Thistlecrown only: the server card (rules, account limits, botting policy, links, account setup) in its own window on the RynthCore bar.</RynthPluginDescription>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
<Import Project="..\Shared\ServerPack\ServerPlugin.props" />
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,20 @@ public static unsafe class ServerPackExports
|
||||||
[UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })]
|
[UnmanagedCallersOnly(EntryPoint = "RynthPluginInit", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||||
private static int Init(RynthCoreApiNative* api) => Runtime.Init(api);
|
private static int Init(RynthCoreApiNative* api) => Runtime.Init(api);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Plugin API v78: a reassembled server message the server's code asked for (ServerMessageInterest,
|
||||||
|
/// 2026-11-07). <paramref name="data"/> is the message after its opcode, valid only during the call. Pump thread.
|
||||||
|
/// </summary>
|
||||||
|
[UnmanagedCallersOnly(EntryPoint = "RynthPluginOnServerMessage", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||||
|
private static void OnServerMessage(uint opcode, byte* data, int length)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Runtime.Plugin?.OnServerMessage(opcode, data != null && length > 0 ? new ReadOnlySpan<byte>(data, length) : ReadOnlySpan<byte>.Empty);
|
||||||
|
}
|
||||||
|
catch { /* never let a managed exception cross the native boundary */ }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Plugin API v68 plugin-to-plugin interfaces: "RynthServer.Profile" v1 (ServerPackInterface),
|
/// Plugin API v68 plugin-to-plugin interfaces: "RynthServer.Profile" v1 (ServerPackInterface),
|
||||||
/// the server's settings for any plugin RynthCore's GetServerStateJson points at this one, and
|
/// the server's settings for any plugin RynthCore's GetServerStateJson points at this one, and
|
||||||
|
|
@ -80,6 +94,18 @@ public static unsafe class ServerPackExports
|
||||||
catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ }
|
catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The same while RynthCore's ImGui shell is off (the bar UI: the engine calls this instead of
|
||||||
|
/// RynthPluginRender). Without it the per-frame ServerRender hook never ran there (2026-11-07:
|
||||||
|
/// RynthDreamWeave's "open this instead of AC's Character window" didn't). Render thread.
|
||||||
|
/// </summary>
|
||||||
|
[UnmanagedCallersOnly(EntryPoint = "RynthPluginRenderOverlay", CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||||
|
public static void RenderOverlay()
|
||||||
|
{
|
||||||
|
try { Runtime.OnRender(); }
|
||||||
|
catch { /* an exception crossing UnmanagedCallersOnly would fail-fast the client */ }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The engine's plugin-command broker: "servermenu" from RynthCore (2026.10.5.48+). The ANSI
|
/// The engine's plugin-command broker: "servermenu" from RynthCore (2026.10.5.48+). The ANSI
|
||||||
/// strings are copied before returning (the caller frees them); the payload is only parsed, so
|
/// strings are copied before returning (the caller frees them); the payload is only parsed, so
|
||||||
|
|
@ -112,11 +138,18 @@ public static unsafe class ServerPackExports
|
||||||
{
|
{
|
||||||
if (surface == null) return 0;
|
if (surface == null) return 0;
|
||||||
string name = Marshal.PtrToStringUTF8((IntPtr)surface) ?? string.Empty;
|
string name = Marshal.PtrToStringUTF8((IntPtr)surface) ?? string.Empty;
|
||||||
if (name.EndsWith(":popout", StringComparison.Ordinal)) name = name[..^":popout".Length];
|
bool popped = name.EndsWith(":popout", StringComparison.Ordinal);
|
||||||
|
if (popped) name = name[..^":popout".Length];
|
||||||
var plugin = Runtime.Plugin;
|
var plugin = Runtime.Plugin;
|
||||||
if (plugin == null) return 0;
|
if (plugin == null) return 0;
|
||||||
float wantH;
|
float wantH, wantW = 0;
|
||||||
if (name.Equals(ServerPackModel.WindowSurface, StringComparison.Ordinal))
|
string? ownWindow = ServerPackWindows.IdOf(name);
|
||||||
|
if (ownWindow != null)
|
||||||
|
{
|
||||||
|
// One of the server's own windows (ServerWindows, 2026-11-07); it may size its width too.
|
||||||
|
if (!plugin.RenderServerWindow(ownWindow, popped, out wantH, out wantW)) return 0;
|
||||||
|
}
|
||||||
|
else if (name.Equals(ServerPackModel.WindowSurface, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
if (!plugin.RenderEmbeddedWindow(out wantH)) return 0;
|
if (!plugin.RenderEmbeddedWindow(out wantH)) return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +162,7 @@ public static unsafe class ServerPackExports
|
||||||
string? page = ServerPackPages.PageIdOf(name, RynthPluginInfo.ServerId);
|
string? page = ServerPackPages.PageIdOf(name, RynthPluginInfo.ServerId);
|
||||||
if (page == null || !plugin.RenderEmbeddedPage(page, out wantH)) return 0;
|
if (page == null || !plugin.RenderEmbeddedPage(page, out wantH)) return 0;
|
||||||
}
|
}
|
||||||
if (wantWidth != null) *wantWidth = width;
|
if (wantWidth != null) *wantWidth = wantW > 0 ? wantW : width;
|
||||||
if (wantHeight != null) *wantHeight = wantH;
|
if (wantHeight != null) *wantHeight = wantH;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,8 @@ internal sealed class ServerPackModel
|
||||||
/// is easy to find, not mixed in with the rest; until then the card and pages were sub-tabs of a
|
/// is easy to find, not mixed in with the rest; until then the card and pages were sub-tabs of a
|
||||||
/// shared "Server" section of the Mini Remote.
|
/// shared "Server" section of the Mini Remote.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string BuildSectionsJson(ServerPackInfo info, string pluginName, IReadOnlyList<ServerPage>? pages = null)
|
public static string BuildSectionsJson(ServerPackInfo info, string pluginName, IReadOnlyList<ServerPage>? pages = null,
|
||||||
|
IReadOnlyList<ServerWindow>? windows = null, bool frameless = false)
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder(512);
|
var sb = new StringBuilder(512);
|
||||||
sb.Append("{\"version\":1,\"servers\":[{\"id\":").Append(Q(info.Id)).Append(",\"name\":").Append(Q(info.Name));
|
sb.Append("{\"version\":1,\"servers\":[{\"id\":").Append(Q(info.Id)).Append(",\"name\":").Append(Q(info.Name));
|
||||||
|
|
@ -184,7 +185,10 @@ internal sealed class ServerPackModel
|
||||||
sb.Append(",\"icon\":").Append(Q(WindowIcon));
|
sb.Append(",\"icon\":").Append(Q(WindowIcon));
|
||||||
sb.Append(",\"width\":").Append(tabs ? ServerPackPages.Width : 460).Append(",\"height\":").Append(ServerPackPages.Height);
|
sb.Append(",\"width\":").Append(tabs ? ServerPackPages.Width : 460).Append(",\"height\":").Append(ServerPackPages.Height);
|
||||||
sb.Append(",\"minWidth\":320,\"minHeight\":200,\"bar\":true,\"server\":").Append(Q(info.Id));
|
sb.Append(",\"minWidth\":320,\"minHeight\":200,\"bar\":true,\"server\":").Append(Q(info.Id));
|
||||||
sb.Append("}]}");
|
sb.Append('}');
|
||||||
|
// The server's own windows (ServerWindows, ServerPackWindows.cs, 2026-11-07).
|
||||||
|
if (windows != null) sb.Append(ServerPackWindows.Json(windows, info.Id, frameless));
|
||||||
|
sb.Append("]}");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@
|
||||||
// ServerPages(list) pages of its own (ServerPackPages.cs): sub-tabs of the Mini Remote's
|
// ServerPages(list) pages of its own (ServerPackPages.cs): sub-tabs of the Mini Remote's
|
||||||
// Server section, only while its server is active, and tabs of the
|
// Server section, only while its server is active, and tabs of the
|
||||||
// /rserver window. Draw runs on the render thread.
|
// /rserver window. Draw runs on the render thread.
|
||||||
|
// ServerWindows(list) windows of its own on RynthCore's bar (ServerPackWindows.cs, 2026-11-07:
|
||||||
|
// RynthDreamWeave's Skills panel), only while its server is active;
|
||||||
|
// "frameless" ones draw their own frame (engines with v90 windows).
|
||||||
// ServerChatText(...) every incoming chat line (pump thread), to read the server's replies
|
// ServerChatText(...) every incoming chat line (pump thread), to read the server's replies
|
||||||
// and hide the ones answering the plugin's own requests (eat).
|
// and hide the ones answering the plugin's own requests (eat).
|
||||||
// ServerChatBar(text) every line sent through the chat bar (AC's thread: note it only),
|
// ServerChatBar(text) every line sent through the chat bar (AC's thread: note it only),
|
||||||
|
|
@ -66,9 +69,11 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
||||||
|
|
||||||
private readonly ServerPackModel _model;
|
private readonly ServerPackModel _model;
|
||||||
private readonly ServerPackUi _ui;
|
private readonly ServerPackUi _ui;
|
||||||
private readonly string _sectionsJson;
|
private string? _sectionsJson;
|
||||||
// The server's own pages (ServerPages), validated; what was left out is logged at Initialize.
|
// The server's own pages (ServerPages), validated; what was left out is logged at Initialize.
|
||||||
private readonly List<ServerPage> _pages;
|
private readonly List<ServerPage> _pages;
|
||||||
|
// The server's own windows (ServerWindows), validated the same way.
|
||||||
|
private readonly List<ServerWindow> _windows;
|
||||||
private readonly List<string> _pageNotes = new();
|
private readonly List<string> _pageNotes = new();
|
||||||
private readonly ServerPackSettings _settings = new(ServerPackSettings.DefaultPath(RynthPluginInfo.Name));
|
private readonly ServerPackSettings _settings = new(ServerPackSettings.DefaultPath(RynthPluginInfo.Name));
|
||||||
private readonly ServerProfileValues _profileValues = new();
|
private readonly ServerProfileValues _profileValues = new();
|
||||||
|
|
@ -91,11 +96,13 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
||||||
var pages = new List<ServerPage>();
|
var pages = new List<ServerPage>();
|
||||||
ServerPages(pages);
|
ServerPages(pages);
|
||||||
_pages = ServerPackPages.Validate(pages, _pageNotes.Add);
|
_pages = ServerPackPages.Validate(pages, _pageNotes.Add);
|
||||||
|
var windows = new List<ServerWindow>();
|
||||||
|
ServerWindows(windows);
|
||||||
|
_windows = ServerPackWindows.Validate(windows, _pageNotes.Add);
|
||||||
var verbs = new List<string>();
|
var verbs = new List<string>();
|
||||||
ServerCommandVerbs(verbs);
|
ServerCommandVerbs(verbs);
|
||||||
foreach (string v in verbs) if (!string.IsNullOrWhiteSpace(v)) _serverVerbs.Add(v.Trim());
|
foreach (string v in verbs) if (!string.IsNullOrWhiteSpace(v)) _serverVerbs.Add(v.Trim());
|
||||||
_ui = new ServerPackUi(_model, RynthPluginInfo.Name + " " + Marshal.PtrToStringAnsi(VersionPointer), () => _world, _pages);
|
_ui = new ServerPackUi(_model, RynthPluginInfo.Name + " " + Marshal.PtrToStringAnsi(VersionPointer), () => _world, _pages);
|
||||||
_sectionsJson = ServerPackModel.BuildSectionsJson(info, RynthPluginInfo.Name, _pages);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal ServerPackInfo Info => _model.Info;
|
internal ServerPackInfo Info => _model.Info;
|
||||||
|
|
@ -130,6 +137,15 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
||||||
partial void ServerInfoLines(Action<string> line);
|
partial void ServerInfoLines(Action<string> line);
|
||||||
/// <summary>The server's own pages (ServerPackPages.cs). Called once, from the constructor (no Host yet).</summary>
|
/// <summary>The server's own pages (ServerPackPages.cs). Called once, from the constructor (no Host yet).</summary>
|
||||||
partial void ServerPages(List<ServerPage> pages);
|
partial void ServerPages(List<ServerPage> pages);
|
||||||
|
/// <summary>The server's own windows on RynthCore's bar (ServerPackWindows.cs). Called once, from the constructor (no Host yet).</summary>
|
||||||
|
partial void ServerWindows(List<ServerWindow> windows);
|
||||||
|
/// <summary>Game event types (0xF7B0 events) the server's code wants on <see cref="ServerMessage"/>. Called once, at Initialize.</summary>
|
||||||
|
partial void ServerMessageInterest(List<uint> gameEvents);
|
||||||
|
/// <summary>A server message asked for in ServerMessageInterest (pump thread; <paramref name="body"/> is the bytes after
|
||||||
|
/// the opcode, valid only during the call: RynthCore.PluginSdk.Net.ServerMessage reads it).</summary>
|
||||||
|
partial void ServerMessage(uint opcode, ReadOnlySpan<byte> body);
|
||||||
|
/// <summary>Every frame while logged in (render thread, AC's main thread; the engine's ImGui context current).</summary>
|
||||||
|
partial void ServerRender();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An incoming chat line (pump thread, logged in only): set <paramref name="eat"/> to keep it out of
|
/// An incoming chat line (pump thread, logged in only): set <paramref name="eat"/> to keep it out of
|
||||||
/// the chat window (it comes in true when an earlier plugin already ate it).
|
/// the chat window (it comes in true when an earlier plugin already ate it).
|
||||||
|
|
@ -180,9 +196,20 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
||||||
_settings.Load();
|
_settings.Load();
|
||||||
if (_settings.LastError.Length > 0) LogTagged($"Settings ({_settings.FilePath}) not read: {_settings.LastError}; using defaults.");
|
if (_settings.LastError.Length > 0) LogTagged($"Settings ({_settings.FilePath}) not read: {_settings.LastError}; using defaults.");
|
||||||
ServerInitialize();
|
ServerInitialize();
|
||||||
|
// The server's own server-message wishes (ServerMessageInterest, 2026-11-07), streamed to ServerMessage.
|
||||||
|
var events = new List<uint>();
|
||||||
|
ServerMessageInterest(events);
|
||||||
|
if (events.Count > 0 && Host.HasServerMessages)
|
||||||
|
{
|
||||||
|
int r = Host.SetServerMessageInterest(ReadOnlySpan<uint>.Empty, events.ToArray());
|
||||||
|
if (r != 1) LogTagged($"Server messages not streamed (SetServerMessageInterest answered {r}).");
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>RynthPluginOnServerMessage (pump thread): a server message the server's code asked for.</summary>
|
||||||
|
internal void OnServerMessage(uint opcode, ReadOnlySpan<byte> body) => ServerMessage(opcode, body);
|
||||||
|
|
||||||
// Also called on a freshly (re)loaded plugin while already in game.
|
// Also called on a freshly (re)loaded plugin while already in game.
|
||||||
public override void OnLoginComplete()
|
public override void OnLoginComplete()
|
||||||
{
|
{
|
||||||
|
|
@ -251,18 +278,55 @@ public sealed partial class ServerPackPlugin : RynthPluginBase
|
||||||
/// (the manifest is static): the engine only collects it once in game, and keeping it across
|
/// (the manifest is static): the engine only collects it once in game, and keeping it across
|
||||||
/// logout and character switches stops the server dropping out of Options > Diagnostics.
|
/// logout and character switches stops the server dropping out of Options > Diagnostics.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal string? BuildSectionsJson() => _sectionsJson;
|
internal string? BuildSectionsJson()
|
||||||
|
=> _sectionsJson ??= ServerPackModel.BuildSectionsJson(Info, RynthPluginInfo.Name, _pages, _windows,
|
||||||
|
frameless: _windows.Count > 0 && Host.HasFramelessWindows);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// RynthPluginRenderEmbed "window:<id>": one of the server's own windows (ServerWindows), into the
|
||||||
|
/// host's window. False for an id this plugin doesn't have, or before login. Render thread.
|
||||||
|
/// </summary>
|
||||||
|
internal bool RenderServerWindow(string id, bool popped, out float wantHeight, out float wantWidth)
|
||||||
|
{
|
||||||
|
wantHeight = 0;
|
||||||
|
wantWidth = 0;
|
||||||
|
ServerWindow? window = _windows.Find(w => w.Id == id);
|
||||||
|
if (window == null || !_loginComplete) return false;
|
||||||
|
IntPtr previous = ImGui.GetCurrentContext();
|
||||||
|
IntPtr context = previous != IntPtr.Zero ? previous : Host.ImGuiContext;
|
||||||
|
if (context == IntPtr.Zero) return false;
|
||||||
|
ImGui.SetCurrentContext(context);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
System.Numerics.Vector2 want = window.Draw(popped);
|
||||||
|
wantHeight = want.Y;
|
||||||
|
wantWidth = want.X;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Host.Log($"[{RynthPluginInfo.Name}] Window {window.Title} failed: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
finally { ImGui.SetCurrentContext(previous); }
|
||||||
|
}
|
||||||
|
|
||||||
// ── Drawing ──────────────────────────────────────────────────────────
|
// ── Drawing ──────────────────────────────────────────────────────────
|
||||||
|
|
||||||
/// <summary>The standalone card window. Render thread.</summary>
|
/// <summary>The standalone card window. Render thread.</summary>
|
||||||
public override void OnRender()
|
public override void OnRender()
|
||||||
{
|
{
|
||||||
if (!_loginComplete || !_ui.WindowOpen || Host.ImGuiContext == IntPtr.Zero) return;
|
if (!_loginComplete || Host.ImGuiContext == IntPtr.Zero) return;
|
||||||
IntPtr previous = ImGui.GetCurrentContext();
|
IntPtr previous = ImGui.GetCurrentContext();
|
||||||
ImGui.SetCurrentContext(Host.ImGuiContext);
|
ImGui.SetCurrentContext(Host.ImGuiContext);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try { ServerRender(); }
|
||||||
|
catch (Exception ex) { LogTagged($"Render hook failed: {ex.GetType().Name}: {ex.Message}"); }
|
||||||
|
if (!_ui.WindowOpen) return;
|
||||||
try { _ui.RenderWindow(); }
|
try { _ui.RenderWindow(); }
|
||||||
catch (Exception ex) { Host.Log($"[{RynthPluginInfo.Name}] Server window failed: {ex.Message}"); _ui.WindowOpen = false; }
|
catch (Exception ex) { Host.Log($"[{RynthPluginInfo.Name}] Server window failed: {ex.Message}"); _ui.WindowOpen = false; }
|
||||||
|
}
|
||||||
finally { ImGui.SetCurrentContext(previous); }
|
finally { ImGui.SetCurrentContext(previous); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
81
Plugins/Shared/ServerPack/ServerPackWindows.cs
Normal file
81
Plugins/Shared/ServerPack/ServerPackWindows.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
// ServerPackWindows.cs - Windows of its own a server plugin adds to RynthCore's bar, beside the server's
|
||||||
|
// window (2026-11-07: RynthDreamWeave's Skills panel, the retail Character panel drawn by the plugin).
|
||||||
|
//
|
||||||
|
// The ServerPackPlugin.ServerWindows hook lists them once, at construction. Each is declared in the
|
||||||
|
// sections manifest's "windows" (plugin windows, API v89; "chrome": "none" for one that draws its own
|
||||||
|
// frame, v90), only while the server is active, and drawn through RynthPluginRenderEmbed "window:<id>"
|
||||||
|
// on the render thread. A frameless window is declared only on engines with frameless windows (an older
|
||||||
|
// engine would wrap it in its own frame), so it simply isn't there on those.
|
||||||
|
// Pure (no ImGui, no host calls): RynthServerPack.Tests covers it.
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace RynthCore.Plugin.ServerPack;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// One window a server plugin adds. <paramref name="Id"/> is 1-16 of a-z, 0-9 and '-' (its surface is
|
||||||
|
/// "window:<id>"); <paramref name="Title"/> is its panel key (bar tooltip, saved place, /rc commands).
|
||||||
|
/// <paramref name="Draw"/> draws the body (popped out or not) and returns the size it wants: the height it used and, for a window that sizes its width too, that width (0: the width it was given). Render thread.
|
||||||
|
/// </summary>
|
||||||
|
internal sealed record ServerWindow(string Id, string Title, string Icon, int Width, int Height, int MinWidth, int MinHeight,
|
||||||
|
bool Frameless, Func<bool, System.Numerics.Vector2> Draw, bool FitHeight = false, bool UnderUi = false, bool DrawScale = false);
|
||||||
|
|
||||||
|
internal static class ServerPackWindows
|
||||||
|
{
|
||||||
|
/// <summary>At most this many windows besides the server's own.</summary>
|
||||||
|
public const int MaxWindows = 3;
|
||||||
|
|
||||||
|
public static string SurfaceFor(string id) => "window:" + id;
|
||||||
|
|
||||||
|
/// <summary>The window id a surface names ("window:skills" -> "skills"), or null. ":popout" is the caller's to strip.</summary>
|
||||||
|
public static string? IdOf(string? surface)
|
||||||
|
{
|
||||||
|
if (surface == null || !surface.StartsWith("window:", StringComparison.Ordinal)) return null;
|
||||||
|
string id = surface["window:".Length..];
|
||||||
|
return ServerPackPages.IsValidId(id) && id != ServerPackModel.WindowId ? id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The windows that can be declared: a valid id that isn't the server window's, a title, each id once.</summary>
|
||||||
|
public static List<ServerWindow> Validate(List<ServerWindow> windows, Action<string> note)
|
||||||
|
{
|
||||||
|
var ok = new List<ServerWindow>();
|
||||||
|
var ids = new HashSet<string>(StringComparer.Ordinal);
|
||||||
|
foreach (ServerWindow w in windows)
|
||||||
|
{
|
||||||
|
if (w == null) continue;
|
||||||
|
if (!ServerPackPages.IsValidId(w.Id) || w.Id == ServerPackModel.WindowId) { note($"Window \"{w.Id}\" left out: its id must be 1-16 of a-z, 0-9 and '-', not \"server\"."); continue; }
|
||||||
|
if (string.IsNullOrWhiteSpace(w.Title)) { note($"Window \"{w.Id}\" left out: it has no title."); continue; }
|
||||||
|
if (!ids.Add(w.Id)) { note($"Window \"{w.Id}\" left out: the id is used twice."); continue; }
|
||||||
|
if (ok.Count >= MaxWindows) { note($"Window \"{w.Id}\" left out: at most {MaxWindows} windows."); continue; }
|
||||||
|
ok.Add(w);
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The manifest entries (",{...}" each) for <paramref name="windows"/>; frameless ones only when <paramref name="frameless"/>.</summary>
|
||||||
|
public static string Json(IReadOnlyList<ServerWindow> windows, string serverId, bool frameless)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
foreach (ServerWindow w in windows)
|
||||||
|
{
|
||||||
|
if (w.Frameless && !frameless) continue;
|
||||||
|
sb.Append(",{\"id\":").Append(ServerPackModel.Q(w.Id));
|
||||||
|
sb.Append(",\"title\":").Append(ServerPackModel.Q(w.Title.Trim()));
|
||||||
|
sb.Append(",\"surface\":").Append(ServerPackModel.Q(SurfaceFor(w.Id)));
|
||||||
|
sb.Append(",\"icon\":").Append(ServerPackModel.Q(w.Icon));
|
||||||
|
sb.Append(",\"width\":").Append(w.Width).Append(",\"height\":").Append(w.Height);
|
||||||
|
sb.Append(",\"minWidth\":").Append(w.MinWidth).Append(",\"minHeight\":").Append(w.MinHeight);
|
||||||
|
sb.Append(",\"bar\":true,\"server\":").Append(ServerPackModel.Q(serverId));
|
||||||
|
if (w.Frameless) sb.Append(",\"chrome\":\"none\"");
|
||||||
|
// The window is as tall as the height the draw reports (the plugin sizes it itself, v90).
|
||||||
|
if (w.FitHeight && w.Frameless) sb.Append(",\"fitHeight\":true");
|
||||||
|
// Drawn under AC's own UI, like a native AC window (engines from 2026-11-07; older ones ignore it).
|
||||||
|
if (w.UnderUi && w.Frameless) sb.Append(",\"layer\":\"underUi\"");
|
||||||
|
// It draws itself at any size: Ctrl+wheel steps its own draw size (PanelScale, 30-250%), not its text.
|
||||||
|
if (w.DrawScale && w.Frameless) sb.Append(",\"scale\":\"draw\"");
|
||||||
|
sb.Append('}');
|
||||||
|
}
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -49,6 +49,8 @@
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ServerPackModel.cs" Link="ServerPack\ServerPackModel.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)ServerPackModel.cs" Link="ServerPack\ServerPackModel.cs" />
|
||||||
<!-- The server's own pages, settings file, reply window and Refresh row (ServerPackPlugin.cs lists the hooks). -->
|
<!-- The server's own pages, settings file, reply window and Refresh row (ServerPackPlugin.cs lists the hooks). -->
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ServerPackPages.cs" Link="ServerPack\ServerPackPages.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)ServerPackPages.cs" Link="ServerPack\ServerPackPages.cs" />
|
||||||
|
<!-- Windows of its own on RynthCore's bar (ServerWindows, 2026-11-07). -->
|
||||||
|
<Compile Include="$(MSBuildThisFileDirectory)ServerPackWindows.cs" Link="ServerPack\ServerPackWindows.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ServerPackSettings.cs" Link="ServerPack\ServerPackSettings.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)ServerPackSettings.cs" Link="ServerPack\ServerPackSettings.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ServerChatRequest.cs" Link="ServerPack\ServerChatRequest.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)ServerChatRequest.cs" Link="ServerPack\ServerChatRequest.cs" />
|
||||||
<Compile Include="$(MSBuildThisFileDirectory)ServerPackRefresh.cs" Link="ServerPack\ServerPackRefresh.cs" />
|
<Compile Include="$(MSBuildThisFileDirectory)ServerPackRefresh.cs" Link="ServerPack\ServerPackRefresh.cs" />
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Plugins for particular Asheron's Call emulator servers, for [RynthCore](https://
|
||||||
| RynthILT | Infinite Leaftide (pets, Vaulted Dungeons, T11, banking, Dynamic Stamps, ...) |
|
| RynthILT | Infinite Leaftide (pets, Vaulted Dungeons, T11, banking, Dynamic Stamps, ...) |
|
||||||
| RynthThreads | DreamWeave's Threads |
|
| RynthThreads | DreamWeave's Threads |
|
||||||
| RynthAelrynth, RynthConquest, RynthLevistras | their server's card, quest pack and own pages |
|
| RynthAelrynth, RynthConquest, RynthLevistras | their server's card, quest pack and own pages |
|
||||||
| RynthAChard, RynthColdeve, RynthDerptide, RynthDreamWeave, RynthEversong, RynthFrostACE, RynthFrostcull, RynthLeafDawn, RynthLeafdawning, RynthPortalStorm, RynthReefcull, RynthSundering, RynthThistlecrown | their server's card in the Mini Remote |
|
| RynthAChard, RynthColdeve, RynthDerptide, RynthDreamWeave, RynthEversong, RynthFrostACE, RynthFrostcull, RynthLeafDawn, RynthLeafdawning, RynthPortalStorm, RynthReefcull, RynthSundering, RynthThistlecrown | their server's card in its own window on the RynthCore bar |
|
||||||
|
|
||||||
The shared server-plugin build is `Plugins/Shared/ServerPack`.
|
The shared server-plugin build is `Plugins/Shared/ServerPack`.
|
||||||
|
|
||||||
|
|
|
||||||
336
Tools/RetailDataGen/gen_retail_data.py
Normal file
336
Tools/RetailDataGen/gen_retail_data.py
Normal file
|
|
@ -0,0 +1,336 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Writes RynthDreamWeave's DreamWeave/RetailData.g.cs from a retail client_portal.dat.
|
||||||
|
|
||||||
|
The DreamWeave Skills panel draws the retail Character panel's Skills page 1:1, so it carries the
|
||||||
|
numbers and glyph tables the retail client reads from portal.dat:
|
||||||
|
|
||||||
|
0x0E000018 XpTable the level chart (total XP for levels 0..275) and the skill-credit levels
|
||||||
|
0x0E000004 SkillTable each skill's name, icon, whether it is usable untrained (MinLevel 1), its
|
||||||
|
formula and description (the hover tooltip)
|
||||||
|
0x2300000E (local dat) the character titles, keyed by AC's string hash of "ID_CharacterTitle_<name>"
|
||||||
|
0x400000xx Font the glyph tables of the five faces the page uses (Palatino_Linotype_14/16/18,
|
||||||
|
Chat_PalatinoLinotype_Large = 20, Stonehenge_36), ASCII and Latin-1 only;
|
||||||
|
the engine draws their glyph sheets (GetIconTexture kind FontSheet)
|
||||||
|
|
||||||
|
Run it again only if the dat changes (it hasn't since end of retail):
|
||||||
|
|
||||||
|
python gen_retail_data.py [client_portal.dat] [client_local_English.dat] [ACE CharacterTitle.cs] >..\\..\\Plugins\\RynthCore.Plugin.RynthDreamWeave\\DreamWeave\\RetailData.g.cs
|
||||||
|
|
||||||
|
No dependencies; the dat reader is the minimal B-tree walk the AC dat format needs.
|
||||||
|
"""
|
||||||
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
|
PORTAL = sys.argv[1] if len(sys.argv) > 1 else r"C:\Games\ACE\Dats\client_portal.dat"
|
||||||
|
LOCAL = sys.argv[2] if len(sys.argv) > 2 else r"C:\Games\ACE\Dats\client_local_English.dat"
|
||||||
|
# The CharacterTitle names (ACE.Entity/Enum/CharacterTitle.cs of any ACE checkout): only the names are read.
|
||||||
|
ENUM = sys.argv[3] if len(sys.argv) > 3 else r"C:\Projects\_dwsrc\ACE-DreamWeave\Source\ACE.Entity\Enum\CharacterTitle.cs"
|
||||||
|
|
||||||
|
|
||||||
|
def cs(s):
|
||||||
|
"""A C# string literal."""
|
||||||
|
return '"' + s.replace('\\', '\\\\').replace('"', '\\"').replace('\n', '\\n').replace('\r', '') + '"'
|
||||||
|
|
||||||
|
HDR = 0x140
|
||||||
|
BRANCHES = 0x3E
|
||||||
|
MAX_ENTRIES = 0x3D
|
||||||
|
ENTRY_SIZE = 24
|
||||||
|
|
||||||
|
|
||||||
|
class Dat:
|
||||||
|
def __init__(self, path):
|
||||||
|
self.f = open(path, 'rb')
|
||||||
|
self.f.seek(HDR)
|
||||||
|
(_ft, self.block_size, _fs, _ds, _dss, _fh, _ftl, _fc, self.root) = struct.unpack('<9I', self.f.read(36))
|
||||||
|
self.entries = {}
|
||||||
|
self._walk(self.root)
|
||||||
|
|
||||||
|
def _chain(self, offset, size):
|
||||||
|
out = bytearray()
|
||||||
|
nxt = offset
|
||||||
|
while len(out) < size and nxt:
|
||||||
|
self.f.seek(nxt)
|
||||||
|
n = struct.unpack('<I', self.f.read(4))[0] & 0x7FFFFFFF
|
||||||
|
out += self.f.read(min(self.block_size - 4, size - len(out)))
|
||||||
|
nxt = n
|
||||||
|
return bytes(out[:size])
|
||||||
|
|
||||||
|
def _walk(self, offset):
|
||||||
|
node = self._chain(offset, 4 * BRANCHES + 4 + ENTRY_SIZE * MAX_ENTRIES)
|
||||||
|
branches = struct.unpack_from('<%dI' % BRANCHES, node, 0)
|
||||||
|
count = struct.unpack_from('<I', node, 4 * BRANCHES)[0]
|
||||||
|
for i in range(count):
|
||||||
|
_flags, did, off, size, _date, _it = struct.unpack_from('<6I', node, 4 * BRANCHES + 4 + i * ENTRY_SIZE)
|
||||||
|
self.entries[did] = (off, size)
|
||||||
|
if branches[0] != 0:
|
||||||
|
for i in range(count + 1):
|
||||||
|
self._walk(branches[i])
|
||||||
|
|
||||||
|
def read(self, did):
|
||||||
|
off, size = self.entries[did]
|
||||||
|
return self._chain(off, size)
|
||||||
|
|
||||||
|
|
||||||
|
def xp_table(dat):
|
||||||
|
b = dat.read(0x0E000018)
|
||||||
|
o = 4
|
||||||
|
a, v, t, s, levels = struct.unpack_from('<iiiiI', b, o)
|
||||||
|
o += 20 + 4 * (a + 1 + v + 1 + t + 1 + s + 1)
|
||||||
|
attrs = list(struct.unpack_from('<%dI' % (a + 1), b, 4 + 20))
|
||||||
|
vitals = list(struct.unpack_from('<%dI' % (v + 1), b, 4 + 20 + 4 * (a + 1)))
|
||||||
|
o0 = 4 + 20 + 4 * (a + 1 + v + 1)
|
||||||
|
trained = list(struct.unpack_from('<%dI' % (t + 1), b, o0))
|
||||||
|
special = list(struct.unpack_from('<%dI' % (s + 1), b, o0 + 4 * (t + 1)))
|
||||||
|
totals = list(struct.unpack_from('<%dQ' % (levels + 1), b, o))
|
||||||
|
o += 8 * (levels + 1)
|
||||||
|
credits = list(struct.unpack_from('<%dI' % (levels + 1), b, o))
|
||||||
|
return totals, credits, trained, special, attrs, vitals
|
||||||
|
|
||||||
|
|
||||||
|
def skill_table(dat):
|
||||||
|
b = dat.read(0x0E000004)
|
||||||
|
o = 4
|
||||||
|
count = struct.unpack_from('<H', b, o)[0]
|
||||||
|
o += 4
|
||||||
|
|
||||||
|
def pstring():
|
||||||
|
nonlocal o
|
||||||
|
n = struct.unpack_from('<H', b, o)[0]
|
||||||
|
o += 2
|
||||||
|
text = b[o:o + n].decode('latin-1')
|
||||||
|
o += n
|
||||||
|
o = (o + 3) & ~3
|
||||||
|
return text
|
||||||
|
|
||||||
|
rows = []
|
||||||
|
for _ in range(count):
|
||||||
|
sid = struct.unpack_from('<I', b, o)[0]
|
||||||
|
o += 4
|
||||||
|
desc = pstring()
|
||||||
|
name = pstring()
|
||||||
|
icon, _tc, _sc, _cat, _cg, min_level = struct.unpack_from('<IiiIII', b, o)
|
||||||
|
o += 24
|
||||||
|
# SkillFormula W X Y Z Attr1 Attr2: X = 0 means no attribute part; Z divides.
|
||||||
|
_w, fx, _y, fz, a1, a2 = struct.unpack_from('<6I', b, o)
|
||||||
|
o += 24 + 24 # the formula, three doubles
|
||||||
|
rows.append((sid, name, icon, min_level == 1, desc, fx, fz, a1, a2))
|
||||||
|
return sorted(rows)
|
||||||
|
|
||||||
|
|
||||||
|
ATTR = {1: 'Strength', 2: 'Endurance', 3: 'Quickness', 4: 'Coordination', 5: 'Focus', 6: 'Self'}
|
||||||
|
|
||||||
|
|
||||||
|
def formula(fx, fz, a1, a2):
|
||||||
|
"""The tooltip's first line as retail writes it: "( Focus + Self ) / 4"."""
|
||||||
|
if fx == 0 or a1 not in ATTR:
|
||||||
|
return ''
|
||||||
|
text = '( ' + ATTR[a1] + (' + ' + ATTR[a2] if a2 in ATTR else '') + ' )'
|
||||||
|
return text + (' / %d' % fz if fz > 1 else '')
|
||||||
|
|
||||||
|
|
||||||
|
def ac_hash(s):
|
||||||
|
"""AC's string-id hash (PStringBase): what string table entries are keyed by."""
|
||||||
|
h = 0
|
||||||
|
for ch in s:
|
||||||
|
h = ((h << 4) + ord(ch)) & 0xFFFFFFFF
|
||||||
|
hi = h & 0xF0000000
|
||||||
|
if hi:
|
||||||
|
h ^= hi >> 24
|
||||||
|
h &= 0x0FFFFFFF
|
||||||
|
return h
|
||||||
|
|
||||||
|
|
||||||
|
def string_table(dat, fid):
|
||||||
|
"""A type-0x23 string table: id -> first string (AcClientReborn Dat/AcStringTable.cs has the format)."""
|
||||||
|
b = dat.read(fid)
|
||||||
|
o = [9]
|
||||||
|
|
||||||
|
def cu32():
|
||||||
|
b0 = b[o[0]]
|
||||||
|
if not b0 & 0x80:
|
||||||
|
o[0] += 1
|
||||||
|
return b0
|
||||||
|
if not b0 & 0x40:
|
||||||
|
v = struct.unpack_from('>H', b, o[0])[0] & 0x3FFF
|
||||||
|
o[0] += 2
|
||||||
|
return v
|
||||||
|
v = struct.unpack_from('>I', b, o[0])[0] & 0x3FFFFFFF
|
||||||
|
o[0] += 4
|
||||||
|
return v
|
||||||
|
|
||||||
|
def ustr():
|
||||||
|
n = cu32()
|
||||||
|
s = b[o[0]:o[0] + 2 * n].decode('utf-16-le', 'replace')
|
||||||
|
o[0] += 2 * n
|
||||||
|
return s
|
||||||
|
|
||||||
|
def u16():
|
||||||
|
v = struct.unpack_from('<H', b, o[0])[0]
|
||||||
|
o[0] += 2
|
||||||
|
return v
|
||||||
|
|
||||||
|
def u32():
|
||||||
|
v = struct.unpack_from('<I', b, o[0])[0]
|
||||||
|
o[0] += 4
|
||||||
|
return v
|
||||||
|
|
||||||
|
out = {}
|
||||||
|
for _ in range(cu32()):
|
||||||
|
sid = u32()
|
||||||
|
for _ in range(u16()):
|
||||||
|
ustr()
|
||||||
|
for _ in range(u16()):
|
||||||
|
ustr()
|
||||||
|
strings = [ustr() for _ in range(u32())]
|
||||||
|
for _ in range(u32()):
|
||||||
|
u32()
|
||||||
|
o[0] += 1
|
||||||
|
out[sid] = strings[0] if strings else ''
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def enum_names(path):
|
||||||
|
"""CharacterTitle's members in order (a C# enum: "Name," or "Name = n,"), id -> name."""
|
||||||
|
import re
|
||||||
|
names, n, inside = {}, 0, False
|
||||||
|
for line in open(path, encoding='utf-8'):
|
||||||
|
line = line.split('//')[0].strip()
|
||||||
|
if line.startswith('public enum'):
|
||||||
|
inside = True
|
||||||
|
continue
|
||||||
|
if not inside or not line or line in ('{',):
|
||||||
|
continue
|
||||||
|
if line.startswith('}'):
|
||||||
|
break
|
||||||
|
m = re.match(r'^(\w+)\s*(?:=\s*(\w+))?\s*,?$', line)
|
||||||
|
if not m:
|
||||||
|
continue
|
||||||
|
if m.group(2):
|
||||||
|
n = int(m.group(2), 0)
|
||||||
|
names[n] = m.group(1)
|
||||||
|
n += 1
|
||||||
|
return names
|
||||||
|
|
||||||
|
|
||||||
|
def titles(local, enum_path):
|
||||||
|
"""CharacterTitleId -> the title's text, from string table 0x2300000E keyed by
|
||||||
|
hash("ID_CharacterTitle_" + its original name). The names come from ACE's CharacterTitle enum
|
||||||
|
(names only, no code), whose spellings drop the original's underscores: each is tried as written,
|
||||||
|
then with underscores between its words, then matched by its letters alone."""
|
||||||
|
import re
|
||||||
|
table = string_table(local, 0x2300000E)
|
||||||
|
by_letters = {}
|
||||||
|
for text in table.values():
|
||||||
|
by_letters.setdefault(re.sub(r'[^a-z0-9]', '', text.lower()), []).append(text)
|
||||||
|
out, missing = {}, []
|
||||||
|
for tid, name in sorted(enum_names(enum_path).items()):
|
||||||
|
if tid == 0 or name.upper().startswith('UNKNOWN'):
|
||||||
|
continue
|
||||||
|
words = re.sub(r'(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])', '_', name)
|
||||||
|
text = None
|
||||||
|
for cand in (name, words):
|
||||||
|
k = ac_hash('ID_CharacterTitle_' + cand)
|
||||||
|
if k in table:
|
||||||
|
text = table[k]
|
||||||
|
break
|
||||||
|
if text is None:
|
||||||
|
hits = by_letters.get(re.sub(r'[^a-z0-9]', '', name.lower()), [])
|
||||||
|
if len(hits) == 1:
|
||||||
|
text = hits[0]
|
||||||
|
if text is None:
|
||||||
|
missing.append(name)
|
||||||
|
else:
|
||||||
|
out[tid] = text
|
||||||
|
sys.stderr.write('titles: %d named, %d not found (%s)\n' % (len(out), len(missing), ', '.join(missing[:12])))
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
FONTS = [
|
||||||
|
('Pal14', 0x40000002, False),
|
||||||
|
('Pal16', 0x40000000, False),
|
||||||
|
('Pal18', 0x40000001, False),
|
||||||
|
('Pal20', 0x40000004, False),
|
||||||
|
('Stone36', 0x40000010, True),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def font(dat, did):
|
||||||
|
b = dat.read(did)
|
||||||
|
o = 4
|
||||||
|
max_h, _max_w, n = struct.unpack_from('<III', b, o)
|
||||||
|
o += 12
|
||||||
|
glyphs = {}
|
||||||
|
for _ in range(n):
|
||||||
|
u, ox, oy, w, h, hb, ha, vb = struct.unpack_from('<HHHBBbbb', b, o)
|
||||||
|
o += 11
|
||||||
|
glyphs[u] = (ox, oy, w, h, hb, ha, vb)
|
||||||
|
bx, by, base, fg, bg = struct.unpack_from('<IIIII', b, o)
|
||||||
|
sheets = []
|
||||||
|
for sid in (fg, bg):
|
||||||
|
if sid:
|
||||||
|
t = dat.read(sid)
|
||||||
|
sheets.append(struct.unpack_from('<ii', t, 8))
|
||||||
|
else:
|
||||||
|
sheets.append((0, 0))
|
||||||
|
return max_h, bx, by, base, fg, bg, sheets, glyphs
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
dat = Dat(PORTAL)
|
||||||
|
totals, credits, trained, special, attrs, vitals = xp_table(dat)
|
||||||
|
skills = skill_table(dat)
|
||||||
|
w = sys.stdout.write
|
||||||
|
w('// <auto-generated> by Tools/RetailDataGen/gen_retail_data.py from a retail client_portal.dat.\n')
|
||||||
|
w('// The numbers the retail client reads to draw its Character panel: do not edit by hand.\n')
|
||||||
|
w('namespace RynthCore.Plugin.RynthDreamWeave;\n\n')
|
||||||
|
w('internal static partial class RetailData\n{\n')
|
||||||
|
w(' /// <summary>XpTable 0x0E000018: total experience to reach each level, 0..%d.</summary>\n' % (len(totals) - 1))
|
||||||
|
w(' public static readonly ulong[] LevelTotals =\n {\n')
|
||||||
|
for i in range(0, len(totals), 6):
|
||||||
|
w(' ' + ', '.join('%dUL' % v for v in totals[i:i + 6]) + ',\n')
|
||||||
|
w(' };\n\n')
|
||||||
|
w(' /// <summary>XpTable 0x0E000018: skill credits granted on reaching each level, 0..%d.</summary>\n' % (len(credits) - 1))
|
||||||
|
w(' public static readonly byte[] LevelCredits =\n {\n')
|
||||||
|
for i in range(0, len(credits), 30):
|
||||||
|
w(' ' + ', '.join(str(v) for v in credits[i:i + 30]) + ',\n')
|
||||||
|
w(' };\n\n')
|
||||||
|
for field, chart, what in (('TrainedSkillXp', trained, 'a trained skill'), ('SpecializedSkillXp', special, 'a specialized skill'),
|
||||||
|
('AttributeXp', attrs, 'an attribute'), ('VitalXp', vitals, 'a vital\'s maximum')):
|
||||||
|
w(' /// <summary>XpTable 0x0E000018: total XP to reach each rank of %s, 0..%d.</summary>\n'
|
||||||
|
% (what, len(chart) - 1))
|
||||||
|
w(' public static readonly uint[] %s =\n {\n' % field)
|
||||||
|
for i in range(0, len(chart), 8):
|
||||||
|
w(' ' + ', '.join('%dU' % v for v in chart[i:i + 8]) + ',\n')
|
||||||
|
w(' };\n\n')
|
||||||
|
w(' /// <summary>SkillTable 0x0E000004: id, name, icon, usable untrained (MinLevel 1), and the hover\n')
|
||||||
|
w(' /// tooltip\'s formula line and description.</summary>\n')
|
||||||
|
w(' public static readonly RetailSkill[] Skills =\n {\n')
|
||||||
|
for sid, name, icon, usable, desc, fx, fz, a1, a2 in skills:
|
||||||
|
w(' new(%d, %s, 0x%08Xu, %s, %s, %s),\n' % (sid, cs(name), icon, 'true' if usable else 'false',
|
||||||
|
cs(formula(fx, fz, a1, a2)), cs(desc)))
|
||||||
|
w(' };\n\n')
|
||||||
|
names = titles(Dat(LOCAL), ENUM)
|
||||||
|
w(' /// <summary>String table 0x2300000E: CharacterTitleId -> the title (the header\'s second line).</summary>\n')
|
||||||
|
w(' public static readonly System.Collections.Generic.Dictionary<int, string> Titles = new()\n {\n')
|
||||||
|
for tid, text in sorted(names.items()):
|
||||||
|
w(' [%d] = %s,\n' % (tid, cs(text)))
|
||||||
|
w(' };\n\n')
|
||||||
|
for field, did, outline in FONTS:
|
||||||
|
max_h, bx, by, base, fg, bg, sheets, glyphs = font(dat, did)
|
||||||
|
chars = [c for c in sorted(glyphs) if 0x20 <= c <= 0x7E or 0xA0 <= c <= 0xFF]
|
||||||
|
w(' /// <summary>Font 0x%08X: glyphs as char, sheet x, y, w, h, before, after, top.</summary>\n' % did)
|
||||||
|
w(' public static readonly RetailFont %s = new(0x%08Xu, %d, %d, %d, %d, 0x%08Xu, %d, %d, 0x%08Xu, %d, %d, new short[]\n {\n'
|
||||||
|
% (field, did, max_h, base, bx, by, fg, sheets[0][0], sheets[0][1], bg if outline else 0,
|
||||||
|
sheets[1][0] if outline else 0, sheets[1][1] if outline else 0))
|
||||||
|
for i in range(0, len(chars), 4):
|
||||||
|
parts = []
|
||||||
|
for c in chars[i:i + 4]:
|
||||||
|
ox, oy, gw, gh, hb, ha, vb = glyphs[c]
|
||||||
|
parts.append('%d,%d,%d,%d,%d,%d,%d,%d' % (c, ox, oy, gw, gh, hb, ha, vb))
|
||||||
|
w(' ' + ', '.join(parts) + ',\n')
|
||||||
|
w(' });\n\n')
|
||||||
|
w('}\n')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
315
Tools/RynthServerPack.Tests/DreamWeaveSkillsTests.cs
Normal file
315
Tools/RynthServerPack.Tests/DreamWeaveSkillsTests.cs
Normal file
|
|
@ -0,0 +1,315 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using RynthCore.Engine.UI.Sections;
|
||||||
|
using RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
using RynthCore.Plugin.ServerPack;
|
||||||
|
using RynthCore.RynthAiTests.Harness;
|
||||||
|
|
||||||
|
namespace RynthServerPack.Tests;
|
||||||
|
|
||||||
|
// RynthDreamWeave's Skills panel (2026-11-07): DreamWeave's level chart past 275 (the reason for the panel:
|
||||||
|
// AC's own panel reads a negative "XP for next level" there), the retail data it carries, the list's
|
||||||
|
// sections and footer, and the shared ServerWindows hook it is declared through.
|
||||||
|
internal static class DreamWeaveSkillsTests
|
||||||
|
{
|
||||||
|
public static void Register(Runner r)
|
||||||
|
{
|
||||||
|
r.Add("dreamweave skills: the retail chart is portal.dat's, levels 0..275", RetailChart);
|
||||||
|
r.Add("dreamweave skills: the chart past 275 follows the server's rule", ExtendedChart);
|
||||||
|
r.Add("dreamweave skills: XP for next level past 275 (the reported level-344 character)", NextLevelPast275);
|
||||||
|
r.Add("dreamweave skills: XP for next level at the edges", NextLevelEdges);
|
||||||
|
r.Add("dreamweave skills: sections, order and what shows in each", Sections);
|
||||||
|
r.Add("dreamweave skills: the footer reads as retail's", Footer);
|
||||||
|
r.Add("dreamweave skills: raise arrows only when affordable", RaiseGates);
|
||||||
|
r.Add("dreamweave skills: header words (rank title, character title)", Header);
|
||||||
|
r.Add("dreamweave skills: the XP bar fills with the way through the level", LevelBar);
|
||||||
|
r.Add("dreamweave skills: tooltips (formula, description, wrapped as retail)", Tooltips);
|
||||||
|
r.Add("dreamweave skills: fonts and skill table", RetailTables);
|
||||||
|
r.Add("hooks: server windows are validated and declared frameless only when the engine can", Windows);
|
||||||
|
r.Add("dreamweave skills: the Attributes page (rows, values, footer, bar)", Attributes);
|
||||||
|
r.Add("dreamweave skills: the Titles page (the server's list, updates, saving)", Titles);
|
||||||
|
r.Add("dreamweave skills: one main panel at a time, as retail", OnePanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Attributes()
|
||||||
|
{
|
||||||
|
Check.Eq(string.Join(",", AttributesPage.Rows.Select(r => r.Name)), "Strength,Endurance,Coordination,Quickness,Focus,Self,Health,Stamina,Mana", "retail's order");
|
||||||
|
var str = new AttributeLine(1, 1, "Strength", 0, 200, 250, 1000, 12000, true, false, 50, RetailData.AttributeXp[50] + (RetailData.AttributeXp[51] - RetailData.AttributeXp[50]) / 2);
|
||||||
|
Check.Eq(str.ValueText, "250", "an attribute shows its buffed value");
|
||||||
|
Check.Eq(AttributesPage.FooterTitle(str), ("Strength: 250", " (+50)"), "footer title");
|
||||||
|
Check.Eq(AttributesPage.FooterTitle(null).Text, "Select an Attribute to Improve", "retail's prompt");
|
||||||
|
var sheet = SkillsSheet.Empty with { UnassignedXp = 5000, SkillCredits = 2 };
|
||||||
|
Check.Eq(AttributesPage.FooterLines(sheet, str).One, ("Experience To Raise:", "1,000"), "cost");
|
||||||
|
Check.Eq(AttributesPage.FooterLines(sheet, null).One, ("Skill Credits Available:", "2"), "nothing selected");
|
||||||
|
Check.True(AttributesPage.CanRaiseOne(sheet, str) && !AttributesPage.CanRaiseTen(sheet, str), "one affordable, ten not");
|
||||||
|
Check.Near(AttributesPage.RankProgress(str), 0.5, 0.01, "half way through rank 50");
|
||||||
|
var health = new AttributeLine(2, 1, "Health", 0, 300, 350, -1, -1, false, true, 196, 0, Current: 280);
|
||||||
|
Check.Eq(health.ValueText, "280/350", "a vital shows current/maximum, as retail");
|
||||||
|
Check.Eq(AttributesPage.FooterLines(sheet, health).One, ("Experience To Raise:", "Infinity!"), "at the top");
|
||||||
|
Check.Eq(AttributesPage.RankProgress(health), 0f, "the last rank: empty");
|
||||||
|
Check.True(AttributesPage.Tip(health).StartsWith("(Endurance/2)"), "health's hover text");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Titles()
|
||||||
|
{
|
||||||
|
// Game event 0x0029: u32 1, u32 displayed (433), u32 count (3), ids 1, 433, 7.
|
||||||
|
byte[] table = new byte[12 + 12];
|
||||||
|
void U32(int at, uint v) => System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(table.AsSpan(at), v);
|
||||||
|
U32(0, 1); U32(4, 433); U32(8, 3); U32(12, 1); U32(16, 433); U32(20, 7);
|
||||||
|
Check.True(TitleList.TryParseTable(table, out TitleList list), "parses");
|
||||||
|
Check.Eq(list.Displayed, 433U, "displayed");
|
||||||
|
Check.Eq(list.Earned.Count, 3, "three earned");
|
||||||
|
Check.Eq(list.Sorted()[0].Text, "Adventurer", "sorted by text (retail's list)");
|
||||||
|
Check.False(TitleList.TryParseTable(table.AsSpan(0, 18), out _), "a short list is refused");
|
||||||
|
|
||||||
|
byte[] update = new byte[8];
|
||||||
|
System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(update, 2);
|
||||||
|
System.Buffers.Binary.BinaryPrimitives.WriteUInt32LittleEndian(update.AsSpan(4), 1);
|
||||||
|
TitleList after = list.WithUpdate(update);
|
||||||
|
Check.True(after.Earned.Contains(2U) && after.Displayed == 2, "0x002B adds a title and can make it the displayed one");
|
||||||
|
Check.Eq(list.WithDisplayed(1).Displayed, 1U, "CharacterTitleId moves the displayed one");
|
||||||
|
|
||||||
|
string saved = after.Save();
|
||||||
|
TitleList back = TitleList.Load(saved);
|
||||||
|
Check.Eq(back.Save(), saved, "saved and loaded per character");
|
||||||
|
Check.False(TitleList.Load("").Known, "nothing saved: not known yet");
|
||||||
|
Check.False(TitleList.Load("garbage").Known, "a broken save is nothing");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RetailChart()
|
||||||
|
{
|
||||||
|
Check.Eq(RetailData.LevelTotals.Length, 276, "levels 0..275");
|
||||||
|
Check.Eq(RetailData.LevelTotals[2], 1000UL, "level 2");
|
||||||
|
Check.Eq(RetailData.LevelTotals[275], 191_226_310_247UL, "level 275 (AC's panel subtracts from this past 275)");
|
||||||
|
Check.Eq(RetailData.LevelCredits[275], (byte)1, "a credit at 275");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ExtendedChart()
|
||||||
|
{
|
||||||
|
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||||
|
for (int i = 0; i <= 275; i++) Check.Eq(t[i], RetailData.LevelTotals[i], "retail levels kept, " + i);
|
||||||
|
// The step past 275 grows by 3,390,451,400 / 3,342,189,670 (the chart's last two steps).
|
||||||
|
ulong s275 = t[275] - t[274], s274 = t[274] - t[273];
|
||||||
|
Check.Eq(t[276] - t[275], (ulong)((UInt128)s275 * s275 / s274), "the first synthesized step");
|
||||||
|
for (int i = 277; i < t.Count; i++) Check.True(t[i] - t[i - 1] >= t[i - 1] - t[i - 2], "steps never shrink, " + i);
|
||||||
|
Check.True(t[^1] <= DreamWeaveXp.TotalCap, "the top stays under long.MaxValue / 2");
|
||||||
|
Check.True(DreamWeaveXp.MaxLevel > 1000, "a thousand-odd levels: " + DreamWeaveXp.MaxLevel);
|
||||||
|
// A flat or shrinking chart repeats its last step; too short a chart is left alone.
|
||||||
|
Check.Eq(string.Join(",", DreamWeaveXp.Extend(new ulong[] { 0, 10, 20 }, 50)), "0,10,20,30,40,50", "flat tail");
|
||||||
|
Check.Eq(string.Join(",", DreamWeaveXp.Extend(new ulong[] { 0, 10 }, 50)), "0,10", "too short");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextLevelPast275()
|
||||||
|
{
|
||||||
|
// The report's character: level 344, 600,303,541,190 total XP. AC's panel read -409,077,230,943.
|
||||||
|
const long total = 600_303_541_190;
|
||||||
|
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||||
|
Check.True(t[344] <= (ulong)total && (ulong)total < t[345], "the total is level 344 on DreamWeave's chart, as the server says");
|
||||||
|
Check.Eq(t[344], 593_567_252_692UL, "level 344");
|
||||||
|
Check.Eq(t[345], 602_816_527_434UL, "level 345");
|
||||||
|
Check.Eq(DreamWeaveXp.ToNextLevel(344, total), 2_512_986_244L, "XP for next level");
|
||||||
|
var sheet = SkillsSheet.Empty with { Level = 344, TotalXp = total };
|
||||||
|
Check.Eq(sheet.NextLevelText, "2,512,986,244", "as the panel prints it");
|
||||||
|
Check.Eq((long)RetailData.LevelTotals[275] - total, -409_077_230_943L, "what AC's own panel showed (for the record)");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void NextLevelEdges()
|
||||||
|
{
|
||||||
|
Check.Eq(DreamWeaveXp.ToNextLevel(1, 0), 1000L, "level 1");
|
||||||
|
Check.Eq(DreamWeaveXp.ToNextLevel(275, (long)RetailData.LevelTotals[275]), (long)(DreamWeaveXp.Totals[276] - DreamWeaveXp.Totals[275]), "at 275 it goes on");
|
||||||
|
Check.Eq(DreamWeaveXp.ToNextLevel(10, long.MaxValue / 4), 0L, "already past the next level: 0, not negative");
|
||||||
|
Check.Null(DreamWeaveXp.ToNextLevel(DreamWeaveXp.MaxLevel, 0), "the chart's top");
|
||||||
|
Check.Eq((SkillsSheet.Empty with { Level = DreamWeaveXp.MaxLevel, TotalXp = 1 }).NextLevelText, "Infinity!", "retail's word at the top");
|
||||||
|
Check.Null(DreamWeaveXp.ToNextLevel(0, 5), "no level");
|
||||||
|
Check.Eq(SkillsSheet.Empty.NextLevelText, "", "nothing read yet");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SkillLine Skill(uint id, SkillClass c, bool usable = true, int b = 100, int buffed = 100,
|
||||||
|
long one = 1000, long ten = 12000, int credits = 0, bool raisable = true, bool trainable = false)
|
||||||
|
=> new(id, RetailData.Skill(id)?.Name ?? "?", RetailData.Skill(id)?.Icon ?? 0, c, usable, b, buffed, one, ten, credits, raisable, trainable, false);
|
||||||
|
|
||||||
|
private static void Sections()
|
||||||
|
{
|
||||||
|
var skills = new List<SkillLine>
|
||||||
|
{
|
||||||
|
Skill(46, SkillClass.Specialized), Skill(38, SkillClass.Specialized), // Finesse Weapons, Alchemy
|
||||||
|
Skill(14, SkillClass.Trained), // Arcane Lore
|
||||||
|
Skill(40, SkillClass.Untrained, usable: true), // Salvaging
|
||||||
|
Skill(33, SkillClass.Untrained, usable: false), // Life Magic
|
||||||
|
};
|
||||||
|
List<SkillRow> rows = SkillsLayout.Rows(skills);
|
||||||
|
string text = string.Join(" | ", rows.Select(r => r.IsBanner ? "[" + SkillsLayout.Title(r.Section) + "]" : r.Skill!.Name));
|
||||||
|
Check.Eq(text, "[Specialized Skills] | Alchemy | Finesse Weapons | [Trained Skills] | Arcane Lore | [Untrained Skills] | Salvaging | [Unusable Skills] | Life Magic",
|
||||||
|
"sections in retail's order, names sorted");
|
||||||
|
Check.Eq(SkillsLayout.Rows(new[] { Skill(14, SkillClass.Trained) }).Count, 2, "empty sections are left out");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Footer()
|
||||||
|
{
|
||||||
|
var sheet = SkillsSheet.Empty with { UnassignedXp = 275_586_157_349, SkillCredits = 3 };
|
||||||
|
var (none1, none2) = SkillsLayout.FooterLines(sheet, null);
|
||||||
|
Check.Eq(SkillsLayout.FooterTitle(null).Text, "Select a Skill to Improve", "nothing selected");
|
||||||
|
Check.Eq(none1, ("Skill Credits Available:", "3"), "credits");
|
||||||
|
Check.Eq(none2, ("Unassigned Experience:", "275,586,157,349"), "unassigned");
|
||||||
|
|
||||||
|
// The reported footer: "Salvaging: 303 (+45)", "Experience To Raise: Infinity!" at the top rank.
|
||||||
|
SkillLine salvaging = Skill(40, SkillClass.Specialized, b: 258, buffed: 303, one: -1, ten: -1, raisable: false);
|
||||||
|
Check.Eq(SkillsLayout.FooterTitle(salvaging), ("Salvaging: 303", " (+45)"), "title and buff part");
|
||||||
|
var (s1, s2) = SkillsLayout.FooterLines(sheet, salvaging);
|
||||||
|
Check.Eq(s1, ("Experience To Raise:", "Infinity!"), "maxed");
|
||||||
|
Check.Eq(s2, ("Unassigned Experience:", "275,586,157,349"), "unassigned");
|
||||||
|
Check.Eq(SkillsLayout.FooterTitle(Skill(40, SkillClass.Trained, b: 300, buffed: 290)).Delta, " (-10)", "a debuff");
|
||||||
|
|
||||||
|
SkillLine untrained = Skill(23, SkillClass.Untrained, usable: false, credits: 6, trainable: true);
|
||||||
|
Check.Eq(SkillsLayout.FooterTitle(untrained), ("Lockpick", ""), "untrained: the name alone");
|
||||||
|
var (u1, u2) = SkillsLayout.FooterLines(sheet, untrained);
|
||||||
|
Check.Eq(u1, ("Skill Credits To Raise:", "6"), "credits to train");
|
||||||
|
Check.Eq(u2, ("Skill Credits Available:", "3"), "credits on hand");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RaiseGates()
|
||||||
|
{
|
||||||
|
var rich = SkillsSheet.Empty with { UnassignedXp = 50_000, SkillCredits = 10 };
|
||||||
|
Check.True(SkillsLayout.CanRaiseOne(rich, Skill(14, SkillClass.Trained, one: 1000)), "affordable");
|
||||||
|
Check.True(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 12000)), "ten affordable");
|
||||||
|
Check.False(SkillsLayout.CanRaiseTen(rich, Skill(14, SkillClass.Trained, ten: 90_000)), "ten too dear");
|
||||||
|
Check.False(SkillsLayout.CanRaiseOne(rich, Skill(14, SkillClass.Trained, one: -1, raisable: false)), "at the top");
|
||||||
|
Check.False(SkillsLayout.CanRaiseOne(rich with { Busy = true }, Skill(14, SkillClass.Trained)), "an earlier raise still pending");
|
||||||
|
Check.True(SkillsLayout.CanRaiseOne(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "train with credits");
|
||||||
|
Check.False(SkillsLayout.CanRaiseOne(rich with { SkillCredits = 5 }, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "not enough credits");
|
||||||
|
Check.False(SkillsLayout.CanRaiseTen(rich, Skill(23, SkillClass.Untrained, credits: 6, trainable: true)), "no +10 for untrained");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Header()
|
||||||
|
{
|
||||||
|
Check.Eq(SkillsLayout.Identity(1, 1, "Obviously Bored"), "Male Aluvian Obviously Bored", "the reported line");
|
||||||
|
Check.Eq(SkillsLayout.Identity(2, 2, ""), "Female Gharu'ndim", "no title");
|
||||||
|
Check.Eq(SkillsLayout.Identity(0, 0, null), "", "nothing known");
|
||||||
|
Check.Eq(SkillsLayout.PkStatus(0x02), "Non-Player Killer", "NPK");
|
||||||
|
Check.Eq(SkillsLayout.PkStatus(0x04), "Player Killer", "PK");
|
||||||
|
Check.Eq(SkillsLayout.PkStatus(0x40), "Player Killer Lite", "PK lite");
|
||||||
|
|
||||||
|
// The reported retail header: "Yeoman Drakkon" / "Male Aluvian Obviously Bored".
|
||||||
|
Check.Eq(SkillsLayout.NameLine("Drakkon", 1, 1, 1), "Yeoman Drakkon", "Aluvian rank 1");
|
||||||
|
Check.Eq(SkillsLayout.NameLine("Drakkon", 1, 1, 0), "Drakkon", "no allegiance rank");
|
||||||
|
Check.Eq(SkillsLayout.NameLine("Lucy", 2, 4, 9), "Queen Lucy", "a Viamontian queen");
|
||||||
|
Check.Eq(SkillsLayout.NameLine("Kor", 1, 6, 3), "Optio Kor", "Gearknight titles are the same for both");
|
||||||
|
Check.Eq(SkillsLayout.Title(433), "Obviously Bored", "CharacterTitleId 433");
|
||||||
|
Check.Eq(SkillsLayout.Title(1), "Adventurer", "title 1");
|
||||||
|
Check.Eq(SkillsLayout.Title(0), "", "no title");
|
||||||
|
Check.True(RetailData.Titles.Count > 800, "the title table: " + RetailData.Titles.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void LevelBar()
|
||||||
|
{
|
||||||
|
IReadOnlyList<ulong> t = DreamWeaveXp.Totals;
|
||||||
|
Check.Eq(SkillsLayout.LevelProgress(345, (long)t[345]), 0f, "just levelled");
|
||||||
|
Check.Near(SkillsLayout.LevelProgress(345, (long)(t[345] + (t[346] - t[345]) / 4)), 0.25, 1e-6, "a quarter of the way");
|
||||||
|
// The reported level-345 character (605,149,503,805 XP) is about a quarter through 345.
|
||||||
|
float p = SkillsLayout.LevelProgress(345, 605_149_503_805);
|
||||||
|
Check.True(p > 0.2f && p < 0.3f, "the reported character: " + p);
|
||||||
|
Check.Eq(SkillsLayout.LevelProgress(DreamWeaveXp.MaxLevel, 1), 1f, "the top");
|
||||||
|
Check.Eq(SkillsLayout.LevelProgress(0, 5), 0f, "unknown");
|
||||||
|
|
||||||
|
// The footer's blue bar: a skill's way through its rank (it fills from use).
|
||||||
|
uint[] tr = RetailData.TrainedSkillXp, sp = RetailData.SpecializedSkillXp;
|
||||||
|
Check.Eq(tr.Length, 209, "trained ranks 0..208");
|
||||||
|
Check.Eq(sp.Length, 227, "specialized ranks 0..226");
|
||||||
|
Check.Eq(sp[^1], 4_100_490_438U, "the specialized cap");
|
||||||
|
SkillLine Spec(uint ranks, uint xp, bool top = false) => new(38, "Alchemy", 0, SkillClass.Specialized, true, 1, 1, 1, 1, 0, !top, false, top, ranks, xp);
|
||||||
|
Check.Near(SkillsLayout.RankProgress(Spec(100, sp[100] + (sp[101] - sp[100]) / 2)), 0.5, 1e-3, "half way through rank 100");
|
||||||
|
Check.Eq(SkillsLayout.RankProgress(Spec(100, sp[100])), 0f, "just ranked up");
|
||||||
|
Check.Eq(SkillsLayout.RankProgress(Spec(226, sp[226], top: true)), 0f, "the last rank: empty, as retail's maxed Salvaging");
|
||||||
|
Check.Eq(SkillsLayout.RankProgress(new SkillLine(23, "Lockpick", 0, SkillClass.Untrained, false, 0, 0, -1, -1, 6, false, true, false, 0, 0)), 0f, "untrained");
|
||||||
|
Check.Near(SkillsLayout.RankProgress(new SkillLine(14, "Arcane Lore", 0, SkillClass.Trained, true, 1, 1, 1, 1, 0, true, false, false, 10, tr[10] + (tr[11] - tr[10]) / 4)), 0.25, 0.01, "trained uses its own chart");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Tooltips()
|
||||||
|
{
|
||||||
|
RetailSkill ie = RetailData.Skill(32)!;
|
||||||
|
Check.Eq(ie.Formula, "( Focus + Self ) / 4", "Item Enchantment's formula, as retail's tooltip writes it");
|
||||||
|
Check.Eq(ie.Description, "Allows you to cast spells that affect an item's properties.", "its description");
|
||||||
|
Check.Eq(RetailData.Skill(24)!.Formula, "( Quickness )", "one attribute, no divisor");
|
||||||
|
Check.Eq(RetailData.Skill(19)!.Formula, "", "no attribute part: no formula line");
|
||||||
|
// Retail breaks that description after "item's" (the reported tooltip).
|
||||||
|
Check.Eq(string.Join("|", RetailData.Pal14.Wrap(ie.Description, 230)), "Allows you to cast spells that affect an item's|properties.", "wrapped as retail");
|
||||||
|
Check.Eq(RetailData.Pal14.Wrap("", 230).Count, 0, "nothing to wrap");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RetailTables()
|
||||||
|
{
|
||||||
|
Check.Eq(RetailData.Skills.Length, 38, "the 38 skills of end-of-retail's table");
|
||||||
|
Check.Eq(RetailData.Skill(40)?.Name, "Salvaging", "by id");
|
||||||
|
Check.True(RetailData.Skill(40)!.UsableUntrained && !RetailData.Skill(33)!.UsableUntrained, "usable untrained");
|
||||||
|
Check.True(RetailData.Skills.All(s => (s.Icon >> 24) == 0x06), "icons are 0x06 textures");
|
||||||
|
foreach (RetailFont f in new[] { RetailData.Pal14, RetailData.Pal16, RetailData.Pal18, RetailData.Pal20, RetailData.Stone36 })
|
||||||
|
{
|
||||||
|
Check.True(f.TryGlyph('0', out RetailGlyph zero) && zero.Width > 0, $"0x{f.Id:X8} has digits");
|
||||||
|
Check.True(f.Sheet >> 24 == 0x06 && f.SheetWidth <= 2048, $"0x{f.Id:X8} sheet fits the engine's font-sheet kind");
|
||||||
|
}
|
||||||
|
Check.True(RetailData.Pal16.Measure("Alchemy") > RetailData.Pal16.Measure("Jump"), "widths add up");
|
||||||
|
Check.Eq(RetailData.Pal16.Measure(""), 0, "empty");
|
||||||
|
Check.True(RetailData.Stone36.OutlineSheet != 0 && RetailData.Pal16.OutlineSheet == 0, "only the level number is outlined");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Windows()
|
||||||
|
{
|
||||||
|
Func<bool, System.Numerics.Vector2> draw = _ => default;
|
||||||
|
var notes = new List<string>();
|
||||||
|
var ok = ServerPackWindows.Validate(new List<ServerWindow>
|
||||||
|
{
|
||||||
|
new("skills", "DreamWeave Skills", "", 310, 610, 120, 120, true, draw, FitHeight: true, UnderUi: true, DrawScale: true),
|
||||||
|
new("skills", "Again", "", 1, 1, 1, 1, false, draw),
|
||||||
|
new("server", "Taken", "", 1, 1, 1, 1, false, draw),
|
||||||
|
new("Bad", "Bad", "", 1, 1, 1, 1, false, draw),
|
||||||
|
new("blank", " ", "", 1, 1, 1, 1, false, draw),
|
||||||
|
}, notes.Add);
|
||||||
|
Check.Eq(ok.Count, 1, "one good window");
|
||||||
|
Check.Eq(notes.Count, 4, "four notes: " + string.Join("; ", notes));
|
||||||
|
Check.Eq(ServerPackWindows.IdOf("window:skills"), "skills", "surface to id");
|
||||||
|
Check.Null(ServerPackWindows.IdOf("window:server"), "the server window is the shared code's");
|
||||||
|
Check.Null(ServerPackWindows.IdOf("section:server-dreamweave"), "not a window");
|
||||||
|
|
||||||
|
var info = new ServerPackInfo("dreamweave", "DreamWeave", new[] { "play.acdreamweave.com" }, new[] { "DreamWeave" });
|
||||||
|
foreach (bool frameless in new[] { true, false })
|
||||||
|
{
|
||||||
|
string json = ServerPackModel.BuildSectionsJson(info, "RynthDreamWeave", null, ok, frameless);
|
||||||
|
SectionManifest? m = SectionManifestParser.Parse("RynthDreamWeave", json, out string error);
|
||||||
|
Check.NotNull(m, "parses: " + error);
|
||||||
|
SectionWindowDecl? skills = m!.Windows.FirstOrDefault(w => w.Id == "skills");
|
||||||
|
if (!frameless) { Check.Null(skills, "an engine without frameless windows doesn't get it"); continue; }
|
||||||
|
Check.NotNull(skills, "declared");
|
||||||
|
Check.Eq(skills!.Surface, "window:skills", "surface");
|
||||||
|
Check.Eq(skills.Server, "dreamweave", "DreamWeave only");
|
||||||
|
Check.True(skills.Frameless && skills.Bar, "frameless, on the bar");
|
||||||
|
Check.True(skills.FitHeight, "sized by the panel (retail's bottom-edge resize)");
|
||||||
|
Check.True(skills.UnderUi, "drawn under AC's own UI (\"layer\": \"underUi\")");
|
||||||
|
Check.True(skills.DrawScale, "its own draw size, 100% = retail's pixels (\"scale\": \"draw\"), not the text size");
|
||||||
|
Check.True(m.Windows.Any(w => w.Id == ServerPackModel.WindowId), "the server window is still there");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void OnePanel()
|
||||||
|
{
|
||||||
|
const uint Inventory = 1u << 3, Spellbook = 1u << 7, Map = 1u << 10;
|
||||||
|
var rule = new OnePanelRule();
|
||||||
|
Check.Eq(rule.Next(false, Inventory), default(OnePanelRule.Step), "the first frame only learns");
|
||||||
|
Check.Eq(rule.Next(false, Inventory), default(OnePanelRule.Step), "nothing changed");
|
||||||
|
// The Character panel opens with the inventory up: the inventory goes.
|
||||||
|
Check.Eq(rule.Next(true, Inventory), new OnePanelRule.Step(Inventory, false), "opening it closes AC's open panel");
|
||||||
|
// AC still reads the inventory open for a moment: not an opening.
|
||||||
|
Check.Eq(rule.Next(true, Inventory), default(OnePanelRule.Step), "a panel on its way out isn't an opening");
|
||||||
|
Check.Eq(rule.Next(true, 0), default(OnePanelRule.Step), "the inventory closed");
|
||||||
|
// The spellbook opens while it's up: it goes.
|
||||||
|
Check.Eq(rule.Next(true, Spellbook), new OnePanelRule.Step(0, true), "an AC panel opening closes it");
|
||||||
|
Check.Eq(rule.Next(true, Spellbook), default(OnePanelRule.Step), "asked once, not every frame while it closes");
|
||||||
|
Check.Eq(rule.Next(false, Spellbook), default(OnePanelRule.Step), "closed");
|
||||||
|
// AC switching between its own panels with it closed: none of its business.
|
||||||
|
Check.Eq(rule.Next(false, Map), default(OnePanelRule.Step), "AC's own switch");
|
||||||
|
// Opened again with two up (an engine without retail's own rule): both go.
|
||||||
|
Check.Eq(rule.Next(true, Map | Spellbook), new OnePanelRule.Step(Map | Spellbook, false), "closes every open one");
|
||||||
|
rule.Reset();
|
||||||
|
Check.Eq(rule.Next(true, Map), default(OnePanelRule.Step), "after a reset the first frame only learns again");
|
||||||
|
}
|
||||||
|
}
|
||||||
183
Tools/RynthServerPack.Tests/DreamWeaveTests.cs
Normal file
183
Tools/RynthServerPack.Tests/DreamWeaveTests.cs
Normal file
|
|
@ -0,0 +1,183 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using RynthCore.Plugin.RynthDreamWeave;
|
||||||
|
using RynthCore.Plugin.ServerPack;
|
||||||
|
using RynthCore.Plugin.Shared;
|
||||||
|
using RynthCore.RynthAiTests.Harness;
|
||||||
|
|
||||||
|
namespace RynthServerPack.Tests;
|
||||||
|
|
||||||
|
// RynthDreamWeave's bank check (Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave, 2026-11-02): "/b"
|
||||||
|
// every minute after the first 20 s, "[BANK] Luminance: N" read into the "bankLuminance" profile value
|
||||||
|
// for Lum/hr, deposits taken out, its own replies marked for hiding while a typed /b shows, and the
|
||||||
|
// setting (on by default).
|
||||||
|
internal static class DreamWeaveTests
|
||||||
|
{
|
||||||
|
// The /b reply as DreamWeave's ShowBankBalances sends it.
|
||||||
|
private static readonly string[] Reply =
|
||||||
|
{
|
||||||
|
"[BANK] Your balances:",
|
||||||
|
"[BANK] Pyreals (shared by every character on this account): 12,345,678",
|
||||||
|
"[BANK] Luminance: 8,904,758",
|
||||||
|
"[BANK] Legendary Keys: 3",
|
||||||
|
"[BANK] Promissory Notes: 0",
|
||||||
|
"[BANK] Offline Bonus Time: 1h 20m",
|
||||||
|
"[BANK] Alternate Character Bonus +25% until Enl 2, Level 150",
|
||||||
|
"[BANK] Type /bank for the full list of commands.",
|
||||||
|
};
|
||||||
|
|
||||||
|
public static void Register(Runner r)
|
||||||
|
{
|
||||||
|
r.Add("dreamweave: /b every minute while logged in, not in the first 20 s, not when turned off", Timing);
|
||||||
|
r.Add("dreamweave: the /b reply's luminance is read, and every line of it is ours to hide", ReplyRead);
|
||||||
|
r.Add("dreamweave: a /b the player types updates the value and its reply shows", TypedShows);
|
||||||
|
r.Add("dreamweave: deposits are taken out of the published value", Deposits);
|
||||||
|
r.Add("dreamweave: a pasted or quoted bank line is ignored", Pasted);
|
||||||
|
r.Add("dreamweave: the setting is on by default and saved", Setting);
|
||||||
|
r.Add("dreamweave: the profile value key is the shared bankLuminance", Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Timing()
|
||||||
|
{
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
Check.Null(b.CheckDue(0), "nothing before login");
|
||||||
|
long t = 1_000_000;
|
||||||
|
b.Login(t);
|
||||||
|
Check.Null(b.CheckDue(t + 19_000), "not in the first 20 s");
|
||||||
|
Check.Eq(b.CheckDue(t + 20_000), "/b", "the first check 20 s after login");
|
||||||
|
Check.Null(b.CheckDue(t + 50_000), "not again within the minute");
|
||||||
|
Check.Eq(b.CheckDue(t + 80_000), "/b", "a minute later");
|
||||||
|
b.OnChatLine("[BANK] Luminance: 10", t + 100_000);
|
||||||
|
Check.Null(b.CheckDue(t + 140_000), "a reading starts the minute again");
|
||||||
|
Check.Eq(b.CheckDue(t + 160_000), "/b", "a minute after the reading");
|
||||||
|
b.CheckEveryMinute = false;
|
||||||
|
Check.Null(b.CheckDue(t + 400_000), "off: no checks");
|
||||||
|
b.CheckEveryMinute = true;
|
||||||
|
Check.Eq(b.CheckDue(t + 400_000), "/b", "on again");
|
||||||
|
b.Logout();
|
||||||
|
Check.Null(b.CheckDue(t + 900_000), "nothing after logout");
|
||||||
|
Check.True(DreamWeaveBank.IsBalanceCommand(" /B ") && DreamWeaveBank.IsBalanceCommand("/bank"), "/b and /bank are the balance command");
|
||||||
|
Check.False(DreamWeaveBank.IsBalanceCommand("/b d") || DreamWeaveBank.IsBalanceCommand("/bank deposit"), "a deposit isn't");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ReplyRead()
|
||||||
|
{
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
long t = 1_000_000;
|
||||||
|
b.Login(t);
|
||||||
|
Check.Null(b.Published, "no value before a reading");
|
||||||
|
b.CheckDue(t + 20_000);
|
||||||
|
b.NoteTypedCommand(); // our own /b through the chat bar
|
||||||
|
b.Tick();
|
||||||
|
long now = t + 20_500;
|
||||||
|
foreach (string line in Reply)
|
||||||
|
Check.True(b.OnChatLine(line, now += 100), "ours: " + line);
|
||||||
|
Check.Eq(b.Luminance, (long?)8_904_758, "luminance with commas");
|
||||||
|
Check.Eq(b.Published, (long?)8_904_758, "published as read");
|
||||||
|
Check.False(b.OnChatLine("You say, \"hello\"", now), "other chat isn't ours");
|
||||||
|
Check.False(b.OnChatLine("[BANK] Luminance: 8,904,800", now + 30_000), "a reply long after the request isn't ours");
|
||||||
|
Check.Eq(b.Luminance, (long?)8_904_800, "but it is read");
|
||||||
|
Check.True(b.OnChatLine("[12:01:02] [BANK] Luminance: 8,904,900\r\n", now + 30_100) == false && b.Luminance == 8_904_900,
|
||||||
|
"a chat timestamp in front is fine");
|
||||||
|
b.Logout();
|
||||||
|
Check.Null(b.Published, "logout forgets the reading");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void TypedShows()
|
||||||
|
{
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
long t = 1_000_000;
|
||||||
|
b.Login(t);
|
||||||
|
// The player types /b with no request of ours out: read, and shown.
|
||||||
|
b.NoteTypedCommand();
|
||||||
|
b.Tick();
|
||||||
|
Check.False(b.OnChatLine("[BANK] Your balances:", t + 5_000), "typed: the heading shows");
|
||||||
|
Check.False(b.OnChatLine("[BANK] Luminance: 1,000", t + 5_100), "typed: the luminance shows");
|
||||||
|
Check.Eq(b.Published, (long?)1_000, "typed: the value updates");
|
||||||
|
|
||||||
|
// Our check goes out, then the player types /b too: the reply is theirs and shows.
|
||||||
|
b.CheckDue(t + 80_000);
|
||||||
|
b.NoteTypedCommand(); // ours, through the chat bar
|
||||||
|
b.NoteTypedCommand(); // the player's
|
||||||
|
b.Tick();
|
||||||
|
Check.False(b.OnChatLine("[BANK] Luminance: 1,500", t + 80_300), "both asked: the reply shows");
|
||||||
|
Check.Eq(b.Published, (long?)1_500, "and is read");
|
||||||
|
|
||||||
|
// Our check, and the chat bar never sees our send: still ours.
|
||||||
|
b.CheckDue(t + 200_000);
|
||||||
|
b.Tick();
|
||||||
|
Check.True(b.OnChatLine("[BANK] Luminance: 1,600", t + 200_300), "ours without the chat bar echo");
|
||||||
|
// A failed send leaves nothing waiting.
|
||||||
|
b.Request(t + 300_000);
|
||||||
|
b.NotSent();
|
||||||
|
Check.False(b.OnChatLine("[BANK] Luminance: 1,700", t + 300_100), "a failed send: the reply isn't ours");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Deposits()
|
||||||
|
{
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
long t = 1_000_000;
|
||||||
|
b.Login(t);
|
||||||
|
b.OnChatLine("[BANK] Luminance: 100,000", t);
|
||||||
|
b.OnChatLine("[BANK] Luminance: 150,000", t + 60_000);
|
||||||
|
Check.Eq(b.Published, (long?)150_000, "earned: the value rises");
|
||||||
|
Check.False(b.OnChatLine("[BANK] Deposited 20,000 luminance. Balance: 170,000", t + 70_000), "a deposit line shows");
|
||||||
|
Check.Eq(b.Luminance, (long?)170_000, "the deposit's balance is a reading");
|
||||||
|
Check.Eq(b.Published, (long?)150_000, "the deposit isn't earned");
|
||||||
|
b.OnChatLine("[BANK] Luminance: 180,000", t + 130_000);
|
||||||
|
Check.Eq(b.Published, (long?)160_000, "earned after it counts");
|
||||||
|
b.OnChatLine("[BANK] Deposited all. Pyreals: 1,000 | Luminance: 230,000 | Keys: 1 | Promissory Notes: 0", t + 140_000);
|
||||||
|
Check.Eq(b.MovedIn, 70_000L, "deposit all: what the bank gained since the reading moved in");
|
||||||
|
Check.Eq(b.Published, (long?)160_000, "deposit all isn't earned");
|
||||||
|
b.OnChatLine("[BANK] Luminance: 30,000", t + 200_000);
|
||||||
|
Check.Eq(b.Published, (long?)0, "spending from the bank is a drop (readers don't count drops), never below 0");
|
||||||
|
b.OnChatLine("[BANK] Luminance: 35,000", t + 260_000);
|
||||||
|
Check.Eq(b.Published, (long?)5_000, "and what comes after it counts");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Pasted()
|
||||||
|
{
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
b.Login(0);
|
||||||
|
b.Request(1_000);
|
||||||
|
Check.False(b.OnChatLine("Someone tells you, \"[BANK] Luminance: 999,999,999\"", 1_100), "a tell");
|
||||||
|
Check.False(b.OnChatLine("[General] Someone says, \"[BANK] Luminance: 999\"", 1_200), "a channel");
|
||||||
|
b.OnChatLine("[BANK] Luminance: lots", 1_300);
|
||||||
|
Check.Null(b.Luminance, "nothing read");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Setting()
|
||||||
|
{
|
||||||
|
string dir = Path.Combine(Path.GetTempPath(), "RynthServerPack.Tests", "dreamweave-" + Guid.NewGuid().ToString("N"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var s = new ServerPackSettings(Path.Combine(dir, "rynthdreamweave.json"));
|
||||||
|
s.Load();
|
||||||
|
var b = new DreamWeaveBank();
|
||||||
|
b.LoadSettings(s);
|
||||||
|
Check.True(b.CheckEveryMinute, "on by default");
|
||||||
|
b.CheckEveryMinute = false;
|
||||||
|
b.SaveSettings(s);
|
||||||
|
var s2 = new ServerPackSettings(s.FilePath);
|
||||||
|
s2.Load();
|
||||||
|
var b2 = new DreamWeaveBank();
|
||||||
|
b2.LoadSettings(s2);
|
||||||
|
Check.False(b2.CheckEveryMinute, "off is saved");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try { if (Directory.Exists(dir)) Directory.Delete(dir, recursive: true); } catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Key()
|
||||||
|
{
|
||||||
|
Check.Eq(DreamWeaveBank.LuminanceKey, RynthServerProfile.ValueBankLuminance, "the shared key");
|
||||||
|
Check.True(ServerProfileValues.IsValidKey(DreamWeaveBank.LuminanceKey), "a valid profile value key");
|
||||||
|
var values = new ServerProfileValues();
|
||||||
|
values.Set(DreamWeaveBank.LuminanceKey, 8_904_758);
|
||||||
|
string json = ServerPackProfile.BuildJson(new ServerPackInfo("dreamweave", "DreamWeave", new[] { "play.example.test" }, new[] { "DreamWeave" }), "RynthDreamWeave", "0.1.0", true,
|
||||||
|
"DreamWeave", values.Snapshot(out _));
|
||||||
|
Check.Eq(ServerProfileView.Value(json, RynthServerProfile.ValueBankLuminance, -1), 8_904_758.0, "readers get it from the profile");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,8 @@ internal static class Program
|
||||||
QuestPackTests.Register(runner);
|
QuestPackTests.Register(runner);
|
||||||
LevistrasTests.Register(runner);
|
LevistrasTests.Register(runner);
|
||||||
ServerPackCommandsTests.Register(runner);
|
ServerPackCommandsTests.Register(runner);
|
||||||
|
DreamWeaveSkillsTests.Register(runner);
|
||||||
|
DreamWeaveTests.Register(runner);
|
||||||
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
|
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@
|
||||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthBoards.cs" Link="Aelrynth\AelrynthBoards.cs" />
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthBoards.cs" Link="Aelrynth\AelrynthBoards.cs" />
|
||||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthFeature.cs" Link="Aelrynth\AelrynthFeature.cs" />
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthFeature.cs" Link="Aelrynth\AelrynthFeature.cs" />
|
||||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\VaultFeed.cs" Link="Aelrynth\VaultFeed.cs" />
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\VaultFeed.cs" Link="Aelrynth\VaultFeed.cs" />
|
||||||
|
<!-- RynthDreamWeave's bank check for Lum/hr (pure part). -->
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveBank.cs" Link="DreamWeave\DreamWeaveBank.cs" />
|
||||||
<!-- The difficulty tier RynthAelrynth publishes for RynthAi (and the value names, RynthServerProfileApi.cs). -->
|
<!-- The difficulty tier RynthAelrynth publishes for RynthAi (and the value names, RynthServerProfileApi.cs). -->
|
||||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthDifficulty.cs" Link="Aelrynth\AelrynthDifficulty.cs" />
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthAelrynth\Aelrynth\AelrynthDifficulty.cs" Link="Aelrynth\AelrynthDifficulty.cs" />
|
||||||
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
|
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\RynthServerProfileApi.cs" Link="Shared\RynthServerProfileApi.cs" />
|
||||||
|
|
@ -62,6 +64,14 @@
|
||||||
<!-- The launcher's known-server picker, checked against the plugins it names. -->
|
<!-- The launcher's known-server picker, checked against the plugins it names. -->
|
||||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
|
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\LaunchServerProfile.cs" Link="Launcher\LaunchServerProfile.cs" />
|
||||||
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\KnownServerCatalog.cs" Link="Launcher\KnownServerCatalog.cs" />
|
<Compile Include="..\..\..\RynthCore\src\RynthCore.App\KnownServerCatalog.cs" Link="Launcher\KnownServerCatalog.cs" />
|
||||||
|
<!-- Windows of a server plugin's own (2026-11-07) and RynthDreamWeave's Skills panel (pure parts). -->
|
||||||
|
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackWindows.cs" Link="Plugin\ServerPackWindows.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\RetailData.cs" Link="DreamWeave\RetailData.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\RetailData.g.cs" Link="DreamWeave\RetailData.g.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\DreamWeaveXp.cs" Link="DreamWeave\DreamWeaveXp.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\SkillsSheet.cs" Link="DreamWeave\SkillsSheet.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\AttributesTitles.cs" Link="DreamWeave\AttributesTitles.cs" />
|
||||||
|
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthDreamWeave\DreamWeave\OnePanelRule.cs" Link="DreamWeave\OnePanelRule.cs" />
|
||||||
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
|
<!-- The RynthAi test tools' check/runner harness (no plugin code in it). -->
|
||||||
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Check.cs" Link="Harness\Check.cs" />
|
||||||
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
<Compile Include="$(RynthSuiteRoot)Tools\RynthCore.RynthAiTests\Harness\Runner.cs" Link="Harness\Runner.cs" />
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue