From 9af23df4f55a3a861bb7daf654c0447ae581c3ac Mon Sep 17 00:00:00 2001
From: Miepee <38186597+Miepee@users.noreply.github.com>
Date: Wed, 5 Jan 2022 17:51:00 +0100
Subject: [PATCH] fix some todos, most notably having nixlauncherconfigpath
defined once
---
.../AM2RLauncher/CrossPlatformOperations.cs | 42 +++++++------------
.../AM2RLauncher/MainForm/MainForm.Events.cs | 4 +-
.../AM2RLauncher/MainForm/MainForm.Methods.cs | 4 --
3 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
index b26daa5..766a021 100644
--- a/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
+++ b/AM2RLauncher/AM2RLauncher/CrossPlatformOperations.cs
@@ -40,6 +40,16 @@ namespace AM2RLauncher
///
public static readonly string LINUXXDGCONFIG = Environment.GetEnvironmentVariable("XDG_CONFIG_HOME");
+ // Config for linux systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
+ // Config for mac systems will be saved in ~/Library/Preferences/AM2RLauncher
+ ///
+ /// Path to the Config file folder on *nix based systems.
+ /// Linux: Will point to XDG_CONFIG_HOME/AM2RLauncher
+ ///
+ public static readonly string NIXLAUNCHERCONFIGPATH = currentPlatform.IsGtk ? ((String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? (NIXHOME + "/.config")
+ : LINUXXDGCONFIG) + "/AM2RLauncher")
+ : NIXHOME + "/Library/Preferences/AM2RLauncher";
+
///
/// Current Path where the Launcher is located. For more info, check .
///
@@ -72,7 +82,7 @@ namespace AM2RLauncher
return new List
{
"https://github.com/Miepee/AM2R-Autopatcher-Mac.git",
- "https://github.com/Miepee/AM2R-Autopatcher-Mac.git" //TODO: make mac official, put this on gitlab
+ "https://github.com/Miepee/AM2R-Autopatcher-Mac.git" //TODO: make mac official at some point:tm:, put this on gitlab
};
}
@@ -88,7 +98,6 @@ namespace AM2RLauncher
///
/// The property to get the value from.
/// The value from as a string
- // TODO: how often is launcherconfigpath / launcherconfigfilepath created? maybe create an extra variable for it so we don't generate it every time
public static string ReadFromConfig(string property)
{
log.Info($"Reading {property} from config.");
@@ -101,15 +110,8 @@ namespace AM2RLauncher
}
else if (currentPlatform.IsGtk || currentPlatform.IsMac)
{
- // Config for linux systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
- // Config for mac systems will be saved in ~/Library/Preferences/AM2RLauncher
- string homePath = NIXHOME;
- string launcherConfigPath = "";
- if (currentPlatform.IsGtk)
- launcherConfigPath = (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? (homePath + "/.config") : LINUXXDGCONFIG) + "/AM2RLauncher";
- else if (currentPlatform.IsMac)
- launcherConfigPath = homePath + "/Library/Preferences/AM2RLauncher";
- string launcherConfigFilePath = launcherConfigPath + "/config.xml";
+ string launcherConfigPath = NIXLAUNCHERCONFIGPATH;
+ string launcherConfigFilePath = launcherConfigPath + "/.config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
// If folder doesn't exist, create it and the config file
@@ -156,14 +158,7 @@ namespace AM2RLauncher
}
else if (currentPlatform.IsGtk || currentPlatform.IsMac)
{
- // Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
- // Config for mac systems will be saved in ~/Library/Preferences/AM2RLauncher
- string homePath = NIXHOME;
- string launcherConfigPath = "";
- if (currentPlatform.IsGtk)
- launcherConfigPath = (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? (homePath + "/.config") : LINUXXDGCONFIG) + "/AM2RLauncher";
- else if (currentPlatform.IsMac)
- launcherConfigPath = homePath + "/Library/Preferences/AM2RLauncher";
+ string launcherConfigPath = NIXLAUNCHERCONFIGPATH;
string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
@@ -211,14 +206,7 @@ namespace AM2RLauncher
}
else if (currentPlatform.IsGtk || currentPlatform.IsMac)
{
- // Config for nix systems will be saved in XDG_CONFIG_HOME/AM2RLauncher (or if empty, ~/.config)
- // Config for mac systems will be saved in ~/Library/Preferences/AM2RLauncher
- string homePath = NIXHOME;
- string launcherConfigPath = "";
- if (currentPlatform.IsGtk)
- launcherConfigPath = (String.IsNullOrWhiteSpace(LINUXXDGCONFIG) ? (homePath + "/.config") : LINUXXDGCONFIG) + "/AM2RLauncher";
- else if (currentPlatform.IsMac)
- launcherConfigPath = homePath + "/Library/Preferences/AM2RLauncher";
+ string launcherConfigPath = NIXLAUNCHERCONFIGPATH;
string launcherConfigFilePath = launcherConfigPath + "/config.xml";
XML.LauncherConfigXML launcherConfig = new XML.LauncherConfigXML();
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
index dba71c3..c780d20 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Events.cs
@@ -634,7 +634,7 @@ namespace AM2RLauncher
///
private void SettingsProfileDropDownSelectedIndexChanged(object sender, EventArgs e)
{
- //TODO: for some reason, clearing the dropdown triggers this event on mac. Why!?
+ //TODO: Eto bug, staying here until it gets fixed.
if (Platform.IsMac && settingsProfileDropDown.SelectedIndex == -1 && settingsProfileDropDown.Items.Count == 0) return;
log.Info("SettingsProfileDropDown.SelectedIndex has been changed to " + settingsProfileDropDown.SelectedIndex + ".");
@@ -746,7 +746,7 @@ namespace AM2RLauncher
/// Gets called when user selects a different item from and changes accordingly.
private void ProfileDropDownSelectedIndexChanged(object sender, EventArgs e)
{
- //TODO: eto bug maybe? for some reason this method shouldnt even get fired when clearing a dropdown...
+ //TODO: Eto bug, staying here until it gets fixed.
if (Platform.IsMac && profileDropDown.SelectedIndex == -1 && profileDropDown.Items.Count == 0) return;
profileIndex = profileDropDown.SelectedIndex;
diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
index c17101f..ece6c1a 100644
--- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
+++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.Methods.cs
@@ -270,10 +270,6 @@ namespace AM2RLauncher
// Switch profilePath on Gtk
if (Platform.IsGtk)
{
- //TODO: it was just recursively deleted, is this really necessary?
- if (Directory.Exists(profilePath + "/assets"))
- Directory.Delete(profilePath + "/assets", true);
-
profilePath += "/assets";
Directory.CreateDirectory(profilePath);
}