Skip to content

Commit

Permalink
v1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RevoLand committed Dec 29, 2017
1 parent bf07b47 commit 81d5b5c
Show file tree
Hide file tree
Showing 27 changed files with 554 additions and 403 deletions.
Binary file modified Binaries/Steam Library Manager.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Binaries/Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.4.0|ACF File Detection, search function and some other fixes & improvements
1.5.0.0|UI Improvements, task manager and code base improvements
Binary file modified Extras/Screenshots/LibraryCleanerTab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Extras/Screenshots/LibraryTab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Extras/Screenshots/LibraryTab_ListView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Extras/Screenshots/SettingsTab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Extras/Screenshots/TaskManagerTab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Extras/Screenshots/TaskManagerTab_ListView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions Source/Steam Library Manager/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Forms/Main.xaml"
DispatcherUnhandledException="Application_DispatcherUnhandledException"
>
DispatcherUnhandledException="Application_DispatcherUnhandledException">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
4 changes: 3 additions & 1 deletion Source/Steam Library Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ protected override void OnStartup(StartupEventArgs e)
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex));
}
}

private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show(e.Exception.ToString(), "Exception Caught", MessageBoxButton.OK, MessageBoxImage.Error);
Definitions.SLM.ravenClient.Capture(new SharpRaven.Data.SentryEvent(e.Exception));
System.Diagnostics.Debug.WriteLine(e.Exception);
Definitions.SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(e.Exception));
e.Handled = true;
}
}
Expand Down
140 changes: 77 additions & 63 deletions Source/Steam Library Manager/Definitions/AppInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AppInfo
public DirectoryInfo InstallationPath;
public long SizeOnDisk { get; set; }
public bool IsCompressed { get; set; }
public bool IsSteamBackup { get; set; }
public DateTime LastUpdated { get; set; }

public string GameHeaderImage => $"http://cdn.akamai.steamstatic.com/steam/apps/{AppID}/header.jpg";
Expand Down Expand Up @@ -69,17 +70,18 @@ public Framework.AsyncObservableCollection<FrameworkElement> GenerateRightClickM
}
else
{
MenuItem slmItem = new MenuItem()
MenuItem SLMItem = new MenuItem()
{
Tag = this,
Header = string.Format(cItem.Header, AppName, AppID, Functions.FileSystem.FormatBytes(SizeOnDisk))
};
slmItem.Tag = cItem.Action;
slmItem.Icon = Functions.FAwesome.GetAwesomeIcon(cItem.Icon, cItem.IconColor);
slmItem.HorizontalContentAlignment = HorizontalAlignment.Left;
slmItem.VerticalContentAlignment = VerticalAlignment.Center;
SLMItem.Tag = cItem.Action;
SLMItem.Icon = Functions.FAwesome.GetAwesomeIcon(cItem.Icon, cItem.IconColor);
SLMItem.HorizontalContentAlignment = HorizontalAlignment.Left;
SLMItem.VerticalContentAlignment = VerticalAlignment.Center;
SLMItem.Click += Main.FormAccessor.AppCMenuItem_Click;

rightClickMenu.Add(slmItem);
rightClickMenu.Add(SLMItem);
}
}

Expand Down Expand Up @@ -131,42 +133,50 @@ public async void ParseMenuItemActionAsync(string Action)

public List<FileSystemInfo> GetFileList(bool includeDownloads = true, bool includeWorkshop = true)
{
List<FileSystemInfo> FileList = new List<FileSystemInfo>();

if (IsCompressed)
{
FileList.Add(CompressedArchiveName);
}
else
try
{
if (CommonFolder.Exists)
{
FileList.AddRange(GetCommonFiles());
}
List<FileSystemInfo> FileList = new List<FileSystemInfo>();

if (includeDownloads && DownloadFolder.Exists)
if (IsCompressed)
{
FileList.AddRange(GetDownloadFiles());
FileList.AddRange(GetPatchFiles());
FileList.Add(CompressedArchiveName);
}

if (includeWorkshop && WorkShopPath.Exists)
else
{
FileList.AddRange(GetWorkshopFiles());
}
if (CommonFolder.Exists)
{
FileList.AddRange(GetCommonFiles());
}

if (FullAcfPath.Exists)
{
FileList.Add(FullAcfPath);
}
if (includeDownloads && DownloadFolder.Exists)
{
FileList.AddRange(GetDownloadFiles());
FileList.AddRange(GetPatchFiles());
}

if (WorkShopAcfPath.Exists)
{
FileList.Add(WorkShopAcfPath);
if (includeWorkshop && WorkShopPath.Exists)
{
FileList.AddRange(GetWorkshopFiles());
}

if (FullAcfPath.Exists)
{
FileList.Add(FullAcfPath);
}

if (WorkShopAcfPath.Exists)
{
FileList.Add(WorkShopAcfPath);
}
}
}

return FileList;
return FileList;
}
catch (Exception ex)
{
SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex));
return null;
}
}

public List<FileSystemInfo> GetCommonFiles() => CommonFolder.EnumerateFileSystemInfos("*", SearchOption.AllDirectories).Where(x => x is FileInfo).ToList();
Expand All @@ -186,18 +196,18 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca
ConcurrentBag<string> CreatedDirectories = new ConcurrentBag<string>();
List<FileSystemInfo> AppFiles = GetFileList();
CurrentTask.TotalFileCount = AppFiles.Count;
long TotalFileSize = 0;

try
{
long TotalFileSize = 0;
ParallelOptions parallelOptions = new ParallelOptions()
ParallelOptions POptions = new ParallelOptions()
{
CancellationToken = cancellationToken
};

Parallel.ForEach(AppFiles, parallelOptions, file =>
Parallel.ForEach(AppFiles, POptions, file =>
{
Interlocked.Add(ref TotalFileSize, (file as FileInfo).Length);
Interlocked.Add(ref TotalFileSize, ((FileInfo)file).Length);
});

CurrentTask.TotalFileSize = TotalFileSize;
Expand All @@ -209,16 +219,16 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca
// If the game is not compressed and user would like to compress it
if (!IsCompressed && CurrentTask.Compress)
{
FileInfo compressedArchive = new FileInfo(CompressedArchiveName.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName));
FileInfo CompressedArchive = new FileInfo(CompressedArchiveName.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName).Replace(".zip", ".slm"));

if (compressedArchive.Exists)
if (CompressedArchive.Exists)
{
compressedArchive.Delete();
CompressedArchive.Delete();
}

using (ZipArchive compressed = ZipFile.Open(compressedArchive.FullName, ZipArchiveMode.Create))
using (ZipArchive Archive = ZipFile.Open(CompressedArchive.FullName, ZipArchiveMode.Create))
{
CopiedFiles.Add(compressedArchive.FullName);
CopiedFiles.Add(CompressedArchive.FullName);

foreach (FileSystemInfo currentFile in AppFiles)
{
Expand All @@ -227,56 +237,58 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca
await Task.Delay(100);
}

string newFileName = currentFile.FullName.Substring(Library.Steam.SteamAppsFolder.FullName.Length + 1);
string FileNameInArchive = currentFile.FullName.Substring(Library.Steam.SteamAppsFolder.FullName.Length + 1);

CurrentTask.TaskStatusInfo = $"Compressing: {currentFile.Name} ({Functions.FileSystem.FormatBytes(((FileInfo)currentFile).Length)})";
compressed.CreateEntryFromFile(currentFile.FullName, newFileName, CompressionLevel.Optimal);
Archive.CreateEntryFromFile(currentFile.FullName, FileNameInArchive, CompressionLevel.Optimal);
CurrentTask.MovedFileSize += ((FileInfo)currentFile).Length;

if (CurrentTask.ReportFileMovement)
{
LogToTM($"[{AppName}] Moved file: {newFileName}");
LogToTM($"[{AppName}] Compressed file: {FileNameInArchive}");
}

Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"Moved file: {newFileName}", this);
Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"Compressed file: {FileNameInArchive}", this);

if (cancellationToken.IsCancellationRequested)
{
throw new OperationCanceledException(cancellationToken);
}
}
}

CompressedArchive.MoveTo(CompressedArchive.FullName.Replace(".slm", ".zip"));
}
// If the game is compressed and user would like to decompress it
else if (IsCompressed && !CurrentTask.Compress)
{
foreach (ZipArchiveEntry currentFile in ZipFile.OpenRead(CompressedArchiveName.FullName).Entries)
foreach (ZipArchiveEntry CurrentFile in ZipFile.OpenRead(CompressedArchiveName.FullName).Entries)
{
while (Framework.TaskManager.Paused)
{
await Task.Delay(100);
}

FileInfo newFile = new FileInfo(Path.Combine(CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName, currentFile.FullName));
FileInfo NewFile = new FileInfo(Path.Combine(CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName, CurrentFile.FullName));

if (!newFile.Directory.Exists)
if (!NewFile.Directory.Exists)
{
newFile.Directory.Create();
CreatedDirectories.Add(newFile.Directory.FullName);
NewFile.Directory.Create();
CreatedDirectories.Add(NewFile.Directory.FullName);
}

CurrentTask.TaskStatusInfo = $"Decompressing: {newFile.Name} ({Functions.FileSystem.FormatBytes(currentFile.Length)})";
currentFile.ExtractToFile(newFile.FullName, true);
CurrentTask.TaskStatusInfo = $"Decompressing: {NewFile.Name} ({Functions.FileSystem.FormatBytes(CurrentFile.Length)})";
CurrentFile.ExtractToFile(NewFile.FullName, true);

CopiedFiles.Add(newFile.FullName);
CurrentTask.MovedFileSize += currentFile.Length;
CopiedFiles.Add(NewFile.FullName);
CurrentTask.MovedFileSize += CurrentFile.Length;

if (CurrentTask.ReportFileMovement)
{
LogToTM($"[{AppName}] Moved file: {newFile.FullName}");
LogToTM($"[{AppName}] Decompressed file: {NewFile.FullName}");
}

Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"Moved file: {newFile.FullName}", this);
Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"Decompressed file: {NewFile.FullName}", this);

if (cancellationToken.IsCancellationRequested)
{
Expand All @@ -287,9 +299,9 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca
// Everything else
else
{
parallelOptions.MaxDegreeOfParallelism = 1;
POptions.MaxDegreeOfParallelism = 1;

Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, CurrentFile =>
Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, CurrentFile =>
{
FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName));

Expand Down Expand Up @@ -339,9 +351,9 @@ public async void CopyFilesAsync(List.TaskInfo CurrentTask, CancellationToken ca
Functions.Logger.LogToFile(Functions.Logger.LogType.App, $"File moved: {NewFile.FullName}", this);
});

parallelOptions.MaxDegreeOfParallelism = -1;
POptions.MaxDegreeOfParallelism = -1;

Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, CurrentFile =>
Parallel.ForEach(AppFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), POptions, CurrentFile =>
{
FileInfo NewFile = new FileInfo(CurrentFile.FullName.Replace(Library.Steam.SteamAppsFolder.FullName, CurrentTask.TargetLibrary.Steam.SteamAppsFolder.FullName));

Expand Down Expand Up @@ -438,7 +450,7 @@ await Main.FormAccessor.AppPanel.Dispatcher.Invoke(async delegate

Main.FormAccessor.TaskManager_Logs.Add($"[{AppName}] An error happened while moving game files. Time Elapsed: {CurrentTask.ElapsedTime.Elapsed}");
Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ex}");
await SLM.ravenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ex));
await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ex));
}
}

Expand Down Expand Up @@ -530,11 +542,13 @@ public async Task<bool> DeleteFilesAsync(List.TaskInfo CurrentTask = null)
}
catch (FileNotFoundException)
{ return true; }
catch (DirectoryNotFoundException)
{ return true; }
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
Functions.Logger.LogToFile(Functions.Logger.LogType.SLM, $"[{AppName}][{AppID}][{AcfName}] {ex}");
await SLM.ravenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ex));
await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ex));

return false;
}
Expand Down
16 changes: 11 additions & 5 deletions Source/Steam Library Manager/Definitions/Enums/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace Steam_Library_Manager.Definitions.Enums
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum AppSortingMethod
{
[Description("Sort by appName")]
[Description("Name")]
appName,
[Description("Sort by appID")]
[Description("AppID")]
appID,
[Description("Sort by app size on disk")]
[Description("Size on disk")]
sizeOnDisk,
[Description("Sort by backup type")]
[Description("Backup type")]
backupType,
[Description("Sort by latest update time")]
[Description("Last write time")]
LastUpdated
}

Expand All @@ -33,9 +33,12 @@ public enum ArchiveSizeCalculationMethod
Uncompressed
}

[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum LibraryStyle
{
[Description("Grid View")]
Grid,
[Description("List View")]
Listview
}

Expand Down Expand Up @@ -87,9 +90,12 @@ public enum ThemeAccents
Sienna
}

[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum BaseTheme
{
[Description("Light")]
BaseLight,
[Description("Dark")]
BaseDark
}
}
Loading

0 comments on commit 81d5b5c

Please sign in to comment.