Skip to content

Commit

Permalink
Reimplemented Legacy modprefs.ini Converter
Browse files Browse the repository at this point in the history
  • Loading branch information
HerpDerpinstine committed Jan 10, 2021
1 parent 3c2ad34 commit 073a4bd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
### Version List:

[v3.0.3](#v303)
[v3.0.2](#v302)
[v3.0.4](#v304)
[v3.0.3](#v303)
[v3.0.2](#v302)
[v3.0.1](#v301)
[v3.0.0](#v300)

---

### v3.0.4:

1. Reimplemented Legacy modprefs.ini Converter.

---

### v3.0.3:

1. Fixed Issue with Legacy Detection bugging out causing modprefs.ini to Delete Itself.
Expand Down
17 changes: 9 additions & 8 deletions OperationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ internal static void Automated_Install(string destination, string selected_versi
string proxy_path = null;
if (GetExistingProxyPath(destination, out proxy_path))
File.Delete(proxy_path);
//if (legacy_version)
// DowngradeMelonPreferences(destination);
using FileStream stream = new FileStream(temp_path, FileMode.Open, FileAccess.Read);
using ZipArchive zip = new ZipArchive(stream);
int total_entry_count = zip.Entries.Count;
Expand Down Expand Up @@ -147,6 +145,7 @@ internal static void Automated_Install(string destination, string selected_versi
throw new IOException("Zip entry name ends in directory separator character but contains data.");
Directory.CreateDirectory(fullPath);
}
DowngradeMelonPreferences(destination, legacy_version);
ExtraDirectoryChecks(destination);
}
catch (Exception ex)
Expand Down Expand Up @@ -255,13 +254,13 @@ private static bool GetExistingProxyPath(string destination, out string proxy_pa
return !string.IsNullOrEmpty(proxy_path);
}

/*
private static void DowngradeMelonPreferences(string destination)
private static void DowngradeMelonPreferences(string destination, bool legacy_version)
{
if (!legacy_version || (Program.mainForm.CurrentInstalledVersion == null) || (Program.mainForm.CurrentInstalledVersion.CompareTo(new Version("0.3.0")) < 0))
return;
string userdatapath = Path.Combine(destination, "UserData");
string newfilepath = Path.Combine(userdatapath, "modprefs.ini");
if (File.Exists(newfilepath))
File.Delete(newfilepath);
if (!Directory.Exists(userdatapath))
return;
string oldfilepath = Path.Combine(userdatapath, "MelonPreferences.cfg");
if (!File.Exists(oldfilepath))
return;
Expand All @@ -274,6 +273,9 @@ private static void DowngradeMelonPreferences(string destination)
TomlTable model = docsyn.ToModel();
if (model.Count <= 0)
return;
string newfilepath = Path.Combine(userdatapath, "modprefs.ini");
if (File.Exists(newfilepath))
File.Delete(newfilepath);
IniFile iniFile = new IniFile(newfilepath);
foreach (KeyValuePair<string, object> keypair in model)
{
Expand Down Expand Up @@ -310,7 +312,6 @@ private static void DowngradeMelonPreferences(string destination)
}
File.Delete(oldfilepath);
}
*/

private static void ExtraDirectoryChecks(string destination)
{
Expand Down
2 changes: 1 addition & 1 deletion Properties/BuildInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public static class BuildInfo
public const string Description = "MelonLoader Installer";
public const string Author = "Lava Gang";
public const string Company = "discord.gg/2Wn3N2P";
public const string Version = "3.0.3";
public const string Version = "3.0.4";
}
}

0 comments on commit 073a4bd

Please sign in to comment.