Skip to content

Commit

Permalink
Fix Mod Updates Restart Reminder
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Aug 27, 2021
1 parent 425b59a commit f3a72b2
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions BloonsTD6 Mod Helper/MelonMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public static void SettingsPatch()
modsButton.Init();
}

private static bool afterTitleScreen;

public override void OnUpdate()
{
KeyCodeHooks();
Expand All @@ -103,8 +105,8 @@ public override void OnUpdate()

if (Game.instance is null)
return;

if (PopupScreen.instance != null)
if (PopupScreen.instance != null && afterTitleScreen)
UpdateHandler.AnnounceUpdates(modsNeedingUpdates, this.GetModDirectory());

if (InGame.instance is null)
Expand All @@ -130,15 +132,6 @@ private void KeyCodeHooks()

public override void OnTitleScreen()
{
if (UpdateHandler.updatedMods && PopupScreen.instance != null)
{
PopupScreen.instance.ShowPopup(PopupScreen.Placement.menuCenter, "Restart Required",
"You've downloaded new updates for mods, but still need to restart your game to apply them.\n" +
"\nWould you like to do that now?", new Action(() => MenuManager.instance.QuitGame()),
"Yes, quit the game", null, "Not now", Popup.TransitionAnim.Update);
UpdateHandler.updatedMods = false;
}

ModSettingsHandler.SaveModSettings(this.GetModSettingsDir());

if (!scheduledInGamePatch)
Expand Down Expand Up @@ -203,6 +196,8 @@ public override void OnTitleScreen()
$"Finished exporting upgrades to {FileIOUtil.sandboxRoot + "Upgrades"}");
});
});

afterTitleScreen = true;
}

private void Schedule_GameModel_Loaded()
Expand Down Expand Up @@ -231,6 +226,18 @@ public static void DoPatchMethods(Action<BloonsTD6Mod> action)
}
}

public override void OnMainMenu()
{
if (UpdateHandler.updatedMods && PopupScreen.instance != null)
{
PopupScreen.instance.ShowPopup(PopupScreen.Placement.menuCenter, "Restart Required",
"You've downloaded new updates for mods, but still need to restart your game to apply them.\n" +
"\nWould you like to do that now?", new Action(() => MenuManager.instance.QuitGame()),
"Yes, quit the game", null, "Not now", Popup.TransitionAnim.Update);
UpdateHandler.updatedMods = false;
}
}

#region Autosave

public static ModSettingBool openBackupDir = new ModSettingBool(true)
Expand Down

0 comments on commit f3a72b2

Please sign in to comment.