Skip to content

Commit

Permalink
Thunderbolt-Switch is now compatible with Microsoft Store games
Browse files Browse the repository at this point in the history
  • Loading branch information
Lesueur Benjamin committed Sep 15, 2020
1 parent 6b84604 commit 1cf409d
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 15 deletions.
68 changes: 60 additions & 8 deletions DockerForm/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml;

namespace DockerForm
{
Expand Down Expand Up @@ -277,9 +278,50 @@ public static void SanityCheck()
}
}

public static List<string> SearchBattleNet()
public static List<DockerGame> SearchMicrosoftStore()
{
List<string> listofBattleNetGames = new List<string>();
List<DockerGame> listofGames = new List<DockerGame>();
string foldername = "C:\\Program Files\\WindowsApps";

foreach(string folder in Directory.GetDirectories(foldername))
{
foreach (string file in Directory.GetFiles(folder))
{
FileInfo myFile = new FileInfo(file);
if (myFile.Name.Equals("MicrosoftGame.config"))
{
XmlDocument doc = new XmlDocument();
doc.Load(file);

string TitleId = doc.DocumentElement["TitleId"].InnerText;
string Executable = doc.DocumentElement["ExecutableList"]["Executable"].Attributes[0].InnerText;
string DisplayName = doc.DocumentElement["ShellVisuals"].Attributes[0].InnerText;
string PublisherDisplayName = doc.DocumentElement["ShellVisuals"].Attributes[1].InnerText;
string StoreLogo = doc.DocumentElement["ShellVisuals"].Attributes[2].InnerText;

string filePath = Path.Combine(folder, Executable);
if (File.Exists(filePath))
{
DockerGame thisGame = new DockerGame(filePath);
thisGame.Platform = PlatformCode.Microsoft;
thisGame.Name = DisplayName;
thisGame.Company = PublisherDisplayName;
thisGame.SanityCheck();

string filename = Path.Combine(folder, StoreLogo);
thisGame.Image = FileManager.GetImage(filename);
listofGames.Add(thisGame);
}
}
}
}

return listofGames;
}

public static List<DockerGame> SearchBattleNet()
{
List<DockerGame> listofGames = new List<DockerGame>();

// HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
string regkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
Expand All @@ -302,18 +344,23 @@ public static List<string> SearchBattleNet()
{
string filePath = subKeys["DisplayIcon"];
if(File.Exists(filePath))
listofBattleNetGames.Add(filePath);
{
DockerGame thisGame = new DockerGame(filePath);
thisGame.Platform = PlatformCode.BattleNet;
thisGame.SanityCheck();
listofGames.Add(thisGame);
}
}
}
}
}

return listofBattleNetGames;
return listofGames;
}

public static List<string> SearchSteam()
public static List<DockerGame> SearchSteam()
{
List<string> listofSteamGames = new List<string>();
List<DockerGame> listofGames = new List<DockerGame>();

// HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall
string regkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall";
Expand All @@ -336,13 +383,18 @@ public static List<string> SearchSteam()
{
string filePath = subKeys["DisplayIcon"];
if (File.Exists(filePath))
listofSteamGames.Add(filePath);
{
DockerGame thisGame = new DockerGame(filePath);
thisGame.Platform = PlatformCode.Steam;
thisGame.SanityCheck();
listofGames.Add(thisGame);
}
}
}
}
}

return listofSteamGames;
return listofGames;
}
}
}
11 changes: 4 additions & 7 deletions DockerForm/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,12 @@ private void removeTheGameToolStripMenuItem_Click(object sender, EventArgs e)

private void automaticDetectionToolStripMenuItem_Click(object sender, EventArgs e)
{
List<string> DetectedGames = new List<string>();
List<DockerGame> DetectedGames = new List<DockerGame>();
DetectedGames.AddRange(DatabaseManager.SearchBattleNet());
DetectedGames.AddRange(DatabaseManager.SearchMicrosoftStore());

foreach(string uri in DetectedGames)
{
DockerGame thisGame = new DockerGame(uri);
thisGame.SanityCheck();
InsertOrUpdateGameItem(thisGame);
}
foreach (DockerGame game in DetectedGames)
InsertOrUpdateGameItem(game, false);
}

private void findAGameToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down

0 comments on commit 1cf409d

Please sign in to comment.