diff --git a/Program.cs b/Program.cs index 7cbc284..aaca31e 100644 --- a/Program.cs +++ b/Program.cs @@ -17,7 +17,7 @@ namespace BeatSaber_Versions ApplicationConfiguration.Initialize(); if (staticHelpers.IsElevated) { - getNormalBeatSaberFolder.getBSFolder(); + Storage.CC = new Config(); Application.Run(new VersionChanger()); } diff --git a/controller/helper/getNormalBeatSaberFolder.cs b/controller/helper/getNormalBeatSaberFolder.cs index fd8eb51..b105443 100644 --- a/controller/helper/getNormalBeatSaberFolder.cs +++ b/controller/helper/getNormalBeatSaberFolder.cs @@ -12,31 +12,44 @@ namespace BeatSaber_Versions.controller.helper public static String getBSFolder() { String f = @"C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; + String basicBeatSaberPath = ""; if (File.Exists(f)) { dynamic steam = VdfConvert.Deserialize(File.ReadAllText(f)); dynamic libs = steam.Value; + bool found = false; foreach (dynamic lib in libs) { + if (found) + { + break; + } Console.Write(lib); foreach(dynamic opt in lib) { Console.Write(opt); } - - dynamic games = lib.Value[lib.Value.Count-1]; - foreach(dynamic game in games) + String path = lib.Value[0].Value.Value; + dynamic games = lib.Value.apps; + foreach (dynamic game in games) { Console.Write(game); + if (game.Key == "620980") + { + basicBeatSaberPath = $"{path}\\Beat Saber"; + found = true; + break; + } + } } } - return ""; + return basicBeatSaberPath; } } } diff --git a/ui/BeatSaberFolders_Modal.Designer.cs b/ui/BeatSaberFolders_Modal.Designer.cs index 32860a7..4f149f3 100644 --- a/ui/BeatSaberFolders_Modal.Designer.cs +++ b/ui/BeatSaberFolders_Modal.Designer.cs @@ -38,6 +38,7 @@ this.saveModal = new System.Windows.Forms.Button(); this.setNormalBeatSaberFolder = new System.Windows.Forms.FolderBrowserDialog(); this.setCustomSongsFolder = new System.Windows.Forms.FolderBrowserDialog(); + this.chkBSBasicFolderViaSteam = new System.Windows.Forms.Button(); this.SuspendLayout(); // // beatSaberFolder @@ -105,12 +106,23 @@ this.saveModal.UseVisualStyleBackColor = true; this.saveModal.Click += new System.EventHandler(this.saveModal_Click); // + // chkBSBasicFolderViaSteam + // + this.chkBSBasicFolderViaSteam.Location = new System.Drawing.Point(332, 82); + this.chkBSBasicFolderViaSteam.Name = "chkBSBasicFolderViaSteam"; + this.chkBSBasicFolderViaSteam.Size = new System.Drawing.Size(164, 23); + this.chkBSBasicFolderViaSteam.TabIndex = 7; + this.chkBSBasicFolderViaSteam.Text = "Check Steam for BS Folder"; + this.chkBSBasicFolderViaSteam.UseVisualStyleBackColor = true; + this.chkBSBasicFolderViaSteam.Click += new System.EventHandler(this.chkBSBasicFolderViaSteam_Click); + // // BeatSaberFolders_Modal // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; this.ClientSize = new System.Drawing.Size(584, 115); + this.Controls.Add(this.chkBSBasicFolderViaSteam); this.Controls.Add(this.saveModal); this.Controls.Add(this.setBSSongsFolder); this.Controls.Add(this.setBSFolder); @@ -139,5 +151,6 @@ private Button saveModal; private FolderBrowserDialog setNormalBeatSaberFolder; private FolderBrowserDialog setCustomSongsFolder; + private Button chkBSBasicFolderViaSteam; } } \ No newline at end of file diff --git a/ui/BeatSaberFolders_Modal.cs b/ui/BeatSaberFolders_Modal.cs index bce01bf..aa6ec48 100644 --- a/ui/BeatSaberFolders_Modal.cs +++ b/ui/BeatSaberFolders_Modal.cs @@ -1,4 +1,5 @@ using BeatSaber_Versions.controller; +using BeatSaber_Versions.controller.helper; using System; using System.Collections.Generic; using System.ComponentModel; @@ -68,5 +69,10 @@ namespace BeatSaber_Versions Storage.CC.writeConfig(); } + + private void chkBSBasicFolderViaSteam_Click(object sender, EventArgs e) + { + beatSaberFolder.Text = getNormalBeatSaberFolder.getBSFolder(); + } } }