addin option to get BS Folder from Steam

This commit is contained in:
Theenoro 2022-05-14 20:43:22 +02:00
parent 75528cc99a
commit a2f01c6100
8 changed files with 134 additions and 24 deletions

View File

@ -10,6 +10,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Gameloop.Vdf" Version="0.6.2" />
<PackageReference Include="YamlDotNet" Version="11.2.1" /> <PackageReference Include="YamlDotNet" Version="11.2.1" />
</ItemGroup> </ItemGroup>

View File

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

View File

@ -0,0 +1,42 @@
using Gameloop.Vdf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BeatSaber_Versions.controller.helper
{
internal class getNormalBeatSaberFolder
{
public static String getBSFolder()
{
String f = @"C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf";
if (File.Exists(f))
{
dynamic steam = VdfConvert.Deserialize(File.ReadAllText(f));
dynamic libs = steam.Value;
foreach (dynamic lib in libs)
{
Console.Write(lib);
foreach(dynamic opt in lib)
{
Console.Write(opt);
}
dynamic games = lib.Value[lib.Value.Count-1];
foreach(dynamic game in games)
{
Console.Write(game);
}
}
}
return "";
}
}
}

View File

@ -29,21 +29,23 @@
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BeatSaberFolders_Modal)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BeatSaberFolders_Modal));
this.textBox1 = new System.Windows.Forms.TextBox(); this.beatSaberFolder = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox(); this.songsFolder = new System.Windows.Forms.TextBox();
this.setBSFolder = new System.Windows.Forms.Button(); this.setBSFolder = new System.Windows.Forms.Button();
this.setBSSongsFolder = new System.Windows.Forms.Button(); this.setBSSongsFolder = new System.Windows.Forms.Button();
this.saveModal = new System.Windows.Forms.Button(); this.saveModal = new System.Windows.Forms.Button();
this.setNormalBeatSaberFolder = new System.Windows.Forms.FolderBrowserDialog();
this.setCustomSongsFolder = new System.Windows.Forms.FolderBrowserDialog();
this.SuspendLayout(); this.SuspendLayout();
// //
// textBox1 // beatSaberFolder
// //
this.textBox1.Location = new System.Drawing.Point(113, 7); this.beatSaberFolder.Location = new System.Drawing.Point(113, 7);
this.textBox1.Name = "textBox1"; this.beatSaberFolder.Name = "beatSaberFolder";
this.textBox1.Size = new System.Drawing.Size(387, 23); this.beatSaberFolder.Size = new System.Drawing.Size(387, 23);
this.textBox1.TabIndex = 0; this.beatSaberFolder.TabIndex = 0;
// //
// label1 // label1
// //
@ -64,12 +66,12 @@
this.label2.Text = "BeatSaber Songs"; this.label2.Text = "BeatSaber Songs";
this.label2.Click += new System.EventHandler(this.label2_Click); this.label2.Click += new System.EventHandler(this.label2_Click);
// //
// textBox2 // songsFolder
// //
this.textBox2.Location = new System.Drawing.Point(113, 36); this.songsFolder.Location = new System.Drawing.Point(113, 36);
this.textBox2.Name = "textBox2"; this.songsFolder.Name = "songsFolder";
this.textBox2.Size = new System.Drawing.Size(387, 23); this.songsFolder.Size = new System.Drawing.Size(387, 23);
this.textBox2.TabIndex = 3; this.songsFolder.TabIndex = 3;
// //
// setBSFolder // setBSFolder
// //
@ -80,6 +82,7 @@
this.setBSFolder.Text = "Set Folder"; this.setBSFolder.Text = "Set Folder";
this.setBSFolder.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage; this.setBSFolder.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
this.setBSFolder.UseVisualStyleBackColor = true; this.setBSFolder.UseVisualStyleBackColor = true;
this.setBSFolder.Click += new System.EventHandler(this.setBSFolder_Click);
// //
// setBSSongsFolder // setBSSongsFolder
// //
@ -90,6 +93,7 @@
this.setBSSongsFolder.Text = "Set Folder"; this.setBSSongsFolder.Text = "Set Folder";
this.setBSSongsFolder.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage; this.setBSSongsFolder.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
this.setBSSongsFolder.UseVisualStyleBackColor = true; this.setBSSongsFolder.UseVisualStyleBackColor = true;
this.setBSSongsFolder.Click += new System.EventHandler(this.setBSSongsFolder_Click);
// //
// saveModal // saveModal
// //
@ -99,6 +103,7 @@
this.saveModal.TabIndex = 6; this.saveModal.TabIndex = 6;
this.saveModal.Text = "Save"; this.saveModal.Text = "Save";
this.saveModal.UseVisualStyleBackColor = true; this.saveModal.UseVisualStyleBackColor = true;
this.saveModal.Click += new System.EventHandler(this.saveModal_Click);
// //
// BeatSaberFolders_Modal // BeatSaberFolders_Modal
// //
@ -109,10 +114,10 @@
this.Controls.Add(this.saveModal); this.Controls.Add(this.saveModal);
this.Controls.Add(this.setBSSongsFolder); this.Controls.Add(this.setBSSongsFolder);
this.Controls.Add(this.setBSFolder); this.Controls.Add(this.setBSFolder);
this.Controls.Add(this.textBox2); this.Controls.Add(this.songsFolder);
this.Controls.Add(this.label2); this.Controls.Add(this.label2);
this.Controls.Add(this.label1); this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1); this.Controls.Add(this.beatSaberFolder);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.HelpButton = true; this.HelpButton = true;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@ -125,12 +130,14 @@
#endregion #endregion
private TextBox textBox1; private TextBox beatSaberFolder;
private Label label1; private Label label1;
private Label label2; private Label label2;
private TextBox textBox2; private TextBox songsFolder;
private Button setBSFolder; private Button setBSFolder;
private Button setBSSongsFolder; private Button setBSSongsFolder;
private Button saveModal; private Button saveModal;
private FolderBrowserDialog setNormalBeatSaberFolder;
private FolderBrowserDialog setCustomSongsFolder;
} }
} }

View File

@ -1,4 +1,5 @@
using System; using BeatSaber_Versions.controller;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -15,11 +16,57 @@ namespace BeatSaber_Versions
public BeatSaberFolders_Modal() public BeatSaberFolders_Modal()
{ {
InitializeComponent(); InitializeComponent();
songsFolder.Text = Storage.Config.beatsabersongs;
beatSaberFolder.Text = Storage.Config.beatsaberfolder;
} }
private void label2_Click(object sender, EventArgs e) private void label2_Click(object sender, EventArgs e)
{ {
} }
private void setBSSongsFolder_Click(object sender, EventArgs e)
{
DialogResult folder = setCustomSongsFolder.ShowDialog();
if (folder == DialogResult.OK)
{
MessageBox.Show("" + setCustomSongsFolder.SelectedPath);
songsFolder.Text = setCustomSongsFolder.SelectedPath;
}
else
{
}
}
private void setBSFolder_Click(object sender, EventArgs e)
{
DialogResult folder = setNormalBeatSaberFolder.ShowDialog();
if (folder == DialogResult.OK)
{
MessageBox.Show("" + setNormalBeatSaberFolder.SelectedPath);
beatSaberFolder.Text = setNormalBeatSaberFolder.SelectedPath;
}
else
{
}
}
private void saveModal_Click(object sender, EventArgs e)
{
String bsFolder = beatSaberFolder.Text;
String songFolder = songsFolder.Text;
Storage.Config.beatsaberfolder = bsFolder;
Storage.Config.beatsabersongs = songFolder;
Storage.CC.writeConfig();
}
} }
} }

View File

@ -57,6 +57,12 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="setNormalBeatSaberFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="setCustomSongsFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>186, 17</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>

View File

@ -30,7 +30,7 @@
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VersionChanger)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(VersionChanger));
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.settingBSFolder = new System.Windows.Forms.ToolStripMenuItem();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button();
this.button_deleteVersion = new System.Windows.Forms.Button(); this.button_deleteVersion = new System.Windows.Forms.Button();
@ -54,18 +54,19 @@
// menuStrip1 // menuStrip1
// //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1}); this.settingBSFolder});
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1008, 24); this.menuStrip1.Size = new System.Drawing.Size(1008, 24);
this.menuStrip1.TabIndex = 0; this.menuStrip1.TabIndex = 0;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
// toolStripMenuItem1 // settingBSFolder
// //
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; this.settingBSFolder.Name = "settingBSFolder";
this.toolStripMenuItem1.Size = new System.Drawing.Size(125, 20); this.settingBSFolder.Size = new System.Drawing.Size(126, 20);
this.toolStripMenuItem1.Text = "toolStripMenuItem1"; this.settingBSFolder.Text = "Set BeatSaber Folder";
this.settingBSFolder.Click += new System.EventHandler(this.settingBSFolder_Click);
// //
// panel1 // panel1
// //
@ -233,7 +234,7 @@
#endregion #endregion
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private ToolStripMenuItem toolStripMenuItem1; private ToolStripMenuItem settingBSFolder;
private Panel panel1; private Panel panel1;
private Button playSelected; private Button playSelected;
private ListBox gameVersions; private ListBox gameVersions;

View File

@ -186,5 +186,10 @@ namespace BeatSaber_Versions
} }
private void settingBSFolder_Click(object sender, EventArgs e)
{
BeatSaberFolders_Modal mod = new BeatSaberFolders_Modal();
mod.Show();
}
} }
} }