Skip to content

Commit

Permalink
- You can now delete all downloads at once
Browse files Browse the repository at this point in the history
- Added setting to automatically delete files from portable games after successful installation
- Added setting to automatically install portable games
  • Loading branch information
Yelo420 committed Jun 25, 2024
1 parent bd00a2c commit 5f12980
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 36 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# GameVault App Changelog

## 1.11.0.0
Recommended Gamevault Server Version: `v12.1.3`
Recommended Gamevault Server Version: `v12.2.0`
### Changes

- You can now delete all downloads at once
- Added setting to automatically delete files from portable games after successful installation
- Added setting to automatically install portable games
- Ability to change and overwrite the Installation Procedure
- Desktop shortcuts start the game via GameVault. So changed executable or parameters are updated immediately as well.
- Option to create a shortcut upon clicking install. Remembers the last input as default.
Expand Down
7 changes: 7 additions & 0 deletions gamevault/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,12 @@ private void CreateDirectories()
Directory.CreateDirectory(AppFilePath.ThemesLoadDir);
}
}
public bool IsWindowActiveAndControlInFocus(MainControl control)
{
if (Current.MainWindow == null)
return false;

return Current.MainWindow.IsActive && MainWindowViewModel.Instance.ActiveControlIndex == (int)control;
}
}
}
5 changes: 4 additions & 1 deletion gamevault/Models/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public enum AppConfigKey
ServerUrl,
LibStartup,
AutoExtract,
AutoInstallPortable,
AutoDeletePortable,
ExtractionFinished,
RunningInTrayMessage,
DownloadLimit,
Expand Down Expand Up @@ -60,6 +62,7 @@ internal static void InitDebugPaths()
}
public static class Globals
{
internal static string[] SupportedExecutables = new string[] { "EXE", "BAT", "COM", "CMD", "INF", "IPA", "OSX", "PIF", "RUN", "WSH", "LNK", "SH" };
internal static string[] SupportedExecutables = new string[] { "EXE", "BAT", "COM", "CMD", "INF", "IPA", "OSX", "PIF", "RUN", "WSH", "LNK", "SH", "MSI" };
internal static string[] SupportedArchives = new string[] { ".7z", ".xz", ".bz2", ".gz", ".tar", ".zip", ".wim", ".ar", ".arj", ".cab", ".chm", ".cpio", ".cramfs", ".dmg", ".ext", ".fat", ".gpt", ".hfs", ".ihex", ".iso", ".lzh", ".lzma", ".mbr", ".msi", ".nsis", ".ntfs", ".qcow2", ".rar", ".rpm", ".squashfs", ".udf", ".uefi", ".vdi", ".vhd", ".vmdk", ".wim", ".xar", ".z" };
}
}
14 changes: 13 additions & 1 deletion gamevault/UserControls/DownloadsUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@
<RowDefinition/>
</Grid.RowDefinitions>
<Border Background="{DynamicResource MahApps.Brushes.ThemeBackground2}" Grid.Row="0">
<TextBlock Text="Downloads" FontSize="35" Margin="20,0,0,0" Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"/>
<Grid>
<TextBlock Text="Downloads" FontSize="35" Margin="20,0,0,0" Foreground="{DynamicResource MahApps.Brushes.ThemeForeground}"/>
<Grid Style="{DynamicResource HoverEffect}" Background="Transparent" ToolTip="Delete all Downloads" Cursor="Hand" HorizontalAlignment="Right" Width="30" Height="30" Margin="0,0,2,0" RenderTransformOrigin="0.5,0.5" MouseLeftButtonUp="DeleteAllDownloads_Click">
<Path Data="{StaticResource IconTrash}" Fill="IndianRed" Margin="0,0,-20,-20">
<Path.RenderTransform>
<ScaleTransform ScaleX="1.3" ScaleY="1.3"/>
</Path.RenderTransform>
</Path>
<Grid.RenderTransform>
<ScaleTransform/>
</Grid.RenderTransform>
</Grid>
</Grid>
</Border>
<TextBlock Grid.Row="1" Text="Downloads empty" FontSize="50" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock.Style>
Expand Down
17 changes: 17 additions & 0 deletions gamevault/UserControls/DownloadsUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,22 @@ private bool IsEnoughDriveSpaceAvailable(long gameSize)
}
return false;
}

private async void DeleteAllDownloads_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
MessageDialogResult result = await ((MetroWindow)App.Current.MainWindow).ShowMessageAsync($"Are you sure you want to delete all Downloads?\nThis cannot be undone.", "", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { AffirmativeButtonText = "Yes", NegativeButtonText = "No", AnimateHide = false });

if (result == MessageDialogResult.Affirmative)
{
try
{
for (int count = DownloadsViewModel.Instance.DownloadedGames.Count - 1; count >= 0; count--)
{
await DownloadsViewModel.Instance.DownloadedGames[count].DeleteFile(false);
}
}
catch { }
}
}
}
}
4 changes: 2 additions & 2 deletions gamevault/UserControls/GameDownloadUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
<TextBlock Text="{Binding InstallPath}" FontSize="3" IsHitTestVisible="False" Foreground="#FF424242" HorizontalAlignment="Left"/>
</Border>

<local:IconButton Kind="Primary" Text="Install" FontSize="5" Icon="{StaticResource IconInstalledGamesSettings}" IconScale="0.29" IconMargin="-8,-7,-5.5,-7" CornerRadius="2" Height="9" Width="34" BorderThickness="0.2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,1,0" Click="Install_Click">
<local:IconButton x:Name="uiBtnInstallSetup" Kind="Primary" Text="Install" FontSize="5" Icon="{StaticResource IconInstalledGamesSettings}" IconScale="0.29" IconMargin="-8,-7,-5.5,-7" CornerRadius="2" Height="9" Width="34" BorderThickness="0.2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,1,0" Click="Install_Click">
<local:IconButton.Style>
<Style TargetType="{x:Type local:IconButton}" BasedOn="{StaticResource {x:Type local:IconButton}}">
<Style.Triggers>
Expand Down Expand Up @@ -200,7 +200,7 @@

<TextBlock FontSize="4" TextWrapping="Wrap" Text="This is a Portable Game, so there's no need for any setup. Once you click 'Install', the files will be automatically moved to the installation folder." MaxWidth="126" Margin="0,18,0,0"/>

<local:IconButton Kind="Primary" Text="Install" FontSize="5" Icon="{StaticResource IconInstalledGamesSettings}" IconScale="0.29" IconMargin="-8,-7,-5.5,-7" CornerRadius="2" Height="9" Width="34" BorderThickness="0.2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,1,0" Click="Install_Click"/>
<local:IconButton x:Name="uiBtnInstallPortable" Kind="Primary" Text="Install" FontSize="5" Icon="{StaticResource IconInstalledGamesSettings}" IconScale="0.29" IconMargin="-8,-7,-5.5,-7" CornerRadius="2" Height="9" Width="34" BorderThickness="0.2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,1,0" Click="Install_Click"/>
</Grid>
<Grid>
<Grid.Style>
Expand Down
52 changes: 43 additions & 9 deletions gamevault/UserControls/GameDownloadUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ private async Task DownloadGame(bool tryResume = false)

if (downloadRetryTimer.Data != "error")
{
ToastMessageHelper.CreateToastMessage("Download Failed", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");
if (!App.Instance.IsWindowActiveAndControlInFocus(MainControl.Downloads))
ToastMessageHelper.CreateToastMessage("Download Failed", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");
}
downloadRetryTimer.Start();

Expand Down Expand Up @@ -308,7 +309,10 @@ private void DownloadCompleted()
Directory.CreateDirectory(ViewModel.InstallPath);
}
MainWindowViewModel.Instance.Library.GetGameInstalls().AddSystemFileWatcher(ViewModel.InstallPath);
ToastMessageHelper.CreateToastMessage("Download Complete", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");

if (!App.Instance.IsWindowActiveAndControlInFocus(MainControl.Downloads))
ToastMessageHelper.CreateToastMessage("Download Complete", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");

if (SettingsViewModel.Instance.AutoExtract)
{
App.Current.Dispatcher.Invoke((Action)async delegate
Expand Down Expand Up @@ -388,6 +392,7 @@ public async Task DeleteFile(bool confirm = true)

DownloadsViewModel.Instance.DownloadedGames.Remove(this);

//Delete Installation Directory if it is empty (Because GV should not create a filewatcher for it anymore)
if (Directory.Exists(ViewModel.InstallPath) && !Directory.EnumerateFileSystemEntries(ViewModel.InstallPath).Any())
{
Directory.Delete(ViewModel.InstallPath);
Expand Down Expand Up @@ -480,10 +485,23 @@ private async Task Extract()
Preferences.Set(AppConfigKey.ExtractionFinished, "1", $"{m_DownloadPath}\\Extract\\gamevault-metadata");
ViewModel.State = "Extracted";
uiBtnExtract.Text = "Re-Extract";
uiBtnInstall.IsEnabled = true;

ViewModel.InstallationStepperProgress = 1;
ViewModel.ExtractionUIVisibility = System.Windows.Visibility.Hidden;
ToastMessageHelper.CreateToastMessage("Extraction Complete", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");

if (!App.Instance.IsWindowActiveAndControlInFocus(MainControl.Downloads))
ToastMessageHelper.CreateToastMessage("Extraction Complete", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");

if (SettingsViewModel.Instance.AutoInstallPortable && (ViewModel.Game.Type == GameType.WINDOWS_PORTABLE || ViewModel.Game.Type == GameType.LINUX_PORTABLE))
{
await Task.Delay(1000);//Just to be sure the extraction stream is closed and the files are ready to copy
await Install();
}
else
{
uiBtnInstall.IsEnabled = true;
}

UpdateDataSizeUI();
}
else
Expand All @@ -508,7 +526,8 @@ private async Task Extract()
else
{
ViewModel.State = "Something went wrong during extraction";
ToastMessageHelper.CreateToastMessage("Extraction Failed", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");
if (!App.Instance.IsWindowActiveAndControlInFocus(MainControl.Downloads))
ToastMessageHelper.CreateToastMessage("Extraction Failed", ViewModel.Game.Title, $"{AppFilePath.ImageCache}/gbox/{ViewModel.Game.ID}.{ViewModel.Game.BoxImage.ID}");
}
ViewModel.ExtractionUIVisibility = System.Windows.Visibility.Hidden;
}
Expand Down Expand Up @@ -553,9 +572,14 @@ private void LoadSetupExecutables()
uiCbSetupExecutable.ItemsSource = null;
}
}
private async void Install_Click(object sender, RoutedEventArgs e)
private async void Install_Click(object s, RoutedEventArgs e)
{
((FrameworkElement)sender).IsEnabled = false;
await Install();
}
private async Task Install()
{
uiBtnInstallPortable.IsEnabled = false;
uiBtnInstallSetup.IsEnabled = false;
uiBtnExtract.IsEnabled = false;
try
{
Expand Down Expand Up @@ -589,7 +613,10 @@ await Task.Run(async () =>
});
uiBtnInstall.IsEnabled = false;
uiProgressRingInstall.IsActive = false;
((FrameworkElement)sender).IsEnabled = true;

uiBtnInstallPortable.IsEnabled = true;
uiBtnInstallSetup.IsEnabled = true;

ViewModel.State = "Downloaded";
uiBtnExtract.Text = "Extract";
if (error)
Expand All @@ -601,6 +628,12 @@ await Task.Run(async () =>
MainWindowViewModel.Instance.AppBarText = $"Successfully installed '{ViewModel.Game.Title}'";
ViewModel.InstallationStepperProgress = 2;
ViewModel.State = "Installed";

//Auto delete files of portable games after successful installation
if (SettingsViewModel.Instance.AutoDeletePortableGameFiles)
{
await DeleteFile(false);
}
}
}
else if (ViewModel.Game.Type == GameType.WINDOWS_SETUP)
Expand Down Expand Up @@ -643,7 +676,8 @@ await Task.Run(async () =>
{
MainWindowViewModel.Instance.AppBarText = $"Could not find executable '{setupEexecutable}'";
}
((FrameworkElement)sender).IsEnabled = true;
uiBtnInstallPortable.IsEnabled = true;
uiBtnInstallSetup.IsEnabled = true;
}
uiInstallOptions.Visibility = System.Windows.Visibility.Collapsed;
uiProgressRingInstall.IsActive = false;
Expand Down
47 changes: 30 additions & 17 deletions gamevault/UserControls/SettingsUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,9 @@
<TabItem Header="Application">
<StackPanel Margin="30,0,0,0">
<StackPanel Margin="0,0,0,0">
<TextBlock Text="Extraction" FontSize="20" FontWeight="Bold"/>
<mah:ToggleSwitch Header="Auto-Extract Downloaded Games" Margin="10,10,0,0" IsOn="{Binding AutoExtract}"/>
<GroupBox Header="Default extraction password" HorizontalAlignment="Left" Width="510" mah:ControlsHelper.CornerRadius="4" Margin="10,10,0,0">
<StackPanel>
<TextBlock Text="Set a password that will automatically be tried when extracting games." Margin="1,0,0,0" TextWrapping="Wrap" FontSize="14"/>
<PasswordBox x:Name="uiPwExtraction" mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.Watermark="Optional Password" mah:ControlsHelper.CornerRadius="5" Margin="0,5,0,0"/>
<local:IconButton Text="Save" FontSize="15" Icon="{StaticResource IconGameSettingsSave}" IconMargin="0,0,5,2" Width="80" Height="30" Margin="0,5,0,0" HorizontalAlignment="Left" Click="ExtractionPasswordSave_Click"/>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Server Settings" FontSize="20" FontWeight="Bold"/>
<settingsComponents:ServerUrlUserControl Margin="10,10,0,0" HorizontalAlignment="Left"/>
<GroupBox Header="Download Limit" Margin="10,10,0,0" Width="510" HorizontalAlignment="Left" mah:ControlsHelper.CornerRadius="4">
<StackPanel>
<TextBox Text="{Binding DownloadLimitUIValue,UpdateSourceTrigger=PropertyChanged}" Margin="0,10,0,5" MaxLength="8" mah:TextBoxHelper.UseFloatingWatermark="True" mah:ControlsHelper.CornerRadius="5" mah:TextBoxHelper.Watermark="{Binding DownloadLimitUIValue,Converter={StaticResource downloadLimitConv}}" PreviewTextInput="DownloadLimit_InputValidation" TextChanged="DownloadLimit_InputValidation" KeyDown="DownloadLimit_Save"/>
<local:IconButton Text="Save" FontSize="15" Icon="{StaticResource IconGameSettingsSave}" IconMargin="0,0,5,2" Width="80" Height="30" HorizontalAlignment="Left" Click="DownloadLimit_Save"/>
</StackPanel>
</GroupBox>

</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Startup" FontSize="20" FontWeight="Bold"/>
Expand Down Expand Up @@ -93,6 +77,35 @@
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="Installation">
<StackPanel Margin="30,0,0,0">
<StackPanel Margin="0,0,0,0">
<TextBlock Text="Download" FontSize="20" FontWeight="Bold"/>
<GroupBox Header="Download Bandwidth Limit" Margin="10,10,0,0" Width="510" HorizontalAlignment="Left" mah:ControlsHelper.CornerRadius="4">
<StackPanel>
<TextBox Text="{Binding DownloadLimitUIValue,UpdateSourceTrigger=PropertyChanged}" Margin="0,10,0,5" MaxLength="8" mah:TextBoxHelper.UseFloatingWatermark="True" mah:ControlsHelper.CornerRadius="5" mah:TextBoxHelper.Watermark="{Binding DownloadLimitUIValue,Converter={StaticResource downloadLimitConv}}" PreviewTextInput="DownloadLimit_InputValidation" TextChanged="DownloadLimit_InputValidation" KeyDown="DownloadLimit_Save"/>
<local:IconButton Text="Save" FontSize="15" Icon="{StaticResource IconGameSettingsSave}" IconMargin="0,0,5,2" Width="80" Height="30" HorizontalAlignment="Left" Click="DownloadLimit_Save"/>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Extraction" FontSize="20" FontWeight="Bold"/>
<mah:ToggleSwitch Header="Auto-Extract Downloaded Games" Margin="10,10,0,0" IsOn="{Binding AutoExtract}"/>
<GroupBox Header="Default extraction password" HorizontalAlignment="Left" Width="510" mah:ControlsHelper.CornerRadius="4" Margin="10,10,0,0">
<StackPanel>
<TextBlock Text="Set a password that will automatically be tried when extracting games." Margin="1,0,0,0" TextWrapping="Wrap" FontSize="14"/>
<PasswordBox x:Name="uiPwExtraction" mah:TextBoxHelper.UseFloatingWatermark="True" mah:TextBoxHelper.Watermark="Optional Password" mah:ControlsHelper.CornerRadius="5" Margin="0,5,0,0"/>
<local:IconButton Text="Save" FontSize="15" Icon="{StaticResource IconGameSettingsSave}" IconMargin="0,0,5,2" Width="80" Height="30" Margin="0,5,0,0" HorizontalAlignment="Left" Click="ExtractionPasswordSave_Click"/>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Margin="0,10,0,0">
<TextBlock Text="Installation" FontSize="20" FontWeight="Bold"/>
<mah:ToggleSwitch Header="Auto-Install Portable Games" IsOn="{Binding AutoInstallPortable}" Margin="10,10,0,0"/>
<mah:ToggleSwitch Header="Auto-Delete Install files of Portable Games on successful installation" IsOn="{Binding AutoDeletePortableGameFiles}" Margin="10,10,0,0"/>
</StackPanel>
</StackPanel>
</TabItem>
<TabItem Header="User">
<StackPanel Margin="30,0,0,0">
<StackPanel Margin="0,0,0,0">
Expand Down
2 changes: 1 addition & 1 deletion gamevault/ViewModels/GameDownloadViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public string[] SupportedArchives
{
get
{
return new string[] { ".7z", ".xz", ".bz2", ".gz", ".tar", ".zip", ".wim", ".ar", ".arj", ".cab", ".chm", ".cpio", ".cramfs", ".dmg", ".ext", ".fat", ".gpt", ".hfs", ".ihex", ".iso", ".lzh", ".lzma", ".mbr", ".msi", ".nsis", ".ntfs", ".qcow2", ".rar", ".rpm", ".squashfs", ".udf", ".uefi", ".vdi", ".vhd", ".vmdk", ".wim", ".xar", ".z" };
return Globals.SupportedArchives;
}
}
public Dictionary<GameType, string?> GameTypes
Expand Down
Loading

0 comments on commit 5f12980

Please sign in to comment.