mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Plugins - Implemented enabling/disabling (doesnt work for devices)
Plugins - Disable plugins that caused a crash Tray icon - Added menu items for quick access
This commit is contained in:
1 parent
16b221d2f8
commit
57d82fafa8
29 files changed
+442
-164
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using McMaster.NETCore.Plugins;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -72,6 +73,12 @@ namespace Artemis.Core.Plugins.Models
|
||||
[JsonIgnore]
|
||||
internal Assembly Assembly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The entity representing the plugin
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
internal PluginEntity PluginEntity { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{nameof(Guid)}: {Guid}, {nameof(Name)}: {Name}, {nameof(Version)}: {Version}";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Artemis.Storage.Entities;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -10,13 +11,13 @@ namespace Artemis.Core.Plugins.Models
|
||||
// ReSharper disable once NotAccessedField.Local
|
||||
private readonly PluginInfo _pluginInfo;
|
||||
private readonly PluginSettingEntity _pluginSettingEntity;
|
||||
private readonly IPluginSettingRepository _pluginSettingRepository;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private T _value;
|
||||
|
||||
internal PluginSetting(PluginInfo pluginInfo, IPluginSettingRepository pluginSettingRepository, PluginSettingEntity pluginSettingEntity)
|
||||
internal PluginSetting(PluginInfo pluginInfo, IPluginRepository pluginRepository, PluginSettingEntity pluginSettingEntity)
|
||||
{
|
||||
_pluginInfo = pluginInfo;
|
||||
_pluginSettingRepository = pluginSettingRepository;
|
||||
_pluginRepository = pluginRepository;
|
||||
_pluginSettingEntity = pluginSettingEntity;
|
||||
|
||||
Name = pluginSettingEntity.Name;
|
||||
@@ -73,7 +74,7 @@ namespace Artemis.Core.Plugins.Models
|
||||
return;
|
||||
|
||||
_pluginSettingEntity.Value = JsonConvert.SerializeObject(Value);
|
||||
_pluginSettingRepository.Save(_pluginSettingEntity);
|
||||
_pluginRepository.SaveSetting(_pluginSettingEntity);
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> SettingChanged;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Artemis.Storage.Entities;
|
||||
using Artemis.Storage.Entities.Plugins;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -12,13 +13,13 @@ namespace Artemis.Core.Plugins.Models
|
||||
public class PluginSettings
|
||||
{
|
||||
private readonly PluginInfo _pluginInfo;
|
||||
private readonly IPluginSettingRepository _pluginSettingRepository;
|
||||
private readonly IPluginRepository _pluginRepository;
|
||||
private readonly Dictionary<string, object> _settingEntities;
|
||||
|
||||
internal PluginSettings(PluginInfo pluginInfo, IPluginSettingRepository pluginSettingRepository)
|
||||
internal PluginSettings(PluginInfo pluginInfo, IPluginRepository pluginRepository)
|
||||
{
|
||||
_pluginInfo = pluginInfo;
|
||||
_pluginSettingRepository = pluginSettingRepository;
|
||||
_pluginRepository = pluginRepository;
|
||||
_settingEntities = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
@@ -37,15 +38,15 @@ namespace Artemis.Core.Plugins.Models
|
||||
if (_settingEntities.ContainsKey(name))
|
||||
return (PluginSetting<T>) _settingEntities[name];
|
||||
// Try to find in database
|
||||
var settingEntity = _pluginSettingRepository.GetByNameAndPluginGuid(name, _pluginInfo.Guid);
|
||||
var settingEntity = _pluginRepository.GetSettingByNameAndGuid(name, _pluginInfo.Guid);
|
||||
// If not found, create a new one
|
||||
if (settingEntity == null)
|
||||
{
|
||||
settingEntity = new PluginSettingEntity {Name = name, PluginGuid = _pluginInfo.Guid, Value = JsonConvert.SerializeObject(defaultValue)};
|
||||
_pluginSettingRepository.Add(settingEntity);
|
||||
_pluginRepository.AddSetting(settingEntity);
|
||||
}
|
||||
|
||||
var pluginSetting = new PluginSetting<T>(_pluginInfo, _pluginSettingRepository, settingEntity);
|
||||
var pluginSetting = new PluginSetting<T>(_pluginInfo, _pluginRepository, settingEntity);
|
||||
_settingEntities.Add(name, pluginSetting);
|
||||
return pluginSetting;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user