RynthCore as of 2026-10-05 evening (internal 0a2043e): release 2026.10.5.20 - own dat reader, plugin manifests, UI/login hooks with Loot Editor drag-and-drop, server-message stream (API v78), raise attributes and skills (API v79), nameplate sizing and overlay opacity, engine reload held while a plugin is fighting, StatusAgent character sheet, world map and travel for DrakRemote

This commit is contained in:
Tom Bohar 2026-10-05 14:59:43 -04:00
commit 913a2a00b6
110 changed files with 12560 additions and 1151 deletions

View file

@ -459,6 +459,10 @@ internal static class EngineFrameController
if (Compatibility.DecalBridgeHost.Active)
Compatibility.DecalBridgeHost.Drain();
PluginManager.ProcessPendingActions(pluginContext, device, _gameHwnd);
// Client::Cleanup started (UiFlowHooks): the call above told the plugins; from
// here on no plugin tick and no plugin export for the panels' data.
if (Compatibility.UiFlowHooks.ClientCleanupStarted)
return;
PluginManager.FlushPendingDeletes(); // closes the create→delete race window
PluginManager.TickAll();
// Panel data: plugin exports for the UI are called here, on the same
@ -475,6 +479,21 @@ internal static class EngineFrameController
}
}
/// <summary>
/// Runs <paramref name="action"/> on the calling thread while no plugin pump frame runs,
/// holding the pump's frame guard so it can't start one meanwhile. False (not run) when a
/// frame is running. For Client::Cleanup (UiFlowHooks): AC's main thread tells the
/// plugins itself when the pump is idle or no longer running frames.
/// </summary>
internal static bool TryRunOutsidePumpFrame(Action action)
{
if (System.Threading.Interlocked.CompareExchange(ref _pluginPumpInFrame, 1, 0) != 0)
return false;
try { action(); }
finally { System.Threading.Interlocked.Exchange(ref _pluginPumpInFrame, 0); }
return true;
}
/// <summary>True when anything ImGui should be drawn this frame.</summary>
private static bool HasImGuiContent()
{
@ -486,9 +505,13 @@ internal static class EngineFrameController
/// <summary>
/// Panel faces show only in the world, like the Avalonia overlay (hidden
/// between characters, not closed).
/// between characters, not closed). Also off as soon as AC leaves the world screen
/// (UiFlowHooks, before the logout dispatch catches up) and for good once
/// Client::Cleanup starts.
/// </summary>
private static bool PanelsLive => Compatibility.LoginLifecycleHooks.HasObservedLoginComplete;
private static bool PanelsLive => Compatibility.LoginLifecycleHooks.HasObservedLoginComplete
&& Compatibility.UiFlowHooks.InWorldOrUnknown
&& !Compatibility.UiFlowHooks.ClientCleanupStarted;
/// <summary>DPI scale the fonts and style were built for (see Init).</summary>
private static float _uiScale = 1f;

View file

@ -123,6 +123,17 @@ internal static unsafe class ImGuiPopOuts
/// <summary>The pop-out typing into a text box, or null (for the input log). AC thread.</summary>
public static string? TextFocusTitle => _keyboard is { WantTextInput: true } k ? k.Title : null;
/// <summary>
/// True when the cursor is over <paramref name="title"/>'s pop-out window right now
/// (UiDropTargets: an AC item released over a popped-out panel). AC thread.
/// </summary>
public static bool IsCursorOver(string title)
{
if (!Pops.TryGetValue(title, out PopOut? pop) || pop.Window == null || pop.Window.Hwnd == IntPtr.Zero)
return false;
return GetCursorPos(out POINT cursor) && WindowFromPoint(cursor) == pop.Window.Hwnd;
}
/// <summary>The screen position of the game window's client origin (to place a pop-out where the docked panel was).</summary>
public static Vector2 ClientOriginOnScreen()
{

View file

@ -858,9 +858,12 @@ internal static class MonsterHud
const float margin = 60f;
if (MonsterHudSettings.KeepOnScreen)
{
// Pinned to the edge: room above the anchor for the name, bar and debuff row (a label: the name).
Vector2 c = ClampToScreen(ref f, sx, sy, (label ? 50f : 70f) * f.UiScale * userScale,
(label ? 22f : 56f) * f.UiScale * userScale);
// Pinned to the edge: room above the anchor for the name, bar and debuff row (a label: the name),
// grown with the plate type's bar / text size.
float sideMul = label ? LabelTextSize(p.Kind) : MathF.Max(MonsterHudSettings.MonsterBarWidth, MonsterHudSettings.MonsterTextSize);
float topMul = label ? LabelTextSize(p.Kind) : MathF.Max(MonsterHudSettings.MonsterBarHeight, MonsterHudSettings.MonsterTextSize);
Vector2 c = ClampToScreen(ref f, sx, sy, (label ? 50f : 70f) * f.UiScale * userScale * sideMul,
(label ? 22f : 56f) * f.UiScale * userScale * topMul);
p.Anchor = new Vector2(MathF.Round(c.X), MathF.Round(c.Y));
p.OnScreen = true;
}
@ -1004,7 +1007,7 @@ internal static class MonsterHud
if (p.IsLabel)
{
// Name only: the same bold bake as a monster's name, no bar, badge or icons.
p.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * s);
p.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * s * LabelTextSize(p.Kind));
p.NameFont = ImGuiFonts.Sharp(p.NameSize, bold: true);
p.NameW = TextWidth(p.NameFont, p.NameSize, p.Name);
p.BadgeW = 0f;
@ -1016,14 +1019,17 @@ internal static class MonsterHud
return;
}
p.BarW = MathF.Round(112f * k);
p.BarH = MathF.Round((MonsterHudSettings.ShowHpNumbers ? 12f : 7f) * k);
// Bar width / height and text size each have their own multiplier (1 = the default look).
float text = MonsterHudSettings.MonsterTextSize;
p.BarW = MathF.Round(112f * k * MonsterHudSettings.MonsterBarWidth);
p.BarH = MathF.Round((MonsterHudSettings.ShowHpNumbers ? 12f : 7f) * k * MonsterHudSettings.MonsterBarHeight);
// Sizes follow the 11 px bold / 9 px regular bakes; the font drawn is the smallest bake at
// least that big, so a scaled-up plate shrinks a bigger bake instead of stretching (blur).
p.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * s);
// Picking a baked font per size: nothing is re-baked when a text size changes.
p.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * s * text);
p.NameFont = ImGuiFonts.Sharp(p.NameSize, bold: true);
p.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.Ui9).FontSize * s);
p.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.Ui9).FontSize * s * text);
p.SmallFont = ImGuiFonts.Sharp(p.SmallSize, bold: false);
p.NameW = MonsterHudSettings.ShowNames && p.Name.Length > 0 ? TextWidth(p.NameFont, p.NameSize, p.Name) : 0f;
@ -1039,11 +1045,15 @@ internal static class MonsterHud
float nameH = (p.NameW > 0 || p.BadgeW > 0) ? p.NameSize + 2f * k : 0f;
// The weak pill (left) and distance (right) hang off the bar's ends: keep them
// inside the crowd-avoidance box, symmetric so the plate stays centred.
float side = (p.Weak != null || MonsterHudSettings.ShowDistance) ? 2f * 30f * k : 0f;
float side = (p.Weak != null || MonsterHudSettings.ShowDistance) ? 2f * 30f * k * text : 0f;
p.Width = MathF.Max(p.BarW + side, nameLine) + 8f * k;
p.Height = nameH + p.BarH + p.BelowBar;
}
/// <summary>A name label's text size: players' or NPCs' (vendors count as NPCs).</summary>
private static float LabelTextSize(byte kind) =>
kind == RadarKind.Player ? MonsterHudSettings.PlayerTextSize : MonsterHudSettings.NpcTextSize;
/// <summary>Screen rect of a plate at a given upward nudge: (x0, y0, x1, y1).</summary>
private static Vector4 RectAt(Plate p, float nudge, float uiScale)
{

View file

@ -102,6 +102,21 @@ internal static class MonsterHudSettings
public static bool GainLum = true;
public static bool GainRadiance = true;
// Per-plate-type sizing (2026-10-05), multipliers on today's look (1 = unchanged), applied on
// top of Scale. Bar width / height and the text drawn in or over the plate, each on its own.
// NPC and player names are name-only labels (no bar), so they only have a text size.
/// <summary>Monster plates: the health bar's width and height, and their text (name, level, HP, weak-to, distance).</summary>
public static float MonsterBarWidth = 1.0f, MonsterBarHeight = 1.0f, MonsterTextSize = 1.0f;
/// <summary>Name labels over NPCs and vendors.</summary>
public static float NpcTextSize = 1.0f;
/// <summary>Name labels over other players.</summary>
public static float PlayerTextSize = 1.0f;
/// <summary>Your own plate: the three bars' width and height, and their text (cur / max numbers, your name).</summary>
public static float SelfBarWidth = 1.0f, SelfBarHeight = 1.0f, SelfTextSize = 1.0f;
public const float MinBarWidth = 0.5f, MaxBarWidth = 2.5f;
public const float MinBarHeight = 0.5f, MaxBarHeight = 3.0f;
public const float MinTextSize = 0.5f, MaxTextSize = 2.0f;
// ── Ranges (shared by the Settings face, the command and Load) ──────
public const float MinDistance = 5f, MaxDistanceLimit = 120f;
public const int MinPlates = 1, MaxPlatesLimit = 60;
@ -137,74 +152,88 @@ internal static class MonsterHudSettings
{
string path = FilePath;
if (!File.Exists(path)) return;
foreach (string raw in File.ReadAllLines(path))
{
string line = raw.Trim();
if (line.Length == 0 || line.StartsWith('#')) continue;
int eq = line.IndexOf('=');
if (eq <= 0) continue;
string key = line[..eq].Trim();
string val = line[(eq + 1)..].Trim();
switch (key)
{
case "enabled": Enabled = val == "1"; break;
case "maxDistance": if (TryF(val, out float d)) MaxDistance = Math.Clamp(d, MinDistance, MaxDistanceLimit); break;
case "maxPlates":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int n))
MaxPlates = Math.Clamp(n, MinPlates, MaxPlatesLimit);
break;
case "filter": Filter = val.Equals("engaged", StringComparison.OrdinalIgnoreCase) ? PlateFilter.Engaged : PlateFilter.All; break;
case "showNames": ShowNames = val == "1"; break;
case "showHp": ShowHpNumbers = val == "1"; break;
case "showDistance": ShowDistance = val == "1"; break;
case "showLevel": ShowLevel = val == "1"; break;
case "showWeakness": ShowWeakness = val == "1"; break;
case "fade": FadeWithDistance = val == "1"; break;
case "scale": if (TryF(val, out float s)) Scale = Math.Clamp(s, MinScale, MaxScale); break;
case "opacity": if (TryF(val, out float o)) Opacity = Math.Clamp(o, MinOpacity, MaxOpacity); break;
case "clickSelect": ClickToSelect = val == "1"; break;
case "heightLift": if (TryF(val, out float h)) HeightLift = Math.Clamp(h, MinLift, MaxLift); break;
case "npcNames": NpcNames = val == "1"; break;
case "npcDistance": if (TryF(val, out float nd)) NpcMaxDistance = Math.Clamp(nd, MinNpcDistance, MaxNpcDistanceLimit); break;
case "npcMax":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int nm))
MaxNpcLabels = Math.Clamp(nm, MinNpcLabels, MaxNpcLabelsLimit);
break;
case "playerNames": PlayerNames = val == "1"; break;
case "showDebuffs": ShowDebuffs = val == "1"; break;
case "showOthersDebuff": ShowOthersDebuff = val == "1"; break;
case "selfPlate": SelfPlate = val == "1"; break;
case "selfNumbers": SelfNumbers = val == "1"; break;
case "selfName": SelfName = val == "1"; break;
case "selfHideFirstPerson": SelfHideFirstPerson = val == "1"; break;
case "selfPlacement": SelfPlacement = val.Equals("follow", StringComparison.OrdinalIgnoreCase) ? SelfPlacement.Follow : SelfPlacement.Fixed; break;
case "selfLocked": SelfLocked = val == "1"; break;
case "selfFixedX": if (TryF(val, out float fx)) SelfFixedX = Math.Clamp(fx, 0f, 1f); break;
case "selfFixedY": if (TryF(val, out float fy)) SelfFixedY = Math.Clamp(fy, 0f, 1f); break;
case "numbers": Numbers = val == "1"; break;
case "numDealt": NumDealt = val == "1"; break;
case "numTaken": NumTaken = val == "1"; break;
case "numHeals": NumHeals = val == "1"; break;
case "numKills": NumKills = val == "1"; break;
case "keepOnScreen": KeepOnScreen = val == "1"; break;
case "numRestores": NumRestores = val == "1"; break;
case "numSize": if (TryF(val, out float ns)) NumSize = Math.Clamp(ns, MinNumSize, MaxNumSize); break;
case "numTime": if (TryF(val, out float nt)) NumTime = Math.Clamp(nt, MinNumTime, MaxNumTime); break;
case "selfPosition": if (Enum.TryParse(val, true, out SelfPlatePosition sp)) SelfPosition = sp; break;
case "gainSize": if (TryF(val, out float gs)) GainSize = Math.Clamp(gs, MinNumSize, MaxNumSize); break;
case "gainTime": if (TryF(val, out float gt)) GainTime = Math.Clamp(gt, MinNumTime, MaxNumTime); break;
case "gains": Gains = val == "1"; break;
case "gainXp": GainXp = val == "1"; break;
case "gainLum": GainLum = val == "1"; break;
case "gainRadiance": GainRadiance = val == "1"; break;
}
}
ApplyLines(File.ReadAllLines(path));
}
catch { /* best-effort: defaults stay */ }
finally { _loaded = true; }
}
}
/// <summary>Applies the file's key=value lines (unknown keys and bad values are skipped). Also the tests' entry.</summary>
internal static void ApplyLines(string[] lines)
{
foreach (string raw in lines)
{
string line = raw.Trim();
if (line.Length == 0 || line.StartsWith('#')) continue;
int eq = line.IndexOf('=');
if (eq <= 0) continue;
string key = line[..eq].Trim();
string val = line[(eq + 1)..].Trim();
switch (key)
{
case "enabled": Enabled = val == "1"; break;
case "maxDistance": if (TryF(val, out float d)) MaxDistance = Math.Clamp(d, MinDistance, MaxDistanceLimit); break;
case "maxPlates":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int n))
MaxPlates = Math.Clamp(n, MinPlates, MaxPlatesLimit);
break;
case "filter": Filter = val.Equals("engaged", StringComparison.OrdinalIgnoreCase) ? PlateFilter.Engaged : PlateFilter.All; break;
case "showNames": ShowNames = val == "1"; break;
case "showHp": ShowHpNumbers = val == "1"; break;
case "showDistance": ShowDistance = val == "1"; break;
case "showLevel": ShowLevel = val == "1"; break;
case "showWeakness": ShowWeakness = val == "1"; break;
case "fade": FadeWithDistance = val == "1"; break;
case "scale": if (TryF(val, out float s)) Scale = Math.Clamp(s, MinScale, MaxScale); break;
case "opacity": if (TryF(val, out float o)) Opacity = Math.Clamp(o, MinOpacity, MaxOpacity); break;
case "clickSelect": ClickToSelect = val == "1"; break;
case "heightLift": if (TryF(val, out float h)) HeightLift = Math.Clamp(h, MinLift, MaxLift); break;
case "npcNames": NpcNames = val == "1"; break;
case "npcDistance": if (TryF(val, out float nd)) NpcMaxDistance = Math.Clamp(nd, MinNpcDistance, MaxNpcDistanceLimit); break;
case "npcMax":
if (int.TryParse(val, NumberStyles.Integer, CultureInfo.InvariantCulture, out int nm))
MaxNpcLabels = Math.Clamp(nm, MinNpcLabels, MaxNpcLabelsLimit);
break;
case "playerNames": PlayerNames = val == "1"; break;
case "showDebuffs": ShowDebuffs = val == "1"; break;
case "showOthersDebuff": ShowOthersDebuff = val == "1"; break;
case "selfPlate": SelfPlate = val == "1"; break;
case "selfNumbers": SelfNumbers = val == "1"; break;
case "selfName": SelfName = val == "1"; break;
case "selfHideFirstPerson": SelfHideFirstPerson = val == "1"; break;
case "selfPlacement": SelfPlacement = val.Equals("follow", StringComparison.OrdinalIgnoreCase) ? SelfPlacement.Follow : SelfPlacement.Fixed; break;
case "selfLocked": SelfLocked = val == "1"; break;
case "selfFixedX": if (TryF(val, out float fx)) SelfFixedX = Math.Clamp(fx, 0f, 1f); break;
case "selfFixedY": if (TryF(val, out float fy)) SelfFixedY = Math.Clamp(fy, 0f, 1f); break;
case "numbers": Numbers = val == "1"; break;
case "numDealt": NumDealt = val == "1"; break;
case "numTaken": NumTaken = val == "1"; break;
case "numHeals": NumHeals = val == "1"; break;
case "numKills": NumKills = val == "1"; break;
case "keepOnScreen": KeepOnScreen = val == "1"; break;
case "numRestores": NumRestores = val == "1"; break;
case "numSize": if (TryF(val, out float ns)) NumSize = Math.Clamp(ns, MinNumSize, MaxNumSize); break;
case "numTime": if (TryF(val, out float nt)) NumTime = Math.Clamp(nt, MinNumTime, MaxNumTime); break;
case "selfPosition": if (Enum.TryParse(val, true, out SelfPlatePosition sp)) SelfPosition = sp; break;
case "gainSize": if (TryF(val, out float gs)) GainSize = Math.Clamp(gs, MinNumSize, MaxNumSize); break;
case "gainTime": if (TryF(val, out float gt)) GainTime = Math.Clamp(gt, MinNumTime, MaxNumTime); break;
case "gains": Gains = val == "1"; break;
case "gainXp": GainXp = val == "1"; break;
case "gainLum": GainLum = val == "1"; break;
case "gainRadiance": GainRadiance = val == "1"; break;
case "monsterBarWidth": if (TryF(val, out float mbw)) MonsterBarWidth = Math.Clamp(mbw, MinBarWidth, MaxBarWidth); break;
case "monsterBarHeight": if (TryF(val, out float mbh)) MonsterBarHeight = Math.Clamp(mbh, MinBarHeight, MaxBarHeight); break;
case "monsterTextSize": if (TryF(val, out float mts)) MonsterTextSize = Math.Clamp(mts, MinTextSize, MaxTextSize); break;
case "npcTextSize": if (TryF(val, out float nts)) NpcTextSize = Math.Clamp(nts, MinTextSize, MaxTextSize); break;
case "playerTextSize": if (TryF(val, out float pts)) PlayerTextSize = Math.Clamp(pts, MinTextSize, MaxTextSize); break;
case "selfBarWidth": if (TryF(val, out float sbw)) SelfBarWidth = Math.Clamp(sbw, MinBarWidth, MaxBarWidth); break;
case "selfBarHeight": if (TryF(val, out float sbh)) SelfBarHeight = Math.Clamp(sbh, MinBarHeight, MaxBarHeight); break;
case "selfTextSize": if (TryF(val, out float sts)) SelfTextSize = Math.Clamp(sts, MinTextSize, MaxTextSize); break;
}
}
}
private static bool TryF(string s, out float v) => float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out v);
/// <summary>Writes the settings in the background. Any thread.</summary>
@ -220,56 +249,70 @@ internal static class MonsterHudSettings
string? dir = Path.GetDirectoryName(path);
if (!string.IsNullOrEmpty(dir)) Directory.CreateDirectory(dir);
using var sw = new StreamWriter(path, append: false);
sw.WriteLine("# RynthCore monster nameplates - auto-generated, hand-edits OK. /rc plates in game.");
sw.WriteLine($"enabled={B(Enabled)}");
sw.WriteLine(FormattableString.Invariant($"maxDistance={MaxDistance:0.#}"));
sw.WriteLine(FormattableString.Invariant($"maxPlates={MaxPlates}"));
sw.WriteLine($"filter={(Filter == PlateFilter.Engaged ? "engaged" : "all")}");
sw.WriteLine($"showNames={B(ShowNames)}");
sw.WriteLine($"showHp={B(ShowHpNumbers)}");
sw.WriteLine($"showDistance={B(ShowDistance)}");
sw.WriteLine($"showLevel={B(ShowLevel)}");
sw.WriteLine($"showWeakness={B(ShowWeakness)}");
sw.WriteLine($"fade={B(FadeWithDistance)}");
sw.WriteLine(FormattableString.Invariant($"scale={Scale:0.##}"));
sw.WriteLine(FormattableString.Invariant($"opacity={Opacity:0.##}"));
sw.WriteLine(FormattableString.Invariant($"heightLift={HeightLift:0.##}"));
sw.WriteLine($"clickSelect={B(ClickToSelect)}");
sw.WriteLine($"npcNames={B(NpcNames)}");
sw.WriteLine(FormattableString.Invariant($"npcDistance={NpcMaxDistance:0.#}"));
sw.WriteLine(FormattableString.Invariant($"npcMax={MaxNpcLabels}"));
sw.WriteLine($"playerNames={B(PlayerNames)}");
sw.WriteLine($"showDebuffs={B(ShowDebuffs)}");
sw.WriteLine($"showOthersDebuff={B(ShowOthersDebuff)}");
sw.WriteLine($"selfPlate={B(SelfPlate)}");
sw.WriteLine($"selfNumbers={B(SelfNumbers)}");
sw.WriteLine($"selfName={B(SelfName)}");
sw.WriteLine($"selfHideFirstPerson={B(SelfHideFirstPerson)}");
sw.WriteLine($"selfPlacement={(SelfPlacement == SelfPlacement.Follow ? "follow" : "fixed")}");
sw.WriteLine($"selfLocked={B(SelfLocked)}");
sw.WriteLine(FormattableString.Invariant($"selfFixedX={SelfFixedX:0.####}"));
sw.WriteLine(FormattableString.Invariant($"selfFixedY={SelfFixedY:0.####}"));
sw.WriteLine($"numbers={B(Numbers)}");
sw.WriteLine($"numDealt={B(NumDealt)}");
sw.WriteLine($"numTaken={B(NumTaken)}");
sw.WriteLine($"numHeals={B(NumHeals)}");
sw.WriteLine($"numKills={B(NumKills)}");
sw.WriteLine($"keepOnScreen={B(KeepOnScreen)}");
sw.WriteLine($"numRestores={B(NumRestores)}");
sw.WriteLine(FormattableString.Invariant($"numSize={NumSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"numTime={NumTime:0.##}"));
sw.WriteLine(FormattableString.Invariant($"gainSize={GainSize:0.##}"));
sw.WriteLine($"selfPosition={SelfPosition}");
sw.WriteLine(FormattableString.Invariant($"gainTime={GainTime:0.##}"));
sw.WriteLine($"gains={B(Gains)}");
sw.WriteLine($"gainXp={B(GainXp)}");
sw.WriteLine($"gainLum={B(GainLum)}");
sw.WriteLine($"gainRadiance={B(GainRadiance)}");
WriteAll(sw);
}
catch { /* non-fatal */ }
}
}
/// <summary>Every setting as the file's key=value lines. Also the tests' entry.</summary>
internal static void WriteAll(TextWriter sw)
{
sw.WriteLine("# RynthCore monster nameplates - auto-generated, hand-edits OK. /rc plates in game.");
sw.WriteLine($"enabled={B(Enabled)}");
sw.WriteLine(FormattableString.Invariant($"maxDistance={MaxDistance:0.#}"));
sw.WriteLine(FormattableString.Invariant($"maxPlates={MaxPlates}"));
sw.WriteLine($"filter={(Filter == PlateFilter.Engaged ? "engaged" : "all")}");
sw.WriteLine($"showNames={B(ShowNames)}");
sw.WriteLine($"showHp={B(ShowHpNumbers)}");
sw.WriteLine($"showDistance={B(ShowDistance)}");
sw.WriteLine($"showLevel={B(ShowLevel)}");
sw.WriteLine($"showWeakness={B(ShowWeakness)}");
sw.WriteLine($"fade={B(FadeWithDistance)}");
sw.WriteLine(FormattableString.Invariant($"scale={Scale:0.##}"));
sw.WriteLine(FormattableString.Invariant($"opacity={Opacity:0.##}"));
sw.WriteLine(FormattableString.Invariant($"heightLift={HeightLift:0.##}"));
sw.WriteLine($"clickSelect={B(ClickToSelect)}");
sw.WriteLine($"npcNames={B(NpcNames)}");
sw.WriteLine(FormattableString.Invariant($"npcDistance={NpcMaxDistance:0.#}"));
sw.WriteLine(FormattableString.Invariant($"npcMax={MaxNpcLabels}"));
sw.WriteLine($"playerNames={B(PlayerNames)}");
sw.WriteLine($"showDebuffs={B(ShowDebuffs)}");
sw.WriteLine($"showOthersDebuff={B(ShowOthersDebuff)}");
sw.WriteLine($"selfPlate={B(SelfPlate)}");
sw.WriteLine($"selfNumbers={B(SelfNumbers)}");
sw.WriteLine($"selfName={B(SelfName)}");
sw.WriteLine($"selfHideFirstPerson={B(SelfHideFirstPerson)}");
sw.WriteLine($"selfPlacement={(SelfPlacement == SelfPlacement.Follow ? "follow" : "fixed")}");
sw.WriteLine($"selfLocked={B(SelfLocked)}");
sw.WriteLine(FormattableString.Invariant($"selfFixedX={SelfFixedX:0.####}"));
sw.WriteLine(FormattableString.Invariant($"selfFixedY={SelfFixedY:0.####}"));
sw.WriteLine($"numbers={B(Numbers)}");
sw.WriteLine($"numDealt={B(NumDealt)}");
sw.WriteLine($"numTaken={B(NumTaken)}");
sw.WriteLine($"numHeals={B(NumHeals)}");
sw.WriteLine($"numKills={B(NumKills)}");
sw.WriteLine($"keepOnScreen={B(KeepOnScreen)}");
sw.WriteLine($"numRestores={B(NumRestores)}");
sw.WriteLine(FormattableString.Invariant($"numSize={NumSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"numTime={NumTime:0.##}"));
sw.WriteLine(FormattableString.Invariant($"gainSize={GainSize:0.##}"));
sw.WriteLine($"selfPosition={SelfPosition}");
sw.WriteLine(FormattableString.Invariant($"gainTime={GainTime:0.##}"));
sw.WriteLine($"gains={B(Gains)}");
sw.WriteLine($"gainXp={B(GainXp)}");
sw.WriteLine($"gainLum={B(GainLum)}");
sw.WriteLine($"gainRadiance={B(GainRadiance)}");
sw.WriteLine(FormattableString.Invariant($"monsterBarWidth={MonsterBarWidth:0.##}"));
sw.WriteLine(FormattableString.Invariant($"monsterBarHeight={MonsterBarHeight:0.##}"));
sw.WriteLine(FormattableString.Invariant($"monsterTextSize={MonsterTextSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"npcTextSize={NpcTextSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"playerTextSize={PlayerTextSize:0.##}"));
sw.WriteLine(FormattableString.Invariant($"selfBarWidth={SelfBarWidth:0.##}"));
sw.WriteLine(FormattableString.Invariant($"selfBarHeight={SelfBarHeight:0.##}"));
sw.WriteLine(FormattableString.Invariant($"selfTextSize={SelfTextSize:0.##}"));
}
private static string B(bool v) => v ? "1" : "0";
/// <summary>Back to the defaults (and saved). Render / chat thread.</summary>
@ -286,9 +329,24 @@ internal static class MonsterHudSettings
NumSize = 1.0f; NumTime = 1.0f; NumRestores = true; KeepOnScreen = true;
GainSize = 1.0f; GainTime = 1.0f; SelfPosition = SelfPlatePosition.Above;
Gains = true; GainXp = true; GainLum = true; GainRadiance = true;
ResetSizesNoSave();
Save();
}
/// <summary>Every plate type's bar and text size back to 1 (and saved). Render / chat thread.</summary>
public static void ResetSizes()
{
ResetSizesNoSave();
Save();
}
private static void ResetSizesNoSave()
{
MonsterBarWidth = 1.0f; MonsterBarHeight = 1.0f; MonsterTextSize = 1.0f;
NpcTextSize = 1.0f; PlayerTextSize = 1.0f;
SelfBarWidth = 1.0f; SelfBarHeight = 1.0f; SelfTextSize = 1.0f;
}
/// <summary>The fixed plate back to its default spot (and saved). Render / chat thread.</summary>
public static void ResetSelfPosition()
{
@ -314,7 +372,10 @@ internal static class MonsterHudSettings
$"self {OnOff(SelfPlate)} ({(SelfPlacement == SelfPlacement.Fixed ? "fixed on screen, " + (SelfLocked ? "locked" : "unlocked") : "follows you, " + SelfPosition.ToString().ToLowerInvariant())}, " +
$"numbers {OnOff(SelfNumbers)}, name {OnOff(SelfName)}, hide in first person {OnOff(SelfHideFirstPerson)}); " +
$"combat text {OnOff(Numbers)} (dealt {OnOff(NumDealt)}, taken {OnOff(NumTaken)}, heals {OnOff(NumHeals)}, kills {OnOff(NumKills)}); " +
$"gains {OnOff(Gains)} (xp {OnOff(GainXp)}, lum {OnOff(GainLum)}, radiance {OnOff(GainRadiance)}).");
$"gains {OnOff(Gains)} (xp {OnOff(GainXp)}, lum {OnOff(GainLum)}, radiance {OnOff(GainRadiance)}); " +
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##}, " +
$"NPC text {NpcTextSize:0.##}, player text {PlayerTextSize:0.##}, " +
$"your bars {SelfBarWidth:0.##}x{SelfBarHeight:0.##} text {SelfTextSize:0.##}.");
private static string OnOff(bool v) => v ? "on" : "off";
}

View file

@ -68,6 +68,12 @@ internal static class MonsterHudSettingsUi
changed |= Toggle("Weak-to element", ref MonsterHudSettings.ShowWeakness,
"What the monster takes most damage from, from RynthAi's Damage data (needs RynthAi).");
changed |= Toggle("Distance", ref MonsterHudSettings.ShowDistance, null);
changed |= SizeSlider("Bar width", ref MonsterHudSettings.MonsterBarWidth, MonsterHudSettings.MinBarWidth, MonsterHudSettings.MaxBarWidth, w,
"How wide a monster's health bar is (1.00x = the default). On top of Look > Scale.");
changed |= SizeSlider("Bar height", ref MonsterHudSettings.MonsterBarHeight, MonsterHudSettings.MinBarHeight, MonsterHudSettings.MaxBarHeight, w,
"How tall (thick) a monster's health bar is (1.00x = the default). HP numbers need a bar at least 9 px tall.");
changed |= SizeSlider("Text size", ref MonsterHudSettings.MonsterTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"The monster plate's text: name, level badge, HP numbers, weak-to pill and distance (1.00x = the default).");
Section("Names over NPCs and players", w);
changed |= Toggle("NPC names", ref MonsterHudSettings.NpcNames,
@ -77,8 +83,12 @@ internal static class MonsterHudSettingsUi
MonsterHudSettings.MinNpcDistance, MonsterHudSettings.MaxNpcDistanceLimit, "%.0f", w);
changed |= SliderI("Max names", ref MonsterHudSettings.MaxNpcLabels,
MonsterHudSettings.MinNpcLabels, MonsterHudSettings.MaxNpcLabelsLimit, w);
changed |= SizeSlider("NPC name size", ref MonsterHudSettings.NpcTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"Text size of the names over NPCs and vendors (1.00x = the default). Names have no bar.");
changed |= Toggle("Player names", ref MonsterHudSettings.PlayerNames,
"The name over other players too (blue), within the same distance and count. Chat: /rv plates players.");
changed |= SizeSlider("Player name size", ref MonsterHudSettings.PlayerTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"Text size of the names over other players (1.00x = the default). Names have no bar.");
Note("Names count apart from the monster plates, so they never push one out; the nearest win.", w);
Section("Debuffs", w);
@ -94,6 +104,12 @@ internal static class MonsterHudSettingsUi
"Your own health, stamina and mana bars: fixed on screen, or following your character. Chat: /rv plates self.");
changed |= Toggle("Numbers on your bars", ref MonsterHudSettings.SelfNumbers, "\"cur / max\" inside each bar (taller bars).", sub: true);
changed |= Toggle("Your name", ref MonsterHudSettings.SelfName, null, sub: true);
changed |= SizeSlider("Your bar width", ref MonsterHudSettings.SelfBarWidth, MonsterHudSettings.MinBarWidth, MonsterHudSettings.MaxBarWidth, w,
"How wide your health, stamina and mana bars are (1.00x = the default).");
changed |= SizeSlider("Your bar height", ref MonsterHudSettings.SelfBarHeight, MonsterHudSettings.MinBarHeight, MonsterHudSettings.MaxBarHeight, w,
"How tall (thick) each of your bars is (1.00x = the default). The numbers need a bar at least 8 px tall.");
changed |= SizeSlider("Your text size", ref MonsterHudSettings.SelfTextSize, MonsterHudSettings.MinTextSize, MonsterHudSettings.MaxTextSize, w,
"Your plate's text: the cur / max numbers and your name (1.00x = the default).");
bool fixedOn = MonsterHudSettings.SelfPlacement == SelfPlacement.Fixed;
if (Toggle("Fixed on screen", ref fixedOn,
@ -151,6 +167,14 @@ internal static class MonsterHudSettingsUi
changed |= Toggle("Fade and shrink with distance", ref MonsterHudSettings.FadeWithDistance, null);
ImGuiNET.ImGui.Dummy(new Vector2(0, 8));
if (SmallButton("Reset bar and text sizes"))
{
MonsterHudSettings.ResetSizes(); // saves
changed = false;
}
if (ImGuiNET.ImGui.IsItemHovered())
ImGuiNET.ImGui.SetTooltip("Every plate type's bar width, bar height and text size back to 1.00x.");
ImGuiNET.ImGui.Dummy(new Vector2(0, 2));
if (SmallButton("Reset all to defaults"))
{
MonsterHudSettings.ResetToDefaults();
@ -238,6 +262,15 @@ internal static class MonsterHudSettingsUi
return EndSliderRow(changed);
}
/// <summary>A size multiplier slider ("1.00x" = the default look) with a tooltip. Labels are the ids: keep them unique.</summary>
private static bool SizeSlider(string label, ref float value, float min, float max, float w, string tip)
{
BeginSliderRow(label, w);
bool changed = ImGuiNET.ImGui.SliderFloat("##v", ref value, min, max, "%.2fx", ImGuiSliderFlags.AlwaysClamp);
if (ImGuiNET.ImGui.IsItemHovered()) ImGuiNET.ImGui.SetTooltip(tip);
return EndSliderRow(changed);
}
private static bool SliderI(string label, ref int value, int min, int max, float w)
{
BeginSliderRow(label, w);

View file

@ -280,15 +280,18 @@ internal static class PlayerPlate
float k = l.K = MonsterHudSettings.Scale * uiScale;
bool numbers = l.Numbers = MonsterHudSettings.SelfNumbers;
// With numbers on, the bars grow to fit bold, outlined text that reads over any fill.
l.BarW = MathF.Round((numbers ? 124f : 96f) * k);
l.BarH = MathF.Round((numbers ? 15f : 5f) * k);
// Width, height and text each have their own multiplier on top (1 = the default look).
l.BarW = MathF.Round((numbers ? 124f : 96f) * k * MonsterHudSettings.SelfBarWidth);
l.BarH = MathF.Round((numbers ? 15f : 5f) * k * MonsterHudSettings.SelfBarHeight);
l.Gap = MathF.Max(2f, MathF.Round(2f * k));
l.Round = MathF.Max(1f, 1.5f * k);
// Sized from the 11 px bold bake, drawn from the smallest bake at least that big (no blur when scaled up).
l.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * MonsterHudSettings.Scale);
// Sized from the 11 px bold bake, drawn from the smallest bake at least that big (no blur when scaled up;
// nothing is re-baked when the text size changes).
float text = MonsterHudSettings.Scale * MonsterHudSettings.SelfTextSize;
l.SmallSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
l.Small = ImGuiFonts.Sharp(l.SmallSize, bold: true);
l.BlockH = 3 * l.BarH + 2 * l.Gap;
l.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * MonsterHudSettings.Scale);
l.NameSize = MathF.Round(ImGuiFonts.Get(UiFont.UiBold11).FontSize * text);
l.NameFont = ImGuiFonts.Sharp(l.NameSize, bold: true);
l.NameH = MonsterHudSettings.SelfName ? l.NameSize + 3f * k : 0f;
return l;
@ -358,7 +361,9 @@ internal static class PlayerPlate
float tw = MonsterHud.TextWidth(font, size, text);
var pos = new Vector2(MathF.Round(left + (w - tw) * 0.5f), MathF.Round(top + (h - size) * 0.5f));
// A dark band behind the text, then an outline, so it reads over bright and dark fills alike.
dl.AddRectFilled(new Vector2(pos.X - 3f, top + 1f), new Vector2(pos.X + tw + 3f, top + h - 1f), MonsterHud.Mul(0x70000000u, a), 2f);
// (Text sized bigger than the bar: the band grows to the text.)
dl.AddRectFilled(new Vector2(pos.X - 3f, MathF.Min(top + 1f, pos.Y)), new Vector2(pos.X + tw + 3f, MathF.Max(top + h - 1f, pos.Y + size)),
MonsterHud.Mul(0x70000000u, a), 2f);
MonsterHud.OutlinedText(dl, font, size, pos, a, text);
dl.AddText(font, size, pos, MonsterHud.Mul(NumCol, a), text);
}

View file

@ -205,6 +205,7 @@ internal sealed class LootEditorFace : IImGuiPanel
else RuleView(origin, size, w);
}
End(origin, size);
AcceptAcDrops(origin, size);
_lootAdd.Draw();
// An item rule added to the open profile: show it (the state already carries it and its Focus).
if (_lootAdd.TakeAdded() && _mode == Mode.List && _state != null && _state.Focus >= 0 && _state.Focus < _state.Rules.Count)
@ -212,6 +213,39 @@ internal sealed class LootEditorFace : IImGuiPanel
_picker.Draw();
}
// ── Drop an item from AC's own inventory on the editor (2026-10-05) ──
// Compatibility/UiElementHooks keeps a drop over this body from AC (AC's own
// "not caught" path, the item stays put) and hands the item here; it opens the
// same "Add to loot profile" popup as "Add selected item", for that item.
private const string DropKey = "LootEditor";
private void AcceptAcDrops(Vector2 origin, Vector2 size)
{
LootEditStateDto? s = _state;
bool can = !_unavailable && s != null && s.Path.Length > 0 && !s.Dirty
&& (!s.ReadOnly || s.Format == "json") && !_lootAdd.IsOpen;
UiDropTargets.Publish(DropKey, Title, origin, origin + size, can);
if (UiDropTargets.TryTake(DropKey, out uint itemId) && can)
{
Compatibility.ClientObjectHooks.TryGetObjectName(itemId, out string name);
_lootAdd.Open(itemId, name ?? string.Empty, toOpenProfile: true);
}
// While AC drags an item: show that letting go here adds a rule.
if (!can || Compatibility.UiElementHooks.CurrentDragObject == 0)
return;
bool over = UiDropTargets.IsCursorOver(DropKey);
var dl = ImGuiNET.ImGui.GetWindowDrawList();
dl.AddRect(origin + new Vector2(1, 1), origin + size - new Vector2(1, 1), over ? Green : Teal, 4, ImDrawFlags.None, over ? 3f : 1.5f);
string hint = over ? "Let go: add a loot rule for this item" : "Drop an item here to add a loot rule";
Vector2 ts = ImGuiNET.ImGui.CalcTextSize(hint);
Vector2 at = new(origin.X + (size.X - ts.X) * 0.5f, origin.Y + size.Y - ts.Y - 10);
dl.AddRectFilled(at - new Vector2(6, 3), at + ts + new Vector2(6, 3), ShellBg, 4);
dl.AddText(at, over ? Green : Teal, hint);
}
private void RequestOpen(string path)
{
if (_state != null && _state.Dirty && path.Length > 0 && !SamePath(path, _state.Path))

View file

@ -25,6 +25,7 @@ using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using RynthCore.Engine.Compatibility;
using RynthCore.Engine.UI;
using RynthCore.Engine.UI.ScriptWindows;
@ -53,6 +54,8 @@ internal sealed class SkillDatTables
public uint[] TrainedXp = Array.Empty<uint>();
public uint[] SpecializedXp = Array.Empty<uint>();
public ulong[] LevelXp = Array.Empty<ulong>();
/// <summary>The same arrays as one object (Compatibility/TrainingCosts).</summary>
public XpTableData Xp = new();
}
internal static class SkillDat
@ -137,51 +140,31 @@ internal static class SkillDat
return r.Ok && t.Skills.Count > 0;
}
// The XpTable layout and the cost arithmetic live in Compatibility/TrainingCosts.cs (shared
// with the plugin API's raise calls and tested against a real portal.dat).
private static bool ParseXp(byte[] raw, SkillDatTables t)
{
var r = new Reader(raw);
r.U32(); // file id
int attrs = (int)r.U32(), vitals = (int)r.U32(), trained = (int)r.U32(), spec = (int)r.U32();
int levels = (int)r.U32();
if (!r.Ok || attrs < 0 || vitals < 0 || trained < 0 || spec < 0 || levels < 0
|| attrs > 10000 || vitals > 10000 || trained > 10000 || spec > 10000 || levels > 10000)
return false;
t.AttributeXp = r.U32s(attrs + 1);
t.VitalXp = r.U32s(vitals + 1);
t.TrainedXp = r.U32s(trained + 1);
t.SpecializedXp = r.U32s(spec + 1);
var lv = new ulong[levels + 1];
for (int i = 0; i <= levels; i++) lv[i] = r.U64();
t.LevelXp = lv;
return r.Ok;
if (!TrainingCosts.TryParseXpTable(raw, out XpTableData xp)) return false;
t.Xp = xp;
t.AttributeXp = xp.AttributeXp;
t.VitalXp = xp.VitalXp;
t.TrainedXp = xp.TrainedXp;
t.SpecializedXp = xp.SpecializedXp;
t.LevelXp = xp.LevelXp;
return true;
}
// ── XP arithmetic (the server's: Player.SpendAttributeXp / SpendSkillXp) ──
/// <summary>True when <paramref name="ranks"/> is the table's top rank (nothing left to buy).</summary>
public static bool IsMax(uint[] table, uint ranks) => table.Length == 0 || ranks + 1 >= (uint)table.Length;
public static bool IsMax(uint[] table, uint ranks) => TrainingCosts.IsMax(table, ranks);
/// <summary>XP to buy <paramref name="n"/> more ranks from <paramref name="ranks"/> with <paramref name="spent"/> already spent; -1 past the top.</summary>
public static long CostOf(uint[] table, uint ranks, uint spent, int n)
{
if (n < 1) return 0;
long target = (long)ranks + n;
if (target >= table.Length) return -1;
return Math.Max(0L, (long)table[target] - spent);
}
public static long CostOf(uint[] table, uint ranks, uint spent, int n) => TrainingCosts.CostOf(table, ranks, spent, n);
/// <summary>How many ranks in a row <paramref name="available"/> XP buys (0 when not even one), up to the top rank.</summary>
public static int Affordable(uint[] table, uint ranks, uint spent, long available)
{
int lo = 0, hi = Math.Max(0, table.Length - 1 - (int)Math.Min(ranks, (uint)int.MaxValue));
while (lo < hi)
{
int mid = (lo + hi + 1) / 2;
long c = CostOf(table, ranks, spent, mid);
if (c >= 0 && c <= available) lo = mid; else hi = mid - 1;
}
return lo;
}
public static int Affordable(uint[] table, uint ranks, uint spent, long available) =>
TrainingCosts.Affordable(table, ranks, spent, available);
/// <summary>Bounds-checked little-endian reader; Ok turns false on overrun.</summary>
private ref struct Reader

View file

@ -3,7 +3,8 @@
// ImGui face of the RynthVision settings (UI/Panels/RynthVisionPanel.cs),
// in three tabs:
// Terrain the plugin's overlays (radar ring, unclimbable slopes,
// impassable water), colours (AARRGGBB hex + swatch), tuning
// impassable water), colours (AARRGGBB hex + swatch) each
// with an opacity slider (the colour's alpha byte), tuning
// sliders (Ctrl+click to type a value), water terrain types,
// and "Log terrain types here";
// Nameplates the RynthVision nameplates (monster plates, debuff icons,
@ -115,10 +116,15 @@ internal sealed class VisionFace : IImGuiPanel
if (ImGuiNET.ImGui.Checkbox("Unclimbable slopes", ref s.Slopes)) Save(VisionKeys.Slopes);
if (ImGuiNET.ImGui.Checkbox("Impassable water", ref s.Water)) Save(VisionKeys.Water);
Header("Colors (hex AARRGGBB)");
Header("Colors (hex AARRGGBB) and opacity");
ImGuiNET.ImGui.PushItemWidth(Math.Max(120, ImGuiNET.ImGui.GetContentRegionAvail().X - 8));
busy |= ColorRow(SlopeColorF, _slopeHex, ref s.SlopeColor);
busy |= OpacitySlider(SlopeOpacityF, _slopeHex, ref s.SlopeColor);
busy |= ColorRow(WaterColorF, _waterHex, ref s.WaterColor);
busy |= OpacitySlider(WaterOpacityF, _waterHex, ref s.WaterColor);
busy |= ColorRow(RadarColorF, _radarHex, ref s.RadarColor);
busy |= OpacitySlider(RadarOpacityF, _radarHex, ref s.RadarColor);
ImGuiNET.ImGui.PopItemWidth();
Header("Tuning");
ImGuiNET.ImGui.PushItemWidth(Math.Max(120, ImGuiNET.ImGui.GetContentRegionAvail().X - 8));
@ -188,6 +194,10 @@ internal sealed class VisionFace : IImGuiPanel
private static readonly Field SlopeColorF = Field.Color("Slope", VisionKeys.SlopeColor);
private static readonly Field WaterColorF = Field.Color("Water", VisionKeys.WaterColor);
private static readonly Field RadarColorF = Field.Color("Radar", VisionKeys.RadarColor);
// Opacity is the colour's alpha byte: the slider saves the colour field.
private static readonly Field SlopeOpacityF = Field.Slider("Slope opacity", VisionKeys.SlopeColor);
private static readonly Field WaterOpacityF = Field.Slider("Water opacity", VisionKeys.WaterColor);
private static readonly Field RadarOpacityF = Field.Slider("Radar ring opacity", VisionKeys.RadarColor);
private static readonly Field RadarRangeF = Field.Slider("Radar range", VisionKeys.RadarRange);
private static readonly Field RingThickF = Field.Slider("Ring thickness", VisionKeys.RingThick);
private static readonly Field RingHeightF = Field.Slider("Ring height (m)", VisionKeys.RingHeight);
@ -227,6 +237,24 @@ internal sealed class VisionFace : IImGuiPanel
return typing;
}
/// <summary>
/// The colour's alpha as 0-100 %: label, then the slider. Rewrites the alpha byte (RGB kept) and the hex
/// box as it moves, saves the colour on release. Untouched, the colour is never rewritten. True while in use.
/// </summary>
private bool OpacitySlider(Field f, byte[] hex, ref uint argb)
{
ImGuiNET.ImGui.TextUnformatted(f.Label);
float pct = ArgbOpacity.Percent(argb);
if (ImGuiNET.ImGui.SliderFloat(f.Id, ref pct, 0f, 100f, "%.0f%%", ImGuiSliderFlags.AlwaysClamp))
{
argb = ArgbOpacity.WithPercent(argb, pct);
WriteUtf8(hex, argb.ToString("X8"));
}
if (ImGuiNET.ImGui.IsItemDeactivatedAfterEdit()) Save(f.Key);
ImGuiNET.ImGui.SetItemTooltip("0% = invisible, 100% = solid. Ctrl+click to type a value");
return ImGuiNET.ImGui.IsItemActive();
}
/// <summary>Label, then the slider; saves on release (or after Ctrl+click typing). True while in use.</summary>
private bool Slider(Field f, ref double value, double min, double max, string format)
{

View file

@ -369,6 +369,8 @@ internal static class RynthCoreShell
new System.Threading.Thread(() =>
{
System.Threading.Thread.Sleep(120);
// Asked for by hand: the reload deferral (EntryPoint.Shutdown) doesn't hold it.
EntryPoint.NoteManualReload();
bool ok = EngineLifecycle.SignalReload();
RynthLog.Info($"ERl: SignalReload returned {ok}.");
})

View file

@ -0,0 +1,135 @@
// ============================================================================
// RynthCore.Engine - ImGui/UiDropTargets.cs
//
// AC items dropped on the engine's ImGui panels (2026-10-05). A face that takes
// drops publishes its body rect every frame it draws (Publish); when the player
// drags an item out of an AC item list (a pack, the main inventory) and lets go
// over that rect, Compatibility/UiElementHooks' UIElement::CatchDroppedItem
// detour asks TryClaim. A claimed drop never reaches AC: the detour answers
// "not caught" (false), which is AC's own drop-rejected path, so the item stays
// where it was. The face picks the item up with TryTake on its next draw.
//
// All on AC's main thread: faces draw in EndScene, the detour runs inside AC's
// StopDragandDrop. A target not published for StaleMs (panel closed, hidden,
// between characters) never claims.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Runtime.InteropServices;
namespace RynthCore.Engine.ImGuiBackend;
internal static class UiDropTargets
{
private const long StaleMs = 500;
private sealed class Target
{
public required string Key;
public required string PanelTitle;
public bool Popped;
public Vector2 Min, Max; // ImGui coordinates of the game window's client area (docked)
public long SeenMs;
public bool Accepting;
public bool HasDrop;
public uint ItemId, SpellId;
}
[StructLayout(LayoutKind.Sequential)] private struct POINT { public int X, Y; }
[DllImport("user32.dll")] private static extern bool GetCursorPos(out POINT p);
private static readonly Dictionary<string, Target> Targets = new(StringComparer.Ordinal);
private static readonly object Sync = new();
/// <summary>
/// Once per frame from a face's Draw: <paramref name="min"/>..<paramref name="max"/> is the
/// body in screen coordinates as ImGui sees them (FaceKit.Begin's origin and size).
/// <paramref name="accepting"/> false: drawn, but a drop now wouldn't be used (it then
/// goes to AC as usual). Popped-out faces hit-test against their own window.
/// </summary>
public static void Publish(string key, string panelTitle, Vector2 min, Vector2 max, bool accepting)
{
lock (Sync)
{
if (!Targets.TryGetValue(key, out Target? t))
Targets[key] = t = new Target { Key = key, PanelTitle = panelTitle };
t.Popped = ImGuiPopOuts.InPopOutFrame;
t.Min = min;
t.Max = max;
t.Accepting = accepting;
t.SeenMs = Environment.TickCount64;
}
}
/// <summary>
/// UIElement::CatchDroppedItem detour, AC's main thread: is the cursor over a live,
/// accepting target? Then that target takes the item and the caller keeps it from AC.
/// </summary>
public static bool TryClaim(uint itemId, uint spellId, out string key)
{
key = string.Empty;
if (itemId == 0)
return false;
long now = Environment.TickCount64;
lock (Sync)
{
foreach (Target t in Targets.Values)
{
if (!t.Accepting || now - t.SeenMs > StaleMs || !IsCursorOver(t))
continue;
t.HasDrop = true;
t.ItemId = itemId;
t.SpellId = spellId;
key = t.Key;
return true;
}
}
return false;
}
/// <summary>The face's draw: an item dropped on it since the last call.</summary>
public static bool TryTake(string key, out uint itemId)
{
itemId = 0;
lock (Sync)
{
if (!Targets.TryGetValue(key, out Target? t) || !t.HasDrop)
return false;
t.HasDrop = false;
itemId = t.ItemId;
return itemId != 0;
}
}
/// <summary>The cursor is over the target now (the face's "drop here" highlight).</summary>
public static bool IsCursorOver(string key)
{
lock (Sync)
return Targets.TryGetValue(key, out Target? t) && IsCursorOver(t);
}
private static bool IsCursorOver(Target t)
{
if (t.Popped)
return ImGuiPopOuts.IsCursorOver(t.PanelTitle);
if (!GetCursorPos(out POINT p))
return false;
Vector2 local = new Vector2(p.X, p.Y) - ImGuiPopOuts.ClientOriginOnScreen();
return local.X >= t.Min.X && local.Y >= t.Min.Y && local.X < t.Max.X && local.Y < t.Max.Y;
}
public static string Describe()
{
long now = Environment.TickCount64;
lock (Sync)
{
if (Targets.Count == 0)
return "Drop targets: none drawn yet.";
var parts = new List<string>();
foreach (Target t in Targets.Values)
parts.Add($"{t.Key} ({(now - t.SeenMs <= StaleMs ? (t.Accepting ? "live" : "drawn, not accepting") : "not drawn")}{(t.Popped ? ", popped out" : string.Empty)})");
return "Drop targets: " + string.Join(", ", parts) + ".";
}
}
}

View file

@ -898,6 +898,15 @@ internal static unsafe class Win32Backend
}
}
// ── Remote tap-to-click (the phone, via the StatusAgent's PostMessage) ──
// A posted mouse message whose point is not where the cursor was when it was queued did not come
// from the mouse: it is the StatusAgent clicking where the phone tapped. Without this, the ImGui
// capture below judged it by the REAL cursor (NewFrame's GetCursorPos): on the focused client,
// with the PC's mouse parked over a RynthCore panel, every remote click was eaten, and the
// phone's tap still fed ImGui a fake cursor. Hand it straight to AC instead.
if (IsRemoteClientMouse(hWnd, msg, lParam))
return CallWindowProcA(_originalWndProc, hWnd, msg, wParam, lParam);
// ── Chat capture: consume all key input for the chat TextBox ────
// Game HWND keeps Win32 focus throughout; callbacks dispatch Text
// updates to the panel on Avalonia's UI thread — no Avalonia focus needed.
@ -1486,6 +1495,29 @@ internal static unsafe class Win32Backend
};
}
[DllImport("user32.dll")]
private static extern uint GetMessagePos();
/// <summary>
/// True for a client-area mouse message another process posted (the StatusAgent's remote click):
/// Windows stamps every queued message with the cursor position at the time it was queued
/// (GetMessagePos). Mouse input carries that same point in lParam; a PostMessage from elsewhere
/// carries its own point while the stamp is wherever the real cursor sat. A 2 px slack covers
/// rounding. Only the move/click messages whose lParam is client coordinates are tested (the wheel's
/// lParam is screen coordinates).
/// </summary>
private static bool IsRemoteClientMouse(IntPtr hWnd, uint msg, IntPtr lParam)
{
if (msg != WM_MOUSEMOVE && msg != WM_LBUTTONDOWN && msg != WM_LBUTTONUP && msg != WM_RBUTTONDOWN && msg != WM_RBUTTONUP)
return false;
uint pos = GetMessagePos();
var stamp = new POINT { X = (short)(pos & 0xFFFF), Y = (short)((pos >> 16) & 0xFFFF) };
if (!ScreenToClient(hWnd, ref stamp))
return false;
int x = (short)((long)lParam & 0xFFFF), y = (short)(((long)lParam >> 16) & 0xFFFF);
return Math.Abs(stamp.X - x) > 2 || Math.Abs(stamp.Y - y) > 2;
}
private static bool IsMouseMessage(uint msg)
{
return msg >= WM_MOUSEMOVE && msg <= WM_MBUTTONUP