Browse Source

Steam not active handling

Krzysztof Krysiński 2 weeks ago
parent
commit
10d9b0ab84

+ 1 - 0
src/PixiEditor.IdentityProvider.PixiAuth/PixiAuthIdentityProvider.cs

@@ -12,6 +12,7 @@ public class PixiAuthIdentityProvider : IIdentityProvider
     public string ProviderName { get; } = "PixiAuth";
     public string ProviderName { get; } = "PixiAuth";
     public bool AllowsLogout { get; } = true;
     public bool AllowsLogout { get; } = true;
     public bool IsValid => isValid;
     public bool IsValid => isValid;
+    public string InvalidInfo { get; } = "ACCOUNT_PROVIDER_NOT_AVAILABLE";
     private bool isValid = true;
     private bool isValid = true;
     public PixiAuthClient PixiAuthClient { get; }
     public PixiAuthClient PixiAuthClient { get; }
     public PixiUser User { get; private set; }
     public PixiUser User { get; private set; }

+ 1 - 0
src/PixiEditor.IdentityProvider/IIdentityProvider.cs

@@ -8,6 +8,7 @@ public interface IIdentityProvider
     public bool IsLoggedIn { get; }
     public bool IsLoggedIn { get; }
     public Uri? EditProfileUrl { get; }
     public Uri? EditProfileUrl { get; }
     public bool IsValid { get; }
     public bool IsValid { get; }
+    public string InvalidInfo { get; }
 
 
     public event Action<string, object> OnError;
     public event Action<string, object> OnError;
     public event Action<List<ProductData>> OwnedProductsUpdated;
     public event Action<List<ProductData>> OwnedProductsUpdated;

+ 16 - 1
src/PixiEditor.Platform.Steam/SteamIdentityProvider.cs

@@ -12,7 +12,22 @@ public class SteamIdentityProvider : IIdentityProvider
     public IUser User { get; private set; }
     public IUser User { get; private set; }
     public bool IsLoggedIn { get; private set; }
     public bool IsLoggedIn { get; private set; }
     public Uri? EditProfileUrl { get; } = new Uri("https://store.steampowered.com/login/");
     public Uri? EditProfileUrl { get; } = new Uri("https://store.steampowered.com/login/");
-    public bool IsValid => true;
+    public bool IsValid
+    {
+        get
+        {
+            try
+            {
+                return SteamAPI.IsSteamRunning() && User != null;
+            }
+            catch (Exception ex)
+            {
+                return false;
+            }
+        }
+    }
+
+    public string InvalidInfo { get; } = "STEAM_OFFLINE";
     public event Action<string, object>? OnError;
     public event Action<string, object>? OnError;
     public event Action<List<ProductData>>? OwnedProductsUpdated;
     public event Action<List<ProductData>>? OwnedProductsUpdated;
     public event Action<string>? UsernameUpdated;
     public event Action<string>? UsernameUpdated;

+ 2 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -1122,5 +1122,6 @@
   "DECOMPOSE_MATRIX": "Decompose Matrix",
   "DECOMPOSE_MATRIX": "Decompose Matrix",
   "NORMALIZE_COORDINATES": "Normalize Coordinates",
   "NORMALIZE_COORDINATES": "Normalize Coordinates",
   "TRANSFORMED_POSITION": "Transformed Position",
   "TRANSFORMED_POSITION": "Transformed Position",
-  "ACCOUNT_PROVIDER_NOT_AVAILABLE": "This build of PixiEditor does not support accounts. Use the official build from pixieditor.net to manage your account."
+  "ACCOUNT_PROVIDER_NOT_AVAILABLE": "This build of PixiEditor does not support accounts. Use the official build from pixieditor.net to manage your account.",
+  "STEAM_OFFLINE": "Cannot validate the account. Steam is offline. Make sure Steam client is running and you are logged in."
 }
 }

+ 1 - 1
src/PixiEditor/Views/Auth/LoginPopup.axaml

@@ -23,7 +23,7 @@
             IsVisible="{Binding DataContext.IdentityProvider.IsValid, RelativeSource={RelativeSource AncestorType=auth:LoginPopup, Mode=FindAncestor}}"
             IsVisible="{Binding DataContext.IdentityProvider.IsValid, RelativeSource={RelativeSource AncestorType=auth:LoginPopup, Mode=FindAncestor}}"
             Margin="15" DataContext="{Binding}" />
             Margin="15" DataContext="{Binding}" />
         <TextBlock IsVisible="{Binding !DataContext.IdentityProvider.IsValid, RelativeSource={RelativeSource AncestorType=auth:LoginPopup, Mode=FindAncestor}}"
         <TextBlock IsVisible="{Binding !DataContext.IdentityProvider.IsValid, RelativeSource={RelativeSource AncestorType=auth:LoginPopup, Mode=FindAncestor}}"
-                   Text="{localization:Translate Key=ACCOUNT_PROVIDER_NOT_AVAILABLE}"
+                   localization:Translator.Key="{Binding DataContext.IdentityProvider.InvalidInfo, RelativeSource={RelativeSource AncestorType=auth:LoginPopup, Mode=FindAncestor}, FallbackValue=ACCOUNT_PROVIDER_NOT_AVAILABLE}"
                    Margin="15" TextWrapping="Wrap" />
                    Margin="15" TextWrapping="Wrap" />
     </Panel>
     </Panel>
 </dialogs:PixiEditorPopup>
 </dialogs:PixiEditorPopup>