Skip to content

Commit

Permalink
v1.7.0 | Fix new steam library creation & steam library deletion
Browse files Browse the repository at this point in the history
RevoLand committed Dec 18, 2022
1 parent a77fde3 commit 582f310
Showing 9 changed files with 96 additions and 11 deletions.
Binary file modified Binaries/Steam Library Manager.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions Binaries/Version.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.6.0.4</version>
<url>http://github.com/RevoLand/Steam-Library-Manager/releases/download/v1.6.0.4/Steam.Library.Manager.zip</url>
<version>1.7.0.0</version>
<url>http://github.com/RevoLand/Steam-Library-Manager/releases/download/v1.7.0.0/Steam.Library.Manager.zip</url>
<changelog>https://github.com/RevoLand/Steam-Library-Manager/releases</changelog>
<mandatory>false</mandatory>
</item>
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]
## [1.7.0.0] - 2022-12-18

### Fixed

* Steam library creation ([#101](https://github.com/RevoLand/Steam-Library-Manager/issues/101))
* Steam library deletion ([#103](https://github.com/RevoLand/Steam-Library-Manager/issues/103))

## [1.6.0.5] - 2021-01-01

1 change: 1 addition & 0 deletions Source/Steam Library Manager/Definitions/Global.cs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ public static class Steam
public const string RegistryKeyPath = @"HKEY_CURRENT_USER\SOFTWARE\Valve\Steam";

public static string VdfFilePath = Alphaleonis.Win32.Filesystem.Path.Combine(Properties.Settings.Default.steamInstallationPath, "config", "config.vdf");
public static string LibraryFoldersPath = Alphaleonis.Win32.Filesystem.Path.Combine(Properties.Settings.Default.steamInstallationPath, "config", "libraryfolders.vdf");

public static bool IsStateChanging, Loaded;
}
53 changes: 52 additions & 1 deletion Source/Steam Library Manager/Definitions/SteamLibrary.cs
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using DirectoryInfo = Alphaleonis.Win32.Filesystem.DirectoryInfo;
using File = Alphaleonis.Win32.Filesystem.File;
@@ -323,7 +324,21 @@ public override async void RemoveLibraryAsync(bool withFiles)
keyValReader.ReadFileAsText(Global.Steam.VdfFilePath);

// Remove old library
keyValReader["Software"]["Valve"]["Steam"].Children.RemoveAll(x => x.Value == FullPath);
keyValReader["Software"]["Valve"]["Steam"].Children.RemoveAll(x =>
{
if (string.IsNullOrEmpty(x.Value))
{
return false;
}

var libraryPath = x.Value;
if (!libraryPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
libraryPath += Path.DirectorySeparatorChar;
}

return libraryPath == FullPath;
});

var i = 1;
foreach (var key in keyValReader["Software"]["Valve"]["Steam"].Children.FindAll(x => x.Name.Contains("BaseInstallFolder")))
@@ -342,6 +357,42 @@ public override async void RemoveLibraryAsync(bool withFiles)
File.Delete(Path.Combine(Properties.Settings.Default.steamInstallationPath, "steamapps", "libraryfolders.vdf"));
}

// Make a KeyValue reader
keyValReader = new Framework.KeyValue();

if (File.Exists(Definitions.Global.Steam.LibraryFoldersPath))
{
// Read vdf file
keyValReader.ReadFileAsText(Definitions.Global.Steam.LibraryFoldersPath);

keyValReader.Children.RemoveAll(x =>
{
if (x.Children.Count() == 0)
{
return true;
}

return x.Children.Any(children =>
{
if (children.Name != "path")
{
return false;
}

var libraryPath = children.Value;
if (!libraryPath.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
libraryPath += Path.DirectorySeparatorChar;
}

return libraryPath == FullPath;
});
});

// Update libraryFolders.vdf file with changes
keyValReader.SaveToFile(Definitions.Global.Steam.LibraryFoldersPath, false);
}

Functions.Steam.RestartSteamAsync();
}
catch (Exception ex)
3 changes: 2 additions & 1 deletion Source/Steam Library Manager/Forms/LibraryView.xaml.cs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Steam_Library_Manager.Definitions.Enums;

namespace Steam_Library_Manager.Forms
{
@@ -128,7 +129,7 @@ private void LibraryActionButtons_Click(object sender, RoutedEventArgs e)
break;

case "remove":
if (Definitions.SLM.CurrentSelectedLibrary != null && !Definitions.SLM.CurrentSelectedLibrary.IsMain && Functions.TaskManager.TaskList.Count(x => x.TargetLibrary == Definitions.SLM.CurrentSelectedLibrary || x.App?.Library == Definitions.SLM.CurrentSelectedLibrary) == 0)
if (Definitions.SLM.CurrentSelectedLibrary != null && !Definitions.SLM.CurrentSelectedLibrary.IsMain && Definitions.SLM.CurrentSelectedLibrary.Type != LibraryType.Steam && Functions.TaskManager.TaskList.Count(x => x.TargetLibrary == Definitions.SLM.CurrentSelectedLibrary || x.App?.Library == Definitions.SLM.CurrentSelectedLibrary) == 0)
{
Definitions.List.Libraries.Remove(Definitions.SLM.CurrentSelectedLibrary);

24 changes: 23 additions & 1 deletion Source/Steam Library Manager/Functions/Steam.cs
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Steam_Library_Manager.Definitions;
using System.Windows.Input;

namespace Steam_Library_Manager.Functions
{
@@ -513,10 +515,30 @@ public static async void CreateNew(string NewLibraryPath, bool Backup)
MessageBox.Show(SLM.Translate(nameof(Properties.Resources.CreateSteamLibrary_UnknownError)));
}
}

// Add library to list
AddNew(NewLibraryPath);

if (File.Exists(Path.Combine(Properties.Settings.Default.steamInstallationPath, "steamapps", "libraryfolders.vdf")))
{
File.Delete(Path.Combine(Properties.Settings.Default.steamInstallationPath, "steamapps", "libraryfolders.vdf"));
}

if (File.Exists(Definitions.Global.Steam.LibraryFoldersPath))
{
Framework.KeyValue Key = new Framework.KeyValue();
// Read vdf file as text
Key.ReadFileAsText(Definitions.Global.Steam.LibraryFoldersPath);

int NewSteamLibraryIndex = Key.Children.Count;

Key.Children.Add(new Framework.KeyValue(NewSteamLibraryIndex.ToString()));
Key[NewSteamLibraryIndex.ToString()].Children.Add(new Framework.KeyValue("path", NewLibraryPath));
Key[NewSteamLibraryIndex.ToString()].Children.Add(new Framework.KeyValue("label", ""));
Key[NewSteamLibraryIndex.ToString()].Children.Add(new Framework.KeyValue("mounted", "1"));
Key[NewSteamLibraryIndex.ToString()].Children.Add(new Framework.KeyValue("contentid", ""));
Key.SaveToFile(Definitions.Global.Steam.LibraryFoldersPath, false);
}

// Save our settings
SLM.Settings.SaveSettings();
}
11 changes: 8 additions & 3 deletions Source/Steam Library Manager/Functions/Uplay.cs
Original file line number Diff line number Diff line change
@@ -195,9 +195,14 @@ public static void UpdateInstallationPath()
{
try
{
Properties.Settings.Default.UplayExePath = Registry
.GetValue(Definitions.Global.Uplay.LauncherRegistryPath, "InstallDir", "").ToString()
.Replace('/', Path.DirectorySeparatorChar);
var uplayInstallDir = Registry.GetValue(Definitions.Global.Uplay.LauncherRegistryPath, "InstallDir", "")?.ToString();

if (string.IsNullOrEmpty(uplayInstallDir))
{
return;
}

Properties.Settings.Default.UplayExePath = uplayInstallDir.Replace('/', Path.DirectorySeparatorChar);

var installationsRegistry = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey(Definitions.Global.Uplay.InstallationsRegistryPath) ?? RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(Definitions.Global.Uplay.InstallationsRegistryPath);

4 changes: 2 additions & 2 deletions Source/Steam Library Manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -48,6 +48,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.0.4")]
[assembly: AssemblyFileVersion("1.6.0.4")]
[assembly: AssemblyVersion("1.7.0.0")]
[assembly: AssemblyFileVersion("1.7.0.0")]
[assembly: NeutralResourcesLanguage("en")]

0 comments on commit 582f310

Please sign in to comment.