Skip to content

Commit 073a4bd

Browse files
Reimplemented Legacy modprefs.ini Converter
1 parent 3c2ad34 commit 073a4bd

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

CHANGELOG.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
### Version List:
22

3-
[v3.0.3](#v303)
4-
[v3.0.2](#v302)
3+
[v3.0.4](#v304)
4+
[v3.0.3](#v303)
5+
[v3.0.2](#v302)
56
[v3.0.1](#v301)
67
[v3.0.0](#v300)
78

9+
---
10+
11+
### v3.0.4:
12+
13+
1. Reimplemented Legacy modprefs.ini Converter.
14+
15+
---
16+
817
### v3.0.3:
918

1019
1. Fixed Issue with Legacy Detection bugging out causing modprefs.ini to Delete Itself.

OperationHandler.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ internal static void Automated_Install(string destination, string selected_versi
107107
string proxy_path = null;
108108
if (GetExistingProxyPath(destination, out proxy_path))
109109
File.Delete(proxy_path);
110-
//if (legacy_version)
111-
// DowngradeMelonPreferences(destination);
112110
using FileStream stream = new FileStream(temp_path, FileMode.Open, FileAccess.Read);
113111
using ZipArchive zip = new ZipArchive(stream);
114112
int total_entry_count = zip.Entries.Count;
@@ -147,6 +145,7 @@ internal static void Automated_Install(string destination, string selected_versi
147145
throw new IOException("Zip entry name ends in directory separator character but contains data.");
148146
Directory.CreateDirectory(fullPath);
149147
}
148+
DowngradeMelonPreferences(destination, legacy_version);
150149
ExtraDirectoryChecks(destination);
151150
}
152151
catch (Exception ex)
@@ -255,13 +254,13 @@ private static bool GetExistingProxyPath(string destination, out string proxy_pa
255254
return !string.IsNullOrEmpty(proxy_path);
256255
}
257256

258-
/*
259-
private static void DowngradeMelonPreferences(string destination)
257+
private static void DowngradeMelonPreferences(string destination, bool legacy_version)
260258
{
259+
if (!legacy_version || (Program.mainForm.CurrentInstalledVersion == null) || (Program.mainForm.CurrentInstalledVersion.CompareTo(new Version("0.3.0")) < 0))
260+
return;
261261
string userdatapath = Path.Combine(destination, "UserData");
262-
string newfilepath = Path.Combine(userdatapath, "modprefs.ini");
263-
if (File.Exists(newfilepath))
264-
File.Delete(newfilepath);
262+
if (!Directory.Exists(userdatapath))
263+
return;
265264
string oldfilepath = Path.Combine(userdatapath, "MelonPreferences.cfg");
266265
if (!File.Exists(oldfilepath))
267266
return;
@@ -274,6 +273,9 @@ private static void DowngradeMelonPreferences(string destination)
274273
TomlTable model = docsyn.ToModel();
275274
if (model.Count <= 0)
276275
return;
276+
string newfilepath = Path.Combine(userdatapath, "modprefs.ini");
277+
if (File.Exists(newfilepath))
278+
File.Delete(newfilepath);
277279
IniFile iniFile = new IniFile(newfilepath);
278280
foreach (KeyValuePair<string, object> keypair in model)
279281
{
@@ -310,7 +312,6 @@ private static void DowngradeMelonPreferences(string destination)
310312
}
311313
File.Delete(oldfilepath);
312314
}
313-
*/
314315

315316
private static void ExtraDirectoryChecks(string destination)
316317
{

Properties/BuildInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public static class BuildInfo
66
public const string Description = "MelonLoader Installer";
77
public const string Author = "Lava Gang";
88
public const string Company = "discord.gg/2Wn3N2P";
9-
public const string Version = "3.0.3";
9+
public const string Version = "3.0.4";
1010
}
1111
}

0 commit comments

Comments
 (0)