mirror of
https://github.com/OxyZin/LegacyConsoleLauncher.git
synced 2026-07-18 00:30:47 +00:00
Move launcher data to AppData and remove admin requirement
- Refactored file paths to use %LOCALAPPDATA% instead of the executable directory - Added centralized launcher data directory (LCELauncher) - Game now installs to AppData - Skins, accounts and launcher data now stored in AppData - Fixed permission issues when running without administrator privileges - New and working settings menu
This commit is contained in:
@@ -12,12 +12,12 @@ namespace LegacyConsoleLauncher
|
||||
usernameComboBox.Items.Clear();
|
||||
playtimeData.Clear();
|
||||
|
||||
if (!File.Exists(accountsFile))
|
||||
if (!File.Exists(LauncherPaths.AccountsFile))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string[] lines = File.ReadAllLines(accountsFile);
|
||||
string[] lines = File.ReadAllLines(LauncherPaths.AccountsFile);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
@@ -63,7 +63,8 @@ namespace LegacyConsoleLauncher
|
||||
lines.Add(entry.Key + "|" + entry.Value);
|
||||
}
|
||||
|
||||
File.WriteAllLines(accountsFile, lines);
|
||||
Directory.CreateDirectory(LauncherPaths.DataDir);
|
||||
File.WriteAllLines(LauncherPaths.AccountsFile, lines);
|
||||
}
|
||||
|
||||
private void AddAccount(string username)
|
||||
|
||||
23
Form1.Designer.cs
generated
23
Form1.Designer.cs
generated
@@ -34,7 +34,6 @@
|
||||
this.gamePathLabel = new System.Windows.Forms.Label();
|
||||
this.gamePathTextBox = new System.Windows.Forms.TextBox();
|
||||
this.openFolderButton = new System.Windows.Forms.Button();
|
||||
this.resetLink = new System.Windows.Forms.LinkLabel();
|
||||
this.playtimeLabel = new System.Windows.Forms.Label();
|
||||
this.checkforLink = new System.Windows.Forms.LinkLabel();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
@@ -135,17 +134,6 @@
|
||||
this.openFolderButton.UseVisualStyleBackColor = true;
|
||||
this.openFolderButton.Click += new System.EventHandler(this.openFolderButton_Click);
|
||||
//
|
||||
// resetLink
|
||||
//
|
||||
this.resetLink.AutoSize = true;
|
||||
this.resetLink.Location = new System.Drawing.Point(13, 280);
|
||||
this.resetLink.Name = "resetLink";
|
||||
this.resetLink.Size = new System.Drawing.Size(124, 13);
|
||||
this.resetLink.TabIndex = 10;
|
||||
this.resetLink.TabStop = true;
|
||||
this.resetLink.Text = "Reset Launcher Settings";
|
||||
this.resetLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.resetLink_LinkClicked);
|
||||
//
|
||||
// playtimeLabel
|
||||
//
|
||||
this.playtimeLabel.AutoSize = true;
|
||||
@@ -158,12 +146,12 @@
|
||||
// checkforLink
|
||||
//
|
||||
this.checkforLink.AutoSize = true;
|
||||
this.checkforLink.Location = new System.Drawing.Point(143, 280);
|
||||
this.checkforLink.Location = new System.Drawing.Point(9, 280);
|
||||
this.checkforLink.Name = "checkforLink";
|
||||
this.checkforLink.Size = new System.Drawing.Size(94, 13);
|
||||
this.checkforLink.Size = new System.Drawing.Size(75, 13);
|
||||
this.checkforLink.TabIndex = 12;
|
||||
this.checkforLink.TabStop = true;
|
||||
this.checkforLink.Text = "Check for updates";
|
||||
this.checkforLink.Text = "Install updates";
|
||||
this.checkforLink.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.checkforLink_LinkClicked);
|
||||
//
|
||||
// button1
|
||||
@@ -182,8 +170,9 @@
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(111, 32);
|
||||
this.button2.TabIndex = 14;
|
||||
this.button2.Text = "Settings (WIP)";
|
||||
this.button2.Text = "Settings";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// button3
|
||||
//
|
||||
@@ -213,7 +202,6 @@
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.checkforLink);
|
||||
this.Controls.Add(this.resetLink);
|
||||
this.Controls.Add(this.openFolderButton);
|
||||
this.Controls.Add(this.gamePathTextBox);
|
||||
this.Controls.Add(this.gamePathLabel);
|
||||
@@ -247,7 +235,6 @@
|
||||
private System.Windows.Forms.Label gamePathLabel;
|
||||
private System.Windows.Forms.TextBox gamePathTextBox;
|
||||
private System.Windows.Forms.Button openFolderButton;
|
||||
private System.Windows.Forms.LinkLabel resetLink;
|
||||
private System.Windows.Forms.Label playtimeLabel;
|
||||
private System.Windows.Forms.LinkLabel checkforLink;
|
||||
private System.Windows.Forms.Button button1;
|
||||
|
||||
@@ -100,20 +100,8 @@ namespace LegacyConsoleLauncher
|
||||
);
|
||||
}
|
||||
|
||||
private void resetLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
public void ResetLauncherData()
|
||||
{
|
||||
DialogResult result = MessageBox.Show(
|
||||
"This will reset the saved accounts and game path. Continue?",
|
||||
"Reset Launcher Settings",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (File.Exists(accountsFile))
|
||||
{
|
||||
File.Delete(accountsFile);
|
||||
@@ -129,23 +117,23 @@ namespace LegacyConsoleLauncher
|
||||
File.Delete(releaseInfoFile);
|
||||
}
|
||||
|
||||
if (Directory.Exists(skinsDir))
|
||||
{
|
||||
Directory.Delete(skinsDir, true);
|
||||
Directory.CreateDirectory(skinsDir);
|
||||
}
|
||||
|
||||
usernameComboBox.Items.Clear();
|
||||
usernameComboBox.Text = string.Empty;
|
||||
playtimeData.Clear();
|
||||
|
||||
exePath = Path.Combine(Application.StartupPath, "Minecraft.Client.exe");
|
||||
exePath = Path.Combine(gameInstallDir, "Minecraft.Client.exe");
|
||||
fullscreenCheckBox.Checked = false;
|
||||
|
||||
AutoDetectGame();
|
||||
UpdateGamePathDisplay();
|
||||
UpdatePlaytimeLabel();
|
||||
|
||||
MessageBox.Show(
|
||||
"Launcher settings have been reset.",
|
||||
"Done",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information
|
||||
);
|
||||
UpdateSkinPreview();
|
||||
}
|
||||
|
||||
private void usernameComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
@@ -169,5 +157,13 @@ namespace LegacyConsoleLauncher
|
||||
private void gamePathLabel_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (Form3 settingsForm = new Form3())
|
||||
{
|
||||
settingsForm.Owner = this;
|
||||
settingsForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,10 @@ namespace LegacyConsoleLauncher
|
||||
|
||||
string[] possiblePaths =
|
||||
{
|
||||
Path.Combine(Application.StartupPath, "Minecraft.Client.exe"),
|
||||
Path.Combine(Application.StartupPath, "build", "Minecraft.Client.exe"),
|
||||
Path.Combine(Application.StartupPath, "bin", "Minecraft.Client.exe"),
|
||||
Path.Combine(Application.StartupPath, "game", "Minecraft.Client.exe"),
|
||||
Path.Combine(LauncherPaths.DataDir, "Minecraft.Client.exe"),
|
||||
Path.Combine(LauncherPaths.DataDir, "build", "Minecraft.Client.exe"),
|
||||
Path.Combine(LauncherPaths.DataDir, "bin", "Minecraft.Client.exe"),
|
||||
Path.Combine(LauncherPaths.DataDir, "game", "Minecraft.Client.exe"),
|
||||
Path.Combine(gameInstallDir, "Minecraft.Client.exe")
|
||||
};
|
||||
|
||||
@@ -228,6 +228,10 @@ namespace LegacyConsoleLauncher
|
||||
{
|
||||
args += "-name \"" + username + "\" ";
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(SettingsManager.AdditionalLaunchArgs))
|
||||
{
|
||||
args += SettingsManager.AdditionalLaunchArgs.Trim() + " ";
|
||||
}
|
||||
|
||||
gameProcess = Process.Start(new ProcessStartInfo
|
||||
{
|
||||
@@ -251,7 +255,6 @@ namespace LegacyConsoleLauncher
|
||||
sessionStart = DateTime.Now;
|
||||
gameProcess.EnableRaisingEvents = true;
|
||||
gameProcess.Exited += GameProcess_Exited;
|
||||
|
||||
Hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace LegacyConsoleLauncher
|
||||
{
|
||||
private string GetSkinFolder()
|
||||
{
|
||||
return skinsDir;
|
||||
return LauncherPaths.SkinsDir;
|
||||
}
|
||||
|
||||
private string GetAccountSkinPath(string username)
|
||||
|
||||
@@ -81,12 +81,12 @@ namespace LegacyConsoleLauncher
|
||||
|
||||
private string GetInstalledCommit()
|
||||
{
|
||||
if (!File.Exists(releaseInfoFile))
|
||||
if (!File.Exists(LauncherPaths.ReleaseInfoFile))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
foreach (string line in File.ReadAllLines(releaseInfoFile))
|
||||
foreach (string line in File.ReadAllLines(LauncherPaths.ReleaseInfoFile))
|
||||
{
|
||||
if (line.StartsWith("commit="))
|
||||
{
|
||||
@@ -104,13 +104,14 @@ namespace LegacyConsoleLauncher
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(releaseInfoFile, "commit=" + commit);
|
||||
Directory.CreateDirectory(LauncherPaths.GameDir);
|
||||
File.WriteAllText(LauncherPaths.ReleaseInfoFile, "commit=" + commit);
|
||||
}
|
||||
|
||||
private async Task InstallGameAsync()
|
||||
{
|
||||
string zipPath = Path.Combine(Application.StartupPath, "LCEWindows64.zip");
|
||||
string tempExtractDir = Path.Combine(Application.StartupPath, "Game_Temp");
|
||||
string zipPath = Path.Combine(LauncherPaths.DataDir, "LCEWindows64.zip");
|
||||
string tempExtractDir = Path.Combine(LauncherPaths.DataDir, "Game_Temp");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -135,6 +136,7 @@ namespace LegacyConsoleLauncher
|
||||
Directory.Delete(gameInstallDir, true);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(gameInstallDir));
|
||||
Directory.Move(tempExtractDir, gameInstallDir);
|
||||
|
||||
string detectedExe = FindGameExe(gameInstallDir);
|
||||
@@ -183,7 +185,7 @@ namespace LegacyConsoleLauncher
|
||||
throw new FileNotFoundException("Game executable was not found.");
|
||||
}
|
||||
|
||||
string tempExePath = Path.Combine(Application.StartupPath, "Minecraft.Client.new.exe");
|
||||
string tempExePath = Path.Combine(LauncherPaths.DataDir, "Minecraft.Client.new.exe");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
23
Form1.cs
23
Form1.cs
@@ -10,13 +10,13 @@ namespace LegacyConsoleLauncher
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private readonly string accountsFile = Path.Combine(Application.StartupPath, "accounts.txt");
|
||||
private readonly string gamePathFile = Path.Combine(Application.StartupPath, "gamepath.txt");
|
||||
private readonly string releaseInfoFile = Path.Combine(Application.StartupPath, "releaseinfo.txt");
|
||||
private readonly string gameInstallDir = Path.Combine(Application.StartupPath, "Game");
|
||||
private readonly string skinsDir = Path.Combine(Application.StartupPath, "skins");
|
||||
private readonly string accountsFile = LauncherPaths.AccountsFile;
|
||||
private readonly string gamePathFile = LauncherPaths.GamePathFile;
|
||||
private readonly string releaseInfoFile = LauncherPaths.ReleaseInfoFile;
|
||||
private readonly string gameInstallDir = LauncherPaths.GameDir;
|
||||
private readonly string skinsDir = LauncherPaths.SkinsDir;
|
||||
|
||||
private string exePath = Path.Combine(Application.StartupPath, "Minecraft.Client.exe");
|
||||
private string exePath = Path.Combine(LauncherPaths.GameDir, "Minecraft.Client.exe");
|
||||
|
||||
private readonly string nightlyReleaseUrl = "https://github.com/smartcmd/MinecraftConsoles/releases/tag/nightly";
|
||||
private readonly string nightlyZipUrl = "https://github.com/smartcmd/MinecraftConsoles/releases/download/nightly/LCEWindows64.zip";
|
||||
@@ -47,7 +47,9 @@ namespace LegacyConsoleLauncher
|
||||
AcceptButton = launchButton;
|
||||
checkforLink.Visible = false;
|
||||
|
||||
Directory.CreateDirectory(skinsDir);
|
||||
Directory.CreateDirectory(LauncherPaths.DataDir);
|
||||
Directory.CreateDirectory(LauncherPaths.GameDir);
|
||||
Directory.CreateDirectory(LauncherPaths.SkinsDir);
|
||||
|
||||
LoadAccounts();
|
||||
LoadSavedGamePath();
|
||||
@@ -61,7 +63,12 @@ namespace LegacyConsoleLauncher
|
||||
DragEnter += Form1_DragEnter;
|
||||
DragDrop += Form1_DragDrop;
|
||||
|
||||
await CheckForUpdatesOnStartupAsync();
|
||||
SettingsManager.Load();
|
||||
|
||||
if (SettingsManager.CheckGameUpdatesOnStartup)
|
||||
{
|
||||
await CheckForUpdatesOnStartupAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
202
Form3.Designer.cs
generated
202
Form3.Designer.cs
generated
@@ -28,12 +28,208 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.Windows.Forms.Button saveButton;
|
||||
this.checkGameUpdatesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.checkLauncherUpdatesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.launchArgsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.openDataFolderButton = new System.Windows.Forms.Button();
|
||||
this.openSkinsFolderButton = new System.Windows.Forms.Button();
|
||||
this.resetLauncherSettingsButton = new System.Windows.Forms.Button();
|
||||
this.versionLabel = new System.Windows.Forms.Label();
|
||||
this.githubLinkLabel = new System.Windows.Forms.LinkLabel();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.groupBox4 = new System.Windows.Forms.GroupBox();
|
||||
saveButton = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Location = new System.Drawing.Point(171, 218);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new System.Drawing.Size(75, 23);
|
||||
saveButton.TabIndex = 18;
|
||||
saveButton.Text = "Save";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += new System.EventHandler(this.saveButton_Click);
|
||||
//
|
||||
// checkGameUpdatesCheckBox
|
||||
//
|
||||
this.checkGameUpdatesCheckBox.AutoSize = true;
|
||||
this.checkGameUpdatesCheckBox.Location = new System.Drawing.Point(6, 19);
|
||||
this.checkGameUpdatesCheckBox.Name = "checkGameUpdatesCheckBox";
|
||||
this.checkGameUpdatesCheckBox.Size = new System.Drawing.Size(192, 17);
|
||||
this.checkGameUpdatesCheckBox.TabIndex = 1;
|
||||
this.checkGameUpdatesCheckBox.Text = "Check for game updates on startup";
|
||||
this.checkGameUpdatesCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkLauncherUpdatesCheckBox
|
||||
//
|
||||
this.checkLauncherUpdatesCheckBox.AutoSize = true;
|
||||
this.checkLauncherUpdatesCheckBox.Location = new System.Drawing.Point(6, 36);
|
||||
this.checkLauncherUpdatesCheckBox.Name = "checkLauncherUpdatesCheckBox";
|
||||
this.checkLauncherUpdatesCheckBox.Size = new System.Drawing.Size(207, 17);
|
||||
this.checkLauncherUpdatesCheckBox.TabIndex = 2;
|
||||
this.checkLauncherUpdatesCheckBox.Text = "Check for launcher updates on startup";
|
||||
this.checkLauncherUpdatesCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.label3.Location = new System.Drawing.Point(6, 16);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(143, 13);
|
||||
this.label3.TabIndex = 5;
|
||||
this.label3.Text = "Additional launch arguments:";
|
||||
//
|
||||
// launchArgsTextBox
|
||||
//
|
||||
this.launchArgsTextBox.Location = new System.Drawing.Point(9, 32);
|
||||
this.launchArgsTextBox.Name = "launchArgsTextBox";
|
||||
this.launchArgsTextBox.Size = new System.Drawing.Size(232, 20);
|
||||
this.launchArgsTextBox.TabIndex = 6;
|
||||
//
|
||||
// openDataFolderButton
|
||||
//
|
||||
this.openDataFolderButton.Location = new System.Drawing.Point(6, 13);
|
||||
this.openDataFolderButton.Name = "openDataFolderButton";
|
||||
this.openDataFolderButton.Size = new System.Drawing.Size(140, 23);
|
||||
this.openDataFolderButton.TabIndex = 8;
|
||||
this.openDataFolderButton.Text = "Open launcher data folder";
|
||||
this.openDataFolderButton.UseVisualStyleBackColor = true;
|
||||
this.openDataFolderButton.Click += new System.EventHandler(this.openDataFolderButton_Click);
|
||||
//
|
||||
// openSkinsFolderButton
|
||||
//
|
||||
this.openSkinsFolderButton.Location = new System.Drawing.Point(6, 43);
|
||||
this.openSkinsFolderButton.Name = "openSkinsFolderButton";
|
||||
this.openSkinsFolderButton.Size = new System.Drawing.Size(140, 23);
|
||||
this.openSkinsFolderButton.TabIndex = 9;
|
||||
this.openSkinsFolderButton.Text = "Open skins folder";
|
||||
this.openSkinsFolderButton.UseVisualStyleBackColor = true;
|
||||
this.openSkinsFolderButton.Click += new System.EventHandler(this.openSkinsFolderButton_Click);
|
||||
//
|
||||
// resetLauncherSettingsButton
|
||||
//
|
||||
this.resetLauncherSettingsButton.Location = new System.Drawing.Point(6, 73);
|
||||
this.resetLauncherSettingsButton.Name = "resetLauncherSettingsButton";
|
||||
this.resetLauncherSettingsButton.Size = new System.Drawing.Size(140, 23);
|
||||
this.resetLauncherSettingsButton.TabIndex = 10;
|
||||
this.resetLauncherSettingsButton.Text = "Reset launcher settings";
|
||||
this.resetLauncherSettingsButton.UseVisualStyleBackColor = true;
|
||||
this.resetLauncherSettingsButton.Click += new System.EventHandler(this.resetLauncherSettingsButton_Click);
|
||||
//
|
||||
// versionLabel
|
||||
//
|
||||
this.versionLabel.AutoSize = true;
|
||||
this.versionLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.versionLabel.Location = new System.Drawing.Point(6, 21);
|
||||
this.versionLabel.Name = "versionLabel";
|
||||
this.versionLabel.Size = new System.Drawing.Size(164, 13);
|
||||
this.versionLabel.TabIndex = 12;
|
||||
this.versionLabel.Text = "Legacy Console Launcher v1.3.0";
|
||||
//
|
||||
// githubLinkLabel
|
||||
//
|
||||
this.githubLinkLabel.AutoSize = true;
|
||||
this.githubLinkLabel.Location = new System.Drawing.Point(7, 38);
|
||||
this.githubLinkLabel.Name = "githubLinkLabel";
|
||||
this.githubLinkLabel.Size = new System.Drawing.Size(220, 13);
|
||||
this.githubLinkLabel.TabIndex = 13;
|
||||
this.githubLinkLabel.TabStop = true;
|
||||
this.githubLinkLabel.Text = "github.com/OxyZin/LegacyConsoleLauncher";
|
||||
this.githubLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.githubLinkLabel_LinkClicked);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.checkGameUpdatesCheckBox);
|
||||
this.groupBox1.Controls.Add(this.checkLauncherUpdatesCheckBox);
|
||||
this.groupBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.groupBox1.Location = new System.Drawing.Point(12, 12);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(226, 57);
|
||||
this.groupBox1.TabIndex = 14;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "General";
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.label3);
|
||||
this.groupBox2.Controls.Add(this.launchArgsTextBox);
|
||||
this.groupBox2.Location = new System.Drawing.Point(12, 75);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(249, 60);
|
||||
this.groupBox2.TabIndex = 15;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "Advanced";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.resetLauncherSettingsButton);
|
||||
this.groupBox3.Controls.Add(this.openDataFolderButton);
|
||||
this.groupBox3.Controls.Add(this.openSkinsFolderButton);
|
||||
this.groupBox3.Location = new System.Drawing.Point(12, 141);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(153, 100);
|
||||
this.groupBox3.TabIndex = 16;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Maintenance";
|
||||
//
|
||||
// groupBox4
|
||||
//
|
||||
this.groupBox4.Controls.Add(this.versionLabel);
|
||||
this.groupBox4.Controls.Add(this.githubLinkLabel);
|
||||
this.groupBox4.Location = new System.Drawing.Point(12, 247);
|
||||
this.groupBox4.Name = "groupBox4";
|
||||
this.groupBox4.Size = new System.Drawing.Size(230, 59);
|
||||
this.groupBox4.TabIndex = 17;
|
||||
this.groupBox4.TabStop = false;
|
||||
this.groupBox4.Text = "About";
|
||||
//
|
||||
// Form3
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form3";
|
||||
this.ClientSize = new System.Drawing.Size(266, 310);
|
||||
this.Controls.Add(saveButton);
|
||||
this.Controls.Add(this.groupBox4);
|
||||
this.Controls.Add(this.groupBox3);
|
||||
this.Controls.Add(this.groupBox2);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Name = "Form3";
|
||||
this.Text = "Settings";
|
||||
this.Load += new System.EventHandler(this.Form3_Load);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox4.ResumeLayout(false);
|
||||
this.groupBox4.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.CheckBox checkGameUpdatesCheckBox;
|
||||
private System.Windows.Forms.CheckBox checkLauncherUpdatesCheckBox;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.TextBox launchArgsTextBox;
|
||||
private System.Windows.Forms.Button openDataFolderButton;
|
||||
private System.Windows.Forms.Button openSkinsFolderButton;
|
||||
private System.Windows.Forms.Button resetLauncherSettingsButton;
|
||||
private System.Windows.Forms.Label versionLabel;
|
||||
private System.Windows.Forms.LinkLabel githubLinkLabel;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.GroupBox groupBox4;
|
||||
}
|
||||
}
|
||||
133
Form3.cs
133
Form3.cs
@@ -1,20 +1,137 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace LegacyConsoleLauncher
|
||||
{
|
||||
public partial class Form3 : Form
|
||||
{
|
||||
private readonly string launcherDataDir =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LCELauncher");
|
||||
|
||||
private readonly string skinsDir;
|
||||
|
||||
public Form3()
|
||||
{
|
||||
InitializeComponent();
|
||||
skinsDir = Path.Combine(launcherDataDir, "skins");
|
||||
}
|
||||
|
||||
private void Form3_Load(object sender, EventArgs e)
|
||||
{
|
||||
Directory.CreateDirectory(launcherDataDir);
|
||||
Directory.CreateDirectory(skinsDir);
|
||||
|
||||
versionLabel.Text = "Legacy Console Launcher v" + Application.ProductVersion;
|
||||
|
||||
SettingsManager.Load();
|
||||
|
||||
checkGameUpdatesCheckBox.Checked = SettingsManager.CheckGameUpdatesOnStartup;
|
||||
checkLauncherUpdatesCheckBox.Checked = SettingsManager.CheckLauncherUpdatesOnStartup;
|
||||
launchArgsTextBox.Text = SettingsManager.AdditionalLaunchArgs;
|
||||
}
|
||||
|
||||
private void SaveUiToSettings()
|
||||
{
|
||||
SettingsManager.CheckGameUpdatesOnStartup = checkGameUpdatesCheckBox.Checked;
|
||||
SettingsManager.CheckLauncherUpdatesOnStartup = checkLauncherUpdatesCheckBox.Checked;
|
||||
SettingsManager.AdditionalLaunchArgs = launchArgsTextBox.Text.Trim();
|
||||
|
||||
SettingsManager.Save();
|
||||
}
|
||||
|
||||
private void openDataFolderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Directory.CreateDirectory(launcherDataDir);
|
||||
Process.Start("explorer.exe", launcherDataDir);
|
||||
}
|
||||
|
||||
private void openSkinsFolderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
Directory.CreateDirectory(skinsDir);
|
||||
Process.Start("explorer.exe", skinsDir);
|
||||
}
|
||||
|
||||
private void ResetEverything()
|
||||
{
|
||||
Form1 mainForm = this.Owner as Form1;
|
||||
|
||||
if (mainForm == null)
|
||||
{
|
||||
MessageBox.Show("Main launcher window not found.", "Error",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
mainForm.ResetLauncherData();
|
||||
SettingsManager.Reset();
|
||||
}
|
||||
|
||||
private void resetLauncherSettingsButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult result = MessageBox.Show(
|
||||
"This will reset all launcher data and settings. Continue?",
|
||||
"Reset Launcher",
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Question
|
||||
);
|
||||
|
||||
if (result != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ResetEverything();
|
||||
|
||||
checkGameUpdatesCheckBox.Checked = SettingsManager.CheckGameUpdatesOnStartup;
|
||||
checkLauncherUpdatesCheckBox.Checked = SettingsManager.CheckLauncherUpdatesOnStartup;
|
||||
launchArgsTextBox.Text = SettingsManager.AdditionalLaunchArgs;
|
||||
|
||||
MessageBox.Show(
|
||||
"Launcher has been fully reset.",
|
||||
"Done",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information
|
||||
);
|
||||
}
|
||||
|
||||
private void githubLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://github.com/OxyZin/LegacyConsoleLauncher",
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
|
||||
private void checkGameUpdatesCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void checkLauncherUpdatesCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void launchArgsTextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void label1_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void label4_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void label2_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveUiToSettings();
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
123
Form3.resx
Normal file
123
Form3.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="saveButton.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
||||
15
LauncherPaths.cs
Normal file
15
LauncherPaths.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace LegacyConsoleLauncher
|
||||
{
|
||||
public static class LauncherPaths
|
||||
{
|
||||
public static readonly string DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LCELauncher");
|
||||
public static readonly string GameDir = Path.Combine(DataDir, "game");
|
||||
public static readonly string SkinsDir = Path.Combine(DataDir, "skins");
|
||||
public static readonly string AccountsFile = Path.Combine(DataDir, "accounts.txt");
|
||||
public static readonly string GamePathFile = Path.Combine(DataDir, "gamepath.txt");
|
||||
public static readonly string ReleaseInfoFile = Path.Combine(GameDir, "releaseinfo.txt");
|
||||
}
|
||||
}
|
||||
@@ -92,14 +92,19 @@
|
||||
<Compile Include="Form3.Designer.cs">
|
||||
<DependentUpon>Form3.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="LauncherPaths.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SettingsManager.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form2.resx">
|
||||
<DependentUpon>Form2.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Form3.resx">
|
||||
<DependentUpon>Form3.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Número da Versão
|
||||
// Revisão
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.4.0")]
|
||||
[assembly: AssemblyFileVersion("1.4.0")]
|
||||
|
||||
84
SettingsManager.cs
Normal file
84
SettingsManager.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace LegacyConsoleLauncher
|
||||
{
|
||||
public static class SettingsManager
|
||||
{
|
||||
private static readonly string LauncherDataDir =
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "LCELauncher");
|
||||
|
||||
private static readonly string SettingsFile =
|
||||
Path.Combine(LauncherDataDir, "settings.txt");
|
||||
|
||||
public static bool CheckGameUpdatesOnStartup { get; set; } = true;
|
||||
public static bool CheckLauncherUpdatesOnStartup { get; set; } = true;
|
||||
public static string AdditionalLaunchArgs { get; set; } = "";
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
Directory.CreateDirectory(LauncherDataDir);
|
||||
|
||||
CheckGameUpdatesOnStartup = true;
|
||||
CheckLauncherUpdatesOnStartup = true;
|
||||
AdditionalLaunchArgs = "";
|
||||
|
||||
if (!File.Exists(SettingsFile))
|
||||
{
|
||||
Save();
|
||||
return;
|
||||
}
|
||||
|
||||
string[] lines = File.ReadAllLines(SettingsFile);
|
||||
|
||||
foreach (string line in lines)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(line) || !line.Contains("="))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] parts = line.Split(new[] { '=' }, 2);
|
||||
string key = parts[0].Trim();
|
||||
string value = parts[1].Trim();
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case "CheckGameUpdatesOnStartup":
|
||||
CheckGameUpdatesOnStartup = value.Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
break;
|
||||
|
||||
case "CheckLauncherUpdatesOnStartup":
|
||||
CheckLauncherUpdatesOnStartup = value.Equals("true", StringComparison.OrdinalIgnoreCase);
|
||||
break;
|
||||
|
||||
case "AdditionalLaunchArgs":
|
||||
AdditionalLaunchArgs = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
Directory.CreateDirectory(LauncherDataDir);
|
||||
|
||||
string[] lines =
|
||||
{
|
||||
"CheckGameUpdatesOnStartup=" + (CheckGameUpdatesOnStartup ? "true" : "false"),
|
||||
"CheckLauncherUpdatesOnStartup=" + (CheckLauncherUpdatesOnStartup ? "true" : "false"),
|
||||
"AdditionalLaunchArgs=" + (AdditionalLaunchArgs ?? "")
|
||||
};
|
||||
|
||||
File.WriteAllLines(SettingsFile, lines);
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
CheckGameUpdatesOnStartup = true;
|
||||
CheckLauncherUpdatesOnStartup = true;
|
||||
AdditionalLaunchArgs = "";
|
||||
Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user