浏览代码

Merge pull request #570 from PixiEditor/removed-steam-overlay

Removed Steam Overlay and added loading screen
Krzysztof Krysiński 2 年之前
父节点
当前提交
81fafcc531

+ 1 - 1
src/PixiEditor.Platform.Steam/OverlayHandler.cs

@@ -17,7 +17,7 @@ public class SteamOverlayHandler
 
     private void InitStartingRefresh()
     {
-        System.Timers.Timer timer = new(10000);
+        System.Timers.Timer timer = new(11000);
         timer.Elapsed += (sender, args) =>
         {
             if (_isOverlayActive) return;

+ 3 - 1
src/PixiEditor.Platform.Steam/SteamAdditionalContentProvider.cs

@@ -11,10 +11,12 @@ public sealed class SteamAdditionalContentProvider : IAdditionalContentProvider
 
     public bool IsContentInstalled(AdditionalContentProduct product)
     {
+        if(!SteamAPI.IsSteamRunning()) return false;
         if(!PlatformHasContent(product)) return false;
 
         AppId_t appId = productIds[product];
-        return SteamApps.BIsDlcInstalled(appId);
+        bool installed = SteamApps.BIsDlcInstalled(appId);
+        return installed;
     }
 
     public bool PlatformHasContent(AdditionalContentProduct product)

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

@@ -1,4 +1,5 @@
 using Steamworks;
+using Timer = System.Timers.Timer;
 
 namespace PixiEditor.Platform.Steam;
 

+ 7 - 1
src/PixiEditor/App.xaml.cs

@@ -55,6 +55,8 @@ internal partial class App : Application
         }
         #endif
 
+        LoadingWindow.ShowInNewThread();
+
         AddNativeAssets();
 
         InitPlatform();
@@ -63,7 +65,11 @@ internal partial class App : Application
         extensionLoader.LoadExtensions();
 
         MainWindow = new MainWindow(extensionLoader);
-
+        MainWindow.ContentRendered += (_, _) =>
+        {
+            LoadingWindow.Instance.SafeClose();
+            MainWindow.Activate();
+        };
         MainWindow.Show();
     }
 

+ 2 - 2
src/PixiEditor/Properties/AssemblyInfo.cs

@@ -50,5 +50,5 @@ using System.Windows;
 // You can specify all the values or you can default the Build and Revision Numbers
 // by using the '*' as shown below:
 // [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.1.1")]
-[assembly: AssemblyFileVersion("1.2.1.1")]
+[assembly: AssemblyVersion("1.2.1.2")]
+[assembly: AssemblyFileVersion("1.2.1.2")]

+ 3 - 2
src/PixiEditor/ViewModels/ViewModelMain.cs

@@ -171,9 +171,10 @@ internal class ViewModelMain : ViewModelBase
 
     private void InitUpdateTimer()
     {
-        _updateTimer = new Timer(50);
+        // Enable this while implementing something that needs it
+        /*_updateTimer = new Timer(50);
         _updateTimer.Elapsed += UpdateTimerOnElapsed;
-        _updateTimer.Start();
+        _updateTimer.Start();*/
     }
 
     private void UpdateTimerOnElapsed(object sender, ElapsedEventArgs e)

+ 27 - 0
src/PixiEditor/Views/LoadingWindow.xaml

@@ -0,0 +1,27 @@
+<Window x:Class="PixiEditor.Views.LoadingWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:local="clr-namespace:PixiEditor.Views"
+        xmlns:gif="http://wpfanimatedgif.codeplex.com"
+        mc:Ignorable="d" ShowInTaskbar="False" WindowStyle="None"
+        ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
+        Title="LoadingWindow" Height="180" Width="160"
+        Background="Transparent"
+        AllowsTransparency="True"
+        x:Name="Window">
+    <Border Background="{StaticResource AccentColor}"
+            BorderBrush="{StaticResource MainColor}" BorderThickness="1.5"
+            CornerRadius="10">
+        <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
+            <Image
+                gif:ImageBehavior.AnimatedSource="{Binding LoadingImage, ElementName=Window}"
+                Height="70"
+                gif:ImageBehavior.AnimationSpeedRatio="1.5"/>
+            <TextBlock Foreground="White" Text="PixiEditor"
+                       FontFamily="Roboto" FontWeight="900" FontSize="28"
+                       Margin="0,10,0,0"/>
+        </StackPanel>
+    </Border>
+</Window>

+ 43 - 0
src/PixiEditor/Views/LoadingWindow.xaml.cs

@@ -0,0 +1,43 @@
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Threading;
+
+namespace PixiEditor.Views;
+
+public partial class LoadingWindow : Window
+{
+    public static LoadingWindow Instance { get; private set; }
+
+    public ImageSource LoadingImage { get; } = new BitmapImage(new Uri("pack://application:,,,/images/processing.gif"));
+    
+    public LoadingWindow()
+    {
+        InitializeComponent();
+    }
+
+    public static void ShowInNewThread()
+    {
+        var thread = new Thread(ThreadStart) { IsBackground = true };
+
+        thread.SetApartmentState(ApartmentState.STA);
+        thread.Start();
+    }
+
+    public void SafeClose()
+    {
+        Dispatcher.Invoke(Close);
+    }
+
+    private static void ThreadStart()
+    {
+        Instance = new LoadingWindow();
+        Instance.Show();
+
+        Instance.Closed += (_, _) =>
+            Instance.Dispatcher.InvokeShutdown();
+
+        Dispatcher.Run();
+    }
+}
+

+ 0 - 2
src/PixiEditor/Views/MainWindow.xaml

@@ -101,8 +101,6 @@
         </b:EventTrigger>
     </b:Interaction.Triggers>
     <Grid>
-        <usercontrols:SteamOverlay x:Name="steamRefresher" Width="{Binding ElementName=mainWindow, Path=Width}"
-                                   Height="{Binding ElementName=mainWindow, Path=Height}"/>
         <Grid
             Name="mainGrid"
             Margin="5"

+ 1 - 26
src/PixiEditor/Views/MainWindow.xaml.cs

@@ -57,8 +57,8 @@ internal partial class MainWindow : Window
 
         preferences = services.GetRequiredService<IPreferences>();
         platform = services.GetRequiredService<IPlatform>();
-        DataContext = services.GetRequiredService<ViewModelMain>();
 
+        DataContext = services.GetRequiredService<ViewModelMain>();
         DataContext.Setup(services);
 
         InitializeComponent();
@@ -79,31 +79,6 @@ internal partial class MainWindow : Window
         });
 
         DataContext.DocumentManagerSubViewModel.ActiveDocumentChanged += DocumentChanged;
-
-        StartSteamRefresher();
-    }
-
-    private void StartSteamRefresher()
-    {
-#if STEAM
-        steamRefresher.Activate();
-
-        var handler = new PixiEditor.Platform.Steam.SteamOverlayHandler();
-        handler.ActivateRefreshingElement += (bool activate) =>
-        {
-            Application.Current.Dispatcher.Invoke(() =>
-            {
-                if (activate)
-                {
-                    steamRefresher.Activate();
-                }
-                else
-                {
-                    steamRefresher.Deactivate();
-                }
-            });
-        };
-#endif
     }
 
     private void SetupTranslator()

+ 5 - 6
src/PixiEditor/Views/UserControls/SteamOverlay.xaml

@@ -6,13 +6,12 @@
              xmlns:local="clr-namespace:PixiEditor.Views.UserControls"
              Name="uc"
              mc:Ignorable="d">
-    <Border HorizontalAlignment="Right" VerticalAlignment="Bottom"
-            Background="Transparent"
-            BorderThickness="0"
-            Width="{Binding Width, ElementName=uc}"
+    <Grid
+          Width="{Binding Width, ElementName=uc}"
             Height="{Binding Height, ElementName=uc}"
+          Background="Transparent"
             Focusable="False"
             Panel.ZIndex="-1000"
-            Name="refresher">
-    </Border>
+            x:Name="refresher">
+    </Grid>
 </UserControl>