Skip to content

Commit

Permalink
Further fixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RevoLand committed Aug 20, 2017
1 parent ba4b6b8 commit 12fc3dc
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 68 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ Binaries/*.config
Binaries/*.pdb
Binaries/*vshost*
Binaries/Logs/*
Binaries/.slmcache/*
*.suo
Source/Steam Library Manager/obj/*
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.3.0|Fixes and improvements have been done
1.4.4.0|ACF File Detection, search function and some other fixes & improvements
1 change: 1 addition & 0 deletions Source/Steam Library Manager/Definitions/Directories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SLM
// Set cache directory of SLM to %temp%/Assembly Name (Steam Library Manager)
public static string CacheDirectory = Path.Combine(Path.GetTempPath(), System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);

public static string HeaderImageDirectory = Path.Combine(Directories.SLM.CurrentDirectory, ".slmcache");
}
}
}
12 changes: 6 additions & 6 deletions Source/Steam Library Manager/Definitions/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,9 @@ public void CopyGameFiles(List.TaskList currentTask, CancellationToken cancellat
// Everything else
else
{
parallelOptions.MaxDegreeOfParallelism = new Random().Next(4, 16);

LogToTM($"Parallelism degree: {parallelOptions.MaxDegreeOfParallelism}");
parallelOptions.MaxDegreeOfParallelism = 1;

Parallel.ForEach(GameFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, currentFile =>
Parallel.ForEach(GameFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, currentFile =>
{
FileInfo newFile = new FileInfo(currentFile.FullName.Replace(InstalledLibrary.SteamAppsFolder.FullName, currentTask.TargetLibrary.SteamAppsFolder.FullName));

Expand All @@ -331,9 +329,10 @@ public void CopyGameFiles(List.TaskList currentTask, CancellationToken cancellat
Functions.Logger.LogToFile(Functions.Logger.LogType.Game, $"[{CopiedFiles.Count}/{currentTask.TotalFileCount}] Moven file: {newFile.FullName}", this);
});

parallelOptions.MaxDegreeOfParallelism = 1;
parallelOptions.MaxDegreeOfParallelism = new Random().Next(6, 12);
LogToTM($"Parallelism degree: {parallelOptions.MaxDegreeOfParallelism}");

Parallel.ForEach(GameFiles.Where(x => (x as FileInfo).Length > Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, currentFile =>
Parallel.ForEach(GameFiles.Where(x => (x as FileInfo).Length <= Properties.Settings.Default.ParallelAfterSize * 1000000).OrderByDescending(x => (x as FileInfo).Length), parallelOptions, currentFile =>
{
FileInfo newFile = new FileInfo(currentFile.FullName.Replace(InstalledLibrary.SteamAppsFolder.FullName, currentTask.TargetLibrary.SteamAppsFolder.FullName));

Expand All @@ -358,6 +357,7 @@ public void CopyGameFiles(List.TaskList currentTask, CancellationToken cancellat

Functions.Logger.LogToFile(Functions.Logger.LogType.Game, $"[{CopiedFiles.Count}/{currentTask.TotalFileCount}] Moven file: {newFile.FullName}", this);
});

}


Expand Down
50 changes: 0 additions & 50 deletions Source/Steam Library Manager/Definitions/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,56 +370,6 @@ public void ParseMenuItemAction(string Action)
Main.Accessor.gamePanel.ItemsSource = null;
}
break;
case "updategames":
if (Games.Count == 0)
return;

if (List.Libraries.Count(x => x.IsBackup) == 0)
return;

try
{
foreach (Library LibraryToCheck in List.Libraries.Where(x => x.IsBackup))
{
foreach (Game LatestGame in Games)
{
if (LibraryToCheck.Games.Count(x => x.AppID == LatestGame.AppID && x.LastUpdated < LatestGame.LastUpdated) > 0)
{
Game OldGameBackup = LibraryToCheck.Games.First(x => x.AppID == LatestGame.AppID && x.LastUpdated < LatestGame.LastUpdated);

if (Framework.TaskManager.TaskList.Count(x => x.TargetGame == LatestGame && x.TargetLibrary == OldGameBackup.InstalledLibrary) == 0)
{
List.TaskList newTask = new List.TaskList
{
TargetGame = LatestGame,
TargetLibrary = OldGameBackup.InstalledLibrary
};

Framework.TaskManager.TaskList.Add(newTask);
Main.Accessor.taskPanel.Items.Add(newTask);

System.Windows.Media.Animation.DoubleAnimation da = new System.Windows.Media.Animation.DoubleAnimation()
{
From = 12,
To = 14,
AutoReverse = true,
Duration = new Duration(TimeSpan.FromSeconds(0.3))
};

Main.Accessor.Tab_TaskManager.BeginAnimation(TextBlock.FontSizeProperty, da);
}

Debug.WriteLine($"An update is available for: {LatestGame.AppName} - Old backup time: {OldGameBackup.LastUpdated} - Latest game time: {LatestGame.LastUpdated}");
Main.Accessor.TaskManager_Logs.Add($"[{DateTime.Now}] An update is available for: {LatestGame.AppName} - Old backup time: {OldGameBackup.LastUpdated} - Updated on: {LatestGame.LastUpdated} - Source: {OldGameBackup.InstalledLibrary.FullPath}");
}
}
}
}
catch (Exception ex)
{
Functions.Logger.LogToFile(Functions.Logger.LogType.Library, ex.ToString());
}
break;
}
}

Expand Down
14 changes: 13 additions & 1 deletion Source/Steam Library Manager/Definitions/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,19 @@ public long TotalFileSize

public double ProgressBarPerc
{
get => _MovenFileSize == 0 ? 0 :((int)Math.Round((double)(100 * _MovenFileSize) / _TotalFileSize));
get
{
double perc = Math.Ceiling((double)(100 * _MovenFileSize) / _TotalFileSize);
Main.Accessor.TaskbarItemInfo.ProgressValue = perc / 100;

if (perc == 100)
{
Main.Accessor.TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.None;
Main.Accessor.TaskbarItemInfo.ProgressValue = 0;
}

return _MovenFileSize == 0 ? 0 : perc;
}
}

public bool Completed
Expand Down
12 changes: 11 additions & 1 deletion Source/Steam Library Manager/Forms/Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
xmlns:cachedImage="clr-namespace:Steam_Library_Manager.Framework.CachedImage"
x:Name="mainForm" x:Class="Steam_Library_Manager.Main"
Title="Steam Library Manager" Icon="/Steam Library Manager;component/Resources/steam-icon.ico" MinWidth="930" MinHeight="800" Width="920" Height="800" SnapsToDevicePixels="True" Loaded="MainForm_Loaded" Closing="MainForm_Closing" WindowStyle="ThreeDBorderWindow" SourceInitialized="MainForm_SourceInitialized">
<Window.TaskbarItemInfo>
<TaskbarItemInfo/>
</Window.TaskbarItemInfo>
<Window.Resources>
<DataTemplate x:Key="Gamelibrary_Gridview">
<Grid MouseMove="Gamelibrary_MouseMove" ScrollViewer.VerticalScrollBarVisibility="Auto" MouseDown="Grid_MouseDown">
Expand Down Expand Up @@ -105,6 +108,7 @@
<MenuItem Header="Remove selected Game(s) from Queue" Tag="Remove" Click="TaskManager_ContextMenu_Click"></MenuItem>
</ContextMenu>
</Grid.ContextMenu>

<ProgressBar Maximum="100" Value="{Binding ProgressBarPerc, Mode=OneWay}" >
<ProgressBar.Style>
<Style TargetType="ProgressBar">
Expand Down Expand Up @@ -404,6 +408,7 @@
</ListView>

<TextBox Margin="215,0,10,10" TextWrapping="Wrap" Height="25" VerticalAlignment="Bottom" Text="{slm:SettingBinding SearchText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" TextChanged="TextBox_TextChanged" />
<Button Content="Reset Search" HorizontalAlignment="Right" Margin="0,0,10,10" VerticalAlignment="Bottom" Width="150" Height="25" Click="ResetSearchTextButton_Click"/>
</Grid>
</TabItem>
<TabItem x:Name="Tab_TaskManager" Header="Task Manager" Padding="20, 10">
Expand Down Expand Up @@ -433,6 +438,7 @@
<Button x:Name="Button_StartTaskManager" Content="Start Task Manager" Tag="Start" Click="TaskManager_Buttons_Click" Margin="0,0,105,0" HorizontalAlignment="Left" Width="140" MinHeight="30" MaxHeight="30" Height="30" VerticalAlignment="Bottom" />
<Button x:Name="Button_StopTaskManager" IsEnabled="False" Content="Stop Task Manager" Tag="Stop" Click="TaskManager_Buttons_Click" HorizontalAlignment="Left" Width="140" MinHeight="30" MaxHeight="30" Height="30" VerticalAlignment="Bottom" Margin="145,0,0,0" />
<Button Content="Clear Completed Tasks" Tag="ClearCompleted" Click="TaskManager_Buttons_Click" Margin="290,0,0,0" HorizontalAlignment="Left" Width="140" MinHeight="30" MaxHeight="30" Height="30" VerticalAlignment="Bottom" />
<Button Content="Check for Backup Updates" Tag="BackupUpdates" Click="TaskManager_Buttons_Click" Margin="435,0,-146,0" HorizontalAlignment="Left" Width="161" MinHeight="30" MaxHeight="30" Height="30" VerticalAlignment="Bottom" />
</Grid>

<ListView x:Name="TaskManager_LogsView" Margin="10,0,10,10" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Height="240" VerticalAlignment="Bottom" >
Expand Down Expand Up @@ -541,14 +547,18 @@
<!-- 2#3 -->
<CheckBox Content="Advanced Logging (req. restart)" IsChecked="{slm:SettingBinding Advanced_Logging, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="225,130,0,0" VerticalAlignment="Top" Height="20" Width="210"/>
<Button Content="View Logs" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="225,155,0,0" Height="25" Width="210" HorizontalAlignment="Left" VerticalAlignment="Top" Click="ViewLogsButton" />


<!-- 2#4-->
<Button Content="Clear Header Image Cache" HorizontalAlignment="Left" Margin="225,185,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="210" Height="25" Click="HeaderImageClearButton_Click"/>

<!-- 3#1 -->
<Label Content="Include search results" HorizontalAlignment="Left" Margin="440,10,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="210"/>
<CheckBox IsChecked="{slm:SettingBinding includeSearchResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="440,40,0,0" VerticalAlignment="Top" Height="17" Width="210"/>
<!-- 3#2 -->
<Label Content="Play a sound on completion" HorizontalAlignment="Left" Margin="440,70,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="210"/>
<CheckBox IsChecked="{slm:SettingBinding PlayASoundOnCompletion, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="440,100,0,0" VerticalAlignment="Top" Height="17" Width="210"/>


<!-- 4#1 -->
<Label Content="Check for Updates at Startup" HorizontalAlignment="Left" Margin="655,10,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="165"/>
<CheckBox IsChecked="{slm:SettingBinding CheckforUpdatesAtStartup, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="655,40,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" VerticalAlignment="Top" Height="17" Width="165"/>
Expand Down
25 changes: 23 additions & 2 deletions Source/Steam Library Manager/Forms/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void UpdateBindings()
{
Accessor = this;

Properties.Settings.Default.SearchText = "";

libraryPanel.ItemsSource = Definitions.List.Libraries;

libraryContextMenuItems.ItemsSource = Definitions.List.LibraryCMenuItems;
Expand Down Expand Up @@ -262,8 +264,6 @@ private void LibraryGrid_MouseDown(object sender, SelectionChangedEventArgs e)

// Update games list from current selection
Functions.Games.UpdateMainForm(Definitions.SLM.selectedLibrary, (Properties.Settings.Default.includeSearchResults) ? Properties.Settings.Default.SearchText : null);

Definitions.SLM.selectedLibrary.ParseMenuItemAction("updategames");
}

private void TaskManager_Buttons_Click(object sender, RoutedEventArgs e)
Expand All @@ -279,6 +279,9 @@ private void TaskManager_Buttons_Click(object sender, RoutedEventArgs e)
Framework.TaskManager.Stop();
Button_StopTaskManager.IsEnabled = false;
break;
case "BackupUpdates":
Functions.Library.CheckForBackupUpdates();
break;
case "ClearCompleted":
if (taskPanel.Items.Count == 0)
return;
Expand Down Expand Up @@ -558,5 +561,23 @@ private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
if (Definitions.SLM.selectedLibrary != null)
Functions.Games.UpdateMainForm(Definitions.SLM.selectedLibrary, Properties.Settings.Default.SearchText);
}

private void ResetSearchTextButton_Click(object sender, RoutedEventArgs e)
{
Properties.Settings.Default.SearchText = "";
}

private void HeaderImageClearButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (Directory.Exists(Definitions.Directories.SLM.HeaderImageDirectory))
{
Directory.Delete(Definitions.Directories.SLM.HeaderImageDirectory, true);
MessageBox.Show("Header Image Cache cleared.");
}
}
catch { }
}
}
}
10 changes: 4 additions & 6 deletions Source/Steam Library Manager/Framework/CachedImage/FileCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Windows;

// https://github.com/floydpink/CachedImage
// Highly modified over the original one
Expand All @@ -15,15 +14,14 @@ public static async System.Threading.Tasks.Task<MemoryStream> HitAsync(Uri url)
{
try
{
string AppCacheDirectory = Path.Combine(Definitions.SLM.selectedLibrary.SteamAppsFolder.FullName, "HeaderImages");
var localFile = $"{AppCacheDirectory}\\{url.AbsolutePath.Replace("/steam/apps/", "").Replace("/header", "")}";
var localFile = $"{Definitions.Directories.SLM.HeaderImageDirectory}\\{url.AbsolutePath.Replace("/steam/apps/", "").Replace("/header", "")}";

MemoryStream memoryStream = new MemoryStream();

if (!File.Exists(localFile))
{
if (!Directory.Exists(AppCacheDirectory))
Directory.CreateDirectory(AppCacheDirectory);
if (!Directory.Exists(Definitions.Directories.SLM.HeaderImageDirectory))
Directory.CreateDirectory(Definitions.Directories.SLM.HeaderImageDirectory);

new WebClient().DownloadFileAsync(url, localFile);

Expand All @@ -43,7 +41,7 @@ public static async System.Threading.Tasks.Task<MemoryStream> HitAsync(Uri url)
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
//MessageBox.Show(ex.ToString());
Debug.WriteLine(ex);

return null;
Expand Down
4 changes: 4 additions & 0 deletions Source/Steam Library Manager/Framework/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public static void Start()
{
if (!Status)
{
Main.Accessor.TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.Normal;

Main.Accessor.TaskManager_Logs.Add($"[{DateTime.Now}] [TaskManager] Task Manager is now active and waiting for tasks...");
Main.Accessor.Button_StartTaskManager.IsEnabled = false;
Main.Accessor.Button_StopTaskManager.IsEnabled = true;
Expand Down Expand Up @@ -101,6 +103,8 @@ public static void Stop()
{
if (Status)
{
Main.Accessor.TaskbarItemInfo.ProgressState = System.Windows.Shell.TaskbarItemProgressState.None;
Main.Accessor.TaskbarItemInfo.ProgressValue = 0;
Main.Accessor.Button_StartTaskManager.IsEnabled = true;
Main.Accessor.Button_StopTaskManager.IsEnabled = false;

Expand Down
Loading

0 comments on commit 12fc3dc

Please sign in to comment.