Skip to content

Commit

Permalink
Fixes and improvements have been done, also done with Settings page f…
Browse files Browse the repository at this point in the history
…or now.
  • Loading branch information
RevoLand committed Aug 13, 2016
1 parent 1d1531e commit 1533154
Show file tree
Hide file tree
Showing 19 changed files with 352 additions and 91 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.3.0.0|Complete overhaul as wpf
1.3.1.0|Fixes and improvements have been done, also done with Settings page for now.
36 changes: 36 additions & 0 deletions Source/Steam Library Manager/Definitions/Enums/Enums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Steam_Library_Manager.Framework;
using System.ComponentModel;

namespace Steam_Library_Manager.Definitions.Enums
{
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum GameSortingMethod
{
[Description("Sort by appName")]
appName = 0,
[Description("Sort by appID")]
appID = 1,
[Description("Sort by app size on disk")]
sizeOnDisk = 2,
[Description("Sort by backup type")]
backupType = 3
}

public enum gameSizeCalculationMethod
{
ACF = 0,
Enumeration = 1
}

public enum archiveSizeCalculationMethod
{
compressed = 0,
unUncompressed = 1
}

public enum menuVisibility
{
NotVisible,
Visible
}
}
8 changes: 4 additions & 4 deletions Source/Steam Library Manager/Definitions/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ public Framework.AsyncObservableCollection<FrameworkElement> generateRightClickM
{
foreach (List.contextMenu cItem in List.gameContextMenuItems.Where(x => x.IsActive))
{
if (IsSteamBackup && cItem.showToSteamBackup == SLM.Settings.menuVisibility.NotVisible)
if (IsSteamBackup && cItem.showToSteamBackup == Enums.menuVisibility.NotVisible)
continue;
else if (installedLibrary.Backup && cItem.showToSLMBackup == SLM.Settings.menuVisibility.NotVisible)
else if (installedLibrary.Backup && cItem.showToSLMBackup == Enums.menuVisibility.NotVisible)
continue;
else if (IsCompressed && cItem.showToCompressed == SLM.Settings.menuVisibility.NotVisible)
else if (IsCompressed && cItem.showToCompressed == Enums.menuVisibility.NotVisible)
continue;
else if (cItem.showToNormal == SLM.Settings.menuVisibility.NotVisible)
else if (cItem.showToNormal == Enums.menuVisibility.NotVisible)
continue;

if (cItem.IsSeparator)
Expand Down
27 changes: 3 additions & 24 deletions Source/Steam Library Manager/Definitions/Library.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
Expand Down Expand Up @@ -46,31 +45,11 @@ public void UpdateGameList()

Functions.Games.AddNewGame(acfFilePath, Convert.ToInt32(Key["appID"].Value), !string.IsNullOrEmpty(Key["name"].Value) ? Key["name"].Value : Key["UserConfig"]["name"].Value, Key["installdir"].Value, this, Convert.ToInt64(Key["SizeOnDisk"].Value), false);
});

// Do a loop for each *.zip file in library
//foreach (string gameArchive in Directory.EnumerateFiles(steamAppsPath.FullName, "*.zip", SearchOption.TopDirectoryOnly))
Parallel.ForEach(Directory.EnumerateFiles(steamAppsPath.FullName, "*.zip", SearchOption.TopDirectoryOnly), gameArchive =>
{
// Open archive for read
using (ZipArchive compressedArchive = ZipFile.OpenRead(gameArchive))
{
// For each file in opened archive
foreach (ZipArchiveEntry acfFilePath in compressedArchive.Entries.Where(x => x.Name.Contains(".acf")))
{
// If it contains
// Define a KeyValue reader
Framework.KeyValue Key = new Framework.KeyValue();

// Open .acf file from archive as text
Key.ReadAsText(acfFilePath.Open());

// If acf file has no children, skip this archive
if (Key.Children.Count == 0)
continue;

Functions.Games.AddNewGame(acfFilePath.FullName, Convert.ToInt32(Key["appID"].Value), !string.IsNullOrEmpty(Key["name"].Value) ? Key["name"].Value : Key["UserConfig"]["name"].Value, Key["installdir"].Value, this, Convert.ToInt64(Key["SizeOnDisk"].Value), true);
}
}
Functions.Games.readGameDetailsFromZip(gameArchive, this);
});

// If library is backup library
Expand Down Expand Up @@ -112,9 +91,9 @@ public Framework.AsyncObservableCollection<FrameworkElement> generateRightClickM
{
foreach (List.contextMenu cItem in List.libraryContextMenuItems.Where(x => x.IsActive))
{
if (Backup && cItem.showToSLMBackup == SLM.Settings.menuVisibility.NotVisible)
if (Backup && cItem.showToSLMBackup == Enums.menuVisibility.NotVisible)
continue;
else if (!Backup && cItem.showToNormal == SLM.Settings.menuVisibility.NotVisible)
else if (!Backup && cItem.showToNormal == Enums.menuVisibility.NotVisible)
continue;

if (cItem.IsSeparator)
Expand Down
23 changes: 5 additions & 18 deletions Source/Steam Library Manager/Definitions/List.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Globalization;
using System.Windows.Media;

namespace Steam_Library_Manager.Definitions
Expand All @@ -13,28 +11,17 @@ public class List
public static Framework.AsyncObservableCollection<contextMenu> libraryContextMenuItems = new Framework.AsyncObservableCollection<contextMenu>();
public static Framework.AsyncObservableCollection<contextMenu> gameContextMenuItems = new Framework.AsyncObservableCollection<contextMenu>();

public class Setting
{
public string steamInstallationPath { get; set; } = Properties.Settings.Default.steamInstallationPath;
public System.Collections.Specialized.StringCollection backupDirectories { get; set; } = Properties.Settings.Default.backupDirectories;
public SLM.Settings.GameSortingMethod defaultGameSortingMethod { get; set; } = (SLM.Settings.GameSortingMethod)Enum.Parse(typeof(SLM.Settings.GameSortingMethod), Properties.Settings.Default.defaultGameSortingMethod, true);
public SLM.Settings.gameSizeCalculationMethod gameSizeCalculationMethod { get; set; } = (SLM.Settings.gameSizeCalculationMethod)Enum.Parse(typeof(SLM.Settings.gameSizeCalculationMethod), Properties.Settings.Default.gameSizeCalculationMethod, true);
public SLM.Settings.archiveSizeCalculationMethod archiveSizeCalculationMethod { get; set; } = (SLM.Settings.archiveSizeCalculationMethod)Enum.Parse(typeof(SLM.Settings.archiveSizeCalculationMethod), Properties.Settings.Default.archiveSizeCalculationMethod, true);
public long ParallelAfterSize { get; set; } = Properties.Settings.Default.ParallelAfterSize;
public bool includeSearchResults { get; set; } = Properties.Settings.Default.includeSearchResults;
}

public class contextMenu
{
public bool IsActive { get; set; } = true;
public string Header { get; set; }
public string Action { get; set; }
public FontAwesome.WPF.FontAwesomeIcon Icon { get; set; } = FontAwesome.WPF.FontAwesomeIcon.None;
public Brush IconColor { get; set; }
public SLM.Settings.menuVisibility showToNormal { get; set; } = SLM.Settings.menuVisibility.Visible;
public SLM.Settings.menuVisibility showToSLMBackup { get; set; } = SLM.Settings.menuVisibility.Visible;
public SLM.Settings.menuVisibility showToSteamBackup { get; set; } = SLM.Settings.menuVisibility.Visible;
public SLM.Settings.menuVisibility showToCompressed { get; set; } = SLM.Settings.menuVisibility.Visible;
public Enums.menuVisibility showToNormal { get; set; } = Enums.menuVisibility.Visible;
public Enums.menuVisibility showToSLMBackup { get; set; } = Enums.menuVisibility.Visible;
public Enums.menuVisibility showToSteamBackup { get; set; } = Enums.menuVisibility.Visible;
public Enums.menuVisibility showToCompressed { get; set; } = Enums.menuVisibility.Visible;
public bool IsSeparator { get; set; }
}

Expand Down
28 changes: 0 additions & 28 deletions Source/Steam Library Manager/Definitions/SLM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,5 @@ public class SLM

public static Library selectedLibrary;
public static string userSteamID64;

public class Settings
{
public enum GameSortingMethod
{
appName,
appID,
sizeOnDisk
}

public enum gameSizeCalculationMethod
{
ACF,
Enumeration
}

public enum archiveSizeCalculationMethod
{
compressedSize,
unUncompressedSize
}

public enum menuVisibility
{
NotVisible,
Visible
}
}
}
}
31 changes: 27 additions & 4 deletions Source/Steam Library Manager/Forms/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Steam_Library_Manager"
xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:cachedImage="clr-namespace:Steam_Library_Manager.Framework.CachedImage" xmlns:slm="clr-namespace:Steam_Library_Manager" x:Name="mainForm" x:Class="Steam_Library_Manager.MainWindow"
xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:cachedImage="clr-namespace:Steam_Library_Manager.Framework.CachedImage" xmlns:slm="clr-namespace:Steam_Library_Manager" xmlns:enums="clr-namespace:Steam_Library_Manager.Definitions.Enums" x:Name="mainForm" x:Class="Steam_Library_Manager.MainWindow"
Title="Steam Library Manager" Icon="/Steam Library Manager;component/Resources/steam-icon.ico" MinWidth="800" MinHeight="670" Width="800" Height="670" SnapsToDevicePixels="True" Loaded="mainForm_Loaded" Closing="mainForm_Closing" WindowStyle="ThreeDBorderWindow" SourceInitialized="mainForm_SourceInitialized">
<Grid Margin="0,41,2,2">
<TabControl x:Name="tabControl" Margin="10,0,10,10" BorderBrush="Black" Background="White">
Expand Down Expand Up @@ -119,8 +119,29 @@
</TabItem>
<TabItem Header="Settings" Padding="20, 10">
<Grid Background="White">
<GroupBox x:Name="groupBox" Header="General Settings" Margin="10,10,10,380">
<Grid>
<!-- 1#1 -->
<Label x:Name="gameSortingMethodLabel" Content="Game sorting method:" HorizontalAlignment="Left" Margin="10,10,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="230"/>
<ComboBox x:Name="gameSortingMethod" HorizontalAlignment="Left" Margin="10,36,0,0" VerticalAlignment="Top" Width="230" ItemsSource="{local:EnumBindingSource {x:Type enums:GameSortingMethod}}" SelectionChanged="gameSortingMethod_SelectionChanged" />
<!-- 1#2 -->
<Label x:Name="gameSizeCalcMethodLabel" Content="Game size calculation method:" HorizontalAlignment="Left" Margin="10,58,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="230"/>
<ComboBox x:Name="gameSizeCalcMethod" HorizontalAlignment="Left" Margin="10,84,0,0" VerticalAlignment="Top" Width="230" ItemsSource="{slm:EnumBindingSource {x:Type enums:gameSizeCalculationMethod}}" SelectionChanged="gameSizeCalcMethod_SelectionChanged" />
<!-- 2#1 -->
<Label x:Name="archiveSizeCalcMethodLabel" Content="Archive size calculation method:" HorizontalAlignment="Left" Margin="245,10,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="230"/>
<ComboBox x:Name="archiveSizeCalcMethod" HorizontalAlignment="Left" Margin="245,36,0,0" VerticalAlignment="Top" Width="230" ItemsSource="{slm:EnumBindingSource {x:Type enums:archiveSizeCalculationMethod}}" SelectionChanged="archiveSizeCalcMethod_SelectionChanged" />
<!-- 2#2 -->
<Label x:Name="parallelAfterSizeLabel" Content="Move files 1 by 1 after that size: (bytes)" HorizontalAlignment="Left" Margin="245,58,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="230"/>
<TextBox x:Name="parallelAfterSize" HorizontalAlignment="Left" Margin="245,84,0,0" VerticalAlignment="Top" Width="230" Text="{slm:SettingBinding ParallelAfterSize}" Height="22" />
<!-- 3#1 -->
<Label x:Name="includeSearchResultsLabel" Content="Inc. search results while selecting another library" HorizontalAlignment="Left" Margin="480,10,0,0" HorizontalContentAlignment="Center" VerticalAlignment="Top" Width="230"/>
<CheckBox x:Name="includeSearchResults" IsChecked="{slm:SettingBinding includeSearchResults}" Content="Library" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Margin="480,36,0,0" VerticalAlignment="Top" Height="17" Width="230"/>
<!-- 3#2 -->
<Button x:Name="checkForUpdates" Content="Check for Updates" HorizontalAlignment="Left" Margin="480,58,0,0" VerticalAlignment="Top" Width="230" Height="48" Click="checkForUpdates_Click"/>
</Grid>
</GroupBox>

<DataGrid x:Name="libraryContextMenuItems" Margin="10,0,10,215" IsSynchronizedWithCurrentItem="True" Height="200" VerticalAlignment="Bottom">
<DataGrid x:Name="libraryContextMenuItems" Margin="10,0,10,195" IsSynchronizedWithCurrentItem="True" Height="180" VerticalAlignment="Bottom">
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Click="libraryDataGridMenuItem_Click" Header="Move Up" Tag="moveUp" />
Expand All @@ -129,7 +150,7 @@
</DataGrid.ContextMenu>
</DataGrid>

<DataGrid x:Name="gameContextMenuItems" Margin="10,0,10,10" IsSynchronizedWithCurrentItem="True" Height="200" VerticalAlignment="Bottom">
<DataGrid x:Name="gameContextMenuItems" Margin="10,0,10,10" IsSynchronizedWithCurrentItem="True" Height="180" VerticalAlignment="Bottom">
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Click="gameDataGridMenuItem_Click" Header="Move Up" Tag="moveUp" />
Expand All @@ -139,6 +160,8 @@
</DataGrid>
</Grid>
</TabItem>
<!--
Removen as PayPal no longer works in Turkey
<TabItem Header="About" Padding="20, 10">
<Grid Background="#FFE5E5E5">
<Grid Margin="10,10,10,145">
Expand All @@ -150,7 +173,7 @@
</Grid>
</Grid>
</TabItem>
</TabItem> -->
</TabControl>
</Grid>
</Window>
51 changes: 50 additions & 1 deletion Source/Steam Library Manager/Forms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,17 @@ private void libraryPanel_Drop(object sender, DragEventArgs e)
if (!Functions.Library.libraryExists(droppedItem))
{
if (Directory.GetDirectoryRoot(droppedItem) != droppedItem)
Functions.Library.createNewLibrary(details.FullName, true);
{
bool isNewLibraryForBackup = false;
MessageBoxResult selectedLibraryType = MessageBox.Show("Is this selected folder going to be used for backups?", "SLM library or Steam library?", MessageBoxButton.YesNoCancel);

if (selectedLibraryType == MessageBoxResult.Cancel)
return;
else if (selectedLibraryType == MessageBoxResult.Yes)
isNewLibraryForBackup = true;

Functions.Library.createNewLibrary(details.FullName, isNewLibraryForBackup);
}
else
MessageBox.Show("Libraries can not be created at root");
}
Expand Down Expand Up @@ -204,5 +214,44 @@ private void donateButton_MouseDown(object sender, MouseButtonEventArgs e)
}
catch { }
}

private void gameSortingMethod_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
Properties.Settings.Default.defaultGameSortingMethod = gameSortingMethod.SelectedItem.ToString();
}
catch { }
}

private void gameSizeCalcMethod_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
Properties.Settings.Default.gameSizeCalculationMethod = gameSizeCalcMethod.SelectedItem.ToString();
}
catch { }
}

private void archiveSizeCalcMethod_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
Properties.Settings.Default.archiveSizeCalculationMethod = archiveSizeCalcMethod.SelectedItem.ToString();
}
catch { }
}

private void checkForUpdates_Click(object sender, RoutedEventArgs e)
{
try
{
Functions.Updater.CheckForUpdates();
}
catch
{

}
}
}
}
3 changes: 2 additions & 1 deletion Source/Steam Library Manager/Forms/MoveGameForm.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void button_Click(object sender, RoutedEventArgs e)
bool removeOldGame = removeOldFiles.IsChecked.Value;
bool compressGame = compress.IsChecked.Value;

if (currentTask == null || currentTask.Status == System.Threading.Tasks.TaskStatus.Canceled)
if (currentTask == null)
{
formLogs.Clear();
button.Content = "Cancel";
Expand Down Expand Up @@ -150,6 +150,7 @@ private void button_Click(object sender, RoutedEventArgs e)
{
button.Content = "Copy";
cancellationToken.Cancel();
currentTask = null;
}
else
{
Expand Down
Loading

0 comments on commit 1533154

Please sign in to comment.