Fixed a bug when starting the server manager and it tries to download steamcmd, but fails as steamcmd is unavailable for download.

This commit is contained in:
Brett Hewitson 2021-12-15 14:55:32 +10:00
parent 8ed965307a
commit dbeaa7699d
11 changed files with 94 additions and 27 deletions

View file

@ -17,6 +17,7 @@
<ProgressBar x:Name="CompletionProgress" Height="10"/>
<Label x:Name="StatusLabel" Content="{DynamicResource AutoUpdater_Status}" HorizontalContentAlignment="Center"/>
<Button Content="{DynamicResource AutoUpdater_CancelButtonLabel}" Width="75" HorizontalAlignment="Center" IsCancel="True" Click="Button_Click"/>
<TextBlock x:Name="ErrorLabel" Text="Error Text" Margin="0,2,0,0" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold" Foreground="{DynamicResource WarningMessage}"/>
</StackPanel>
</Grid>
</Window>

View file

@ -2,6 +2,7 @@
using ServerManagerTool.Common.Utils;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using WPFSharp.Globalizer;
@ -12,15 +13,16 @@ namespace ServerManagerTool
/// </summary>
public partial class AutoUpdateWindow : Window
{
private GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
private SteamCmdUpdater updater = new SteamCmdUpdater();
private readonly GlobalizedApplication _globalizer = GlobalizedApplication.Instance;
private readonly SteamCmdUpdater updater = new SteamCmdUpdater();
private CancellationTokenSource cancelSource;
public AutoUpdateWindow()
{
InitializeComponent();
WindowUtils.RemoveDefaultResourceDictionary(this, Config.Default.DefaultGlobalizationFile);
this.ErrorLabel.Visibility = Visibility.Collapsed;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
@ -32,10 +34,13 @@ namespace ServerManagerTool
this.StatusLabel.Content = message;
this.CompletionProgress.Value = u.CompletionPercent;
if(u.FailureText != null)
if (u.FailureText != null)
{
// TODO: Report error through UI
throw new Exception(u.FailureText);
this.ErrorLabel.Text = u.FailureText;
this.ErrorLabel.Visibility = Visibility.Visible;
await Task.Delay(10000);
Environment.Exit(1);
}
if (u.CompletionPercent >= 100 || u.Cancelled)