Skip to content

Commit

Permalink
Release 1.4.0
Browse files Browse the repository at this point in the history
Release 1.4.0
  • Loading branch information
Yelo420 authored Aug 21, 2023
2 parents bb0acef + 7107854 commit c2f4e6a
Show file tree
Hide file tree
Showing 25 changed files with 221 additions and 72 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# GameVault App Changelog

## 1.4.0
### Changes
- In case of an unhandled exception, you can now navigate directly to the error logs
- In the admin console, you can now jump directly to the profiles
- Support single file binary
- The selectable executables are now trimmed in the installation tab
- Enter key on forms now submits forms
- Bug fix: Dealing with undetected game types in the installation process
- Bug fix: A long error message in the download tab, no longer rescales the individual elements
- Bug fix: Download speed not shown, when it's KB/s and below

## 1.3.0
### Changes
- Installation pipeline implemented. The UI for the download tab has been completely overhauled. GameVault is now able to extract downloaded game archives and perform the installation process depending on the game type.
Expand Down
10 changes: 8 additions & 2 deletions gamevault/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private async void Application_Startup(object sender, StartupEventArgs e)
{

Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(AppDispatcherUnhandledException);

try
{
NewNameMigrationHelper.MigrateIfNeeded();
Expand Down Expand Up @@ -101,7 +102,7 @@ private void AppDispatcherUnhandledException(object sender, DispatcherUnhandledE
{
ProcessShepherd.KillAllChildProcesses();
#if DEBUG
e.Handled = false;
e.Handled = false;
#else
LogUnhandledException(e);
#endif
Expand All @@ -121,7 +122,12 @@ void LogUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{
e.Handled = true;
LogUnhandledException(e.Exception);
System.Windows.MessageBox.Show("Something went wrong. View error log for more details", "Unhandled Exception", MessageBoxButton.OK, MessageBoxImage.Warning);
MessageBoxResult result = System.Windows.MessageBox.Show("Something went wrong. View error log for more details.\nDo you want to open the error logs?", "Unhandled Exception", MessageBoxButton.YesNo, MessageBoxImage.Warning);
if (result == MessageBoxResult.Yes)
{
if (Directory.Exists(AppFilePath.ErrorLog))
Process.Start("explorer.exe", AppFilePath.ErrorLog.Replace(@"\\",@"\").Replace("/",@"\"));
}
ShutdownApp();
}
private void StartServer()
Expand Down
23 changes: 15 additions & 8 deletions gamevault/Helper/HttpClientDownloadWithProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace gamevault.Helper
public class HttpClientDownloadWithProgress : IDisposable
{
private readonly string _downloadUrl;
private readonly string _destinationFilePath;
private readonly string _destinationFolderPath;
private string _fileName;
private bool _Cancelled = false;
private DateTime lastTime;
private HttpClient _httpClient;
Expand All @@ -24,10 +25,10 @@ public class HttpClientDownloadWithProgress : IDisposable

public event ProgressChangedHandler ProgressChanged;

public HttpClientDownloadWithProgress(string downloadUrl, string destinationFilePath)
public HttpClientDownloadWithProgress(string downloadUrl, string destinationFolderPath)
{
_downloadUrl = downloadUrl;
_destinationFilePath = destinationFilePath;
_destinationFolderPath = destinationFolderPath;
}

public async Task StartDownload()
Expand All @@ -45,6 +46,11 @@ private async Task DownloadFileFromHttpResponseMessage(HttpResponseMessage respo
{
response.EnsureSuccessStatusCode();

_fileName = response.Content.Headers.ContentDisposition.FileName.Replace("\"", "");
if(string.IsNullOrEmpty(_fileName))
{
throw new Exception("Incomplete request header");
}
var totalBytes = response.Content.Headers.ContentLength;

using (var contentStream = await response.Content.ReadAsStreamAsync())
Expand All @@ -53,11 +59,12 @@ private async Task DownloadFileFromHttpResponseMessage(HttpResponseMessage respo

private async Task ProcessContentStream(long? totalDownloadSize, Stream contentStream)
{
var totalBytesRead = 0L;
var totalBytesRead = 0L;
var buffer = new byte[8192];
var isMoreToRead = true;
lastTime = DateTime.Now;
using (var fileStream = new FileStream(_destinationFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true))
string fullFilePath = $"{_destinationFolderPath}\\{_fileName}";
using (var fileStream = new FileStream(fullFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, true))
{
do
{
Expand All @@ -66,7 +73,7 @@ private async Task ProcessContentStream(long? totalDownloadSize, Stream contentS
fileStream.Close();
try
{
File.Delete(_destinationFilePath);
File.Delete(fullFilePath);
}
catch { }
return;
Expand All @@ -84,10 +91,10 @@ private async Task ProcessContentStream(long? totalDownloadSize, Stream contentS

totalBytesRead += bytesRead;
//readCount += 1;
if((DateTime.Now - lastTime).TotalSeconds > 2)
if ((DateTime.Now - lastTime).TotalSeconds > 2)
{
TriggerProgressChanged(totalDownloadSize, totalBytesRead);
lastTime = DateTime.Now;
lastTime = DateTime.Now;
}
//if (readCount % 100 == 0)
// TriggerProgressChanged(totalDownloadSize, totalBytesRead);
Expand Down
2 changes: 1 addition & 1 deletion gamevault/UserControls/AdminConsoleUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</Style>
</Grid.Style>

<local:CacheImage ImageCacheType="UserIcon" Data="{Binding}" Width="6" HorizontalAlignment="Left">
<local:CacheImage ImageCacheType="UserIcon" Data="{Binding}" Width="6" HorizontalAlignment="Left" Cursor="Hand" MouseLeftButtonUp="ShowUser_Click">
<local:CacheImage.Clip>
<EllipseGeometry RadiusX="3" RadiusY="3" Center="3,3"/>
</local:CacheImage.Clip>
Expand Down
7 changes: 7 additions & 0 deletions gamevault/UserControls/AdminConsoleUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,12 @@ private async Task HandleChangesOnCurrentUser(User selectedUser)
await InitUserList();
await MainWindowViewModel.Instance.Community.InitUserList();
}

private void ShowUser_Click(object sender, MouseButtonEventArgs e)
{
User selectedUser = ((FrameworkElement)sender).DataContext as User;
MainWindowViewModel.Instance.SetActiveControl(MainControl.Community);
MainWindowViewModel.Instance.Community.ShowUser(selectedUser);
}
}
}
14 changes: 13 additions & 1 deletion gamevault/UserControls/CommunityUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ public async Task InitUserList()
return users;
});
}

internal void ShowUser(User userToShow)
{
for (int count = 0; count < ViewModel.Users.Length; count++)
{
if (ViewModel.Users[count].ID == userToShow.ID)
{
if (uiSelectUser.SelectedIndex != count)
{
uiSelectUser.SelectedIndex = count;
}
}
}
}
private async void Users_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
Expand Down
2 changes: 1 addition & 1 deletion gamevault/UserControls/DownloadsUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<ScrollViewer Grid.Column="1" Margin="10,10,0,0" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto">
<Viewbox>
<ItemsControl ItemsSource="{Binding DownloadedGames}">
<ItemsControl ItemsSource="{Binding DownloadedGames}" Focusable="False">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical"/>
Expand Down
20 changes: 18 additions & 2 deletions gamevault/UserControls/GameDownloadUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
<Grid>
<local:CacheImage HorizontalAlignment="Left" VerticalAlignment="Top" MaxWidth="52" Margin="2,2,120,2" ImageCacheType="BoxArt" Data="{Binding Path=Game}" CornerRadius="2" Cursor="Hand" MouseLeftButtonUp="GameImage_MouseLeftButtonUp"/>

<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="56,2,0,0" Text="{Binding Path=Game.Title}" MaxWidth="100" FontSize="6" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="56,2,0,0" Text="{Binding Path=Game.Title}" MaxWidth="106" FontSize="6" FontWeight="Bold"/>
<TextBlock Text="🗑️" FontSize="6" Foreground="IndianRed" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,2,2,0" Cursor="Hand" ToolTip="Delete File" MouseLeftButtonUp="DeleteFile_MouseLeftButtonUp"/>
<TextBlock Text="📁" FontSize="6" Foreground="LightBlue" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,2,10,0" Cursor="Hand" ToolTip="Open Directory" MouseLeftButtonUp="OpenDirectory_MouseLeftButtonUp"/>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="56,10,0,0" Text="{Binding State,StringFormat={}State: {0}}" FontSize="4"/>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="56,10,0,0" Text="{Binding State,StringFormat={}State: {0}}" FontSize="4" Width="122"/>

<TextBlock Text="📥" FontSize="9" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="55,17,0,0"/>
<Border Visibility="{Binding DownloadFailedVisibility}" Background="{StaticResource MahApps.Brushes.Accent}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="70,21,2,0" CornerRadius="2" Padding="1" Cursor="Hand" ToolTip="Download Game" MouseLeftButtonUp="RetryDownload_Click">
Expand Down Expand Up @@ -147,6 +147,22 @@
<TextBlock Text="Install" FontSize="5"/>
</Border>
</Grid>
<Grid>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Game.Type}" Value="UNDETECTABLE">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<TextBlock Text="Could not determine game type. Please install this game manually to the folder below." FontSize="4" TextWrapping="Wrap" MaxWidth="126" Margin="0,17,0,0"/>
<Border Background="Gainsboro" CornerRadius="2" Margin="0,31,1,0" VerticalAlignment="Top" Padding="1" ToolTip="Copy to clipboard" MouseLeftButtonUp="CopyInstallPathToClipboard_Click">
<TextBlock Text="{Binding InstallPath}" FontSize="3" Foreground="#FF424242" HorizontalAlignment="Left" Cursor="Hand"/>
</Border>
</Grid>
<Viewbox Width="9" Height="9" Margin="0,0,30,0" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<mah:ProgressRing x:Name="uiProgressRingInstall" IsActive="False"/>
</Viewbox>
Expand Down
20 changes: 14 additions & 6 deletions gamevault/UserControls/GameDownloadUserControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using gamevault.Helper;
using gamevault.Models;
using gamevault.ViewModels;
using ImageMagick.Formats;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -103,7 +105,7 @@ private void DownloadGame()
ViewModel.DownloadFailedVisibility = System.Windows.Visibility.Hidden;

if (!Directory.Exists(m_DownloadPath)) { Directory.CreateDirectory(m_DownloadPath); }
client = new HttpClientDownloadWithProgress($"{SettingsViewModel.Instance.ServerUrl}/api/v1/games/{ViewModel.Game.ID}/download", $"{m_DownloadPath}\\{Path.GetFileName(ViewModel.Game.FilePath)}");
client = new HttpClientDownloadWithProgress($"{SettingsViewModel.Instance.ServerUrl}/api/v1/games/{ViewModel.Game.ID}/download", m_DownloadPath);
client.ProgressChanged += DownloadProgress;
startTime = DateTime.Now;

Expand Down Expand Up @@ -170,18 +172,17 @@ private void CancelExtraction_Click(object sender, System.Windows.Input.MouseBut
}
private string CalculateSpeed(double size, double tspan)
{
string message = string.Empty;
if (size / tspan > 1024 * 1024) // MB
{
return $"{message} {Math.Round(size / (1024 * 1204) / tspan, 2)} MB/s"; //string.Format(message, size / (1024 * 1204) / tspan, "MB/s");
return $"{Math.Round(size / (1024 * 1204) / tspan, 2)} MB/s";
}
else if (size / tspan > 1024) // KB
{
return string.Format(message, size / (1024) / tspan, "KB/s");
return $"{Math.Round(size / (1024) / tspan, 2)} KB/s";
}
else
{
return string.Format(message, size / tspan, "B/s");
return $"{Math.Round(size / tspan, 2)} B/s";
}
}

Expand Down Expand Up @@ -235,14 +236,21 @@ private void ExtractionProgress(object sender, SevenZipProgressEventArgs e)

private async void Extract_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
DirectoryInfo dirInf = new DirectoryInfo(m_DownloadPath);
FileInfo[] files = dirInf.GetFiles().Where(f => ViewModel.SupportedArchives.Contains(f.Extension.ToLower())).ToArray();
if (files.Length <= 0)
{
ViewModel.State = "No archive found";
return;
}
uiBtnInstall.IsEnabled = false;
ViewModel.ExtractionUIVisibility = System.Windows.Visibility.Hidden;
ViewModel.State = "Extracting...";
ViewModel.ExtractionUIVisibility = System.Windows.Visibility.Visible;

sevenZipHelper.Process += ExtractionProgress;
startTime = DateTime.Now;
int result = await sevenZipHelper.ExtractArchive($"{m_DownloadPath}\\{Path.GetFileName(ViewModel.Game.FilePath)}", $"{m_DownloadPath}\\Extract");
int result = await sevenZipHelper.ExtractArchive($"{m_DownloadPath}\\{files[0].Name}", $"{m_DownloadPath}\\Extract");
if (result == 0)
{
if (!File.Exists($"{m_DownloadPath}\\Extract\\gamevault-metadata"))
Expand Down
2 changes: 1 addition & 1 deletion gamevault/UserControls/GameInstallUserControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,10,0">
<StackPanel Margin="5">
<TextBlock Text="Executable" FontSize="15" FontWeight="Bold" HorizontalAlignment="Right"/>
<ComboBox x:Name="uiCbExecutables" ItemsSource="{Binding Executables}" SelectionChanged="Executable_SelectionChanged" PreviewMouseLeftButtonDown="ExecutablesCombobox_Click"/>
<ComboBox x:Name="uiCbExecutables" DisplayMemberPath="Value" ItemsSource="{Binding Executables}" SelectionChanged="Executable_SelectionChanged" PreviewMouseLeftButtonDown="ExecutablesCombobox_Click"/>
</StackPanel>
<Button Content="Play" FontSize="25" Padding="15,0,15,0" Background="{StaticResource MahApps.Brushes.Accent}" Click="Play_Clicked">
<Button.Style>
Expand Down
20 changes: 12 additions & 8 deletions gamevault/UserControls/GameInstallUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ private void FindGameExecutables(string directory, bool checkForSavedExecutable)
{
if (ContainsValueFromIgnoreList(allExecutables[count]))
continue;

ViewModel.Executables.Add(allExecutables[count]);
if (true == checkForSavedExecutable && allExecutables[count] == m_SavedExecutable) { uiCbExecutables.SelectedIndex = count; }
else if(true == checkForSavedExecutable && m_SavedExecutable == string.Empty && uiCbExecutables.SelectedIndex == -1)
var currentItem = new KeyValuePair<string, string>(allExecutables[count], allExecutables[count].Substring(m_Directory.Length + 1));
ViewModel.Executables.Add(currentItem);
if (true == checkForSavedExecutable && allExecutables[count] == m_SavedExecutable)
{
uiCbExecutables.SelectedItem = currentItem;
}
else if (true == checkForSavedExecutable && m_SavedExecutable == string.Empty)
{
uiCbExecutables.SelectedIndex = count;
checkForSavedExecutable = false;
uiCbExecutables.SelectedItem = currentItem;
}
}
}
Expand All @@ -79,10 +83,10 @@ private void Executable_SelectionChanged(object sender, SelectionChangedEventArg
{
if (e.AddedItems.Count > 0)
{
m_SavedExecutable = e.AddedItems[0].ToString();
m_SavedExecutable = ((KeyValuePair<string, string>)e.AddedItems[0]).Key;
if (Directory.Exists(m_Directory))
{
Preferences.Set(AppConfigKey.Executable, e.AddedItems[0].ToString(), $"{m_Directory}\\gamevault-exec");
Preferences.Set(AppConfigKey.Executable, m_SavedExecutable, $"{m_Directory}\\gamevault-exec");
}
}
}
Expand Down Expand Up @@ -113,7 +117,7 @@ private void Play_Clicked(object sender, RoutedEventArgs e)
{
MainWindowViewModel.Instance.AppBarText = $"Could not find executable '{m_SavedExecutable}'";
}
}
}

private void GameImage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Expand Down
Loading

0 comments on commit c2f4e6a

Please # to comment.