Skip to content

Commit

Permalink
Merge pull request #209 from anno-mods/devel/modloader-dialog
Browse files Browse the repository at this point in the history
add remove modloader dialog at startup
  • Loading branch information
taubenangriff authored Apr 7, 2023
2 parents ed36492 + 0724814 commit 57c8875
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ModManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using System.Windows;
using Imya.UI.Properties;
using Imya.UI.Utils;
using Imya.Utils;

namespace Imya.UI
Expand Down Expand Up @@ -39,6 +40,13 @@ public MainWindow()
{
Task.Run(async () => await GithubClientProvider.Authenticator.StartAuthentication());
}

if (GameSetupManager.Instance.NeedsModloaderRemoval())
{
var result = PopupCreator.CreateModloaderPopup().ShowDialog();
if (result is true)
GameSetupManager.Instance.RemoveModloader();
}
}

public void SetUpEmbeddedConsole()
Expand Down
7 changes: 7 additions & 0 deletions ModManager/Utils/PopupCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,12 @@ public static GenericOkayPopup CreateInvalidSetupPopup()

};

public static GenericOkayPopup CreateModloaderPopup() => new()
{
MESSAGE = TextManager.GetText("STARTUP_REMOVECOMMUNITYMODLOADER"),
CANCEL_TEXT = TextManager.GetText("STARTUP_REMOVECOMMUNITYMODLOADER_NO"),
OK_TEXT = TextManager.GetText("STARTUP_REMOVECOMMUNITYMODLOADER_YES"),
};

}
}
39 changes: 39 additions & 0 deletions ModManager/resources/texts.json
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,45 @@
"Spanish": null,
"Taiwanese": null
},
"STARTUP_REMOVECOMMUNITYMODLOADER": {
"Chinese": null,
"English": "You seem to have an old community modloader, which is no longer needed since Game Update 17. Do you want to remove it?",
"French": null,
"German": "Wie es scheint, ist der alte Community-Modloader noch installiert. Dieser wird seit Game Update 17 nicht mehr benötigt. Soll dieser entfernt werden?",
"Italian": null,
"Japanese": null,
"Korean": null,
"Polish": null,
"Russian": null,
"Spanish": null,
"Taiwanese": null
},
"STARTUP_REMOVECOMMUNITYMODLOADER_YES": {
"Chinese": null,
"English": "Yes, remove it",
"French": null,
"German": "Ja, entfernen",
"Italian": null,
"Japanese": null,
"Korean": null,
"Polish": null,
"Russian": null,
"Spanish": null,
"Taiwanese": null
},
"STARTUP_REMOVECOMMUNITYMODLOADER_NO": {
"Chinese": null,
"English": "Keep",
"French": null,
"German": "Beibehalten",
"Italian": null,
"Japanese": null,
"Korean": null,
"Polish": null,
"Russian": null,
"Spanish": null,
"Taiwanese": null
},
"CONTROLS_TOGGLE_HIDE": {
"Chinese": null,
"English": "hide",
Expand Down
28 changes: 28 additions & 0 deletions ModManager_Classes/Utils/GameSetupManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,34 @@ private void DeactivateModloader()
}
}

/// <summary>
/// Check if python35_ubi.dll is there.
/// </summary>
public bool NeedsModloaderRemoval()
{
if (ExecutableDir is null || !Directory.Exists(ExecutableDir)) return false;
return File.Exists(Path.Combine(ExecutableDir, "python35_ubi.dll"));
}

/// <summary>
/// Rename python35_ubi.dll to python35.dll
/// </summary>
public void RemoveModloader()
{
if (!NeedsModloaderRemoval()) return;

try
{
File.Delete(Path.Combine(ExecutableDir!, "python35.dll"));
File.Move(Path.Combine(ExecutableDir!, "python35_ubi.dll"), Path.Combine(ExecutableDir!, "python35.dll"));
ModloaderState = ModloaderInstallationState.Uninstalled;
}
catch (Exception)
{
Console.WriteLine("Modloader deactivation unsuccessful");
}
}

private FileSystemWatcher? CreateWatcher(string pathToWatch)
{
if (!Directory.Exists(pathToWatch))
Expand Down

0 comments on commit 57c8875

Please sign in to comment.