Skip to content

PalmForest0/BloomEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

107 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BloomEngine

GameBanana Discord GitHub tag

What is BloomEngine?

BloomEngine is a MelonLoader mod for PvZ Replanted, which adds an in-game mod menu and config manager. It is also a modding library that makes creating mods for PvZ Replanted easier by providing a variety of utilities and extensions. To use the BloomEngine mod, first install MelonLoader in your game's directory. Then download BloomEngine.dll from the releases section and place it in the Mods folder.

Developer Usage

1. Referencing BloomEngine

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.

2. Registering your mod

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;

namespace BloomEngine;

internal sealed class BloomEngineMod : MelonMod
{
    public const string Name = "BloomEngine";
    public const string Version = "0.3.2-beta";
    public const string Author = "PalmForest";

    public override void OnInitializeMelon()
    {
        ModMenuService.CreateEntry(this)
            .AddDisplayName(Name)
            .AddDescription($"Mod menu and config manager library for PvZ Replanted.")
            .AddIcon(AssetHelper.LoadSprite("BloomEngine.Resources.BloomEngineIcon.png"))
            .Register();
    }
}

3. Creating config inputs

To create config inputs for your mod, you can use the methods provided by ConfigService. BloomEngine currently supports 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 actions and function, for example:

public static StringConfigInput TestStringInput = ConfigService.CreateString("Test String", "Cooler description.", "ABCDEFG")
    .WithOnValueChanged(val => Melon<BloomEngine>.Logger.Msg($"Value of {nameof(TestStringInput)} updated to \"{val}\""))
    .WithOnInputChanged(() => TestStringInput.Textbox.SetTextWithoutNotify(TestStringInput.Textbox.text.ToUpperInvariant()))
    .WithTransformFunc(val => val.ToUpperInvariant())
    .WithValidateFunc(val => !string.IsNullOrWhiteSpace(val));

Note

Using MelonLogger.Msg() within one of the above actions will show [BloomEngine] as the source in the MelonLoader console. Instead, it is recommended you use Melon<YourMainModClass>.Logger.Msg() or create a custom logger using new MelonLogger.Instance().

4. Registering the config

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(Name)
    .AddDescription($"Mod menu and config manager library for PvZ Replanted.")
    .AddIcon(AssetHelper.LoadSprite("BloomEngine.Resources.BloomEngineIcon.png"))
    .AddConfigInputs(TestStringInput, TestBoolInput)
    .Register();

Screenshots

ModMenu ConfigPanel

About

In-game mod menu and config manager, as well as a modding utility library for PvZ Replanted.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages