Skip to content

Commit

Permalink
Round Set Changer / Apopalypse changes, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doombubbles committed Sep 3, 2024
1 parent 34f4083 commit 4b864b2
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 66 deletions.
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/Api/Helpers/FileDialogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace BTD_Mod_Helper.Api.Helpers;
/// </summary>
public static class FileDialogHelper
{
private static readonly string[] Dlls = {"nfd.dll", "nfd_x86.dll"};
private static readonly string[] Dlls = ["nfd.dll", "nfd_x86.dll"];

/// <summary>
/// Ensure that the NFD native dlls are present in the game root folder
Expand Down
66 changes: 7 additions & 59 deletions BloonsTD6 Mod Helper/LATEST.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,7 @@
## Misc Updates

- Added a button that lets you open the Mods Menu from the In Game Pause Screen
- This includes opening Mod Settings menus, but not many settings yet will probably live update in a game
- Added a button in the Mods Menu that can display the SHA 256 hashes of active mods
- Added a new `ModTower.IncludeInMonkeyTeams` override
- Fixed some inconsistencies where some simulation behavior extensions would throw exceptions instead of just returning null
- ModHelperData now supports multiline raw strings for descriptions, [example](https://github.com/doombubbles/ability-choice/blob/699658591855043372a128294de679670600e3c1/ModHelperData.cs#L10)

## Localization Updates

### General

- Added a new button in the Mods Menu to export a mod's localization to a json file, which can be edited to change its
supported displayed text for your language
- This goes to a newly added subfolder `Mods/BloonsTD6 Mod Helper/Localization/[Language]`
- Edits to files here should refresh the text without requiring a game restart
- Added a new [Translation Tool page on the website](https://gurrenm3.github.io/BTD-Mod-Helper/tools/translate) that can
easily put Localization files through Google translate for individual or all supported languages
- Using this tool, Mod Helper now contains Localizations for all supported BTD6 language. If you see a way that
one/many of the Google Translations could be improved for your language, you can help out by submitting edits to
the [corresponding Language file](https://github.com/gurrenm3/BTD-Mod-Helper/tree/master/BloonsTD6%20Mod%20Helper/Localization) through GitHub
- The text in mods that should be automatically supported for localization editing includes
- Names and Descriptions for Towers, Upgrades, Heroes, Bloons etc
- Names and Descriptions for Mod Settings
- General mod info like the description

### For Modders

- The standard btd6.targets import will now automatically embed `/Localization/[Language].json` files in your mod
project
- Use the Localization Button on your own mod with active language English to get a starter .json for your mod
- If you paste in the .json content on the website and press the "Translate All" button it will create a .zip file
with all the correctly named .json files you'd need for your mod
- ModHelperText and ModHelperDropdown components now Localize their texts by default
- For Localization Entries, putting text within [Square Brackets] will make it try to fetch existing localization for
that key
- e.g. `The description is [DartMonkey Description]` ->
`The description is Throws a single dart at nearby Bloons. Short range and low pierce but cheap.`
- Added new `ModContent.Localize` methods that can add new mod specific localizations from variables
```csharp
private static readonly string DoTheThing = ModContent.Localize<MyMod>(nameof(DoTheThing), "Do The Thing!");
```
Or within any method/constructor that's going to run as the game loads
```csharp
var doTheThing = ModContent.Localize(nameof(DoTheThing), "Do The Thing!");
```
The result assigned to the `DoTheThing` is your mod specific localization key, that you can use in a
`ModHelperText.SetText(DoTheThing)` directly or as `string localizedText = DoTheThing.Localize()` otherwise
- As before, you can still override the `RegisterText` method in any class that extends `NamedModContent` to
directly add extra stuff to the text table
```csharp
public override void RegisterText(Il2CppSystem.Collections.Generic.Dictionary<string, string> textTable)
{
base.RegisterText(textTable); // Call the base to still register DisplayName / Description
textTable[Id + " Long Description"] = LongDescription; // More specific stuff to your ModContent
}
```
- Pause Screen Mods Button now shows number of active mods
- Updated icon for Pause Screen mods button
- Made it less likely for other mods to have errors if they tried to use file/folder picker popups outside standard mod settings
- Apopalypse Mode is now correctly affected by the Round Set changer
- Made the Round Changer button also show up in the Challenge Editor Play screen
- Note: The Round Set Changer would always technically apply to challenges, this is just making it clearer and easier
to change without going back to the normal map play screens
9 changes: 9 additions & 0 deletions BloonsTD6 Mod Helper/MelonMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ public override void OnInitialize()
loadErrors.Add("MelonLoader versions higher than 0.6.1 are not yet considered stable for BloonsTD6. " +
"Please downgrade to MelonLoader 0.6.1 via its installer for best results.");
}

try
{
FileDialogHelper.PrepareNativeDlls();
}
catch (Exception e)
{
ModHelper.Warning(e);
}
}

public override void OnUpdate()
Expand Down
2 changes: 1 addition & 1 deletion BloonsTD6 Mod Helper/ModHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace BTD_Mod_Helper;
public static class ModHelper
{
internal const string Name = "BloonsTD6 Mod Helper";
internal const string Version = "3.2.0";
internal const string Version = "3.2.1";
internal const string RepoOwner = "gurrenm3";
internal const string RepoName = "BTD-Mod-Helper";
internal const string Description =
Expand Down
5 changes: 3 additions & 2 deletions BloonsTD6 Mod Helper/Patches/UI/PauseScreen_Open.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BTD_Mod_Helper.Api;
using System.Linq;
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.UI.Menus;
using BTD_Mod_Helper.UI.Modded;
using Il2CppAssets.Scripts.Unity.UI_New.Pause;
Expand Down Expand Up @@ -68,7 +69,7 @@ private static void Postfix(PauseScreen __instance)
image.SetSprite(sprite);

var modsText = modsBtn.GetComponentInChildren<NK_TextMeshProUGUI>();
modsText.localizeKey = ModsButton.Mods;
modsText.localizeKey = $"[{ModsButton.Mods}] ({ModHelper.Melons.Count()})";
modsText.SetText(ModsButton.Mods.Localize());

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using BTD_Mod_Helper.UI.Modded;
using Il2CppAssets.Scripts.Models;
using Il2CppAssets.Scripts.Simulation.Track.RoundManagers;
using Il2CppAssets.Scripts.Unity.Bridge;

namespace BTD_Mod_Helper.Patches.UI;

[HarmonyPatch(typeof(Il2CppAssets.Scripts.Unity.UI_New.UI), nameof(Il2CppAssets.Scripts.Unity.UI_New.UI.ApplyExtraNotInSimModelSettings))]
internal static class UI_ApplyExtraNotInSimModelSettings
{
[HarmonyPostfix]
internal static void Postfix(UnityToSimulation uts, GameModel model)
{
if (!string.IsNullOrEmpty(RoundSetChanger.RoundSetOverride) && model.isApopalypse)
{
var roundManager = new DefaultRoundManager(model);
uts.InitRoundSet(roundManager);
}
}
}
Binary file modified BloonsTD6 Mod Helper/Resources/IconMinimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions BloonsTD6 Mod Helper/UI/Modded/RoundSetChanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
using BTD_Mod_Helper.Api.Bloons;
using BTD_Mod_Helper.Api.Components;
using BTD_Mod_Helper.Api.Enums;
using Il2CppAssets.Scripts;
using Il2CppAssets.Scripts.Unity.Menu;
using Il2CppAssets.Scripts.Unity.UI_New;
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppAssets.Scripts.Unity.UI_New.Main.Facebook;
using Il2CppAssets.Scripts.Unity.UI_New.Main.MapSelect;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace BTD_Mod_Helper.UI.Modded;

Expand All @@ -25,8 +27,9 @@ public static class RoundSetChanger // TODO make this internal, add alt way to g

private static readonly string[] ShowOnMenus =
{
"DifficultySelectUI", "ModeSelectUI",
"DifficultySelectScreen", "ModeSelectScreen"
SceneNames.DifficultySelectUI,
SceneNames.ModeSelectUI,
SceneNames.ChallengeEditorPlay
};

private static ModHelperPanel buttonPanel;
Expand Down
12 changes: 11 additions & 1 deletion Documentation/BTD_Mod_Helper.BloonsMod.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,14 @@ public virtual void OnSaveSettings(JObject settings);

`settings` [Newtonsoft.Json.Linq.JObject](https://docs.microsoft.com/en-us/dotnet/api/Newtonsoft.Json.Linq.JObject 'Newtonsoft.Json.Linq.JObject')

The json representation of the settings about to be saved
The json representation of the settings about to be saved

<a name='BTD_Mod_Helper.BloonsMod.SaveModSettings()'></a>

## BloonsMod.SaveModSettings() Method

Saves the current mod settings for this mod

```csharp
public void SaveModSettings();
```

0 comments on commit 4b864b2

Please sign in to comment.