Snapshot for release 2026.10.8.2 (internal ccc32e5)
This commit is contained in:
parent
650915dadc
commit
754c13f2b8
10 changed files with 677 additions and 31 deletions
|
|
@ -3,7 +3,8 @@
|
|||
// ImGui face of RynthChat (docked or popped out; the old Avalonia face is
|
||||
// UI/Panels/RynthChatPanel.cs): channel and custom tabs with unread counts
|
||||
// (right-click a tab: mark read, rename, delete), Filters (the ChatFilters
|
||||
// rule editor), the settings gear, search, the coloured scrollback, and the
|
||||
// rule editor), the settings gear (with a colour per kind of line under
|
||||
// "Line colours", ChatLineColors), search, the coloured scrollback, and the
|
||||
// input line with Tell and the panel's resize grip beside it.
|
||||
//
|
||||
// Scrollback: wrapped lines, heights cached per wrap width and font; only
|
||||
|
|
@ -91,6 +92,8 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
private string _unreadTab = "";
|
||||
|
||||
private bool _openSettings, _openNewTab, _focusNewTab, _openTabMenu, _openLineMenu, _openRename;
|
||||
/// <summary>A line colour changed and isn't saved yet (saved once the picker is let go).</summary>
|
||||
private bool _coloursDirty;
|
||||
private string? _ctxTab, _renameFrom;
|
||||
private ChatLine? _ctxLine;
|
||||
private string _ctxPattern = "";
|
||||
|
|
@ -747,7 +750,11 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
|
||||
private void DrawSettingsPopup()
|
||||
{
|
||||
if (!ImGuiNET.ImGui.BeginPopup("##chat_settings")) return;
|
||||
if (!ImGuiNET.ImGui.BeginPopup("##chat_settings"))
|
||||
{
|
||||
if (_coloursDirty) SaveColours(); // closed mid-drag
|
||||
return;
|
||||
}
|
||||
ImGuiNET.ImGui.PushItemWidth(150);
|
||||
int font = (int)MathF.Round(ChatModel.FontSize);
|
||||
if (ImGuiNET.ImGui.SliderInt("Font size", ref font, 8, 18)) ChatModel.FontSize = font;
|
||||
|
|
@ -819,10 +826,96 @@ internal sealed class ChatFace : IImGuiPanel
|
|||
ChatModel.SaveSettings();
|
||||
}
|
||||
}
|
||||
ImGuiNET.ImGui.Separator();
|
||||
if (ImGuiNET.ImGui.CollapsingHeader("Line colours")) DrawLineColours();
|
||||
|
||||
if (!ChatModel.PluginBound) Label("Plugin not bound", Mute);
|
||||
// A colour drag changes it every frame: save once the picker lets go.
|
||||
if (_coloursDirty && !ImGuiNET.ImGui.IsAnyItemActive()) SaveColours();
|
||||
ImGuiNET.ImGui.EndPopup();
|
||||
}
|
||||
|
||||
private void SaveColours()
|
||||
{
|
||||
_coloursDirty = false;
|
||||
ChatModel.SaveSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A colour per kind of line (ChatLineColors), two to a row: say, tells,
|
||||
/// allegiance, fellowship, emotes; each chat channel by its [Tag] (and any
|
||||
/// other tag seen this session); then the tab colours everything else takes.
|
||||
/// A rule's line colour still wins over all of these. x puts one back to its default.
|
||||
/// </summary>
|
||||
private void DrawLineColours()
|
||||
{
|
||||
Label("A rule's colour wins over these.", Mute);
|
||||
ColourGroup("Chat", ChatLineColors.ChatKinds);
|
||||
|
||||
var channels = new List<ChatColorKind>(ChatLineColors.ChannelKinds);
|
||||
var others = new List<string>(ChatLineColors.SeenTags);
|
||||
foreach (string key in ChatLineColors.SetKeys)
|
||||
if (ChatLineColors.IsOtherChannel(key)) others.Add(key[ChatLineColors.ChanPrefix.Length..]);
|
||||
foreach (string tag in others)
|
||||
if (!channels.Exists(c => string.Equals(c.Label, tag, StringComparison.OrdinalIgnoreCase)))
|
||||
channels.Add(new ChatColorKind(ChatLineColors.ChanPrefix + tag, tag, $"[{tag}] lines", "Channels"));
|
||||
ColourGroup("Channels", channels);
|
||||
|
||||
ColourGroup("Tabs (everything else)", ChatLineColors.TabKinds);
|
||||
|
||||
if (ChatLineColors.AnySet)
|
||||
{
|
||||
if (ImGuiNET.ImGui.SmallButton("Reset all colours"))
|
||||
{
|
||||
ChatLineColors.ResetAll();
|
||||
SaveColours();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ColourGroup(string title, IReadOnlyList<ChatColorKind> kinds)
|
||||
{
|
||||
Label(title, Teal);
|
||||
float x0 = ImGuiNET.ImGui.GetCursorPosX();
|
||||
for (int i = 0; i < kinds.Count; i++)
|
||||
{
|
||||
if (i % 2 == 1) ImGuiNET.ImGui.SameLine(x0 + 150);
|
||||
ColourRow(kinds[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void ColourRow(ChatColorKind kind)
|
||||
{
|
||||
uint argb = ChatLineColors.EffectiveArgb(kind);
|
||||
bool set = ChatLineColors.Get(kind.Key) != null;
|
||||
ImGuiNET.ImGui.PushID(kind.Key);
|
||||
Vector4 v = RynthTheme.Vec(argb);
|
||||
var rgb = new Vector3(v.X, v.Y, v.Z);
|
||||
if (ImGuiNET.ImGui.ColorEdit3("##col", ref rgb, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel))
|
||||
{
|
||||
ChatLineColors.Set(kind.Key, 0xFF000000
|
||||
| ((uint)Math.Clamp((int)MathF.Round(rgb.X * 255), 0, 255) << 16)
|
||||
| ((uint)Math.Clamp((int)MathF.Round(rgb.Y * 255), 0, 255) << 8)
|
||||
| (uint)Math.Clamp((int)MathF.Round(rgb.Z * 255), 0, 255));
|
||||
_coloursDirty = true;
|
||||
}
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
Label(kind.Label, RynthTheme.Argb(argb));
|
||||
ImGuiNET.ImGui.SetItemTooltip(kind.Hint + (set ? "" : kind.Key.StartsWith(ChatLineColors.TabPrefix, StringComparison.Ordinal)
|
||||
? "\nThe built-in colour." : $"\nNot set: the {kind.Tab} tab's colour."));
|
||||
if (set)
|
||||
{
|
||||
ImGuiNET.ImGui.SameLine();
|
||||
if (ImGuiNET.ImGui.SmallButton("x"))
|
||||
{
|
||||
ChatLineColors.Reset(kind.Key);
|
||||
SaveColours();
|
||||
}
|
||||
ImGuiNET.ImGui.SetItemTooltip("Back to the default colour");
|
||||
}
|
||||
ImGuiNET.ImGui.PopID();
|
||||
}
|
||||
|
||||
private void DrawNewTabPopup()
|
||||
{
|
||||
if (!ImGuiNET.ImGui.BeginPopup("##chat_newtab"))
|
||||
|
|
|
|||
|
|
@ -560,7 +560,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(route.LineArgb ?? ChatModel.ChannelArgb(channel));
|
||||
uint color = RynthTheme.Argb(ChatLineColors.Resolve(route.LineArgb, ChatLineColors.KindOf(type, channel, text), channel));
|
||||
_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).
|
||||
|
|
|
|||
|
|
@ -695,8 +695,10 @@ internal static unsafe class Win32Backend
|
|||
// GetAsyncKeyState reads the physical key whatever window has focus: without
|
||||
// the focus test, Insert (or Shift/Ctrl+Insert paste/copy) pressed in another
|
||||
// client or app flipped this client's capture off unseen. Not while typing in
|
||||
// RynthChat: there Shift/Ctrl+Insert are paste/copy.
|
||||
if (insertDown && !_insertWasDown && _hasFocus && !ChatCaptureActive)
|
||||
// RynthChat: there Shift/Ctrl+Insert are paste/copy. Opt-in (Settings > Display,
|
||||
// EngineSettings.InsertReleasesUi): off, Insert does nothing.
|
||||
if (insertDown && !_insertWasDown && _hasFocus && !ChatCaptureActive
|
||||
&& Plugins.EngineSettings.InsertReleasesUi)
|
||||
{
|
||||
_uiCaptureEnabled = !_uiCaptureEnabled;
|
||||
RynthLog.Render($"Win32Backend: ImGui capture {(_uiCaptureEnabled ? "ENABLED" : "DISABLED")} (Insert)");
|
||||
|
|
@ -1725,6 +1727,15 @@ internal static unsafe class Win32Backend
|
|||
return _uiCaptureEnabled;
|
||||
}
|
||||
|
||||
/// <summary>The Insert toggle was switched off in the settings: a released UI comes back,
|
||||
/// since Insert can no longer bring it back. AC thread.</summary>
|
||||
public static void ReclaimUi()
|
||||
{
|
||||
if (_uiCaptureEnabled || !_initialized) return;
|
||||
_uiCaptureEnabled = true;
|
||||
RynthLog.Render("Win32Backend: ImGui capture ENABLED (the Insert toggle was switched off)");
|
||||
}
|
||||
|
||||
private static OverlayPoint ClientToOverlayPoint(int clientX, int clientY)
|
||||
{
|
||||
if (!GetClientRect(_gameHwnd, out RECT rect))
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ internal static class EngineSettings
|
|||
private static readonly HashSet<string> _disabledUiHooks = new(StringComparer.OrdinalIgnoreCase);
|
||||
private static bool _serverMessageStream = true;
|
||||
private static bool _flightRecorder = true;
|
||||
private static bool _insertReleasesUi;
|
||||
private static bool _loaded;
|
||||
|
||||
public static IReadOnlyList<string> PluginPaths
|
||||
|
|
@ -302,6 +303,26 @@ internal static class EngineSettings
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>"InsertReleasesUi" in engine.json (default false, 2026-10-08): Insert hands the
|
||||
/// mouse to the game (the UI/GAME toggle, Win32Backend), for clicking through a Rynth window.
|
||||
/// Off, Insert does nothing: a stray press left every Rynth text box unable to keep the
|
||||
/// keyboard, which read as "can't type in Rynth". Set in game in Settings > Display.</summary>
|
||||
public static bool InsertReleasesUi
|
||||
{
|
||||
get
|
||||
{
|
||||
EnsureLoaded();
|
||||
return _insertReleasesUi;
|
||||
}
|
||||
set
|
||||
{
|
||||
EnsureLoaded(); // populate _pluginPaths before Save() rewrites the file
|
||||
if (_insertReleasesUi == value) return;
|
||||
_insertReleasesUi = value;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddPluginPath(string path)
|
||||
{
|
||||
EnsureLoaded();
|
||||
|
|
@ -432,6 +453,10 @@ internal static class EngineSettings
|
|||
(frEl.ValueKind == JsonValueKind.True || frEl.ValueKind == JsonValueKind.False))
|
||||
_flightRecorder = frEl.GetBoolean();
|
||||
|
||||
if (doc.RootElement.TryGetProperty("InsertReleasesUi", out var iruEl) &&
|
||||
(iruEl.ValueKind == JsonValueKind.True || iruEl.ValueKind == JsonValueKind.False))
|
||||
_insertReleasesUi = iruEl.GetBoolean();
|
||||
|
||||
if (doc.RootElement.TryGetProperty("PreventIdleLogoff", out var pilEl) &&
|
||||
(pilEl.ValueKind == JsonValueKind.True || pilEl.ValueKind == JsonValueKind.False))
|
||||
{
|
||||
|
|
@ -464,7 +489,7 @@ internal static class EngineSettings
|
|||
"EnableAvaloniaOverlay", "EnableD3D9Hook", "EnableEngine", "EngineHookCount",
|
||||
"EnableImGuiBackend", "EnableHangMinidump", "PreventIdleLogoff", "DecalBridge",
|
||||
"DecalInGameImGui", "DecalStandDown", "DisabledUiHooks", "ServerMessageStream",
|
||||
"FlightRecorder",
|
||||
"FlightRecorder", "InsertReleasesUi",
|
||||
};
|
||||
|
||||
private static void Save()
|
||||
|
|
@ -509,6 +534,8 @@ internal static class EngineSettings
|
|||
w.WriteBoolean("ServerMessageStream", false);
|
||||
if (!_flightRecorder) // default true: leave the file as it was
|
||||
w.WriteBoolean("FlightRecorder", false);
|
||||
if (_insertReleasesUi) // default false: leave the file as it was
|
||||
w.WriteBoolean("InsertReleasesUi", true);
|
||||
w.WriteEndObject();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,8 @@ internal sealed class ChatLine
|
|||
ChatType = chatType;
|
||||
Sender = sender;
|
||||
Text = text;
|
||||
ColorKind = ChatLineColors.KindOf(chatType, chan, text);
|
||||
ChatLineColors.NoteKind(ColorKind);
|
||||
// The text already names the speaker ("Bob says, ..."); until 2026-09-29
|
||||
// the sender was printed in front of it as well ("Bob: Bob says, ...").
|
||||
FormattedText = $"{ts} {text}";
|
||||
|
|
@ -89,6 +91,9 @@ internal sealed class ChatLine
|
|||
public string? Sender { get; }
|
||||
/// <summary>The line as AC printed it. Rules match this.</summary>
|
||||
public string Text { get; }
|
||||
/// <summary>Which line colour setting applies ("say", "chan:General", ...), or null:
|
||||
/// its tab's colour (ChatLineColors.KindOf, worked out once here).</summary>
|
||||
public string? ColorKind { get; }
|
||||
/// <summary>"HH:mm:ss text": copy, log and the Avalonia face.</summary>
|
||||
public string FormattedText { get; }
|
||||
|
||||
|
|
@ -648,19 +653,13 @@ internal static class ChatModel
|
|||
/// <summary>Channel tabs; must match ChatClassifier in the plugin.</summary>
|
||||
public static readonly string[] BaseTabs = { "All", "Chat", "Channels", "System", "Combat", "Rynth", "Other" };
|
||||
|
||||
/// <summary>Channel colour as 0xAARRGGBB.</summary>
|
||||
public static uint ChannelArgb(string chan) => chan switch
|
||||
{
|
||||
"Chat" => 0xFFE0E0E0,
|
||||
"Channels" => 0xFF7AB8F5,
|
||||
"System" => 0xFF8CA6BF,
|
||||
"Combat" => 0xFFD93333,
|
||||
"Rynth" => 0xFFE6B450, // amber, distinct from the blue/grey channels
|
||||
_ => 0xFFAAAAAA,
|
||||
};
|
||||
/// <summary>Channel tab colour as 0xAARRGGBB: the user's (Line colours in the chat
|
||||
/// settings), else the built-in one (ChatLineColors.BuiltInTabArgb).</summary>
|
||||
public static uint ChannelArgb(string chan) => ChatLineColors.TabArgb(chan);
|
||||
|
||||
/// <summary>The line's colour: a rule's line colour, else its channel's. 0xAARRGGBB.</summary>
|
||||
public static uint LineArgb(ChatLine line) => line.Route.LineArgb ?? ChannelArgb(line.Channel);
|
||||
/// <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);
|
||||
|
||||
/// <summary>
|
||||
/// What a rule's "When" can be: (stored value, label). Channel tabs, then
|
||||
|
|
@ -1173,20 +1172,10 @@ internal static class ChatModel
|
|||
/// An alpha of 00 is taken as opaque: a colour that makes the text invisible
|
||||
/// is never what a rule wants (hiding is the Hide action).
|
||||
/// </summary>
|
||||
public static uint? ParseColor(string? s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return null;
|
||||
s = s.Trim().TrimStart('#');
|
||||
if (s.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) s = s[2..];
|
||||
if (s.Length is not (6 or 8)) return null;
|
||||
if (!uint.TryParse(s, System.Globalization.NumberStyles.AllowHexSpecifier, null, out uint v)) return null;
|
||||
if (s.Length == 6 || (v >> 24) == 0) v |= 0xFF000000;
|
||||
return v;
|
||||
}
|
||||
public static uint? ParseColor(string? s) => ChatLineColors.ParseColor(s);
|
||||
|
||||
/// <summary>0xAARRGGBB as "#RRGGBB", or "#AARRGGBB" when it isn't opaque (an imported colour keeps its alpha).</summary>
|
||||
public static string FormatColor(uint argb) =>
|
||||
(argb >> 24) == 0xFF ? $"#{argb & 0xFFFFFF:X6}" : $"#{argb:X8}";
|
||||
public static string FormatColor(uint argb) => ChatLineColors.FormatColor(argb);
|
||||
|
||||
// ── Plugin binding (set by ChatSource on the pump) ───────────────────
|
||||
|
||||
|
|
@ -1589,6 +1578,8 @@ internal static class ChatModel
|
|||
// "when", "colorMode" and "color". A version-1 file loads as before (see
|
||||
// FromDto for what its rules become); the first load copies it to
|
||||
// rynthchat_settings.v1.bak, and the next save writes version 2.
|
||||
// "lineColors" (2026-10-08, ChatLineColors) is written only once a colour
|
||||
// is set, so it needs no version bump: a file without it loads as before.
|
||||
|
||||
public const int SettingsVersion = 2;
|
||||
private static readonly object SaveLock = new();
|
||||
|
|
@ -1635,6 +1626,7 @@ internal static class ChatModel
|
|||
MentionHighlight = dto.MentionHighlight;
|
||||
MentionSound = dto.MentionSound;
|
||||
MentionWords = dto.MentionWords ?? "";
|
||||
ChatLineColors.Load(dto.LineColors); // absent before 2026-10-08: nothing set
|
||||
|
||||
var tabs = new List<string>();
|
||||
foreach (string t in dto.CustomTabs ?? Array.Empty<string>())
|
||||
|
|
@ -1700,6 +1692,7 @@ internal static class ChatModel
|
|||
MentionHighlight = MentionHighlight,
|
||||
MentionSound = MentionSound,
|
||||
MentionWords = MentionWords,
|
||||
LineColors = ChatLineColors.ToJson(), // null (left out) until a colour is set
|
||||
CustomTabs = Volatile.Read(ref _customTabs),
|
||||
Filters = Filters.Select(ToDto).ToArray(),
|
||||
};
|
||||
|
|
|
|||
299
src/RynthCore.Engine/UI/Data/ChatLineColors.cs
Normal file
299
src/RynthCore.Engine/UI/Data/ChatLineColors.cs
Normal file
|
|
@ -0,0 +1,299 @@
|
|||
// ============================================================================
|
||||
// RynthCore.Engine - UI/Data/ChatLineColors.cs
|
||||
// RynthChat's per-kind line colours (2026-10-08): the user can pick a colour
|
||||
// for each kind of line - say, tells in and out, allegiance, fellowship,
|
||||
// emotes, each Turbine chat channel by its "[Tag]" (General is /cg, Trade
|
||||
// /ct, LFG /clfg, Roleplay /crp, Society /soc, Olthoi /o; the client's own
|
||||
// @help text) - and for each channel tab.
|
||||
//
|
||||
// A line's colour, first that applies:
|
||||
// 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.
|
||||
//
|
||||
// Kept apart from ChatData.cs (no engine state) so tools/ChatFilterTests can
|
||||
// compile it in. The colours are an immutable snapshot, replaced on every
|
||||
// edit: the faces read it every frame from AC's thread, the settings popup
|
||||
// writes it on the same thread, and the loader writes it once at startup.
|
||||
// Saved as "lineColors" in rynthchat_settings.json ({ key: "#RRGGBB" }),
|
||||
// only the colours that were set; absent in every file before 2026-10-08.
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace RynthCore.Engine.UI.Data;
|
||||
|
||||
/// <summary>One colour setting: its key (in the settings file), label, a tooltip, and the tab its lines sit in.</summary>
|
||||
internal readonly record struct ChatColorKind(string Key, string Label, string Hint, string Tab);
|
||||
|
||||
internal static class ChatLineColors
|
||||
{
|
||||
public const string Say = "say", Tell = "tell", TellOut = "tellOut",
|
||||
Allegiance = "allegiance", Fellowship = "fellowship", Emote = "emote";
|
||||
public const string ChanPrefix = "chan:", TabPrefix = "tab:";
|
||||
/// <summary>Longest "[Tag]" taken as a channel; the same bound as ChatClassifier's sender regex.</summary>
|
||||
public const int MaxTagLength = 40;
|
||||
|
||||
/// <summary>Channel tabs that have a colour (All has none); must match ChatModel.BaseTabs.</summary>
|
||||
public static readonly string[] Tabs = { "Chat", "Channels", "System", "Combat", "Rynth", "Other" };
|
||||
|
||||
/// <summary>The player-to-player kinds (ChatMessageType).</summary>
|
||||
public static readonly ChatColorKind[] ChatKinds =
|
||||
{
|
||||
new(Say, "Say", "Local speech (0x02)", "Chat"),
|
||||
new(Tell, "Tells to you", "Tells you receive (0x03)", "Chat"),
|
||||
new(TellOut, "Tells you send", "\"You tell ...\" (0x04)", "Chat"),
|
||||
new(Allegiance, "Allegiance", "/a, and [Allegiance] channel lines (0x12)", "Chat"),
|
||||
new(Fellowship, "Fellowship", "/f (0x13)", "Chat"),
|
||||
new(Emote, "Emotes", "/e and soul emotes (0x0A-0x0C)", "Chat"),
|
||||
};
|
||||
|
||||
/// <summary>The Turbine chat channels, by the tag AC prints in front of their lines.</summary>
|
||||
public static readonly ChatColorKind[] ChannelKinds =
|
||||
{
|
||||
new(ChanPrefix + "General", "General", "[General]: /general, /cg", "Channels"),
|
||||
new(ChanPrefix + "Trade", "Trade", "[Trade]: /trade, /ct", "Channels"),
|
||||
new(ChanPrefix + "LFG", "LFG", "[LFG]: /lfg, /clfg", "Channels"),
|
||||
new(ChanPrefix + "Roleplay", "Roleplay", "[Roleplay]: /roleplay, /crp", "Channels"),
|
||||
new(ChanPrefix + "Society", "Society", "[Society]: /society, /soc", "Channels"),
|
||||
new(ChanPrefix + "Olthoi", "Olthoi", "[Olthoi]: /olthoi, /o", "Channels"),
|
||||
};
|
||||
|
||||
/// <summary>The tab colours, for lines with no kind of their own (system, combat...).</summary>
|
||||
public static readonly ChatColorKind[] TabKinds = Array.ConvertAll(Tabs,
|
||||
t => new ChatColorKind(TabPrefix + t, t, $"Lines in the {t} tab with no colour of their own", t));
|
||||
|
||||
/// <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));
|
||||
|
||||
/// <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
|
||||
{
|
||||
"Chat" => 0xFFE0E0E0,
|
||||
"Channels" => 0xFF7AB8F5,
|
||||
"System" => 0xFF8CA6BF,
|
||||
"Combat" => 0xFFD93333,
|
||||
"Rynth" => 0xFFE6B450, // amber, distinct from the blue/grey channels
|
||||
_ => 0xFFAAAAAA,
|
||||
};
|
||||
|
||||
// ── Which kind a line is ─────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// The channel tag a line starts with: "[General] Bob says, ..." gives
|
||||
/// "General". Null when there is none, it's empty, too long, not followed
|
||||
/// by a space, or is a Rynth plugin's own "[Rynth…]" prefix.
|
||||
/// </summary>
|
||||
public static string? TagOf(string? text)
|
||||
{
|
||||
if (text == null || text.Length < 4 || text[0] != '[') return null;
|
||||
int end = text.IndexOf(']', 1);
|
||||
if (end <= 1 || end - 1 > MaxTagLength || end + 1 >= text.Length || text[end + 1] != ' ') return null;
|
||||
string tag = text.Substring(1, end - 1).Trim();
|
||||
if (tag.Length == 0 || tag.IndexOf('[') >= 0) return null;
|
||||
if (tag.StartsWith("Rynth", StringComparison.OrdinalIgnoreCase)) return null;
|
||||
return tag;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The colour key of a line (one of the ChatKinds keys or "chan:Tag"), or
|
||||
/// null when it has no kind of its own and takes its tab's colour.
|
||||
/// <paramref name="chatType"/> is AC's ChatMessageType, -1 from RynthChat before 0.2.0.
|
||||
/// </summary>
|
||||
public static string? KindOf(int chatType, string channel, string text)
|
||||
{
|
||||
switch (chatType)
|
||||
{
|
||||
case 0x02: return Say;
|
||||
case 0x03: return Tell;
|
||||
case 0x04: return TellOut;
|
||||
case 0x0A or 0x0B or 0x0C: return Emote;
|
||||
case 0x13: return Fellowship;
|
||||
case 0x12: return TagKind(TagOf(text)) ?? Allegiance;
|
||||
case 0x08 or 0x09: return TagKind(TagOf(text));
|
||||
case -1 when string.Equals(channel, "Channels", StringComparison.OrdinalIgnoreCase)
|
||||
|| string.Equals(channel, "Chat", StringComparison.OrdinalIgnoreCase):
|
||||
return TagKind(TagOf(text));
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>"Allegiance" is the allegiance kind (the /a lines, tagged or not); the
|
||||
/// three societies' rooms share Society; any other tag is its own channel.</summary>
|
||||
private static string? TagKind(string? tag)
|
||||
{
|
||||
if (tag == null) return null;
|
||||
if (tag.Equals("Allegiance", StringComparison.OrdinalIgnoreCase)) return Allegiance;
|
||||
if (tag.Equals("Celestial Hand", StringComparison.OrdinalIgnoreCase)
|
||||
|| tag.Equals("Eldrytch Web", StringComparison.OrdinalIgnoreCase)
|
||||
|| tag.Equals("Radiant Blood", StringComparison.OrdinalIgnoreCase)) return ChanPrefix + "Society";
|
||||
foreach (ChatColorKind k in ChannelKinds) // the listed spelling, whatever case AC used
|
||||
if (string.Equals(k.Key, ChanPrefix + tag, StringComparison.OrdinalIgnoreCase)) return k.Key;
|
||||
return ChanPrefix + tag;
|
||||
}
|
||||
|
||||
/// <summary>True for "chan:Tag" keys that aren't one of the listed channels.</summary>
|
||||
public static bool IsOtherChannel(string? kind)
|
||||
{
|
||||
if (kind == null || !kind.StartsWith(ChanPrefix, StringComparison.Ordinal)) return false;
|
||||
foreach (ChatColorKind k in ChannelKinds)
|
||||
if (string.Equals(k.Key, kind, StringComparison.OrdinalIgnoreCase)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ── Other channel tags seen this session (offered in the settings) ───
|
||||
|
||||
private const int MaxSeenTags = 24;
|
||||
private static readonly object SeenLock = new();
|
||||
private static string[] _seenTags = Array.Empty<string>();
|
||||
|
||||
/// <summary>Tags other than the listed channels seen on channel lines this session, oldest first.</summary>
|
||||
public static string[] SeenTags => Volatile.Read(ref _seenTags);
|
||||
|
||||
/// <summary>A real chat line's kind (ChatLine): an unlisted channel's tag is remembered for the settings.</summary>
|
||||
public static void NoteKind(string? kind)
|
||||
{
|
||||
if (IsOtherChannel(kind)) NoteTag(kind![ChanPrefix.Length..]);
|
||||
}
|
||||
|
||||
private static void NoteTag(string tag)
|
||||
{
|
||||
string[] seen = Volatile.Read(ref _seenTags);
|
||||
foreach (string s in seen)
|
||||
if (string.Equals(s, tag, StringComparison.OrdinalIgnoreCase)) return;
|
||||
lock (SeenLock)
|
||||
{
|
||||
seen = _seenTags;
|
||||
if (seen.Length >= MaxSeenTags) return;
|
||||
foreach (string s in seen)
|
||||
if (string.Equals(s, tag, StringComparison.OrdinalIgnoreCase)) return;
|
||||
var next = new string[seen.Length + 1];
|
||||
seen.CopyTo(next, 0);
|
||||
next[^1] = tag;
|
||||
Volatile.Write(ref _seenTags, next);
|
||||
}
|
||||
}
|
||||
|
||||
// ── The colours the user set ─────────────────────────────────────────
|
||||
|
||||
private static readonly object EditLock = new();
|
||||
private static Dictionary<string, uint> _set = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>The colour set for <paramref name="key"/> (a kind, "chan:Tag" or "tab:Name"), or null.</summary>
|
||||
public static uint? Get(string? key)
|
||||
{
|
||||
if (key == null) return null;
|
||||
return Volatile.Read(ref _set).TryGetValue(key, out uint v) ? v : null;
|
||||
}
|
||||
|
||||
public static bool AnySet => Volatile.Read(ref _set).Count > 0;
|
||||
|
||||
/// <summary>The keys that have a colour, e.g. so other channels' colours are listed after a relaunch.</summary>
|
||||
public static IReadOnlyCollection<string> SetKeys => Volatile.Read(ref _set).Keys;
|
||||
|
||||
public static void Set(string key, uint argb) => Edit(d => d[key] = argb | 0xFF000000);
|
||||
|
||||
public static void Reset(string key) => Edit(d => d.Remove(key));
|
||||
|
||||
public static void ResetAll() => Edit(d => d.Clear());
|
||||
|
||||
private static void Edit(Action<Dictionary<string, uint>> change)
|
||||
{
|
||||
lock (EditLock)
|
||||
{
|
||||
var next = new Dictionary<string, uint>(_set, StringComparer.OrdinalIgnoreCase);
|
||||
change(next);
|
||||
Volatile.Write(ref _set, next);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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>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 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)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(key)) return false;
|
||||
foreach (ChatColorKind k in ChatKinds)
|
||||
if (string.Equals(k.Key, key, StringComparison.OrdinalIgnoreCase)) return true;
|
||||
if (key.StartsWith(TabPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
return Array.Exists(Tabs, t => string.Equals(TabPrefix + t, key, StringComparison.OrdinalIgnoreCase));
|
||||
if (key.StartsWith(ChanPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string tag = key[ChanPrefix.Length..];
|
||||
return tag.Length > 0 && tag.Length <= MaxTagLength && tag.Trim() == tag
|
||||
&& tag.IndexOf('[') < 0 && tag.IndexOf(']') < 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ── Settings file ────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>The colours set, for "lineColors"; null when none (the key is then left out of the file).</summary>
|
||||
public static Dictionary<string, string>? ToJson()
|
||||
{
|
||||
Dictionary<string, uint> set = Volatile.Read(ref _set);
|
||||
if (set.Count == 0) return null;
|
||||
var json = new Dictionary<string, string>(StringComparer.Ordinal);
|
||||
foreach (var kv in set) json[kv.Key] = FormatColor(kv.Value);
|
||||
return json;
|
||||
}
|
||||
|
||||
/// <summary>Replaces the colours with the file's; null (an older file) clears them. Bad entries are skipped.</summary>
|
||||
public static void Load(Dictionary<string, string>? json)
|
||||
{
|
||||
var next = new Dictionary<string, uint>(StringComparer.OrdinalIgnoreCase);
|
||||
if (json != null)
|
||||
foreach (var kv in json)
|
||||
{
|
||||
if (!IsValidKey(kv.Key)) continue;
|
||||
uint? argb = ParseColor(kv.Value);
|
||||
if (argb != null) next[CanonicalKey(kv.Key)] = argb.Value | 0xFF000000;
|
||||
}
|
||||
lock (EditLock) Volatile.Write(ref _set, next);
|
||||
}
|
||||
|
||||
/// <summary>A listed kind or tab in its listed spelling ("Say" -> "say", "tab:chat" -> "tab:Chat").</summary>
|
||||
private static string CanonicalKey(string key)
|
||||
{
|
||||
foreach (ChatColorKind k in ChatKinds)
|
||||
if (string.Equals(k.Key, key, StringComparison.OrdinalIgnoreCase)) return k.Key;
|
||||
foreach (ChatColorKind k in ChannelKinds)
|
||||
if (string.Equals(k.Key, key, StringComparison.OrdinalIgnoreCase)) return k.Key;
|
||||
foreach (string t in Tabs)
|
||||
if (string.Equals(TabPrefix + t, key, StringComparison.OrdinalIgnoreCase)) return TabPrefix + t;
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// "#RRGGBB" or "#AARRGGBB" to 0xAARRGGBB (opaque when no alpha is given).
|
||||
/// An alpha of 00 is taken as opaque: a colour that makes the text invisible
|
||||
/// is never what a rule wants (hiding is the Hide action).
|
||||
/// </summary>
|
||||
public static uint? ParseColor(string? s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return null;
|
||||
s = s.Trim().TrimStart('#');
|
||||
if (s.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) s = s[2..];
|
||||
if (s.Length is not (6 or 8)) return null;
|
||||
if (!uint.TryParse(s, System.Globalization.NumberStyles.AllowHexSpecifier, null, out uint v)) return null;
|
||||
if (s.Length == 6 || (v >> 24) == 0) v |= 0xFF000000;
|
||||
return v;
|
||||
}
|
||||
|
||||
/// <summary>0xAARRGGBB as "#RRGGBB", or "#AARRGGBB" when it isn't opaque (an imported colour keeps its alpha).</summary>
|
||||
public static string FormatColor(uint argb) =>
|
||||
(argb >> 24) == 0xFF ? $"#{argb & 0xFFFFFF:X6}" : $"#{argb:X8}";
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
// rules with the real serializer.
|
||||
// ============================================================================
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RynthCore.Engine.UI.Data;
|
||||
|
|
@ -58,6 +59,9 @@ internal sealed class RynthChatSettingsDto
|
|||
[JsonPropertyName("mentionHighlight")] public bool MentionHighlight { get; set; } = true;
|
||||
[JsonPropertyName("mentionSound")] public bool MentionSound { get; set; }
|
||||
[JsonPropertyName("mentionWords")] public string? MentionWords { get; set; }
|
||||
// 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; }
|
||||
[JsonPropertyName("customTabs")] public string[]? CustomTabs { get; set; }
|
||||
[JsonPropertyName("filters")] public RynthChatFilterDto[]? Filters { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,6 +171,9 @@ internal sealed class RynthAiSettings
|
|||
// Cast our own buff even when gear already gives it (servers with buff augments). Default
|
||||
// on; a RynthAi that predates it doesn't send it, and must not read as off.
|
||||
public bool CastBuffsOverItemBuffs { get; set; } = true;
|
||||
// RynthAi's unticked prots and banes (buff base names). Null = never received from RynthAi:
|
||||
// sent back as null, which RynthAi reads as "unchanged".
|
||||
public System.Collections.Generic.List<string>? DisabledBuffs { get; set; }
|
||||
public int BuffMinSkillLevelTier1 { get; set; } = 35;
|
||||
public int BuffMinSkillLevelTier2 { get; set; } = 85;
|
||||
public int BuffMinSkillLevelTier3 { get; set; } = 135;
|
||||
|
|
@ -392,6 +395,48 @@ internal static class SettingsSchema
|
|||
return rows;
|
||||
}
|
||||
|
||||
// The prots and banes RynthAi lets you untick (its BuffManager.ToggleProtections/ToggleBanes):
|
||||
// (buff base name, label). The names must match RynthAi's.
|
||||
private static readonly (string Buff, string Label)[] ProtToggles =
|
||||
{
|
||||
("Armor Self", "Armor"), ("Fire Protection Self", "Fire Protection"), ("Cold Protection Self", "Cold Protection"),
|
||||
("Acid Protection Self", "Acid Protection"), ("Lightning Protection Self", "Lightning Protection"),
|
||||
("Blade Protection Self", "Blade Protection"), ("Piercing Protection Self", "Piercing Protection"),
|
||||
("Bludgeoning Protection Self", "Bludgeoning Protection"),
|
||||
};
|
||||
|
||||
private static readonly (string Buff, string Label)[] BaneToggles =
|
||||
{
|
||||
("Impenetrability", "Impenetrability"), ("Flame Bane", "Flame Bane"), ("Frost Bane", "Frost Bane"),
|
||||
("Acid Bane", "Acid Bane"), ("Lightning Bane", "Lightning Bane"),
|
||||
("Blade Bane", "Blade Bane"), ("Piercing Bane", "Piercing Bane"),
|
||||
("Bludgeoning Bane", "Bludgeoning Bane"),
|
||||
};
|
||||
|
||||
private static SettingRow[] BuffToggles((string Buff, string Label)[] toggles)
|
||||
{
|
||||
var rows = new SettingRow[toggles.Length];
|
||||
for (int i = 0; i < toggles.Length; i++)
|
||||
{
|
||||
string buff = toggles[i].Buff;
|
||||
rows[i] = Bool(toggles[i].Label, s => BuffOn(s, buff), (s, v) => SetBuffOn(s, buff, v),
|
||||
"Ticked: RynthAi casts it in the buff cycle. Unticked: it is skipped and never waited on.");
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private static bool BuffOn(RynthAiSettings s, string buff)
|
||||
=> s.DisabledBuffs == null || !s.DisabledBuffs.Exists(b => string.Equals(b, buff, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
/// <summary>A new list each time (RynthAi replaces its list rather than editing it).</summary>
|
||||
private static void SetBuffOn(RynthAiSettings s, string buff, bool on)
|
||||
{
|
||||
var list = s.DisabledBuffs == null ? new System.Collections.Generic.List<string>() : new System.Collections.Generic.List<string>(s.DisabledBuffs);
|
||||
list.RemoveAll(b => string.Equals(b, buff, StringComparison.OrdinalIgnoreCase));
|
||||
if (!on) list.Add(buff);
|
||||
s.DisabledBuffs = list;
|
||||
}
|
||||
|
||||
private static SettingRow[] Concat(params object[] parts)
|
||||
{
|
||||
var list = new System.Collections.Generic.List<SettingRow>();
|
||||
|
|
@ -409,6 +454,10 @@ internal static class SettingsSchema
|
|||
{
|
||||
Bool("Show Target Stamina / Mana", s => s.ShowTargetStaminaMana, (s, v) => s.ShowTargetStaminaMana = v,
|
||||
"When enabled, displays stamina and mana bars for the selected target (requires appraisal data)."),
|
||||
// Stored in engine.json for every client (EngineSettings), not in the RynthAi profile.
|
||||
Bool("Insert Key Releases the UI", _ => Plugins.EngineSettings.InsertReleasesUi,
|
||||
(_, v) => { Plugins.EngineSettings.InsertReleasesUi = v; if (!v) ImGuiBackend.Win32Backend.ReclaimUi(); },
|
||||
"On: Insert switches between UI and GAME (shown on the RynthCore bar). In GAME, clicks pass through\nRynth windows to the game and Rynth text boxes can't be typed in. Press Insert again to get the UI back.\nOff (default): Insert does nothing. Applies to all your clients; others pick it up when they start."),
|
||||
Spacer(),
|
||||
Section("Text Size (in-game panels)"),
|
||||
Combo("All Panels", PanelTextScale.SizeNames, _ => PanelTextScale.GetAll(), (_, v) => PanelTextScale.SetAll(v),
|
||||
|
|
@ -699,6 +748,12 @@ internal static class SettingsSchema
|
|||
Bool("Cast buffs even when an item gives them", s => s.CastBuffsOverItemBuffs, (s, v) => s.CastBuffsOverItemBuffs = v,
|
||||
"Cast your own buff even when worn gear already gives that buff.\nFor servers with buff augments, where your own cast is stronger or lasts longer.\nOn by default: on retail it costs a few extra casts."),
|
||||
Spacer(),
|
||||
Section("Protections (untick to skip)"),
|
||||
BuffToggles(ProtToggles),
|
||||
Spacer(),
|
||||
Section("Banes (untick to skip)"),
|
||||
BuffToggles(BaneToggles),
|
||||
Spacer(),
|
||||
Section("Buff Difficulty (Min Buffed Skill)"),
|
||||
Tiers(
|
||||
new Func<RynthAiSettings, int>[] { s => s.BuffMinSkillLevelTier1, s => s.BuffMinSkillLevelTier2, s => s.BuffMinSkillLevelTier3, s => s.BuffMinSkillLevelTier4,
|
||||
|
|
|
|||
Loading…
Reference in a new issue