Explorar o código

Login check in onboarding

Krzysztof Krysiński hai 1 mes
pai
achega
0367560b3a

+ 19 - 8
src/PixiEditor.Platform.Steam/SteamAdditionalContentProvider.cs

@@ -11,14 +11,17 @@ public sealed class SteamAdditionalContentProvider : IAdditionalContentProvider
     {
         if (!SteamAPI.IsSteamRunning()) return false;
         if (string.IsNullOrEmpty(product)) return false;
-        if (!PlatformHasContent(product)) return false;
+
+        string productLower = product.ToLowerInvariant();
+
+        if (!PlatformHasContent(productLower)) return false;
 
         AppId_t appId = new AppId_t(0);
-        if (dlcMap.TryGetValue(product, out var value))
+        if (dlcMap.TryGetValue(productLower, out var value))
         {
             appId = value;
         }
-        else if (!uint.TryParse(product, out uint id))
+        else if (!uint.TryParse(productLower, out uint id))
         {
             OnError?.Invoke("INVALID_PRODUCT_ID", product);
             return false;
@@ -34,15 +37,19 @@ public sealed class SteamAdditionalContentProvider : IAdditionalContentProvider
 
     public async Task<string?> InstallContent(string productId)
     {
+        if (string.IsNullOrEmpty(productId)) return null;
+
+        string productLower = productId.ToLowerInvariant();
+
         if (!SteamAPI.IsSteamRunning()) return null;
-        if (!PlatformHasContent(productId)) return null;
+        if (!PlatformHasContent(productLower)) return null;
 
         AppId_t appId = new AppId_t(0);
-        if (dlcMap.TryGetValue(productId, out var value))
+        if (dlcMap.TryGetValue(productLower, out var value))
         {
             appId = value;
         }
-        else if (!uint.TryParse(productId, out uint id))
+        else if (!uint.TryParse(productLower, out uint id))
         {
             OnError?.Invoke("INVALID_PRODUCT_ID", productId);
             return null;
@@ -121,12 +128,16 @@ public sealed class SteamAdditionalContentProvider : IAdditionalContentProvider
 
     public bool IsInstalled(string productId)
     {
+        if (string.IsNullOrEmpty(productId)) return false;
+
+        string productIdLower = productId.ToLowerInvariant();
+
         AppId_t appId = new AppId_t(0);
-        if (dlcMap.TryGetValue(productId, out var value))
+        if (dlcMap.TryGetValue(productIdLower, out var value))
         {
             appId = value;
         }
-        else if (!uint.TryParse(productId, out uint id))
+        else if (!uint.TryParse(productIdLower, out uint id))
         {
             return false;
         }

+ 4 - 1
src/PixiEditor.Platform.Steam/SteamPlatform.cs

@@ -13,14 +13,17 @@ public class SteamPlatform : IPlatform
     {
         try
         {
+            Console.WriteLine("Initializing Steam API...");
             bool initialized = SteamAPI.Init();
+            Console.WriteLine($"Steam API initialized: {initialized}");
             if (!initialized) return false;
 
             IdentityProvider?.Initialize();
             return true;
         }
-        catch
+        catch (Exception ex)
         {
+            Console.WriteLine($"Error initializing Steam API: {ex.Message}");
             return false;
         }
     }

+ 11 - 0
src/PixiEditor/ViewModels/UserPreferences/OnboardingViewModel.cs

@@ -4,9 +4,11 @@ using Avalonia.Threading;
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
 using Drawie.Numerics;
+using PixiEditor.IdentityProvider;
 using PixiEditor.Models.Commands;
 using PixiEditor.Models.Commands.Templates;
 using PixiEditor.Models.Handlers;
+using PixiEditor.Platform;
 using PixiEditor.UI.Common.Localization;
 using PixiEditor.ViewModels.SubViewModels;
 using PixiEditor.ViewModels.UserPreferences.Settings;
@@ -71,6 +73,7 @@ internal class OnboardingViewModel : PixiObservableObject
     public RelayCommand<IToolSetHandler> SelectToolsetCommand { get; }
 
     public string FoundersBundleLink => UserViewModel.FoundersBundleLink;
+    public bool ShowLoginButton => !(IPlatform.Current?.IdentityProvider?.IsLoggedIn) ?? true;
 
     Dictionary<string, VecI> DefaultNewFileSizes = new()
     {
@@ -84,6 +87,14 @@ internal class OnboardingViewModel : PixiObservableObject
         NextFormStepCommand = new RelayCommand(NextFormStep, CanNextFormStep);
         PreviousFormStepCommand = new RelayCommand(PreviousFormStep, CanPreviousFormStep);
 
+        bool showFoundersBundle = ViewModelMain.Current.UserViewModel.OwnedProducts
+            .All(x => x.ProductData.Id != "2435860" && x.ProductData.Id != "PixiEditor.FoundersPack");
+
+        if (!showFoundersBundle)
+        {
+            AllFormSteps.RemoveAt(AllFormSteps.Count - 1);
+        }
+
         SelectToolsetCommand = new RelayCommand<IToolSetHandler>(x =>
         {
             foreach (var toolset in ToolSets)

+ 1 - 0
src/PixiEditor/Views/Dialogs/OnboardingDialog.axaml

@@ -283,6 +283,7 @@
                     <StackPanel Spacing="12" HorizontalAlignment="Center" DockPanel.Dock="Bottom"
                                 Orientation="Horizontal">
                         <Button ui:Translator.Key="LOGIN"
+                                IsVisible="{Binding ShowLoginButton}"
                                 Command="{xaml:Command Name=PixiEditor.Window.OpenAccountWindow}"
                                 Background="Transparent" Padding="8, 4" />
                         <Button ui:Translator.Key="BECOME_A_FOUNDER" Background="Transparent"