Skip to content

Commit

Permalink
Preliminary fix for 1330 studios ML version
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Dec 22, 2022
1 parent aeb57a6 commit 9cc3f16
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 258 deletions.
90 changes: 0 additions & 90 deletions BloonsTD6 Mod Helper/Api/AutoSave.cs

This file was deleted.

6 changes: 3 additions & 3 deletions BloonsTD6 Mod Helper/Api/ProfileManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ internal static void UnCleanProfile(ProfileModel profile)
{
if (profile.savedMaps?.ContainsKey(map) == true)
{
var mapSaveDataModel = profile.savedMaps[map];
var mapSaveDataModel = profile.savedMaps[(string) map];
if (mapSaveDataModel.players.ContainsKey(player))
{
mapSaveDataModel.players[player].hero = hero;
mapSaveDataModel.players[(int) player].hero = hero;
}
}
}
Expand Down Expand Up @@ -293,7 +293,7 @@ private static void CleanDictionary<T>(Il2CppSystem.Collections.Generic.Dictiona
{
return;
}

foreach (var (thing, value) in dictionary)
{
if (clean(thing))
Expand Down
44 changes: 0 additions & 44 deletions BloonsTD6 Mod Helper/MelonMain.Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,50 +188,6 @@ internal partial class MelonMain
onSave = ModHelperFiles.CreateTargetsFile
};

#region Autosave

public static readonly ModSettingCategory AutoSaveCategory = new("Auto Save Settings")
{
icon = SaveGameIcon
};

public static readonly ModSettingButton OpenBackupDir = new(AutoSave.OpenBackupDir)
{
displayName = "Open Backup Directory",
buttonText = "Open",
category = AutoSaveCategory
};

public static readonly ModSettingButton OpenSaveDir = new(AutoSave.OpenAutoSaveDir)
{
displayName = "Open Save Directory",
buttonText = "Open",
category = AutoSaveCategory
};

public static readonly ModSettingFolder AutosavePath =
new(Path.Combine(ModHelper.ModHelperDirectory, "Mod Settings"))
{
displayName = "Backup Directory",
onSave = AutoSave.SetAutosaveDirectory,
category = AutoSaveCategory
};

public static readonly ModSettingInt TimeBetweenBackup = new(30)
{
displayName = "Minutes Between Each Backup",
category = AutoSaveCategory
};

public static readonly ModSettingInt MaxSavedBackups = new(10)
{
displayName = "Max Saved Backups",
onSave = max => AutoSave.backup.SetMaxBackups(max),
category = AutoSaveCategory
};

#endregion

#region Debug

private static readonly ModSettingCategory Debug = new("Debug");
Expand Down
10 changes: 1 addition & 9 deletions BloonsTD6 Mod Helper/MelonMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public override void OnInitialize()
public override void OnUpdate()
{
ModByteLoader.OnUpdate();
InitialLoadTasks_MoveNext.Update();
// InitialLoadTasks_MoveNext.Update();

if (Game.instance is null)
return;
Expand Down Expand Up @@ -112,8 +112,6 @@ public override void OnTitleScreen()

if (!scheduledInGamePatch) Schedule_InGame_Loaded();

AutoSave.InitAutosave(this.GetModSettingsDir(true));

foreach (var gameMode in Game.instance.model.mods)
{
if (gameMode.name.EndsWith("Only"))
Expand Down Expand Up @@ -171,10 +169,4 @@ public override void OnMainMenu()
Fonts.Load();
RoundSetChanger.EnsureHidden();
}

#region Autosave

public override void OnMatchEnd() => AutoSave.backup.CreateBackup();

#endregion
}
4 changes: 2 additions & 2 deletions BloonsTD6 Mod Helper/Patches/InitialLoadTasks_MoveNext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using Object = Il2CppSystem.Object;
namespace BTD_Mod_Helper.Patches;

[HarmonyPatch(typeof(Main._InitialLoadTasks_d__45), nameof(Main._InitialLoadTasks_d__45.MoveNext))]
/*[HarmonyPatch(typeof(Main._InitialLoadTasks_d__45), nameof(Main._InitialLoadTasks_d__45.MoveNext))]
internal static class InitialLoadTasks_MoveNext
{
internal static List<ModLoadTask> modsTasks;
Expand Down Expand Up @@ -150,4 +150,4 @@ private static bool Prefix(ref Task __result)
}
return true;
}
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private static IEnumerable<MethodBase> TargetMethods()
[HarmonyPrefix]
private static bool Prefix(ref bool __result)
{
if (ModdedClientBypassing.CurrentlyBypassingCheck && MelonMain.BypassSavingRestrictions)
if (MelonMain.BypassSavingRestrictions)
{
__result = false;
return false;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BTD_Mod_Helper.Patches.Resources;
/// <summary>
/// This makes the first GameModel loaded always be the one returned, even if another GameModel load tries to happen
/// </summary>
[HarmonyPatch(typeof(GameModelUtil._LoadGameModelAsync_d__9),
/*[HarmonyPatch(typeof(GameModelUtil._LoadGameModelAsync_d__9),
nameof(GameModelUtil._LoadGameModelAsync_d__9.MoveNext))]
internal static class LoadGameModelAsync_MoveNext
{
Expand All @@ -32,4 +32,4 @@ private static void Postfix(GameModelUtil._LoadGameModelAsync_d__9 __instance)
}
}
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace BTD_Mod_Helper.Patches.Resources;

[HarmonyPatch(typeof(LocalizationManager._LoadTableAsync_d__45),
/*[HarmonyPatch(typeof(LocalizationManager._LoadTableAsync_d__45),
nameof(LocalizationManager._LoadTableAsync_d__45.MoveNext))]
internal static class LocalizationManger_LoadTableAsync
{
Expand All @@ -29,4 +29,4 @@ private static void Postfix(LocalizationManager._LoadTableAsync_d__45 __instance
}
}
}
}
}*/
4 changes: 2 additions & 2 deletions BloonsTD6 Mod Helper/Patches/UI/LayoutGroupPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace BTD_Mod_Helper.Patches.UI;
/// <summary>
/// I'm just annoyed that Unity doesn't work this way by default lol
/// </summary>
internal static class LayoutGroupPatches
/*internal static class LayoutGroupPatches
{
[HarmonyPatch(typeof(LayoutGroup), nameof(LayoutGroup.flexibleHeight), MethodType.Getter)]
internal static class LayoutGroup_FlexibleHeight
Expand Down Expand Up @@ -109,4 +109,4 @@ private static void Postfix(HorizontalLayoutGroup __instance, ref float __result
}
}
}
}
}*/
20 changes: 19 additions & 1 deletion BloonsTD6 Mod Helper/Patches/UI/TitleScreen_Start.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Linq;
using System;
using System.Linq;
using Assets.Main.Scenes;
using BTD_Mod_Helper.Api;
using NinjaKiwi.Common;

namespace BTD_Mod_Helper.Patches.UI;

Expand All @@ -26,6 +28,22 @@ internal static void Postfix()
ModContent.GetContent<ModLoadTask>().Do(task => task.RunSync());
}

var currentTable = LocalizationManager.Instance.textTable;
var defaultTable = LocalizationManager.Instance.defaultTable;
foreach (var namedModContent in ModContent.GetContent<NamedModContent>())
{
try
{
namedModContent.RegisterText(currentTable);
namedModContent.RegisterText(defaultTable);
}
catch (Exception e)
{
ModHelper.Log($"Failed to register text for {namedModContent}");
ModHelper.Error(e);
}
}

ModHelper.PerformHook(mod => mod.OnTitleScreen());
}
}
Loading

0 comments on commit 9cc3f16

Please sign in to comment.