feat(engine): install-aware paths, logging levels and item drag bridge

- RynthInstallPaths: logs, AcClient, RynthSuite data and imgui.ini resolve
  from the installer-chosen folders instead of hard-coded C:\Games paths
  (engine, injector, loader, launcher, StatusAgent).
- Logging levels: engine.json "LoggingLevel" plus per-category levels
  (LogSettings), edited live from the launcher's Logging tab; RynthLog
  category methods write through them. Errors are always written.
- RynthCore.DesktopLog: shared rolling log + .NET desktop prerequisite check
  for the launcher and agents.
- Item drag bridge: an AC inventory item dragged onto an ImGui window is
  handed to the window instead of dropping on the ground (DragDropHooks,
  ItemDragBridge, Win32Backend input routing); ImGui gets the mouse over
  Avalonia panels while it wants it.

No plugin API changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
BlankenshipG 2026-10-05 16:42:54 -04:00
commit 9709a39e63
32 changed files with 1978 additions and 87 deletions

View file

@ -1,6 +1,8 @@
using System;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using RynthCore;
namespace RynthCore.App.Avalonia;
@ -13,6 +15,18 @@ public partial class App : Application
public override void OnFrameworkInitializationCompleted()
{
try
{
string t = DateTime.Now.ToString("O");
DesktopRollingLog.AppendLine(DesktopRollingLog.StemLauncher,
$"[{t}] [pid:{Environment.ProcessId}] RynthCore.App.Avalonia started (launcher).");
// Detailed host + sidecar file layout (see LauncherHostDiagnostics) for runtime mis-detection triage.
LauncherHostDiagnostics.AppendDesktopLogBlock(t);
}
catch
{
}
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
desktop.MainWindow = new MainWindow();

View file

@ -120,4 +120,19 @@ internal static class EngineJsonStore
fields[field] = doc.RootElement.Clone();
Write(fields);
}
/// <summary>
/// Sets a single string field (e.g. "LoggingLevel"), preserving every other field.
/// </summary>
public static void SetString(string field, string value)
{
Dictionary<string, JsonElement> fields = Read();
using var ms = new MemoryStream();
using (var w = new Utf8JsonWriter(ms))
w.WriteStringValue(value);
using var doc = JsonDocument.Parse(ms.ToArray());
fields[field] = doc.RootElement.Clone();
Write(fields);
}
}

View file

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Text;
using System.Threading;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
@ -18,7 +19,8 @@ namespace RynthCore.App.Avalonia;
/// </summary>
internal static class LauncherDiag
{
private const string UnifiedLogDirectory = @"C:\Games\RynthCore\Logs";
// Installer-chosen RynthCore folder (falls back to C:\Games\RynthCore).
private static readonly string UnifiedLogDirectory = RynthInstallPaths.CoreLogsDir;
private const string UnifiedLogFileName = "RynthCore.log";
private static readonly object LogLock = new();

View file

@ -0,0 +1,110 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using RynthCore;
namespace RynthCore.App.Avalonia;
/// <summary>
/// One-shot host metadata for the Avalonia launcher: helps confirm the renamed apphost
/// (<c>RynthCore.exe</c>) sits next to matching <c>.runtimeconfig.json</c> / <c>.deps.json</c> after installer staging.
/// </summary>
internal static class LauncherHostDiagnostics
{
/// <summary>Single line for the in-window activity feed (short).</summary>
internal static string BuildActivitySummaryLine()
{
string exe = TryGetHostExePath();
string dir = Path.GetDirectoryName(exe) ?? AppContext.BaseDirectory;
HostSidecars side = DescribeSidecars(dir);
// x64 FDD tool prereq: same registry keys as installer/RynthCore.iss (see NetDesktopX64Prerequisite).
string suiteTools = NetDesktopX64Prerequisite.IsSatisfied()
? "x64 suite tools: .NET 10+ OK (registry, same as setup)"
: "x64 suite tools: .NET 10+ not found — install x64 runtime from " + NetDesktopX64Prerequisite.DotNet10RuntimeDownloadUrl;
if (!Environment.Is64BitOperatingSystem)
suiteTools = "x64 suite tools: n/a on 32-bit OS (same as setup)";
return
$"Host: {RuntimeInformation.FrameworkDescription}, arch={RuntimeInformation.ProcessArchitecture}, " +
$"runtimeconfig={(side.RenamedRuntimeConfig ? "RynthCore" : side.LegacyRuntimeConfig ? "App.Avalonia (mismatch?)" : "missing")}, " +
$"deps={(side.RenamedDeps ? "RynthCore" : side.LegacyDeps ? "App.Avalonia (mismatch?)" : "missing")}; {suiteTools}";
}
/// <summary>Writes a detailed block to the desktop rolling launcher log.</summary>
internal static void AppendDesktopLogBlock(string timestampIso)
{
try
{
string exe = TryGetHostExePath();
string dir = Path.GetDirectoryName(exe) ?? AppContext.BaseDirectory;
HostSidecars side = DescribeSidecars(dir);
var sb = new StringBuilder(512);
sb.Append('[').Append(timestampIso).Append("] [pid:").Append(Environment.ProcessId).AppendLine("] Launcher host resolution:");
sb.Append(" ProcessPath: ").AppendLine(exe);
sb.Append(" BaseDirectory: ").AppendLine(AppContext.BaseDirectory);
sb.Append(" Framework: ").AppendLine(RuntimeInformation.FrameworkDescription);
sb.Append(" OSDescription: ").AppendLine(RuntimeInformation.OSDescription);
sb.Append(" ProcessArchitecture: ").AppendLine(RuntimeInformation.ProcessArchitecture.ToString());
sb.Append(" CLR: ").AppendLine(Environment.Version.ToString());
sb.Append(" RynthCore.runtimeconfig.json: ").AppendLine(side.RenamedRuntimeConfig ? "present" : "absent");
sb.Append(" RynthCore.App.Avalonia.runtimeconfig.json: ").AppendLine(side.LegacyRuntimeConfig ? "present (unexpected if exe is RynthCore.exe)" : "absent");
sb.Append(" RynthCore.deps.json: ").AppendLine(side.RenamedDeps ? "present" : "absent");
sb.Append(" RynthCore.App.Avalonia.deps.json: ").AppendLine(side.LegacyDeps ? "present (unexpected if exe is RynthCore.exe)" : "absent");
// Loot/Monster editors are x64 FDD: probe matches RynthCore.iss prerequisite page (64-bit registry view).
sb.Append(" x64 FDD tool runtime (Loot/Monster, same checks as installer): ")
.AppendLine(NetDesktopX64Prerequisite.IsSatisfied() ? "present" : "not detected")
.Append(" .NET 10+ x64 download hub: ")
.AppendLine(NetDesktopX64Prerequisite.DotNet10RuntimeDownloadUrl);
DesktopRollingLog.AppendLine(DesktopRollingLog.StemLauncher, sb.ToString());
}
catch
{
// Logging must never prevent startup.
}
}
private static string TryGetHostExePath()
{
try
{
// Prefer the actual apphost path (works for published rename to RynthCore.exe).
string? p = Environment.ProcessPath;
if (!string.IsNullOrWhiteSpace(p))
return p;
}
catch
{
// ignore
}
try
{
return typeof(App).Assembly.Location;
}
catch
{
return string.Empty;
}
}
private static HostSidecars DescribeSidecars(string directory)
{
if (string.IsNullOrWhiteSpace(directory) || !Directory.Exists(directory))
return new HostSidecars(false, false, false, false);
bool renamedRc = File.Exists(Path.Combine(directory, "RynthCore.runtimeconfig.json"));
bool legacyRc = File.Exists(Path.Combine(directory, "RynthCore.App.Avalonia.runtimeconfig.json"));
bool renamedDeps = File.Exists(Path.Combine(directory, "RynthCore.deps.json"));
bool legacyDeps = File.Exists(Path.Combine(directory, "RynthCore.App.Avalonia.deps.json"));
return new HostSidecars(renamedRc, legacyRc, renamedDeps, legacyDeps);
}
private readonly record struct HostSidecars(
bool RenamedRuntimeConfig,
bool LegacyRuntimeConfig,
bool RenamedDeps,
bool LegacyDeps);
}

View file

@ -0,0 +1,192 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Nodes;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
/// <summary>
/// Launcher-side access to every live logging switch:
/// <list type="bullet">
/// <item>Engine: engine.json "LoggingLevel" (global threshold) and "LogCategories" (per-category emit
/// level). The engine polls engine.json once a second, so edits apply to running clients.</item>
/// <item>RynthAi: Logs\Diagnostics\diagnostics.json "Categories" and "Events" (Off / Trace / Info).
/// RynthAi polls it every couple of seconds and rewrites it with the full catalog on load.</item>
/// </list>
/// </summary>
internal static class LoggingSettingsStore
{
/// <summary>One engine log category as shown in the launcher.</summary>
internal readonly record struct EngineCategory(string Name, string DefaultLevel, string Description);
/// <summary>One RynthAi category / event row read from diagnostics.json.</summary>
internal sealed record DiagnosticsRow(string Key, string Level, string Description);
/// <summary>Global level choices (engine.json "LoggingLevel"), most to least quiet.</summary>
internal static readonly string[] GlobalLevels = { "Off", "Error", "Warning", "Info", "Debug", "Trace" };
/// <summary>Engine category emit levels. Info = normal log; Debug/Trace show only at that global level.</summary>
internal static readonly string[] EngineCategoryLevels = { "Off", "Trace", "Debug", "Info" };
/// <summary>RynthAi category / event levels: Off, Trace (trace file only), Info (also the normal log).</summary>
internal static readonly string[] RynthAiLevels = { "Off", "Trace", "Info" };
/// <summary>Must match RynthCore.Engine.LogCategory names and LogSettings defaults.</summary>
internal static readonly EngineCategory[] EngineCategories =
{
new("General", "Info", "Uncategorised engine lines."),
new("D3D9", "Info", "D3D9 hook, EndScene, bootstrapper, matrix capture, nav markers."),
new("Compat", "Info", "Client hooks: objects, combat, movement, vitals, chat."),
new("Render", "Off", "ImGui rendering and Win32 input (very chatty)."),
new("Plugin", "Info", "Plugin loader/manager and every plugin host Log line."),
new("UI", "Info", "Avalonia overlay and panels."),
new("Verbose", "Debug", "Detail lines across all subsystems (Info = always in the normal log)."),
};
private const string EngineCategoriesProperty = "LogCategories";
/// <summary>RynthAi's diagnostics.json (created by RynthAi on its first load).</summary>
internal static string DiagnosticsPath =>
Path.Combine(RynthInstallPaths.RynthAiDir, "Logs", "Diagnostics", "diagnostics.json");
// ── Engine ──────────────────────────────────────────────────────────
/// <summary>Current engine category levels; categories missing from engine.json get their defaults.</summary>
internal static Dictionary<string, string> ReadEngineCategoryLevels()
{
var result = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
foreach (EngineCategory c in EngineCategories) result[c.Name] = c.DefaultLevel;
Dictionary<string, JsonElement> fields = EngineJsonStore.Read();
if (fields.TryGetValue(EngineCategoriesProperty, out JsonElement cats) && cats.ValueKind == JsonValueKind.Object)
{
foreach (JsonProperty p in cats.EnumerateObject())
{
if (p.Value.ValueKind == JsonValueKind.String && result.ContainsKey(p.Name))
result[p.Name] = p.Value.GetString() ?? result[p.Name];
}
}
return result;
}
/// <summary>Sets one engine category level in engine.json, preserving every other field.</summary>
internal static void SetEngineCategoryLevel(string category, string level)
{
Dictionary<string, string> levels = ReadEngineCategoryLevels();
levels[category] = level;
using var ms = new MemoryStream();
using (var w = new Utf8JsonWriter(ms))
{
w.WriteStartObject();
foreach (EngineCategory c in EngineCategories)
w.WriteString(c.Name, levels[c.Name]);
w.WriteEndObject();
}
Dictionary<string, JsonElement> fields = EngineJsonStore.Read();
using var doc = JsonDocument.Parse(ms.ToArray());
fields[EngineCategoriesProperty] = doc.RootElement.Clone();
EngineJsonStore.Write(fields);
}
// ── RynthAi ─────────────────────────────────────────────────────────
/// <summary>
/// Reads RynthAi's category and event rows. Returns false (with empty lists) when diagnostics.json
/// does not exist yet or cannot be parsed (e.g. RynthAi is mid-write; retry later).
/// </summary>
internal static bool TryReadRynthAi(out List<DiagnosticsRow> categories, out List<DiagnosticsRow> events, out string? error)
{
categories = new List<DiagnosticsRow>();
events = new List<DiagnosticsRow>();
error = null;
try
{
if (!File.Exists(DiagnosticsPath))
{
error = "diagnostics.json not found - start RynthAi once to create it.";
return false;
}
if (JsonNode.Parse(File.ReadAllText(DiagnosticsPath)) is not JsonObject root)
{
error = "diagnostics.json is not a JSON object.";
return false;
}
ReadRows(root["Categories"] as JsonArray, "Name", categories);
ReadRows(root["Events"] as JsonArray, "Key", events);
if (categories.Count == 0)
error = "diagnostics.json has no category list - update RynthAi to 0.6.18 or later.";
return true;
}
catch (Exception ex)
{
error = $"diagnostics.json unreadable ({ex.GetType().Name}: {ex.Message}).";
return false;
}
}
/// <summary>Sets a RynthAi category level ("Off", "Trace", "Info") and keeps "Traces" in sync.</summary>
internal static void SetRynthAiCategoryLevel(string category, string level)
=> UpdateDiagnostics("Categories", "Name", category, level);
/// <summary>Sets a RynthAi key-event level ("Off", "Trace", "Info").</summary>
internal static void SetRynthAiEventLevel(string eventKey, string level)
=> UpdateDiagnostics("Events", "Key", eventKey, level);
private static void ReadRows(JsonArray? array, string keyField, List<DiagnosticsRow> into)
{
if (array == null) return;
foreach (JsonNode? node in array)
{
if (node is not JsonObject o) continue;
string key = o[keyField]?.GetValue<string>() ?? string.Empty;
if (key.Length == 0) continue;
into.Add(new DiagnosticsRow(
key,
o["Level"]?.GetValue<string>() ?? "Off",
o["Description"]?.GetValue<string>() ?? string.Empty));
}
}
/// <summary>Read-modify-write of one row's Level; every other field in the file is preserved.</summary>
private static void UpdateDiagnostics(string section, string keyField, string key, string level)
{
string path = DiagnosticsPath;
if (JsonNode.Parse(File.ReadAllText(path)) is not JsonObject root)
throw new InvalidDataException("diagnostics.json is not a JSON object.");
if (root[section] is not JsonArray rows)
throw new InvalidDataException($"diagnostics.json has no \"{section}\" list.");
bool found = false;
foreach (JsonNode? node in rows)
{
if (node is JsonObject o && string.Equals(o[keyField]?.GetValue<string>(), key, StringComparison.OrdinalIgnoreCase))
{
o["Level"] = level;
found = true;
}
}
if (!found)
throw new KeyNotFoundException($"\"{key}\" is not in diagnostics.json {section}.");
// RynthAi reads Categories when present, but older readers (and /ra trace status) use Traces.
if (section == "Categories")
{
var traces = new JsonArray();
foreach (JsonNode? node in rows)
{
if (node is JsonObject o && !string.Equals(o["Level"]?.GetValue<string>(), "Off", StringComparison.OrdinalIgnoreCase))
traces.Add(o["Name"]?.GetValue<string>());
}
root["Traces"] = traces;
}
// Atomic swap so RynthAi's poll never reads a half-written file.
string tmp = path + ".tmp";
File.WriteAllText(tmp, root.ToJsonString(new JsonSerializerOptions { WriteIndented = false }));
File.Move(tmp, path, overwrite: true);
}
}

View file

@ -0,0 +1,153 @@
using System;
using System.Collections.Generic;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
namespace RynthCore.App.Avalonia;
/// <summary>
/// Runtime tab → Logging card and the live global Logging level box. Every change is written
/// straight to engine.json / diagnostics.json (see <see cref="LoggingSettingsStore"/>); running
/// clients poll those files, so nothing needs a restart or the Save button.
/// </summary>
internal partial class MainWindow
{
private static readonly IBrush LogNameBrush = new SolidColorBrush(Color.Parse("#EAF0F4"));
private static readonly IBrush LogMutedBrush = new SolidColorBrush(Color.Parse("#9AA8B3"));
// Set while the rows are being (re)built so programmatic selections don't write files.
private bool _suppressLoggingEvents;
/// <summary>Wires the Logging card and the live global level box. Called once after LoadRuntimeControls.</summary>
private void InitLoggingControls()
{
LoggingLevelComboBox.SelectionChanged += (_, _) => OnGlobalLoggingLevelChanged();
ReloadLoggingButton.Click += (_, _) => BuildLoggingRows();
BuildLoggingRows();
}
/// <summary>Global level changed: persist to the launcher settings and push to engine.json now.</summary>
private void OnGlobalLoggingLevelChanged()
{
if (_suppressLoggingEvents) return;
string level = GetSelectedLoggingLevel();
if (string.Equals(level, _settings.LoggingLevel, StringComparison.OrdinalIgnoreCase)) return;
try
{
_settings.LoggingLevel = level;
SaveSettings();
EngineJsonStore.SetString("LoggingLevel", level);
AppendActivity($"Logging level set to {level} (applied live to running clients).");
}
catch (Exception ex)
{
AppendActivity($"Failed to save logging level: {ex.Message}");
}
}
/// <summary>(Re)builds the engine category, RynthAi category and RynthAi event rows from disk.</summary>
private void BuildLoggingRows()
{
_suppressLoggingEvents = true;
try
{
EngineLogCategoriesPanel.Children.Clear();
Dictionary<string, string> engineLevels = LoggingSettingsStore.ReadEngineCategoryLevels();
foreach (LoggingSettingsStore.EngineCategory cat in LoggingSettingsStore.EngineCategories)
{
string name = cat.Name;
EngineLogCategoriesPanel.Children.Add(BuildLoggingRow(
name, cat.Description, LoggingSettingsStore.EngineCategoryLevels, engineLevels[name],
level =>
{
LoggingSettingsStore.SetEngineCategoryLevel(name, level);
AppendActivity($"Engine log category {name} set to {level} (applied live).");
}));
}
RynthAiLogCategoriesPanel.Children.Clear();
RynthAiLogEventsPanel.Children.Clear();
bool ok = LoggingSettingsStore.TryReadRynthAi(
out List<LoggingSettingsStore.DiagnosticsRow> categories,
out List<LoggingSettingsStore.DiagnosticsRow> events,
out string? error);
foreach (LoggingSettingsStore.DiagnosticsRow row in categories)
{
string key = row.Key;
RynthAiLogCategoriesPanel.Children.Add(BuildLoggingRow(
key, row.Description, LoggingSettingsStore.RynthAiLevels, row.Level,
level =>
{
LoggingSettingsStore.SetRynthAiCategoryLevel(key, level);
AppendActivity($"RynthAi log category {key} set to {level} (applied live).");
}));
}
foreach (LoggingSettingsStore.DiagnosticsRow row in events)
{
string key = row.Key;
RynthAiLogEventsPanel.Children.Add(BuildLoggingRow(
key, row.Description, LoggingSettingsStore.RynthAiLevels, row.Level,
level =>
{
LoggingSettingsStore.SetRynthAiEventLevel(key, level);
AppendActivity($"RynthAi log event {key} set to {level} (applied live).");
}));
}
LoggingStatusText.Text = ok && error == null
? $"engine.json: {EngineJsonStore.Path}\ndiagnostics.json: {LoggingSettingsStore.DiagnosticsPath}"
: $"RynthAi: {error}";
}
catch (Exception ex)
{
LoggingStatusText.Text = $"Failed to load logging settings: {ex.Message}";
}
finally
{
_suppressLoggingEvents = false;
}
}
/// <summary>One "Name | level box | description" row. <paramref name="apply"/> runs on user changes only.</summary>
private Control BuildLoggingRow(string name, string description, string[] levels, string current, Action<string> apply)
{
var grid = new Grid { ColumnDefinitions = new ColumnDefinitions("170,110,*") };
grid.Children.Add(new TextBlock
{
Text = name,
Foreground = LogNameBrush,
VerticalAlignment = VerticalAlignment.Center,
});
var combo = new ComboBox { ItemsSource = levels, MinWidth = 100, Margin = new global::Avalonia.Thickness(0, 0, 8, 0) };
int index = Array.FindIndex(levels, l => string.Equals(l, current, StringComparison.OrdinalIgnoreCase));
combo.SelectedIndex = index >= 0 ? index : 0;
combo.SelectionChanged += (_, _) =>
{
if (_suppressLoggingEvents || combo.SelectedItem is not string level) return;
try { apply(level); }
catch (Exception ex)
{
AppendActivity($"Failed to set {name} to {level}: {ex.Message}");
// Show what is actually on disk; posted so the combo raising this event isn't torn down mid-handler.
global::Avalonia.Threading.Dispatcher.UIThread.Post(BuildLoggingRows);
}
};
Grid.SetColumn(combo, 1);
grid.Children.Add(combo);
var desc = new TextBlock
{
Text = description,
Foreground = LogMutedBrush,
TextWrapping = TextWrapping.Wrap,
VerticalAlignment = VerticalAlignment.Center,
};
Grid.SetColumn(desc, 2);
grid.Children.Add(desc);
return grid;
}
}

View file

@ -366,7 +366,17 @@
<CheckBox x:Name="OverrideWindowTitleCheckBox"
Content="Rewrite AC window titles per account"
ToolTip.Tip="Replaces &quot;Asheron's Call&quot; with &quot;Account / Character @ Server&quot; on tracked clients so multi-box taskbars are readable. Untracked external clients are left alone." />
<CheckBox x:Name="InjectAllRunningAcCheckBox" Content="Inject all running AC sessions" />
<TextBlock Text="Logging level (applies live)" Foreground="#EAF0F4" Margin="0,4,0,0" />
<ComboBox x:Name="LoggingLevelComboBox" SelectedIndex="3"
ToolTip.Tip="Engine log threshold. Written to engine.json immediately; running clients pick it up within a second. Off = errors only.">
<ComboBoxItem Content="Off" />
<ComboBoxItem Content="Error" />
<ComboBoxItem Content="Warning" />
<ComboBoxItem Content="Info" />
<ComboBoxItem Content="Debug" />
<ComboBoxItem Content="Trace" />
</ComboBox>
<Grid ColumnDefinitions="*,Auto" RowDefinitions="Auto,Auto,Auto" Margin="0,8,0,0">
<TextBlock Grid.Row="0" Grid.Column="0" Text="Inter-launch stagger (ms)" Foreground="#EAF0F4" VerticalAlignment="Center" Margin="0,0,8,6" />
<NumericUpDown Grid.Row="0" Grid.Column="1" x:Name="LaunchStaggerMsBox" Minimum="0" Maximum="5000" Increment="50" Width="120" Margin="0,0,0,6" />
@ -409,6 +419,42 @@
</StackPanel>
</Border>
<!-- Live logging switches: engine categories (engine.json) and RynthAi categories/events
(diagnostics.json). Rows are built in code (MainWindow.Logging.cs). -->
<Border Background="#132028" CornerRadius="16" Padding="18">
<StackPanel Spacing="8">
<Grid ColumnDefinitions="*,Auto">
<TextBlock Grid.Column="0" Text="Logging" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" VerticalAlignment="Center" />
<Button Grid.Column="1" x:Name="ReloadLoggingButton" Content="Reload" />
</Grid>
<TextBlock Text="Every change is saved immediately and applies to running clients without a restart (engine within 1 s, RynthAi within 2 s). Set any Trace or Debug item to Info to see it in the normal log; Off silences it."
TextWrapping="Wrap"
Foreground="#9AA8B3" />
<Expander Header="Engine categories" IsExpanded="True" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="The level each category's lines are written at. A line shows when its level is within the global Logging level above (Info = normal log)."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="EngineLogCategoriesPanel" Spacing="2" />
</StackPanel>
</Expander>
<Expander Header="RynthAi categories" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="Where each RynthAi category's trace lines go: Off = dropped, Trace = Logs\Diagnostics\Trace file only, Info = trace file and the normal log."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="RynthAiLogCategoriesPanel" Spacing="2" />
</StackPanel>
</Expander>
<Expander Header="RynthAi key events" HorizontalAlignment="Stretch">
<StackPanel Spacing="4">
<TextBlock Text="Named milestones (Hub login, options refresh, ...). Off = dropped, Trace = trace file while that category is traced, Info = normal log."
TextWrapping="Wrap" Foreground="#9AA8B3" />
<StackPanel x:Name="RynthAiLogEventsPanel" Spacing="2" />
</StackPanel>
</Expander>
<TextBlock x:Name="LoggingStatusText" TextWrapping="Wrap" Foreground="#9AA8B3" />
</StackPanel>
</Border>
<Border Background="#132028" CornerRadius="16" Padding="18">
<StackPanel Spacing="8">
<TextBlock Text="Recovery Actions" FontSize="16" FontWeight="SemiBold" Foreground="#26C1A6" />
@ -423,7 +469,7 @@
<Button x:Name="CheckDecalBridgeButton" Content="Check Decal bridge" Margin="0,0,8,8"
ToolTip.Tip="For Decal + RynthCore (experimental): checks whether a client started now will load the RynthCore Decal bridge - where Decal reads its plugin list on this PC, whether the bridge is listed and enabled there, Decal's version and its .NET part. Changes nothing unless you press Repair." />
</WrapPanel>
<TextBlock Text="Manual inject targets the first detected acclient.exe session. Reset Overlay Bar signals all running RynthCore clients via the dispatch file."
<TextBlock Text="Manual inject target scope follows the 'Inject all running AC sessions' launch behavior toggle. Reset Overlay Bar signals all running RynthCore clients via the dispatch file."
TextWrapping="Wrap"
Foreground="#9AA8B3" />
</StackPanel>

View file

@ -18,6 +18,7 @@ using Avalonia.Media;
using Avalonia.Platform.Storage;
using Avalonia.Threading;
using RynthCore.Injector;
using RynthCore.Install;
namespace RynthCore.App.Avalonia;
@ -136,6 +137,8 @@ internal partial class MainWindow : Window
SessionList.ItemsSource = _sessionItems;
LoadSettings();
LoadRuntimeControls();
InitLoggingControls();
ApplyInstallerPluginRegistration();
LoadPluginDllPaths();
BuildPluginLoadout();
WireEvents();
@ -149,6 +152,8 @@ internal partial class MainWindow : Window
Closing += (_, _) => SaveWindowLayout();
ShowVersion();
AppendActivity("Avalonia launcher preview ready.");
// One-line host/runtime sidecar check (full detail in Desktop RynthCore-Launcher.log).
AppendActivity(LauncherHostDiagnostics.BuildActivitySummaryLine());
_ = RefreshServerStatusesAsync();
_updateTimer.Tick += async (_, _) => await CheckForUpdatesAsync();
_updateTimer.Start();
@ -307,6 +312,8 @@ internal partial class MainWindow : Window
AutoLaunchHeaderCheckBox.IsChecked = _settings.AutoLaunch;
AutoInjectAfterLaunchCheckBox.IsChecked = _settings.AutoInjectAfterLaunch;
WatchForAcStartCheckBox.IsChecked = _settings.WatchForAcStart;
InjectAllRunningAcCheckBox.IsChecked = _settings.InjectAllRunningClients;
SetLoggingLevelSelection(_settings.LoggingLevel);
OverrideWindowTitleCheckBox.IsChecked = _settings.OverrideWindowTitle;
LaunchStaggerMsBox.Value = _settings.LaunchStaggerMs;
CrashRelaunchLimitBox.Value = _settings.CrashRelaunchLimitInWindow;
@ -1309,6 +1316,8 @@ internal partial class MainWindow : Window
_settings.AutoLaunch = AutoLaunchHeaderCheckBox.IsChecked == true;
_settings.AutoInjectAfterLaunch = AutoInjectAfterLaunchCheckBox.IsChecked == true;
_settings.WatchForAcStart = WatchForAcStartCheckBox.IsChecked == true;
_settings.InjectAllRunningClients = InjectAllRunningAcCheckBox.IsChecked == true;
_settings.LoggingLevel = GetSelectedLoggingLevel();
_settings.OverrideWindowTitle = OverrideWindowTitleCheckBox.IsChecked == true;
if (LaunchStaggerMsBox.Value is decimal staggerMs)
_settings.LaunchStaggerMs = (int)staggerMs;
@ -1323,8 +1332,12 @@ internal partial class MainWindow : Window
if (_settings.EnabledPluginIds.Count == 0)
_settings.EnabledPluginIds.Add("rynthcore-engine");
SaveSettings();
SyncPluginPathsToEngineSettings();
if (appendActivity)
{
AppendActivity($"Logging level saved: {_settings.LoggingLevel}.");
AppendActivity("Launch behavior saved.");
}
}
private void SaveAutoLaunchPreference()
@ -1981,6 +1994,78 @@ internal partial class MainWindow : Window
AppendActivity($"Runtime loadout updated: {Path.GetFileName(dllPath)} {(enabled ? "enabled" : "disabled")} (engine.json synced).");
}
/// <summary>
/// Applies the installer's one-shot plugin hand-off: the full installer writes the plugin
/// DLL paths it placed in the user-chosen RynthSuite folder to
/// <c>Software\Rynth\PendingPluginRegistration</c> (';'-separated). Each existing DLL is added
/// to the Plugins list, and any entry with the same file name that no longer exists (e.g. the
/// old <c>C:\Games\RynthSuite\...</c> path after moving the Suite folder) is replaced.
/// Rows pointing inside the RynthCore folder whose file the installer removed are dropped too.
/// The value is consumed once (deleted from HKCU; remembered in settings for HKLM).
/// </summary>
private void ApplyInstallerPluginRegistration()
{
try
{
string? pending = RynthInstallPaths.ReadSetting("PendingPluginRegistration");
if (string.IsNullOrWhiteSpace(pending)
|| string.Equals(pending, _settings.AppliedInstallerPluginRegistration, StringComparison.OrdinalIgnoreCase))
return;
_settings.PluginDllPaths ??= [];
var added = new List<string>();
// The installer clears loose DLLs out of the RynthCore folder (old 0.4.x layouts kept plugins
// and SDK DLLs there), so drop rows that pointed inside it and are now gone. Rows elsewhere are
// left alone, since a missing file there may just be on a drive that isn't mounted.
string coreRoot = Path.TrimEndingDirectorySeparator(RynthInstallPaths.CoreDir) + Path.DirectorySeparatorChar;
bool IsRemovedCoreFile(string p) =>
p.StartsWith(coreRoot, StringComparison.OrdinalIgnoreCase) && !File.Exists(p);
int pruned = _settings.PluginDllPaths.RemoveAll(IsRemovedCoreFile);
_settings.DisabledPluginDllPaths.RemoveAll(IsRemovedCoreFile);
foreach (string raw in pending.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
{
string path;
try { path = Path.GetFullPath(raw); } catch { continue; }
if (!File.Exists(path)) continue;
string fileName = Path.GetFileName(path);
// Drop stale rows for the same plugin that point at a file which is gone.
_settings.PluginDllPaths.RemoveAll(p =>
string.Equals(Path.GetFileName(p), fileName, StringComparison.OrdinalIgnoreCase)
&& !string.Equals(p, path, StringComparison.OrdinalIgnoreCase)
&& !File.Exists(p));
if (!_settings.PluginDllPaths.Any(p => string.Equals(p, path, StringComparison.OrdinalIgnoreCase)))
{
_settings.PluginDllPaths.Add(path);
added.Add(fileName);
}
}
_settings.AppliedInstallerPluginRegistration = pending;
SaveSettings();
RynthInstallPaths.DeleteUserSetting("PendingPluginRegistration");
_pluginDllPaths.Clear();
foreach (string p in _settings.PluginDllPaths) _pluginDllPaths.Add(p);
SyncPluginPathsToEngineSettings();
string msg = added.Count > 0
? $"Installer registered plugin(s): {string.Join(", ", added)} (engine.json synced)."
: "Installer plugin registration already up to date.";
if (pruned > 0)
msg += $" Removed {pruned} plugin path(s) for files the installer cleared from {RynthInstallPaths.CoreDir}.";
LauncherDiag.Info("PLUGINS: " + msg);
try { AppendActivity(msg); } catch { }
}
catch (Exception ex)
{
LauncherDiag.Info("PLUGINS: installer registration failed: " + ex.Message);
}
}
private void LoadPluginDllPaths()
{
_pluginDllPaths.Clear();
@ -2069,6 +2154,8 @@ internal partial class MainWindow : Window
.Where(p => !disabled.Contains(p))
.ToList();
EngineJsonStore.SetStringArray("PluginPaths", enabledPaths);
// The engine reads its log verbosity from engine.json on init (EngineSettings.LoggingLevel).
EngineJsonStore.SetString("LoggingLevel", GetSelectedLoggingLevel());
}
catch (Exception ex)
{
@ -2564,18 +2651,28 @@ internal partial class MainWindow : Window
try
{
SetOperationState(true);
Process target = targets.OrderBy(process => process.Id).First();
AppendActivity($"Applying selected loadout to running AC (PID {target.Id}).");
IReadOnlyList<Process> orderedTargets = targets.OrderBy(process => process.Id).ToList();
bool injectAllSessions = InjectAllRunningAcCheckBox.IsChecked == true;
IReadOnlyList<Process> targetsToInject = injectAllSessions
? orderedTargets
: [orderedTargets[0]];
AppendActivity(injectAllSessions
? $"Applying selected loadout to {targetsToInject.Count} running AC session(s)."
: $"Applying selected loadout to first running AC session (PID {targetsToInject[0].Id}).");
InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(target, enginePath, AppendActivity));
if (result.Success)
foreach (Process target in targetsToInject)
{
_launchedSessionPids.Add(target.Id);
AppendActivity($"Injection complete for PID {target.Id}.");
}
else
{
AppendActivity($"Injection failed: {result.Summary}");
AppendActivity($"Injecting running AC (PID {target.Id}).");
InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(target, enginePath, AppendActivity));
if (result.Success)
{
_launchedSessionPids.Add(target.Id);
AppendActivity($"Injection complete for PID {target.Id}.");
}
else
{
AppendActivity($"Injection failed for PID {target.Id}: {result.Summary}");
}
}
}
catch (Exception ex)
@ -2589,6 +2686,39 @@ internal partial class MainWindow : Window
}
}
private string GetSelectedLoggingLevel()
{
return LoggingLevelComboBox.SelectedItem is ComboBoxItem item
? item.Content?.ToString() ?? "Info"
: "Info";
}
private void SetLoggingLevelSelection(string? loggingLevel)
{
string desiredLevel = string.IsNullOrWhiteSpace(loggingLevel) ? "Info" : loggingLevel.Trim();
if (LoggingLevelComboBox.Items == null)
{
LoggingLevelComboBox.SelectedIndex = 0;
return;
}
foreach (object? item in LoggingLevelComboBox.Items)
{
if (item is not ComboBoxItem comboItem)
continue;
string candidate = comboItem.Content?.ToString() ?? string.Empty;
if (!string.Equals(candidate, desiredLevel, StringComparison.OrdinalIgnoreCase))
continue;
LoggingLevelComboBox.SelectedItem = comboItem;
return;
}
// Unknown saved value: fall back to Info (index 3 after Off, Error, Warning), not the quietest level.
LoggingLevelComboBox.SelectedIndex = 3;
}
private void OnPrimarySelectionChanged()
{
if (_suppressPrimarySelectionChanged)
@ -2988,7 +3118,7 @@ internal partial class MainWindow : Window
// Tail the per-PID log for the last heartbeat line. Cheap: seek to
// the end, read ~2KB, FileShare-tolerant of the engine's writer.
string logPath = System.IO.Path.Combine(@"C:\Games\RynthCore\Logs", $"RynthCore.{pid}.log");
string logPath = System.IO.Path.Combine(RynthInstallPaths.CoreLogsDir, $"RynthCore.{pid}.log");
string tail;
try
{

View file

@ -1,6 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Launcher assembly version (bump when changing launcher-only behavior). Previous: 0.1.4.
No hard-coded InformationalVersion: release builds pass -p:Version=yyyy.m.d.n, and the
product version derived from it is what the launcher/About show (BuildVersion.Format). -->
<Version>0.1.5</Version>
<AssemblyVersion>0.1.5.0</AssemblyVersion>
<FileVersion>0.1.5.0</FileVersion>
<OutputType>WinExe</OutputType>
<TargetFramework>net10.0-windows7.0</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
@ -11,6 +17,8 @@
<RootNamespace>RynthCore.App.Avalonia</RootNamespace>
<AssemblyName>RynthCore.App.Avalonia</AssemblyName>
<RuntimeIdentifiers>win-x86</RuntimeIdentifiers>
<!-- Build-Installer.ps1 publishes self-contained so RynthCore.exe does not require a machine-wide
.NET 10 Desktop Runtime. Local dotnet build or dotnet run still use the SDK. -->
<ApplicationIcon>LogoCore.ico</ApplicationIcon>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
</PropertyGroup>
@ -25,6 +33,12 @@
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
<!-- Direct reference overrides Avalonia's transitive 0.20.x (NU1903 / GHSA-xrw6-gwf8-vvr9). -->
<PackageReference Include="Tmds.DBus.Protocol" Version="0.21.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RynthCore.DesktopLog\RynthCore.DesktopLog.csproj" />
</ItemGroup>
<ItemGroup>
@ -53,4 +67,9 @@
<Compile Include="..\RynthCore.Injector\InjectionResult.cs" Link="Shared\InjectionResult.cs" />
</ItemGroup>
<ItemGroup>
<!-- Install-location resolver (installer-chosen RynthCore / RynthSuite folders). -->
<Compile Include="..\RynthCore.App\RynthInstallPaths.cs" Link="Shared\RynthInstallPaths.cs" />
</ItemGroup>
</Project>