BloomEngine is a MelonLoader mod for PvZ Replanted, which adds an in-game mod list and config manager through MelonPreferences. It functions as a library that makes it easier for developers to add config options and provides various useful modding extensions.
To add the mod to your game, install MelonLoader, download BloomEngine.dll from
the releases section and place it in your Mods folder.
Download both BloomEngine.dll and BloomEngine.xml from the latest release version, found in the releases section.
Place both files somewhere in your mod project and add a reference to BloomEngine.dll. As long as the xml file is in the same folder, it will load automatically.
Note
While downloading BloomEngine.xml is technically optional, it is required for library documentation to be visible in your IDE.
After referencing BloomEngine, you can now add you mod to the in-game mod menu like this:
using BloomEngine.ModMenu;
using BloomEngine.Helpers;
using MelonLoader;
internal sealed class YourCoreModClass : MelonMod
{
public override void OnInitializeMelon()
{
ModMenuService.CreateEntry(this)
.AddDisplayName("YourCoolMod")
.AddDescription("Your cool mod description.")
.AddIcon(AssetHelper.LoadSprite("YourModNamespace.YourResourcesFolder.YourModIcon.png"))
.Register();
}
}To create config inputs for your mod, you can use the methods provided by ConfigService. BloomEngine provides built-in support for the following types: string, int, float, bool and enum.
Here is an example definition of a simple config input that sets a display name, description and default value.
public static BoolConfigInput TestBoolInput = ConfigService.CreateBool("Test Bool", "Cool description.", true);Additionally, you can extend your config inputs with additional functionality through the provided methods, for example:
public static StringConfigInput TestStringInput = ConfigService.CreateString("Test String", "Cooler description.", "ABCDEFG")
.WithOnValueChanged(val => Melon<YourCoreModClass>.Logger.Msg($"Value of {nameof(TestStringInput)} updated to \"{val}\""))
.WithOnInputChanged(() => TestStringInput.Textbox.SetTextWithoutNotify(TestStringInput.Textbox.text.ToUpperInvariant()))
.WithTransform(val => val.ToUpperInvariant())
.WithValidate(val => !string.IsNullOrWhiteSpace(val));Finally, to add the config inputs you just created to your mod's config, you must pass them to AddConfigInputs(StringInput, BoolInput) when registering your mod:
ModMenuService.CreateEntry(this)
.AddDisplayName("YourCoolMod")
.AddDescription("Your cool mod description.")
.AddIcon(AssetHelper.LoadSprite("YourModAssembly.YourResourcesFolder.YourModIcon.png"))
.AddConfigInputs(TestStringInput, TestBoolInput)
.Register();
