diff --git a/BUILD.md b/BUILD.md
new file mode 100644
index 0000000..ab9f247
--- /dev/null
+++ b/BUILD.md
@@ -0,0 +1,141 @@
+# Build & Deploy
+
+RynthCore is the injection framework. RynthSuite (separate repo) contains the plugins that run on top of it.
+
+## Prerequisites
+
+- Windows 10/11
+- .NET 9 SDK (x86)
+- Visual Studio 2022 Build Tools with the .NET desktop and C++ desktop workloads (required by the NativeAOT ILC linker)
+- Asheron's Call client installed
+
+## Projects
+
+| Project | Type | Output |
+|---------|------|--------|
+| `src/RynthCore.Engine` | NativeAOT x86 DLL | Injected into acclient.exe — hooks D3D9 EndScene, hosts ImGui overlay |
+| `src/RynthCore.Injector` | Console app | Injects the engine DLL via LoadLibrary + CreateRemoteThread |
+| `src/RynthCore.App.Avalonia` | Avalonia desktop app | Desktop launcher — server/account profiles, plugin management, launches + injects |
+| `src/RynthCore.PluginSdk` | Class library | Public host API surface for plugins |
+| `src/RynthCore.PluginCore` | Class library | Runtime helpers for plugin bootstrap/lifecycle |
+| `src/RynthCore.App` | Shared source | Model and service files linked by both the Avalonia app and the Engine (not a standalone project) |
+
+## Publish Commands
+
+### Launcher (Avalonia)
+
+```bash
+cd C:\Projects\RynthCore\src\RynthCore.App.Avalonia
+dotnet build -c Release
+```
+
+Output: `bin\Release\net9.0-windows7.0\RynthCore.App.Avalonia.dll`
+
+### Engine (NativeAOT — slow first build, ~2 min)
+
+Requires `vswhere.exe` on PATH. If the build fails with `'vswhere.exe' is not recognized`, add the VS Installer directory:
+
+```bash
+set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\Installer
+```
+
+```bash
+cd C:\Projects\RynthCore\src\RynthCore.Engine
+dotnet publish -c Release
+```
+
+Output: `bin\Release\net9.0-windows\win-x86\publish\RynthCore.Engine.dll` (~26 MB)
+
+### RynthAi Plugin (NativeAOT — separate repo)
+
+Always clean first — incremental builds can silently skip NativeAOT and produce a stale DLL.
+
+```bash
+cd C:\Projects\RynthSuite\Plugins\RynthCore.Plugin.RynthAi
+rmdir /s /q obj\Release bin\Release 2>nul
+dotnet publish -c Release
+```
+
+Output: `bin\Release\net9.0-windows\win-x86\publish\RynthCore.Plugin.RynthAi.dll` (~7 MB)
+
+## Deploy
+
+### Directory Layout
+
+```
+C:\Games\RynthCore\
+├── RynthCore.exe ← Launcher (renamed from RynthCore.App.Avalonia.exe)
+├── RynthCore.App.Avalonia.dll ← Launcher assembly
+├── RynthCore.App.Avalonia.deps.json
+├── RynthCore.App.Avalonia.runtimeconfig.json
+├── Avalonia.*.dll ← Avalonia framework DLLs
+└── Runtime\
+ ├── RynthCore.Engine.dll ← Engine (NativeAOT x86)
+ ├── minhook.x86.dll ← MinHook (x86), preloaded by EntryPoint
+ ├── cimgui.dll ← ImGui C bindings (x86, docking branch)
+ └── Plugins\
+ └── *.dll ← Plugin DLLs (built-in directory)
+
+C:\Games\RynthSuite\RynthAi\
+├── RynthCore.Plugin.RynthAi.dll ← RynthAi plugin (recommended deploy location)
+├── NavProfiles\ ← Navigation profiles
+├── LootProfiles\ ← Loot profiles
+└── Metas\ ← Meta files
+```
+
+### Deploy Launcher
+
+The launcher can stay open while you replace its DLL.
+
+```bash
+copy src\RynthCore.App.Avalonia\bin\Release\net9.0-windows7.0\RynthCore.App.Avalonia.dll C:\Games\RynthCore\
+copy src\RynthCore.App.Avalonia\bin\Release\net9.0-windows7.0\RynthCore.App.Avalonia.deps.json C:\Games\RynthCore\
+```
+
+Restart the launcher after deploying.
+
+### Deploy Engine
+
+**AC must be closed** — the running client holds a file lock on the engine DLL.
+
+```bash
+copy src\RynthCore.Engine\bin\Release\net9.0-windows\win-x86\publish\RynthCore.Engine.dll C:\Games\RynthCore\Runtime\
+```
+
+### Deploy RynthAi Plugin
+
+**AC can stay open** — plugins are shadow-copied at load time, so the file is not locked.
+
+The recommended deploy location is `C:\Games\RynthSuite\RynthAi\` — alongside the plugin's data files. Add this path in the launcher's **Plugins** tab. Paths are persisted to `%AppData%\RynthCore\engine.json`.
+
+```bash
+copy C:\Projects\RynthSuite\Plugins\RynthCore.Plugin.RynthAi\bin\Release\net9.0-windows\win-x86\publish\RynthCore.Plugin.RynthAi.dll C:\Games\RynthSuite\RynthAi\
+```
+
+Alternatively, deploy to the engine's built-in plugin directory:
+
+```bash
+copy ... C:\Games\RynthCore\Runtime\Plugins\
+```
+
+After deploying a plugin with AC running, click **RL** on the RynthCore overlay bar to hot-reload.
+
+## Verify
+
+| File | Expected Size | If Wrong |
+|------|--------------|----------|
+| `Runtime\RynthCore.Engine.dll` | ~26 MB | NativeAOT didn't run — check for `Generating native code` in build output |
+| `RynthSuite\RynthAi\RynthCore.Plugin.RynthAi.dll` | ~7 MB | If ~1 MB, you built the stale stub at `C:\Projects\RynthCore\Plugins\` instead of `C:\Projects\RynthSuite\Plugins\` |
+| `Runtime\cimgui.dll` | ~1.5 MB | Must match ImGui.NET 1.91.6.1 |
+
+To confirm NativeAOT actually ran, check that `.lib` and `.exp` files exist alongside the DLL in the `native\` directory.
+
+## Gotchas
+
+- **`dotnet publish`, not `dotnet build` for Engine and Plugins.** NativeAOT only runs during `dotnet publish`. A `dotnet build` produces a valid managed DLL that compiles fine but has no unmanaged exports and will be silently ignored by the engine. The Avalonia launcher is the exception — `dotnet build` is fine since it's a normal .NET app.
+- **Clean before plugin publish.** Incremental NativeAOT builds can silently reuse stale output. Delete `obj\Release` and `bin\Release` before every publish to guarantee a fresh compile.
+- **Engine deploy path is `Runtime\`**, not `C:\Games\RynthCore\`. The injector resolves `Runtime\RynthCore.Engine.dll` by default.
+- **Two RynthAi projects exist.** The real plugin is at `C:\Projects\RynthSuite\Plugins\RynthCore.Plugin.RynthAi\`. There is a stale stub at `C:\Projects\RynthCore\Plugins\RynthCore.Plugin.RynthAi\` — do not build or deploy from there.
+- **Engine publish copies a stale plugin** into the engine's publish output. Always deploy the plugin from the RynthSuite path last.
+- **cimgui.dll version must match ImGui.NET NuGet.** Post-1.90 struct layouts changed. A mismatched cimgui.dll causes `DisplaySize = <1, 1>` or font crashes.
+- **vswhere.exe must be on PATH** for NativeAOT link step. Add `C:\Program Files (x86)\Microsoft Visual Studio\Installer` to PATH if missing.
diff --git a/RynthCore.sln b/RynthCore.sln
index de2c66e..662fa62 100644
--- a/RynthCore.sln
+++ b/RynthCore.sln
@@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RynthCore.Engine", "src\Ryn
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RynthCore.Injector", "src\RynthCore.Injector\RynthCore.Injector.csproj", "{A1B2C3D4-0002-0002-0002-000000000002}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RynthCore.App", "src\RynthCore.App\RynthCore.App.csproj", "{A1B2C3D4-0003-0003-0003-000000000003}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RynthCore.Plugin.RynthAi", "Plugins\RynthCore.Plugin.RynthAi\RynthCore.Plugin.RynthAi.csproj", "{A1B2C3D4-0005-0005-0005-000000000005}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
@@ -53,19 +51,7 @@ Global
{A1B2C3D4-0002-0002-0002-000000000002}.Release|Any CPU.Build.0 = Release|Any CPU
{A1B2C3D4-0002-0002-0002-000000000002}.Release|x64.ActiveCfg = Release|Any CPU
{A1B2C3D4-0002-0002-0002-000000000002}.Release|x64.Build.0 = Release|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|x86.ActiveCfg = Debug|x86
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|x86.Build.0 = Debug|x86
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|x64.ActiveCfg = Debug|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Debug|x64.Build.0 = Debug|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|x86.ActiveCfg = Release|x86
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|x86.Build.0 = Release|x86
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|Any CPU.Build.0 = Release|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|x64.ActiveCfg = Release|Any CPU
- {A1B2C3D4-0003-0003-0003-000000000003}.Release|x64.Build.0 = Release|Any CPU
- {A1B2C3D4-0005-0005-0005-000000000005}.Debug|x86.ActiveCfg = Debug|x86
+{A1B2C3D4-0005-0005-0005-000000000005}.Debug|x86.ActiveCfg = Debug|x86
{A1B2C3D4-0005-0005-0005-000000000005}.Debug|x86.Build.0 = Debug|x86
{A1B2C3D4-0005-0005-0005-000000000005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1B2C3D4-0005-0005-0005-000000000005}.Debug|Any CPU.Build.0 = Debug|Any CPU
diff --git a/src/RynthCore.App.Avalonia/MainWindow.axaml b/src/RynthCore.App.Avalonia/MainWindow.axaml
index 4bada85..8aab5b3 100644
--- a/src/RynthCore.App.Avalonia/MainWindow.axaml
+++ b/src/RynthCore.App.Avalonia/MainWindow.axaml
@@ -226,23 +226,31 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
-
@@ -269,7 +277,7 @@
-
@@ -284,38 +292,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -346,19 +337,11 @@
-
-
-
-
-
-
-
-
diff --git a/src/RynthCore.App.Avalonia/MainWindow.axaml.cs b/src/RynthCore.App.Avalonia/MainWindow.axaml.cs
index 68dda87..5ba19a2 100644
--- a/src/RynthCore.App.Avalonia/MainWindow.axaml.cs
+++ b/src/RynthCore.App.Avalonia/MainWindow.axaml.cs
@@ -4,11 +4,13 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
+using System.Text.Json;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.Media;
+using Avalonia.Platform.Storage;
using Avalonia.Threading;
using RynthCore.Injector;
@@ -25,6 +27,7 @@ internal partial class MainWindow : Window
private readonly ServerStatusProbeService _serverStatusProbe = new();
private readonly ObservableCollection _activityItems = [];
private readonly ObservableCollection _sessionItems = [];
+ private readonly ObservableCollection _pluginDllPaths = [];
private readonly HashSet _launchedSessionPids = [];
private readonly Dictionary _launchTargetStatusTexts = [];
private readonly Dictionary _launchTargetChecks = [];
@@ -41,14 +44,6 @@ internal partial class MainWindow : Window
Summary = "Injects the in-process runtime and overlay host into acclient.exe.",
StatusText = "Implemented now",
RuntimeImplemented = true
- },
- new PluginDefinition
- {
- Id = "nexai",
- Name = "RynthAi",
- Summary = "Selection is persisted now so the desktop host becomes the future loadout surface for adopted runtime modules.",
- StatusText = "Planned adoption",
- RuntimeImplemented = false
}
];
private readonly Dictionary _pluginChecks = [];
@@ -68,6 +63,7 @@ internal partial class MainWindow : Window
SessionList.ItemsSource = _sessionItems;
LoadSettings();
LoadRuntimeControls();
+ LoadPluginDllPaths();
BuildPluginLoadout();
WireEvents();
RefreshLists();
@@ -103,6 +99,7 @@ internal partial class MainWindow : Window
SaveBehaviorButton.Click += (_, _) => SaveLaunchBehavior();
InjectRunningAcButton.Click += async (_, _) => await InjectRunningAcAsync();
RefreshSessionsButton.Click += (_, _) => RefreshSessionState();
+ AddPluginDllButton.Click += async (_, _) => await AddPluginDllAsync();
ServerProfilesList.SelectionChanged += (_, _) => OnPrimarySelectionChanged();
AccountProfilesList.SelectionChanged += (_, _) => OnPrimarySelectionChanged();
@@ -164,41 +161,87 @@ internal partial class MainWindow : Window
foreach (PluginDefinition plugin in _plugins)
{
- var host = new Border
- {
- Background = Brush.Parse("#0F161D"),
- BorderBrush = Brush.Parse("#243742"),
- BorderThickness = new Thickness(1),
- CornerRadius = new CornerRadius(12),
- Padding = new Thickness(12)
- };
-
- var stack = new StackPanel { Spacing = 6 };
var checkBox = new CheckBox
{
Content = plugin.Name,
IsChecked = _settings.EnabledPluginIds.Contains(plugin.Id, StringComparer.OrdinalIgnoreCase)
};
checkBox.IsCheckedChanged += (_, _) => OnPluginSelectionChanged(plugin, checkBox);
-
- stack.Children.Add(checkBox);
- stack.Children.Add(new TextBlock
- {
- Text = plugin.StatusText.ToUpperInvariant(),
- Foreground = Brush.Parse(plugin.RuntimeImplemented ? "#66D687" : "#E2B348"),
- FontWeight = FontWeight.Bold
- });
- stack.Children.Add(new TextBlock
- {
- Text = plugin.Summary,
- TextWrapping = TextWrapping.Wrap,
- Foreground = Brush.Parse("#9AA8B3")
- });
-
- host.Child = stack;
- PluginLoadoutPanel.Children.Add(host);
_pluginChecks[plugin.Id] = checkBox;
+
+ PluginLoadoutPanel.Children.Add(BuildPluginCard(checkBox, plugin.Summary, null));
}
+
+ foreach (string dllPath in _pluginDllPaths)
+ {
+ string capturedPath = dllPath;
+ string pluginName = Path.GetFileNameWithoutExtension(dllPath);
+
+ var checkBox = new CheckBox { Content = pluginName, IsChecked = true };
+
+ PluginLoadoutPanel.Children.Add(BuildPluginCard(checkBox, capturedPath, () =>
+ {
+ for (int j = _pluginDllPaths.Count - 1; j >= 0; j--)
+ {
+ if (string.Equals(_pluginDllPaths[j], capturedPath, StringComparison.OrdinalIgnoreCase))
+ {
+ _pluginDllPaths.RemoveAt(j);
+ break;
+ }
+ }
+ SavePluginDllPaths();
+ BuildPluginLoadout();
+ AppendActivity($"Removed plugin: {Path.GetFileName(capturedPath)}");
+ }));
+ }
+ }
+
+ private static Border BuildPluginCard(CheckBox checkBox, string description, Action? onRemove)
+ {
+ var host = new Border
+ {
+ Background = Brush.Parse("#0F161D"),
+ BorderBrush = Brush.Parse("#243742"),
+ BorderThickness = new Thickness(1),
+ CornerRadius = new CornerRadius(12),
+ Padding = new Thickness(12)
+ };
+
+ var stack = new StackPanel { Spacing = 6 };
+ stack.Children.Add(checkBox);
+ stack.Children.Add(new TextBlock
+ {
+ Text = description,
+ TextWrapping = TextWrapping.Wrap,
+ Foreground = Brush.Parse("#9AA8B3")
+ });
+
+ if (onRemove == null)
+ {
+ host.Child = stack;
+ return host;
+ }
+
+ var row = new Grid { ColumnDefinitions = new ColumnDefinitions("*, Auto") };
+ var removeButton = new Button
+ {
+ Content = "\u2715",
+ FontSize = 14,
+ Padding = new Thickness(6, 2),
+ VerticalAlignment = VerticalAlignment.Top,
+ Background = Brushes.Transparent,
+ Foreground = Brush.Parse("#9AA8B3"),
+ BorderThickness = new Thickness(0)
+ };
+ removeButton.Click += (_, _) => onRemove();
+
+ Grid.SetColumn(stack, 0);
+ Grid.SetColumn(removeButton, 1);
+ row.Children.Add(stack);
+ row.Children.Add(removeButton);
+
+ host.Child = row;
+ return host;
}
private void RefreshLists()
@@ -997,6 +1040,87 @@ internal partial class MainWindow : Window
AppendActivity($"Runtime loadout updated: {plugin.Name} {(checkBox.IsChecked == true ? "enabled" : "disabled")}.");
}
+ private void LoadPluginDllPaths()
+ {
+ _pluginDllPaths.Clear();
+ if (_settings.PluginDllPaths != null)
+ {
+ foreach (string path in _settings.PluginDllPaths)
+ _pluginDllPaths.Add(path);
+ }
+ }
+
+ private async Task AddPluginDllAsync()
+ {
+ var topLevel = GetTopLevel(this);
+ if (topLevel == null)
+ return;
+
+ var files = await topLevel.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
+ {
+ Title = "Select a plugin DLL",
+ AllowMultiple = false,
+ FileTypeFilter =
+ [
+ new FilePickerFileType("Plugin DLL") { Patterns = ["*.dll"] },
+ new FilePickerFileType("All Files") { Patterns = ["*"] }
+ ]
+ });
+
+ if (files.Count == 0)
+ return;
+
+ string fullPath = Path.GetFullPath(files[0].Path.LocalPath);
+
+ if (_pluginDllPaths.Any(p => string.Equals(p, fullPath, StringComparison.OrdinalIgnoreCase)))
+ {
+ AppendActivity($"Plugin path already added: {fullPath}");
+ return;
+ }
+
+ _pluginDllPaths.Add(fullPath);
+ SavePluginDllPaths();
+ BuildPluginLoadout();
+ AppendActivity($"Added plugin: {Path.GetFileName(fullPath)}");
+ }
+
+ private void SavePluginDllPaths()
+ {
+ _settings.PluginDllPaths = _pluginDllPaths.ToList();
+ SaveSettings();
+ SyncPluginPathsToEngineSettings();
+ }
+
+ private void SyncPluginPathsToEngineSettings()
+ {
+ string engineSettingsPath = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
+ "RynthCore",
+ "engine.json");
+
+ try
+ {
+ string? dir = Path.GetDirectoryName(engineSettingsPath);
+ if (dir != null) Directory.CreateDirectory(dir);
+
+ using var ms = new MemoryStream();
+ using (var w = new Utf8JsonWriter(ms, new JsonWriterOptions { Indented = true }))
+ {
+ w.WriteStartObject();
+ w.WriteStartArray("PluginPaths");
+ foreach (string p in _pluginDllPaths)
+ w.WriteStringValue(p);
+ w.WriteEndArray();
+ w.WriteEndObject();
+ }
+ File.WriteAllBytes(engineSettingsPath, ms.ToArray());
+ }
+ catch (Exception ex)
+ {
+ AppendActivity($"Failed to sync plugin paths to engine.json: {ex.Message}");
+ }
+ }
+
private async Task InjectRunningAcAsync()
{
if (_operationBusy)
@@ -1035,9 +1159,6 @@ internal partial class MainWindow : Window
Process target = targets.OrderBy(process => process.Id).First();
AppendActivity($"Applying selected loadout to running AC (PID {target.Id}).");
- if (GetSelectedPluginIds().Contains("nexai", StringComparer.OrdinalIgnoreCase))
- AppendActivity("RynthAi is selected and saved in the loadout. Runtime adoption is still a future step.");
-
InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(target, enginePath, AppendActivity));
if (result.Success)
{
diff --git a/src/RynthCore.App/AppSettings.cs b/src/RynthCore.App/AppSettings.cs
index d3dbd44..1b77a8f 100644
--- a/src/RynthCore.App/AppSettings.cs
+++ b/src/RynthCore.App/AppSettings.cs
@@ -18,6 +18,7 @@ internal sealed class AppSettings
public bool AutoInjectAfterLaunch { get; set; } = true;
public bool WatchForAcStart { get; set; } = true;
public List EnabledPluginIds { get; set; } = [];
+ public List PluginDllPaths { get; set; } = [];
public List ServerProfiles { get; set; } = [];
public List AccountProfiles { get; set; } = [];
diff --git a/src/RynthCore.App/Assets/RynthCore.ico b/src/RynthCore.App/Assets/RynthCore.ico
deleted file mode 100644
index e359225..0000000
Binary files a/src/RynthCore.App/Assets/RynthCore.ico and /dev/null differ
diff --git a/src/RynthCore.App/LaunchProfileDialogs.cs b/src/RynthCore.App/LaunchProfileDialogs.cs
deleted file mode 100644
index 9d64a41..0000000
--- a/src/RynthCore.App/LaunchProfileDialogs.cs
+++ /dev/null
@@ -1,224 +0,0 @@
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace RynthCore.App;
-
-internal static class LaunchProfileDialogs
-{
- public static bool TryEditServer(IWin32Window owner, LaunchServerProfile profile)
- {
- using var dialog = CreateEditorDialog("Server Profile", 520, 300);
- var nameBox = CreateTextBox(profile.Name);
- var aliasBox = CreateTextBox(profile.Alias);
- var hostBox = CreateTextBox(profile.Host);
- var portBox = CreateTextBox(profile.Port > 0 ? profile.Port.ToString() : string.Empty);
- var emulatorCombo = CreateComboBox();
- emulatorCombo.Items.AddRange(Enum.GetNames());
- emulatorCombo.SelectedItem = profile.Emulator.ToString();
- var rodatCheck = new CheckBox
- {
- Text = "Enable Rodat",
- AutoSize = true,
- Checked = profile.RodatEnabled,
- ForeColor = Color.White,
- BackColor = Color.Transparent,
- Margin = new Padding(0, 6, 0, 0)
- };
-
- var body = CreateFormLayout();
- body.Controls.Add(CreateLabeledRow("Server Name", nameBox), 0, 0);
- body.Controls.Add(CreateLabeledRow("Alias", aliasBox), 0, 1);
- body.Controls.Add(CreateLabeledRow("Host", hostBox), 0, 2);
- body.Controls.Add(CreateLabeledRow("Port", portBox), 0, 3);
- body.Controls.Add(CreateLabeledRow("Emulator", emulatorCombo), 0, 4);
- body.Controls.Add(rodatCheck, 0, 5);
- dialog.Controls.Add(body);
-
- void SaveAndClose(object? _, EventArgs __)
- {
- if (string.IsNullOrWhiteSpace(nameBox.Text))
- {
- ShowValidation(dialog, "Server name is required.");
- return;
- }
-
- if (string.IsNullOrWhiteSpace(hostBox.Text))
- {
- ShowValidation(dialog, "Server host is required.");
- return;
- }
-
- if (!int.TryParse(portBox.Text.Trim(), out int port) || port <= 0)
- {
- ShowValidation(dialog, "Server port must be a positive integer.");
- return;
- }
-
- if (emulatorCombo.SelectedItem is not string emulatorText ||
- !Enum.TryParse(emulatorText, ignoreCase: true, out AcEmulatorKind emulator))
- {
- ShowValidation(dialog, "Select an emulator type.");
- return;
- }
-
- profile.Name = nameBox.Text.Trim();
- profile.Alias = aliasBox.Text.Trim();
- profile.Host = hostBox.Text.Trim();
- profile.Port = port;
- profile.Emulator = emulator;
- profile.RodatEnabled = rodatCheck.Checked;
-
- dialog.DialogResult = DialogResult.OK;
- dialog.Close();
- }
-
- WireDialogButtons(dialog, SaveAndClose);
- return dialog.ShowDialog(owner) == DialogResult.OK;
- }
-
- public static bool TryEditAccount(IWin32Window owner, LaunchAccountProfile profile)
- {
- using var dialog = CreateEditorDialog("Account Profile", 520, 300);
- var accountBox = CreateTextBox(profile.AccountName);
- var passwordBox = CreateTextBox(profile.Password);
- passwordBox.UseSystemPasswordChar = true;
- var characterBox = CreateTextBox(profile.CharacterName);
- var aliasBox = CreateTextBox(profile.Alias);
-
- var body = CreateFormLayout();
- body.Controls.Add(CreateLabeledRow("Account", accountBox), 0, 0);
- body.Controls.Add(CreateLabeledRow("Password", passwordBox), 0, 1);
- body.Controls.Add(CreateLabeledRow("Character / Slot", characterBox), 0, 2);
- body.Controls.Add(CreateLabeledRow("Alias (Optional)", aliasBox), 0, 3);
- dialog.Controls.Add(body);
-
- void SaveAndClose(object? _, EventArgs __)
- {
- if (string.IsNullOrWhiteSpace(accountBox.Text))
- {
- ShowValidation(dialog, "Account name is required.");
- return;
- }
-
- profile.AccountName = accountBox.Text.Trim();
- profile.Password = passwordBox.Text;
- profile.CharacterName = characterBox.Text.Trim();
- profile.Alias = aliasBox.Text.Trim();
-
- dialog.DialogResult = DialogResult.OK;
- dialog.Close();
- }
-
- WireDialogButtons(dialog, SaveAndClose);
- return dialog.ShowDialog(owner) == DialogResult.OK;
- }
-
- private static Form CreateEditorDialog(string title, int width, int height)
- {
- return new Form
- {
- Text = title,
- FormBorderStyle = FormBorderStyle.FixedDialog,
- StartPosition = FormStartPosition.CenterParent,
- MinimizeBox = false,
- MaximizeBox = false,
- ShowInTaskbar = false,
- Width = width,
- Height = height,
- BackColor = Color.FromArgb(20, 28, 36),
- ForeColor = Color.White
- };
- }
-
- private static TableLayoutPanel CreateFormLayout()
- {
- return new TableLayoutPanel
- {
- Dock = DockStyle.Fill,
- ColumnCount = 1,
- RowCount = 6,
- Padding = new Padding(14, 14, 14, 56),
- AutoSize = false
- };
- }
-
- private static Panel CreateLabeledRow(string labelText, Control editor)
- {
- var panel = new Panel
- {
- Dock = DockStyle.Top,
- Height = 54
- };
-
- var label = new Label
- {
- Text = labelText,
- AutoSize = true,
- ForeColor = Color.Gainsboro,
- Location = new Point(0, 2)
- };
-
- editor.Location = new Point(0, 22);
- editor.Width = 458;
- panel.Controls.Add(label);
- panel.Controls.Add(editor);
- return panel;
- }
-
- private static TextBox CreateTextBox(string value)
- {
- return new TextBox
- {
- Text = value,
- BorderStyle = BorderStyle.FixedSingle,
- BackColor = Color.FromArgb(15, 22, 30),
- ForeColor = Color.White
- };
- }
-
- private static ComboBox CreateComboBox()
- {
- return new ComboBox
- {
- DropDownStyle = ComboBoxStyle.DropDownList,
- BackColor = Color.FromArgb(15, 22, 30),
- ForeColor = Color.White,
- FlatStyle = FlatStyle.Flat
- };
- }
-
- private static void WireDialogButtons(Form dialog, EventHandler saveHandler)
- {
- var okButton = new Button
- {
- Text = "Save",
- Width = 96,
- Height = 34,
- Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
- Location = new Point(dialog.ClientSize.Width - 214, dialog.ClientSize.Height - 46),
- DialogResult = DialogResult.None
- };
- okButton.Click += saveHandler;
-
- var cancelButton = new Button
- {
- Text = "Cancel",
- Width = 96,
- Height = 34,
- Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
- Location = new Point(dialog.ClientSize.Width - 108, dialog.ClientSize.Height - 46),
- DialogResult = DialogResult.Cancel
- };
-
- dialog.AcceptButton = okButton;
- dialog.CancelButton = cancelButton;
- dialog.Controls.Add(okButton);
- dialog.Controls.Add(cancelButton);
- }
-
- private static void ShowValidation(IWin32Window owner, string message)
- {
- MessageBox.Show(owner, message, "Incomplete Profile", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
-}
diff --git a/src/RynthCore.App/MainForm.cs b/src/RynthCore.App/MainForm.cs
deleted file mode 100644
index 30a7205..0000000
--- a/src/RynthCore.App/MainForm.cs
+++ /dev/null
@@ -1,1869 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Drawing;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using RynthCore.Injector;
-
-namespace RynthCore.App;
-
-internal sealed class MainForm : Form
-{
- private const int WsExComposited = 0x02000000;
- private const string LauncherTabId = "launcher";
- private const string RuntimeTabId = "runtime";
- private static readonly Color AppBack = Color.FromArgb(12, 18, 24);
- private static readonly Color PanelBack = Color.FromArgb(20, 28, 36);
- private static readonly Color PanelAlt = Color.FromArgb(15, 22, 30);
- private static readonly Color Border = Color.FromArgb(44, 58, 70);
- private static readonly Color Accent = Color.FromArgb(42, 193, 166);
- private static readonly Color Gold = Color.FromArgb(226, 179, 72);
- private static readonly Color TextPrimary = Color.FromArgb(234, 240, 244);
- private static readonly Color TextMuted = Color.FromArgb(154, 168, 179);
- private static readonly Color Good = Color.FromArgb(102, 214, 135);
-
- private readonly EngineInjectionService _injector = new();
- private readonly AcClientLaunchSettingsService _launchSettings = new();
- private readonly AcLaunchArgumentBuilder _launchArgumentBuilder = new();
- private readonly AcClientLoginAutomationService _loginAutomation = new();
- private readonly List _plugins =
- [
- new PluginDefinition
- {
- Id = "rynthcore-engine",
- Name = "RynthCore Engine",
- Summary = "Injects the in-process runtime and overlay host into acclient.exe.",
- StatusText = "Implemented now",
- RuntimeImplemented = true
- },
- new PluginDefinition
- {
- Id = "nexai",
- Name = "RynthAi",
- Summary = "Adoption target from RynthSuite. Selection is saved now so the desktop host becomes the future loadout surface.",
- StatusText = "Planned adoption",
- RuntimeImplemented = false
- }
- ];
-
- private readonly Dictionary _pluginChecks = [];
- private readonly HashSet _injectedPids = [];
- private readonly HashSet _pendingInjectionPids = [];
- private readonly HashSet _autoInjectFailedPids = [];
- private readonly object _injectionStateLock = new();
- private readonly object _activityLock = new();
- private readonly System.Windows.Forms.Timer _watchTimer = new() { Interval = 1500 };
- private readonly System.Windows.Forms.Timer _activityFlushTimer = new() { Interval = 120 };
- private readonly Queue _pendingActivityLines = new();
-
- private AppSettings _settings = new();
- private bool _loadingUiState;
- private bool _rebindingLaunchAccountChecklist;
- private bool _watchTickBusy;
- private bool _operationBusy;
-
- private readonly TextBox _acPathTextBox = CreateTextBox();
- private readonly TextBox _enginePathTextBox = CreateTextBox();
- private readonly TextBox _launchArgsTextBox = CreateTextBox();
- private readonly ComboBox _serverComboBox = CreateComboBox();
- private readonly ComboBox _accountComboBox = CreateComboBox();
- private readonly CheckedListBox _launchAccountsCheckedList = CreateCheckedListBox();
- private readonly CheckBox _autoInjectCheckBox = CreateCheckBox("Auto Inject");
- private readonly CheckBox _allowMultipleClientsCheckBox = CreateCheckBox("Allow Multiple Clients");
- private readonly CheckBox _skipIntroVideosCheckBox = CreateCheckBox("Skip Intro Videos");
- private readonly CheckBox _skipLoginLogosCheckBox = CreateCheckBox("Skip Login Logos");
- private readonly Label _statusValueLabel = CreateValueLabel();
- private readonly Label _selectedValueLabel = CreateValueLabel();
- private readonly Label _launchProfileValueLabel = CreateValueLabel();
- private readonly Label _hotReloadValueLabel = CreateValueLabel();
- private readonly ListBox _activityListBox = CreateActivityListBox();
- private readonly TabControl _mainTabs = CreateMainTabs();
-
- private readonly Button _launchButton = CreateAccentButton("Launch");
- private readonly Button _injectButton = CreateActionButton("Inject RynthCore");
-
- protected override CreateParams CreateParams
- {
- get
- {
- CreateParams cp = base.CreateParams;
- cp.ExStyle |= WsExComposited;
- return cp;
- }
- }
-
- public MainForm()
- {
- Text = "RynthCore";
- StartPosition = FormStartPosition.CenterScreen;
- MinimumSize = new Size(1100, 720);
- ClientSize = new Size(1240, 820);
- BackColor = AppBack;
- ForeColor = TextPrimary;
- Font = new Font("Segoe UI", 10f, FontStyle.Regular, GraphicsUnit.Point);
- Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
- DoubleBuffered = true;
- SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
- UpdateStyles();
-
- BuildLayout();
- LoadSettingsIntoUi();
-
- _watchTimer.Tick += WatchTimer_Tick;
- _watchTimer.Start();
- _activityFlushTimer.Tick += (_, _) => FlushPendingActivity();
- _activityFlushTimer.Start();
-
- _launchButton.Click += async (_, _) => await LaunchAcAsync(injectAfterLaunch: _autoInjectCheckBox.Checked);
- _injectButton.Click += async (_, _) => await InjectIntoRunningAcAsync();
- _autoInjectCheckBox.CheckedChanged += (_, _) =>
- {
- SaveUiState();
- UpdateStatusSummary();
- };
- _launchArgsTextBox.TextChanged += (_, _) =>
- {
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- };
- _serverComboBox.SelectedIndexChanged += (_, _) =>
- {
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- };
- _accountComboBox.SelectedIndexChanged += (_, _) =>
- {
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- };
- _launchAccountsCheckedList.ItemCheck += (_, _) =>
- {
- if (_rebindingLaunchAccountChecklist)
- return;
-
- BeginInvoke(new Action(() =>
- {
- SaveUiState();
- UpdateStatusSummary();
- }));
- };
- _mainTabs.SelectedIndexChanged += (_, _) => SaveUiState();
- _allowMultipleClientsCheckBox.CheckedChanged += (_, _) => SaveAndApplyLaunchSettings();
- _skipIntroVideosCheckBox.CheckedChanged += (_, _) => SaveAndApplyLaunchSettings();
- _skipLoginLogosCheckBox.CheckedChanged += (_, _) => SaveUiState();
- FormClosing += (_, _) => SaveUiState();
-
- UpdateStatusSummary();
- AppendActivity("Desktop host ready.");
- }
-
- private void BuildLayout()
- {
- var root = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Fill,
- BackColor = AppBack,
- ColumnCount = 1,
- RowCount = 2,
- Padding = new Padding(18)
- };
- root.RowStyles.Add(new RowStyle(SizeType.Absolute, 136f));
- root.RowStyles.Add(new RowStyle(SizeType.Percent, 100f));
- Controls.Add(root);
-
- root.Controls.Add(BuildHeroPanel(), 0, 0);
- root.Controls.Add(BuildContentPanel(), 0, 1);
- }
-
- private Control BuildHeroPanel()
- {
- var hero = new BufferedPanel
- {
- Dock = DockStyle.Fill,
- BackColor = PanelBack,
- Padding = new Padding(18),
- Margin = new Padding(0, 0, 0, 14)
- };
- hero.Paint += DrawPanelBorder;
-
- var heroLayout = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Fill,
- BackColor = PanelBack,
- ColumnCount = 2,
- RowCount = 1,
- Margin = new Padding(0),
- Padding = new Padding(0)
- };
- heroLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f));
- heroLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 240f));
-
- var copyPanel = new BufferedFlowLayoutPanel
- {
- Dock = DockStyle.Fill,
- BackColor = PanelBack,
- FlowDirection = FlowDirection.TopDown,
- AutoSize = false,
- WrapContents = false,
- Margin = new Padding(0),
- Padding = new Padding(0)
- };
-
- var title = new Label
- {
- Text = "RYNTHCORE DESKTOP HOST",
- ForeColor = Accent,
- Font = new Font("Segoe UI Semibold", 22f, FontStyle.Bold),
- AutoSize = true,
- Margin = new Padding(14, 10, 0, 0)
- };
-
- var subtitle = new Label
- {
- Text = "Launcher first: pick a server, choose the character/account slots you want, and start Asheron's Call from RynthCore. Runtime paths and advanced settings live in the secondary tab.",
- ForeColor = TextPrimary,
- AutoSize = true,
- MaximumSize = new Size(760, 0),
- Margin = new Padding(16, 6, 0, 0)
- };
-
- var note = new Label
- {
- Text = "Launch is now the default path. Runtime keeps the paths, toggles, and manual injection action for recovery cases, while normal play starts here with RynthCore already in the process.",
- ForeColor = TextMuted,
- AutoSize = true,
- MaximumSize = new Size(760, 0),
- Margin = new Padding(16, 6, 0, 0)
- };
-
- var actionHost = new BufferedPanel
- {
- Dock = DockStyle.Fill,
- BackColor = PanelBack,
- Margin = new Padding(0),
- Padding = new Padding(0)
- };
-
- _launchButton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
- _launchButton.Width = 184;
- _launchButton.Height = 42;
- _launchButton.Location = new Point(32, 18);
-
- var launchNote = new Label
- {
- Text = "Launch uses the selected server and checked targets, then injects RynthCore before AC gets moving.",
- ForeColor = TextMuted,
- AutoSize = false,
- Size = new Size(184, 50),
- Location = new Point(32, 68),
- TextAlign = ContentAlignment.TopRight
- };
-
- copyPanel.Controls.Add(title);
- copyPanel.Controls.Add(subtitle);
- copyPanel.Controls.Add(note);
- actionHost.Controls.Add(_launchButton);
- actionHost.Controls.Add(launchNote);
- heroLayout.Controls.Add(copyPanel, 0, 0);
- heroLayout.Controls.Add(actionHost, 1, 0);
- hero.Controls.Add(heroLayout);
- return hero;
- }
-
- private Control BuildContentPanel()
- {
- var launcherPage = CreateTabPage("Launcher");
- launcherPage.Tag = LauncherTabId;
- launcherPage.Controls.Add(CreateScrollHost(BuildLauncherColumn()));
-
- var runtimePage = CreateTabPage("Runtime");
- runtimePage.Tag = RuntimeTabId;
- runtimePage.Controls.Add(CreateScrollHost(BuildRuntimeColumn()));
-
- _mainTabs.TabPages.Add(launcherPage);
- _mainTabs.TabPages.Add(runtimePage);
- return _mainTabs;
- }
-
- private Control BuildLauncherColumn()
- {
- var host = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = AppBack,
- ColumnCount = 1,
- RowCount = 3,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- Margin = new Padding(0)
- };
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
-
- host.Controls.Add(BuildLaunchProfilesPanel(), 0, 0);
- host.Controls.Add(BuildSessionPanel(), 0, 1);
- host.Controls.Add(BuildActivityPanel(), 0, 2);
- return host;
- }
-
- private Control BuildRuntimeColumn()
- {
- var host = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = AppBack,
- ColumnCount = 1,
- RowCount = 2,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- Margin = new Padding(0)
- };
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
-
- host.Controls.Add(BuildPathsPanel(), 0, 0);
- host.Controls.Add(BuildPluginColumn(), 0, 1);
- return host;
- }
-
- private Control BuildPluginColumn()
- {
- var host = CreateSectionPanel();
- host.Dock = DockStyle.Top;
- host.AutoSize = true;
- host.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- host.Margin = new Padding(10, 0, 0, 0);
-
- var layout = CreateSectionLayout(5);
- host.Controls.Add(layout);
-
- layout.Controls.Add(CreateSectionTitle("Runtime Loadout"), 0, 0);
- layout.Controls.Add(CreateSectionBody("These runtime selections are still saved and applied when you launch from RynthCore, but they now live behind the secondary tab so the launcher can stay front and center."), 0, 1);
-
- var pluginFlow = new BufferedFlowLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = PanelBack,
- FlowDirection = FlowDirection.TopDown,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- WrapContents = false,
- Padding = new Padding(0, 8, 0, 0)
- };
-
- foreach (PluginDefinition plugin in _plugins)
- pluginFlow.Controls.Add(CreatePluginCard(plugin));
-
- layout.Controls.Add(pluginFlow, 0, 2);
-
- var footer = CreateFooterLabel("Selections are persisted in AppData so RynthCore can reopen with your preferred runtime loadout.");
- layout.Controls.Add(footer, 0, 3);
-
- return host;
- }
-
- private Control BuildHostColumn()
- {
- var host = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = AppBack,
- ColumnCount = 1,
- RowCount = 4,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- Margin = new Padding(0)
- };
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- host.RowStyles.Add(new RowStyle(SizeType.AutoSize));
-
- host.Controls.Add(BuildPathsPanel(), 0, 0);
- host.Controls.Add(BuildLaunchProfilesPanel(), 0, 1);
- host.Controls.Add(BuildSessionPanel(), 0, 2);
- host.Controls.Add(BuildActivityPanel(), 0, 3);
- return host;
- }
-
- private Control BuildPathsPanel()
- {
- var panel = CreateSectionPanel();
- panel.Dock = DockStyle.Top;
- panel.AutoSize = true;
- panel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- panel.Margin = new Padding(10, 0, 0, 10);
-
- var layout = CreateSectionLayout(8);
- panel.Controls.Add(layout);
-
- layout.Controls.Add(CreateSectionTitle("Runtime Settings"), 0, 0);
- layout.Controls.Add(CreateSectionBody("These are the settings you rarely need to touch: client path, engine path, manual argument override, and the runtime behavior flags that RynthCore applies before launch."), 0, 1);
-
- layout.Controls.Add(CreateFieldRow("Asheron's Call", _acPathTextBox, BrowseForAcClient), 0, 2);
- layout.Controls.Add(CreateFieldRow("RynthCore Engine", _enginePathTextBox, BrowseForEngineDll), 0, 3);
- layout.Controls.Add(CreateFieldRow("Arguments Override (Optional)", _launchArgsTextBox, null), 0, 4);
-
- var optionsRow = new BufferedFlowLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = PanelBack,
- FlowDirection = FlowDirection.TopDown,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- WrapContents = false,
- Margin = new Padding(0, 8, 0, 0)
- };
- optionsRow.Controls.Add(_autoInjectCheckBox);
- optionsRow.Controls.Add(CreateSectionBody("Launch from RynthCore already injects early. Auto Inject only matters for AC sessions that appear outside the launcher."));
- optionsRow.Controls.Add(_allowMultipleClientsCheckBox);
- optionsRow.Controls.Add(CreateSectionBody("Writes ComputeUniquePort=True into Documents\\Asheron's Call\\UserPreferences.ini and, for RynthCore-launched sessions, patches AC's already-running gate before startup."));
- optionsRow.Controls.Add(_skipIntroVideosCheckBox);
- optionsRow.Controls.Add(CreateSectionBody("Parks turbine_logo_ac.avi in the AC install folder so launches skip the intro movie. Turn it off to restore the file."));
- optionsRow.Controls.Add(_skipLoginLogosCheckBox);
- optionsRow.Controls.Add(CreateSectionBody("For RynthCore-launched sessions, sends the same early login-screen clicks that Decal-style launchers use to bypass the logo screens after the client window appears."));
- layout.Controls.Add(optionsRow, 0, 5);
-
- layout.Controls.Add(CreateRuntimeActionRow(), 0, 6);
- layout.Controls.Add(CreateFooterLabel("The launcher tab is the normal entry point now. Come back here only when you need to change engine paths, toggles, recovery actions, or the advanced override."), 0, 7);
-
- return panel;
- }
-
- private Control BuildLaunchProfilesPanel()
- {
- var panel = CreateSectionPanel();
- panel.Dock = DockStyle.Top;
- panel.AutoSize = true;
- panel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- panel.Margin = new Padding(10, 0, 0, 10);
-
- var layout = CreateSectionLayout(8);
- panel.Controls.Add(layout);
-
- layout.Controls.Add(CreateSectionTitle("Launcher"), 0, 0);
- layout.Controls.Add(CreateSectionBody("Pick a server and the launch targets you want. RynthCore will build the emulator-specific command line, launch suspended, and apply the runtime before AC gets to its single-instance checks."), 0, 1);
- layout.Controls.Add(CreateProfileSelectorRow("Server", _serverComboBox, AddServerProfile, EditSelectedServerProfile, DeleteSelectedServerProfile), 0, 2);
- layout.Controls.Add(CreateProfileSelectorRow("Primary Target", _accountComboBox, AddAccountProfile, EditSelectedAccountProfile, DeleteSelectedAccountProfile), 0, 3);
- layout.Controls.Add(CreateSectionBody("These profiles can act like remembered character slots. Give them a character or slot label, check the ones you want to start, and RynthCore will remember that launch set the next time you open the launcher."), 0, 4);
- layout.Controls.Add(CreateCheckedListRow("Launch Targets", _launchAccountsCheckedList), 0, 5);
- layout.Controls.Add(CreateFooterLabel("The checked launch targets are persisted in AppData so you can reopen RynthCore and hit Launch again without rebuilding the list."), 0, 6);
-
- return panel;
- }
-
- private Control BuildSessionPanel()
- {
- var panel = CreateSectionPanel();
- panel.Dock = DockStyle.Top;
- panel.AutoSize = true;
- panel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- panel.Margin = new Padding(10, 0, 0, 10);
-
- var layout = CreateSectionLayout(2);
- panel.Controls.Add(layout);
-
- layout.Controls.Add(CreateSectionTitle("Session State"), 0, 0);
-
- var stateGrid = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = PanelBack,
- ColumnCount = 2,
- RowCount = 4,
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink,
- Margin = new Padding(0, 6, 0, 0)
- };
- stateGrid.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 190f));
- stateGrid.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100f));
-
- AddStateRow(stateGrid, 0, "AC Status", _statusValueLabel);
- AddStateRow(stateGrid, 1, "Selected Loadout", _selectedValueLabel);
- AddStateRow(stateGrid, 2, "Launch Profile", _launchProfileValueLabel);
- AddStateRow(stateGrid, 3, "Hot Reload Path", _hotReloadValueLabel);
-
- layout.Controls.Add(stateGrid, 0, 1);
- return panel;
- }
-
- private Control BuildActivityPanel()
- {
- var panel = CreateSectionPanel();
- panel.Dock = DockStyle.Top;
- panel.AutoSize = true;
- panel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
- panel.Margin = new Padding(10, 0, 0, 0);
-
- var layout = CreateSectionLayout(3);
- panel.Controls.Add(layout);
-
- _activityListBox.Dock = DockStyle.Top;
- _activityListBox.Height = 280;
-
- layout.Controls.Add(CreateSectionTitle("Activity"), 0, 0);
- layout.Controls.Add(CreateSectionBody("Runtime decisions, launch actions, injection output, and future plugin-host events surface here."), 0, 1);
- layout.Controls.Add(_activityListBox, 0, 2);
-
- return panel;
- }
-
- private Panel CreatePluginCard(PluginDefinition plugin)
- {
- var card = new BufferedPanel
- {
- Width = 420,
- Height = 124,
- BackColor = PanelAlt,
- Margin = new Padding(0, 0, 0, 10),
- Padding = new Padding(14)
- };
- card.Paint += DrawPanelBorder;
-
- var checkBox = CreateCheckBox(plugin.Name);
- checkBox.Font = new Font("Segoe UI Semibold", 11f, FontStyle.Bold);
- checkBox.Location = new Point(12, 10);
- checkBox.CheckedChanged += (_, _) =>
- {
- UpdateStatusSummary();
- SaveUiState();
- };
-
- var badge = new Label
- {
- Text = plugin.StatusText.ToUpperInvariant(),
- ForeColor = plugin.RuntimeImplemented ? Good : Gold,
- AutoSize = true,
- Location = new Point(16, 42),
- Font = new Font("Segoe UI", 8.5f, FontStyle.Bold)
- };
-
- var summary = new Label
- {
- Text = plugin.Summary,
- ForeColor = TextMuted,
- AutoSize = true,
- MaximumSize = new Size(370, 0),
- Location = new Point(16, 66)
- };
-
- card.Controls.Add(checkBox);
- card.Controls.Add(badge);
- card.Controls.Add(summary);
-
- _pluginChecks[plugin.Id] = checkBox;
- return card;
- }
-
- private void AddServerProfile()
- {
- var draft = new LaunchServerProfile();
- if (!LaunchProfileDialogs.TryEditServer(this, draft))
- return;
-
- _settings.ServerProfiles.Add(draft);
- _settings.SelectedServerProfileId = draft.Id;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Saved server profile '{draft.DisplayName}'.");
- }
-
- private void EditSelectedServerProfile()
- {
- LaunchServerProfile? selected = GetSelectedServerProfile();
- if (selected == null)
- {
- AppendActivity("Select a server profile first.");
- return;
- }
-
- var draft = selected.Clone();
- if (!LaunchProfileDialogs.TryEditServer(this, draft))
- return;
-
- selected.CopyFrom(draft);
- _settings.SelectedServerProfileId = selected.Id;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Updated server profile '{selected.DisplayName}'.");
- }
-
- private void DeleteSelectedServerProfile()
- {
- LaunchServerProfile? selected = GetSelectedServerProfile();
- if (selected == null)
- {
- AppendActivity("Select a server profile first.");
- return;
- }
-
- if (MessageBox.Show(
- this,
- $"Delete server profile '{selected.DisplayName}'?",
- "Delete Server Profile",
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
-
- _settings.ServerProfiles.RemoveAll(profile => string.Equals(profile.Id, selected.Id, StringComparison.OrdinalIgnoreCase));
- _settings.SelectedServerProfileId = _settings.ServerProfiles.FirstOrDefault()?.Id ?? string.Empty;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Deleted server profile '{selected.DisplayName}'.");
- }
-
- private void AddAccountProfile()
- {
- var draft = new LaunchAccountProfile();
- if (!LaunchProfileDialogs.TryEditAccount(this, draft))
- return;
-
- _settings.AccountProfiles.Add(draft);
- _settings.SelectedAccountProfileId = draft.Id;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Saved account profile '{draft.DisplayName}'.");
- }
-
- private void EditSelectedAccountProfile()
- {
- LaunchAccountProfile? selected = GetSelectedAccountProfile();
- if (selected == null)
- {
- AppendActivity("Select an account profile first.");
- return;
- }
-
- var draft = selected.Clone();
- if (!LaunchProfileDialogs.TryEditAccount(this, draft))
- return;
-
- selected.CopyFrom(draft);
- _settings.SelectedAccountProfileId = selected.Id;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Updated account profile '{selected.DisplayName}'.");
- }
-
- private void DeleteSelectedAccountProfile()
- {
- LaunchAccountProfile? selected = GetSelectedAccountProfile();
- if (selected == null)
- {
- AppendActivity("Select an account profile first.");
- return;
- }
-
- if (MessageBox.Show(
- this,
- $"Delete account profile '{selected.DisplayName}'?",
- "Delete Account Profile",
- MessageBoxButtons.YesNo,
- MessageBoxIcon.Question) != DialogResult.Yes)
- {
- return;
- }
-
- _settings.AccountProfiles.RemoveAll(profile => string.Equals(profile.Id, selected.Id, StringComparison.OrdinalIgnoreCase));
- _settings.SelectedAccountProfileId = _settings.AccountProfiles.FirstOrDefault()?.Id ?? string.Empty;
- RebindLaunchProfiles();
- SaveUiState();
- UpdateLaunchPreview();
- UpdateStatusSummary();
- AppendActivity($"Deleted account profile '{selected.DisplayName}'.");
- }
-
- private void RebindLaunchProfiles()
- {
- _serverComboBox.DisplayMember = nameof(LaunchServerProfile.DisplayName);
- _serverComboBox.ValueMember = nameof(LaunchServerProfile.Id);
- _serverComboBox.DataSource = null;
- _serverComboBox.DataSource = _settings.ServerProfiles;
-
- _accountComboBox.DisplayMember = nameof(LaunchAccountProfile.DisplayName);
- _accountComboBox.ValueMember = nameof(LaunchAccountProfile.Id);
- _accountComboBox.DataSource = null;
- _accountComboBox.DataSource = _settings.AccountProfiles;
-
- SelectComboValue(_serverComboBox, _settings.SelectedServerProfileId);
- SelectComboValue(_accountComboBox, _settings.SelectedAccountProfileId);
-
- RebindLaunchAccountChecklist();
- }
-
- private void RebindLaunchAccountChecklist()
- {
- var validIds = _settings.AccountProfiles
- .Select(account => account.Id)
- .ToHashSet(StringComparer.OrdinalIgnoreCase);
-
- _settings.CheckedLaunchAccountProfileIds = _settings.CheckedLaunchAccountProfileIds
- .Where(id => validIds.Contains(id))
- .Distinct(StringComparer.OrdinalIgnoreCase)
- .ToList();
-
- _rebindingLaunchAccountChecklist = true;
- _launchAccountsCheckedList.BeginUpdate();
- try
- {
- _launchAccountsCheckedList.Items.Clear();
- foreach (LaunchAccountProfile account in _settings.AccountProfiles)
- {
- bool isChecked = _settings.CheckedLaunchAccountProfileIds.Contains(account.Id, StringComparer.OrdinalIgnoreCase);
- _launchAccountsCheckedList.Items.Add(account, isChecked);
- }
- }
- finally
- {
- _launchAccountsCheckedList.EndUpdate();
- _rebindingLaunchAccountChecklist = false;
- }
- }
-
- private static void SelectComboValue(ComboBox comboBox, string selectedId)
- {
- if (comboBox.Items.Count == 0)
- return;
-
- if (string.IsNullOrWhiteSpace(selectedId))
- {
- comboBox.SelectedIndex = 0;
- return;
- }
-
- comboBox.SelectedValue = selectedId;
- if (comboBox.SelectedIndex < 0)
- comboBox.SelectedIndex = 0;
- }
-
- private LaunchServerProfile? GetSelectedServerProfile()
- {
- return _serverComboBox.SelectedItem as LaunchServerProfile;
- }
-
- private LaunchAccountProfile? GetSelectedAccountProfile()
- {
- return _accountComboBox.SelectedItem as LaunchAccountProfile;
- }
-
- private List GetCheckedLaunchAccounts()
- {
- return _launchAccountsCheckedList.CheckedItems
- .OfType()
- .ToList();
- }
-
- private List GetAccountsToLaunch()
- {
- List checkedAccounts = GetCheckedLaunchAccounts();
- if (checkedAccounts.Count > 0)
- return checkedAccounts;
-
- LaunchAccountProfile? selected = GetSelectedAccountProfile();
- return selected == null ? [] : [selected];
- }
-
- private bool TryGetEffectiveLaunchArguments(out string arguments, out string launchSummary, out string error)
- {
- LaunchAccountProfile? account = GetSelectedAccountProfile();
- if (account == null)
- {
- arguments = string.Empty;
- launchSummary = string.Empty;
- error = "Select an account profile, or create one first.";
- return false;
- }
-
- return TryGetLaunchArgumentsForAccount(account, out arguments, out launchSummary, out error);
- }
-
- private bool TryGetLaunchArgumentsForAccount(LaunchAccountProfile account, out string arguments, out string launchSummary, out string error)
- {
- string overrideArguments = _launchArgsTextBox.Text.Trim();
- if (!string.IsNullOrWhiteSpace(overrideArguments))
- {
- arguments = overrideArguments;
- launchSummary = string.IsNullOrWhiteSpace(account.DisplayName)
- ? "Manual argument override"
- : $"Manual argument override / {account.DisplayName}";
- error = string.Empty;
- return true;
- }
-
- LaunchServerProfile? server = GetSelectedServerProfile();
- if (server == null)
- {
- arguments = string.Empty;
- launchSummary = string.Empty;
- error = "Select a server profile, or enter a manual arguments override.";
- return false;
- }
-
- try
- {
- arguments = _launchArgumentBuilder.BuildArguments(server, account);
- launchSummary = _launchArgumentBuilder.Describe(server, account);
- error = string.Empty;
- return true;
- }
- catch (Exception ex)
- {
- arguments = string.Empty;
- launchSummary = string.Empty;
- error = ex.Message;
- return false;
- }
- }
-
- private void UpdateLaunchPreview()
- {
- LaunchServerProfile? selectedServer = GetSelectedServerProfile();
- if (selectedServer != null)
- _settings.SelectedServerProfileId = selectedServer.Id;
-
- LaunchAccountProfile? selectedAccount = GetSelectedAccountProfile();
- if (selectedAccount != null)
- _settings.SelectedAccountProfileId = selectedAccount.Id;
-
- if (TryGetEffectiveLaunchArguments(out string arguments, out string summary, out _))
- {
- if (!string.IsNullOrWhiteSpace(summary))
- _launchProfileValueLabel.Text = summary;
- }
- }
-
- private void LoadSettingsIntoUi()
- {
- _loadingUiState = true;
- _settings = AppSettingsStore.Load();
- _settings.ServerProfiles ??= [];
- _settings.AccountProfiles ??= [];
- _settings.CheckedLaunchAccountProfileIds ??= [];
- _settings.SelectedMainTabId = string.IsNullOrWhiteSpace(_settings.SelectedMainTabId)
- ? LauncherTabId
- : _settings.SelectedMainTabId;
-
- _acPathTextBox.Text = _settings.AcClientPath;
- _enginePathTextBox.Text = !string.IsNullOrWhiteSpace(_settings.EnginePath)
- ? _settings.EnginePath
- : _injector.TryResolveEnginePath(null) ?? string.Empty;
- _launchArgsTextBox.Text = _settings.LaunchArguments;
- _allowMultipleClientsCheckBox.Checked = _settings.AllowMultipleClients;
- _skipIntroVideosCheckBox.Checked = _settings.SkipIntroVideos;
- _skipLoginLogosCheckBox.Checked = _settings.SkipLoginLogos;
- _autoInjectCheckBox.Checked = _settings.AutoInjectAfterLaunch || _settings.WatchForAcStart;
-
- foreach ((string pluginId, CheckBox checkBox) in _pluginChecks)
- checkBox.Checked = _settings.EnabledPluginIds.Contains(pluginId, StringComparer.OrdinalIgnoreCase);
-
- if (!_pluginChecks.Values.Any(cb => cb.Checked) && _pluginChecks.TryGetValue("rynthcore-engine", out CheckBox? engineCheck))
- engineCheck.Checked = true;
-
- RebindLaunchProfiles();
- UpdateLaunchPreview();
- SelectMainTab(_settings.SelectedMainTabId);
- _loadingUiState = false;
- }
-
- private void SaveUiState()
- {
- if (_loadingUiState)
- return;
-
- _settings.AcClientPath = _acPathTextBox.Text.Trim();
- _settings.EnginePath = _enginePathTextBox.Text.Trim();
- _settings.LaunchArguments = _launchArgsTextBox.Text.Trim();
- _settings.SelectedServerProfileId = GetSelectedServerProfile()?.Id ?? _settings.SelectedServerProfileId;
- _settings.SelectedAccountProfileId = GetSelectedAccountProfile()?.Id ?? _settings.SelectedAccountProfileId;
- _settings.CheckedLaunchAccountProfileIds = GetCheckedLaunchAccounts().Select(profile => profile.Id).ToList();
- _settings.SelectedMainTabId = GetSelectedMainTabId();
- _settings.AllowMultipleClients = _allowMultipleClientsCheckBox.Checked;
- _settings.SkipIntroVideos = _skipIntroVideosCheckBox.Checked;
- _settings.SkipLoginLogos = _skipLoginLogosCheckBox.Checked;
- _settings.AutoInjectAfterLaunch = _autoInjectCheckBox.Checked;
- _settings.WatchForAcStart = _autoInjectCheckBox.Checked;
- _settings.EnabledPluginIds = GetSelectedPluginIds().ToList();
- AppSettingsStore.Save(_settings);
- }
-
- private async Task LaunchAcAsync(bool injectAfterLaunch)
- {
- if (_operationBusy)
- return;
-
- string acPath = _acPathTextBox.Text.Trim();
- if (string.IsNullOrWhiteSpace(acPath) || !File.Exists(acPath))
- {
- AppendActivity("Asheron's Call path is missing or invalid.");
- return;
- }
-
- List accountsToLaunch = GetAccountsToLaunch();
- if (accountsToLaunch.Count == 0)
- {
- AppendActivity("Launch blocked: choose or check at least one account profile.");
- return;
- }
-
- if (!string.IsNullOrWhiteSpace(_launchArgsTextBox.Text.Trim()) && accountsToLaunch.Count > 1)
- {
- AppendActivity("Launch blocked: manual argument override can only be used for one account at a time.");
- return;
- }
-
- if (!TryGetLaunchArgumentsForAccount(accountsToLaunch[0], out _, out string firstLaunchSummary, out string launchError))
- {
- AppendActivity($"Launch blocked: {launchError}");
- return;
- }
-
- SaveUiState();
- ApplyLaunchSettings();
-
- try
- {
- SetOperationState(true);
- AppendActivity(accountsToLaunch.Count == 1
- ? $"Preparing AC launch using {firstLaunchSummary}."
- : $"Preparing {accountsToLaunch.Count} AC launches from the selected account checklist.");
-
- bool shouldInject = injectAfterLaunch || _autoInjectCheckBox.Checked;
-
- for (int i = 0; i < accountsToLaunch.Count; i++)
- {
- LaunchAccountProfile account = accountsToLaunch[i];
- if (!TryGetLaunchArgumentsForAccount(account, out string launchArguments, out string launchSummary, out string accountError))
- {
- AppendActivity($"Launch blocked for {account.DisplayName}: {accountError}");
- continue;
- }
-
- if (shouldInject)
- {
- string enginePath = _enginePathTextBox.Text.Trim();
- InjectionResult launchResult = await Task.Run(() =>
- _injector.LaunchSuspendedAndInject(
- acPath,
- launchArguments,
- enginePath,
- AppendActivity));
-
- if (launchResult.Success)
- {
- if (launchResult.ProcessId is int launchedPid)
- {
- lock (_injectionStateLock)
- _injectedPids.Add(launchedPid);
-
- AppendActivity($"Launch + inject complete for PID {launchedPid} using {launchSummary}.");
- QueueSkipLoginLogos(launchedPid);
- }
- else
- {
- AppendActivity($"Launch + inject completed using {launchSummary}, but no PID was reported.");
- }
- }
- else
- {
- AppendActivity($"Launch + inject failed for {launchSummary}: {launchResult.Summary}");
- }
- }
- else
- {
- try
- {
- var psi = new System.Diagnostics.ProcessStartInfo(acPath, launchArguments)
- {
- UseShellExecute = false
- };
- System.Diagnostics.Process.Start(psi);
- AppendActivity($"Launched AC (no injection) using {launchSummary}.");
- }
- catch (Exception launchEx)
- {
- AppendActivity($"Launch failed for {launchSummary}: {launchEx.Message}");
- }
- }
-
- if (i < accountsToLaunch.Count - 1)
- await Task.Delay(500);
- }
- }
- catch (Exception ex)
- {
- AppendActivity($"Launch failed: {ex.Message}");
- }
- finally
- {
- SetOperationState(false);
- UpdateStatusSummary();
- }
- }
-
- private async Task InjectIntoRunningAcAsync()
- {
- if (!GetSelectedPluginIds().Contains("rynthcore-engine", StringComparer.OrdinalIgnoreCase))
- {
- AppendActivity("Inject blocked: RynthCore Engine is not selected in Runtime Loadout.");
- UpdateStatusSummary();
- return;
- }
-
- Process[] targets = _injector.FindTargetProcesses();
- if (targets.Length == 0)
- {
- AppendActivity("No running acclient.exe process found.");
- UpdateStatusSummary();
- return;
- }
-
- await ApplySelectedLoadoutAsync(targets[0], "Applying selected loadout to running AC");
- }
-
- private void QueueSkipLoginLogos(int processId)
- {
- if (!_skipLoginLogosCheckBox.Checked)
- return;
-
- _ = _loginAutomation.TryBypassLoginLogosAsync(processId, AppendActivity);
- }
-
- private async Task ApplySelectedLoadoutAsync(Process targetProcess, string reason)
- {
- if (_operationBusy)
- return;
-
- string enginePath = _enginePathTextBox.Text.Trim();
- if (string.IsNullOrWhiteSpace(enginePath))
- enginePath = _injector.TryResolveEnginePath(null) ?? string.Empty;
-
- string[] selectedPluginIds = GetSelectedPluginIds().ToArray();
- if (selectedPluginIds.Length == 0)
- {
- AppendActivity("No plugins selected.");
- return;
- }
-
- SaveUiState();
- SetOperationState(true);
-
- try
- {
- AppendActivity(reason + $" (PID {targetProcess.Id}).");
-
- if (selectedPluginIds.Contains("nexai", StringComparer.OrdinalIgnoreCase))
- {
- AppendActivity("RynthAi is selected and saved in the loadout. Runtime adoption into RynthCore is not wired yet, so it is queued as a host-level intent.");
- }
-
- if (!selectedPluginIds.Contains("rynthcore-engine", StringComparer.OrdinalIgnoreCase))
- {
- AppendActivity("RynthCore Engine is not selected, so there is nothing injectable for this session yet.");
- return;
- }
-
- InjectionResult result = await Task.Run(() => _injector.InjectIntoProcess(targetProcess, enginePath, AppendActivity));
- if (result.Success)
- {
- lock (_injectionStateLock)
- _injectedPids.Add(targetProcess.Id);
-
- AppendActivity($"Injection complete for PID {targetProcess.Id}.");
- }
- else
- {
- AppendActivity($"Injection failed: {result.Summary}");
- }
- }
- catch (Exception ex)
- {
- AppendActivity($"Loadout apply failed: {ex.Message}");
- }
- finally
- {
- SetOperationState(false);
- UpdateStatusSummary();
- }
- }
-
- private void WatchTimer_Tick(object? sender, EventArgs e)
- {
- UpdateStatusSummary();
-
- if (_watchTickBusy || !_autoInjectCheckBox.Checked || _operationBusy)
- return;
-
- _watchTickBusy = true;
- try
- {
- Process[] processes = _injector.FindTargetProcesses();
- PruneInjectedPidCache(processes);
-
- Process? nextProcess = processes.FirstOrDefault(process => !IsHandledOrPending(process.Id));
- if (nextProcess == null)
- return;
-
- QueueAutoInject(nextProcess, "Detected a new AC session");
- }
- finally
- {
- _watchTickBusy = false;
- }
- }
-
- private void PruneInjectedPidCache(IEnumerable processes)
- {
- var activePids = processes.Select(p => p.Id).ToHashSet();
-
- lock (_injectionStateLock)
- {
- _injectedPids.RemoveWhere(pid => !activePids.Contains(pid));
- _pendingInjectionPids.RemoveWhere(pid => !activePids.Contains(pid));
- _autoInjectFailedPids.RemoveWhere(pid => !activePids.Contains(pid));
- }
- }
-
- private IEnumerable GetSelectedPluginIds()
- {
- return _pluginChecks
- .Where(pair => pair.Value.Checked)
- .Select(pair => pair.Key);
- }
-
- private void UpdateStatusSummary()
- {
- Process[] targets = _injector.FindTargetProcesses();
- SetLabelText(_statusValueLabel, targets.Length == 0
- ? "Waiting for acclient.exe"
- : $"{targets.Length} client session(s) detected");
-
- string[] selectedNames = _plugins
- .Where(plugin => _pluginChecks.TryGetValue(plugin.Id, out CheckBox? checkBox) && checkBox.Checked)
- .Select(plugin => plugin.Name)
- .ToArray();
-
- SetLabelText(_selectedValueLabel, selectedNames.Length == 0 ? "None" : string.Join(", ", selectedNames));
- SetLabelText(_launchProfileValueLabel, string.Join(", ", GetLaunchProfileParts()));
- SetLabelText(_hotReloadValueLabel, _autoInjectCheckBox.Checked
- ? "Launch always injects RynthCore. Auto Inject is also watching for AC sessions started outside the launcher"
- : "Launch always injects RynthCore. Auto Inject is off for AC sessions started outside the launcher");
- }
-
- private void SetOperationState(bool busy)
- {
- _operationBusy = busy;
- _launchButton.Enabled = !busy;
- _injectButton.Enabled = !busy;
- Cursor = busy ? Cursors.WaitCursor : Cursors.Default;
- }
-
- private void BrowseForAcClient()
- {
- using var dialog = new OpenFileDialog
- {
- Filter = "Asheron's Call Client|acclient.exe|Executable Files|*.exe|All Files|*.*",
- Title = "Select acclient.exe"
- };
-
- if (dialog.ShowDialog(this) != DialogResult.OK)
- return;
-
- _acPathTextBox.Text = dialog.FileName;
- SaveUiState();
- ApplyLaunchSettings();
- }
-
- private void BrowseForEngineDll()
- {
- using var dialog = new OpenFileDialog
- {
- Filter = "RynthCore Engine|RynthCore.Engine.dll|DLL Files|*.dll|All Files|*.*",
- Title = "Select RynthCore.Engine.dll"
- };
-
- if (dialog.ShowDialog(this) != DialogResult.OK)
- return;
-
- _enginePathTextBox.Text = dialog.FileName;
- SaveUiState();
- }
-
- private void AppendActivity(string message)
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(AppendActivity), message);
- return;
- }
-
- string line = $"[{DateTime.Now:HH:mm:ss}] {message}";
- lock (_activityLock)
- _pendingActivityLines.Enqueue(line);
- }
-
- private void FlushPendingActivity()
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(FlushPendingActivity));
- return;
- }
-
- string[] pending;
- lock (_activityLock)
- {
- if (_pendingActivityLines.Count == 0)
- return;
-
- pending = _pendingActivityLines.ToArray();
- _pendingActivityLines.Clear();
- }
-
- _activityListBox.BeginUpdate();
- try
- {
- _activityListBox.Items.AddRange(pending);
- while (_activityListBox.Items.Count > 500)
- _activityListBox.Items.RemoveAt(0);
-
- if (_activityListBox.Items.Count > 0)
- _activityListBox.TopIndex = _activityListBox.Items.Count - 1;
- }
- finally
- {
- _activityListBox.EndUpdate();
- }
- }
-
- private void QueueAutoInject(Process targetProcess, string reason)
- {
- bool shouldQueue;
- lock (_injectionStateLock)
- {
- shouldQueue =
- !_injectedPids.Contains(targetProcess.Id) &&
- !_autoInjectFailedPids.Contains(targetProcess.Id) &&
- _pendingInjectionPids.Add(targetProcess.Id);
- }
-
- if (!shouldQueue)
- return;
-
- AppendActivity($"Queued auto-inject for PID {targetProcess.Id}.");
-
- _ = Task.Run(async () =>
- {
- try
- {
- AppendActivity($"PID {targetProcess.Id}: injecting early so RynthCore can bootstrap against the real D3D9 device.");
-
- while (true)
- {
- targetProcess.Refresh();
- if (targetProcess.HasExited)
- {
- AppendActivity($"PID {targetProcess.Id}: AC exited before auto-inject could run.");
- return;
- }
-
- break;
- }
-
- while (_operationBusy)
- await Task.Delay(500);
-
- if (IsHandledOrPending(targetProcess.Id) && !targetProcess.HasExited)
- {
- lock (_injectionStateLock)
- {
- if (_injectedPids.Contains(targetProcess.Id))
- return;
- }
- }
-
- await ApplySelectedLoadoutAsync(targetProcess, reason);
-
- lock (_injectionStateLock)
- {
- if (!_injectedPids.Contains(targetProcess.Id))
- _autoInjectFailedPids.Add(targetProcess.Id);
- }
- }
- catch (Exception ex)
- {
- lock (_injectionStateLock)
- _autoInjectFailedPids.Add(targetProcess.Id);
-
- AppendActivity($"Auto-inject wait failed for PID {targetProcess.Id}: {ex.Message}");
- }
- finally
- {
- lock (_injectionStateLock)
- _pendingInjectionPids.Remove(targetProcess.Id);
-
- if (!IsDisposed && IsHandleCreated)
- BeginInvoke(new Action(UpdateStatusSummary));
- }
- });
- }
-
- private bool IsHandledOrPending(int pid)
- {
- lock (_injectionStateLock)
- return _injectedPids.Contains(pid) || _pendingInjectionPids.Contains(pid);
- }
-
- private void SaveAndApplyLaunchSettings()
- {
- SaveUiState();
- ApplyLaunchSettings();
- UpdateStatusSummary();
- }
-
- private void ApplyLaunchSettings()
- {
- try
- {
- _launchSettings.Apply(
- _acPathTextBox.Text.Trim(),
- _allowMultipleClientsCheckBox.Checked,
- _skipIntroVideosCheckBox.Checked,
- AppendActivity);
- }
- catch (Exception ex)
- {
- AppendActivity($"Launch settings update failed: {ex.Message}");
- }
- }
-
- private IEnumerable GetLaunchProfileParts()
- {
- LaunchServerProfile? server = GetSelectedServerProfile();
- LaunchAccountProfile? account = GetSelectedAccountProfile();
- int checkedCount = GetCheckedLaunchAccounts().Count;
-
- if (server != null)
- yield return $"Server: {server.DisplayName}";
- if (account != null)
- yield return $"Account: {account.DisplayName}";
- if (checkedCount > 0)
- yield return $"Launch set: {checkedCount} checked";
- if (!string.IsNullOrWhiteSpace(_launchArgsTextBox.Text.Trim()))
- yield return "Manual args override";
- yield return _allowMultipleClientsCheckBox.Checked ? "Multi-client on" : "Multi-client off";
- yield return _skipIntroVideosCheckBox.Checked ? "Intro videos skipped" : "Intro videos normal";
- }
-
- private string GetSelectedMainTabId()
- {
- if (_mainTabs.SelectedTab == null)
- return LauncherTabId;
-
- return string.Equals(_mainTabs.SelectedTab.Tag as string, RuntimeTabId, StringComparison.Ordinal)
- ? RuntimeTabId
- : LauncherTabId;
- }
-
- private void SelectMainTab(string tabId)
- {
- foreach (TabPage page in _mainTabs.TabPages)
- {
- if (string.Equals(page.Tag as string, tabId, StringComparison.OrdinalIgnoreCase))
- {
- _mainTabs.SelectedTab = page;
- return;
- }
- }
-
- if (_mainTabs.TabPages.Count > 0)
- _mainTabs.SelectedIndex = 0;
- }
-
- private static TabControl CreateMainTabs()
- {
- return new BufferedTabControl
- {
- Dock = DockStyle.Fill,
- Font = new Font("Segoe UI Semibold", 10f, FontStyle.Bold),
- Padding = new Point(18, 8)
- };
- }
-
- private static TabPage CreateTabPage(string title)
- {
- return new TabPage(title)
- {
- BackColor = AppBack,
- Padding = new Padding(8)
- };
- }
-
- private static TableLayoutPanel CreateSectionLayout(int rowCount, int? fillRowIndex = null)
- {
- var layout = new BufferedTableLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = PanelBack,
- ColumnCount = 1,
- RowCount = rowCount,
- Padding = new Padding(14),
- AutoSize = true,
- AutoSizeMode = AutoSizeMode.GrowAndShrink
- };
- for (int i = 0; i < rowCount; i++)
- {
- layout.RowStyles.Add(new RowStyle(SizeType.AutoSize));
- }
- return layout;
- }
-
- private static Panel CreateSectionPanel()
- {
- var panel = new BufferedPanel
- {
- Dock = DockStyle.Fill,
- BackColor = PanelBack
- };
- panel.Paint += DrawPanelBorder;
- return panel;
- }
-
- private static Panel CreateScrollHost(Control content)
- {
- var host = new BufferedPanel
- {
- Dock = DockStyle.Fill,
- BackColor = AppBack,
- AutoScroll = true,
- Padding = new Padding(0, 0, 6, 0)
- };
-
- bool updating = false;
- content.Location = Point.Empty;
- content.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
- host.Controls.Add(content);
-
- void UpdateScrollLayout(object? _, EventArgs __)
- {
- if (updating)
- return;
-
- try
- {
- updating = true;
- int availableWidth = Math.Max(1, host.ClientSize.Width - host.Padding.Horizontal - SystemInformation.VerticalScrollBarWidth);
- if (content.MaximumSize.Width != availableWidth)
- content.MaximumSize = new Size(availableWidth, 0);
-
- Size preferredSize = content.GetPreferredSize(new Size(availableWidth, 0));
- int width = Math.Max(availableWidth, preferredSize.Width);
- int height = Math.Max(preferredSize.Height, content.Height);
-
- if (content.Size.Width != width || content.Size.Height != height)
- content.Size = new Size(width, height);
-
- Size minSize = new(width, height);
- if (host.AutoScrollMinSize != minSize)
- host.AutoScrollMinSize = minSize;
- }
- finally
- {
- updating = false;
- }
- }
-
- host.ClientSizeChanged += UpdateScrollLayout;
- content.SizeChanged += UpdateScrollLayout;
- UpdateScrollLayout(null, EventArgs.Empty);
- return host;
- }
-
- private static void SetLabelText(Label label, string value)
- {
- if (!string.Equals(label.Text, value, StringComparison.Ordinal))
- label.Text = value;
- }
-
- private static Label CreateSectionTitle(string text)
- {
- return new Label
- {
- Text = text,
- ForeColor = TextPrimary,
- AutoSize = true,
- Font = new Font("Segoe UI Semibold", 14f, FontStyle.Bold),
- Margin = new Padding(0, 0, 0, 4)
- };
- }
-
- private static Label CreateSectionBody(string text)
- {
- return new Label
- {
- Text = text,
- ForeColor = TextMuted,
- AutoSize = true,
- MaximumSize = new Size(620, 0),
- Margin = new Padding(0, 0, 0, 8)
- };
- }
-
- private static Label CreateFooterLabel(string text)
- {
- return new Label
- {
- Text = text,
- ForeColor = TextMuted,
- AutoSize = true,
- MaximumSize = new Size(420, 0),
- Margin = new Padding(0, 8, 0, 0)
- };
- }
-
- private static Panel CreateFieldRow(string labelText, TextBox textBox, Action? browseAction)
- {
- var row = new BufferedPanel
- {
- Dock = DockStyle.Top,
- Height = 74,
- BackColor = PanelBack,
- Margin = new Padding(0, 0, 0, 4)
- };
-
- var label = new Label
- {
- Text = labelText,
- ForeColor = TextMuted,
- AutoSize = true,
- Location = new Point(0, 4)
- };
-
- textBox.Location = new Point(0, 28);
- textBox.Width = browseAction == null ? 520 : 430;
-
- row.Controls.Add(label);
- row.Controls.Add(textBox);
-
- if (browseAction != null)
- {
- var browseButton = CreateActionButton("Browse");
- browseButton.Location = new Point(textBox.Right + 10, 26);
- browseButton.Width = 90;
- browseButton.Click += (_, _) => browseAction();
- row.Controls.Add(browseButton);
- }
-
- return row;
- }
-
- private static Panel CreateProfileSelectorRow(
- string labelText,
- ComboBox comboBox,
- Action addAction,
- Action editAction,
- Action deleteAction)
- {
- var row = new BufferedPanel
- {
- Dock = DockStyle.Top,
- Height = 78,
- BackColor = PanelBack,
- Margin = new Padding(0, 0, 0, 4)
- };
-
- var label = new Label
- {
- Text = labelText,
- ForeColor = TextMuted,
- AutoSize = true,
- Location = new Point(0, 4)
- };
-
- comboBox.Location = new Point(0, 28);
- comboBox.Width = 332;
-
- var addButton = CreateActionButton("Add");
- addButton.Location = new Point(comboBox.Right + 10, 26);
- addButton.Width = 74;
- addButton.Click += (_, _) => addAction();
-
- var editButton = CreateActionButton("Edit");
- editButton.Location = new Point(addButton.Right + 8, 26);
- editButton.Width = 74;
- editButton.Click += (_, _) => editAction();
-
- var deleteButton = CreateActionButton("Delete");
- deleteButton.Location = new Point(editButton.Right + 8, 26);
- deleteButton.Width = 82;
- deleteButton.Click += (_, _) => deleteAction();
-
- row.Controls.Add(label);
- row.Controls.Add(comboBox);
- row.Controls.Add(addButton);
- row.Controls.Add(editButton);
- row.Controls.Add(deleteButton);
- return row;
- }
-
- private static Panel CreateCheckedListRow(string labelText, CheckedListBox listBox)
- {
- var row = new BufferedPanel
- {
- Dock = DockStyle.Top,
- Height = 150,
- BackColor = PanelBack,
- Margin = new Padding(0, 0, 0, 4)
- };
-
- var label = new Label
- {
- Text = labelText,
- ForeColor = TextMuted,
- AutoSize = true,
- Location = new Point(0, 4)
- };
-
- listBox.Location = new Point(0, 28);
- listBox.Size = new Size(520, 112);
-
- row.Controls.Add(label);
- row.Controls.Add(listBox);
- return row;
- }
-
- private Panel CreateRuntimeActionRow()
- {
- var row = new BufferedPanel
- {
- Dock = DockStyle.Top,
- Height = 86,
- BackColor = PanelBack,
- Margin = new Padding(0, 4, 0, 0)
- };
-
- var body = CreateSectionBody("Use this only when AC is already running and you need to attach RynthCore manually. Normal play should start from the Launch button in the top-right header.");
- body.Location = new Point(0, 46);
- body.MaximumSize = new Size(860, 0);
-
- var buttonRow = new BufferedFlowLayoutPanel
- {
- Dock = DockStyle.Top,
- BackColor = PanelBack,
- FlowDirection = FlowDirection.LeftToRight,
- AutoSize = false,
- WrapContents = false,
- Margin = new Padding(0),
- Height = 42
- };
-
- buttonRow.Controls.Add(_injectButton);
- row.Controls.Add(buttonRow);
- row.Controls.Add(body);
- return row;
- }
-
- private static void AddStateRow(TableLayoutPanel layout, int rowIndex, string labelText, Label valueLabel)
- {
- layout.RowStyles.Add(new RowStyle(SizeType.Absolute, 34f));
-
- var nameLabel = new Label
- {
- Text = labelText,
- ForeColor = TextMuted,
- AutoSize = true,
- Anchor = AnchorStyles.Left
- };
-
- valueLabel.Anchor = AnchorStyles.Left;
- layout.Controls.Add(nameLabel, 0, rowIndex);
- layout.Controls.Add(valueLabel, 1, rowIndex);
- }
-
- private static TextBox CreateTextBox(bool readOnly = false)
- {
- return new TextBox
- {
- BorderStyle = BorderStyle.FixedSingle,
- BackColor = PanelAlt,
- ForeColor = TextPrimary,
- ReadOnly = readOnly
- };
- }
-
- private static ComboBox CreateComboBox()
- {
- return new ComboBox
- {
- DropDownStyle = ComboBoxStyle.DropDownList,
- FlatStyle = FlatStyle.Flat,
- BackColor = PanelAlt,
- ForeColor = TextPrimary
- };
- }
-
- private static CheckedListBox CreateCheckedListBox()
- {
- return new CheckedListBox
- {
- CheckOnClick = true,
- BorderStyle = BorderStyle.FixedSingle,
- BackColor = PanelAlt,
- ForeColor = TextPrimary,
- IntegralHeight = false
- };
- }
-
- private static CheckBox CreateCheckBox(string text)
- {
- return new CheckBox
- {
- Text = text,
- AutoSize = true,
- ForeColor = TextPrimary,
- BackColor = Color.Transparent,
- Margin = new Padding(0, 0, 0, 6)
- };
- }
-
- private static Button CreateActionButton(string text)
- {
- var button = new Button
- {
- Text = text,
- Height = 38,
- Width = 168,
- FlatStyle = FlatStyle.Flat,
- BackColor = PanelAlt,
- ForeColor = TextPrimary,
- Margin = new Padding(0, 0, 10, 0)
- };
- button.FlatAppearance.BorderColor = Border;
- button.FlatAppearance.BorderSize = 1;
- return button;
- }
-
- private static Button CreateAccentButton(string text)
- {
- var button = new Button
- {
- Text = text,
- Height = 38,
- Width = 210,
- FlatStyle = FlatStyle.Flat,
- BackColor = Accent,
- ForeColor = Color.Black,
- Margin = new Padding(0)
- };
- button.FlatAppearance.BorderColor = Accent;
- button.FlatAppearance.BorderSize = 1;
- return button;
- }
-
- private static Label CreateValueLabel()
- {
- return new Label
- {
- AutoSize = true,
- ForeColor = TextPrimary,
- Font = new Font("Segoe UI Semibold", 10f, FontStyle.Bold)
- };
- }
-
- private static ListBox CreateActivityListBox()
- {
- return new BufferedListBox
- {
- Dock = DockStyle.Fill,
- BackColor = PanelAlt,
- ForeColor = TextPrimary,
- BorderStyle = BorderStyle.None,
- HorizontalScrollbar = true,
- IntegralHeight = false
- };
- }
-
- private static void DrawPanelBorder(object? sender, PaintEventArgs e)
- {
- if (sender is not Control control)
- return;
-
- using var borderPen = new Pen(Border);
- e.Graphics.DrawRectangle(borderPen, 0, 0, control.Width - 1, control.Height - 1);
-
- using var accentPen = new Pen(Gold);
- e.Graphics.DrawLine(accentPen, 0, 0, Math.Min(86, control.Width - 1), 0);
- }
-}
-
-internal sealed class BufferedListBox : ListBox
-{
- public BufferedListBox()
- {
- DoubleBuffered = true;
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
- UpdateStyles();
- }
-}
-
-internal sealed class BufferedPanel : Panel
-{
- public BufferedPanel()
- {
- DoubleBuffered = true;
- ResizeRedraw = true;
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
- UpdateStyles();
- }
-}
-
-internal sealed class BufferedTableLayoutPanel : TableLayoutPanel
-{
- public BufferedTableLayoutPanel()
- {
- DoubleBuffered = true;
- ResizeRedraw = true;
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
- UpdateStyles();
- }
-}
-
-internal sealed class BufferedFlowLayoutPanel : FlowLayoutPanel
-{
- public BufferedFlowLayoutPanel()
- {
- DoubleBuffered = true;
- ResizeRedraw = true;
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
- UpdateStyles();
- }
-}
-
-internal sealed class BufferedTabControl : TabControl
-{
- public BufferedTabControl()
- {
- DoubleBuffered = true;
- ResizeRedraw = true;
- SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
- UpdateStyles();
- }
-}
diff --git a/src/RynthCore.App/Program.cs b/src/RynthCore.App/Program.cs
deleted file mode 100644
index 14221b7..0000000
--- a/src/RynthCore.App/Program.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-using System;
-using System.Windows.Forms;
-
-namespace RynthCore.App;
-
-internal static class Program
-{
- [STAThread]
- private static void Main()
- {
- ApplicationConfiguration.Initialize();
- Application.Run(new MainForm());
- }
-}
diff --git a/src/RynthCore.App/RynthCore.App.csproj b/src/RynthCore.App/RynthCore.App.csproj
deleted file mode 100644
index 12bdb91..0000000
--- a/src/RynthCore.App/RynthCore.App.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- WinExe
- net9.0-windows
- true
- x86
- RynthCore.App
- RynthCore.App
- x86
- enable
- Assets\RynthCore.ico
-
-
-
-
-
-
-
diff --git a/src/RynthCore.Engine/ImGui/RynthCoreShell.cs b/src/RynthCore.Engine/ImGui/RynthCoreShell.cs
index 5e5b2ac..4e45f82 100644
--- a/src/RynthCore.Engine/ImGui/RynthCoreShell.cs
+++ b/src/RynthCore.Engine/ImGui/RynthCoreShell.cs
@@ -47,6 +47,7 @@ internal static class RynthCoreShell
private static long _nextLogRefreshTick;
private static int _selectedPlugin = 0;
private static bool _showPluginTips = true;
+ private static string _newPluginPathInput = "";
private static readonly bool[] PluginBarButtonsVisible = [true, false, false, false];
private static Vector2 _barPosition = new(12f, 12f);
private static bool _barPositionInitialized;
@@ -389,22 +390,38 @@ internal static class RynthCoreShell
}
RenderShellToolbar();
- DrawHero();
- ImGui.Spacing();
- if (ImGui.BeginTable("ShellMain", 2, ImGuiTableFlags.SizingStretchProp))
+ if (ImGui.BeginTabBar("##ShellTabs"))
{
- ImGui.TableSetupColumn("Left", ImGuiTableColumnFlags.WidthStretch, 0.60f);
- ImGui.TableSetupColumn("Right", ImGuiTableColumnFlags.WidthStretch, 0.40f);
- ImGui.TableNextRow();
+ if (ImGui.BeginTabItem("Dashboard"))
+ {
+ DrawHero();
+ ImGui.Spacing();
- ImGui.TableNextColumn();
- RenderControlDeck();
+ if (ImGui.BeginTable("ShellMain", 2, ImGuiTableFlags.SizingStretchProp))
+ {
+ ImGui.TableSetupColumn("Left", ImGuiTableColumnFlags.WidthStretch, 0.60f);
+ ImGui.TableSetupColumn("Right", ImGuiTableColumnFlags.WidthStretch, 0.40f);
+ ImGui.TableNextRow();
- ImGui.TableNextColumn();
- RenderPluginDeck();
+ ImGui.TableNextColumn();
+ RenderControlDeck();
- ImGui.EndTable();
+ ImGui.TableNextColumn();
+ RenderPluginDeck();
+
+ ImGui.EndTable();
+ }
+ ImGui.EndTabItem();
+ }
+
+ if (ImGui.BeginTabItem("Plugins"))
+ {
+ RenderPluginsTab();
+ ImGui.EndTabItem();
+ }
+
+ ImGui.EndTabBar();
}
ImGui.End();
@@ -656,6 +673,109 @@ internal static class RynthCoreShell
ImGui.EndChild();
}
+ private static void RenderPluginsTab()
+ {
+ ImGui.Spacing();
+
+ // ── Loaded plugins ──────────────────────────────────────────────────
+ var loadedPlugins = PluginManager.Plugins;
+ ImGui.TextColored(Accent, $"Loaded Plugins ({loadedPlugins.Count})");
+ ImGui.Separator();
+
+ if (loadedPlugins.Count == 0)
+ {
+ ImGui.TextColored(TextMute, "No plugins loaded.");
+ }
+ else
+ {
+ for (int i = 0; i < loadedPlugins.Count; i++)
+ {
+ var p = loadedPlugins[i];
+ bool waitingForLogin = p.Initialized && !p.Failed && p.OnLoginComplete != null && !p.LoginCompleteDispatched;
+ Vector4 statusColor = p.Failed ? Warn : waitingForLogin ? Gold : p.Initialized ? Good : TextMute;
+ string statusText = p.Failed ? "FAILED" : waitingForLogin ? "WAIT LOGIN" : p.Initialized ? "ACTIVE" : "PENDING";
+
+ string ver = string.IsNullOrEmpty(p.VersionString) ? "" : $" v{p.VersionString}";
+ ImGui.BulletText("");
+ ImGui.SameLine();
+ ImGui.TextColored(Accent, p.DisplayName);
+ ImGui.SameLine();
+ ImGui.TextColored(TextMute, ver);
+ ImGui.SameLine(280f);
+ ImGui.TextColored(statusColor, statusText);
+ ImGui.TextColored(TextMute, $" {p.SourceFilePath}");
+ }
+ }
+
+ ImGui.Spacing();
+ ImGui.Spacing();
+
+ // ── Plugin sources ──────────────────────────────────────────────────
+ ImGui.TextColored(Accent, "Plugin Sources");
+ ImGui.Separator();
+
+ string builtInDir = PluginManager.PluginDirectory;
+ if (!string.IsNullOrEmpty(builtInDir))
+ {
+ ImGui.TextColored(TextMute, "Built-in directory:");
+ ImGui.SameLine();
+ ImGui.TextColored(TextDim, builtInDir);
+ }
+
+ ImGui.Spacing();
+ ImGui.TextColored(TextMute, "Additional plugin DLLs:");
+
+ var extraPaths = PluginManager.ExtraPluginPaths;
+ int removeIdx = -1;
+ if (extraPaths.Count == 0)
+ {
+ ImGui.TextColored(TextMute, " (none)");
+ }
+ else
+ {
+ for (int i = 0; i < extraPaths.Count; i++)
+ {
+ ImGui.PushID($"pluginpath_{i}");
+ bool exists = File.Exists(extraPaths[i]);
+ ImGui.TextColored(exists ? Good : Warn, exists ? " OK" : " ??");
+ ImGui.SameLine();
+ ImGui.TextColored(TextDim, extraPaths[i]);
+ ImGui.SameLine();
+ if (ImGui.SmallButton("Remove"))
+ removeIdx = i;
+ ImGui.PopID();
+ }
+ }
+ if (removeIdx >= 0)
+ {
+ EngineSettings.RemovePluginPath(removeIdx);
+ PluginManager.RequestRescan();
+ }
+
+ ImGui.Spacing();
+ ImGui.TextColored(TextMute, "Add plugin DLL path:");
+ ImGui.SetNextItemWidth(-80f);
+ ImGui.InputText("##newpath", ref _newPluginPathInput, 512);
+ ImGui.SameLine();
+ bool canAdd = !string.IsNullOrWhiteSpace(_newPluginPathInput);
+ if (!canAdd) ImGui.BeginDisabled();
+ if (ImGui.SmallButton("Add"))
+ {
+ EngineSettings.AddPluginPath(_newPluginPathInput.Trim());
+ _newPluginPathInput = "";
+ PluginManager.RequestRescan();
+ }
+ if (!canAdd) ImGui.EndDisabled();
+
+ ImGui.Spacing();
+ ImGui.Separator();
+ ImGui.Spacing();
+
+ if (ImGui.Button("Rescan Plugins"))
+ PluginManager.RequestRescan();
+ ShowTooltip("Unload all plugins, re-scan built-in directory and all extra paths, reload.");
+ }
+
private static void RenderCompatibilityDeck()
{
ClientActionHookStatus status = ClientActionHooks.GetStatus();
diff --git a/src/RynthCore.Engine/Plugins/EngineSettings.cs b/src/RynthCore.Engine/Plugins/EngineSettings.cs
new file mode 100644
index 0000000..5a3933e
--- /dev/null
+++ b/src/RynthCore.Engine/Plugins/EngineSettings.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text.Json;
+
+namespace RynthCore.Engine.Plugins;
+
+internal static class EngineSettings
+{
+ private static readonly string SettingsPath = Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
+ "RynthCore",
+ "engine.json");
+
+ private static List _pluginPaths = new();
+ private static bool _loaded;
+
+ public static IReadOnlyList PluginPaths
+ {
+ get
+ {
+ EnsureLoaded();
+ return _pluginPaths;
+ }
+ }
+
+ public static void AddPluginPath(string path)
+ {
+ EnsureLoaded();
+ string full = Path.GetFullPath(path);
+ for (int i = 0; i < _pluginPaths.Count; i++)
+ {
+ if (string.Equals(_pluginPaths[i], full, StringComparison.OrdinalIgnoreCase))
+ return;
+ }
+ _pluginPaths.Add(full);
+ Save();
+ }
+
+ public static void RemovePluginPath(int index)
+ {
+ EnsureLoaded();
+ if (index >= 0 && index < _pluginPaths.Count)
+ {
+ _pluginPaths.RemoveAt(index);
+ Save();
+ }
+ }
+
+ private static void EnsureLoaded()
+ {
+ if (_loaded) return;
+ _loaded = true;
+
+ try
+ {
+ if (!File.Exists(SettingsPath)) return;
+ using var doc = JsonDocument.Parse(File.ReadAllBytes(SettingsPath));
+ if (doc.RootElement.TryGetProperty("PluginPaths", out var arr) &&
+ arr.ValueKind == JsonValueKind.Array)
+ {
+ foreach (var el in arr.EnumerateArray())
+ {
+ string? val = el.GetString();
+ if (!string.IsNullOrWhiteSpace(val))
+ _pluginPaths.Add(val);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Plugin($"EngineSettings: Failed to load {SettingsPath}: {ex.Message}");
+ }
+ }
+
+ private static void Save()
+ {
+ try
+ {
+ string? dir = Path.GetDirectoryName(SettingsPath);
+ if (dir != null) Directory.CreateDirectory(dir);
+
+ using var ms = new MemoryStream();
+ using (var w = new Utf8JsonWriter(ms, new JsonWriterOptions { Indented = true }))
+ {
+ w.WriteStartObject();
+ w.WriteStartArray("PluginPaths");
+ foreach (string p in _pluginPaths)
+ w.WriteStringValue(p);
+ w.WriteEndArray();
+ w.WriteEndObject();
+ }
+ File.WriteAllBytes(SettingsPath, ms.ToArray());
+ }
+ catch (Exception ex)
+ {
+ RynthLog.Plugin($"EngineSettings: Failed to save: {ex.Message}");
+ }
+ }
+}
diff --git a/src/RynthCore.Engine/Plugins/PluginLoader.cs b/src/RynthCore.Engine/Plugins/PluginLoader.cs
index ada0541..50fa296 100644
--- a/src/RynthCore.Engine/Plugins/PluginLoader.cs
+++ b/src/RynthCore.Engine/Plugins/PluginLoader.cs
@@ -106,6 +106,12 @@ internal static class PluginLoader
}
}
+ public static LoadedPlugin? LoadSingle(string sourcePath, string shadowRootDir, int generation)
+ {
+ string sessionShadowDir = PrepareShadowDirectory(shadowRootDir, generation);
+ return TryLoad(sourcePath, sessionShadowDir);
+ }
+
private static LoadedPlugin? TryLoad(string sourcePath, string sessionShadowDir)
{
string fileName = Path.GetFileName(sourcePath);
diff --git a/src/RynthCore.Engine/Plugins/PluginManager.cs b/src/RynthCore.Engine/Plugins/PluginManager.cs
index 8afb19a..1f9dad6 100644
--- a/src/RynthCore.Engine/Plugins/PluginManager.cs
+++ b/src/RynthCore.Engine/Plugins/PluginManager.cs
@@ -196,6 +196,7 @@ internal static class PluginManager
public static IReadOnlyList Plugins => _plugins;
public static bool IsRescanQueued => _rescanRequested;
public static string PluginDirectory => _pluginsDir;
+ public static IReadOnlyList ExtraPluginPaths => EngineSettings.PluginPaths;
public static bool HasObservedUIInitialized => _uiInitializedObserved;
public static bool HasObservedLoginComplete => _loginCompleteObserved;
@@ -1493,8 +1494,26 @@ internal static class PluginManager
private static void LoadPluginsFromDisk()
{
_loadGeneration++;
+
+ // Default directory
var loaded = PluginLoader.LoadAll(_pluginsDir, _shadowRootDir, _loadGeneration);
_plugins.AddRange(loaded);
+
+ // Extra DLL paths from engine settings
+ var extraPaths = EngineSettings.PluginPaths;
+ for (int i = 0; i < extraPaths.Count; i++)
+ {
+ string dllPath = extraPaths[i];
+ if (!File.Exists(dllPath))
+ {
+ RynthLog.Plugin($"PluginManager: Extra plugin not found: {dllPath}");
+ continue;
+ }
+ RynthLog.Plugin($"PluginManager: Loading extra plugin: {dllPath}");
+ var plugin = PluginLoader.LoadSingle(dllPath, _shadowRootDir, _loadGeneration);
+ if (plugin != null)
+ _plugins.Add(plugin);
+ }
}
private static void InitializeLoadedPlugins()