Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload list on export+Exclude from list entries present in vdf file #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions UWPHook/GamesWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ private async void ExportButton_Click(object sender, RoutedEventArgs e)
{
await ExportGames();
await RestartSteam(restartSteam);
LoadButton_Click(null, null);

msg = "Your apps were successfuly exported!";
if (!restartSteam)
Expand Down Expand Up @@ -715,6 +716,31 @@ private void Bwr_DoWork(object sender, DoWorkEventArgs e)
//Rejoin them in the original list, but putting them into last
installedApps = installedApps.Union(nameNotFound).ToList<String>();

//Get already installed apps from Steam Library
string steam_folder = SteamManager.GetSteamFolder();
VDFEntry[] vdf = new VDFEntry[0];

if (Directory.Exists(steam_folder))
{
var users = SteamManager.GetUsers(steam_folder);

foreach (var user in users)
{
try
{
if (Directory.Exists(user + @"\\config\\"))
{
vdf = VDFParser.VDFParser.Parse(user + @"\\config\\shortcuts.vdf");
break;
}
}
catch (Exception ex) when (!(ex is System.IO.FileNotFoundException) || !(ex is VDFParser.VDFTooShortException))
{
throw new Exception("Error: Program failed while trying to read your Steam shortcuts" + Environment.NewLine + ex.Message);
}
}
}

foreach (var app in installedApps)
{
//Remove end lines from the String and split both values, I split the appname and the AUMID using |
Expand All @@ -724,10 +750,17 @@ private void Bwr_DoWork(object sender, DoWorkEventArgs e)
if (values.Length >= 3 && AppManager.IsKnownApp(values[2], out string readableName))
{
values[0] = readableName;
Log.Verbose("readableName => " + readableName);
}

if (!String.IsNullOrWhiteSpace(values[0]))
{
Log.Verbose("vdf => " + vdf.Length);
if (vdf.Length > 0 && Array.Exists(vdf, entry => entry.AppName == values[0])) {
Log.Debug(values[0] + " is already installed !");
continue;
}

//We get the default square tile to find where the app stores it's icons, then we resolve which one is the widest
string logosPath = Path.GetDirectoryName(values[1]);
Application.Current.Dispatcher.BeginInvoke((Action)delegate ()
Expand Down