-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
After setting up an SMAPI mod there are a few quick steps to adding your mod to the Mod Config tab.
First, we need to allow your project to reference the Framework. There are 2 methods:
NOTE: These images are of the Mac client, although Windows has a similar process.
The NuGet package makes it quick and easy to add the framework in Visual Studio.
1. Open the project Solution in Visual Studio
2. Right click the References
option in the Solution Explorer, usually on the left side, and select Edit References
.
3. Select the .Net Assembly
tab and browse for the downloaded StardewConfigFramework.dll
. Download here. Ensure the assembly file is selected with a check by the name.
4. That's it! Hit OK, and you now have a reference to the Framework.
For the Framework to be accessed it must be loaded before your mod, to ensure this, we will add StardewConfigFramework as a dependency. Add the following lines to your manifest.json
file.
"Dependencies": [
{ "UniqueID": "Juice805.StardewConfigMenu" }
]
For Example, your manifest may look like this:
{
"Name": "Framework Example",
"Authour": "Juice805",
"Version": "1.0.0",
"Description": "A short description of your app.",
"UniqueID": "You.ModID",
"EntryDll": "Example.dll",
"Dependencies": [
{ "UniqueID": "Juice805.StardewConfigMenu" }
]
}
For more update to date Manifest examples and properties check the wiki
Congratulations! You have setup your project and are ready to do some actual work. To begin we will modify your ModEntry
class by adding a few lines.
There are multiple methods for packaging up your mod's options at this stage: For a mod with multiple option tabs and max configurability use a TabbedOptionsPackage
, for simpler mods with a single tab it is recommended to use a SimpleOptionsPackage
which contains convienence methods for a single tab. For the basic example we will use a SimpleOptionsPackage
. For more information about the differences between the two packages check the Options Package page.
using System;
using Microsoft.Xna.Framework;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using StardewValley;
using StardewConfigFramework; // Add the framework
namespace YourMod
{
public class ModEntry: Mod
{
internal SimpleOptionsPackage Package;
/*********
** Public methods
*********/
/// <summary>The mod entry point, called after the mod is first loaded.</summary>
/// <param name="helper">Provides simplified APIs for writing mods.</param>
public override void Entry(IModHelper helper)
{
var Menu = helper.ModRegistry.GetApi<IConfigMenu>("Juice805.StardewConfigMenu"); // Access the menu api through SMAPI
Package = new SimpleOptionsPackage(this); // Create an Options Package
Menu.AddOptionsPackage(Package); // Add it to the menu
// Your Code goes here
}
}
}
That's it! Your mod has a options menu! Check out other pages on the Wiki for detailed instructions on how to use the ModOptions object and each option individually