mirror of
https://github.com/9ParsonsB/Pulsar.git
synced 2025-07-04 17:43:42 -04:00
observatory herald (#30)
* WIP: initial commit for observatory herald * Plugin error handling refactor * make error window non-modal * tidy up plugin error handling * first pass for basic herald functionality * corrections for linux env * Use FNV hash directly instead of managing through dictionary/index file * resolve audio queuing issue, switch to personal NetCoreAudio fork * merge cleanup * add enable setting, populate defaults * framework xml doc update * Adjust settings, add style selection, replace locale with demonym in dropdown list. * Test is position is on screen before saving/loading. * use a default that's actually in the list
This commit is contained in:
@ -6,7 +6,7 @@ using System.Reflection;
|
||||
using System.Data;
|
||||
using Observatory.Framework.Interfaces;
|
||||
using System.IO;
|
||||
using System.Configuration;
|
||||
using Observatory.Framework;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Observatory.PluginManagement
|
||||
@ -39,11 +39,6 @@ namespace Observatory.PluginManagement
|
||||
{
|
||||
errorList = LoadPlugins(out workerPlugins, out notifyPlugins);
|
||||
|
||||
foreach (var error in errorList)
|
||||
{
|
||||
Console.WriteLine(error);
|
||||
}
|
||||
|
||||
var pluginHandler = new PluginEventHandler(workerPlugins.Select(p => p.plugin), notifyPlugins.Select(p => p.plugin));
|
||||
var logMonitor = LogMonitor.GetInstance;
|
||||
pluginPanels = new();
|
||||
@ -54,24 +49,53 @@ namespace Observatory.PluginManagement
|
||||
|
||||
var core = new PluginCore();
|
||||
|
||||
List<IObservatoryPlugin> errorPlugins = new();
|
||||
|
||||
foreach (var plugin in workerPlugins.Select(p => p.plugin))
|
||||
{
|
||||
LoadSettings(plugin);
|
||||
plugin.Load(core);
|
||||
try
|
||||
{
|
||||
LoadSettings(plugin);
|
||||
plugin.Load(core);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
errorList.Add(FormatErrorMessage(ex));
|
||||
errorPlugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
|
||||
workerPlugins.RemoveAll(w => errorPlugins.Contains(w.plugin));
|
||||
errorPlugins.Clear();
|
||||
|
||||
foreach (var plugin in notifyPlugins.Select(p => p.plugin))
|
||||
{
|
||||
// Notifiers which are also workers need not be loaded again (they are the same instance).
|
||||
if (!plugin.GetType().IsAssignableTo(typeof(IObservatoryWorker)))
|
||||
{
|
||||
LoadSettings(plugin);
|
||||
plugin.Load(core);
|
||||
try
|
||||
{
|
||||
LoadSettings(plugin);
|
||||
plugin.Load(core);
|
||||
}
|
||||
catch (PluginException ex)
|
||||
{
|
||||
errorList.Add(FormatErrorMessage(ex));
|
||||
errorPlugins.Add(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifyPlugins.RemoveAll(n => errorPlugins.Contains(n.plugin));
|
||||
|
||||
core.Notification += pluginHandler.OnNotificationEvent;
|
||||
}
|
||||
|
||||
private static string FormatErrorMessage(PluginException ex)
|
||||
{
|
||||
return $"{ex.PluginName}: {ex.UserMessage}";
|
||||
}
|
||||
|
||||
private void LoadSettings(IObservatoryPlugin plugin)
|
||||
{
|
||||
string savedSettings = Properties.Core.Default.PluginSettings;
|
||||
|
Reference in New Issue
Block a user