Skip to content

Commit

Permalink
Fixed update button clicks not getting registered, fixed update proce…
Browse files Browse the repository at this point in the history
…ss being unable to proceed past downloading files
  • Loading branch information
BlackTasty committed Mar 17, 2024
1 parent 48c15c4 commit 50e70dc
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
2 changes: 2 additions & 0 deletions SLC_LayoutEditor/Controls/Updater.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private void SearchUpdates_Click(object sender, RoutedEventArgs e)
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
vm.IsPressed = true;
e.Handled = true;
}

private void Grid_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
Expand All @@ -49,6 +50,7 @@ private void Grid_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e
{
ProceedThroughUpdate();
vm.IsPressed = false;
e.Handled = true;
}
}

Expand Down
14 changes: 4 additions & 10 deletions SLC_LayoutEditor/Core/Patcher/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private void SearchForUpdates()
Util.SafeDeleteFile(versionFilePath);
isPullingVersionFile = true;
DownloadFile("version.txt", versionFilePath, false);
isPullingVersionFile = false;
}
else
{
Expand Down Expand Up @@ -333,9 +334,9 @@ private void DownloadFile(string fileName, string targetDir, bool notifyProgress

using (WebClient wc = new WebClient())
{
wc.DownloadFileCompleted += DownloadFileCompleted;
if (notifyProgress)
{
wc.DownloadFileCompleted += DownloadFileCompleted;
wc.DownloadProgressChanged += DownloadChanged;
downloadSpeedStopWatch.Start();
wc.DownloadFileAsync(new Uri(targetServer.URL + fileName), targetDir);
Expand Down Expand Up @@ -372,15 +373,8 @@ public string CalculateSpeed(long bytesReceived)

private void DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
if (!isPullingVersionFile)
{
downloadSpeedStopWatch.Reset();
InstallUpdate();
}
else
{
isPullingVersionFile = false;
}
downloadSpeedStopWatch.Reset();
InstallUpdate();
}

private void DownloadChanged(object sender, DownloadProgressChangedEventArgs e)
Expand Down
3 changes: 2 additions & 1 deletion SLC_LayoutEditor/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
<Button Content="Return to editor" Click="ReturnToEditor_Click" FontSize="12"
DockPanel.Dock="Right" Margin="24,0,24,0"
Visibility="{Binding IsViewNotEditor, Converter={StaticResource BooleanToVisibilityConverter}}"/>
<controls:Updater DockPanel.Dock="Right" Margin="32,0,8,0" InstallUpdateClicked="Updater_InstallUpdateClicked"/>
<controls:Updater DockPanel.Dock="Right" Margin="32,0,8,0" InstallUpdateClicked="Updater_InstallUpdateClicked"
x:Name="updater"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{TemplateBinding Title}" Style="{StaticResource Title3TextStyle}"
Margin="8,0" VerticalAlignment="Center"/>
Expand Down
2 changes: 1 addition & 1 deletion SLC_LayoutEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private void InitHeader(UIElement header)
if (e.ClickCount == 2)
{
if (e.OriginalSource is FrameworkElement originalSource &&
(originalSource.Name == "panel_historyButtons" ||
(originalSource.Name == "panel_historyButtons" || originalSource.Name == "updater" ||
(originalSource.Name == "panel_guideStepper" && App.GuidedTour.IsTourRunning)
))
{
Expand Down
4 changes: 2 additions & 2 deletions SLC_LayoutEditor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// 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.6.6.1")]
[assembly: AssemblyFileVersion("1.6.6.1")]
[assembly: AssemblyVersion("1.6.6.2")]
[assembly: AssemblyFileVersion("1.6.6.2")]
2 changes: 2 additions & 0 deletions SLC_LayoutEditor/Resources/patchnotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ Added: Two new default templates have been added ("B744 - Boeing 747-400" and "B
Changed: Added some more logging to the undo/redo system
Changed: The undo and redo commands (Ctrl+Z and Ctrl+Y) are now only available if no dialog or guide overlay is open or the current view is not the editor (e.g. settings)
Fixed: Potential fix for a crash when undoing/redoing a step
Fixed: Clicking the update button would most of the time not be registered
Fixed: The update process was unable to proceed past downloading
Fixed: "Rows" and "Columns" texts have been swapped
Fixed: When undoing or redoing multiple steps, the editor no longer checks for issues for every step
4 changes: 2 additions & 2 deletions SLC_LayoutEditor/ViewModel/UpdaterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,9 @@ private void UpdateManager_UpdateFailed(object sender, UpdateFailedEventArgs e)
private void UpdateManager_DownloadProgressChanged(object sender, System.Net.DownloadProgressChangedEventArgs e)
{
UpdateText = "Downloading - " +
Math.Round((e.BytesReceived / 1024d) / 1024d, 2).ToString("0.00") + " from " +
Math.Round((e.BytesReceived / 1024d) / 1024d, 2).ToString("0.00") + " MB from " +
Math.Round((e.TotalBytesToReceive / 1024d) / 1024d, 2).ToString("0.00") +
" (" + Patcher.CalculateSpeed(e.BytesReceived) + ")";
" MB (" + Patcher.CalculateSpeed(e.BytesReceived) + ")";
DownloadSize = e.TotalBytesToReceive;
DownloadCurrent = e.BytesReceived;
}
Expand Down

0 comments on commit 50e70dc

Please sign in to comment.