1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Plugin Features - Removed icons

Data model event node - Fix numeric values
This commit is contained in:
Robert 2022-09-17 19:12:14 +02:00
parent 654863e0de
commit 212f8855de
9 changed files with 60 additions and 59 deletions

View File

@ -22,6 +22,7 @@ public class PluginFeatureAttribute : Attribute
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
/// available icons
/// </summary>
[Obsolete("Feature icons are no longer shown in the UI.")]
public string? Icon { get; set; }
/// <summary>

View File

@ -31,20 +31,7 @@ public class PluginFeatureInfo : CorePropertyChanged, IPrerequisitesSubject
Name = attribute?.Name ?? featureType.Name.Humanize(LetterCasing.Title);
Description = attribute?.Description;
Icon = attribute?.Icon;
AlwaysEnabled = attribute?.AlwaysEnabled ?? false;
if (Icon != null) return;
if (typeof(DeviceProvider).IsAssignableFrom(featureType))
Icon = "Devices";
else if (typeof(Module).IsAssignableFrom(featureType))
Icon = "VectorRectangle";
else if (typeof(LayerBrushProvider).IsAssignableFrom(featureType))
Icon = "Brush";
else if (typeof(LayerEffectProvider).IsAssignableFrom(featureType))
Icon = "AutoAwesome";
else
Icon = "Plugin";
}
internal PluginFeatureInfo(Plugin plugin, PluginFeatureAttribute? attribute, PluginFeature instance)
@ -56,19 +43,8 @@ public class PluginFeatureInfo : CorePropertyChanged, IPrerequisitesSubject
Name = attribute?.Name ?? instance.GetType().Name.Humanize(LetterCasing.Title);
Description = attribute?.Description;
Icon = attribute?.Icon;
AlwaysEnabled = attribute?.AlwaysEnabled ?? false;
Instance = instance;
if (Icon != null) return;
Icon = Instance switch
{
DeviceProvider => "Devices",
Module => "VectorRectangle",
LayerBrushProvider => "Brush",
LayerEffectProvider => "AutoAwesome",
_ => "Plugin"
};
}
/// <summary>
@ -110,17 +86,6 @@ public class PluginFeatureInfo : CorePropertyChanged, IPrerequisitesSubject
set => SetAndNotify(ref _description, value);
}
/// <summary>
/// The plugins display icon that's shown in the settings see <see href="https://materialdesignicons.com" /> for
/// available icons
/// </summary>
[JsonProperty]
public string? Icon
{
get => _icon;
set => SetAndNotify(ref _icon, value);
}
/// <summary>
/// Marks the feature to always be enabled as long as the plugin is enabled and cannot be disabled.
/// <para>Note: always <see langword="true" /> if this is the plugin's only feature</para>
@ -142,20 +107,7 @@ public class PluginFeatureInfo : CorePropertyChanged, IPrerequisitesSubject
get => _instance;
internal set => SetAndNotify(ref _instance, value);
}
/// <summary>
/// Gets a string representing either a full path pointing to an svg or the markdown icon
/// </summary>
public string? ResolvedIcon
{
get
{
if (Icon == null)
return null;
return Icon.Contains('.') ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}
internal PluginFeatureEntity Entity { get; }
/// <inheritdoc />

View File

@ -129,7 +129,7 @@ public class ArtemisIcon : UserControl
/// theme
/// </summary>
public static readonly StyledProperty<bool> FillProperty =
AvaloniaProperty.Register<ArtemisIcon, bool>(nameof(Icon), true, notifying: IconChanging);
AvaloniaProperty.Register<ArtemisIcon, bool>(nameof(Icon), false, notifying: IconChanging);
/// <summary>
/// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the

View File

@ -25,12 +25,12 @@
</Grid.ContextFlyout>
<!-- Icon column -->
<shared:ArtemisIcon Grid.Column="0"
Icon="{CompiledBinding FeatureInfo.ResolvedIcon}"
Fill="False"
Width="20"
Height="20"
IsVisible="{CompiledBinding LoadException, Converter={x:Static ObjectConverters.IsNull}}" />
<avalonia:MaterialIcon Grid.Column="0"
ToolTip.Tip="{CompiledBinding FeatureType}"
Kind="{CompiledBinding FeatureIcon}"
Width="20"
Height="20"
IsVisible="{CompiledBinding LoadException, Converter={x:Static ObjectConverters.IsNull}}" />
<Button Grid.Column="0"
Classes="AppBarButton icon-button"

View File

@ -5,11 +5,17 @@ using System.Reactive;
using System.Reactive.Disposables;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.DeviceProviders;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
using Artemis.Core.Modules;
using Artemis.Core.ScriptingProviders;
using Artemis.Core.Services;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.Builders;
using Avalonia.Threading;
using Material.Icons;
using ReactiveUI;
namespace Artemis.UI.Screens.Plugins;
@ -90,6 +96,42 @@ public class PluginFeatureViewModel : ActivatableViewModelBase
public bool CanRemovePrerequisites => FeatureInfo.PlatformPrerequisites.Any(p => p.UninstallActions.Any());
public bool IsPopupEnabled => CanInstallPrerequisites || CanRemovePrerequisites;
public MaterialIconKind FeatureIcon
{
get
{
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(DeviceProvider)))
return MaterialIconKind.Devices;
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(Module)))
return MaterialIconKind.VectorRectangle;
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(LayerBrushProvider)))
return MaterialIconKind.Brush;
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(LayerEffectProvider)))
return MaterialIconKind.AutoAwesome;
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(ScriptingProvider)))
return MaterialIconKind.Code;
return MaterialIconKind.Extension;
}
}
public string FeatureType
{
get
{
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(DeviceProvider)))
return "Device Provider";
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(Module)))
return "Module";
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(LayerBrushProvider)))
return "Layer Brush";
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(LayerEffectProvider)))
return "Layer Effect";
if (FeatureInfo.FeatureType.IsAssignableTo(typeof(ScriptingProvider)))
return "Scripting Provider";
return "Miscellaneous feature";
}
}
private void ExecuteShowLogsFolder()
{
try

View File

@ -21,7 +21,7 @@
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<shared:ArtemisIcon Icon="{CompiledBinding Info.ResolvedIcon}" Width="16" Height="16" Margin="0 0 5 0" />
<shared:ArtemisIcon Icon="{CompiledBinding Plugin.Info.ResolvedIcon}" Width="16" Height="16" Margin="0 0 5 0" />
<TextBlock Text="{CompiledBinding LanguageName}" />
</StackPanel>
</DataTemplate>

View File

@ -23,7 +23,7 @@
<shared:ArtemisIcon Grid.Row="0"
Grid.Column="0"
Grid.RowSpan="2"
Icon="{CompiledBinding ScriptConfiguration.Script.ScriptingProvider.Info.ResolvedIcon, FallbackValue=QuestionMark}"
Icon="{CompiledBinding ScriptConfiguration.Script.ScriptingProvider.Plugin.Info.ResolvedIcon, FallbackValue=QuestionMark}"
Width="32 "
Height="32"
Margin="0 0 10 0"

View File

@ -10,7 +10,7 @@ public class ProfileModuleViewModel : ViewModelBase
{
Module = module;
Name = module.Info.Name;
Icon = module.Info.ResolvedIcon ?? MaterialIconKind.QuestionMark.ToString();
Icon = module.Plugin.Info.ResolvedIcon ?? MaterialIconKind.QuestionMark.ToString();
Description = module.Info.Description;
}

View File

@ -56,6 +56,9 @@ public class DataModelEventNode : Node<DataModelPathEntity, DataModelEventNodeCu
// If the path is a regular value, evaluate the current value
else if (_oldValuePin != null && _newValuePin != null)
{
if (_newValuePin.IsNumeric)
pathValue = new Numeric(pathValue);
if (Equals(_lastValue, pathValue))
{
TimeSinceLastTrigger.Value = (DateTime.Now - _lastTrigger).TotalMilliseconds;
@ -119,6 +122,9 @@ public class DataModelEventNode : Node<DataModelPathEntity, DataModelEventNodeCu
if (propertyType == null)
return;
if (Numeric.IsTypeCompatible(propertyType))
propertyType = typeof(Numeric);
_oldValuePin = CreateOrAddOutputPin(propertyType, "Old value");
_newValuePin = CreateOrAddOutputPin(propertyType, "New value");
_lastValue = null;