Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give feedback to the user when they clear engines/clear server content #101

Merged
merged 4 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions SS14.Launcher/Utility/ButtonExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Threading.Tasks;
using Avalonia.Controls;

namespace SS14.Launcher.Utility;

public static class ButtonExtensions
{
/// <summary>
/// Sets the content of a button to a specified message ("Done!" by default) for a specified duration (2s by
/// default), and disabled the button for this duration.
/// </summary>
public static async Task DisplayDoneMessage(this Button button, string message = "Done!", int duration = 2000)
{
var previousContent = button.Content;
button.Content = message;
button.IsEnabled = false;
await Task.Delay(duration);
button.Content = previousContent;
button.IsEnabled = true;
}
}
8 changes: 4 additions & 4 deletions SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<DockPanel>
<Button Content="*flip" DockPanel.Dock="Bottom" HorizontalAlignment="Right" Name="Flip" />
<Button Content="Clear installed engines" DockPanel.Dock="Bottom" HorizontalAlignment="Left"
Command="{Binding ClearEngines}"/>
<Button Content="Clear installed server content" DockPanel.Dock="Bottom" HorizontalAlignment="Left"
Command="{Binding ClearServerContent}"/>
<Button Name="ClearEnginesButton" Content="Clear installed engines" DockPanel.Dock="Bottom"
HorizontalAlignment="Left" Click="ClearEnginesPressed" />
<Button Name="ClearServerContentButton" Content="Clear installed server content" DockPanel.Dock="Bottom"
HorizontalAlignment="Left" Click="ClearServerContentPressed" />
<Button Content="Open log directory" DockPanel.Dock="Bottom" HorizontalAlignment="Left"
Command="{Binding OpenLogDirectory}"/>

Expand Down
16 changes: 15 additions & 1 deletion SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Interactivity;
using Avalonia.Threading;
using ReactiveUI;
using SS14.Launcher.Utility;
using SS14.Launcher.ViewModels.MainWindowTabs;

namespace SS14.Launcher.Views.MainWindowTabs;

Expand All @@ -24,4 +26,16 @@ public OptionsTabView()
DispatcherTimer.RunOnce(() => { window.Classes.Remove("DoAFlip"); }, TimeSpan.FromSeconds(1));
});
}

public async void ClearEnginesPressed(object? _1, RoutedEventArgs _2)
{
((OptionsTabViewModel)DataContext!).ClearEngines();
await ClearEnginesButton.DisplayDoneMessage();
}

public async void ClearServerContentPressed(object? _1, RoutedEventArgs _2)
{
((OptionsTabViewModel)DataContext!).ClearServerContent();
await ClearServerContentButton.DisplayDoneMessage();
}
}
Loading