mirror of
https://github.com/OxyZin/LegacyConsoleLauncher.git
synced 2026-07-18 02:51:13 +00:00
- 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
84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
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();
|
|
}
|
|
}
|
|
} |