Steam Lib search for beat saber folder

This commit is contained in:
Theenoro 2022-05-15 01:04:38 +02:00
parent a2f01c6100
commit aa2e6cbc60
4 changed files with 37 additions and 5 deletions

View File

@ -17,7 +17,7 @@ namespace BeatSaber_Versions
ApplicationConfiguration.Initialize();
if (staticHelpers.IsElevated)
{
getNormalBeatSaberFolder.getBSFolder();
Storage.CC = new Config();
Application.Run(new VersionChanger());
}

View File

@ -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;
}
}
}

View File

@ -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;
}
}

View File

@ -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();
}
}
}