From 3952a268d12b9d66a1299b413599667aaca7c442 Mon Sep 17 00:00:00 2001 From: RobertBeekman Date: Fri, 2 Feb 2024 09:44:56 +0100 Subject: [PATCH 1/3] Debugger - Fixed current renderer always showing as Software Render service - Log which renderer is used Updating - Fixed release not loading when viewing it from the desktop notification Core - Removed old unused code Data model event cycle node - Fixed crash on shutdown --- src/Artemis.Core/Constants.cs | 6 - src/Artemis.Core/Models/Profile/Renderer.cs | 117 ------------------ src/Artemis.Core/Services/RenderService.cs | 1 + .../WindowsUpdateNotificationProvider.cs | 4 +- .../Performance/PerformanceDebugViewModel.cs | 2 +- .../Tabs/Render/RenderDebugViewModel.cs | 2 +- .../Steps/UploadStepViewModel.cs | 4 +- .../DataModel/DataModelEventCycleNode.cs | 21 +++- 8 files changed, 23 insertions(+), 134 deletions(-) delete mode 100644 src/Artemis.Core/Models/Profile/Renderer.cs 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/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/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/Workshop/SubmissionWizard/Steps/UploadStepViewModel.cs b/src/Artemis.UI/Screens/Workshop/SubmissionWizard/Steps/UploadStepViewModel.cs index 2a21cde43..04eae8c0f 100644 --- a/src/Artemis.UI/Screens/Workshop/SubmissionWizard/Steps/UploadStepViewModel.cs +++ b/src/Artemis.UI/Screens/Workshop/SubmissionWizard/Steps/UploadStepViewModel.cs @@ -82,8 +82,8 @@ public partial class UploadStepViewModel : SubmissionViewModel FailureMessage = e.Message; Failed = true; - // If something went wrong halfway through, delete the entry - if (_entryId != null) + // If something went wrong halfway through, delete the entry if it was new + if (State.EntryId == null && _entryId != null) await _workshopClient.RemoveEntry.ExecuteAsync(_entryId.Value, CancellationToken.None); } finally diff --git a/src/Artemis.VisualScripting/Nodes/DataModel/DataModelEventCycleNode.cs b/src/Artemis.VisualScripting/Nodes/DataModel/DataModelEventCycleNode.cs index b0c8b684a..6ab264a77 100644 --- a/src/Artemis.VisualScripting/Nodes/DataModel/DataModelEventCycleNode.cs +++ b/src/Artemis.VisualScripting/Nodes/DataModel/DataModelEventCycleNode.cs @@ -11,6 +11,7 @@ public class DataModelEventCycleNode : Node public void Dispose() { - if (_dataModelPath?.GetValue() is IDataModelEvent newEvent) - newEvent.EventTriggered -= OnEventTriggered; + if (_subscribedEvent != null) + { + _subscribedEvent.EventTriggered -= OnEventTriggered; + _subscribedEvent = null; + } + _dataModelPath?.Dispose(); } } \ No newline at end of file From a2fe5d5d083fffa301c3c76b383f3e37dcc19e53 Mon Sep 17 00:00:00 2001 From: RobertBeekman Date: Thu, 8 Feb 2024 20:58:16 +0100 Subject: [PATCH 2/3] Settings - Added account management --- src/Artemis.UI/Routing/Routes.cs | 1 + .../LayoutProviders/WorkshopLayoutView.axaml | 5 +- .../WorkshopLayoutViewModel.cs | 1 + .../Account/ChangeEmailAddressView.axaml | 14 ++ .../Account/ChangeEmailAddressView.axaml.cs | 16 +++ .../Account/ChangeEmailAddressViewModel.cs | 50 ++++++++ .../Settings/Account/ChangePasswordView.axaml | 17 +++ .../Account/ChangePasswordView.axaml.cs | 17 +++ .../Account/ChangePasswordViewModel.cs | 47 +++++++ .../Settings/Account/RemoveAccountView.axaml | 14 ++ .../Account/RemoveAccountView.axaml.cs | 16 +++ .../Account/RemoveAccountViewModel.cs | 52 ++++++++ .../Screens/Settings/SettingsViewModel.cs | 1 + .../Settings/Tabs/AccountTabView.axaml | 121 ++++++++++++++++++ .../Settings/Tabs/AccountTabView.axaml.cs | 14 ++ .../Settings/Tabs/AccountTabViewModel.cs | 105 +++++++++++++++ .../CurrentUser/CurrentUserView.axaml | 18 ++- .../CurrentUser/CurrentUserView.axaml.cs | 8 +- .../CurrentUser/CurrentUserViewModel.cs | 10 +- .../Entries/Details/EntryReleasesViewModel.cs | 1 + .../Dialogs/DeviceSelectionDialogViewModel.cs | 1 + .../Workshop/Layout/LayoutDetailsViewModel.cs | 1 + .../Library/SubmissionDetailViewModel.cs | 2 +- .../Library/Tabs/InstalledTabItemViewModel.cs | 1 + .../Library/Tabs/InstalledTabViewModel.cs | 1 + .../Steps/UploadStepViewModel.cs | 4 +- .../DryIoc/ContainerExtensions.cs | 8 +- .../EntryInstallResult.cs | 3 +- .../IEntryInstallationHandler.cs | 1 + .../LayoutEntryInstallationHandler.cs | 1 + .../ProfileEntryInstallationHandler.cs | 1 + .../{ImageUploadResult.cs => ApiResult.cs} | 10 +- .../{Services => Models}/AccessToken.cs | 3 +- .../{Services => Models}/InstalledEntry.cs | 2 +- .../Models/PersonalAccessToken.cs | 3 + .../Providers/WorkshopLayoutProvider.cs | 1 + .../Services/AuthenticationService.cs | 1 + .../Interfaces/IUserManagementService.cs | 16 +++ .../Services/Interfaces/IWorkshopService.cs | 5 +- .../Services/UserManagementService.cs | 103 +++++++++++++++ .../Services/WorkshopService.cs | 14 +- .../WorkshopConstants.cs | 1 + 42 files changed, 681 insertions(+), 30 deletions(-) create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangeEmailAddressView.axaml create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangeEmailAddressView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangeEmailAddressViewModel.cs create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangePasswordView.axaml create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangePasswordView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Settings/Account/ChangePasswordViewModel.cs create mode 100644 src/Artemis.UI/Screens/Settings/Account/RemoveAccountView.axaml create mode 100644 src/Artemis.UI/Screens/Settings/Account/RemoveAccountView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Settings/Account/RemoveAccountViewModel.cs create mode 100644 src/Artemis.UI/Screens/Settings/Tabs/AccountTabView.axaml create mode 100644 src/Artemis.UI/Screens/Settings/Tabs/AccountTabView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Settings/Tabs/AccountTabViewModel.cs rename src/Artemis.WebClient.Workshop/Handlers/UploadHandlers/{ImageUploadResult.cs => ApiResult.cs} (51%) rename src/Artemis.WebClient.Workshop/{Services => Models}/AccessToken.cs (92%) rename src/Artemis.WebClient.Workshop/{Services => Models}/InstalledEntry.cs (99%) create mode 100644 src/Artemis.WebClient.Workshop/Models/PersonalAccessToken.cs create mode 100644 src/Artemis.WebClient.Workshop/Services/Interfaces/IUserManagementService.cs create mode 100644 src/Artemis.WebClient.Workshop/Services/UserManagementService.cs 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/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 + + + + + + + Change avatar + + + + - + - + @@ -45,7 +46,7 @@ - + @@ -54,11 +55,27 @@ + + + + Credentials + + + +