diff --git a/src/Artemis.Core/Constants.cs b/src/Artemis.Core/Constants.cs index 8386f5fcf..ce374ca88 100644 --- a/src/Artemis.Core/Constants.cs +++ b/src/Artemis.Core/Constants.cs @@ -155,10 +155,4 @@ public static class Constants /// Gets the startup arguments provided to the application /// public static ReadOnlyCollection StartupArguments { get; set; } = null!; - - /// - /// Gets the graphics context to be used for rendering by SkiaSharp. - /// - public static IManagedGraphicsContext? ManagedGraphicsContext { get; internal set; } - } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 85683eb49..58c13265f 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -18,7 +18,7 @@ public sealed class Layer : RenderProfileElement { private const string BROKEN_STATE_BRUSH_NOT_FOUND = "Failed to load layer brush, ensure the plugin is enabled"; private const string BROKEN_STATE_INIT_FAILED = "Failed to initialize layer brush"; - + private readonly List _renderCopies = new(); private LayerGeneralProperties _general = new(); private LayerTransformProperties _transform = new(); @@ -735,6 +735,9 @@ public sealed class Layer : RenderProfileElement if (Disposed) throw new ObjectDisposedException("Layer"); + if (_leds.Contains(led)) + return; + _leds.Add(led); CalculateRenderProperties(); } @@ -761,7 +764,9 @@ public sealed class Layer : RenderProfileElement if (Disposed) throw new ObjectDisposedException("Layer"); - _leds.Remove(led); + if (!_leds.Remove(led)) + return; + CalculateRenderProperties(); } @@ -773,6 +778,9 @@ public sealed class Layer : RenderProfileElement if (Disposed) throw new ObjectDisposedException("Layer"); + if (!_leds.Any()) + return; + _leds.Clear(); CalculateRenderProperties(); } @@ -790,7 +798,7 @@ public sealed class Layer : RenderProfileElement { ArtemisLed? match = availableLeds.FirstOrDefault(a => a.Device.Identifier == ledEntity.DeviceIdentifier && a.RgbLed.Id.ToString() == ledEntity.LedName); - if (match != null) + if (match != null && !leds.Contains(match)) leds.Add(match); else _missingLeds.Add(ledEntity); diff --git a/src/Artemis.Core/Models/Profile/Renderer.cs b/src/Artemis.Core/Models/Profile/Renderer.cs deleted file mode 100644 index b72d48319..000000000 --- a/src/Artemis.Core/Models/Profile/Renderer.cs +++ /dev/null @@ -1,117 +0,0 @@ -using System; -using SkiaSharp; - -namespace Artemis.Core; - -internal class Renderer : IDisposable -{ - private bool _disposed; - private SKRect _lastBounds; - private GRContext? _lastGraphicsContext; - private SKRect _lastParentBounds; - private bool _valid; - public SKSurface? Surface { get; private set; } - public SKPaint? Paint { get; private set; } - public SKPath? Path { get; private set; } - public SKPoint TargetLocation { get; private set; } - - public bool IsOpen { get; private set; } - - /// - /// Opens the render context using the dimensions of the provided path - /// - public void Open(SKPath path, Folder? parent) - { - if (_disposed) - throw new ObjectDisposedException("Renderer"); - - if (IsOpen) - throw new ArtemisCoreException("Cannot open render context because it is already open"); - - if (path.Bounds != _lastBounds || (parent != null && parent.Bounds != _lastParentBounds) || _lastGraphicsContext != Constants.ManagedGraphicsContext?.GraphicsContext) - Invalidate(); - - if (!_valid || Surface == null) - { - SKRect pathBounds = path.Bounds; - int width = (int) pathBounds.Width; - int height = (int) pathBounds.Height; - - SKImageInfo imageInfo = new(width, height); - if (Constants.ManagedGraphicsContext?.GraphicsContext == null) - Surface = SKSurface.Create(imageInfo); - else - Surface = SKSurface.Create(Constants.ManagedGraphicsContext.GraphicsContext, true, imageInfo); - - Path = new SKPath(path); - Path.Transform(SKMatrix.CreateTranslation(pathBounds.Left * -1, pathBounds.Top * -1)); - - TargetLocation = new SKPoint(pathBounds.Location.X, pathBounds.Location.Y); - if (parent != null) - TargetLocation -= parent.Bounds.Location; - - Surface.Canvas.ClipPath(Path); - - _lastParentBounds = parent?.Bounds ?? new SKRect(); - _lastBounds = path.Bounds; - _lastGraphicsContext = Constants.ManagedGraphicsContext?.GraphicsContext; - _valid = true; - } - - Paint = new SKPaint(); - - Surface.Canvas.Clear(); - Surface.Canvas.Save(); - - IsOpen = true; - } - - public void Close() - { - if (_disposed) - throw new ObjectDisposedException("Renderer"); - - Surface?.Canvas.Restore(); - - // Looks like every part of the paint needs to be disposed :( - Paint?.ColorFilter?.Dispose(); - Paint?.ImageFilter?.Dispose(); - Paint?.MaskFilter?.Dispose(); - Paint?.PathEffect?.Dispose(); - Paint?.Dispose(); - - Paint = null; - - IsOpen = false; - } - - public void Invalidate() - { - if (_disposed) - throw new ObjectDisposedException("Renderer"); - - _valid = false; - } - - ~Renderer() - { - if (IsOpen) - Close(); - } - - public void Dispose() - { - if (IsOpen) - Close(); - - Surface?.Dispose(); - Paint?.Dispose(); - Path?.Dispose(); - - Surface = null; - Paint = null; - Path = null; - - _disposed = true; - } -} \ No newline at end of file diff --git a/src/Artemis.Core/Services/RenderService.cs b/src/Artemis.Core/Services/RenderService.cs index 26e23ca6f..bd73a0f0d 100644 --- a/src/Artemis.Core/Services/RenderService.cs +++ b/src/Artemis.Core/Services/RenderService.cs @@ -123,6 +123,7 @@ internal class RenderService : IRenderService, IRenderer, IDisposable return; } + _logger.Information("Applying {Name} graphics context", _preferredGraphicsContext.Value); if (_preferredGraphicsContext.Value == "Software") { GraphicsContext = null; diff --git a/src/Artemis.UI.Windows/Providers/WindowsUpdateNotificationProvider.cs b/src/Artemis.UI.Windows/Providers/WindowsUpdateNotificationProvider.cs index 8ca86dd87..ed241cf62 100644 --- a/src/Artemis.UI.Windows/Providers/WindowsUpdateNotificationProvider.cs +++ b/src/Artemis.UI.Windows/Providers/WindowsUpdateNotificationProvider.cs @@ -60,10 +60,10 @@ public class WindowsUpdateNotificationProvider : IUpdateNotificationProvider Dispatcher.UIThread.Invoke(async () => { _mainWindowService.OpenMainWindow(); - if (releaseId != null) + if (releaseId != null && releaseId.Value != Guid.Empty) await _router.Navigate($"settings/releases/{releaseId}"); else - await _router.Navigate($"settings/releases"); + await _router.Navigate("settings/releases"); }); } diff --git a/src/Artemis.UI/Routing/Routes.cs b/src/Artemis.UI/Routing/Routes.cs index e129b384c..1d4862f44 100644 --- a/src/Artemis.UI/Routing/Routes.cs +++ b/src/Artemis.UI/Routing/Routes.cs @@ -64,6 +64,7 @@ public static class Routes new RouteRegistration("{releaseId:guid}") } }, + new RouteRegistration("account"), new RouteRegistration("about") } }, diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs index cefb569dc..0b2bd65a9 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugViewModel.cs @@ -63,7 +63,7 @@ public partial class PerformanceDebugViewModel : ActivatableViewModelBase private void HandleActivation() { - Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software"; + Renderer = _renderService.GraphicsContext?.GetType().Name ?? "Software"; _renderService.FrameRendered += RenderServiceOnFrameRendered; } diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs index b4594eee3..dbf76e823 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugViewModel.cs @@ -35,7 +35,7 @@ public partial class RenderDebugViewModel : ActivatableViewModelBase private void HandleActivation() { - Renderer = Constants.ManagedGraphicsContext != null ? Constants.ManagedGraphicsContext.GetType().Name : "Software"; + Renderer = _renderService.GraphicsContext?.GetType().Name ?? "Software"; _renderService.FrameRendered += RenderServiceOnFrameRendered; } diff --git a/src/Artemis.UI/Screens/Device/Tabs/Layout/LayoutProviders/WorkshopLayoutView.axaml b/src/Artemis.UI/Screens/Device/Tabs/Layout/LayoutProviders/WorkshopLayoutView.axaml index 07a8a7325..38c1e2eef 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/Layout/LayoutProviders/WorkshopLayoutView.axaml +++ b/src/Artemis.UI/Screens/Device/Tabs/Layout/LayoutProviders/WorkshopLayoutView.axaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:services="clr-namespace:Artemis.WebClient.Workshop.Services;assembly=Artemis.WebClient.Workshop" xmlns:layoutProviders="clr-namespace:Artemis.UI.Screens.Device.Layout.LayoutProviders" + xmlns:models="clr-namespace:Artemis.WebClient.Workshop.Models;assembly=Artemis.WebClient.Workshop" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.Device.Layout.LayoutProviders.WorkshopLayoutView" x:DataType="layoutProviders:WorkshopLayoutViewModel"> @@ -19,7 +20,7 @@ + + + You are not logged in + + In order to manage your account you must be logged in. + + Creating an account is free and we'll not bother you with a newsletter or crap like that. + + + + + + Click Log In below to (create an account) and log in. + + You'll also be able to log in with Google or Discord. + + + + + + + + + + + + + + + + + + + + Account management + + + + + + + Credentials + + + +