diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1691f22 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.png filter=lfs diff=lfs merge=lfs -text +*.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/BeatSaber-Versions.csproj b/BeatSaber-Versions.csproj index 9c7d017..b6815cc 100644 --- a/BeatSaber-Versions.csproj +++ b/BeatSaber-Versions.csproj @@ -7,6 +7,8 @@ enable true enable + AnyCPU;x86 + app.manifest diff --git a/BeatSaber-Versions.sln b/BeatSaber-Versions.sln index 60e13f4..6e9283c 100644 --- a/BeatSaber-Versions.sln +++ b/BeatSaber-Versions.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.32112.339 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BeatSaber-Versions", "BeatSaber-Versions.csproj", "{92403BEE-848E-4C1D-9629-AE45CFE516C6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BeatSaber-Versions", "BeatSaber-Versions.csproj", "{92403BEE-848E-4C1D-9629-AE45CFE516C6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D699286A-E227-419D-B679-C06476A92A01}" ProjectSection(SolutionItems) = preProject @@ -13,13 +13,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Debug|x86.ActiveCfg = Debug|x86 + {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Debug|x86.Build.0 = Debug|x86 {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Release|Any CPU.Build.0 = Release|Any CPU + {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Release|x86.ActiveCfg = Release|Any CPU + {92403BEE-848E-4C1D-9629-AE45CFE516C6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/README.md b/README.md index 8e2fb26..4371706 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # BeatSaber-version-changer +Setup [Link](./doc/setup.md) +Releases [Link](https://git.dev-c.at/Theenoro/BeatSaber-version-changer/releases) + + ## Base Config The config file is the `config.yaml`. You can open it with any editor you want, I recommend `Visual Studio Code` or `Notepad++`. diff --git a/app.manifest b/app.manifest new file mode 100644 index 0000000..c602020 --- /dev/null +++ b/app.manifest @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/controller/helper/getNormalBeatSaberFolder.cs b/controller/helper/getNormalBeatSaberFolder.cs index b105443..9ca7a1f 100644 --- a/controller/helper/getNormalBeatSaberFolder.cs +++ b/controller/helper/getNormalBeatSaberFolder.cs @@ -14,7 +14,7 @@ namespace BeatSaber_Versions.controller.helper String f = @"C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf"; String basicBeatSaberPath = ""; - if (File.Exists(f)) + if (File.Exists(f)) { dynamic steam = VdfConvert.Deserialize(File.ReadAllText(f)); dynamic libs = steam.Value; @@ -38,7 +38,7 @@ namespace BeatSaber_Versions.controller.helper Console.Write(game); if (game.Key == "620980") { - basicBeatSaberPath = $"{path}\\Beat Saber"; + basicBeatSaberPath = $"{path}\\steamapps\\common\\Beat Saber"; found = true; break; } diff --git a/doc/img/contains.png b/doc/img/contains.png new file mode 100644 index 0000000..e5c5a56 --- /dev/null +++ b/doc/img/contains.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e280308ab4b1f0d93555b4c69c883095e9e781ef9f620aa897d62d119e9d88c +size 14007 diff --git a/doc/img/firstView.png b/doc/img/firstView.png new file mode 100644 index 0000000..6bc14b9 --- /dev/null +++ b/doc/img/firstView.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7c3ce012cb892b9e52b9cf34247d0481e885768d3c073f76ccf1a5a9a0811f0 +size 7883 diff --git a/doc/img/renameBeatSaberFolder.png b/doc/img/renameBeatSaberFolder.png new file mode 100644 index 0000000..829faa8 --- /dev/null +++ b/doc/img/renameBeatSaberFolder.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a165540305932cc70e9322061f6aaccec2253091094bd75d35e32e266bfa117a +size 968 diff --git a/doc/img/running_as_nonAdmin.png b/doc/img/running_as_nonAdmin.png new file mode 100644 index 0000000..d313d7d --- /dev/null +++ b/doc/img/running_as_nonAdmin.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7641a61f94530a98d3a18a3468e467af740ae0df9aff4a10d2b629d1925061f3 +size 4368 diff --git a/doc/img/setBeatSaberFolders1.png b/doc/img/setBeatSaberFolders1.png new file mode 100644 index 0000000..427f3c0 --- /dev/null +++ b/doc/img/setBeatSaberFolders1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e39087243e9039d3b74ed66ab90d502a6983682300818790a04bd56f9e136cea +size 5040 diff --git a/doc/img/setBeatSaberFolders2.png b/doc/img/setBeatSaberFolders2.png new file mode 100644 index 0000000..5afcaec --- /dev/null +++ b/doc/img/setBeatSaberFolders2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c35b45e877de87c9ec53daf04a981450fd55ca2637b04b4645954894aee72c28 +size 6948 diff --git a/doc/img/setupYourBeatSaberVersion.png b/doc/img/setupYourBeatSaberVersion.png new file mode 100644 index 0000000..590ae4e --- /dev/null +++ b/doc/img/setupYourBeatSaberVersion.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:388a9b44721cfa3586a97c9c02a28e40bfe00032219bf31afb3460186d8f02e7 +size 8294 diff --git a/doc/img/setupYourBeatSaberVersion2.png b/doc/img/setupYourBeatSaberVersion2.png new file mode 100644 index 0000000..06a1232 --- /dev/null +++ b/doc/img/setupYourBeatSaberVersion2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9b74ed448ccdbb77d6faaa483b8e51b99ca1075cc8686dddacfc89bddcecaa17 +size 9266 diff --git a/doc/img/setupYourBeatSaberVersion3.png b/doc/img/setupYourBeatSaberVersion3.png new file mode 100644 index 0000000..c77c28f --- /dev/null +++ b/doc/img/setupYourBeatSaberVersion3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a658f494da82bf7b31112744b6a777b630b610491d9b3ce836bb4678138c8a75 +size 9422 diff --git a/doc/img/setupYourBeatSaberVersion4.png b/doc/img/setupYourBeatSaberVersion4.png new file mode 100644 index 0000000..83cfb1f --- /dev/null +++ b/doc/img/setupYourBeatSaberVersion4.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f85ff4e6b997a7d0447b8dbeedea94bb368ab1f3d8d3f1f2bc66bf8fc1e95b4 +size 14290 diff --git a/doc/setup.md b/doc/setup.md new file mode 100644 index 0000000..5aba1fd --- /dev/null +++ b/doc/setup.md @@ -0,0 +1,39 @@ +[Readme.md](../README.md) + +# Setup + +## Contains +![./img/contains.png](./img/contains.png) + +## Run for the first time + +If you running the `BeatSaber-Versions.exe` you have to run it with admin rights, cause the normal user is unable to create symbolic links. + +>This is the window if you doesn't run it as admin, you can close the window or press `reopen as Admin`. This will restart the programm as Admin. +>![./img/running_as_nonAdmin.png](./img/running_as_nonAdmin.png) + +The first thing you will see is, that there is already a `1.21.0` in the list. This is the default one in the freshly generated configuration file. +![./img/firstView.png](./img/firstView.png) + +To setup the normal BeatSaber folders you hit the `Set BeatSaber Folder` button at the top left. Then a new window will open. There you can set the normal BS folder or let the programm detect itsef where BS is installed. (This is only working if Steam is installed on C:\\ drive) +![./img/setBeatSaberFolders1.png](./img/setBeatSaberFolders1.png) +I also recommend to relocate your custom songs folder to use the songs in every version of BS. This cleans up some space that you don't have your song lib multiple times on your drive. +![](img/setBeatSaberFolders2.png) + +## Adding your current version of BeatSaber to it + +Currently is the newest version of BeatSaber the `1.22.0` therfore rename the BeatSaber folder to `Beat Saber-1.22.0` on your harddrive. After that edit the values `Name`, `Version` and `Folder`. With the `Set Folder` button you can set the Folder over a dialog window. + +![](img/setupYourBeatSaberVersion.png) +![](img/setupYourBeatSaberVersion2.png) +After the editing hit "Save" and all will be written in your `config.yaml` file. +![](img/setupYourBeatSaberVersion3.png) + +Then if you wanna select your BeatSaber version hit `Play Selected` then the programm will create a symbolic link in your `steamapps` folder with the name `Beat Saber` and will link it to your version folder. If you don't have a custom songs folder or removed it from your `Beat Saber_Data` folder, it will ask if you wanna create a symbolic link to your secified song folder under `Set BeatSaber Folder` which you may have previusly set. +![](img/setupYourBeatSaberVersion4.png) + +After all that you are good to go, play BeatSaber or change versions if you have another on your drive. + +## Preventing your BeatSaber version from updates + +To completly prevent your custom BeatSaber from updates, I recommend to create one version which is normally set as symbolic link, this is the version steam will update. The second one is your custom one, only set this version if you wanna play BeatSaber. \ No newline at end of file diff --git a/ui/BeatSaberFolders_Modal.Designer.cs b/ui/BeatSaberFolders_Modal.Designer.cs index 4f149f3..28b8349 100644 --- a/ui/BeatSaberFolders_Modal.Designer.cs +++ b/ui/BeatSaberFolders_Modal.Designer.cs @@ -134,7 +134,7 @@ this.HelpButton = true; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "BeatSaberFolders_Modal"; - this.Text = "BeatSaberFolders_Modal"; + this.Text = "BeatSaber Folders"; this.ResumeLayout(false); this.PerformLayout(); diff --git a/ui/NoAdmin.Designer.cs b/ui/NoAdmin.Designer.cs index bf56fae..79c36b4 100644 --- a/ui/NoAdmin.Designer.cs +++ b/ui/NoAdmin.Designer.cs @@ -31,16 +31,18 @@ this.button1 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); + this.button2 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(426, 24); + this.button1.Location = new System.Drawing.Point(201, 72); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 30); + this.button1.Size = new System.Drawing.Size(196, 23); this.button1.TabIndex = 0; - this.button1.Text = "OK"; + this.button1.Text = "reopen as Admin"; this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // label1 // @@ -63,11 +65,22 @@ "caused that the normal user can\'t create symbolic links."; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // button2 + // + this.button2.Location = new System.Drawing.Point(12, 72); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(183, 23); + this.button2.TabIndex = 3; + this.button2.Text = "Close"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // // NoAdmin // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(513, 71); + this.ClientSize = new System.Drawing.Size(403, 107); + this.Controls.Add(this.button2); this.Controls.Add(this.label2); this.Controls.Add(this.label1); this.Controls.Add(this.button1); @@ -87,5 +100,6 @@ private Button button1; private Label label1; private Label label2; + private Button button2; } } \ No newline at end of file diff --git a/ui/NoAdmin.cs b/ui/NoAdmin.cs index d53b4cf..c39edb6 100644 --- a/ui/NoAdmin.cs +++ b/ui/NoAdmin.cs @@ -2,8 +2,10 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Drawing; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -16,5 +18,32 @@ namespace BeatSaber_Versions.ui { InitializeComponent(); } + + private void button1_Click(object sender, EventArgs e) + { + + StartAsAdmin($@"{AppDomain.CurrentDomain.BaseDirectory}BeatSaber-Versions.exe"); + } + public static void StartAsAdmin(string fileName) + { + var proc = new Process + { + StartInfo = + { + FileName = fileName, + UseShellExecute = true, + Verb = "runas" + } + }; + + proc.Start(); + Application.Exit(); + } + + private void button2_Click(object sender, EventArgs e) + { + Application.Exit(); + } } + } diff --git a/ui/VersionChanger.Designer.cs b/ui/VersionChanger.Designer.cs index 125f981..e375cfd 100644 --- a/ui/VersionChanger.Designer.cs +++ b/ui/VersionChanger.Designer.cs @@ -114,7 +114,7 @@ this.versionListBox.ItemHeight = 15; this.versionListBox.Location = new System.Drawing.Point(2, 66); this.versionListBox.Name = "versionListBox"; - this.versionListBox.Size = new System.Drawing.Size(164, 454); + this.versionListBox.Size = new System.Drawing.Size(164, 184); this.versionListBox.TabIndex = 2; this.versionListBox.SelectedIndexChanged += new System.EventHandler(this.versionListBox_SelectedIndexChanged); // @@ -130,10 +130,10 @@ this.groupBox1.Controls.Add(this.label1); this.groupBox1.Location = new System.Drawing.Point(167, 66); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(838, 454); + this.groupBox1.Size = new System.Drawing.Size(838, 184); this.groupBox1.TabIndex = 3; this.groupBox1.TabStop = false; - this.groupBox1.Text = "groupBox1"; + this.groupBox1.Text = "Version"; // // saveSetting // @@ -211,7 +211,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1008, 525); + this.ClientSize = new System.Drawing.Size(1008, 261); this.Controls.Add(this.groupBox1); this.Controls.Add(this.versionListBox); this.Controls.Add(this.panel1); @@ -220,7 +220,7 @@ this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MainMenuStrip = this.menuStrip1; this.Name = "VersionChanger"; - this.Text = "Form1"; + this.Text = "Version Changer"; this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.panel1.ResumeLayout(false); diff --git a/ui/VersionChanger.cs b/ui/VersionChanger.cs index fc8cd3f..648abc1 100644 --- a/ui/VersionChanger.cs +++ b/ui/VersionChanger.cs @@ -15,7 +15,7 @@ namespace BeatSaber_Versions string lpTargetFileName, int dwFlags); private string Path = $@"{AppDomain.CurrentDomain.BaseDirectory}config.yaml"; - private VersionConfigDict Versionen = null; + private VersionConfigDict Versionen = Storage.Config; private String beatsaberfolder = @"A:\BS"; public VersionChanger() @@ -23,16 +23,9 @@ namespace BeatSaber_Versions InitializeComponent(); - var deserializer = new DeserializerBuilder() - .WithNamingConvention(UnderscoredNamingConvention.Instance) // see height_in_inches in sample yml - .Build(); - - string yml = File.ReadAllText(Path); - var p = deserializer.Deserialize(yml); - - Versionen = p; - beatsaberfolder = p.beatsaberfolder; - foreach (var key in (p.versions).Keys) + VersionConfigDict Versionen = Storage.Config; + beatsaberfolder = Versionen.beatsaberfolder; + foreach (var key in (Versionen.versions).Keys) { versionListBox.Items.Add(key); } @@ -75,15 +68,15 @@ namespace BeatSaber_Versions private void playSelected_Click(object sender, EventArgs e) { String Target = folderPath.Text; - if (Directory.Exists(beatsaberfolder)) + if (Directory.Exists(Storage.Config.beatsaberfolder)) { - if (staticHelpers.IsSymbolic(beatsaberfolder)) + if (staticHelpers.IsSymbolic(Storage.Config.beatsaberfolder)) { - Directory.Delete(beatsaberfolder); + Directory.Delete(Storage.Config.beatsaberfolder); if (Directory.Exists(Target)) { - CreateSymbolicLink(beatsaberfolder, Target, 0x1); + CreateSymbolicLink(Storage.Config.beatsaberfolder, Target, 0x1); setSongFolder(); } } @@ -92,47 +85,49 @@ namespace BeatSaber_Versions { if (Directory.Exists(Target)) { - CreateSymbolicLink(beatsaberfolder, Target, 0x1); + CreateSymbolicLink(Storage.Config.beatsaberfolder, Target, 0x1); setSongFolder(); } } } private void setSongFolder() { - String songFolderConf = Versionen.beatsabersongs; - String songFolder = beatsaberfolder+ "\\Beat Saber_Data\\CustomLevels"; - if (Directory.Exists(songFolder)) - { - if (staticHelpers.IsSymbolic(songFolder)) + String songFolderConf = Storage.Config.beatsabersongs; + if (songFolderConf != "") { + String songFolder = Storage.Config.beatsaberfolder + "\\Beat Saber_Data\\CustomLevels"; + if (Directory.Exists(songFolder)) { - MessageBox.Show("Is a symbolic link <3"); + if (staticHelpers.IsSymbolic(songFolder)) + { + MessageBox.Show("Is a symbolic link <3"); + } + else + { + MessageBox.Show("Is a normal folder."); + } } else { - MessageBox.Show("Is a normal folder."); + DialogResult dialogResult = MessageBox.Show("Create symbolic link, may deduplicate your song library", "Settings", MessageBoxButtons.YesNo); + if (dialogResult == DialogResult.Yes) + { + CreateSymbolicLink(songFolder, songFolderConf, 0x1); + MessageBox.Show("Created symbolic link to song folder."); + } + else if (dialogResult == DialogResult.No) + { + //do something else + } + } } - else - { - DialogResult dialogResult = MessageBox.Show("Create symbolic link, may deduplicate your song library", "Settings", MessageBoxButtons.YesNo); - if (dialogResult == DialogResult.Yes) - { - CreateSymbolicLink(songFolder, songFolderConf, 0x1); - MessageBox.Show("Created symbolic link to song folder."); - } - else if (dialogResult == DialogResult.No) - { - //do something else - } - - } - - } private void saveSetting_Click(object sender, EventArgs e) { + + Versionen = Storage.Config; VersionConfig tmp = new VersionConfig(); tmp.path = folderPath.Text; tmp.name = versionName.Text; @@ -151,13 +146,8 @@ namespace BeatSaber_Versions { versionListBox.Items.Add(key); } - - var serializer = new SerializerBuilder() - .WithNamingConvention(CamelCaseNamingConvention.Instance) - .Build(); - var yaml = serializer.Serialize(Versionen); - File.WriteAllTextAsync(Path,yaml); - System.Console.WriteLine(yaml); + Storage.Config = Versionen; + Storage.CC.writeConfig(); } private void addVersion(object sender,EventArgs e){ folderPath.Text = ""; @@ -167,6 +157,7 @@ namespace BeatSaber_Versions } private void deleteVersion(object sender, EventArgs e){ var Item = versionVersion.Text; + Versionen = Storage.Config; if(Item != null) { Versionen.versions.Remove((String)Item); @@ -177,12 +168,8 @@ namespace BeatSaber_Versions versionListBox.Items.Add(key); } - var serializer = new SerializerBuilder() - .WithNamingConvention(CamelCaseNamingConvention.Instance) - .Build(); - var yaml = serializer.Serialize(Versionen); - File.WriteAllTextAsync(Path,yaml); - System.Console.WriteLine(yaml); + Storage.Config = Versionen; + Storage.CC.writeConfig(); }