Sunday, April 16, 2023

Campaign Manager: Mod Support

The big update this time is Mod support!

At startup, Campaign Manager with look in a \Mods folder for dll files it can consume to extend its functionality.

Mods can currently:
- Add buttons to the main menu bar.
- Play / stop music.
- Change the background canvas color.
- Get a collection of the campaign encounters.

Mods are written in C# .NET 4.8. Documentation is included with Campaign Manager for how to setup Visual Studio to create a mod, and a sample mod is included with the Campaign Manager installer.

Example code snippets:

            // Add a button to the Tools menu.
            _sampleButtonPressedEvent = new EventHandler(SampleButtonPressed);
            _campaignManagerHost.AddButton("Sample Mod",
                                           "Tools",
                                           Properties.Resources.sampleModIcon,
                                           "Tooltip to demonstrate opening a form for the sample mod.",
                                           _sampleButtonPressedEvent);

            this._campaignManagerHost.PlayMusic("Battle Theme");

            _campaignManagerHost.ActiveCampaign().ActiveCanvas().BackgroundColor = Color.Blue;

                String newOutput = "";
                foreach (IEncounter loopEncounter in this._campaignManagerHost.ActiveCampaign().ActiveCanvas().Encounters)
                {
                    newOutput += loopEncounter.Name + Environment.NewLine;
                }
                textBoxOutput.Text = newOutput;

The API functionality will extend over time, but this is the first step for any developer to extend the Campaign Manager user interface and capabilities.

You can download Campaign Manager from:

https://kamoly.itch.io/campaign-manager