From 1cf409dc3b17f673853a0f256605756fa319f74b Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Tue, 15 Sep 2020 11:12:38 +0200 Subject: [PATCH] Thunderbolt-Switch is now compatible with Microsoft Store games --- DockerForm/DatabaseManager.cs | 68 ++++++++++++++++++++++++++++++----- DockerForm/Form1.cs | 11 +++--- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/DockerForm/DatabaseManager.cs b/DockerForm/DatabaseManager.cs index 63c4a2c..969793c 100644 --- a/DockerForm/DatabaseManager.cs +++ b/DockerForm/DatabaseManager.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using System.Windows.Forms; +using System.Xml; namespace DockerForm { @@ -277,9 +278,50 @@ public static void SanityCheck() } } - public static List SearchBattleNet() + public static List SearchMicrosoftStore() { - List listofBattleNetGames = new List(); + List listofGames = new List(); + 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 SearchBattleNet() + { + List listofGames = new List(); // HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall string regkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; @@ -302,18 +344,23 @@ public static List 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 SearchSteam() + public static List SearchSteam() { - List listofSteamGames = new List(); + List listofGames = new List(); // HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall string regkey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; @@ -336,13 +383,18 @@ public static List 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; } } } diff --git a/DockerForm/Form1.cs b/DockerForm/Form1.cs index 568c333..64c5e9f 100644 --- a/DockerForm/Form1.cs +++ b/DockerForm/Form1.cs @@ -546,15 +546,12 @@ private void removeTheGameToolStripMenuItem_Click(object sender, EventArgs e) private void automaticDetectionToolStripMenuItem_Click(object sender, EventArgs e) { - List DetectedGames = new List(); + List DetectedGames = new List(); 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)