bugfixes and Doc

This commit is contained in:
Theenoro
2022-05-15 03:02:51 +02:00
parent aa2e6cbc60
commit 764dcf50a5
22 changed files with 259 additions and 65 deletions

View File

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

22
ui/NoAdmin.Designer.cs generated
View File

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

View File

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

View File

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

View File

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