Add Plugins tab, remove WinForms launcher, add BUILD.md

- Add Plugins tab to Avalonia launcher with add/remove plugin DLL management
- Plugin paths sync to engine.json for runtime loading
- Engine loads plugins from custom DLL paths via EngineSettings
- Remove defunct WinForms launcher (RynthCore.App project, MainForm, Program)
- Shared source files remain in src/RynthCore.App for Avalonia and Engine
- Add BUILD.md with full publish/deploy instructions for all components

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
tombohar 2026-04-16 17:08:26 -04:00
commit 36e8208caa
14 changed files with 584 additions and 2233 deletions

View file

@ -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();

View file

@ -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<string> _pluginPaths = new();
private static bool _loaded;
public static IReadOnlyList<string> 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}");
}
}
}

View file

@ -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);

View file

@ -196,6 +196,7 @@ internal static class PluginManager
public static IReadOnlyList<LoadedPlugin> Plugins => _plugins;
public static bool IsRescanQueued => _rescanRequested;
public static string PluginDirectory => _pluginsDir;
public static IReadOnlyList<string> 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()