// This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
// This is a duplicate of CrossPlatformOperations.GenerateCurrentPath, because trying to invoke that would cause a crash due to currentPlatform not being initialized.
Log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_"+onlineVersion+platformSuffix+".zip to "+zipPath+".");
log.Info("Downloading https://github.com/AM2R-Community-Developers/AM2RLauncher/releases/latest/download/AM2RLauncher_"+onlineVersion+platformSuffix+".zip to "+zipPath+".");
/// When a Launcher update occurs that introduces new config properties, this method ensures that the old user config is copied over as much as possible.
/// When a Launcher update occurs that introduces new config properties, this method ensures that the old user config is copied over as much as possible.
// If copying subdirectories, copy them and their contents to new location.
if(!copySubDirs)
return;
/// <summary>
foreach(DirectoryInfosubDirindirs)
/// This is a custom method, that deletes a Directory. The reason this is used, instead of <see cref="Directory.Delete(string)"/>,
/// is because this one sets the attributes of all files to be deletable, while <see cref="Directory.Delete(string)"/> does not do that on it's own.
/// It's needed, because sometimes there are read-only files being generated, that would normally need more code in order to reset the attributes.<br/>
/// Note, that this method acts recursively.
/// </summary>
/// <param name="targetDir">The directory to delete.</param>
/// This is a custom method, that deletes a Directory. The reason this is used, instead of <see cref="Directory.Delete(string)"/>,
File.SetAttributes(file,FileAttributes.Normal);
/// is because this one sets the attributes of all files to be deletable, while <see cref="Directory.Delete(string)"/> does not do that on it's own.
File.Delete(file);
/// It's needed, because sometimes there are read-only files being generated, that would normally need more code in order to reset the attributes.<br/>
}
/// Note, that this method acts recursively.
/// </summary>
/// <param name="targetDir">The directory to delete.</param>
/// Class that handles how the Launcher settings are saved as XML. Only affects Linux
/// </summary>
[Serializable]
[XmlRoot("settings")]
publicclassLauncherConfigXML
{
{
/// <summary>Indicates wether or not to auto-update the Launcher. Used for <see cref="MainForm.autoUpdateAM2RCheck"/></summary>
[XmlAttribute("AutoUpdateAM2R")]
publicboolAutoUpdateAM2R
{get;set;}
/// <summary>Indicates wether or not to auto-update the Launcher. Used for <see cref="MainForm.autoUpdateLauncherCheck"/></summary>
[XmlAttribute("AutoUpdateLauncher")]
publicboolAutoUpdateLauncher
{get;set;}
/// <summary>Indicates the Language of the Launcher. Used for <see cref="MainForm.languageDropDown"/></summary>
[XmlAttribute("Language")]
publicstringLanguage
{get;set;}
/// <summary>Indicates wether or not to use High-quality music when patching to PC. Used for <see cref="MainForm.hqMusicPCCheck"/></summary>
[XmlAttribute("MusicHQPC")]
publicboolMusicHQPC
{get;set;}
/// <summary>Indicates wether or not to use High-quality music when patching to Android. Used for <see cref="MainForm.hqMusicAndroidCheck"/></summary>
[XmlAttribute("MusicHQAndroid")]
publicboolMusicHQAndroid
{get;set;}
/// <summary>Indicates the index for <see cref="MainForm.mirrorDropDown"/>.</summary>
[XmlAttribute("MirrorIndex")]
publicintMirrorIndex
{get;set;}
/// <summary>Indicates the index for <see cref="MainForm.profileDropDown"/>.</summary>
[XmlAttribute("ProfileIndex")]
publicstringProfileIndex
{get;set;}
/// <summary>Indicates wether or not to have custom mirrors enabled. Used for <see cref="MainForm.customMirrorCheck"/></summary>
[XmlAttribute("CustomMirrorEnabled")]
publicboolCustomMirrorEnabled
{get;set;}
/// <summary>Indicates the custom mirror as a text. Used for <see cref="MainForm.customMirrorTextBox"/></summary>
[XmlAttribute("CustomMirrorText")]
publicstringCustomMirrorText
{get;set;}
/// <summary>Indicates whether or not to create debug logs of profile. Used for <see cref="MainForm.profileDebugLogCheck"/></summary>
[XmlAttribute("ProfileDebugLog")]
publicboolProfileDebugLog
{get;set;}
/// <summary>Indicates the custom environment variable(s) as text. Used for <see cref="MainForm.customEnvVarTextBox"/></summary>
[XmlAttribute("CustomEnvVar")]
publicstringCustomEnvVar
{get;set;}
/// <summary>Indicates the Width of the Launcher.</summary>
[XmlAttribute("Width")]
publicintWidth
{get;set;}
/// <summary>Indicates the Height of the Launcher.</summary>
[XmlAttribute("Height")]
publicintHeight
{get;set;}
/// <summary>Indicates wether or not the Launcher is maximized or not.</summary>
[XmlAttribute("IsMaximized")]
publicboolIsMaximized
{get;set;}
// Huge help from James for all of this!!!
// Here's a short explanation of this. Basically, what we do is create an indexer. This makes it possible for this class to be indexed, like this LauncherConfigXML[i]
// The indexer here has a get and set "submethod". And both use Reflection to get the current class as something that can be used with lambda values
// So for get we just lambda the properties and search for something that can be read and has the same name as the input property. After that, we just get the value and return it as a string
// Set is basiaclly the same, but instead of returning it, we set the prtoperty value, which would be followed after the `='.
// So LauncherConfigXML[property] = hellWorld would set the value of `property` to `hellWorld`
/// <summary>
/// <summary>
/// Class that handles how the Launcher settings are saved as XML. Only affects Linux
/// An Indexer for <see cref="ProfileXML"/>. Not to be used directly, use <see cref="CrossPlatformOperations.WriteToConfig(string, object)"/>
/// or <see cref="CrossPlatformOperations.ReadFromConfig(string)"/> instead!
/// </summary>
/// </summary>
[Serializable]
/// <param name="property">The property to get or set.</param>
[XmlRoot("settings")]
/// <returns>The value of <paramref name="property"/> as an <see cref="object"/> if used as a get, <see cref="Void"/> if used as a set.</returns>
publicclassLauncherConfigXML
publicobjectthis[stringproperty]
{
{
/// <summary>Indicates wether or not to auto-update the Launcher. Used for <see cref="MainForm.autoUpdateAM2RCheck"/></summary>
get
[XmlAttribute("AutoUpdateAM2R")]
{
publicboolAutoUpdateAM2R
// This is gonna throw an exception, if the property can't be found. because of null.GetValue(this)
/// <summary>Indicates the Language of the Launcher. Used for <see cref="MainForm.languageDropDown"/></summary>
}
[XmlAttribute("Language")]
}
publicstringLanguage
{get;set;}
/// <summary>Indicates wether or not to use High-quality music when patching to PC. Used for <see cref="MainForm.hqMusicPCCheck"/></summary>
[XmlAttribute("MusicHQPC")]
publicboolMusicHQPC
{get;set;}
/// <summary>Indicates wether or not to use High-quality music when patching to Android. Used for <see cref="MainForm.hqMusicAndroidCheck"/></summary>
[XmlAttribute("MusicHQAndroid")]
publicboolMusicHQAndroid
{get;set;}
/// <summary>Indicates the index for <see cref="MainForm.mirrorDropDown"/>.</summary>
[XmlAttribute("MirrorIndex")]
publicintMirrorIndex
{get;set;}
/// <summary>Indicates the index for <see cref="MainForm.profileDropDown"/>.</summary>
[XmlAttribute("ProfileIndex")]
publicstringProfileIndex
{get;set;}
/// <summary>Indicates wether or not to have custom mirrors enabled. Used for <see cref="MainForm.customMirrorCheck"/></summary>
[XmlAttribute("CustomMirrorEnabled")]
publicboolCustomMirrorEnabled
{get;set;}
/// <summary>Indicates the custom mirror as a text. Used for <see cref="MainForm.customMirrorTextBox"/></summary>
[XmlAttribute("CustomMirrorText")]
publicstringCustomMirrorText
{get;set;}
/// <summary>Indicates whether or not to create debug logs of profile. Used for <see cref="MainForm.profileDebugLogCheck"/></summary>
[XmlAttribute("ProfileDebugLog")]
publicboolProfileDebugLog
{get;set;}
/// <summary>Indicates the custom environment variable(s) as text. Used for <see cref="MainForm.customEnvVarTextBox"/></summary>
[XmlAttribute("CustomEnvVar")]
publicstringCustomEnvVar
{get;set;}
/// <summary>Indicates the Width of the Launcher.</summary>
[XmlAttribute("Width")]
publicintWidth
{get;set;}
/// <summary>Indicates the Height of the Launcher.</summary>
[XmlAttribute("Height")]
publicintHeight
{get;set;}
/// <summary>Indicates wether or not the Launcher is maximized or not.</summary>
[XmlAttribute("IsMaximized")]
publicboolIsMaximized
{get;set;}
// Huge help from James for all of this!!!
// Here's a short explanation of this. Basically, what we do is create an indexer. This makes it possible for this class to be indexed, like this LauncherConfigXML[i]
// The indexer here has a get and set "submethod". And both use Reflection to get the current class as something that can be used with lambda values
// So for get we just lambda the properties and search for something that can be read and has the same name as the input property. After that, we just get the value and return it as a string
// Set is basiaclly the same, but instead of returning it, we set the prtoperty value, which would be followed after the `='.
// So LauncherConfigXML[property] = hellWorld would set the value of `property` to `hellWorld`
/// <summary>
/// An Indexer for <see cref="ProfileXML"/>. Not to be used directly, use <see cref="CrossPlatformOperations.WriteToConfig(string, object)"/>
/// or <see cref="CrossPlatformOperations.ReadFromConfig(string)"/> instead!
/// </summary>
/// <param name="property">The property to get or set.</param>
/// <returns>The value of <paramref name="property"/> as an <see cref="object"/> if used as a get, <see cref="Void"/> if used as a set.</returns>
publicobjectthis[stringproperty]
{
get
{
// This is gonna throw an exception, if the property can't be found. because of null.GetValue(this)
/// Class that handles how the mod settings are saved as XML.
/// </summary>
[Serializable]
[XmlRoot("message")]
publicclassProfileXML
{
{
/// <summary>Indicates the Operating system the mod was made for.</summary>
[XmlAttribute("OperatingSystem")]
publicstringOperatingSystem
{get;set;}
/// <summary>Indicates the xml version the mod was made in.</summary>
[XmlAttribute("XMLVersion")]
publicintXMLVersion
{get;set;}
/// <summary>Indicates the version of the mod.</summary>
[XmlAttribute("Version")]
publicstringVersion
{get;set;}
/// <summary>Indicates the mod's name.</summary>
[XmlAttribute("Name")]
publicstringName
{get;set;}
/// <summary>Indicates the mod's author.</summary>
[XmlAttribute("Author")]
publicstringAuthor
{get;set;}
/// <summary>Indicates wether or not the mod uses custom music.</summary>
[XmlAttribute("UsesCustomMusic")]
publicboolUsesCustomMusic
{get;set;}
/// <summary>Indicates the save location of the mod.</summary>
[XmlAttribute("SaveLocation")]
publicstringSaveLocation
{get;set;}
/// <summary>Indicates wether or not the mod supports Android.</summary>
[XmlAttribute("SupportsAndroid")]
publicboolSupportsAndroid
{get;set;}
/// <summary>Indicates wether or not the mod was compiled with YYC.</summary>
[XmlAttribute("UsesYYC")]
publicboolUsesYYC
{get;set;}
/// <summary>Indicates if the mod is installable. This is only <see langword="false"/> for archival community updates mods.</summary>
[XmlAttribute("Installable")]
publicboolInstallable
{get;set;}
/// <summary>Indicates any notes that the mod author deemed worthy to share about his mod.</summary>
[XmlAttribute("ProfileNotes")]
publicstringProfileNotes
{get;set;}
/// <summary>This gets calculated at runtime, by <see cref="MainForm.LoadProfiles"/>. Indicates where the install data for the mod is stored.</summary>
[XmlIgnore]
publicstringDataPath
{get;set;}
/// <summary>Creates a <see cref="ProfileXML"/> with a default set of attributes.</summary>
publicProfileXML()
{
Installable=true;
}
/// <summary>
/// <summary>
/// Class that handles how the mod settings are saved as XML.
/// Creates a <see cref="ProfileXML"/> with a custom set of attributes.
/// </summary>
/// </summary>
[Serializable]
/// <param name="operatingSystem">The operating system the mod was made on.</param>
[XmlRoot("message")]
/// <param name="xmlVersion">The xml version the mod was created with.</param>
publicclassProfileXML
/// <param name="version">The version of the mod.</param>
/// <param name="name">The mod name.</param>
/// <param name="author">The mod author.</param>
/// <param name="usesCustomMusic">Wether or not the mod uses custom music.</param>
/// <param name="saveLocation">The save location of the mod.</param>
/// <param name="android">Wether or not the mod works for android.</param>
/// <param name="usesYYC">Wether or not the mod was made with YYC.</param>
/// <param name="installable">Wether or not the mod is installable.</param>
/// <param name="profileNotes">The notes of the mod.</param>
/// <summary>Indicates the Operating system the mod was made for.</summary>
OperatingSystem=operatingSystem;
[XmlAttribute("OperatingSystem")]
XMLVersion=xmlVersion;
publicstringOperatingSystem
Version=version;
{get;set;}
Name=name;
/// <summary>Indicates the xml version the mod was made in.</summary>
Author=author;
[XmlAttribute("XMLVersion")]
UsesCustomMusic=usesCustomMusic;
publicintXMLVersion
SaveLocation=saveLocation;
{get;set;}
SupportsAndroid=android;
/// <summary>Indicates the version of the mod.</summary>
UsesYYC=usesYYC;
[XmlAttribute("Version")]
Installable=installable;
publicstringVersion
ProfileNotes=profileNotes;
{get;set;}
/// <summary>Indicates the mod's name.</summary>
[XmlAttribute("Name")]
publicstringName
{get;set;}
/// <summary>Indicates the mod's author.</summary>
[XmlAttribute("Author")]
publicstringAuthor
{get;set;}
/// <summary>Indicates wether or not the mod uses custom music.</summary>
[XmlAttribute("UsesCustomMusic")]
publicboolUsesCustomMusic
{get;set;}
/// <summary>Indicates the save location of the mod.</summary>
[XmlAttribute("SaveLocation")]
publicstringSaveLocation
{get;set;}
/// <summary>Indicates wether or not the mod supports Android.</summary>
[XmlAttribute("SupportsAndroid")]
publicboolSupportsAndroid
{get;set;}
/// <summary>Indicates wether or not the mod was compiled with YYC.</summary>
[XmlAttribute("UsesYYC")]
publicboolUsesYYC
{get;set;}
/// <summary>Indicates if the mod is installable. This is only <see langword="false"/> for archival community updates mods.</summary>
[XmlAttribute("Installable")]
publicboolInstallable
{get;set;}
/// <summary>Indicates any notes that the mod author deemed worthy to share about his mod.</summary>
[XmlAttribute("ProfileNotes")]
publicstringProfileNotes
{get;set;}
/// <summary>This gets calculated at runtime, by <see cref="MainForm.LoadProfiles"/>. Indicates where the install data for the mod is stored.</summary>
[XmlIgnore]
publicstringDataPath
{get;set;}
/// <summary>Creates a <see cref="ProfileXML"/> with a default set of attributes.</summary>
publicProfileXML()
{
Installable=true;
}
/// <summary>
/// Creates a <see cref="ProfileXML"/> with a custom set of attributes.
/// </summary>
/// <param name="operatingSystem">The operating system the mod was made on.</param>
/// <param name="xmlVersion">The xml version the mod was created with.</param>
/// <param name="version">The version of the mod.</param>
/// <param name="name">The mod name.</param>
/// <param name="author">The mod author.</param>
/// <param name="usesCustomMusic">Wether or not the mod uses custom music.</param>
/// <param name="saveLocation">The save location of the mod.</param>
/// <param name="android">Wether or not the mod works for android.</param>
/// <param name="usesYYC">Wether or not the mod was made with YYC.</param>
/// <param name="installable">Wether or not the mod is installable.</param>
/// <param name="profileNotes">The notes of the mod.</param>