From f4073263774778cb2184df812deda44137c6b310 Mon Sep 17 00:00:00 2001 From: Tom Bohar Date: Sun, 27 Sep 2026 00:26:16 -0400 Subject: [PATCH] RynthCore as of 2026-09-27 (internal b778a81): version display, RynthChat Tell button, retail chat usable, release 2026.9.27.1 Co-Authored-By: Claude Opus 5.5 --- installer/Build-Installer.ps1 | 15 ++- installer/Publish-Update.ps1 | 2 +- src/RynthCore.App.Avalonia/MainWindow.axaml | 3 + .../MainWindow.axaml.cs | 22 +++- .../RynthCore.App.Avalonia.csproj | 1 + src/RynthCore.App/BuildVersion.cs | 46 ++++++++ .../Compatibility/ChatHooks.cs | 22 +++- src/RynthCore.Engine/EntryPoint.cs | 21 +++- src/RynthCore.Engine/ImGui/Win32Backend.cs | 24 +++- src/RynthCore.Engine/Plugins/PluginLoader.cs | 6 + src/RynthCore.Engine/RynthCore.Engine.csproj | 1 + src/RynthCore.Engine/UI/AvaloniaOverlay.cs | 4 +- .../UI/Panels/RynthAiPanel.cs | 19 +++ .../UI/Panels/RynthChatPanel.cs | 109 +++++++++++++++++- src/RynthCore.Engine/UI/Panels/StatusPanel.cs | 4 +- 15 files changed, 277 insertions(+), 22 deletions(-) create mode 100644 src/RynthCore.App/BuildVersion.cs diff --git a/installer/Build-Installer.ps1 b/installer/Build-Installer.ps1 index 70d4276..12fe70a 100644 --- a/installer/Build-Installer.ps1 +++ b/installer/Build-Installer.ps1 @@ -51,6 +51,11 @@ if ($Version) { $release = [int]$p[0] * 1000000 + [int]$p[1] * 10000 + [int]$p[2] * 100 + [int]$p[3] } +# Stamp every build with the release, so the launcher, the engine log and the in-game +# Status panel show it (RynthCore.App.BuildVersion); the SDK appends the git commit. +$VersionArgs = @() +if ($Version) { $VersionArgs = @("-p:Version=$Version") } + $ScriptDir = $PSScriptRoot $RepoRoot = Split-Path $ScriptDir -Parent # e.g. C:\Projects\RynthCore $ProjectsRoot = Split-Path $RepoRoot -Parent # e.g. C:\Projects @@ -85,31 +90,31 @@ if (-not $SkipBuild) { # ── 1. Launcher (self-contained Avalonia WinExe) ───────────────────────── Write-Host "" Write-Host "[1/5] Publishing Launcher (self-contained, x86)..." -ForegroundColor Cyan - dotnet publish $LauncherProject -c $Configuration -r win-x86 --self-contained true + dotnet publish $LauncherProject -c $Configuration -r win-x86 --self-contained true @VersionArgs if ($LASTEXITCODE -ne 0) { throw "Launcher publish failed (exit $LASTEXITCODE)" } # ── 2. Engine (NativeAOT — the slow one) ────────────────────────────────── Write-Host "" Write-Host "[2/5] Publishing Engine (NativeAOT, ~2 min)..." -ForegroundColor Cyan - dotnet publish $EngineProject -c $Configuration + dotnet publish $EngineProject -c $Configuration @VersionArgs if ($LASTEXITCODE -ne 0) { throw "Engine publish failed (exit $LASTEXITCODE)" } # ── 3. Loader (NativeAOT, small) ────────────────────────────────────────── Write-Host "" Write-Host "[3/5] Publishing Loader (NativeAOT)..." -ForegroundColor Cyan - dotnet publish $LoaderProject -c $Configuration + dotnet publish $LoaderProject -c $Configuration @VersionArgs if ($LASTEXITCODE -ne 0) { throw "Loader publish failed (exit $LASTEXITCODE)" } # ── 4. Plugin (NativeAOT) ───────────────────────────────────────────────── Write-Host "" Write-Host "[4/5] Publishing Plugin (NativeAOT)..." -ForegroundColor Cyan - dotnet publish $PluginProject -c $Configuration + dotnet publish $PluginProject -c $Configuration @VersionArgs if ($LASTEXITCODE -ne 0) { throw "Plugin publish failed (exit $LASTEXITCODE)" } # ── 5. Loot Editor (self-contained Avalonia tool) ───────────────────────── Write-Host "" Write-Host "[5/5] Publishing Loot Editor (self-contained, x86)..." -ForegroundColor Cyan - dotnet publish $LootEditorProject -c $Configuration -r win-x86 --self-contained true + dotnet publish $LootEditorProject -c $Configuration -r win-x86 --self-contained true @VersionArgs if ($LASTEXITCODE -ne 0) { throw "Loot Editor publish failed (exit $LASTEXITCODE)" } } diff --git a/installer/Publish-Update.ps1 b/installer/Publish-Update.ps1 index c9ce6ce..c284781 100644 --- a/installer/Publish-Update.ps1 +++ b/installer/Publish-Update.ps1 @@ -117,7 +117,7 @@ foreach ($name in $suitePlugins) { Step "Building $name" $proj = Join-Path $RynthSuiteRoot "Plugins\RynthCore.Plugin.$name\RynthCore.Plugin.$name.csproj" # PublishDir overrides the projects' own (RynthNav/RynthVision publish into the live C:\Games folders). - dotnet publish $proj -c Release "-p:PublishDir=$rel\build\$name\" -v q -nologo + dotnet publish $proj -c Release "-p:Version=$Version" "-p:PublishDir=$rel\build\$name\" -v q -nologo if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed for $name" } Copy-Item "$rel\build\$name\RynthCore.Plugin.$name.dll" "$rel\plugins\" } diff --git a/src/RynthCore.App.Avalonia/MainWindow.axaml b/src/RynthCore.App.Avalonia/MainWindow.axaml index 38cbd8d..1b67e79 100644 --- a/src/RynthCore.App.Avalonia/MainWindow.axaml +++ b/src/RynthCore.App.Avalonia/MainWindow.axaml @@ -71,6 +71,9 @@ FontSize="24" FontWeight="Bold" Foreground="#26C1A6" /> + await RefreshServerStatusesAsync(); _serverStatusTimer.Start(); Closing += (_, _) => SaveWindowLayout(); + ShowVersion(); AppendActivity("Avalonia launcher preview ready."); _ = RefreshServerStatusesAsync(); _updateTimer.Tick += async (_, _) => await CheckForUpdatesAsync(); @@ -333,10 +335,11 @@ internal partial class MainWindow : Window { string capturedPath = dllPath; string pluginName = Path.GetFileNameWithoutExtension(dllPath); + string pluginVersion = BuildVersion.OfFile(dllPath); var checkBox = new CheckBox { - Content = pluginName, + Content = pluginVersion.Length > 0 ? $"{pluginName} {pluginVersion}" : pluginName, IsChecked = !disabledSet.Contains(capturedPath) }; checkBox.IsCheckedChanged += (_, _) => OnUserPluginEnabledChanged(capturedPath, checkBox); @@ -1705,6 +1708,19 @@ internal partial class MainWindow : Window } } + // ── Version ─────────────────────────────────────────────────────────────── + + /// Launcher version under the title; the engine's (Runtime\) in its tooltip and the log. + private void ShowVersion() + { + string launcher = BuildVersion.Format(typeof(MainWindow).Assembly + .GetCustomAttribute()?.InformationalVersion); + string engine = BuildVersion.OfFile(Path.Combine(AppContext.BaseDirectory, "Runtime", "RynthCore.Engine.dll")); + HeaderVersionText.Text = launcher; + ToolTip.SetTip(HeaderVersionText, $"Launcher {launcher}\nEngine {(engine.Length > 0 ? engine : "not found")}"); + AppendActivity($"RynthCore launcher {launcher}, engine {(engine.Length > 0 ? engine : "not found")}."); + } + // ── Updates (RynthUpdater) ──────────────────────────────────────────────── // Plugins swap in place and never touch a running bot; the core installer runs only // with every RynthCore client closed. Nothing here ever triggers a reload (RL). @@ -1773,8 +1789,10 @@ internal partial class MainWindow : Window _pluginsUpdatedThisSession.Add(done); AppendActivity($"Plugin updated: {done}. Running clients keep their version; it loads the next time AC starts."); } - // Re-check so the panel reflects the files now on disk. + // Re-check so the panel reflects the files now on disk, and redraw the plugin + // rows so they show the new versions. _updateCheck = await _updater.CheckAsync(_pluginDllPaths.ToList()); + BuildPluginLoadout(); } private void ShowUpdateState() diff --git a/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj b/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj index 614db58..d4d6877 100644 --- a/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj +++ b/src/RynthCore.App.Avalonia/RynthCore.App.Avalonia.csproj @@ -38,6 +38,7 @@ + diff --git a/src/RynthCore.App/BuildVersion.cs b/src/RynthCore.App/BuildVersion.cs new file mode 100644 index 0000000..e7f87c6 --- /dev/null +++ b/src/RynthCore.App/BuildVersion.cs @@ -0,0 +1,46 @@ +using System.Diagnostics; +using System.IO; + +namespace RynthCore.App; + +/// +/// Human-readable build versions, for the launcher and the in-game UI. +/// +/// Release builds are stamped with the release number (Build-Installer.ps1 and +/// Publish-Update.ps1 pass -p:Version=yyyy.m.d.n), and the .NET SDK appends the git +/// commit to the product version: "2026.9.26.3+8ca322f…". Anything built without a +/// version (Deploy-RynthCore.ps1, an IDE build) reads "1.0.0+8ca322f…" — a dev build. +/// NativeAOT DLLs carry the same Windows version resource, so plugins need no code. +/// +internal static class BuildVersion +{ + /// "2026.9.26.3 (8ca322f)" for a release, "dev (8ca322f)" otherwise. + public static string Format(string? productVersion) + { + if (string.IsNullOrWhiteSpace(productVersion)) return "unknown"; + string version = productVersion.Trim(); + string commit = ""; + int plus = version.IndexOf('+'); + if (plus >= 0) + { + commit = version[(plus + 1)..]; + version = version[..plus]; + } + if (commit.Length > 7) commit = commit[..7]; + if (version is "1.0.0" or "1.0.0.0") version = "dev"; + return commit.Length > 0 ? $"{version} ({commit})" : version; + } + + /// A DLL's or EXE's version resource, formatted; "" if it has none or can't be read. + public static string OfFile(string path) + { + try + { + return File.Exists(path) ? Format(FileVersionInfo.GetVersionInfo(path).ProductVersion) : ""; + } + catch + { + return ""; + } + } +} diff --git a/src/RynthCore.Engine/Compatibility/ChatHooks.cs b/src/RynthCore.Engine/Compatibility/ChatHooks.cs index 241ecfb..ef552f3 100644 --- a/src/RynthCore.Engine/Compatibility/ChatHooks.cs +++ b/src/RynthCore.Engine/Compatibility/ChatHooks.cs @@ -59,7 +59,17 @@ internal static class ChatHooks public static bool IsInstalled => _hookInstalled; public static string StatusMessage => _statusMessage; - public static bool SuppressOriginalChat; + public static bool SuppressOriginalChat; // the user's "Hide retail chat" option + + /// RynthChat's panel is on screen (set by RynthChatPanel). + public static volatile bool ChatPanelShown; + + /// + /// RynthChat is standing in for the retail chat: its panel is open AND "Hide retail chat" + /// is on. Only then is the retail chatbox hidden and Enter routed to RynthChat — whichever + /// chat is visible gets Enter. + /// + public static bool RynthChatOwnsChat => SuppressOriginalChat && ChatPanelShown; public static IntPtr GmMainChatInstance => _gmMainChatInstance; @@ -119,7 +129,11 @@ internal static class ChatHooks catch (Exception ex) { try { RynthLog.Compat($"ChatHooks: Listen original threw {ex.GetType().Name}: {ex.Message}"); } catch { } throw; } } - private static bool _isHiddenAsserted; + // Starts true so the first tick asserts the setting either way: after an engine reload + // the previous generation may have left the chatbox hidden, and a fresh "false" here + // would never show it again even with "Hide retail chat" off. SetVisible(true) on a + // visible chatbox is a no-op. + private static bool _isHiddenAsserted = true; public static unsafe void TickHide() { @@ -130,7 +144,7 @@ internal static class ChatHooks if (inst == IntPtr.Zero) return; if (_uiElementSetVisibleAddress == IntPtr.Zero) return; - if (SuppressOriginalChat) + if (RynthChatOwnsChat) { try { @@ -155,6 +169,6 @@ internal static class ChatHooks public static void ResetCachedInstance() { _gmMainChatInstance = IntPtr.Zero; - _isHiddenAsserted = false; + _isHiddenAsserted = true; // re-assert on the next instance, as at start-up } } diff --git a/src/RynthCore.Engine/EntryPoint.cs b/src/RynthCore.Engine/EntryPoint.cs index 1e2d0ab..7485d87 100644 --- a/src/RynthCore.Engine/EntryPoint.cs +++ b/src/RynthCore.Engine/EntryPoint.cs @@ -22,7 +22,12 @@ namespace RynthCore.Engine; public static class EntryPoint { - internal const string BuildStamp = "2026-06-06-resize-nonmodal"; + /// + /// This engine's version — "2026.9.26.3 (8ca322f)", or "dev (8ca322f)" for an unstamped + /// build — read from the DLL's own version resource at init (RynthCore.App.BuildVersion). + /// Goes into every log header and crash line, and the in-game Status panel. + /// + internal static string BuildStamp { get; private set; } = "unknown"; private const int MaxRecentLogLines = 256; private static int _initialized; /// Init counter the loader passes in lpParam. 1 = cold start, @@ -84,6 +89,12 @@ public static class EntryPoint try { _initCount = lpParam.ToInt32(); + try + { + string version = RynthCore.App.BuildVersion.OfFile(GetEngineModulePath() ?? ""); + if (version.Length > 0) BuildStamp = version; + } + catch { } // Set up the unified log sink BEFORE anything else so all // subsequent failures are captured in C:\Games\RynthCore\Logs. @@ -176,7 +187,11 @@ public static class EntryPoint private const uint GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 0x00000004; private const uint GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 0x00000002; - private static unsafe string? GetEngineDirectory() + private static string? GetEngineDirectory() => + GetEngineModulePath() is { } path ? Path.GetDirectoryName(path) : null; + + /// Full path of the engine DLL actually loaded (the loader's staged copy on hot reload). + private static unsafe string? GetEngineModulePath() { // Resolve our module by passing the address of a static method // compiled into our DLL. `&StaticMethod` yields a direct pointer to @@ -216,7 +231,7 @@ public static class EntryPoint if (length == 0) return null; - return Path.GetDirectoryName(new string(buffer, 0, (int)length)); + return new string(buffer, 0, (int)length); } /// diff --git a/src/RynthCore.Engine/ImGui/Win32Backend.cs b/src/RynthCore.Engine/ImGui/Win32Backend.cs index d6871c1..ddfbd66 100644 --- a/src/RynthCore.Engine/ImGui/Win32Backend.cs +++ b/src/RynthCore.Engine/ImGui/Win32Backend.cs @@ -237,6 +237,19 @@ internal static unsafe class Win32Backend /// Custom WM_USER message for deferred chat command dispatch. internal const uint WM_RYNTHCORE_CHAT = 0x0400 + 0x5243; // WM_USER + "RC" + // Chat's Tell button (Avalonia UI thread) asks for "/tell , " to be started; + // posted so the selection and its name are read on AC's main thread. + internal const uint WM_RYNTHCORE_TELL = 0x0400 + 0x5244; + + /// Fired on the game thread when the Tell button asks to address the selected object. + public static Action? OnChatTellSelected; + + /// Callable from any thread: runs on AC's main thread. + public static void RequestTellSelected() + { + if (_gameHwnd != IntPtr.Zero) + PostMessage(_gameHwnd, WM_RYNTHCORE_TELL, IntPtr.Zero, IntPtr.Zero); + } /// The game's main window handle. public static IntPtr GameHwnd => _gameHwnd; @@ -820,6 +833,11 @@ internal static unsafe class Win32Backend OnChatSend?.Invoke(); return IntPtr.Zero; } + if (msg == WM_RYNTHCORE_TELL) + { + OnChatTellSelected?.Invoke(); + return IntPtr.Zero; + } // ── Chat: Enter in-game activates the chat TextBox ─────────── // Numpad Enter (extended key, lParam bit 24) is reserved for AC functions — never capture it. @@ -827,7 +845,11 @@ internal static unsafe class Win32Backend // panel TextBox this branch otherwise runs BEFORE the text-input // forwarding block and hijacks Enter into chat capture — stealing // the TextBox's own commit handler and every subsequent keystroke. - if (msg == WM_KEYDOWN && (int)wParam == VK_RETURN && !IsExtendedKey(lParam) && !ChatCaptureActive && !AvaloniaTextInputActive) + // RynthChatOwnsChat: only while RynthChat is open AND hiding the retail chatbox — + // whichever chat is visible gets Enter. Otherwise Enter belongs to AC's own chat, + // which used to be unusable whenever RynthChat was installed, even closed. + if (msg == WM_KEYDOWN && (int)wParam == VK_RETURN && !IsExtendedKey(lParam) && !ChatCaptureActive && !AvaloniaTextInputActive + && RynthCore.Engine.Compatibility.ChatHooks.RynthChatOwnsChat) { if (OnChatCaptureActivated != null) { diff --git a/src/RynthCore.Engine/Plugins/PluginLoader.cs b/src/RynthCore.Engine/Plugins/PluginLoader.cs index 8bd69af..14e4ec5 100644 --- a/src/RynthCore.Engine/Plugins/PluginLoader.cs +++ b/src/RynthCore.Engine/Plugins/PluginLoader.cs @@ -493,6 +493,12 @@ internal static class PluginLoader if (strPtr != IntPtr.Zero) plugin.VersionString = Marshal.PtrToStringAnsi(strPtr) ?? ""; } + // The DLL's version resource is stamped at release time with the release and commit; + // the plugins' own RynthPluginVersion strings are hand-written and never change. + string fileVersion = RynthCore.App.BuildVersion.OfFile( + plugin.SourceFilePath.Length > 0 ? plugin.SourceFilePath : plugin.FilePath); + if (fileVersion.Length > 0) + plugin.VersionString = fileVersion; string ver = string.IsNullOrEmpty(plugin.VersionString) ? "" : $" v{plugin.VersionString}"; string caps = BuildCapsList(plugin); diff --git a/src/RynthCore.Engine/RynthCore.Engine.csproj b/src/RynthCore.Engine/RynthCore.Engine.csproj index 1202243..f67b54a 100644 --- a/src/RynthCore.Engine/RynthCore.Engine.csproj +++ b/src/RynthCore.Engine/RynthCore.Engine.csproj @@ -44,6 +44,7 @@ + diff --git a/src/RynthCore.Engine/UI/AvaloniaOverlay.cs b/src/RynthCore.Engine/UI/AvaloniaOverlay.cs index 801060b..9108e4c 100644 --- a/src/RynthCore.Engine/UI/AvaloniaOverlay.cs +++ b/src/RynthCore.Engine/UI/AvaloniaOverlay.cs @@ -1263,7 +1263,9 @@ internal class RynthOverlayWindow : Window var stack = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 4, Margin = new Thickness(8, 4) }; _barStack = stack; - stack.Children.Add(new TextBlock { Text = "RC", FontWeight = FontWeight.Bold, Foreground = Brushes.LightGreen, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0,0,10,0) }); + var rcLabel = new TextBlock { Text = "RC", FontWeight = FontWeight.Bold, Foreground = Brushes.LightGreen, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(0,0,10,0) }; + ToolTip.SetTip(rcLabel, $"RynthCore {EntryPoint.BuildStamp}"); // plugins: Status panel + stack.Children.Add(rcLabel); var barSuppressed = new HashSet { "Monsters", "Settings", "Nav", "Meta", "Items" }; foreach (var p in registeredPanels) diff --git a/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs index 83dee99..bfb3c89 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthAiPanel.cs @@ -346,6 +346,17 @@ internal static partial class RynthAiPanel Foreground = ColText, VerticalAlignment = VerticalAlignment.Center }); + // RynthAi's version (its DLL's version resource), filled by the poll below — + // the plugin may load after the panel is built, and changes on a reload. + var versionText = new TextBlock + { + FontSize = 10, + Foreground = ColMute, + VerticalAlignment = VerticalAlignment.Center, + Margin = new Thickness(8, 2, 0, 0) + }; + int versionPollTicks = 0; + titleStack.Children.Add(versionText); titleRow.Children.Add(titleStack); var chipRow = new StackPanel @@ -836,6 +847,14 @@ internal static partial class RynthAiPanel var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(33) }; timer.Tick += (_, _) => { + if (versionPollTicks-- <= 0) // ~every 2 s; the timer runs at 30 Hz + { + versionPollTicks = 60; + string ver = ""; + foreach (var p in PluginManager.Plugins) + if (p.DisplayName.Contains("RynthAi", StringComparison.OrdinalIgnoreCase)) { ver = p.VersionString; break; } + if (versionText.Text != ver) versionText.Text = ver; + } if (_getSnapshotJson == null) TryBind(); // TL;DR #7: signal the popout host (if floating) that a new diff --git a/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs b/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs index 5252c35..5444ba3 100644 --- a/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/RynthChatPanel.cs @@ -334,6 +334,27 @@ internal static class RynthChatPanel ScrollViewer.SetHorizontalScrollBarVisibility(chatInputBox, ScrollBarVisibility.Disabled); ScrollViewer.SetVerticalScrollBarVisibility(chatInputBox, ScrollBarVisibility.Disabled); + // Tell: start "/tell , " for the NPC or player selected in the game — quest + // NPCs usually haven't spoken to you, so there's no name to click in the scrollback. + // Typing "/tell" (or "/t") alone and pressing Enter does the same. + var tellButton = new Button + { + Content = "Tell", + FontSize = 10, + Height = 22, + Padding = new Thickness(8, 0), + Margin = new Thickness(0, 1, 2, 1), + VerticalContentAlignment = VerticalAlignment.Center, + Background = new SolidColorBrush(Color.FromArgb(0xFF, 0x0E, 0x2E, 0x3A)), + Foreground = Brushes.White, + }; + ToolTip.SetTip(tellButton, "Select an NPC or player in the game, then click to start /tell , — or type /tell and press Enter."); + tellButton.Click += (_, _) => Win32Backend.RequestTellSelected(); + var inputRow = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") }; + inputRow.Children.Add(chatInputBox); + inputRow.Children.Add(tellButton); + Grid.SetColumn(tellButton, 1); + // ── Main layout ──────────────────────────────────────────────── var mainLayout = new DockPanel { @@ -341,10 +362,10 @@ internal static class RynthChatPanel }; DockPanel.SetDock(tabStrip, Dock.Top); DockPanel.SetDock(searchBox, Dock.Top); - DockPanel.SetDock(chatInputBox, Dock.Bottom); + DockPanel.SetDock(inputRow, Dock.Bottom); mainLayout.Children.Add(tabStrip); mainLayout.Children.Add(searchBox); - mainLayout.Children.Add(chatInputBox); + mainLayout.Children.Add(inputRow); mainLayout.Children.Add(scrollViewer); // ── "Copied N lines" flash (top-right, above the scrollback) ── @@ -373,11 +394,14 @@ internal static class RynthChatPanel var suppressChatCheck = new CheckBox { - Content = "Hide retail chat", + Content = "Hide retail chat (Enter types here)", IsChecked = ChatHooks.SuppressOriginalChat, FontSize = 9, Foreground = Brushes.White, }; + ToolTip.SetTip(suppressChatCheck, + "On: the retail chatbox is hidden and Enter types in RynthChat.\n" + + "Off: the retail chatbox is shown and Enter types there; RynthChat keeps showing lines and its Tell button still works."); suppressChatCheck.IsCheckedChanged += (_, _) => { ChatHooks.SuppressOriginalChat = suppressChatCheck.IsChecked == true; @@ -783,6 +807,8 @@ internal static class RynthChatPanel var defaultBorderBrush = chatInputBox.BorderBrush; var activeBorderBrush = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0xD7, 0x00)); + string defaultWatermark = chatInputBox.Watermark ?? ""; + Win32Backend.OnChatCaptureActivated = () => { _captureText = ""; @@ -792,9 +818,40 @@ internal static class RynthChatPanel { chatInputBox.Text = ""; chatInputBox.BorderBrush = activeBorderBrush; + chatInputBox.Watermark = defaultWatermark; }); }; + // Start "/tell , " and leave the player typing. Game thread only + // (Tell button via WM_RYNTHCORE_TELL, or "/tell" alone in OnChatSend), where the + // selection and its name read live. Nothing selected → a hint in the input box. + bool BeginTellToSelected() + { + if (!TryGetSelectedTellName(out string name)) + { + Dispatcher.UIThread.Post(() => + { + chatInputBox.Text = ""; + chatInputBox.Watermark = "Select an NPC or player in the game first, then Tell."; + }); + return false; + } + _captureText = $"/tell {name}, "; + _cursorPos = _captureText.Length; + _historyIndex = -1; + Win32Backend.ChatCaptureActive = true; // keep typing: keys now go to this line + var (snap, pos) = (_captureText, _cursorPos); + Dispatcher.UIThread.Post(() => + { + chatInputBox.Text = snap; + chatInputBox.CaretIndex = pos; + chatInputBox.BorderBrush = activeBorderBrush; + chatInputBox.Watermark = defaultWatermark; + }); + return true; + } + Win32Backend.OnChatTellSelected = () => BeginTellToSelected(); + Win32Backend.OnChatChar = c => { _captureText = _captureText[.._cursorPos] + c + _captureText[_cursorPos..]; @@ -885,6 +942,17 @@ internal static class RynthChatPanel Win32Backend.OnChatSend = () => { string text = _captureText.Trim(); + // "/tell" or "/t" alone addresses the selected NPC or player instead of being + // sent (AC would only answer with the usage line). + if (text.Equals("/tell", StringComparison.OrdinalIgnoreCase) || text.Equals("/t", StringComparison.OrdinalIgnoreCase)) + { + if (!BeginTellToSelected()) + { + _captureText = ""; _cursorPos = 0; _historyIndex = -1; + Dispatcher.UIThread.Post(() => chatInputBox.BorderBrush = defaultBorderBrush); + } + return; + } _captureText = ""; _cursorPos = 0; _historyIndex = -1; @@ -972,6 +1040,13 @@ internal static class RynthChatPanel RebuildTabs(); SelectTab(_activeChannel); + // Whether RynthChat is on screen decides who owns Enter and whether the retail + // chatbox is hidden (ChatHooks.RynthChatOwnsChat). A closed RynthChat used to keep + // both: Enter typed into the invisible panel — every key swallowed until Enter or + // Escape — and the retail chat stayed hidden, so there was no chat at all. + root.AttachedToVisualTree += (_, _) => SetShown(true); + root.DetachedFromVisualTree += (_, _) => SetShown(false); + return root; } @@ -1194,6 +1269,34 @@ internal static class RynthChatPanel internal static bool FloatingSelectionActive => _selDragging; + /// The panel went on or off screen (opened, closed, popped out or back in). + private static void SetShown(bool shown) + { + ChatHooks.ChatPanelShown = shown; + if (!shown && Win32Backend.ChatCaptureActive) + { + // Abandon a half-typed line rather than keep swallowing keys for a closed panel. + Win32Backend.ChatCaptureActive = false; + _captureText = ""; + _cursorPos = 0; + _historyIndex = -1; + } + } + + /// + /// Name of the creature selected in the game — an NPC or another player — for /tell. + /// AC's main thread only (the name read is live there). Never yourself, never an item. + /// + private static bool TryGetSelectedTellName(out string name) + { + name = ""; + uint id = SelectedTargetHooks.ReadCurrentSelectedId(); + if (id == 0 || id == ClientHelperHooks.GetPlayerId()) return false; + const uint ItemTypeCreature = 0x00000010; + if (ClientObjectHooks.TryGetItemType(id, out uint flags) && (flags & ItemTypeCreature) == 0) return false; + return ClientObjectHooks.TryGetObjectName(id, out name) && !string.IsNullOrWhiteSpace(name); + } + // RL loads fresh plugin copies without unloading the old ones: drop the // exports bound below so the next poll re-binds to the live copy. static RynthChatPanel() => PluginManager.PluginsUnloaded += () => diff --git a/src/RynthCore.Engine/UI/Panels/StatusPanel.cs b/src/RynthCore.Engine/UI/Panels/StatusPanel.cs index 08140e0..4062ef1 100644 --- a/src/RynthCore.Engine/UI/Panels/StatusPanel.cs +++ b/src/RynthCore.Engine/UI/Panels/StatusPanel.cs @@ -41,7 +41,7 @@ internal static class StatusPanel panel.Children.Clear(); AddHeader(panel, "Engine"); - AddRow(panel, "Build", EntryPoint.BuildStamp); + AddRow(panel, "Version", EntryPoint.BuildStamp); AddRow(panel, "Game HWND", $"0x{EntryPoint.GameHwnd:X8}"); AddRow(panel, "Plugin dir", PluginManager.PluginDirectory); @@ -64,7 +64,7 @@ internal static class StatusPanel foreach (var p in plugins) { string state = p.Failed ? "FAILED" : p.Initialized ? "OK" : "pending"; - string version = p.VersionString.Length > 0 ? $" v{p.VersionString}" : ""; + string version = p.VersionString.Length > 0 ? $" {p.VersionString}" : ""; AddRow(panel, p.DisplayName + version, state, p.Failed); } }