Snapshot for release 2026.10.28.1 (internal de8d80b)
This commit is contained in:
parent
f4246dbbd0
commit
8728446a27
46 changed files with 2522 additions and 259 deletions
|
|
@ -18,15 +18,32 @@
|
|||
// InitKeymap): InitializeKeymap (+0x08, clears), AddKeyMap_(path) (+0x28,
|
||||
// the file), AddKeyMap(0x10000001) and AddKeyMap(1) (+0x2C, the game's
|
||||
// fixed maps from the dat);
|
||||
// 4. the file's new time goes in "<keymap>.rynthcore" beside it.
|
||||
// Every other client looks at the file once a second and loads it the same
|
||||
// way when it changed with that time noted. A file a closing client wrote (AC's
|
||||
// own save on shutdown) isn't loaded: that would throw away keys the others
|
||||
// changed in Configure Keyboard and haven't saved, as AC would never do.
|
||||
// 4. the edits made (AcKeymapText.Edit: bind K to A / K off A / K off
|
||||
// everything) go in "<keymap>.rynthcore" beside it, one change per stamp.
|
||||
//
|
||||
// Following (2026-10-27, a player: keys deleted in Configure Keyboard came back
|
||||
// mid-fight). Every other client looks at "<keymap>.rynthcore" once a second
|
||||
// (and before a change of its own) and makes each change it hasn't made yet to
|
||||
// ITS OWN keys: AC writes them (SaveKeyMap) to a scratch file in %TEMP%, the
|
||||
// same edits go in that text, and the scratch is loaded as above, then
|
||||
// deleted. Its keys changed in Configure Keyboard and not saved stay; the
|
||||
// shared change lands. It never loads the shared file for another client's
|
||||
// change (that file holds the changing client's keys, not its own), so a file
|
||||
// a closing client wrote (AC's own save) is never loaded either. Anything that
|
||||
// fails before the load leaves the keys as they are; an edited scratch that
|
||||
// didn't load is followed by the client's own keys as AC wrote them.
|
||||
// What was made last ("RYNTHCORE_KEYMAP_SEEN", the process's environment)
|
||||
// outlives an engine hot reload, so a reload makes nothing again; a new client
|
||||
// makes only changes newer than its start (AC loaded the file after older ones).
|
||||
// An older RynthCore's marker (the file's time alone: what changed isn't known)
|
||||
// is logged and not loaded: loading the whole file is what lost the keys.
|
||||
//
|
||||
// A key for one of RynthCore's own commands (RynthDefective's slots past the
|
||||
// game's 18: "/rdef use 2") is an engine hotkey; it takes its key the same way
|
||||
// (off AC's actions too, so no key shows on two slots).
|
||||
// (off AC's actions too, so no key shows on two slots). Op.BindCommandOnly
|
||||
// (SetActionKey op 3, for RynthDefective's independent bar) sets the engine
|
||||
// hotkey alone: AC's keymap isn't touched, no client loads anything, and the
|
||||
// hotkey simply answers first.
|
||||
//
|
||||
// ICIDM::s_cidm (the CInputManager*, by code-xref), the four functions and
|
||||
// PStringBase<char>(const char*) (0x00401340) are found by pattern only, and
|
||||
|
|
@ -38,6 +55,7 @@ using System;
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
|
@ -159,10 +177,14 @@ internal static unsafe class AcKeymapLive
|
|||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
private static extern int GetShortPathNameW(string longPath, StringBuilder shortPath, int size);
|
||||
|
||||
// ── Watching (every client) ──────────────────────────────────────────────
|
||||
// ── Following another client's change (every client) ─────────────────────
|
||||
|
||||
private static DateTime _seenUtc = DateTime.MinValue;
|
||||
private static string _seenFile = string.Empty;
|
||||
private const string SeenEnv = "RYNTHCORE_KEYMAP_SEEN"; // the newest change made here; the process's, so it outlives a hot reload
|
||||
private const int KeepChanges = 64; // changes kept in "<keymap>.rynthcore"
|
||||
|
||||
private static long _seenStamp = -1; // -1: not read yet (SeenStamp)
|
||||
private static string _markerFile = string.Empty;
|
||||
private static DateTime _markerUtc = DateTime.MinValue;
|
||||
private static long _nextCheckMs;
|
||||
private static readonly DateTime ProcessStartUtc = SafeStartUtc();
|
||||
|
||||
|
|
@ -174,61 +196,187 @@ internal static unsafe class AcKeymapLive
|
|||
|
||||
private static string MarkerPath(string keymap) => keymap + ".rynthcore";
|
||||
|
||||
private static long ReadMarker(string keymap)
|
||||
/// <summary>
|
||||
/// The newest change this client has made. After an engine hot reload: what the last generation made (so the
|
||||
/// reload makes nothing again). A new client: its start (AC loaded the file after anything older).
|
||||
/// </summary>
|
||||
private static long SeenStamp
|
||||
{
|
||||
try
|
||||
get
|
||||
{
|
||||
string m = MarkerPath(keymap);
|
||||
return File.Exists(m) && long.TryParse(File.ReadAllText(m).Trim(), out long t) ? t : 0;
|
||||
if (_seenStamp < 0)
|
||||
{
|
||||
string? carried = null;
|
||||
try { carried = Environment.GetEnvironmentVariable(SeenEnv); } catch { }
|
||||
long start = ProcessStartUtc.Ticks;
|
||||
_seenStamp = long.TryParse(carried, NumberStyles.None, CultureInfo.InvariantCulture, out long s) && s > start ? s : start;
|
||||
}
|
||||
return _seenStamp;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>Game thread, after AC's tick: the queued changes, then (once a second) another client's change.</summary>
|
||||
private static void MarkSeen(long stamp)
|
||||
{
|
||||
if (stamp <= SeenStamp) return;
|
||||
_seenStamp = stamp;
|
||||
try { Environment.SetEnvironmentVariable(SeenEnv, stamp.ToString(CultureInfo.InvariantCulture)); } catch { }
|
||||
}
|
||||
|
||||
/// <summary>Game thread, after AC's tick: another client's change (once a second, and before one made here), then the queued changes.</summary>
|
||||
public static void Tick()
|
||||
{
|
||||
if (!CanChange || !LoginLifecycleHooks.HasObservedLoginComplete) return;
|
||||
if (!LoginLifecycleHooks.HasObservedLoginComplete) return;
|
||||
if (CanChange)
|
||||
{
|
||||
long now = Environment.TickCount64;
|
||||
// Before a change of this client's own too: its keys, saved first, then hold the other client's change.
|
||||
if (now >= _nextCheckMs || !Requests.IsEmpty)
|
||||
{
|
||||
_nextCheckMs = now + 1000;
|
||||
try { FollowOthers(); }
|
||||
catch (Exception ex) { RynthLog.Compat($"AcKeymapLive: following another client's key change failed: {ex.GetType().Name}: {ex.Message}"); }
|
||||
}
|
||||
}
|
||||
// An engine hotkey alone (BindCommandOnly, a command's unbind) needs none of AC's functions.
|
||||
DrainRequests();
|
||||
if (_dumpTo is { } dump)
|
||||
if (CanChange && _dumpTo is { } dump)
|
||||
{
|
||||
_dumpTo = null;
|
||||
string said = SaveOwn(dump) ? $"AC's keys in memory written to {dump}." : "AC couldn't write its keys there.";
|
||||
RynthLog.Compat("AcKeymapLive: " + said);
|
||||
AcMainThreadQueue.EnqueueWriteToChat("[RynthCore] " + said, 1);
|
||||
}
|
||||
long now = Environment.TickCount64;
|
||||
if (now < _nextCheckMs) return;
|
||||
_nextCheckMs = now + 1000;
|
||||
}
|
||||
|
||||
/// <summary>The changes in "<keymap>.rynthcore" this client hasn't made yet, made to its own keys. Game thread.</summary>
|
||||
private static void FollowOthers()
|
||||
{
|
||||
string file = AcKeymap.FilePath;
|
||||
if (file.Length == 0) return;
|
||||
string marker = MarkerPath(file);
|
||||
if (!File.Exists(marker)) return;
|
||||
DateTime w = File.GetLastWriteTimeUtc(marker);
|
||||
if (w == _markerUtc && string.Equals(marker, _markerFile, StringComparison.OrdinalIgnoreCase)) return;
|
||||
string text;
|
||||
try { text = File.ReadAllText(marker); }
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { return; } // being written: the next look
|
||||
_markerFile = marker;
|
||||
_markerUtc = w;
|
||||
|
||||
List<AcKeymapText.Change> log = AcKeymapText.ParseChanges(text, out bool older);
|
||||
if (older)
|
||||
{
|
||||
// It says the file changed, not what: loading the whole file would throw away this client's keys changed in
|
||||
// Configure Keyboard and not saved (the bug this replaced). The change is in the file for the next start.
|
||||
if (w > ProcessStartUtc)
|
||||
RynthLog.Compat("AcKeymapLive: an older RynthCore changed a key in another client; not loaded here (the whole file would " +
|
||||
"replace keys changed in this client and not saved). It is in the keymap for the next start.");
|
||||
return;
|
||||
}
|
||||
List<AcKeymapText.Change> pending = AcKeymapText.Pending(log, SeenStamp, Environment.ProcessId);
|
||||
long newest = AcKeymapText.Newest(log);
|
||||
if (pending.Count > 0)
|
||||
{
|
||||
try { Follow(pending); }
|
||||
catch (Exception ex)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys; not made here ({ex.GetType().Name}: {ex.Message}), this client's keys are left as they are.");
|
||||
}
|
||||
}
|
||||
MarkSeen(newest); // made or not (logged), each change is tried once
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Another client's changes, made to this client's own keys: AC writes them to a scratch file, the same edits
|
||||
/// go in, and the scratch is loaded as AC loads its keymap. Anything failing before the load: logged, keys left
|
||||
/// as they are. Game thread.
|
||||
/// </summary>
|
||||
private static void Follow(List<AcKeymapText.Change> pending)
|
||||
{
|
||||
var what = new List<string>();
|
||||
foreach (AcKeymapText.Change c in pending)
|
||||
foreach (AcKeymapText.Edit e in c.Edits) what.Add(AcKeymapText.Describe(e));
|
||||
string changes = string.Join("; ", what);
|
||||
|
||||
IntPtr im = InputManager();
|
||||
if (im == IntPtr.Zero)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); not made here: the input manager isn't there.");
|
||||
return;
|
||||
}
|
||||
string scratch = Path.Combine(Path.GetTempPath(), $"rynthcore-keymap-{Environment.ProcessId}.keymap");
|
||||
try
|
||||
{
|
||||
string file = AcKeymap.FilePath;
|
||||
if (file.Length == 0) return;
|
||||
DateTime t = File.GetLastWriteTimeUtc(file);
|
||||
bool first = !string.Equals(file, _seenFile, StringComparison.OrdinalIgnoreCase);
|
||||
if (!first && t == _seenUtc) return;
|
||||
_seenFile = file;
|
||||
_seenUtc = t;
|
||||
// RynthCore's change (the time noted beside it); at the first look, only one made after this client loaded the file.
|
||||
if (ReadMarker(file) != t.Ticks) return;
|
||||
if (first && t <= ProcessStartUtc.AddSeconds(5)) return;
|
||||
Reload(file, "another client changed a key");
|
||||
// There first, so a folder name AC's file functions can't take has a short (8.3) form.
|
||||
File.WriteAllBytes(scratch, Array.Empty<byte>());
|
||||
if (!SaveOwn(scratch))
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); AC couldn't write this client's keys to {scratch}, so they are left as they are.");
|
||||
return;
|
||||
}
|
||||
// Latin-1: AC's bytes back exactly as it wrote them (the edits are ASCII).
|
||||
string own = File.ReadAllText(scratch, Encoding.Latin1);
|
||||
List<string> lines = AcKeymapText.Split(own, out string nl);
|
||||
if (AcKeymapText.Bindings(lines).Count == 0)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); AC wrote no keys for this client, so they are left as they are.");
|
||||
return;
|
||||
}
|
||||
int r = AcKeymapText.ApplyChanges(lines, pending, out string err);
|
||||
if (r < 0)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); it can't be made here ({err}), so this client's keys are left as they are.");
|
||||
return;
|
||||
}
|
||||
if (r == 0)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); this client has them already.");
|
||||
return;
|
||||
}
|
||||
File.WriteAllText(scratch, AcKeymapText.Join(lines, nl), Encoding.Latin1);
|
||||
int loaded = LoadKeys(im, scratch);
|
||||
if (loaded > 0)
|
||||
{
|
||||
AcKeymap.Invalidate();
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys; made here too, this client's own keys kept ({changes}).");
|
||||
return;
|
||||
}
|
||||
if (loaded < 0)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); AC can't open {scratch}, so this client's keys are left as they are.");
|
||||
return;
|
||||
}
|
||||
// The edited keys didn't load (AC cleared them): this client's own back, as AC wrote them; else the file, as AC starts.
|
||||
bool back = false;
|
||||
try
|
||||
{
|
||||
File.WriteAllText(scratch, own, Encoding.Latin1);
|
||||
back = LoadKeys(im, scratch) > 0;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { }
|
||||
RynthLog.Compat($"AcKeymapLive: another client changed keys ({changes}); AC didn't load them here - " +
|
||||
(back ? "this client's own keys loaded again." : "nor this client's own keys: loading the keymap file."));
|
||||
if (!back) Reload(AcKeymap.FilePath, "this client's own keys didn't load");
|
||||
AcKeymap.Invalidate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
finally
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: watching the keymap failed: {ex.GetType().Name}: {ex.Message}");
|
||||
try { File.Delete(scratch); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Loads the file into AC as AC does when it starts. Game thread.</summary>
|
||||
private static bool Reload(string file, string why)
|
||||
/// <summary>
|
||||
/// AC's keys from <paramref name="file"/> the way gmClient::InitKeymap loads them: InitializeKeymap (clears),
|
||||
/// AddKeyMap_(file), the dat's two fixed maps. 1 loaded; 0 the file didn't load (the game's own keys now); -1
|
||||
/// nothing done (a name AC can't open: the keys as they were). Game thread.
|
||||
/// </summary>
|
||||
private static int LoadKeys(IntPtr im, string file)
|
||||
{
|
||||
IntPtr im = InputManager();
|
||||
if (im == IntPtr.Zero) return false;
|
||||
IntPtr path = AcString(file);
|
||||
if (path == IntPtr.Zero)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: AC can't open '{file}' (its name has letters AC's file functions don't take).");
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
IntPtr vt = Marshal.ReadIntPtr(im);
|
||||
var init = (delegate* unmanaged[Thiscall]<IntPtr, byte>)Marshal.ReadIntPtr(vt, VtInitialize);
|
||||
|
|
@ -239,9 +387,19 @@ internal static unsafe class AcKeymapLive
|
|||
if (!loaded) init(im); // as gmClient::InitKeymap: a file that didn't load leaves the game's own keys
|
||||
db(im, FixedMapA);
|
||||
db(im, FixedMapB);
|
||||
return loaded ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>Loads the shared keymap file into AC as AC does when it starts (this client's own change). Game thread.</summary>
|
||||
private static bool Reload(string file, string why)
|
||||
{
|
||||
IntPtr im = InputManager();
|
||||
if (im == IntPtr.Zero || file.Length == 0) return false;
|
||||
int r = LoadKeys(im, file);
|
||||
if (r < 0) return false;
|
||||
AcKeymap.Invalidate();
|
||||
RynthLog.Compat($"AcKeymapLive: keys loaded again from {Path.GetFileName(file)} ({why}){(loaded ? "" : " - the file didn't load: the game's default keys")}.");
|
||||
return loaded;
|
||||
RynthLog.Compat($"AcKeymapLive: keys loaded again from {Path.GetFileName(file)} ({why}){(r > 0 ? "" : " - the file didn't load: the game's default keys")}.");
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
/// <summary>This client's keys to the file (AC's own writer). Game thread.</summary>
|
||||
|
|
@ -257,7 +415,8 @@ internal static unsafe class AcKeymapLive
|
|||
|
||||
// ── Changing (queued from any thread, done on the game thread) ───────────
|
||||
|
||||
public enum Op { Bind = 1, Unbind = 2 }
|
||||
/// <summary>SetActionKey's ops (0 is Check). BindCommandOnly: an engine command's hotkey alone, AC's keymap untouched.</summary>
|
||||
public enum Op { Bind = 1, Unbind = 2, BindCommandOnly = 3 }
|
||||
|
||||
private readonly record struct Request(string Action, string Key, Op Op, long QueuedMs);
|
||||
|
||||
|
|
@ -312,15 +471,22 @@ internal static unsafe class AcKeymapLive
|
|||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>Queues binding or unbinding the key; done on the game thread. False (with why) when it can't be.</summary>
|
||||
/// <summary>
|
||||
/// Queues binding or unbinding the key; done on the game thread. False (with why) when it can't be.
|
||||
/// <see cref="Op.BindCommandOnly"/>: an engine command ("/rdef use 3") only; its hotkey alone is set (off
|
||||
/// RynthCore's other hotkeys), AC's keymap is never touched, so it needs none of AC's keymap functions.
|
||||
/// </summary>
|
||||
public static bool Enqueue(string action, string keyText, Op op, out string message)
|
||||
{
|
||||
message = string.Empty;
|
||||
action = action.Trim();
|
||||
keyText = keyText.Trim();
|
||||
if (op is not (Op.Bind or Op.Unbind or Op.BindCommandOnly)) { message = "Unknown op."; return false; }
|
||||
if (!ValidAction(action)) { message = "Not an action."; return false; }
|
||||
if (op == Op.BindCommandOnly && !IsCommand(action)) { message = "Only a RynthCore command (\"/rdef use 3\") takes a key without AC's keymap."; return false; }
|
||||
if (keyText.Length == 0 || keyText.Length > 40) { message = "No key."; return false; }
|
||||
if (op == Op.Bind && !HotkeyKeys.TryParse(keyText, out _, out string err)) { message = err; return false; }
|
||||
if (op is Op.Bind or Op.BindCommandOnly && !HotkeyKeys.TryParse(keyText, out _, out string err)) { message = err; return false; }
|
||||
// A command's unbind and BindCommandOnly change only RynthCore's hotkeys.
|
||||
if (!CanChange && (!IsCommand(action) || op == Op.Bind)) { message = "This client can't change AC's keys (" + _status + ")"; return false; }
|
||||
if (Requests.Count >= 16) { message = "Too many changes at once."; return false; }
|
||||
Requests.Enqueue(new Request(action, keyText, op, Environment.TickCount64));
|
||||
|
|
@ -367,8 +533,8 @@ internal static unsafe class AcKeymapLive
|
|||
Backup(file);
|
||||
SaveOwn(file);
|
||||
List<string> ul = AcKeymapText.Split(File.ReadAllText(file), out string unl);
|
||||
if (!UnbindAc(ul, r.Action, r.Key)) return $"{AcKeymapText.Describe(r.Action)} has no key {r.Key}.";
|
||||
WriteAndLoad(file, ul, unl);
|
||||
if (!UnbindAc(ul, r.Action, r.Key, out AcKeymapText.Edit unbound)) return $"{AcKeymapText.Describe(r.Action)} has no key {r.Key}.";
|
||||
WriteAndLoad(file, ul, unl, new[] { unbound });
|
||||
return $"{r.Key} no longer does {AcKeymapText.Describe(r.Action)}.";
|
||||
}
|
||||
|
||||
|
|
@ -378,8 +544,9 @@ internal static unsafe class AcKeymapLive
|
|||
if (!command && file.Length == 0) return "There is no AC keymap file to change.";
|
||||
|
||||
// AC's side: the key comes off AC's other actions (a command's hotkey would take it before AC anyway).
|
||||
// BindCommandOnly: the hotkey alone; AC keeps its keys (the hotkey answers first), nothing is loaded anywhere.
|
||||
var from = new List<string>();
|
||||
if (file.Length > 0 && dik != null)
|
||||
if (r.Op != Op.BindCommandOnly && file.Length > 0 && dik != null)
|
||||
{
|
||||
List<string> lines = AcKeymapText.Split(File.ReadAllText(file), out string nl);
|
||||
bool metaOk = AcKeymapText.TryMeta(lines, combo.Mods, out uint meta, out string metaErr);
|
||||
|
|
@ -391,14 +558,21 @@ internal static unsafe class AcKeymapLive
|
|||
if (SaveOwn(file)) lines = AcKeymapText.Split(File.ReadAllText(file), out nl);
|
||||
else RynthLog.Compat("AcKeymapLive: couldn't save this client's keys first; changing the file as it is.");
|
||||
List<AcKeymapText.Line> taken;
|
||||
string mods = AcKeymapText.ModsOf(lines, meta);
|
||||
AcKeymapText.Edit edit;
|
||||
if (command)
|
||||
{
|
||||
taken = AcKeymapText.Uses(lines, 0, dik, meta);
|
||||
for (int k = taken.Count - 1; k >= 0; k--) lines.RemoveAt(taken[k].Index);
|
||||
taken = AcKeymapText.Take(lines, 0, dik, meta);
|
||||
edit = new AcKeymapText.Edit(AcKeymapText.EditKind.Take, string.Empty, 0, AcKeymapText.Canonical(dik), mods);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AcKeymapText.Bind(lines, r.Action, 0, dik, meta, out taken, out string bindErr)) return bindErr;
|
||||
edit = new AcKeymapText.Edit(AcKeymapText.EditKind.Bind, r.Action, 0, AcKeymapText.Canonical(dik), mods,
|
||||
AcKeymapText.GroupOf(lines, r.Action, 0, dik, meta));
|
||||
}
|
||||
else if (!AcKeymapText.Bind(lines, r.Action, 0, dik, meta, out taken, out string bindErr)) return bindErr;
|
||||
foreach (AcKeymapText.Line l in taken) from.Add(AcKeymapText.Describe(l.Action));
|
||||
WriteAndLoad(file, lines, nl);
|
||||
WriteAndLoad(file, lines, nl, new[] { edit });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -411,32 +585,89 @@ internal static unsafe class AcKeymapLive
|
|||
return $"{combo} now does {what}" + (from.Count > 0 ? " (taken from " + string.Join(", ", from) + ")." : ".");
|
||||
}
|
||||
|
||||
/// <summary>The edited file written (backed up the first time), its time noted, and loaded here; the others follow within a second.</summary>
|
||||
private static void WriteAndLoad(string file, List<string> lines, string newline)
|
||||
/// <summary>
|
||||
/// The edited file written (backed up the first time) and loaded here, and its edits recorded in
|
||||
/// "<keymap>.rynthcore"; the others make them to their own keys within a second.
|
||||
/// </summary>
|
||||
private static void WriteAndLoad(string file, List<string> lines, string newline, IReadOnlyList<AcKeymapText.Edit> edits)
|
||||
{
|
||||
Backup(file);
|
||||
string tmp = file + ".tmp";
|
||||
File.WriteAllText(tmp, AcKeymapText.Join(lines, newline), Encoding.ASCII);
|
||||
File.Move(tmp, file, overwrite: true);
|
||||
DateTime t = File.GetLastWriteTimeUtc(file);
|
||||
File.WriteAllText(MarkerPath(file), t.Ticks.ToString(System.Globalization.CultureInfo.InvariantCulture));
|
||||
_seenFile = file;
|
||||
_seenUtc = t;
|
||||
MoveOver(tmp, file);
|
||||
try { Record(file, edits); }
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
RynthLog.Compat($"AcKeymapLive: couldn't note the change for the other clients ({ex.Message}); they get it at their next start.");
|
||||
}
|
||||
Reload(file, "a key changed here");
|
||||
}
|
||||
|
||||
/// <summary>Removes the action's key: by combo ("Ctrl+1") or by the text GetActionKeys showed ("Mouse4").</summary>
|
||||
private static bool UnbindAc(List<string> lines, string action, string keyText)
|
||||
/// <summary>The change added to "<keymap>.rynthcore" (the newest <see cref="KeepChanges"/> kept), written whole.</summary>
|
||||
private static void Record(string file, IReadOnlyList<AcKeymapText.Edit> edits)
|
||||
{
|
||||
string marker = MarkerPath(file);
|
||||
List<AcKeymapText.Change> log = new();
|
||||
try
|
||||
{
|
||||
// An older RynthCore's marker (or none): the log starts here.
|
||||
if (File.Exists(marker)) log = AcKeymapText.ParseChanges(File.ReadAllText(marker), out _);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException) { }
|
||||
long stamp = AcKeymapText.NextStamp(log, DateTime.UtcNow.Ticks);
|
||||
log = AcKeymapText.Append(log, new AcKeymapText.Change(stamp, Environment.ProcessId, new List<AcKeymapText.Edit>(edits)), KeepChanges);
|
||||
string tmp = marker + "." + Environment.ProcessId.ToString(CultureInfo.InvariantCulture) + ".tmp";
|
||||
File.WriteAllText(tmp, AcKeymapText.FormatChanges(log), Encoding.ASCII);
|
||||
try { MoveOver(tmp, marker); }
|
||||
catch
|
||||
{
|
||||
try { File.Delete(tmp); } catch { }
|
||||
throw;
|
||||
}
|
||||
// Made here: never again by this client (nor by its next engine after a hot reload).
|
||||
MarkSeen(stamp);
|
||||
_markerFile = marker;
|
||||
_markerUtc = File.GetLastWriteTimeUtc(marker);
|
||||
}
|
||||
|
||||
/// <summary>Replaces <paramref name="dest"/> with <paramref name="tmp"/>; a few tries, as another client may be reading it that moment.</summary>
|
||||
private static void MoveOver(string tmp, string dest)
|
||||
{
|
||||
for (int attempt = 1; ; attempt++)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Move(tmp, dest, overwrite: true);
|
||||
return;
|
||||
}
|
||||
catch (Exception ex) when (attempt < 5 && ex is IOException or UnauthorizedAccessException)
|
||||
{
|
||||
System.Threading.Thread.Sleep(15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes the action's key: by combo ("Ctrl+1") or by the text GetActionKeys showed ("Mouse4").
|
||||
/// <paramref name="edit"/>: the binding removed, for the other clients.
|
||||
/// </summary>
|
||||
private static bool UnbindAc(List<string> lines, string action, string keyText, out AcKeymapText.Edit edit)
|
||||
{
|
||||
edit = default;
|
||||
if (HotkeyKeys.TryParse(keyText, out KeyCombo combo, out _) && AcKeymapText.DikForVk(combo.Vk) is { } dik
|
||||
&& AcKeymapText.TryMeta(lines, combo.Mods, out uint meta, out _)
|
||||
&& AcKeymapText.Unbind(lines, action, 0, dik, meta))
|
||||
{
|
||||
edit = new AcKeymapText.Edit(AcKeymapText.EditKind.Unbind, action, 0, AcKeymapText.Canonical(dik), AcKeymapText.ModsOf(lines, meta));
|
||||
return true;
|
||||
}
|
||||
foreach (AcKeymapText.Line l in AcKeymapText.Bindings(lines))
|
||||
{
|
||||
if (!l.Action.Equals(action, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (AcKeymap.Describe(new AcKeymap.Binding(l.Device, l.Dik, l.Meta)).Equals(keyText, StringComparison.OrdinalIgnoreCase))
|
||||
return AcKeymapText.Unbind(lines, action, l.Device, l.Dik, l.Meta);
|
||||
if (!AcKeymap.Describe(new AcKeymap.Binding(l.Device, l.Dik, l.Meta)).Equals(keyText, StringComparison.OrdinalIgnoreCase)) continue;
|
||||
if (!AcKeymapText.Unbind(lines, action, l.Device, l.Dik, l.Meta)) return false;
|
||||
edit = new AcKeymapText.Edit(AcKeymapText.EditKind.Unbind, action, l.Device, l.Dik, AcKeymapText.ModsOf(lines, l.Meta));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,10 +24,17 @@
|
|||
// has Home and Ctrl+C). The key names written are the ones AC writes itself
|
||||
// (DIK_PGUP, DIK_UPARROW...), all in its own name table; any name it accepts
|
||||
// is matched (DIK_PRIOR is DIK_PGUP).
|
||||
//
|
||||
// A change every client makes (2026-10-27: a player's own Configure Keyboard
|
||||
// keys reverted mid-fight when another client changed one): the client that
|
||||
// changes a key records the edits it made (Edit, Change) in "<keymap>.
|
||||
// rynthcore"; every other client makes the same edits to its OWN keys (AC
|
||||
// writes them out, ApplyChanges, AC loads them), never to the shared file's.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using RynthCore.Engine.Hotkeys;
|
||||
|
|
@ -194,10 +201,14 @@ internal static class AcKeymapText
|
|||
/// <summary>
|
||||
/// Binds the key to <paramref name="action"/>, taking it from every other action that has it (game
|
||||
/// groups). <paramref name="taken"/>: the bindings it came off. Returns false (lines unchanged) with
|
||||
/// <paramref name="error"/> when there is nowhere to put it.
|
||||
/// <paramref name="error"/> when there is nowhere to put it. <paramref name="group"/>: where a new line
|
||||
/// goes when the action has none yet (another client's change: the group it went in there), before
|
||||
/// <see cref="DefaultGroup"/>.
|
||||
/// </summary>
|
||||
public static bool Bind(List<string> lines, string action, int device, string dik, uint meta, out List<Line> taken, out string error)
|
||||
public static bool Bind(List<string> lines, string action, int device, string dik, uint meta, out List<Line> taken, out string error,
|
||||
string? group = null)
|
||||
{
|
||||
string? recordedGroup = string.IsNullOrEmpty(group) || IsTextGroup(group) ? null : group;
|
||||
error = string.Empty;
|
||||
string d = Canonical(dik);
|
||||
List<Line> all = Bindings(lines);
|
||||
|
|
@ -207,7 +218,7 @@ internal static class AcKeymapText
|
|||
&& l.Action.Equals(action, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
// Where the new line goes: after the action's last line, else at the end of its group.
|
||||
string? group = null;
|
||||
group = null;
|
||||
int insertAt = -1;
|
||||
if (!already)
|
||||
{
|
||||
|
|
@ -215,7 +226,7 @@ internal static class AcKeymapText
|
|||
if (l.Action.Equals(action, StringComparison.OrdinalIgnoreCase) && !IsTextGroup(l.Group)) { group = l.Group; insertAt = l.Index + 1; }
|
||||
if (insertAt < 0)
|
||||
{
|
||||
group = DefaultGroup(action);
|
||||
group = recordedGroup ?? DefaultGroup(action);
|
||||
if (group == null) { error = $"No group for {action} in the keymap."; taken = new(); return false; }
|
||||
}
|
||||
}
|
||||
|
|
@ -262,6 +273,277 @@ internal static class AcKeymapText
|
|||
return mine.Count > 0;
|
||||
}
|
||||
|
||||
/// <summary>Takes the key off every action that has it in the game's groups (an engine command's key); the bindings removed.</summary>
|
||||
public static List<Line> Take(List<string> lines, int device, string dik, uint meta)
|
||||
{
|
||||
List<Line> uses = Uses(lines, device, dik, meta);
|
||||
for (int k = uses.Count - 1; k >= 0; k--) lines.RemoveAt(uses[k].Index);
|
||||
return uses;
|
||||
}
|
||||
|
||||
/// <summary>The game group the action's binding of this key is in ("" when it has none).</summary>
|
||||
public static string GroupOf(List<string> lines, string action, int device, string dik, uint meta)
|
||||
{
|
||||
string d = Canonical(dik);
|
||||
List<Line> all = Bindings(lines);
|
||||
int i = all.FindIndex(x => x.Device == device && x.Dik == d && x.Meta == meta && !IsTextGroup(x.Group)
|
||||
&& x.Action.Equals(action, StringComparison.OrdinalIgnoreCase));
|
||||
return i >= 0 ? all[i].Group : string.Empty;
|
||||
}
|
||||
|
||||
// ── A change every client makes ─────────────────────────────────────────
|
||||
//
|
||||
// "<keymap>.rynthcore", one line per edit, oldest first:
|
||||
// RynthCore keymap changes 2
|
||||
// <stamp> <pid> bind|unbind|take <action, or - for take> <device> <key> <modifiers, or -> <group, or ->
|
||||
// stamp: the change's UTC ticks (every edit of one change has it; each change's is past the last's), pid:
|
||||
// the client that made it. The modifiers are each metakey bit by its key names ("DIK_LCONTROL|DIK_RCONTROL+
|
||||
// DIK_LSHIFT"), so a keymap numbering its MetaKeys differently gets the same keys; "0x00000005" is a raw mask
|
||||
// (a bit no metakey names). The group (a bind's): where the line went, for a keymap with no line for the
|
||||
// action yet. An older RynthCore wrote just the keymap's time there (one number): that says the file
|
||||
// changed, not what.
|
||||
|
||||
/// <summary>Bind: the action gets the key, which comes off every other game action. Unbind: off the action. Take: off every game action.</summary>
|
||||
public enum EditKind { Bind, Unbind, Take }
|
||||
|
||||
/// <summary>
|
||||
/// One edit of a change. <see cref="Action"/> is "" for Take; <see cref="Mods"/> as <see cref="ModsOf"/>
|
||||
/// writes it; <see cref="Group"/> a bind's group where it was made ("" none).
|
||||
/// </summary>
|
||||
internal readonly record struct Edit(EditKind Kind, string Action, int Device, string Dik, string Mods, string Group = "");
|
||||
|
||||
/// <summary>One change: its stamp (UTC ticks), the client that made it, its edits in order.</summary>
|
||||
internal sealed record Change(long Stamp, int Pid, List<Edit> Edits);
|
||||
|
||||
public const string ChangesHeader = "RynthCore keymap changes 2";
|
||||
private const string ChangesHeaderPrefix = "RynthCore keymap changes ";
|
||||
|
||||
private static readonly Regex ModsText = new(@"^(0x[0-9A-Fa-f]{1,8}|[A-Za-z0-9_]+(\|[A-Za-z0-9_]+)*(\+[A-Za-z0-9_]+(\|[A-Za-z0-9_]+)*)*)$",
|
||||
RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
/// <summary>
|
||||
/// A modifier mask as the key names of its metakeys in this keymap ("" for none): bits joined by '+', each
|
||||
/// bit's names by '|'. A bit no metakey names goes as the raw mask ("0x00000010").
|
||||
/// </summary>
|
||||
public static string ModsOf(List<string> lines, uint mask)
|
||||
{
|
||||
if (mask == 0) return string.Empty;
|
||||
var names = new Dictionary<int, List<string>>();
|
||||
foreach (KeyValuePair<string, int> kv in MetaKeys(lines))
|
||||
{
|
||||
if (!names.TryGetValue(kv.Value, out List<string>? list)) names[kv.Value] = list = new List<string>();
|
||||
list.Add(kv.Key);
|
||||
}
|
||||
var parts = new List<string>();
|
||||
for (int n = 1; n <= 32; n++)
|
||||
{
|
||||
if ((mask & (1u << (n - 1))) == 0) continue;
|
||||
if (!names.TryGetValue(n, out List<string>? list)) return "0x" + mask.ToString("X8", CultureInfo.InvariantCulture);
|
||||
parts.Add(string.Join("|", list));
|
||||
}
|
||||
return string.Join("+", parts);
|
||||
}
|
||||
|
||||
/// <summary>The mask of <see cref="ModsOf"/>'s text by this keymap's own MetaKeys. False (why) when it has no such modifier.</summary>
|
||||
public static bool TryMaskOf(List<string> lines, string mods, out uint mask, out string error)
|
||||
{
|
||||
mask = 0;
|
||||
error = string.Empty;
|
||||
if (mods.Length == 0) return true;
|
||||
if (mods.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (uint.TryParse(mods.AsSpan(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out mask)) return true;
|
||||
error = $"Not a modifier mask: {mods}.";
|
||||
return false;
|
||||
}
|
||||
Dictionary<string, int> meta = MetaKeys(lines);
|
||||
foreach (string part in mods.Split('+'))
|
||||
{
|
||||
int n = 0;
|
||||
foreach (string name in part.Split('|'))
|
||||
if (meta.TryGetValue(Canonical(name), out n)) break;
|
||||
if (n is < 1 or > 32)
|
||||
{
|
||||
error = $"This keymap has no {part} modifier (MetaKeys).";
|
||||
return false;
|
||||
}
|
||||
mask |= 1u << (n - 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Makes one recorded edit: 1 changed, 0 nothing to do (the keys have it already), -1 can't (why in <paramref name="error"/>).</summary>
|
||||
public static int ApplyEdit(List<string> lines, Edit e, out string error)
|
||||
{
|
||||
if (!TryMaskOf(lines, e.Mods, out uint meta, out error)) return -1;
|
||||
switch (e.Kind)
|
||||
{
|
||||
case EditKind.Bind:
|
||||
{
|
||||
var before = new List<string>(lines);
|
||||
if (!Bind(lines, e.Action, e.Device, e.Dik, meta, out _, out error, e.Group)) return -1;
|
||||
return SameLines(before, lines) ? 0 : 1;
|
||||
}
|
||||
case EditKind.Unbind:
|
||||
return Unbind(lines, e.Action, e.Device, e.Dik, meta) ? 1 : 0;
|
||||
case EditKind.Take:
|
||||
return Take(lines, e.Device, e.Dik, meta).Count > 0 ? 1 : 0;
|
||||
default:
|
||||
error = "Not an edit.";
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Every edit of the changes, in order, on a copy of <paramref name="lines"/>: the lines are changed only
|
||||
/// when all of them could be made. 1 changed, 0 nothing to do, -1 one couldn't be made (why in
|
||||
/// <paramref name="error"/>; the lines as they were).
|
||||
/// </summary>
|
||||
public static int ApplyChanges(List<string> lines, IEnumerable<Change> changes, out string error)
|
||||
{
|
||||
error = string.Empty;
|
||||
var work = new List<string>(lines);
|
||||
foreach (Change c in changes)
|
||||
foreach (Edit e in c.Edits)
|
||||
if (ApplyEdit(work, e, out string err) < 0)
|
||||
{
|
||||
error = $"{Describe(e)}: {err}";
|
||||
return -1;
|
||||
}
|
||||
if (SameLines(work, lines)) return 0;
|
||||
lines.Clear();
|
||||
lines.AddRange(work);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// <summary>An edit as the log reads: "bind UseQuickSlot_5 DIK_F5 DIK_LCONTROL|DIK_RCONTROL".</summary>
|
||||
public static string Describe(Edit e) =>
|
||||
KindName(e.Kind) + (e.Action.Length > 0 ? " " + e.Action : "") + (e.Device != 0 ? $" device {e.Device}" : "") + " " + e.Dik
|
||||
+ (e.Mods.Length > 0 ? " " + e.Mods : "");
|
||||
|
||||
private static bool SameLines(List<string> a, List<string> b)
|
||||
{
|
||||
if (a.Count != b.Count) return false;
|
||||
for (int i = 0; i < a.Count; i++)
|
||||
if (!string.Equals(a[i], b[i], StringComparison.Ordinal)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static string KindName(EditKind k) => k switch { EditKind.Bind => "bind", EditKind.Unbind => "unbind", _ => "take" };
|
||||
|
||||
private static bool TryKind(string s, out EditKind k)
|
||||
{
|
||||
switch (s)
|
||||
{
|
||||
case "bind": k = EditKind.Bind; return true;
|
||||
case "unbind": k = EditKind.Unbind; return true;
|
||||
case "take": k = EditKind.Take; return true;
|
||||
default: k = EditKind.Take; return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The log's text (<see cref="ChangesHeader"/>, then one line per edit).</summary>
|
||||
public static string FormatChanges(IReadOnlyList<Change> log)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append(ChangesHeader).Append("\r\n");
|
||||
foreach (Change c in log)
|
||||
foreach (Edit e in c.Edits)
|
||||
{
|
||||
sb.Append(c.Stamp.ToString(CultureInfo.InvariantCulture)).Append(' ')
|
||||
.Append(c.Pid.ToString(CultureInfo.InvariantCulture)).Append(' ')
|
||||
.Append(KindName(e.Kind)).Append(' ')
|
||||
.Append(e.Action.Length > 0 ? e.Action : "-").Append(' ')
|
||||
.Append(e.Device.ToString(CultureInfo.InvariantCulture)).Append(' ')
|
||||
.Append(e.Dik).Append(' ')
|
||||
.Append(e.Mods.Length > 0 ? e.Mods : "-").Append(' ')
|
||||
.Append(e.Group.Length > 0 ? e.Group : "-").Append("\r\n");
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The changes in a "<keymap>.rynthcore" file's text, by stamp. <paramref name="older"/>: it is an
|
||||
/// older RynthCore's marker (the keymap's time alone, no edits). A change with a line this version can't
|
||||
/// read is left out whole (never made in part); so is anything in a text that is neither.
|
||||
/// </summary>
|
||||
public static List<Change> ParseChanges(string text, out bool older)
|
||||
{
|
||||
older = false;
|
||||
var list = new List<Change>();
|
||||
List<string> lines = Split(text ?? string.Empty, out _);
|
||||
int i = 0;
|
||||
while (i < lines.Count && lines[i].Trim().Length == 0) i++;
|
||||
if (i >= lines.Count) return list;
|
||||
string first = lines[i].Trim();
|
||||
if (long.TryParse(first, NumberStyles.None, CultureInfo.InvariantCulture, out _)) { older = true; return list; }
|
||||
if (!first.StartsWith(ChangesHeaderPrefix, StringComparison.Ordinal)
|
||||
|| !int.TryParse(first.AsSpan(ChangesHeaderPrefix.Length), NumberStyles.None, CultureInfo.InvariantCulture, out int version)
|
||||
|| version < 2)
|
||||
return list;
|
||||
|
||||
var bad = new HashSet<(long, int)>();
|
||||
for (i++; i < lines.Count; i++)
|
||||
{
|
||||
string[] f = lines[i].Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (f.Length == 0 || f[0].StartsWith('#')) continue;
|
||||
if (f.Length < 2 || !long.TryParse(f[0], NumberStyles.None, CultureInfo.InvariantCulture, out long stamp) || stamp <= 0
|
||||
|| !int.TryParse(f[1], NumberStyles.None, CultureInfo.InvariantCulture, out int pid))
|
||||
continue; // not even whose: nothing to leave out
|
||||
bool ok = f.Length == 8 && TryKind(f[2], out EditKind kind)
|
||||
&& (kind == EditKind.Take ? f[3] == "-" : Name.IsMatch(f[3]))
|
||||
&& int.TryParse(f[4], NumberStyles.None, CultureInfo.InvariantCulture, out int device) && device <= 15
|
||||
&& Name.IsMatch(f[5])
|
||||
&& (f[6] == "-" || ModsText.IsMatch(f[6]))
|
||||
&& (f[7] == "-" || Name.IsMatch(f[7]));
|
||||
if (!ok) { bad.Add((stamp, pid)); continue; }
|
||||
TryKind(f[2], out kind);
|
||||
var edit = new Edit(kind, kind == EditKind.Take ? string.Empty : f[3], int.Parse(f[4], CultureInfo.InvariantCulture),
|
||||
Canonical(f[5]), f[6] == "-" ? string.Empty : f[6], f[7] == "-" ? string.Empty : f[7]);
|
||||
Change? c = list.Count > 0 && list[^1].Stamp == stamp && list[^1].Pid == pid ? list[^1]
|
||||
: list.Find(x => x.Stamp == stamp && x.Pid == pid);
|
||||
if (c == null) list.Add(c = new Change(stamp, pid, new List<Edit>()));
|
||||
c.Edits.Add(edit);
|
||||
}
|
||||
list.RemoveAll(c => bad.Contains((c.Stamp, c.Pid)));
|
||||
// By stamp, keeping the file's order for equal ones (List.Sort isn't stable).
|
||||
var ordered = new List<(Change C, int At)>(list.Count);
|
||||
for (int k = 0; k < list.Count; k++) ordered.Add((list[k], k));
|
||||
ordered.Sort((a, b) => a.C.Stamp != b.C.Stamp ? a.C.Stamp.CompareTo(b.C.Stamp) : a.At.CompareTo(b.At));
|
||||
return ordered.ConvertAll(o => o.C);
|
||||
}
|
||||
|
||||
/// <summary>The newest stamp in the log (0 for none).</summary>
|
||||
public static long Newest(IReadOnlyList<Change> log)
|
||||
{
|
||||
long n = 0;
|
||||
foreach (Change c in log) if (c.Stamp > n) n = c.Stamp;
|
||||
return n;
|
||||
}
|
||||
|
||||
/// <summary>A new change's stamp: now, or just past the newest in the log when that is later (another clock).</summary>
|
||||
public static long NextStamp(IReadOnlyList<Change> log, long nowTicks) => Math.Max(nowTicks, Newest(log) + 1);
|
||||
|
||||
/// <summary>The log with <paramref name="change"/> added, keeping the newest <paramref name="keep"/> changes.</summary>
|
||||
public static List<Change> Append(IReadOnlyList<Change> log, Change change, int keep)
|
||||
{
|
||||
var list = new List<Change>(log) { change };
|
||||
if (keep > 0 && list.Count > keep) list.RemoveRange(0, list.Count - keep);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The changes a client that has made every change up to <paramref name="seenStamp"/> still has to make:
|
||||
/// the newer ones, not its own (<paramref name="ownPid"/>), oldest first.
|
||||
/// </summary>
|
||||
public static List<Change> Pending(IReadOnlyList<Change> log, long seenStamp, int ownPid)
|
||||
{
|
||||
var list = new List<Change>();
|
||||
foreach (Change c in log)
|
||||
if (c.Stamp > seenStamp && c.Pid != ownPid && c.Edits.Count > 0) list.Add(c);
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>A binding line as AC writes it: <c>UseQuickSlot_1 [ "" [ 0 DIK_1 ] 0x00000002 ]</c>.</summary>
|
||||
public static string Format(string action, int device, string dik, uint meta) =>
|
||||
meta == 0 ? $"{action} [ \"\" [ {device} {dik} ] ]" : $"{action} [ \"\" [ {device} {dik} ] 0x{meta:X8} ]";
|
||||
|
|
|
|||
|
|
@ -1288,8 +1288,9 @@ internal static class RynthCoreChatCommands
|
|||
// Placement: fixed on screen (drag it while unlocked) or following the character.
|
||||
case "fixed": case "screen": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Fixed; break;
|
||||
case "follow": case "world": S.SelfPlacement = ImGuiBackend.Hud.SelfPlacement.Follow; break;
|
||||
case "lock": S.SelfLocked = subValue == null || Flag(subValue, S.SelfLocked); break;
|
||||
case "unlock": S.SelfLocked = false; break;
|
||||
// Unlocking a plate that follows you fixes it on screen first (only a fixed plate drags).
|
||||
case "lock": S.SetSelfLocked(subValue == null || Flag(subValue, S.SelfLocked)); break;
|
||||
case "unlock": S.SetSelfLocked(false); break;
|
||||
case "reset": S.SelfFixedX = S.DefaultSelfFixedX; S.SelfFixedY = S.DefaultSelfFixedY; break;
|
||||
case "position": case "pos":
|
||||
{
|
||||
|
|
|
|||
228
src/RynthCore.Engine/D3D9/AmbientLight.cs
Normal file
228
src/RynthCore.Engine/D3D9/AmbientLight.cs
Normal file
|
|
@ -0,0 +1,228 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - D3D9/AmbientLight.cs
|
||||
// A floor under the client's world ambient light (2026-10-27, plugin API
|
||||
// v91): the hook RynthVision's dungeon light uses. A player asked for
|
||||
// SkunkVision's "Dungeon Light" (problem report R-20261027-141534-6a2b:
|
||||
// the dark TOR dungeons). Drawing only, in this client: nothing is sent to
|
||||
// the server and nobody else sees a difference.
|
||||
//
|
||||
// How AC lights its world (read offline from our client, 4,841,472 bytes;
|
||||
// the Chorizite names in GhidraTools\symbols.csv):
|
||||
// - AC draws with D3D9 fixed-function lighting. Its world ambient is three
|
||||
// floats (0x008682B0, RGB) that SmartBox::SetWorldAmbientLight
|
||||
// (0x004530E0) sets to level x colour. CellManager::ChangePosition
|
||||
// (0x00455AD0) picks them on every cell change: outdoors, or in an
|
||||
// EnvCell that sees outside (a building), from the sky
|
||||
// (LScape::calc_object_light); in any other EnvCell (a dungeon)
|
||||
// SetWorldAmbientLight(0.2, white), a flat 20 %: that is why dungeons
|
||||
// are dark away from their torches.
|
||||
// - Every viewpoint update (Render::update_viewpoint: the world once a
|
||||
// frame, and the 3D views in AC's own UI, e.g. the paper doll) runs
|
||||
// PrimD3DRender::UpdateLightsInternal (0x0059BEE0), which makes those
|
||||
// floats a colour and hands it to RenderDeviceD3D::SetFFAmbientColor32
|
||||
// (0x005A3EB0, below): SetRenderState(D3DRS_AMBIENT) when it differs from
|
||||
// the copy AC keeps at +0x4A0. Its only other caller is
|
||||
// SetDefaultDeviceStates (after a device reset).
|
||||
// - Dungeon walls (EnvCells) are drawn with lighting on: their static
|
||||
// lights (torches) are baked into the vertex colour
|
||||
// (D3DPolyRender::SetStaticLightingVertexColors), which
|
||||
// D3DPolyRender::RenderMeshSubset uses as the EMISSIVE colour, with a
|
||||
// white material (1.0 at 0x00821E38) for ambient and diffuse. A wall is
|
||||
// torches + D3DRS_AMBIENT + dynamic lights, so more ambient lights every
|
||||
// wall, floor, creature and item evenly; torches, textures and the fog
|
||||
// (distance fade to black) are unchanged.
|
||||
// - Gamma is no way round it: RenderDeviceD3D::SetGamma is SetGammaRamp,
|
||||
// which D3D9 applies only in full-screen exclusive mode.
|
||||
// The hook changes SetFFAmbientColor32's colour argument: per channel the
|
||||
// brighter of AC's and the floor (AmbientLightPolicy). AC's cache then holds
|
||||
// what was really set, so it stays consistent; a new floor shows on the next
|
||||
// frame (UpdateLightsInternal calls it every frame) and floor 0 hands AC's
|
||||
// colour back the same way. The floor applies wherever AC sets an ambient
|
||||
// while it is set: the plugin decides where (RynthVision: dungeons only by
|
||||
// default) and clears it when it doesn't apply.
|
||||
//
|
||||
// Safety (as VideoPatch):
|
||||
// - A hook on one argument, not a patch of AC's floats or code paths: with
|
||||
// no floor (the default) the detour passes AC's colour through as it is.
|
||||
// - Kill switch: UI hook slot "AmbientLight" (engine.json DisabledUiHooks
|
||||
// ["AmbientLight"]; /rc hooks off AmbientLight = pass-through now).
|
||||
// - Pattern first (HookResolver; tools\pe_pattern.py CHECK covers it), the
|
||||
// Decal guard (UiHookRegistry.TryInstall). Unresolved: logged once, and
|
||||
// SetFloor answers 0 so the plugin can say so.
|
||||
// - The floor goes back to 0 when the plugins unload (reload, rescan,
|
||||
// shutdown): a plugin that is gone never leaves the world lit.
|
||||
// - Cost: one managed call per SetFFAmbientColor32, a few per frame.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using RynthCore.Engine.Compatibility;
|
||||
using RynthCore.Engine.Plugins;
|
||||
|
||||
namespace RynthCore.Engine.D3D9;
|
||||
|
||||
internal static unsafe class AmbientLight
|
||||
{
|
||||
// RenderDeviceD3D::SetFFAmbientColor32 on the 4,841,472-byte client. Pattern is the source of truth.
|
||||
private const int SetAmbientFallbackVa = 0x005A3EB0;
|
||||
|
||||
// __thiscall (RenderDeviceD3D* this, D3DCOLOR color), ret 4:
|
||||
// push esi; mov esi,ecx; mov al,[esi+470h] (force flag); test al,al; push edi;
|
||||
// mov edi,[esp+0Ch] (color); jnz +8; cmp [esi+4A0h],edi (cached ambient); jz +1Bh;
|
||||
// mov eax,[esi+468h] (IDirect3DDevice9*); mov ecx,[eax]; push edi;
|
||||
// push 8Bh (D3DRS_AMBIENT); ... call [ecx+0E4h] (SetRenderState).
|
||||
// The first 24 bytes are shared by ten sibling SetFF* setters (other cache offsets); with the
|
||||
// cache offset and the push of D3DRS_AMBIENT it is unique in the scanned window (C:\Turbine
|
||||
// client, 2026-10-27). MinHook relocates the first three instructions (9 bytes, no branches).
|
||||
private static readonly byte?[] SetAmbientPattern =
|
||||
[
|
||||
0x56,
|
||||
0x8B, 0xF1,
|
||||
0x8A, 0x86, 0x70, 0x04, 0x00, 0x00,
|
||||
0x84, 0xC0,
|
||||
0x57,
|
||||
0x8B, 0x7C, 0x24, 0x0C,
|
||||
0x75, 0x08,
|
||||
0x39, 0xBE, 0xA0, 0x04, 0x00, 0x00,
|
||||
0x74, 0x1B,
|
||||
0x8B, 0x86, 0x68, 0x04, 0x00, 0x00,
|
||||
0x8B, 0x08,
|
||||
0x57,
|
||||
0x68, 0x8B, 0x00, 0x00, 0x00,
|
||||
];
|
||||
|
||||
private static readonly UiHookSlot Slot =
|
||||
UiHookRegistry.Register("AmbientLight", "RenderDeviceD3D::SetFFAmbientColor32 - the world's ambient light (light floor)", SetAmbientFallbackVa);
|
||||
|
||||
private static IntPtr _origSetAmbient;
|
||||
private static int _initialized;
|
||||
|
||||
/// <summary>The hook is live (cleared first on shutdown, so the detour passes through).</summary>
|
||||
public static volatile bool IsInstalled;
|
||||
|
||||
// The floor (0x00RRGGBB, 0 = none): any thread writes, AC's render thread reads.
|
||||
private static uint _floor;
|
||||
// What the detour last saw and set (AC's render thread writes; diagnostics read).
|
||||
private static uint _lastClient, _lastApplied;
|
||||
|
||||
/// <summary>Installed, switched on, and so able to light: what SetFloor and Get report.</summary>
|
||||
public static bool Live => IsInstalled && Slot.Live;
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _initialized, 1, 0) != 0)
|
||||
return;
|
||||
|
||||
// Whatever happens below: a floor never outlives the plugins that set it.
|
||||
PluginManager.PluginsUnloaded += ClearOnUnload;
|
||||
|
||||
if (!AcClientModule.TryReadTextSection(out AcClientTextSection text))
|
||||
{
|
||||
Slot.Reason = "acclient.exe not available";
|
||||
RynthLog.Compat("AmbientLight: acclient.exe not available - unavailable.");
|
||||
return;
|
||||
}
|
||||
if (!UiHookRegistry.SwitchedOn(Slot))
|
||||
return;
|
||||
|
||||
HookResolver.ResolveResult r = HookResolver.Resolve(text, "AmbientLight.RenderDeviceD3D::SetFFAmbientColor32", SetAmbientPattern, SetAmbientFallbackVa);
|
||||
delegate* unmanaged[Thiscall]<IntPtr, uint, void> d = &SetAmbientDetour;
|
||||
if (UiHookRegistry.TryInstall(Slot, r, (IntPtr)d, out IntPtr t))
|
||||
{
|
||||
_origSetAmbient = t;
|
||||
Thread.MemoryBarrier();
|
||||
if (UiHookRegistry.Enable(Slot))
|
||||
IsInstalled = true;
|
||||
}
|
||||
RynthLog.Compat(IsInstalled
|
||||
? $"AmbientLight: ready (RenderDeviceD3D::SetFFAmbientColor32 @ 0x{Slot.Address.ToInt32():X8} via {Slot.Source}); no floor until a plugin sets one."
|
||||
: $"AmbientLight: unavailable - {Slot.Reason}.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Engine shutdown / hot reload (lifecycle thread): the detour passes straight to AC from here
|
||||
/// on, then the hook is disabled. Idempotent.
|
||||
/// </summary>
|
||||
public static void Uninstall()
|
||||
{
|
||||
Volatile.Write(ref _floor, 0u);
|
||||
PluginManager.PluginsUnloaded -= ClearOnUnload;
|
||||
if (!IsInstalled) return;
|
||||
IsInstalled = false;
|
||||
Thread.MemoryBarrier();
|
||||
int status = Hooking.MinHook.MH_DisableHook(Slot.Address);
|
||||
RynthLog.Compat($"AmbientLight: uninstalled (disable = {Hooking.MinHook.StatusString(status)}).");
|
||||
}
|
||||
|
||||
private static void ClearOnUnload()
|
||||
{
|
||||
if (Volatile.Read(ref _floor) == 0) return;
|
||||
Volatile.Write(ref _floor, 0u);
|
||||
Slot.LastNote = "floor cleared (plugins unloaded)";
|
||||
RynthLog.Compat("AmbientLight: plugins unloaded - floor cleared (AC's own ambient again).");
|
||||
}
|
||||
|
||||
// ── Plugin API v91 (any thread) ─────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// v91 SetAmbientLightFloor: the least ambient light AC may use, 0x00RRGGBB (alpha ignored), 0 =
|
||||
/// none (AC's own). Takes effect on the next frame. Returns 1 when the hook is live (the floor
|
||||
/// lights the world), 0 when it isn't (not installed, switched off): the value is kept either
|
||||
/// way. The last caller's floor wins.
|
||||
/// </summary>
|
||||
public static int SetFloor(uint argb)
|
||||
{
|
||||
try
|
||||
{
|
||||
uint floor = AmbientLightPolicy.FloorRgb(argb);
|
||||
uint old = Volatile.Read(ref _floor);
|
||||
Volatile.Write(ref _floor, floor);
|
||||
if (floor != old)
|
||||
{
|
||||
Slot.LastNote = floor == 0 ? "floor off" : $"floor 0x{floor:X6}";
|
||||
RynthLog.Verbose($"AmbientLight: floor 0x{old:X6} -> 0x{floor:X6} (hook {(Live ? "live" : "not live")}).");
|
||||
}
|
||||
return Live ? 1 : 0;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// v91 GetAmbientLight: the last ambient colour AC asked for and the one that was set (0xAARRGGBB;
|
||||
/// 0 before the first frame). Returns 1 when the hook is live, 0 when it isn't (then both are 0).
|
||||
/// Either pointer may be null.
|
||||
/// </summary>
|
||||
public static int Get(uint* client, uint* applied)
|
||||
{
|
||||
try
|
||||
{
|
||||
bool live = Live;
|
||||
if (client != null) *client = live ? Volatile.Read(ref _lastClient) : 0u;
|
||||
if (applied != null) *applied = live ? Volatile.Read(ref _lastApplied) : 0u;
|
||||
return live ? 1 : 0;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
// ── The detour (AC's render thread) ─────────────────────────────────
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvThiscall)])]
|
||||
private static void SetAmbientDetour(IntPtr renderDevice, uint color)
|
||||
{
|
||||
uint set = color;
|
||||
try
|
||||
{
|
||||
if (IsInstalled && Slot.Enabled)
|
||||
{
|
||||
set = AmbientLightPolicy.Apply(color, Volatile.Read(ref _floor));
|
||||
_lastClient = color;
|
||||
_lastApplied = set;
|
||||
Interlocked.Increment(ref Slot.Fired);
|
||||
}
|
||||
}
|
||||
catch { set = color; }
|
||||
((delegate* unmanaged[Thiscall]<IntPtr, uint, void>)_origSetAmbient)(renderDevice, set);
|
||||
}
|
||||
}
|
||||
37
src/RynthCore.Engine/D3D9/AmbientLightPolicy.cs
Normal file
37
src/RynthCore.Engine/D3D9/AmbientLightPolicy.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - D3D9/AmbientLightPolicy.cs
|
||||
// The pure part of the ambient light floor (D3D9/AmbientLight.cs, plugin API
|
||||
// v91, 2026-10-27): the colour AC's world ambient becomes when a plugin has
|
||||
// asked for at least some light. Compiled into tools\AmbientLightTests.
|
||||
//
|
||||
// Colours are D3DCOLOR (0xAARRGGBB), the form AC hands to
|
||||
// RenderDeviceD3D::SetFFAmbientColor32. The floor's alpha byte means nothing
|
||||
// (D3D ignores D3DRS_AMBIENT's alpha) and AC's own alpha byte is kept, so a
|
||||
// floor never changes anything but the three colour channels. A floor whose
|
||||
// colour channels are all 0 is "off": AC's colour passes unchanged.
|
||||
// ============================================================================
|
||||
|
||||
namespace RynthCore.Engine.D3D9;
|
||||
|
||||
internal static class AmbientLightPolicy
|
||||
{
|
||||
/// <summary>The colour bits of a floor; 0 = no floor.</summary>
|
||||
public static uint FloorRgb(uint floorArgb) => floorArgb & 0x00FFFFFFu;
|
||||
|
||||
/// <summary>
|
||||
/// AC's ambient <paramref name="client"/> with <paramref name="floorArgb"/> under it: per channel
|
||||
/// the brighter of the two, AC's alpha byte kept. Never darker than AC's own (outdoors at noon a
|
||||
/// dim floor changes nothing); floor 0 returns <paramref name="client"/> as it is.
|
||||
/// </summary>
|
||||
public static uint Apply(uint client, uint floorArgb)
|
||||
{
|
||||
uint floor = FloorRgb(floorArgb);
|
||||
if (floor == 0) return client;
|
||||
uint r = Max((client >> 16) & 0xFF, (floor >> 16) & 0xFF);
|
||||
uint g = Max((client >> 8) & 0xFF, (floor >> 8) & 0xFF);
|
||||
uint b = Max(client & 0xFF, floor & 0xFF);
|
||||
return (client & 0xFF000000u) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
private static uint Max(uint a, uint b) => a > b ? a : b;
|
||||
}
|
||||
|
|
@ -160,6 +160,8 @@ internal static class EngineLifecycle
|
|||
Step("AcUiPassHook.Uninstall", () => AcUiPassHook.Uninstall());
|
||||
// The video patch's scene hook passes straight to AC from here on (AC draws again).
|
||||
Step("VideoPatch.Uninstall", () => VideoPatch.Uninstall());
|
||||
// The ambient light floor's hook passes AC's own colour from here on (no floor).
|
||||
Step("AmbientLight.Uninstall", () => AmbientLight.Uninstall());
|
||||
Step("EndSceneHook.Uninstall", () => EndSceneHook.Uninstall());
|
||||
|
||||
// Give in-flight EndScene calls a chance to drain. AC's render thread
|
||||
|
|
|
|||
|
|
@ -938,6 +938,10 @@ public static class EntryPoint
|
|||
// SmartBox::RenderNormalMode: the video patch (/rc video) skips AC's 3D scene on
|
||||
// request; off until asked. Kill switch: engine.json DisabledUiHooks ["VideoPatch"].
|
||||
Step("video patch hook", VideoPatch.Initialize);
|
||||
// RenderDeviceD3D::SetFFAmbientColor32: a floor under AC's world ambient light that a
|
||||
// plugin can set (API v91; RynthVision's dungeon light). No floor until one is set.
|
||||
// Kill switch: engine.json DisabledUiHooks ["AmbientLight"].
|
||||
Step("ambient light hook", AmbientLight.Initialize);
|
||||
Step("vendor hooks", VendorHooks.Initialize);
|
||||
Step("chat callback hooks", ChatCallbackHooks.Initialize);
|
||||
// Flight recorder (Net/FlightRecorder.cs): before the packet hooks that feed it.
|
||||
|
|
|
|||
25
src/RynthCore.Engine/ImGui/MonsterHud/DebuffIcon.cs
Normal file
25
src/RynthCore.Engine/ImGui/MonsterHud/DebuffIcon.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/DebuffIcon.cs
|
||||
// What one debuff icon stands for, shared by the monster plates' row
|
||||
// (PlateDebuffs: your debuffs on each monster) and your own plate's row
|
||||
// (SelfDebuffs: harmful spells on you), both painted by DebuffIconRow.
|
||||
// Plain data, no engine dependencies (the offline tests compile it in).
|
||||
// ============================================================================
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>What an icon on the plate stands for (one icon per kind).</summary>
|
||||
internal enum DebuffKind : byte
|
||||
{
|
||||
VulnFire, VulnCold, VulnLightning, VulnAcid, VulnSlash, VulnPierce, VulnBludgeon,
|
||||
Imperil, MagicYield, Defense, Attributes, Vitals, Movement, Skills, Dot, Other,
|
||||
}
|
||||
|
||||
/// <summary>One icon: the kind, when its soonest entry expires, that entry's full length, and how many categories it merges.</summary>
|
||||
internal struct DebuffIcon
|
||||
{
|
||||
public DebuffKind Kind;
|
||||
public long Expiry; // Stopwatch ticks
|
||||
public float Duration; // seconds, of the entry expiring first
|
||||
public int Stack;
|
||||
}
|
||||
138
src/RynthCore.Engine/ImGui/MonsterHud/DebuffIconRow.cs
Normal file
138
src/RynthCore.Engine/ImGui/MonsterHud/DebuffIconRow.cs
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/DebuffIconRow.cs
|
||||
// The debuff icon row, shared by the monster plates (your debuffs on each
|
||||
// monster, under its health bar) and your own plate (harmful spells on you,
|
||||
// under your mana bar): one icon per kind (a Phosphor glyph in the kind's
|
||||
// tint on a dark square), a stack digit when a kind merges several spell
|
||||
// categories, a countdown line under each icon that runs out with the spell,
|
||||
// a blink in the last BlinkSec seconds, "+N" when more kinds than fit, and
|
||||
// (monster plates only) the "debuffed by others" marker.
|
||||
//
|
||||
// Moved out of MonsterHud.PaintIcons unchanged (2026-10-27) so the player
|
||||
// plate can draw the same row; the monster plates look exactly as before.
|
||||
// Render thread only. Engine-owned statics.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
internal static class DebuffIconRow
|
||||
{
|
||||
/// <summary>Icons per row; more shows "+N" (the last slot makes room for it).</summary>
|
||||
internal const int MaxIcons = 5;
|
||||
/// <summary>Icons blink in their last seconds.</summary>
|
||||
internal const float BlinkSec = 5f;
|
||||
|
||||
private static readonly uint IconBack = MonsterHud.C(0xD80B1219), OthersTint = MonsterHud.C(0xFFFF8A7A);
|
||||
|
||||
// One glyph and tint per DebuffKind (index = kind).
|
||||
private static readonly string[] KindGlyph =
|
||||
{
|
||||
PhosphorIcons.Fire, PhosphorIcons.Snowflake, PhosphorIcons.Lightning, PhosphorIcons.Flask,
|
||||
PhosphorIcons.Sword, PhosphorIcons.Knife, PhosphorIcons.Hammer,
|
||||
PhosphorIcons.ShieldSlash, PhosphorIcons.MagicWand, PhosphorIcons.ShieldWarning,
|
||||
PhosphorIcons.ArrowFatLinesDown, PhosphorIcons.HeartBreak, PhosphorIcons.Footprints,
|
||||
PhosphorIcons.TrendDown, PhosphorIcons.Skull, PhosphorIcons.ArrowFatDown,
|
||||
};
|
||||
private static readonly uint[] KindTint =
|
||||
{
|
||||
MonsterHud.ElemFire, MonsterHud.ElemCold, MonsterHud.ElemLightning, MonsterHud.ElemAcid,
|
||||
MonsterHud.ElemSlash, MonsterHud.ElemPierce, MonsterHud.ElemBludgeon,
|
||||
MonsterHud.C(0xFF9FB4C8), // Imperil: steel
|
||||
MonsterHud.C(0xFFB98CFF), // Magic Yield: violet
|
||||
MonsterHud.C(0xFFFFB347), // melee / missile defense: orange
|
||||
MonsterHud.C(0xFFF2D24B), // attributes: yellow
|
||||
MonsterHud.C(0xFFFF6B8A), // vitals / regen: pink-red
|
||||
MonsterHud.C(0xFFA8C66C), // movement: moss
|
||||
MonsterHud.C(0xFF8FB8DE), // skills: blue-grey
|
||||
MonsterHud.C(0xFF7CE08A), // damage over time: green
|
||||
MonsterHud.C(0xFFC8C8C8), // other
|
||||
};
|
||||
private static readonly string[] StackDigits = { "", "", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
|
||||
/// <summary>
|
||||
/// The row centred on <paramref name="cx"/> with its top at <paramref name="top"/>:
|
||||
/// <paramref name="count"/> kinds (may exceed <paramref name="icons"/>' length: the rest
|
||||
/// show as "+N"), then the "debuffed by others" marker when <paramref name="others"/>.
|
||||
/// <paramref name="sz"/> is the icon square, <paramref name="smallFont"/>/<paramref name="smallSize"/>
|
||||
/// draw the stack digit and "+N"; <paramref name="overflowKey"/>/<paramref name="overflowText"/>
|
||||
/// cache the "+N" string per row. <paramref name="now"/> is Stopwatch ticks.
|
||||
/// </summary>
|
||||
internal static void Paint(ImDrawListPtr dl, DebuffIcon[] icons, int count, bool others, float sz,
|
||||
ImFontPtr smallFont, float smallSize, ref int overflowKey, ref string overflowText,
|
||||
float cx, float top, float k, float a, long now)
|
||||
{
|
||||
float gap = MathF.Max(2f, MathF.Round(2f * k));
|
||||
int shown = count > icons.Length ? icons.Length - 1 : count;
|
||||
int overflow = count - shown;
|
||||
string more = "";
|
||||
float moreW = 0f;
|
||||
if (overflow > 0)
|
||||
{
|
||||
if (overflow != overflowKey)
|
||||
{
|
||||
overflowKey = overflow;
|
||||
overflowText = "+" + overflow.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
more = overflowText;
|
||||
moreW = MonsterHud.TextWidth(smallFont, smallSize, more) + 4f * k;
|
||||
}
|
||||
int slots = shown + (others ? 1 : 0);
|
||||
float rowW = slots * sz + Math.Max(0, slots - 1) * gap + (overflow > 0 ? gap + moreW : 0f);
|
||||
float x = MathF.Round(cx - rowW * 0.5f);
|
||||
float glyphPx = MathF.Round(sz * 0.8f);
|
||||
ImFontPtr iconFont = ImGuiFonts.Sharp(glyphPx, bold: false); // the icons are merged into every bake
|
||||
float lineH = MathF.Max(1f, MathF.Round(1.5f * k));
|
||||
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
DebuffIcon ic = icons[i];
|
||||
int kind = (int)ic.Kind;
|
||||
uint tint = kind < KindTint.Length ? KindTint[kind] : KindTint[^1];
|
||||
float remaining = (ic.Expiry - now) / (float)Stopwatch.Frequency;
|
||||
float frac = ic.Duration > 0 ? Math.Clamp(remaining / ic.Duration, 0f, 1f) : 0f;
|
||||
float blink = remaining < BlinkSec ? 0.45f + 0.55f * MathF.Abs(MathF.Cos(remaining * MathF.PI * 2f)) : 1f;
|
||||
|
||||
var i0 = new Vector2(x, top);
|
||||
var i1 = i0 + new Vector2(sz, sz);
|
||||
dl.AddRectFilled(i0, i1, MonsterHud.Mul(IconBack, a), 2f * k);
|
||||
dl.AddRect(i0, i1, MonsterHud.Mul(tint, a * 0.55f * blink), 2f * k, ImDrawFlags.None, 1f);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, KindGlyph[kind < KindGlyph.Length ? kind : KindGlyph.Length - 1],
|
||||
i0, new Vector2(sz, sz), MonsterHud.Mul(tint, a * blink));
|
||||
if (ic.Stack > 1 && ic.Stack < StackDigits.Length)
|
||||
{
|
||||
string digit = StackDigits[ic.Stack];
|
||||
float ds = MathF.Round(smallSize * 0.85f);
|
||||
var dp = new Vector2(i1.X - MonsterHud.TextWidth(smallFont, ds, digit) + 1f, i0.Y - 2f);
|
||||
MonsterHud.OutlinedText(dl, smallFont, ds, dp, a, digit);
|
||||
dl.AddText(smallFont, ds, dp, MonsterHud.Mul(MonsterHud.HpText, a), digit);
|
||||
}
|
||||
// Countdown: a line under the icon that shrinks to nothing at expiry.
|
||||
float ly = i1.Y + 1f;
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i1.X, ly + lineH), MonsterHud.Mul(MonsterHud.Outline, a * 0.8f));
|
||||
if (frac > 0f)
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i0.X + MathF.Max(1f, sz * frac), ly + lineH), MonsterHud.Mul(tint, a * blink));
|
||||
x += sz + gap;
|
||||
}
|
||||
|
||||
if (overflow > 0)
|
||||
{
|
||||
var mp = new Vector2(x, MathF.Round(top + (sz - smallSize) * 0.5f));
|
||||
MonsterHud.OutlinedText(dl, smallFont, smallSize, mp, a, more);
|
||||
dl.AddText(smallFont, smallSize, mp, MonsterHud.Mul(MonsterHud.DimText, a), more);
|
||||
x += moreW + gap;
|
||||
}
|
||||
|
||||
if (others)
|
||||
{
|
||||
var i0 = new Vector2(x, top);
|
||||
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), MonsterHud.Mul(IconBack, a * 0.8f), 2f * k);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, PhosphorIcons.UsersThree, i0, new Vector2(sz, sz), MonsterHud.Mul(OthersTint, a * 0.8f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -77,45 +77,23 @@ internal static class MonsterHud
|
|||
private const uint BfVendor = 0x200; // PublicWeenieDesc BF_VENDOR
|
||||
private const uint PetOwnerIid = 44; // PropertyInstanceId PetOwner (summoned pets)
|
||||
internal const float LandblockSize = 192f;
|
||||
private const int MaxIcons = 5; // debuff icons per plate; more shows "+N"
|
||||
private const float BlinkSec = 5f; // icons blink in their last seconds
|
||||
|
||||
// ── Palette (ARGB literals -> ImGui ABGR) ────────────────────────────
|
||||
private static readonly uint BarBack = C(0xE00C1118), BarEdge = C(0xFF000000), Tick = C(0x70000000),
|
||||
Shine = C(0x38FFFFFF), Trail = C(0xFFF3E2A8), Gold = C(0xFFE6C766), GoldBright = C(0xFFFFD966),
|
||||
GoldGlow = C(0x55E6C766), NameText = C(0xFFF2E8DC), AttackerText = C(0xFFFF8A7A), Outline = C(0xE6000000),
|
||||
HpText = C(0xFFFFFFFF), DimText = C(0xFFB8C4D0), BadgeBack = C(0xD0101820), Leader = C(0x60FFFFFF),
|
||||
HoverEdge = C(0xC0FFFFFF), UnknownFill = C(0xFF5E8A6A), IconBack = C(0xD80B1219), OthersTint = C(0xFFFF8A7A);
|
||||
GoldGlow = C(0x55E6C766), NameText = C(0xFFF2E8DC), AttackerText = C(0xFFFF8A7A),
|
||||
BadgeBack = C(0xD0101820), Leader = C(0x60FFFFFF),
|
||||
HoverEdge = C(0xC0FFFFFF), UnknownFill = C(0xFF5E8A6A);
|
||||
// Also the debuff icon row's (DebuffIconRow): outlines, stack digits, "+N".
|
||||
internal static readonly uint Outline = C(0xE6000000), HpText = C(0xFFFFFFFF), DimText = C(0xFFB8C4D0);
|
||||
private static uint BadgeEdge => RynthTheme.Border;
|
||||
private static readonly Vector3 HpHigh = new(0x3F, 0xD0, 0x6A), HpMid = new(0xE8, 0xB3, 0x33), HpLow = new(0xE0, 0x4A, 0x4A);
|
||||
|
||||
// Element colours, shared by the "weak to" pill and the vulnerability icons.
|
||||
private static readonly uint ElemSlash = C(0xFFC9D1DB), ElemPierce = C(0xFFD9C19A), ElemBludgeon = C(0xFFB59A7E),
|
||||
// Element colours, shared by the "weak to" pill and the vulnerability icons (DebuffIconRow's tints).
|
||||
internal static readonly uint ElemSlash = C(0xFFC9D1DB), ElemPierce = C(0xFFD9C19A), ElemBludgeon = C(0xFFB59A7E),
|
||||
ElemFire = C(0xFFFF7A3D), ElemCold = C(0xFF7FD3FF), ElemLightning = C(0xFFC89BFF), ElemAcid = C(0xFF8FE36A);
|
||||
|
||||
// One glyph and tint per DebuffKind (index = kind).
|
||||
private static readonly string[] KindGlyph =
|
||||
{
|
||||
PhosphorIcons.Fire, PhosphorIcons.Snowflake, PhosphorIcons.Lightning, PhosphorIcons.Flask,
|
||||
PhosphorIcons.Sword, PhosphorIcons.Knife, PhosphorIcons.Hammer,
|
||||
PhosphorIcons.ShieldSlash, PhosphorIcons.MagicWand, PhosphorIcons.ShieldWarning,
|
||||
PhosphorIcons.ArrowFatLinesDown, PhosphorIcons.HeartBreak, PhosphorIcons.Footprints,
|
||||
PhosphorIcons.TrendDown, PhosphorIcons.Skull, PhosphorIcons.ArrowFatDown,
|
||||
};
|
||||
private static readonly uint[] KindTint =
|
||||
{
|
||||
ElemFire, ElemCold, ElemLightning, ElemAcid, ElemSlash, ElemPierce, ElemBludgeon,
|
||||
C(0xFF9FB4C8), // Imperil: steel
|
||||
C(0xFFB98CFF), // Magic Yield: violet
|
||||
C(0xFFFFB347), // melee / missile defense: orange
|
||||
C(0xFFF2D24B), // attributes: yellow
|
||||
C(0xFFFF6B8A), // vitals / regen: pink-red
|
||||
C(0xFFA8C66C), // movement: moss
|
||||
C(0xFF8FB8DE), // skills: blue-grey
|
||||
C(0xFF7CE08A), // damage over time: green
|
||||
C(0xFFC8C8C8), // other
|
||||
};
|
||||
private static readonly string[] StackDigits = { "", "", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||
// The debuff icons' glyphs, tints and painter are in DebuffIconRow (shared with your own plate).
|
||||
|
||||
internal static uint C(uint argb) => RynthTheme.Argb(argb);
|
||||
|
||||
|
|
@ -160,8 +138,8 @@ internal static class MonsterHud
|
|||
public float LastX, LastY, LastZ;
|
||||
|
||||
// Debuff icons (this frame)
|
||||
public readonly DebuffIcon[] Icons = new DebuffIcon[MaxIcons];
|
||||
public int IconCount; // may exceed MaxIcons (overflow)
|
||||
public readonly DebuffIcon[] Icons = new DebuffIcon[DebuffIconRow.MaxIcons];
|
||||
public int IconCount; // may exceed DebuffIconRow.MaxIcons (overflow)
|
||||
public bool Others; // "debuffed by others" marker
|
||||
|
||||
// Layout (this frame)
|
||||
|
|
@ -290,6 +268,8 @@ internal static class MonsterHud
|
|||
if (!track) ClearPlates();
|
||||
SetDamageSubscription(monsters && MonsterHudSettings.ShowWeakness);
|
||||
if (monsters && MonsterHudSettings.ShowDebuffs) PortalSpellTable.EnsureLoadQueued();
|
||||
// Your own plate's "Debuffs on you" row reads it too, plates on or off.
|
||||
if (MonsterHudSettings.SelfPlate && MonsterHudSettings.SelfDebuffs) PortalSpellTable.EnsureLoadQueued();
|
||||
|
||||
long now = Stopwatch.GetTimestamp();
|
||||
if (now >= _nextSnapshotTicks)
|
||||
|
|
@ -1310,7 +1290,8 @@ internal static class MonsterHud
|
|||
|
||||
// Under the bar: the debuff icons.
|
||||
if (icons)
|
||||
PaintIcons(dl, p, cx, iconTop, k, a, now);
|
||||
DebuffIconRow.Paint(dl, p.Icons, p.IconCount, p.Others, p.IconSize, p.SmallFont, p.SmallSize,
|
||||
ref p.OverflowKey, ref p.OverflowString, cx, iconTop, k, a, now);
|
||||
|
||||
// ── Name line: [level badge] Name ──
|
||||
if (p.NameW > 0 || p.BadgeW > 0)
|
||||
|
|
@ -1394,13 +1375,18 @@ internal static class MonsterHud
|
|||
/// <summary>
|
||||
/// A bar: black edge, dark track, the chip (what the last drop took), the
|
||||
/// gradient fill with a shine line, and optional quarter ticks. Shared with
|
||||
/// the player plate.
|
||||
/// the player plate, whose options can leave out the edge and track
|
||||
/// (<paramref name="track"/>) and the chip (<paramref name="chip"/>);
|
||||
/// monster plates always draw both.
|
||||
/// </summary>
|
||||
internal static void PaintBar(ImDrawListPtr dl, Vector2 b0, Vector2 b1, float round, float a,
|
||||
float shownRatio, float trailRatio, uint baseCol, bool ticks)
|
||||
float shownRatio, float trailRatio, uint baseCol, bool ticks, bool track = true, bool chip = true)
|
||||
{
|
||||
dl.AddRectFilled(b0 - Vector2.One, b1 + Vector2.One, Mul(BarEdge, a * 0.9f), round + 1);
|
||||
dl.AddRectFilled(b0, b1, Mul(BarBack, a), round);
|
||||
if (track)
|
||||
{
|
||||
dl.AddRectFilled(b0 - Vector2.One, b1 + Vector2.One, Mul(BarEdge, a * 0.9f), round + 1);
|
||||
dl.AddRectFilled(b0, b1, Mul(BarBack, a), round);
|
||||
}
|
||||
|
||||
float innerW = b1.X - b0.X - 2f;
|
||||
var i0 = new Vector2(b0.X + 1, b0.Y + 1);
|
||||
|
|
@ -1409,7 +1395,7 @@ internal static class MonsterHud
|
|||
float shown = Math.Clamp(shownRatio, 0f, 1f);
|
||||
float trail = Math.Clamp(trailRatio, 0f, 1f);
|
||||
|
||||
if (trail > shown + 0.002f)
|
||||
if (chip && trail > shown + 0.002f)
|
||||
dl.AddRectFilled(new Vector2(i0.X + innerW * shown, i0.Y), new Vector2(i0.X + innerW * trail, innerBottom), Mul(Trail, a * 0.85f));
|
||||
|
||||
if (shown > 0.001f)
|
||||
|
|
@ -1428,84 +1414,6 @@ internal static class MonsterHud
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The debuff row, centred under the bar: one icon per kind with a shrinking
|
||||
/// countdown line, blinking in its last seconds; "+N" when more than fit;
|
||||
/// then the "debuffed by others" marker.
|
||||
/// </summary>
|
||||
private static void PaintIcons(ImDrawListPtr dl, Plate p, float cx, float top, float k, float a, long now)
|
||||
{
|
||||
float sz = p.IconSize;
|
||||
float gap = MathF.Max(2f, MathF.Round(2f * k));
|
||||
int count = p.IconCount;
|
||||
int shown = count > MaxIcons ? MaxIcons - 1 : count;
|
||||
int overflow = count - shown;
|
||||
string more = "";
|
||||
float moreW = 0f;
|
||||
if (overflow > 0)
|
||||
{
|
||||
if (overflow != p.OverflowKey)
|
||||
{
|
||||
p.OverflowKey = overflow;
|
||||
p.OverflowString = "+" + overflow.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
more = p.OverflowString;
|
||||
moreW = TextWidth(p.SmallFont, p.SmallSize, more) + 4f * k;
|
||||
}
|
||||
int slots = shown + (p.Others ? 1 : 0);
|
||||
float rowW = slots * sz + Math.Max(0, slots - 1) * gap + (overflow > 0 ? gap + moreW : 0f);
|
||||
float x = MathF.Round(cx - rowW * 0.5f);
|
||||
float glyphPx = MathF.Round(sz * 0.8f);
|
||||
ImFontPtr iconFont = ImGuiFonts.Sharp(glyphPx, bold: false); // the icons are merged into every bake
|
||||
float lineH = MathF.Max(1f, MathF.Round(1.5f * k));
|
||||
|
||||
for (int i = 0; i < shown; i++)
|
||||
{
|
||||
DebuffIcon ic = p.Icons[i];
|
||||
int kind = (int)ic.Kind;
|
||||
uint tint = kind < KindTint.Length ? KindTint[kind] : KindTint[^1];
|
||||
float remaining = (ic.Expiry - now) / (float)Stopwatch.Frequency;
|
||||
float frac = ic.Duration > 0 ? Math.Clamp(remaining / ic.Duration, 0f, 1f) : 0f;
|
||||
float blink = remaining < BlinkSec ? 0.45f + 0.55f * MathF.Abs(MathF.Cos(remaining * MathF.PI * 2f)) : 1f;
|
||||
|
||||
var i0 = new Vector2(x, top);
|
||||
var i1 = i0 + new Vector2(sz, sz);
|
||||
dl.AddRectFilled(i0, i1, Mul(IconBack, a), 2f * k);
|
||||
dl.AddRect(i0, i1, Mul(tint, a * 0.55f * blink), 2f * k, ImDrawFlags.None, 1f);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, KindGlyph[kind < KindGlyph.Length ? kind : KindGlyph.Length - 1],
|
||||
i0, new Vector2(sz, sz), Mul(tint, a * blink));
|
||||
if (ic.Stack > 1 && ic.Stack < StackDigits.Length)
|
||||
{
|
||||
string digit = StackDigits[ic.Stack];
|
||||
float ds = MathF.Round(p.SmallSize * 0.85f);
|
||||
var dp = new Vector2(i1.X - TextWidth(p.SmallFont, ds, digit) + 1f, i0.Y - 2f);
|
||||
OutlinedText(dl, p.SmallFont, ds, dp, a, digit);
|
||||
dl.AddText(p.SmallFont, ds, dp, Mul(HpText, a), digit);
|
||||
}
|
||||
// Countdown: a line under the icon that shrinks to nothing at expiry.
|
||||
float ly = i1.Y + 1f;
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i1.X, ly + lineH), Mul(Outline, a * 0.8f));
|
||||
if (frac > 0f)
|
||||
dl.AddRectFilled(new Vector2(i0.X, ly), new Vector2(i0.X + MathF.Max(1f, sz * frac), ly + lineH), Mul(tint, a * blink));
|
||||
x += sz + gap;
|
||||
}
|
||||
|
||||
if (overflow > 0)
|
||||
{
|
||||
var mp = new Vector2(x, MathF.Round(top + (sz - p.SmallSize) * 0.5f));
|
||||
OutlinedText(dl, p.SmallFont, p.SmallSize, mp, a, more);
|
||||
dl.AddText(p.SmallFont, p.SmallSize, mp, Mul(DimText, a), more);
|
||||
x += moreW + gap;
|
||||
}
|
||||
|
||||
if (p.Others)
|
||||
{
|
||||
var i0 = new Vector2(x, top);
|
||||
dl.AddRectFilled(i0, i0 + new Vector2(sz, sz), Mul(IconBack, a * 0.8f), 2f * k);
|
||||
PhosphorIcons.DrawCentered(dl, iconFont, glyphPx, PhosphorIcons.UsersThree, i0, new Vector2(sz, sz), Mul(OthersTint, a * 0.8f));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A soft 1 px outline under text (the text itself is drawn by the caller).</summary>
|
||||
internal static void OutlinedText(ImDrawListPtr dl, ImFontPtr font, float size, Vector2 pos, float a, string text)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,6 +79,18 @@ internal static class MonsterHudSettings
|
|||
public static float SelfFixedX = DefaultSelfFixedX, SelfFixedY = DefaultSelfFixedY;
|
||||
/// <summary>Just under a third-person character, clear of the chat in the bottom-left corner.</summary>
|
||||
public const float DefaultSelfFixedX = 0.5f, DefaultSelfFixedY = 0.68f;
|
||||
// Your plate's look (2026-10-27), each piece on its own; all on = the look before they existed.
|
||||
// Your plate only: the monster plates share the bar painter but always draw all of it.
|
||||
/// <summary>The dark track and 1 px black edge behind each of your bars.</summary>
|
||||
public static bool SelfBarTrack = true;
|
||||
/// <summary>The pale gold "chip" that shows what a drop took, then drains.</summary>
|
||||
public static bool SelfBarChip = true;
|
||||
/// <summary>The black outline around your plate's text (numbers, name).</summary>
|
||||
public static bool SelfTextOutline = true;
|
||||
/// <summary>The dark band behind the "cur / max" numbers.</summary>
|
||||
public static bool SelfNumberBand = true;
|
||||
/// <summary>"Debuffs on you": icons for harmful spells on you under your mana bar (only while you have one).</summary>
|
||||
public static bool SelfDebuffs = true;
|
||||
|
||||
// Combat text (CombatText): floating numbers and the kill burst.
|
||||
public static bool Numbers = true;
|
||||
|
|
@ -209,6 +221,11 @@ internal static class MonsterHudSettings
|
|||
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 "selfBarTrack": SelfBarTrack = val == "1"; break;
|
||||
case "selfBarChip": SelfBarChip = val == "1"; break;
|
||||
case "selfTextOutline": SelfTextOutline = val == "1"; break;
|
||||
case "selfNumberBand": SelfNumberBand = val == "1"; break;
|
||||
case "selfDebuffs": SelfDebuffs = val == "1"; break;
|
||||
case "numbers": Numbers = val == "1"; break;
|
||||
case "numDealt": NumDealt = val == "1"; break;
|
||||
case "numTaken": NumTaken = val == "1"; break;
|
||||
|
|
@ -291,6 +308,11 @@ internal static class MonsterHudSettings
|
|||
sw.WriteLine($"selfLocked={B(SelfLocked)}");
|
||||
sw.WriteLine(FormattableString.Invariant($"selfFixedX={SelfFixedX:0.####}"));
|
||||
sw.WriteLine(FormattableString.Invariant($"selfFixedY={SelfFixedY:0.####}"));
|
||||
sw.WriteLine($"selfBarTrack={B(SelfBarTrack)}");
|
||||
sw.WriteLine($"selfBarChip={B(SelfBarChip)}");
|
||||
sw.WriteLine($"selfTextOutline={B(SelfTextOutline)}");
|
||||
sw.WriteLine($"selfNumberBand={B(SelfNumberBand)}");
|
||||
sw.WriteLine($"selfDebuffs={B(SelfDebuffs)}");
|
||||
sw.WriteLine($"numbers={B(Numbers)}");
|
||||
sw.WriteLine($"numDealt={B(NumDealt)}");
|
||||
sw.WriteLine($"numTaken={B(NumTaken)}");
|
||||
|
|
@ -329,6 +351,7 @@ internal static class MonsterHudSettings
|
|||
NpcNames = true; NpcMaxDistance = 30f; MaxNpcLabels = 15; PlayerNames = false; PlayerBars = false;
|
||||
SelfPlate = true; SelfNumbers = false; SelfName = false; SelfHideFirstPerson = true;
|
||||
SelfPlacement = SelfPlacement.Fixed; SelfLocked = true; SelfFixedX = DefaultSelfFixedX; SelfFixedY = DefaultSelfFixedY;
|
||||
SelfBarTrack = true; SelfBarChip = true; SelfTextOutline = true; SelfNumberBand = true; SelfDebuffs = true;
|
||||
Numbers = true; NumDealt = true; NumTaken = true; NumHeals = true; NumKills = true;
|
||||
NumSize = 1.0f; NumTime = 1.0f; NumRestores = true; KeepOnScreen = true;
|
||||
GainSize = 1.0f; GainTime = 1.0f; SelfPosition = SelfPlatePosition.Above;
|
||||
|
|
@ -359,6 +382,22 @@ internal static class MonsterHudSettings
|
|||
Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Locks or unlocks your plate (not saved: the caller saves). Only a plate fixed on screen can be
|
||||
/// dragged, so unlocking one that follows your character fixes it on screen first, at its saved
|
||||
/// spot. True when that switch happened. Render / chat thread.
|
||||
/// </summary>
|
||||
public static bool SetSelfLocked(bool locked)
|
||||
{
|
||||
SelfLocked = locked;
|
||||
if (locked || SelfPlacement == SelfPlacement.Fixed) return false;
|
||||
SelfPlacement = SelfPlacement.Fixed;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Your plate can be dragged right now: fixed on screen and unlocked.</summary>
|
||||
public static bool SelfMovable => SelfPlacement == SelfPlacement.Fixed && !SelfLocked;
|
||||
|
||||
/// <summary>Every master switch at once ("/rv plates all on|off").</summary>
|
||||
public static void SetAll(bool on)
|
||||
{
|
||||
|
|
@ -374,7 +413,9 @@ internal static class MonsterHudSettings
|
|||
$"distance {OnOff(ShowDistance)}, fade {OnOff(FadeWithDistance)}, click to select {OnOff(ClickToSelect)}), debuffs {OnOff(ShowDebuffs)} (others {OnOff(ShowOthersDebuff)}); " +
|
||||
$"NPC names {OnOff(NpcNames)} ({NpcMaxDistance:0}yd, max {MaxNpcLabels}), player names {OnOff(PlayerNames)} (bars {OnOff(PlayerBars)}); " +
|
||||
$"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)}); " +
|
||||
$"numbers {OnOff(SelfNumbers)}, name {OnOff(SelfName)}, hide in first person {OnOff(SelfHideFirstPerson)}, " +
|
||||
$"debuffs on you {OnOff(SelfDebuffs)}, track {OnOff(SelfBarTrack)}, damage trail {OnOff(SelfBarChip)}, " +
|
||||
$"text outline {OnOff(SelfTextOutline)}, number band {OnOff(SelfNumberBand)}); " +
|
||||
$"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)}); " +
|
||||
$"sizes: monster bar {MonsterBarWidth:0.##}x{MonsterBarHeight:0.##} text {MonsterTextSize:0.##}, " +
|
||||
|
|
|
|||
|
|
@ -111,12 +111,25 @@ 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 |= Toggle("Debuffs on you", ref MonsterHudSettings.SelfDebuffs,
|
||||
"Icons under your mana bar for harmful spells on you (vulnerabilities, Imperil, Magic Yield, attribute and skill debuffs...), " +
|
||||
"the monster plates' icons: one per kind, a line that runs out with the spell, blinking in its last 5 seconds, \"+N\" when more than fit. " +
|
||||
"Only shows while you have one.", 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).");
|
||||
// The plate's shading, piece by piece (your plate only; the monster plates keep theirs).
|
||||
changed |= Toggle("Dark track behind the bars", ref MonsterHudSettings.SelfBarTrack,
|
||||
"The dark background and thin black edge behind each of your bars. Off: only the coloured fill shows.", sub: true);
|
||||
changed |= Toggle("Damage trail", ref MonsterHudSettings.SelfBarChip,
|
||||
"The pale gold strip that shows what a drop just took, then drains away.", sub: true);
|
||||
changed |= Toggle("Text outline", ref MonsterHudSettings.SelfTextOutline,
|
||||
"The thin black outline around your numbers and your name.", sub: true);
|
||||
changed |= Toggle("Band behind the numbers", ref MonsterHudSettings.SelfNumberBand,
|
||||
"The dark band behind the cur / max numbers (with Numbers on your bars).", sub: true);
|
||||
|
||||
bool fixedOn = MonsterHudSettings.SelfPlacement == SelfPlacement.Fixed;
|
||||
if (Toggle("Fixed on screen", ref fixedOn,
|
||||
|
|
@ -132,9 +145,10 @@ internal static class MonsterHudSettingsUi
|
|||
bool locked = MonsterHudSettings.SelfLocked;
|
||||
if (Toggle("Lock position", ref locked,
|
||||
"Locked, the plate can't be grabbed or clicked, so play never moves it. " +
|
||||
"Untick it, then drag the plate (it shows a frame) and tick it again. Chat: /rv plates self lock on|off.", indent: 32))
|
||||
"Untick it, then drag the plate (it shows a frame) and tick it again. Also in Settings > UI > Vitals. " +
|
||||
"Chat: /rv plates self lock on|off.", indent: 32))
|
||||
{
|
||||
MonsterHudSettings.SelfLocked = locked;
|
||||
MonsterHudSettings.SetSelfLocked(locked);
|
||||
changed = true;
|
||||
}
|
||||
if (unlocked)
|
||||
|
|
|
|||
|
|
@ -44,21 +44,7 @@ using RynthCore.Engine.Compatibility;
|
|||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>What an icon on the plate stands for (one icon per kind).</summary>
|
||||
internal enum DebuffKind : byte
|
||||
{
|
||||
VulnFire, VulnCold, VulnLightning, VulnAcid, VulnSlash, VulnPierce, VulnBludgeon,
|
||||
Imperil, MagicYield, Defense, Attributes, Vitals, Movement, Skills, Dot, Other,
|
||||
}
|
||||
|
||||
/// <summary>One icon: the kind, when its soonest entry expires, that entry's full length, and how many categories it merges.</summary>
|
||||
internal struct DebuffIcon
|
||||
{
|
||||
public DebuffKind Kind;
|
||||
public long Expiry; // Stopwatch ticks
|
||||
public float Duration; // seconds, of the entry expiring first
|
||||
public int Stack;
|
||||
}
|
||||
// DebuffKind and DebuffIcon (what an icon stands for) are in DebuffIcon.cs, shared with your own plate's row.
|
||||
|
||||
internal static class PlateDebuffs
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,10 +29,25 @@
|
|||
// (setting; on by default). The head point is published either way, for the
|
||||
// gain text.
|
||||
//
|
||||
// Look (2026-10-27, each its own setting, all on by default = the old look):
|
||||
// the dark track + black edge behind each bar, the damage chip, the text
|
||||
// outline and the dark band behind the numbers. Your plate only.
|
||||
//
|
||||
// "Debuffs on you" (2026-10-27, setting, on by default): the monster plates'
|
||||
// icon row (DebuffIconRow) under your mana bar, for harmful spells on you,
|
||||
// only while there is one. Data: the engine's player enchantment snapshot
|
||||
// (EnchantmentHooks.CopyPlayerStatMods: the main thread refreshes it every
|
||||
// 250 ms; here a lock and an array copy, four times a second, as the Buffs
|
||||
// tab reads it), picked by SelfDebuffs.Select with the spell table
|
||||
// (PortalSpellTable, queued by MonsterHud.Update while the row is on). The
|
||||
// row hangs under the bars: placement keeps the bars where they are and
|
||||
// only the clamp and the drag area grow to cover it.
|
||||
//
|
||||
// Render thread only. Engine-owned statics.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
|
@ -63,6 +78,19 @@ internal static class PlayerPlate
|
|||
private static BarState _hp, _st, _mn;
|
||||
private static float _alpha;
|
||||
|
||||
// "Debuffs on you": the snapshot copy (preallocated, read 4x a second) and this read's icons.
|
||||
private const int MaxEnch = SelfDebuffs.MaxEntries;
|
||||
private const int DebuffReadMs = 250;
|
||||
private static readonly uint[] _eIds = new uint[MaxEnch], _eTypes = new uint[MaxEnch], _eKeys = new uint[MaxEnch], _eCats = new uint[MaxEnch];
|
||||
private static readonly double[] _eExp = new double[MaxEnch];
|
||||
private static readonly float[] _eVals = new float[MaxEnch];
|
||||
private static readonly DebuffIcon[] _icons = new DebuffIcon[DebuffIconRow.MaxIcons];
|
||||
private static int _iconCount;
|
||||
private static long _nextDebuffRead; // Environment.TickCount64
|
||||
private static int _overflowKey = -1;
|
||||
private static string _overflowText = "";
|
||||
private static readonly HarmfulSpellLookup Harmful = LookupHarmful;
|
||||
|
||||
// Fixed mode: dragging (unlocked only).
|
||||
private static bool _hover, _dragging, _wantsMouse;
|
||||
private static Vector2 _grab; // cursor minus the bars' centre when the drag began
|
||||
|
|
@ -85,6 +113,8 @@ internal static class PlayerPlate
|
|||
{
|
||||
_hp = default; _st = default; _mn = default;
|
||||
_alpha = 0f;
|
||||
_iconCount = 0;
|
||||
_nextDebuffRead = 0;
|
||||
HeadOnScreen = false;
|
||||
FirstPerson = false;
|
||||
DropDrag();
|
||||
|
|
@ -115,15 +145,16 @@ internal static class PlayerPlate
|
|||
PlayerVitalsHooks.TryGetSnapshot(out _);
|
||||
if (!Advance(ref f, show)) return;
|
||||
Layout l = Measure(f.UiScale);
|
||||
float k = l.K, barW = l.BarW, blockH = l.BlockH, nameH = l.NameH;
|
||||
float k = l.K, barW = l.BarW, blockH = l.BlockH, nameH = l.NameH, iconsH = l.IconsH;
|
||||
|
||||
// Where the block goes: above the head (default), under the feet, or beside the character.
|
||||
float left, y;
|
||||
SelfPlatePosition where = MonsterHudSettings.SelfPosition;
|
||||
if (where == SelfPlatePosition.Above)
|
||||
{
|
||||
// The debuff row (when there is one) sits between the bars and the head.
|
||||
left = head.X - barW * 0.5f;
|
||||
y = head.Y - 4f * k - blockH;
|
||||
y = head.Y - 4f * k - blockH - iconsH;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -151,9 +182,9 @@ internal static class PlayerPlate
|
|||
if (MonsterHudSettings.KeepOnScreen)
|
||||
{
|
||||
left = Math.Clamp(left, 4f, MathF.Max(4f, f.Display.X - barW - 4f));
|
||||
y = Math.Clamp(y, 4f + nameH, MathF.Max(4f + nameH, f.Display.Y - blockH - 4f));
|
||||
y = Math.Clamp(y, 4f + nameH, MathF.Max(4f + nameH, f.Display.Y - blockH - iconsH - 4f));
|
||||
}
|
||||
float top = Paint(f.Dl, ref l, MathF.Round(left), MathF.Round(y));
|
||||
float top = Paint(f.Dl, ref l, MathF.Round(left), MathF.Round(y), f.Now);
|
||||
// Gain text floats above the plate when it's over the head, else above the head itself.
|
||||
PlateTop = where == SelfPlatePosition.Above ? top : head.Y;
|
||||
}
|
||||
|
|
@ -189,8 +220,10 @@ internal static class PlayerPlate
|
|||
MonsterHudSettings.Save();
|
||||
}
|
||||
}
|
||||
// The saved spot is the bars' centre (a debuff row coming and going never moves them); the
|
||||
// clamp keeps the row under them on screen too.
|
||||
float left = Math.Clamp(cx - l.BarW * 0.5f, 4f, MathF.Max(4f, display.X - l.BarW - 4f));
|
||||
float y = Math.Clamp(cy - l.BlockH * 0.5f, 4f + l.NameH, MathF.Max(4f + l.NameH, display.Y - l.BlockH - 4f));
|
||||
float y = Math.Clamp(cy - l.BlockH * 0.5f, 4f + l.NameH, MathF.Max(4f + l.NameH, display.Y - l.BlockH - l.IconsH - 4f));
|
||||
left = MathF.Round(left);
|
||||
y = MathF.Round(y);
|
||||
if (_dragging && display.X > 1 && display.Y > 1)
|
||||
|
|
@ -200,10 +233,10 @@ internal static class PlayerPlate
|
|||
MonsterHudSettings.SelfFixedY = Math.Clamp((y + l.BlockH * 0.5f) / display.Y, 0f, 1f);
|
||||
}
|
||||
|
||||
// The plate's rect (name included), a little padded: the drag surface.
|
||||
// The plate's rect (name and debuff row included), a little padded: the drag surface.
|
||||
float pad = MathF.Round(4f * l.K);
|
||||
var r0 = new Vector2(left - pad, y - l.NameH - pad);
|
||||
var r1 = new Vector2(left + l.BarW + pad, y + l.BlockH + pad);
|
||||
var r1 = new Vector2(left + l.BarW + pad, y + l.BlockH + l.IconsH + pad);
|
||||
Drag(unlocked, r0, r1, new Vector2(left + l.BarW * 0.5f, y + l.BlockH * 0.5f));
|
||||
|
||||
ImDrawListPtr dl = ImGuiNET.ImGui.GetBackgroundDrawList();
|
||||
|
|
@ -215,7 +248,7 @@ internal static class PlayerPlate
|
|||
dl.AddRectFilled(r0, r1, MonsterHud.Mul(hot ? 0x40000000u : 0x28000000u, a), 3f);
|
||||
dl.AddRect(r0, r1, MonsterHud.Mul(hot ? FrameHot : FrameCol, a), 3f, ImDrawFlags.None, hot ? 1.5f : 1f);
|
||||
}
|
||||
Paint(dl, ref l, left, y);
|
||||
Paint(dl, ref l, left, y, f.Now);
|
||||
}
|
||||
|
||||
private static uint FrameCol => RynthTheme.WithAlpha(RynthTheme.Accent, 0xB0);
|
||||
|
|
@ -250,7 +283,7 @@ internal static class PlayerPlate
|
|||
_wantsMouse = _hover || _dragging;
|
||||
}
|
||||
|
||||
private const string DragTip = "Drag to move your plate.\nLock it again in Vision > Nameplates > Your plate (or /rv plates self lock).";
|
||||
private const string DragTip = "Drag to move your plate.\nLock it again in Settings > UI > Vitals or Vision > Nameplates > Your plate (or /rv plates self lock).";
|
||||
|
||||
/// <summary>Fades the plate in / out and steps the bars; false when nothing should be painted.</summary>
|
||||
private static bool Advance(ref MonsterHud.Frame f, bool show)
|
||||
|
|
@ -265,15 +298,49 @@ internal static class PlayerPlate
|
|||
Step(ref _hp, v.Health, v.MaxHealth, f.Now, kBar, f.Dt);
|
||||
Step(ref _st, v.Stamina, v.MaxStamina, f.Now, kBar, f.Dt);
|
||||
Step(ref _mn, v.Mana, v.MaxMana, f.Now, kBar, f.Dt);
|
||||
RefreshDebuffs(f.Now);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>The plate's sizes and fonts this frame.</summary>
|
||||
/// <summary>"Debuffs on you": the snapshot read and the icons picked, four times a second. Render thread.</summary>
|
||||
private static void RefreshDebuffs(long nowTicks)
|
||||
{
|
||||
if (!MonsterHudSettings.SelfDebuffs) { _iconCount = 0; return; }
|
||||
long ms = Environment.TickCount64;
|
||||
if (ms < _nextDebuffRead) return;
|
||||
_nextDebuffRead = ms + DebuffReadMs;
|
||||
if (!PortalSpellTable.Ready) { _iconCount = 0; return; } // MonsterHud.Update queued the load
|
||||
int n = EnchantmentHooks.CopyPlayerStatMods(_eIds, _eExp, _eTypes, _eKeys, _eVals, _eCats);
|
||||
_iconCount = n > 0
|
||||
? SelfDebuffs.Select(_eIds, _eExp, _eCats, n, TimeSyncHooks.GetCurrentServerTime(), nowTicks, Stopwatch.Frequency, Harmful, _icons)
|
||||
: 0;
|
||||
}
|
||||
|
||||
/// <summary>The spell table only holds non-beneficial enchantments: a hit is harmful. Its kind and base length.</summary>
|
||||
private static bool LookupHarmful(uint spellId, out DebuffKind kind, out float duration)
|
||||
{
|
||||
if (PortalSpellTable.TryGetById(spellId, out DebuffSpell s))
|
||||
{
|
||||
kind = PlateDebuffs.KindOf(s);
|
||||
duration = (float)s.Duration;
|
||||
return true;
|
||||
}
|
||||
kind = DebuffKind.Other;
|
||||
duration = 0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>The plate's sizes, fonts and look this frame.</summary>
|
||||
private struct Layout
|
||||
{
|
||||
public float K, BarW, BarH, Gap, Round, BlockH, NameH, SmallSize, NameSize;
|
||||
public bool Numbers;
|
||||
public ImFontPtr Small, NameFont;
|
||||
// Look options (MonsterHudSettings.SelfBarTrack ...), read once per frame.
|
||||
public bool Track, Chip, Outline, Band;
|
||||
// The debuff row under the bars: icon square, its text (stack digit, "+N"), and the room it takes (0 = none).
|
||||
public float IconSize, IconTextSize, IconsH;
|
||||
public ImFontPtr IconText;
|
||||
}
|
||||
|
||||
private static Layout Measure(float uiScale)
|
||||
|
|
@ -296,16 +363,31 @@ internal static class PlayerPlate
|
|||
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;
|
||||
l.Track = MonsterHudSettings.SelfBarTrack;
|
||||
l.Chip = MonsterHudSettings.SelfBarChip;
|
||||
l.Outline = MonsterHudSettings.SelfTextOutline;
|
||||
l.Band = MonsterHudSettings.SelfNumberBand;
|
||||
// The debuff row: the monster plates' icon size and small text, only while there is an icon.
|
||||
l.IconSize = MathF.Round(13f * k);
|
||||
l.IconTextSize = MathF.Round(ImGuiFonts.Get(UiFont.Ui9).FontSize * text);
|
||||
l.IconText = ImGuiFonts.Sharp(l.IconTextSize, bold: false);
|
||||
l.IconsH = _iconCount > 0 ? MathF.Round(3f * k) + l.IconSize + 3f : 0f;
|
||||
return l;
|
||||
}
|
||||
|
||||
/// <summary>Paints the three bars (and the name over them) with their top-left at (left, y); returns the plate's top.</summary>
|
||||
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y)
|
||||
/// <summary>
|
||||
/// Paints the three bars (and the name over them, the debuff row under them) with the bars' top-left
|
||||
/// at (left, y); returns the plate's top. <paramref name="now"/> is Stopwatch ticks.
|
||||
/// </summary>
|
||||
private static float Paint(ImDrawListPtr dl, ref Layout l, float left, float y, long now)
|
||||
{
|
||||
float a = Math.Clamp(_alpha, 0f, 1f);
|
||||
PaintOne(dl, ref _hp, left, y, l.BarW, l.BarH, l.Round, a, HealthCol, l.Numbers, l.Small, l.SmallSize);
|
||||
PaintOne(dl, ref _st, left, y + l.BarH + l.Gap, l.BarW, l.BarH, l.Round, a, StaminaCol, l.Numbers, l.Small, l.SmallSize);
|
||||
PaintOne(dl, ref _mn, left, y + 2 * (l.BarH + l.Gap), l.BarW, l.BarH, l.Round, a, ManaCol, l.Numbers, l.Small, l.SmallSize);
|
||||
PaintOne(dl, ref _hp, ref l, left, y, a, HealthCol);
|
||||
PaintOne(dl, ref _st, ref l, left, y + l.BarH + l.Gap, a, StaminaCol);
|
||||
PaintOne(dl, ref _mn, ref l, left, y + 2 * (l.BarH + l.Gap), a, ManaCol);
|
||||
if (_iconCount > 0)
|
||||
DebuffIconRow.Paint(dl, _icons, _iconCount, others: false, l.IconSize, l.IconText, l.IconTextSize,
|
||||
ref _overflowKey, ref _overflowText, left + l.BarW * 0.5f, y + l.BlockH + MathF.Round(3f * l.K), l.K, a, now);
|
||||
float top = y - 1f;
|
||||
if (MonsterHudSettings.SelfName)
|
||||
{
|
||||
|
|
@ -314,7 +396,7 @@ internal static class PlayerPlate
|
|||
{
|
||||
float w = MonsterHud.TextWidth(l.NameFont, l.NameSize, name);
|
||||
var pos = new Vector2(MathF.Round(left + (l.BarW - w) * 0.5f), MathF.Round(y - 3f * l.K - l.NameSize));
|
||||
MonsterHud.OutlinedText(dl, l.NameFont, l.NameSize, pos, a, name);
|
||||
if (l.Outline) MonsterHud.OutlinedText(dl, l.NameFont, l.NameSize, pos, a, name);
|
||||
dl.AddText(l.NameFont, l.NameSize, pos, MonsterHud.Mul(NameCol, a), name);
|
||||
top = pos.Y;
|
||||
}
|
||||
|
|
@ -346,13 +428,14 @@ internal static class PlayerPlate
|
|||
MonsterHud.StepBar(ref b.Shown, ref b.Trail, ref b.Hold, ratio, now, kBar, dt);
|
||||
}
|
||||
|
||||
private static void PaintOne(ImDrawListPtr dl, ref BarState b, float left, float top, float w, float h, float round, float a,
|
||||
uint col, bool numbers, ImFontPtr font, float size)
|
||||
private static void PaintOne(ImDrawListPtr dl, ref BarState b, ref Layout l, float left, float top, float a, uint col)
|
||||
{
|
||||
float w = l.BarW, h = l.BarH, size = l.SmallSize;
|
||||
ImFontPtr font = l.Small;
|
||||
var b0 = new Vector2(left, top);
|
||||
var b1 = new Vector2(left + w, top + h);
|
||||
MonsterHud.PaintBar(dl, b0, b1, round, a, b.Shown, b.Trail, col, ticks: false);
|
||||
if (!numbers || h < 8f || b.Max == 0) return;
|
||||
MonsterHud.PaintBar(dl, b0, b1, l.Round, a, b.Shown, b.Trail, col, ticks: false, track: l.Track, chip: l.Chip);
|
||||
if (!l.Numbers || h < 8f || b.Max == 0) return;
|
||||
long key = ((long)b.Max << 32) | b.Cur;
|
||||
string? text = b.Text;
|
||||
if (key != b.TextKey || text == null)
|
||||
|
|
@ -362,11 +445,12 @@ 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.
|
||||
// (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);
|
||||
// A dark band behind the text, then an outline, so it reads over bright and dark fills alike
|
||||
// (each can be turned off). Text sized bigger than the bar: the band grows to the text.
|
||||
if (l.Band)
|
||||
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);
|
||||
if (l.Outline) MonsterHud.OutlinedText(dl, font, size, pos, a, text);
|
||||
dl.AddText(font, size, pos, MonsterHud.Mul(NumCol, a), text);
|
||||
}
|
||||
|
||||
|
|
@ -388,5 +472,8 @@ internal static class PlayerPlate
|
|||
$"Self plate {(MonsterHudSettings.SelfPlate ? "on" : "off")}" +
|
||||
(MonsterHudSettings.SelfPlacement == SelfPlacement.Fixed
|
||||
? (MonsterHudSettings.SelfLocked ? ", fixed on screen (locked)." : ", fixed on screen (unlocked: drag it).")
|
||||
: FirstPerson ? ", follows you (first person" + (MonsterHudSettings.SelfHideFirstPerson ? ", hidden)." : ").") : ", follows you.");
|
||||
: FirstPerson ? ", follows you (first person" + (MonsterHudSettings.SelfHideFirstPerson ? ", hidden)." : ").") : ", follows you.") +
|
||||
(MonsterHudSettings.SelfDebuffs
|
||||
? $" Debuffs on you: {_iconCount} icon(s){(PortalSpellTable.Ready ? "" : " (spell table not loaded)")}."
|
||||
: "");
|
||||
}
|
||||
|
|
|
|||
119
src/RynthCore.Engine/ImGui/MonsterHud/SelfDebuffs.cs
Normal file
119
src/RynthCore.Engine/ImGui/MonsterHud/SelfDebuffs.cs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - ImGui/MonsterHud/SelfDebuffs.cs
|
||||
// "Debuffs on you" (2026-10-27): which harmful spells on the player get an
|
||||
// icon in the row under your plate's mana bar. A pure function over the
|
||||
// engine's player enchantment snapshot (EnchantmentHooks.CopyPlayerStatMods:
|
||||
// spell id, expiry in server seconds, spell category); PlayerPlate reads the
|
||||
// snapshot four times a second and hands it in with the server time and a
|
||||
// lookup (PortalSpellTable.TryGetById, which only holds non-beneficial
|
||||
// enchantments, so a hit means harmful; PlateDebuffs.KindOf gives the icon).
|
||||
//
|
||||
// Rules, the monster row's where they apply:
|
||||
// - only harmful spells; cooldowns (ids 0x8000+) and buffs never show;
|
||||
// - an entry already past its expiry is dropped, and so is one that never
|
||||
// ends (vitae, spells from items: a state, not a fight debuff; the Buffs
|
||||
// tab still lists them);
|
||||
// - one entry per spell category: AC runs the strongest of a category and
|
||||
// the rest wait under it, so the category lasts until its last entry ends;
|
||||
// - one icon per kind (DebuffKind); a kind merging several categories shows
|
||||
// their count and the soonest end, like the monster row;
|
||||
// - icons in kind order (the monster row's), as many as fit in dst; the
|
||||
// count returned includes the rest (the "+N").
|
||||
// No engine dependencies beyond DebuffIcon.cs (the offline tests compile it).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
||||
namespace RynthCore.Engine.ImGuiBackend.Hud;
|
||||
|
||||
/// <summary>A harmful spell's icon kind and full length (s); false for a spell that isn't harmful.</summary>
|
||||
internal delegate bool HarmfulSpellLookup(uint spellId, out DebuffKind kind, out float duration);
|
||||
|
||||
internal static class SelfDebuffs
|
||||
{
|
||||
/// <summary>Expiries at or past this (server seconds) never end; the snapshot writes double.MaxValue for them.</summary>
|
||||
internal const double NoEnd = 1e12;
|
||||
/// <summary>Snapshot ids from here up are cooldowns, not spells.</summary>
|
||||
internal const uint FirstCooldownId = 0x8000;
|
||||
/// <summary>Snapshot entries looked at (the player rarely carries more than ~100).</summary>
|
||||
internal const int MaxEntries = 256;
|
||||
private const int KindCount = (int)DebuffKind.Other + 1;
|
||||
private const double MaxRemainingSec = 1e6; // keeps the tick conversion far from overflow
|
||||
|
||||
/// <summary>
|
||||
/// Fills <paramref name="dst"/> with the icons for the first <paramref name="n"/> snapshot entries
|
||||
/// (<paramref name="ids"/>, <paramref name="expiry"/> in server seconds, <paramref name="categories"/>)
|
||||
/// at server time <paramref name="serverNow"/>; icon expiries come out in Stopwatch ticks from
|
||||
/// <paramref name="nowTicks"/>. Returns the icon count (may exceed dst.Length: the overflow).
|
||||
/// 0 when the server time isn't known yet.
|
||||
/// </summary>
|
||||
internal static int Select(uint[] ids, double[] expiry, uint[] categories, int n, double serverNow,
|
||||
long nowTicks, long ticksPerSecond, HarmfulSpellLookup harmful, DebuffIcon[] dst)
|
||||
{
|
||||
if (serverNow <= 0 || n <= 0) return 0;
|
||||
n = Math.Min(Math.Min(n, MaxEntries), Math.Min(ids.Length, Math.Min(expiry.Length, categories.Length)));
|
||||
|
||||
// 1. Live harmful entries, one per spell category (the one that ends last).
|
||||
Span<uint> catKey = stackalloc uint[MaxEntries];
|
||||
Span<double> catEnd = stackalloc double[MaxEntries];
|
||||
Span<float> catDur = stackalloc float[MaxEntries];
|
||||
Span<byte> catKind = stackalloc byte[MaxEntries];
|
||||
int cats = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
uint id = ids[i];
|
||||
if (id == 0 || id >= FirstCooldownId) continue;
|
||||
double end = expiry[i];
|
||||
if (double.IsNaN(end) || end >= NoEnd || end <= serverNow) continue;
|
||||
if (!harmful(id, out DebuffKind kind, out float dur)) continue;
|
||||
// No category recorded: the spell stands alone (ids are below 0x8000, so no clash).
|
||||
uint key = categories[i] != 0 ? categories[i] : 0x80000000u | id;
|
||||
int c = 0;
|
||||
while (c < cats && catKey[c] != key) c++;
|
||||
if (c == cats)
|
||||
{
|
||||
catKey[c] = key;
|
||||
cats++;
|
||||
}
|
||||
else if (end <= catEnd[c])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
catEnd[c] = end;
|
||||
catDur[c] = dur;
|
||||
catKind[c] = (byte)Math.Min((int)kind, KindCount - 1);
|
||||
}
|
||||
if (cats == 0) return 0;
|
||||
|
||||
// 2. One icon per kind: the categories it merges and the soonest end among them.
|
||||
Span<long> kindEnd = stackalloc long[KindCount];
|
||||
Span<float> kindDur = stackalloc float[KindCount];
|
||||
Span<int> kindStack = stackalloc int[KindCount];
|
||||
kindEnd.Clear();
|
||||
kindDur.Clear();
|
||||
kindStack.Clear();
|
||||
for (int c = 0; c < cats; c++)
|
||||
{
|
||||
int k = catKind[c];
|
||||
double remaining = Math.Min(catEnd[c] - serverNow, MaxRemainingSec);
|
||||
long end = nowTicks + (long)(remaining * ticksPerSecond);
|
||||
if (kindStack[k] == 0 || end < kindEnd[k])
|
||||
{
|
||||
kindEnd[k] = end;
|
||||
kindDur[k] = catDur[c];
|
||||
}
|
||||
kindStack[k]++;
|
||||
}
|
||||
|
||||
// 3. In kind order, as many as fit; the count includes the rest.
|
||||
int count = 0;
|
||||
for (int k = 0; k < KindCount; k++)
|
||||
{
|
||||
if (kindStack[k] == 0) continue;
|
||||
if (count < dst.Length)
|
||||
dst[count] = new DebuffIcon { Kind = (DebuffKind)k, Expiry = kindEnd[k], Duration = kindDur[k], Stack = kindStack[k] };
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
|
@ -1267,6 +1267,15 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
/// </summary>
|
||||
private void DrawLineColours()
|
||||
{
|
||||
bool retail = ChatLineColors.RetailColors;
|
||||
if (ImGuiNET.ImGui.Checkbox("Retail colours", ref retail))
|
||||
{
|
||||
ChatLineColors.RetailColors = retail;
|
||||
SaveColours();
|
||||
}
|
||||
SafeImGui.SetItemTooltip("Each kind of line in AC's own colour: magic and spells blue, combat red, tells yellow,\n" +
|
||||
"system purple, allegiance orange. RynthCore's own lines (the Rynth and Items tabs) keep theirs.\n" +
|
||||
"Off: every line takes its tab's colour. A colour you set below still wins.");
|
||||
Label("A rule's colour wins over these.", Mute);
|
||||
ColourGroup("Chat", ChatLineColors.ChatKinds);
|
||||
|
||||
|
|
@ -1320,7 +1329,9 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ImGuiNET.ImGui.SameLine();
|
||||
Label(kind.Label, RynthTheme.Argb(argb));
|
||||
SafeImGui.SetItemTooltip(kind.Hint + (set ? "" : kind.Key.StartsWith(ChatLineColors.TabPrefix, StringComparison.Ordinal)
|
||||
? "\nThe built-in colour." : $"\nNot set: the {kind.Tab} tab's colour."));
|
||||
? (ChatLineColors.RetailColors ? "\nThe built-in colour, for lines AC has no colour for (Retail colours on)." : "\nThe built-in colour.")
|
||||
: ChatLineColors.RetailColors && ChatLineColors.Get(ChatLineColors.TabPrefix + kind.Tab) == null
|
||||
? "\nNot set: AC's own colour." : $"\nNot set: the {kind.Tab} tab's colour."));
|
||||
if (set)
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ internal sealed class ChatFiltersFace : IImGuiPanel
|
|||
if (route.Tabs != null) tabs.AddRange(route.Tabs);
|
||||
where = tabs.Count == 0 ? "Shown nowhere." : "Shows in: " + string.Join(", ", tabs) + ".";
|
||||
}
|
||||
uint color = RynthTheme.Argb(ChatLineColors.Resolve(route.LineArgb, ChatLineColors.KindOf(type, channel, text), channel));
|
||||
uint color = RynthTheme.Argb(ChatLineColors.Resolve(route.LineArgb, ChatLineColors.KindOf(type, channel, text), channel, type));
|
||||
_testResult.Add((where + (route.LineArgb != null ? " (this is its colour)" : ""), route.Hidden ? Faded(Mute) : color));
|
||||
|
||||
// Not hidden: name a standard filter that would hide it (one not in the rules yet).
|
||||
|
|
|
|||
|
|
@ -207,6 +207,7 @@ internal sealed class ClassicMonstersTab : IClassicTab
|
|||
// Debuffs and shapes: three gems a row.
|
||||
float gw = w / 3;
|
||||
y = GemGrid("Debuffs", DamageCommands.DebuffDefs, sel, name, new Vector2(o.X, y), gw);
|
||||
y = GemGrid("Void", DamageCommands.VoidDebuffDefs, sel, name, new Vector2(o.X, y), gw);
|
||||
y = GemGrid("Spells", DamageCommands.ShapeDefs, sel, name, new Vector2(o.X, y), gw);
|
||||
return y;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@ internal sealed class DamageDetailFace : IImGuiPanel
|
|||
|
||||
// A name rule has no Damage panel row: its debuffs, off hand and pet are set here.
|
||||
ToggleRow("Debuffs", DamageCommands.DebuffDefs, view, name);
|
||||
ToggleRow("Void", DamageCommands.VoidDebuffDefs, view, name);
|
||||
int off = view.OffhandId;
|
||||
string offText = off >= 0 && off < DamageCommands.OffhandModeNames.Length ? DamageCommands.OffhandModeNames[off] : "Item " + unchecked((uint)off);
|
||||
Combo("Off hand", "##offhand", DamageCommands.OffhandModeNames, offText,
|
||||
|
|
|
|||
|
|
@ -1046,6 +1046,7 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
{
|
||||
var parts = new List<string>();
|
||||
foreach (var (field, label, _) in DamageCommands.DebuffDefs) if (v.GetToggle(field)) parts.Add(label);
|
||||
foreach (var (field, _, tip) in DamageCommands.VoidDebuffDefs) if (v.GetToggle(field)) parts.Add(tip[..tip.IndexOf(':')]);
|
||||
if (!string.IsNullOrEmpty(v.ExVuln) && !v.ExVuln.Equals("None", StringComparison.OrdinalIgnoreCase)) parts.Add("Extra Vuln: " + v.ExVuln);
|
||||
if (!string.IsNullOrWhiteSpace(v.CustomDebuffs)) parts.Add("Yours: " + v.CustomDebuffs);
|
||||
return string.Join("\n", parts);
|
||||
|
|
@ -1099,6 +1100,22 @@ internal sealed class DamageFace : IImGuiPanel
|
|||
SafeImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
// The Void debuffs, two to a row.
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Void Magic");
|
||||
for (int i = 0; i < DamageCommands.VoidDebuffDefs.Length; i++)
|
||||
{
|
||||
var (field, label, tip) = DamageCommands.VoidDebuffDefs[i];
|
||||
if (i % 2 == 1) ImGuiNET.ImGui.SameLine(140);
|
||||
bool on = view.GetToggle(field);
|
||||
if (ImGuiNET.ImGui.Checkbox(label + "##db_" + field, ref on))
|
||||
{
|
||||
bool v = on;
|
||||
string f = field;
|
||||
DamageCommands.EditRule(name, rule => rule.SetToggle(f, v));
|
||||
}
|
||||
SafeImGui.SetItemTooltip(tip);
|
||||
}
|
||||
|
||||
ImGuiNET.ImGui.TextColored(RynthTheme.VecOf(RynthTheme.MuteAlt), "Extra Vuln");
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
string ex = string.IsNullOrEmpty(view.ExVuln) ? "None" : view.ExVuln;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,19 @@
|
|||
// here is saved the same way and a pin made here is the same pin. A drawer
|
||||
// that wasn't drawn in a frame drops its hub subscriptions (EndFrame).
|
||||
//
|
||||
// AC thread only (inside RynthAi's window, and EndFrame after the panels).
|
||||
// 2026-10-27: RynthVision draws the whole Vision window itself (it takes over
|
||||
// the engine's VisionFace, "takeOver"), but two of its tabs set things that are
|
||||
// still RynthCore's: the nameplates and the combat text (ImGui/MonsterHud,
|
||||
// MonsterHudSettings) are drawn by the engine until they move to RynthVision.
|
||||
// So RynthVision's window asks for those two tab bodies here, the same rows the
|
||||
// engine's Vision panel shows (MonsterHudSettingsUi), saved the same way:
|
||||
// nameplates the "Nameplates" tab
|
||||
// combattext the "Combat text" tab
|
||||
// They draw popped out too (the engine's Vision panel did); the three drawers
|
||||
// above stay docked-only (UiKit.RenderSettingsDrawer, DrawsPoppedOut).
|
||||
//
|
||||
// AC thread only (inside RynthAi's or RynthVision's window, and EndFrame after
|
||||
// the panels).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
|
@ -43,6 +55,7 @@ internal static class SettingsDrawerBodies
|
|||
{
|
||||
Vector2 at = ImGuiNET.ImGui.GetCursorScreenPos();
|
||||
float w = MathF.Max(1, width);
|
||||
if (key is "nameplates" or "combattext") return DrawVisionTab(key, at, w);
|
||||
float k = MathF.Max(1f, ImGuiFonts.Get(UiFont.Dash11).FontSize / 11f);
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Dash10));
|
||||
try
|
||||
|
|
@ -101,6 +114,30 @@ internal static class SettingsDrawerBodies
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>True for the bodies that draw in a popped-out window too (the Vision tabs).</summary>
|
||||
public static bool DrawsPoppedOut(string key) => key is "nameplates" or "combattext";
|
||||
|
||||
/// <summary>
|
||||
/// A Vision tab RynthVision's window shows (the engine's rows: MonsterHudSettingsUi), in Ui11 as the
|
||||
/// engine's Vision panel drew them. Returns the height drawn.
|
||||
/// </summary>
|
||||
private static float DrawVisionTab(string key, Vector2 at, float w)
|
||||
{
|
||||
ImGuiNET.ImGui.PushFont(ImGuiFonts.Get(UiFont.Ui11));
|
||||
ImGuiNET.ImGui.PushID(key == "nameplates" ? "##sdb_plates" : "##sdb_ctext");
|
||||
try
|
||||
{
|
||||
if (key == "nameplates") Hud.MonsterHudSettingsUi.DrawNameplates(w);
|
||||
else Hud.MonsterHudSettingsUi.DrawCombatText(w);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ImGuiNET.ImGui.PopID();
|
||||
ImGuiNET.ImGui.PopFont();
|
||||
}
|
||||
return MathF.Max(0f, ImGuiNET.ImGui.GetCursorScreenPos().Y - at.Y);
|
||||
}
|
||||
|
||||
/// <summary>After the panels each frame: a body that wasn't drawn this frame lets its hub sources go.</summary>
|
||||
public static void EndFrame()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,14 @@
|
|||
// your own plate), engine-side (Hud/MonsterHudSettingsUi);
|
||||
// Combat text floating damage / heal numbers, kill burst and gains.
|
||||
//
|
||||
// 2026-10-27: RynthVision draws the Vision window itself (its manifest's
|
||||
// "takeOver" window, RynthVision Ui/VisionWindow.cs, on engines with plugin
|
||||
// API v91): this face then steps aside (ImGuiPanelHost.TakeOver; same key, so
|
||||
// the saved place, bar button, hotkeys and /rc commands carry over) and comes back
|
||||
// when RynthVision unloads. Its Nameplates and Combat text tabs are drawn into
|
||||
// RynthVision's window by the engine (SettingsDrawerBodies "nameplates" /
|
||||
// "combattext"). Kept for an older RynthVision; goes a release after.
|
||||
//
|
||||
// Terrain edits a private copy and saves just the changed field
|
||||
// (VisionCommands) when a control finishes changing (a slider on release).
|
||||
// A newer snapshot replaces the copy unless a control is in use. The other
|
||||
|
|
|
|||
|
|
@ -997,7 +997,9 @@ internal struct RynthCoreAPI
|
|||
/// open its list of settings to pin). Drawn at the cursor of the window being drawn, <c>width</c>
|
||||
/// pixels wide and at most <c>room</c> tall (0 = its own height). Returns the height it wants
|
||||
/// (pixels), -1 for another key. AC's render thread, inside a docked window's
|
||||
/// RynthPluginRenderEmbed. Requires API v90+.</summary>
|
||||
/// RynthPluginRenderEmbed. Requires API v90+. 2026-10-27 (engines with v91): also "nameplates"
|
||||
/// and "combattext", the Vision window's tabs that set RynthCore's nameplates and combat text,
|
||||
/// for RynthVision's own Vision window (it takes over the engine's); those draw popped out too.</summary>
|
||||
public IntPtr RenderSettingsDrawerFn;
|
||||
/// <summary>v90: <c>int GetShortcuts(uint* objectIds, uint* spellIds, int max)</c>: the player's
|
||||
/// 18 shortcut slots (AC's own, the retail toolbar's), object id 0 = empty. Returns 18, or 0 out
|
||||
|
|
@ -1023,7 +1025,9 @@ internal struct RynthCoreAPI
|
|||
/// <summary>v90: <c>int SetActionKey(const char* action, const char* key, int op, char* message, int
|
||||
/// length)</c>: a keymap action ("UseQuickSlot_5") or engine command ("/rdef use 2") and a key: op 0
|
||||
/// checks (0 free, 1 taken from what the message names, -1 can't), 1 binds it (off everything else,
|
||||
/// every client follows), 2 removes it (1 queued, -1 refused). Any thread. Requires API v90+.</summary>
|
||||
/// every client follows), 2 removes it, 3 binds an engine command's key as its hotkey alone (AC's keymap
|
||||
/// untouched; engines after 2026-10-27, older ones refuse it) (1 queued, -1 refused). Any thread.
|
||||
/// Requires API v90+.</summary>
|
||||
public IntPtr SetActionKeyFn;
|
||||
/// <summary>v90: <c>int AcPanel(int id, int op)</c>: AC's own panel by the id its panel notice uses (7
|
||||
/// the pack, 12 fellowship/allegiance, 13 spellbook, 16 the map...): op 0 asks (1 open, 0 closed, -1
|
||||
|
|
@ -1039,6 +1043,20 @@ internal struct RynthCoreAPI
|
|||
/// dropped since the last call (0 = none); *dragging = 1 while an item drag is on. A claimed drop never
|
||||
/// reaches AC. AC's main thread, in the window's draw. Requires API v90+.</summary>
|
||||
public IntPtr DropTargetFn;
|
||||
|
||||
// ── v91: a floor under the world's ambient light (D3D9/AmbientLight.cs) ──
|
||||
|
||||
/// <summary>v91: <c>int SetAmbientLightFloor(uint rgb)</c>: the least ambient light AC may draw the
|
||||
/// world with, 0x00RRGGBB (alpha ignored; per channel the brighter of AC's and this), 0 = none
|
||||
/// (AC's own). Shows from the next frame, in this client only (drawing; nothing goes to the
|
||||
/// server). Returns 1 when the engine's hook is live, 0 when it isn't (not installed, or switched
|
||||
/// off: /rc hooks AmbientLight). One floor for all plugins (the last call wins); it goes back to 0
|
||||
/// when the plugins unload. Any thread. Requires API v91+.</summary>
|
||||
public IntPtr SetAmbientLightFloorFn;
|
||||
/// <summary>v91: <c>int GetAmbientLight(uint* client, uint* applied)</c>: the ambient colour AC last
|
||||
/// asked for and the one drawn (0xAARRGGBB; 0 before the first frame). Returns 1 when the hook is
|
||||
/// live, 0 when it isn't (both 0). Either pointer may be null. Any thread. Requires API v91+.</summary>
|
||||
public IntPtr GetAmbientLightFn;
|
||||
}
|
||||
|
||||
/// <summary>v89 GetUiColor tokens. Append only: plugins compiled against these numbers keep them.</summary>
|
||||
|
|
@ -1891,6 +1909,12 @@ internal unsafe delegate int PanelScaleCallbackDelegate(byte* key, int percent);
|
|||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate uint DropTargetCallbackDelegate(byte* window, float x0, float y0, float x1, float y1, int flags, int* dragging);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal delegate int SetAmbientLightFloorCallbackDelegate(uint rgb);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetAmbientLightCallbackDelegate(uint* client, uint* applied);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate uint VendorBuyCallbackDelegate(uint vendorId, VendorTradeEntryNative* entries, int count);
|
||||
|
||||
|
|
|
|||
|
|
@ -33,5 +33,12 @@ internal static class PluginContractVersion
|
|||
// v90: windows that draw their own frame (manifest "chrome": "none", "fitHeight"):
|
||||
// PanelDragWithLastItem, SetPanelPopOut, PanelTextSize; GetUiColor's Muted and instrument
|
||||
// shades (KeyFace, Hairline, Inset, Faint), GetUiFont's Dash and Narrow fonts (2026-10-21).
|
||||
public const uint Current = 90;
|
||||
// v91: SetAmbientLightFloor and GetAmbientLight: a floor under AC's world ambient light, drawn
|
||||
// in this client only (D3D9/AmbientLight.cs; RynthVision's dungeon light, 2026-10-27).
|
||||
// No table change, same release: RenderSettingsDrawer also draws "nameplates" and
|
||||
// "combattext" (popped out too), the engine-owned tabs of RynthVision's own Vision window.
|
||||
// v92: SetActionKey op 3, a RynthCore command's key as an engine hotkey only (AC's keymap untouched),
|
||||
// and the SDK's BindCommandKeyOnly / UnbindCommandKeyOnly; no new function or field, but a plugin
|
||||
// calling them needs this SDK in Runtime\PluginShared (fix/keymap-follow-change, 2026-10-27).
|
||||
public const uint Current = 92;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -301,6 +301,8 @@ internal static partial class PluginManager
|
|||
private static AcPanelCallbackDelegate? _acPanelCallback; // v90
|
||||
private static PanelScaleCallbackDelegate? _panelScaleCallback; // v90
|
||||
private static DropTargetCallbackDelegate? _dropTargetCallback; // v90
|
||||
private static SetAmbientLightFloorCallbackDelegate? _setAmbientLightFloorCallback; // v91
|
||||
private static GetAmbientLightCallbackDelegate? _getAmbientLightCallback; // v91
|
||||
private static ForceResetBusyCountCallbackDelegate? _forceResetBusyCountCallback;
|
||||
private static GetObjectSpellIdsCallbackDelegate? _getObjectSpellIdsCallback;
|
||||
private static GetObjectSkillLevelCallbackDelegate? _getObjectSkillBuffedCallback;
|
||||
|
|
@ -3224,6 +3226,8 @@ internal static partial class PluginManager
|
|||
_acPanelCallback ??= ShortcutApi.AcPanel;
|
||||
unsafe { _panelScaleCallback ??= UiKit.PanelScale; }
|
||||
unsafe { _dropTargetCallback ??= ShortcutApi.DropTarget; }
|
||||
_setAmbientLightFloorCallback ??= AmbientLight.SetFloor; // v91
|
||||
unsafe { _getAmbientLightCallback ??= AmbientLight.Get; }
|
||||
|
||||
_api.Version = PluginContractVersion.Current;
|
||||
_api.LogFn = Marshal.GetFunctionPointerForDelegate(_logCallback);
|
||||
|
|
@ -3394,6 +3398,8 @@ internal static partial class PluginManager
|
|||
_api.AcPanelFn = Marshal.GetFunctionPointerForDelegate(_acPanelCallback);
|
||||
_api.PanelScaleFn = Marshal.GetFunctionPointerForDelegate(_panelScaleCallback);
|
||||
_api.DropTargetFn = Marshal.GetFunctionPointerForDelegate(_dropTargetCallback);
|
||||
_api.SetAmbientLightFloorFn = Marshal.GetFunctionPointerForDelegate(_setAmbientLightFloorCallback);
|
||||
_api.GetAmbientLightFn = Marshal.GetFunctionPointerForDelegate(_getAmbientLightCallback);
|
||||
RouteApiThroughLoader();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,8 +163,11 @@ internal static unsafe class ShortcutApi
|
|||
/// v90 SetActionKey: for a keymap action ("UseQuickSlot_5") or an engine command ("/rdef use 2"), key
|
||||
/// "Ctrl+F5" (or a key as GetActionKeys wrote it, to remove): op 0 checks (0 free, 1 it would be taken
|
||||
/// from what the message names, -1 it can't be, why in the message), 1 binds it (it comes off
|
||||
/// everything else; every client follows within a second), 2 removes it. 1/2 return 1 queued (done on
|
||||
/// AC's game thread; the result goes to chat), -1 refused (why in the message). Any thread.
|
||||
/// everything else; every client follows within a second), 2 removes it (an engine command's: its hotkey
|
||||
/// only, as ever), 3 binds an engine command's key as its hotkey alone (off RynthCore's other hotkeys; AC's
|
||||
/// keymap untouched, nothing reloaded anywhere; 2026-10-27, an engine before that refuses op 3 as unknown).
|
||||
/// 1-3 return 1 queued (done on AC's game thread; the result goes to chat), -1 refused (why in the
|
||||
/// message). Any thread.
|
||||
/// </summary>
|
||||
public static int SetActionKey(byte* action, byte* key, int op, byte* message, int length)
|
||||
{
|
||||
|
|
@ -176,7 +179,7 @@ internal static unsafe class ShortcutApi
|
|||
string msg;
|
||||
int result;
|
||||
if (op == 0) result = AcKeymapLive.Check(a, k, out msg);
|
||||
else if (op is 1 or 2) result = AcKeymapLive.Enqueue(a, k, op == 1 ? AcKeymapLive.Op.Bind : AcKeymapLive.Op.Unbind, out msg) ? 1 : -1;
|
||||
else if (op is 1 or 2 or 3) result = AcKeymapLive.Enqueue(a, k, (AcKeymapLive.Op)op, out msg) ? 1 : -1;
|
||||
else { result = -1; msg = "Unknown op."; }
|
||||
Write(msg, message, length);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -212,17 +212,19 @@ internal static unsafe class UiKit
|
|||
/// v90 RenderSettingsDrawer: the body of a dashboard drawer that shows Settings rows ("ranges",
|
||||
/// "patrol", "pinned"; SettingsDrawerBodies) at the cursor, <paramref name="width"/> pixels wide
|
||||
/// and at most <paramref name="room"/> tall (0 = its own height); flags 1: open My settings' list
|
||||
/// of settings to pin. Returns the height it wants (pixels), -1 for another key or outside a
|
||||
/// docked panel's draw on AC's thread.
|
||||
/// of settings to pin. Since 2026-10-27 also the Vision window's engine-owned tabs for RynthVision's
|
||||
/// own window ("nameplates", "combattext"), which draw popped out too. Returns the height it wants
|
||||
/// (pixels), -1 for another key or outside a panel's draw on AC's thread (docked, for the drawers).
|
||||
/// </summary>
|
||||
public static float RenderSettingsDrawer(byte* key, float width, float room, int flags)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (key == null || !MainThreadGuard.IsOnMainThread() || ImGuiPanelHost.DrawingTitle == null
|
||||
|| ImGuiPopOuts.InPopOutFrame || !float.IsFinite(width) || !float.IsFinite(room)) return -1f;
|
||||
|| !float.IsFinite(width) || !float.IsFinite(room)) return -1f;
|
||||
string? name = Marshal.PtrToStringUTF8((IntPtr)key);
|
||||
if (string.IsNullOrEmpty(name) || name.Length > MaxKeyLength) return -1f;
|
||||
if (ImGuiPopOuts.InPopOutFrame && !SettingsDrawerBodies.DrawsPoppedOut(name)) return -1f;
|
||||
return SettingsDrawerBodies.Draw(name, width, MathF.Max(0f, room), (flags & 1) != 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ internal static class ChatModel
|
|||
|
||||
/// <summary>The line's colour: a rule's line colour, else the colour set for its kind
|
||||
/// (say, fellowship, [General]...), else its channel's. 0xAARRGGBB.</summary>
|
||||
public static uint LineArgb(ChatLine line) => ChatLineColors.Resolve(line.Route.LineArgb, line.ColorKind, line.Channel);
|
||||
public static uint LineArgb(ChatLine line) => ChatLineColors.Resolve(line.Route.LineArgb, line.ColorKind, line.Channel, line.ChatType);
|
||||
|
||||
/// <summary>
|
||||
/// What a rule's "When" can be: (stored value, label). Channel tabs, then
|
||||
|
|
@ -1415,6 +1415,7 @@ internal static class ChatModel
|
|||
HistoryLines = ChatHistory.Clamp(dto.HistoryLines ?? 0); // absent before 2026-10-11: the default
|
||||
TabsAcross = dto.TabsAcross ?? false; // absent before 2026-10-20 (and while off): the drawer
|
||||
ChatLineColors.Load(dto.LineColors); // absent before 2026-10-08: nothing set
|
||||
ChatLineColors.RetailColors = dto.RetailColors ?? true; // absent before 2026-10-28 (and while on): on
|
||||
|
||||
var tabs = new List<string>();
|
||||
foreach (string t in dto.CustomTabs ?? Array.Empty<string>())
|
||||
|
|
@ -1504,6 +1505,7 @@ internal static class ChatModel
|
|||
HistoryLines = HistoryLines == ChatHistory.DefaultLines ? null : HistoryLines,
|
||||
TabsAcross = TabsAcross ? true : null,
|
||||
LineColors = ChatLineColors.ToJson(), // null (left out) until a colour is set
|
||||
RetailColors = ChatLineColors.RetailColors ? null : false, // left out while on (the default)
|
||||
CustomTabs = Volatile.Read(ref _customTabs),
|
||||
Filters = Filters.Select(ToDto).ToArray(),
|
||||
// Only presets the user touched: new presets in later builds start off.
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@
|
|||
// 1. a rule's line colour (ChatRoute.LineArgb),
|
||||
// 2. the colour the user set for the line's kind,
|
||||
// 3. the colour the user set for its tab,
|
||||
// 4. the tab's built-in colour (what every line looked like before).
|
||||
// With nothing set, every line looks exactly as before.
|
||||
// 4. with Retail colours on (2026-10-28, the default), AC's own colour for
|
||||
// the line's ChatMessageType: magic blue, combat red, tells yellow...;
|
||||
// not for the Rynth and Items tabs (RynthCore's own lines),
|
||||
// 5. the tab's built-in colour (what every line looked like before).
|
||||
// With nothing set and Retail colours off, every line looks exactly as before.
|
||||
//
|
||||
// Kept apart from ChatData.cs (no engine state) so tools/ChatFilterTests can
|
||||
// compile it in. The colours are an immutable snapshot, replaced on every
|
||||
|
|
@ -69,7 +72,50 @@ internal static class ChatLineColors
|
|||
|
||||
/// <summary>A kind or tab's colour as it shows now: the user's, else its default.</summary>
|
||||
public static uint EffectiveArgb(ChatColorKind kind) =>
|
||||
Get(kind.Key) ?? (kind.Key.StartsWith(TabPrefix, StringComparison.Ordinal) ? BuiltInTabArgb(kind.Tab) : TabArgb(kind.Tab));
|
||||
Get(kind.Key) ?? (kind.Key.StartsWith(TabPrefix, StringComparison.Ordinal) ? BuiltInTabArgb(kind.Tab) : DefaultArgb(kind));
|
||||
|
||||
// ── Retail colours (2026-10-28) ──────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// AC's own chat colour for each ChatMessageType 0x00-0x21, as 0xAARRGGBB: the retail client's
|
||||
/// table, taken from OpenAC (AcDream.Runtime.Chat.RuntimeChatColors, MIT licence). 0x06/0x15
|
||||
/// combat red, 0x16 your hits on you light red, 0x07/0x11 magic and spellcasting light blue,
|
||||
/// 0x03 tells yellow, 0x05 system purple, 0x12 allegiance orange, 0x08/0x09 channels pink.
|
||||
/// </summary>
|
||||
private static readonly uint[] RetailArgbByType =
|
||||
{
|
||||
0xFF80FF7F, 0xFF80FF7F, 0xFFFFFFFF, 0xFFFFFF3F, // 0x00 default, 0x01 all, 0x02 speech, 0x03 tell
|
||||
0xFFD2D264, 0xFFFF7FFF, 0xFFFF3F3F, 0xFF3FBFFF, // 0x04 tell sent, 0x05 system, 0x06 combat, 0x07 magic
|
||||
0xFFFF9696, 0xFFFF9696, 0xFFFFFF3F, 0xFFD2D264, // 0x08 channel, 0x09 channel sent, 0x0A social, 0x0B social sent
|
||||
0xFFD2D2C8, 0xFF3FDCDC, 0xFFB4DCF0, 0xFFFF3F3F, // 0x0C emote, 0x0D advancement, 0x0E abuse, 0x0F help
|
||||
0xFF80FF7F, 0xFF3FBFFF, 0xFFEE921E, 0xFFFFFF3F, // 0x10 appraisal, 0x11 spellcasting, 0x12 allegiance, 0x13 fellowship
|
||||
0xFF80FF7F, 0xFFFF3F3F, 0xFFF57572, 0xFF80FF7F, // 0x14 world broadcast, 0x15 combat enemy, 0x16 combat self, 0x17 recall
|
||||
0xFF80FF7F, 0xFF80FF7F, 0xFFFF0000, 0xFFB4DCF0, // 0x18 craft, 0x19 salvaging, 0x1A, 0x1B
|
||||
0xFFB4DCF0, 0xFFB4DCF0, 0xFFB4DCF0, 0xFFFFFF3F, // 0x1C, 0x1D, 0x1E, 0x1F admin tell
|
||||
0xFFB4DCF0, 0xFFEE921E, // 0x20, 0x21
|
||||
};
|
||||
|
||||
private static volatile bool _retail = true;
|
||||
|
||||
/// <summary>Lines take AC's own colour for their kind (on unless the settings file says off).</summary>
|
||||
public static bool RetailColors { get => _retail; set => _retail = value; }
|
||||
|
||||
/// <summary>AC's own colour for <paramref name="chatType"/>, or null for a type it has none for (-1: unknown).</summary>
|
||||
public static uint? RetailArgb(int chatType) =>
|
||||
chatType >= 0 && chatType < RetailArgbByType.Length ? RetailArgbByType[chatType] : null;
|
||||
|
||||
/// <summary>The tabs of RynthCore's own lines (plugins' "[RynthAi] ..." and the item info), which keep their colour.</summary>
|
||||
private static bool IsOwnTab(string tab) =>
|
||||
string.Equals(tab, "Rynth", StringComparison.OrdinalIgnoreCase) || string.Equals(tab, "Items", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
private static uint? RetailFor(int chatType, string tab) => _retail && !IsOwnTab(tab) ? RetailArgb(chatType) : null;
|
||||
|
||||
/// <summary>The ChatMessageType a kind's lines come as, for showing its unset colour (the emotes: 0x0C, channels: 0x08).</summary>
|
||||
private static int TypeOfKind(string key) => key switch
|
||||
{
|
||||
Say => 0x02, Tell => 0x03, TellOut => 0x04, Allegiance => 0x12, Fellowship => 0x13, Emote => 0x0C,
|
||||
_ => key.StartsWith(ChanPrefix, StringComparison.Ordinal) ? 0x08 : -1,
|
||||
};
|
||||
|
||||
/// <summary>A tab's colour before anything is set, as 0xAARRGGBB (ChatModel.ChannelArgb until 2026-10-08).</summary>
|
||||
public static uint BuiltInTabArgb(string tab) => tab switch
|
||||
|
|
@ -216,12 +262,15 @@ internal static class ChatLineColors
|
|||
/// <summary>A tab's colour: the user's, else the built-in one. 0xAARRGGBB.</summary>
|
||||
public static uint TabArgb(string tab) => Get(TabPrefix + tab) ?? BuiltInTabArgb(tab);
|
||||
|
||||
/// <summary>What a kind looks like while it has no colour of its own: its tab's colour.</summary>
|
||||
public static uint DefaultArgb(ChatColorKind kind) => TabArgb(kind.Tab);
|
||||
/// <summary>What a kind looks like while it has no colour of its own: its tab's colour if the user
|
||||
/// set one, else AC's own (Retail colours on), else the tab's built-in colour.</summary>
|
||||
public static uint DefaultArgb(ChatColorKind kind) =>
|
||||
Get(TabPrefix + kind.Tab) ?? RetailFor(TypeOfKind(kind.Key), kind.Tab) ?? BuiltInTabArgb(kind.Tab);
|
||||
|
||||
/// <summary>A line's colour; see the header for the order.</summary>
|
||||
public static uint Resolve(uint? ruleArgb, string? kind, string channel) =>
|
||||
ruleArgb ?? Get(kind) ?? TabArgb(channel);
|
||||
/// <summary>A line's colour; see the header for the order. <paramref name="chatType"/> is AC's
|
||||
/// ChatMessageType (-1 unknown: no retail colour).</summary>
|
||||
public static uint Resolve(uint? ruleArgb, string? kind, string channel, int chatType = -1) =>
|
||||
ruleArgb ?? Get(kind) ?? Get(TabPrefix + channel) ?? RetailFor(chatType, channel) ?? BuiltInTabArgb(channel);
|
||||
|
||||
/// <summary>A key worth keeping from the settings file: a listed kind, a base tab, or a sane channel tag.</summary>
|
||||
public static bool IsValidKey(string? key)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ internal sealed class RynthChatSettingsDto
|
|||
// 2026-10-08: per-kind line colours (ChatLineColors), { "say": "#RRGGBB", "chan:General": ..., "tab:Chat": ... };
|
||||
// only the colours the user set, and absent while none is.
|
||||
[JsonPropertyName("lineColors")] public Dictionary<string, string>? LineColors { get; set; }
|
||||
// 2026-10-28: lines in AC's own colour for their kind (ChatLineColors.RetailColors); absent while on.
|
||||
[JsonPropertyName("retailColors")] public bool? RetailColors { get; set; }
|
||||
// 2026-10-11: how many lines the scrollback keeps (ChatHistory); absent at the default (2000).
|
||||
[JsonPropertyName("historyLines")] public int? HistoryLines { get; set; }
|
||||
// 2026-10-20: the tabs in a row across the top instead of the channels drawer; absent while off.
|
||||
|
|
|
|||
|
|
@ -691,6 +691,8 @@ internal static unsafe class DamageCommands
|
|||
ExVuln = s.ExVuln, PetDamage = "PAuto", AttackPower = "Default", Kite = "Default", PreferredDamage = "Auto",
|
||||
Fester = s.Fester, Broadside = s.Broadside, GravityWell = s.GravityWell,
|
||||
Imperil = s.Imperil, Yield = s.Yield, Vuln = s.Vuln,
|
||||
Corrosion = s.Corrosion, Corruption = s.Corruption, DestructiveCurse = s.DestructiveCurse,
|
||||
WeakeningCurse = s.WeakeningCurse, FesteringCurse = s.FesteringCurse,
|
||||
UseArc = s.UseArc, UseBolt = s.UseBolt, UseRing = s.UseRing, UseStreak = s.UseStreak, UseBlast = s.UseBlast, UseWall = s.UseWall,
|
||||
CustomDebuffs = s.CustomDebuffs,
|
||||
};
|
||||
|
|
@ -747,10 +749,23 @@ internal static unsafe class DamageCommands
|
|||
("GravityWell", "Gravity", "Gravity Well (Vulnerability Other)"),
|
||||
};
|
||||
|
||||
/// <summary>The Damage panel's one-letter debuff marks, in DebuffDefs order.</summary>
|
||||
/// <summary>The Void debuffs, cast with Void Magic (a character without it skips them). Drawn
|
||||
/// as their own group: the faces lay DebuffDefs out in one row.</summary>
|
||||
public static readonly (string Field, string Label, string Tip)[] VoidDebuffDefs =
|
||||
{
|
||||
("Corrosion", "Corrosion", "Corrosion: Nether damage over about 15 seconds.\nA Void projectile; the damage starts when it hits."),
|
||||
("Corruption", "Corruption", "Corruption: Nether damage over about 30 seconds.\nA Void blast (a spread of projectiles); the damage starts when it hits."),
|
||||
("DestructiveCurse", "Destructive", "Destructive Curse: Nether damage over about 30 seconds."),
|
||||
("WeakeningCurse", "Weakening", "Weakening Curse: the monster does less damage (15 seconds)."),
|
||||
("FesteringCurse", "Festering", "Festering Curse: the monster is healed less (30 seconds)."),
|
||||
};
|
||||
|
||||
/// <summary>The Damage panel's one-letter debuff marks, in DebuffDefs then VoidDebuffDefs order.</summary>
|
||||
public static readonly (string Field, char Letter)[] DebuffLetters =
|
||||
{
|
||||
("Imperil", 'I'), ("Vuln", 'V'), ("Fester", 'F'), ("Yield", 'Y'), ("Broadside", 'B'), ("GravityWell", 'G'),
|
||||
// Void: C Corrosion, R coRRuption, D Destructive Curse, W Weakening Curse, H Festering Curse (less healing).
|
||||
("Corrosion", 'C'), ("Corruption", 'R'), ("DestructiveCurse", 'D'), ("WeakeningCurse", 'W'), ("FesteringCurse", 'H'),
|
||||
};
|
||||
|
||||
/// <summary>"IVF" for the debuffs a rule has on; X = an extra vuln, + = typed-in ones.</summary>
|
||||
|
|
|
|||
|
|
@ -614,6 +614,22 @@ internal static class SettingsSchema
|
|||
"How big it is: 30% to 250% of normal. \"Text size\" = as big as the panels' text (Text Size above).\nAlso: Ctrl+wheel over it.",
|
||||
when: _ => ImGuiBackend.ImGuiPanelHost.HasFace(title));
|
||||
|
||||
// RynthVision's player plate lock (MonsterHudSettings, nameplate_settings.txt): locked unless it is fixed on
|
||||
// screen and unlocked (a plate following the character can't be dragged, so it reads as locked).
|
||||
private static bool SelfPlateLocked()
|
||||
{
|
||||
if (!ImGuiBackend.Hud.MonsterHudSettings.Loaded) { ImGuiBackend.Hud.MonsterHudSettings.EnsureLoadQueued(); return true; }
|
||||
return !ImGuiBackend.Hud.MonsterHudSettings.SelfMovable;
|
||||
}
|
||||
|
||||
// Unlocking a following plate fixes it on screen at its saved spot (SetSelfLocked); saved at once.
|
||||
private static void SetSelfPlateLocked(bool locked)
|
||||
{
|
||||
if (!ImGuiBackend.Hud.MonsterHudSettings.Loaded) { ImGuiBackend.Hud.MonsterHudSettings.EnsureLoadQueued(); return; }
|
||||
ImGuiBackend.Hud.MonsterHudSettings.SetSelfLocked(locked);
|
||||
ImGuiBackend.Hud.MonsterHudSettings.Save();
|
||||
}
|
||||
|
||||
private static SettingRow TextSize(string label, string panelTitle) =>
|
||||
Combo(" " + label, PanelTextScale.SizeNames, _ => PanelTextScale.GetOwn(panelTitle), (_, v) => PanelTextScale.Set(panelTitle, v),
|
||||
"This panel's size: 100% = normal, 10% a step. Also: Ctrl+wheel over the panel.")
|
||||
|
|
@ -832,6 +848,19 @@ internal static class SettingsSchema
|
|||
Bool("Hide retail vitals bar", _ => Compatibility.RetailVitalsHooks.HideRetailVitals,
|
||||
(_, v) => Compatibility.RetailVitalsHooks.HideRetailVitals = v,
|
||||
"Hide the game's own health/stamina/mana bars; the RynthVision player plate and the RynthAi dashboard show them.\nSaved for this PC. Also: /rc ui retailvitals on|off."),
|
||||
// RynthVision's own plate (2026-10-27: players couldn't find how to move it). The same setting as
|
||||
// Vision > Nameplates > Your plate > Lock position, stored by the engine (nameplate_settings.txt).
|
||||
Bool("Lock your vitals plate", _ => SelfPlateLocked(), (_, v) => SetSelfPlateLocked(v),
|
||||
"Your RynthVision plate (the health, stamina and mana bars). Untick it and the plate shows a frame:\n" +
|
||||
"drag it where you want it, then tick this again to lock it there. A plate that follows your character\n" +
|
||||
"is fixed on screen when you untick this. Same as Vision > Nameplates > Your plate > Lock position.\n" +
|
||||
"Also: /rv plates self lock on|off.",
|
||||
when: _ => ImGuiBackend.Hud.HudFeed.VisionInstalled),
|
||||
Note("To move it: untick, drag the plate itself (not where a panel covers it), then tick to lock it.",
|
||||
when: _ => ImGuiBackend.Hud.HudFeed.VisionInstalled && ImGuiBackend.Hud.MonsterHudSettings.SelfPlate),
|
||||
Note("Your plate is turned off: Vision > Nameplates > Your plate > Show your plate.",
|
||||
when: _ => ImGuiBackend.Hud.HudFeed.VisionInstalled && ImGuiBackend.Hud.MonsterHudSettings.Loaded
|
||||
&& !ImGuiBackend.Hud.MonsterHudSettings.SelfPlate),
|
||||
Spacer(),
|
||||
Section("Toolbar"),
|
||||
// Stored by the engine (RetailToolbarHooks, retail_ui.txt beside the vitals), not in the profile.
|
||||
|
|
|
|||
|
|
@ -116,6 +116,13 @@ internal static class MonstersPanel
|
|||
public bool Imperil { get; set; }
|
||||
public bool Yield { get; set; }
|
||||
public bool Vuln { get; set; }
|
||||
/// <summary>The Void debuffs (Void Magic): Corrosion, Corruption and Destructive Curse (Nether
|
||||
/// damage over time), Weakening Curse and Festering Curse. Off in rules saved before 2026-10-27.</summary>
|
||||
public bool Corrosion { get; set; }
|
||||
public bool Corruption { get; set; }
|
||||
public bool DestructiveCurse { get; set; }
|
||||
public bool WeakeningCurse { get; set; }
|
||||
public bool FesteringCurse { get; set; }
|
||||
public bool UseArc { get; set; }
|
||||
public bool UseRing { get; set; }
|
||||
public bool UseStreak { get; set; }
|
||||
|
|
@ -145,6 +152,11 @@ internal static class MonstersPanel
|
|||
"Imperil" => Imperil,
|
||||
"Yield" => Yield,
|
||||
"Vuln" => Vuln,
|
||||
"Corrosion" => Corrosion,
|
||||
"Corruption" => Corruption,
|
||||
"DestructiveCurse" => DestructiveCurse,
|
||||
"WeakeningCurse" => WeakeningCurse,
|
||||
"FesteringCurse" => FesteringCurse,
|
||||
"UseArc" => UseArc,
|
||||
"UseBolt" => UseBolt,
|
||||
"UseRing" => UseRing,
|
||||
|
|
@ -164,6 +176,11 @@ internal static class MonstersPanel
|
|||
case "Imperil": Imperil = v; break;
|
||||
case "Yield": Yield = v; break;
|
||||
case "Vuln": Vuln = v; break;
|
||||
case "Corrosion": Corrosion = v; break;
|
||||
case "Corruption": Corruption = v; break;
|
||||
case "DestructiveCurse": DestructiveCurse = v; break;
|
||||
case "WeakeningCurse": WeakeningCurse = v; break;
|
||||
case "FesteringCurse": FesteringCurse = v; break;
|
||||
case "UseArc": UseArc = v; break;
|
||||
case "UseBolt": UseBolt = v; break;
|
||||
case "UseRing": UseRing = v; break;
|
||||
|
|
@ -1031,6 +1048,8 @@ internal static class MonstersPanel
|
|||
|| x.MatchExpression != y.MatchExpression
|
||||
|| x.Fester != y.Fester || x.Broadside != y.Broadside || x.GravityWell != y.GravityWell
|
||||
|| x.Imperil != y.Imperil || x.Yield != y.Yield || x.Vuln != y.Vuln
|
||||
|| x.Corrosion != y.Corrosion || x.Corruption != y.Corruption || x.DestructiveCurse != y.DestructiveCurse
|
||||
|| x.WeakeningCurse != y.WeakeningCurse || x.FesteringCurse != y.FesteringCurse
|
||||
|| x.UseArc != y.UseArc || x.UseBolt != y.UseBolt
|
||||
|| x.UseRing != y.UseRing || x.UseStreak != y.UseStreak || x.UseBlast != y.UseBlast || x.UseWall != y.UseWall
|
||||
|| (x.CustomDebuffs ?? "") != (y.CustomDebuffs ?? ""))
|
||||
|
|
|
|||
Loading…
Reference in a new issue