From c0a509ac0566ecb871acabc32c94291eba8135a0 Mon Sep 17 00:00:00 2001 From: GatoWare Date: Tue, 10 Mar 2026 12:01:07 -0300 Subject: [PATCH] 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 --- Form1.Accounts.cs | 7 +- Form1.Designer.cs | 23 +--- Form1.Events.cs | 40 ++++--- Form1.Game.cs | 13 ++- Form1.Skins.cs | 2 +- Form1.Updates.cs | 14 +-- Form1.cs | 23 ++-- Form3.Designer.cs | 202 ++++++++++++++++++++++++++++++++++- Form3.cs | 133 +++++++++++++++++++++-- Form3.resx | 123 +++++++++++++++++++++ LauncherPaths.cs | 15 +++ LegacyConsoleLauncher.csproj | 5 + Properties/AssemblyInfo.cs | 4 +- SettingsManager.cs | 84 +++++++++++++++ 14 files changed, 612 insertions(+), 76 deletions(-) create mode 100644 Form3.resx create mode 100644 LauncherPaths.cs create mode 100644 SettingsManager.cs diff --git a/Form1.Accounts.cs b/Form1.Accounts.cs index cb584de..e74d1f4 100644 --- a/Form1.Accounts.cs +++ b/Form1.Accounts.cs @@ -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) diff --git a/Form1.Designer.cs b/Form1.Designer.cs index dedcdc6..294dbff 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -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; diff --git a/Form1.Events.cs b/Form1.Events.cs index a6c0534..538a25f 100644 --- a/Form1.Events.cs +++ b/Form1.Events.cs @@ -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(); + } + } } -} \ No newline at end of file + } \ No newline at end of file diff --git a/Form1.Game.cs b/Form1.Game.cs index b655ca6..56eb6ab 100644 --- a/Form1.Game.cs +++ b/Form1.Game.cs @@ -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(); } diff --git a/Form1.Skins.cs b/Form1.Skins.cs index 294fcb2..8d02aae 100644 --- a/Form1.Skins.cs +++ b/Form1.Skins.cs @@ -10,7 +10,7 @@ namespace LegacyConsoleLauncher { private string GetSkinFolder() { - return skinsDir; + return LauncherPaths.SkinsDir; } private string GetAccountSkinPath(string username) diff --git a/Form1.Updates.cs b/Form1.Updates.cs index 3b3826f..30956df 100644 --- a/Form1.Updates.cs +++ b/Form1.Updates.cs @@ -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 { diff --git a/Form1.cs b/Form1.cs index 47ebfc5..ec53f65 100644 --- a/Form1.cs +++ b/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(); + } } } } \ No newline at end of file diff --git a/Form3.Designer.cs b/Form3.Designer.cs index afb8c94..5ddbb6d 100644 --- a/Form3.Designer.cs +++ b/Form3.Designer.cs @@ -28,12 +28,208 @@ /// 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; } } \ No newline at end of file diff --git a/Form3.cs b/Form3.cs index 3a08a21..ef3e360 100644 --- a/Form3.cs +++ b/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(); } } -} +} \ No newline at end of file diff --git a/Form3.resx b/Form3.resx new file mode 100644 index 0000000..417cd97 --- /dev/null +++ b/Form3.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/LauncherPaths.cs b/LauncherPaths.cs new file mode 100644 index 0000000..b3e1460 --- /dev/null +++ b/LauncherPaths.cs @@ -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"); + } +} diff --git a/LegacyConsoleLauncher.csproj b/LegacyConsoleLauncher.csproj index dfadf37..4543eac 100644 --- a/LegacyConsoleLauncher.csproj +++ b/LegacyConsoleLauncher.csproj @@ -92,14 +92,19 @@ Form3.cs + + Form1.cs Form2.cs + + Form3.cs + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 1c0bf09..b55e473 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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")] diff --git a/SettingsManager.cs b/SettingsManager.cs new file mode 100644 index 0000000..a77d492 --- /dev/null +++ b/SettingsManager.cs @@ -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(); + } + } +} \ No newline at end of file