Bläddra i källkod

Founders Edition setup

Krzysztof Krysiński 3 månader sedan
förälder
incheckning
11c3d9301d

+ 1 - 1
src/ColorPicker

@@ -1 +1 @@
-Subproject commit 78237e9c5d70ebd878b34f4dd63f54b25bafea23
+Subproject commit 56faff5afcc6fc96b44b5caa6f15d0b3a902cd0a

+ 8 - 1
src/Directory.Build.props

@@ -50,7 +50,14 @@
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)'=='Release'">
-    <DefineConstants>TRACE;UPDATE</DefineConstants>
+    <DefineConstants>TRACE;UPDATE;RELEASE</DefineConstants>
+    <DebugSymbols>False</DebugSymbols>
+    <DebugType>None</DebugType>
+    <Optimize>true</Optimize>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)'=='ReleaseFoundersEdition'">
+    <DefineConstants>TRACE;UPDATE;RELEASE;FOUNDERS_PACK_REQUIRED</DefineConstants>
     <DebugSymbols>False</DebugSymbols>
     <DebugType>None</DebugType>
     <Optimize>true</Optimize>

+ 0 - 4
src/PixiEditor.Platform.Standalone/StandaloneAdditionalContentProvider.cs

@@ -97,11 +97,7 @@ public sealed class StandaloneAdditionalContentProvider : IAdditionalContentProv
 
     public bool PlatformHasContent(string product)
     {
-#if DEBUG
         return true;
-#else
-        return false;
-#endif
     }
 
     public void Error(string error)

+ 5 - 5
src/PixiEditor/Helpers/VersionHelpers.cs

@@ -39,15 +39,15 @@ internal static class VersionHelpers
     public static string GetBuildId()
     {
 #if DEBUG
-        return "BetaDebug";
+        return "Debug";
 #elif DEVRELEASE
-        return "BetaDevRelease";
+        return "DevRelease";
 #elif STEAM
-        return "BetaSteam";
+        return "Steam";
 #elif RELEASE
-        return "BetaRelease";
+        return "Release";
 #elif MSIX
-        return "BetaMSIX";
+        return "MSIX";
 #else
         #error No build name configured for this configuration
 #endif

+ 73 - 2
src/PixiEditor/Initialization/ClassicDesktopEntry.cs

@@ -5,16 +5,21 @@ using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Platform.Storage;
 using Avalonia.Threading;
 using Avalonia.Xaml.Interactivity;
+using Microsoft.Extensions.DependencyInjection;
+using PixiEditor.Extensions;
 using PixiEditor.Extensions.Runtime;
 using PixiEditor.Helpers;
 using PixiEditor.Helpers.Behaviours;
+using PixiEditor.IdentityProvider;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.ExceptionHandling;
 using PixiEditor.Models.IO;
 using PixiEditor.OperatingSystem;
 using PixiEditor.Platform;
 using PixiEditor.UI.Common.Controls;
+using PixiEditor.ViewModels.SubViewModels;
 using PixiEditor.Views;
+using PixiEditor.Views.Auth;
 using PixiEditor.Views.Dialogs;
 using ViewModels_ViewModelMain = PixiEditor.ViewModels.ViewModelMain;
 
@@ -22,9 +27,14 @@ namespace PixiEditor.Initialization;
 
 internal class ClassicDesktopEntry
 {
+    public ServiceProvider? Services { get; private set; }
     private IClassicDesktopStyleApplicationLifetime desktop;
     private bool restartQueued = false;
+
+    private LoginPopup? loginPopup = null!;
+
     public static ClassicDesktopEntry? Active { get; private set; }
+
     public ClassicDesktopEntry(IClassicDesktopStyleApplicationLifetime desktop)
     {
         this.desktop = desktop;
@@ -34,7 +44,7 @@ internal class ClassicDesktopEntry
         {
             activable.Activated += ActivableOnActivated;
         }
-        
+
         Active = this;
 
         desktop.Startup += Start;
@@ -108,9 +118,57 @@ internal class ClassicDesktopEntry
 #endif
 
         var extensionLoader = InitApp(safeMode);
+        ViewModels_ViewModelMain viewModel = Services.GetRequiredService<ViewModels_ViewModelMain>();
+        viewModel.Setup(Services);
 
+#if FOUNDERS_PACK_REQUIRED
+        if (!IsFoundersPackOwner())
+        {
+            IPlatform.Current.IdentityProvider.OwnedProductsUpdated += IdentityProviderOnOwnedProductsUpdated;
+            loginPopup = new LoginPopup();
+            loginPopup.SystemDecorations = SystemDecorations.BorderOnly;
+            loginPopup.CanMinimize = false;
+            loginPopup.DataContext = viewModel.UserViewModel;
+            loginPopup.ShowStandalone();
+            loginPopup.Closed += (_, _) =>
+            {
+                if (IsFoundersPackOwner())
+                {
+                    desktop.MainWindow = new MainWindow(extensionLoader);
+                    desktop.MainWindow.Show();
+                }
+                else
+                {
+                    desktop.Shutdown();
+                }
+            };
+        }
+        else
+        {
+            
+            desktop.MainWindow = new MainWindow(extensionLoader);
+            desktop.MainWindow.Show();
+        }
+#else
         desktop.MainWindow = new MainWindow(extensionLoader);
         desktop.MainWindow.Show();
+#endif
+    }
+
+    private void IdentityProviderOnOwnedProductsUpdated(List<ProductData> obj)
+    {
+        if (IsFoundersPackOwner())
+        {
+            IPlatform.Current.IdentityProvider.OwnedProductsUpdated -= IdentityProviderOnOwnedProductsUpdated;
+            loginPopup?.Close();
+            loginPopup = null!;
+        }
+    }
+
+    private static bool IsFoundersPackOwner()
+    {
+        return IPlatform.Current.IdentityProvider.IsLoggedIn &&
+               IPlatform.Current.AdditionalContentProvider.IsContentOwned("PixiEditor.FoundersPack");
     }
 
     private void InitPlatform()
@@ -128,6 +186,11 @@ internal class ClassicDesktopEntry
 
         NumberInput.AttachGlobalBehaviors += AttachGlobalShortcutBehavior;
 
+        if (!Directory.Exists(Paths.LocalExtensionPackagesPath))
+        {
+            Directory.CreateDirectory(Paths.LocalExtensionPackagesPath);
+        }
+
         ExtensionLoader extensionLoader = new ExtensionLoader(
             [Paths.InstallDirExtensionPackagesPath, Paths.LocalExtensionPackagesPath], Paths.UserExtensionsPath);
         if (!safeMode)
@@ -135,6 +198,14 @@ internal class ClassicDesktopEntry
             extensionLoader.LoadExtensions();
         }
 
+        Services = new ServiceCollection()
+            .AddPlatform()
+            .AddPixiEditor(extensionLoader)
+            .AddExtensionServices(extensionLoader)
+            .BuildServiceProvider();
+
+        extensionLoader.Services = new ExtensionServices(Services);
+
         return extensionLoader;
     }
 
@@ -209,7 +280,7 @@ internal class ClassicDesktopEntry
 
         return match.Success;
     }
-    
+
     public void Restart()
     {
         restartQueued = true;

+ 4 - 9
src/PixiEditor/PixiEditor.csproj

@@ -68,6 +68,10 @@
   <ItemGroup Condition=" '$(Configuration)' == 'DevRelease' ">
     <ProjectReference Include="..\PixiEditor.Platform.Standalone\PixiEditor.Platform.Standalone.csproj"/>
   </ItemGroup>
+  
+  <ItemGroup Condition=" '$(Configuration)' == 'ReleaseFoundersEdition' ">
+    <ProjectReference Include="..\PixiEditor.Platform.Standalone\PixiEditor.Platform.Standalone.csproj"/>
+  </ItemGroup>
 
   <ItemGroup Condition=" '$(Configuration)' == 'MSIX' ">
     <ProjectReference Include="..\PixiEditor.Platform.MSStore\PixiEditor.Platform.MSStore.csproj"/>
@@ -81,10 +85,6 @@
     <AvaloniaResource Include="Images\**"/>
     <AvaloniaResource Include="Fonts\**"/>
     <AvaloniaResource Include="Data\**"/>
-    <AvaloniaResource Include="Data\Languages\**"/>
-    <AvaloniaResource Include="Data\ShortcutActionMaps\**"/>
-    <AvaloniaResource Include="Data\BetaExampleFiles\**"/>
-    <AvaloniaResource Include="Data\Configs\**"/>
   </ItemGroup>
 
   <ItemGroup>
@@ -148,9 +148,4 @@
     <Folder Include="Models\User\"/>
   </ItemGroup>
 
-  <ItemGroup>
-    <UpToDateCheckInput Remove="Fonts\NodeIcons.cs" />
-    <UpToDateCheckInput Remove="Fonts\nodeicons.ttf" />
-  </ItemGroup>
-
 </Project>

+ 7 - 4
src/PixiEditor/ViewModels/SubViewModels/ClipboardViewModel.cs

@@ -26,6 +26,7 @@ using PixiEditor.Models.Commands;
 using PixiEditor.UI.Common.Fonts;
 using PixiEditor.ViewModels.Dock;
 using PixiEditor.ViewModels.Document;
+using PixiEditor.Views;
 
 namespace PixiEditor.ViewModels.SubViewModels;
 #nullable enable
@@ -42,10 +43,12 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
     public ClipboardViewModel(ViewModelMain owner)
         : base(owner)
     {
-        Application.Current.ForDesktopMainWindow((mainWindow) =>
-        {
-            ClipboardController.Initialize(mainWindow.Clipboard);
-        });
+        owner.AttachedToWindow += AttachClipboard;
+    }
+
+    private void AttachClipboard(MainWindow window)
+    {
+        ClipboardController.Initialize(window.Clipboard);
     }
 
     [Command.Basic("PixiEditor.Clipboard.Cut", "CUT", "CUT_DESCRIPTIVE", CanExecute = "PixiEditor.Selection.IsNotEmpty",

+ 11 - 9
src/PixiEditor/ViewModels/SubViewModels/IoViewModel.cs

@@ -55,15 +55,6 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
         // TODO: Implement mouse capturing
         //GlobalMouseHook.Instance.OnMouseUp += mouseFilter.MouseUpInlet;
 
-        if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
-        {
-            desktop.MainWindow.KeyDown += MainWindowKeyDown;
-            desktop.MainWindow.KeyUp += MainWindowKeyUp;
-
-            desktop.MainWindow.Deactivated += keyboardFilter.DeactivatedInlet;
-            desktop.MainWindow.Deactivated += mouseFilter.DeactivatedInlet;
-        }
-
         mouseFilter.OnMouseDown += OnMouseDown;
         mouseFilter.OnMouseMove += OnMouseMove;
         mouseFilter.OnMouseUp += OnMouseUp;
@@ -74,6 +65,17 @@ internal class IoViewModel : SubViewModel<ViewModelMain>
 
         keyboardFilter.OnConvertedKeyDown += OnConvertedKeyDown;
         keyboardFilter.OnConvertedKeyUp += OnConvertedKeyDown;
+        
+        Owner.AttachedToWindow += AttachWindowEvents;
+    }
+
+    public void AttachWindowEvents(MainWindow mainWindow)
+    {
+        mainWindow.KeyDown += MainWindowKeyDown;
+        mainWindow.KeyUp += MainWindowKeyUp;
+
+        mainWindow.Deactivated += keyboardFilter.DeactivatedInlet;
+        mainWindow.Deactivated += mouseFilter.DeactivatedInlet;
     }
 
     private void OnLayoutManagerOnWindowFloated(HostWindow window)

+ 1 - 1
src/PixiEditor/ViewModels/SubViewModels/UserViewModel.cs

@@ -92,7 +92,7 @@ internal class UserViewModel : SubViewModel<ViewModelMain>
 #if STEAM
         "https://store.steampowered.com/app/2435860/PixiEditor__Supporter_Pack/";
 #else
-        "https://pixieditor.net/purchase/";
+        "https://pixieditor.net/download/";
 #endif
 
     public UserViewModel(ViewModelMain owner) : base(owner)

+ 8 - 0
src/PixiEditor/ViewModels/ViewModelMain.cs

@@ -26,6 +26,7 @@ using PixiEditor.ViewModels.Menu;
 using PixiEditor.ViewModels.SubViewModels;
 using PixiEditor.ViewModels.SubViewModels.AdditionalContent;
 using PixiEditor.ViewModels.Tools;
+using PixiEditor.Views;
 using PixiEditor.Views.Dialogs;
 
 namespace PixiEditor.ViewModels;
@@ -98,6 +99,8 @@ internal partial class ViewModelMain : ViewModelBase, ICommandsHandler
 
     public event Action<DocumentViewModel> BeforeDocumentClosed;
     public event Action<LazyDocumentViewModel> LazyDocumentClosed;
+    
+    public event Action<MainWindow> AttachedToWindow;
 
     public ViewModelMain()
     {
@@ -400,4 +403,9 @@ internal partial class ViewModelMain : ViewModelBase, ICommandsHandler
             viewport.CenterViewportTrigger.Execute(this, viewport.GetRenderOutputSize());
         }
     }
+
+    public void AttachToWindow(MainWindow mainWindow)
+    {
+        AttachedToWindow?.Invoke(mainWindow);
+    }
 }

+ 5 - 0
src/PixiEditor/Views/Dialogs/PixiEditorPopup.cs

@@ -125,6 +125,11 @@ public partial class PixiEditorPopup : Window, IPopupWindow
     {
         Show(MainWindow.Current);
     }
+    
+    public void ShowStandalone()
+    {
+        base.Show();
+    }
 
     public AsyncCall<bool?> ShowDialog()
     {

+ 10 - 12
src/PixiEditor/Views/MainWindow.axaml.cs

@@ -32,9 +32,9 @@ namespace PixiEditor.Views;
 
 internal partial class MainWindow : Window
 {
-    private readonly IPreferences preferences;
-    private readonly IPlatform platform;
-    private readonly IServiceProvider services;
+    private IPreferences preferences;
+    private IPlatform platform;
+    private IServiceProvider services;
     private static ExtensionLoader extLoader;
 
     private MainTitleBar titleBar;
@@ -64,22 +64,20 @@ internal partial class MainWindow : Window
         StartupPerformance.ReportToMainWindow();
 
         (Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime).MainWindow = this;
+        
         extLoader = extensionLoader;
-
-        services = new ServiceCollection()
-            .AddPlatform()
-            .AddPixiEditor(extensionLoader)
-            .AddExtensionServices(extensionLoader)
-            .BuildServiceProvider();
-
+        
         AsyncImageLoader.ImageLoader.AsyncImageLoader =
             new DiskCachedWebImageLoader(Path.Combine(Paths.TempFilesPath, "ImageCache"));
 
+        services = ClassicDesktopEntry.Active.Services;
+        
         preferences = services.GetRequiredService<IPreferences>();
         platform = services.GetRequiredService<IPlatform>();
         DataContext = services.GetRequiredService<ViewModels_ViewModelMain>();
-        DataContext.Setup(services);
-        extensionLoader.Services = new ExtensionServices(services);
+
+        DataContext.AttachToWindow(this);
+        
         StartupPerformance.ReportToMainViewModel();
 
         var analytics = services.GetService<AnalyticsPeriodicReporter>();