mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Implemented profile default loading and rendering without the editor
Changed edit tool rotation to allow rotation past 360 degrees
This commit is contained in:
1 parent
f8fc30ace2
commit
fabb385556
13 files changed
+116
-41
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.Models.Profile.LayerProperties;
|
||||
@@ -77,8 +78,7 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
|
||||
return;
|
||||
|
||||
var keyframes = LayerProperty.UntypedKeyframes.ToList();
|
||||
Progress = Progress.Add(TimeSpan.FromMilliseconds(deltaTime));
|
||||
|
||||
Progress = Progress.Add(TimeSpan.FromSeconds(deltaTime));
|
||||
// The current keyframe is the last keyframe before the current time
|
||||
CurrentKeyframe = keyframes.LastOrDefault(k => k.Position <= Progress);
|
||||
// The next keyframe is the first keyframe that's after the current time
|
||||
@@ -112,7 +112,7 @@ namespace Artemis.Core.Models.Profile.KeyframeEngines
|
||||
public void OverrideProgress(TimeSpan progress)
|
||||
{
|
||||
Progress = TimeSpan.Zero;
|
||||
Update(progress.TotalMilliseconds);
|
||||
Update(progress.TotalSeconds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Artemis.Core.Models.Profile
|
||||
/// <summary>
|
||||
/// The rotation property of this layer range 0 - 360, also found in <see cref="Properties" />
|
||||
/// </summary>
|
||||
public LayerProperty<int> RotationProperty { get; private set; }
|
||||
public LayerProperty<float> RotationProperty { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The opacity property of this layer range 0 - 100, also found in <see cref="Properties" />
|
||||
@@ -153,11 +153,8 @@ namespace Artemis.Core.Models.Profile
|
||||
{
|
||||
property.KeyframeEngine?.Update(deltaTime);
|
||||
// This is a placeholder method of repeating the animation until repeat modes are implemented
|
||||
if (property.KeyframeEngine != null && property.IsUsingKeyframes && property.KeyframeEngine.NextKeyframe == null)
|
||||
{
|
||||
Debug.WriteLine($"Reset {property} progress");
|
||||
if (property.KeyframeEngine != null && property.IsUsingKeyframes && property.KeyframeEngine.NextKeyframe == null)
|
||||
property.KeyframeEngine.OverrideProgress(TimeSpan.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
LayerBrush?.Update(deltaTime);
|
||||
@@ -421,7 +418,7 @@ namespace Artemis.Core.Models.Profile
|
||||
AnchorPointProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.AnchorPoint", "Anchor Point", "The point at which the shape is attached to its position.");
|
||||
PositionProperty = new LayerProperty<SKPoint>(this, transformProperty, "Core.Position", "Position", "The position of the shape.");
|
||||
SizeProperty = new LayerProperty<SKSize>(this, transformProperty, "Core.Size", "Size", "The size of the shape.") {InputAffix = "%"};
|
||||
RotationProperty = new LayerProperty<int>(this, transformProperty, "Core.Rotation", "Rotation", "The rotation of the shape in degrees.") {InputAffix = "°"};
|
||||
RotationProperty = new LayerProperty<float>(this, transformProperty, "Core.Rotation", "Rotation", "The rotation of the shape in degrees.") {InputAffix = "°"};
|
||||
OpacityProperty = new LayerProperty<float>(this, transformProperty, "Core.Opacity", "Opacity", "The opacity of the shape.") {InputAffix = "%"};
|
||||
transformProperty.Children.Add(AnchorPointProperty);
|
||||
transformProperty.Children.Add(PositionProperty);
|
||||
|
||||
@@ -222,6 +222,8 @@ namespace Artemis.Core.Models.Profile.LayerProperties
|
||||
|
||||
currentKeyframe.BaseValue = value;
|
||||
}
|
||||
|
||||
OnValueChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,6 +13,11 @@ namespace Artemis.Core.Plugins.Abstract
|
||||
{
|
||||
}
|
||||
|
||||
public override void EnablePlugin()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Profile ActiveProfile { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -23,17 +23,19 @@ namespace Artemis.Core.Services
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly IRgbService _rgbService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IProfileService _profileService;
|
||||
private List<Module> _modules;
|
||||
|
||||
internal CoreService(ILogger logger, IPluginService pluginService, IRgbService rgbService, ISurfaceService surfaceService)
|
||||
internal CoreService(ILogger logger, IPluginService pluginService, IRgbService rgbService, ISurfaceService surfaceService, IProfileService profileService)
|
||||
{
|
||||
_logger = logger;
|
||||
_pluginService = pluginService;
|
||||
_rgbService = rgbService;
|
||||
_surfaceService = surfaceService;
|
||||
_profileService = profileService;
|
||||
_rgbService.Surface.Updating += SurfaceOnUpdating;
|
||||
_rgbService.Surface.Updated += SurfaceOnUpdated;
|
||||
|
||||
|
||||
_modules = _pluginService.GetPluginsOfType<Module>();
|
||||
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||
_pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||
@@ -42,6 +44,9 @@ namespace Artemis.Core.Services
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
public bool ModuleUpdatingDisabled { get; set; }
|
||||
public bool ModuleRenderingDisabled { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose services
|
||||
@@ -75,6 +80,8 @@ namespace Artemis.Core.Services
|
||||
else
|
||||
_logger.Information("Initialized without an active surface entity");
|
||||
|
||||
await Task.Run(() => _profileService.ActivateDefaultProfiles());
|
||||
|
||||
OnInitialized();
|
||||
}
|
||||
|
||||
@@ -82,11 +89,14 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (_modules)
|
||||
if (!ModuleUpdatingDisabled)
|
||||
{
|
||||
// Update all active modules
|
||||
foreach (var module in _modules)
|
||||
module.Update(args.DeltaTime);
|
||||
lock (_modules)
|
||||
{
|
||||
// Update all active modules
|
||||
foreach (var module in _modules)
|
||||
module.Update(args.DeltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
// If there is no ready bitmap brush, skip the frame
|
||||
@@ -102,10 +112,13 @@ namespace Artemis.Core.Services
|
||||
using (var canvas = new SKCanvas(_rgbService.BitmapBrush.Bitmap))
|
||||
{
|
||||
canvas.Clear(new SKColor(0, 0, 0));
|
||||
lock (_modules)
|
||||
if (!ModuleRenderingDisabled)
|
||||
{
|
||||
foreach (var module in _modules)
|
||||
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, canvas);
|
||||
lock (_modules)
|
||||
{
|
||||
foreach (var module in _modules)
|
||||
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, canvas);
|
||||
}
|
||||
}
|
||||
|
||||
OnFrameRendering(new FrameRenderingEventArgs(_modules, canvas, args.DeltaTime, _rgbService.Surface));
|
||||
|
||||
@@ -6,9 +6,18 @@ namespace Artemis.Core.Services.Interfaces
|
||||
public interface ICoreService : IArtemisService, IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates wether or not the core has been initialized
|
||||
/// Gets whether the or not the core has been initialized
|
||||
/// </summary>
|
||||
bool IsInitialized { get; set; }
|
||||
bool IsInitialized { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether modules are updated each frame by calling their Update method
|
||||
/// </summary>
|
||||
bool ModuleUpdatingDisabled { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets whether modules are rendered each frame by calling their Render method
|
||||
/// </summary>
|
||||
bool ModuleRenderingDisabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Occurs the core has finished initializing
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Artemis.Core.Services.Storage.Interfaces
|
||||
{
|
||||
public interface IProfileService : IArtemisService
|
||||
{
|
||||
void ActivateDefaultProfiles();
|
||||
Profile CreateProfile(ProfileModule module, string name);
|
||||
List<Profile> GetProfiles(ProfileModule module);
|
||||
Profile GetActiveProfile(ProfileModule module);
|
||||
|
||||
@@ -14,7 +14,7 @@ using Newtonsoft.Json;
|
||||
namespace Artemis.Core.Services.Storage
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to profile storage
|
||||
/// Provides access to profile storage and is responsible for activating default profiles
|
||||
/// </summary>
|
||||
public class ProfileService : IProfileService
|
||||
{
|
||||
@@ -35,6 +35,14 @@ namespace Artemis.Core.Services.Storage
|
||||
_pluginService.PluginLoaded += OnPluginLoaded;
|
||||
}
|
||||
|
||||
public void ActivateDefaultProfiles()
|
||||
{
|
||||
foreach (var profileModule in _pluginService.GetPluginsOfType<ProfileModule>())
|
||||
{
|
||||
var activeProfile = GetActiveProfile(profileModule);
|
||||
ActivateProfile(profileModule, activeProfile);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Profile> GetProfiles(ProfileModule module)
|
||||
{
|
||||
@@ -204,6 +212,11 @@ namespace Artemis.Core.Services.Storage
|
||||
ActiveProfilesInstantiateProfileLayerBrushes();
|
||||
ActiveProfilesInstantiateKeyframeEngines();
|
||||
}
|
||||
else if (e.PluginInfo.Instance is ProfileModule profileModule)
|
||||
{
|
||||
var activeProfile = GetActiveProfile(profileModule);
|
||||
ActivateProfile(profileModule, activeProfile);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in new issue
Block a user