Outward
0 of 0

File information

Last updated

Original upload

Created by

Sinai

Uploaded by

sinaidev

Virus scan

Safe to use

Tags for this mod

About this mod

Allows multiple mods to share a universal config menu, accessed with a single keybind.

Requirements
Permissions and credits
Shared Mod Config Menu
by Sinai | My Mods | My GitHub


NOTE: This mod is obsolete, I am no longer maintaining it. Authors of mods which use this are recommended to use BepInEx config instead.





This is a tool to allow multiple mods to share a common mod menu, accessed with one keybind. This is to solve the current problem where many different mods have their own keybinding for their menu.

This mod will add a new option to your in-game keybindings under the 'Menu' section called "Shared Mod Config Menu".
Make sure you set a keybinding for this to access the menu. You need to load a character in order to access the menu.

NOTE:
You must press "Save and Apply" for your settings to take effect. (as of v1.3 update)

How To Install
This is a BepInEx mod.

  1. If you haven't already, download and install BepInEx: instructions here
  2. Install the SideLoader first.
  3. Download the SharedModConfig.zip file from the Files page
  4. Put this zip file in your Outward directory, so it looks like "Outward\SharedModConfig.zip"
  5. Right-click the file and Extract Here, so it merges with the folders.
  6. Done!

How To Use (for Modders)


IMPORTANT NOTE: If you want to use your settings immediately on load, add a callback to your ModConfig.OnSettingsLoaded (example below).

Setting Up

  1. The first step is to add a reference to SharedModConfig.dll to your mod. You should install SharedModConfig and add the reference from your Outward/Mods/ folder.
  2. With the reference added, put "using SharedModConfig;" inside any classes which you want to use settings with.

Defining your Config

The example below shows the entire process for defining a config, and registering it to the ConfigManager. You can copy+paste this if you want.

I will go over exactly how the ModConfig and BBSetting classes work below, so don't stress about what they are yet.

NOTE: You need to add a BepInDependency for "com.sinai.SharedModConfig", to ensure that SharedModConfig is loaded before your mod.

/* --------------------------------------------------- */
using System.Collections;
using UnityEngine;
using SharedModConfig;
using BepInEx;

[BepInPlugin("myguid", "My Mod", "1.0")]
[BepInDependency("com.sinai.SharedModConfig", BepInDependency.DependencyFlags.HardDependency)]
public class MyMod : BaseUnityPlugin
{
public ModConfig myConfig;

internal void Awake()
{
// You don't have to use a function like this, I'm just doing it like this to make the code more readable.
myConfig = SetupConfig();

// If you want to do things immediately on settings load, use a Callback like this:
myConfig.OnSettingsLoaded += LoadCallback;

// Call this to finalize the settings, which will either load the saved settings from disk or create a new XML save if none exists.
myConfig.Register();

// Add a listener here if you want to do something whenever the user clicks "Save and Apply"
myConfig.OnSettingsSaved += SaveCallback;
}

private void OnSettingsLoaded()
{
Debug.Log("Settings loaded!");
}

private void OnSettingsSaved()
{
Debug.Log("Settings saved!");
}

private ModConfig SetupConfig()
{
var config = new ModConfig
{
ModName = "MyModName",
SettingsVersion = 1.0,
Settings = new List<BBSetting>()
{
new BoolSetting
{
Name = "MyBoolSetting",
SectionTitle = "MySectionTitle (optional)",
Description = "If you define a Description, it shows it instead of the Name",
DefaultValue = true
},
new FloatSetting
{
Name = "MyFloatSetting",
Description = "Leave Description blank to show Name instead",
DefaultValue = 40f,
MaxValue = 250f,
MinValue = 0f,
RoundTo = 0,
ShowPercent = false
},
new StringSetting
{
Name = "MyStringSetting",
Description = "",
DefaultValue = "DefaultString",
},
// can keep adding as many settings as you want here...
}
};
return config;
}
}
/* --------------------------------------------------- */


Classes Explanation
There are 5 custom classes used by the SharedModConfig which you'll need to be familiar with.

ModConfig:

This is the class used for the Config itself. It contains information about the config, and all the settings.

- ModConfig.ModName: Name of your Mod (string). This must be a unique identifier, don't just put "MyOutwardMod" or something generic.
- ModConfig.Settings: A list of all your settings (List<BBSetting>).
- ModConfig.OnSettingsLoaded: A callback you can subscribe to. See example above.
- ModConfig.OnSettingsSaved: A callback for when the user saves. See example above.
- ModConfig.SettingsVersion: Currently not really used for anything, but if you want to use it for something you can.

BBSetting:
You don't need to ever use this class directly, it's an abstract class used by BoolSetting, FloatSetting and StringSetting. Just remember that these three classes all inherit from BBSetting.

- BBSetting.Name: name of the setting. You cannot have two identical settings names in your config.
- BBSetting.Description: if used, it will display this instead of the name in the menu.
- BBSetting.DefaultValue: the default value of your setting, when the user does not have any settings or any valid settings.
- BBSetting.SectionTitle: OPTIONAL. Displays this title above the setting in the menu. Use this on the first setting of the section.

BoolSetting : BBSetting:
Used for simple true/false settings values.
 
There are no special fields in BoolSetting, it only has the base BBSetting fields. However, it will expect you to use a bool object.

FloatSetting : BBSetting:
Used for float settings, will display a slider in the menu. As well as the BBSetting fields, a FloatSetting has:

- FloatSetting.MinValue: minimum accepted value
- FloatSetting.MaxValue: maximum accepted value
- FloatSetting.RoundTo: if 0 or greater, will round the value to this many decimal places. Use -1 for no rounding.
- FloatSetting.ShowPercent: will display a "%" symbol in the menu, if true. Has no other effects.
- FloatSetting.Increment: will "snap" the value to a multiple of your increment. Eg, if your increment is 5, the slider values will snap to multiples of 5. You can use any increment you want.

StringSetting : BBSetting:
Used for simple string values, it will display an input-field text box in the menu.
 
There are no special fields in StringSetting, it only has the base BBSetting fields. However, it will expect you to use a string object.

Using Your Config
Accessing your config from this point is easy. You don't need to manage the settings or call for updates, this mod will take care of all of that for you, as well as saving them when the game closes.

GetValue
The only thing you need to keep in mind here is that the GetValue() will only return object, so you need to cast from object to your expected type.

/* --------------------------------------------------- */

// Using a BoolSetting:

Debug.Log("MyBoolSetting value is " + (bool)myConfig.GetValue("MyBoolSetting"));

// Using a FloatSetting:

Debug.Log("MyFloatSetting value: " + (float)myConfig.GetValue("MyFloatSetting"));

// Using a StringSetting:

Debug.Log("MyStringSetting value: " + (string)myConfig.GetValue("MyStringSetting"));

/* --------------------------------------------------- */

SetValue
While you don't need to use this one, I've left it as an option in case you want to manually change settings for some reason.

/* --------------------------------------------------- */
using System.Linq;

myConfig.SetValue("MySetting", myValue);

/* --------------------------------------------------- */


Final Notes
If you have any more questions, contact me in the Outward Discord, I'm Sinai#4637.

----------------------------------------------------

Credits
- Stia
n for CustomKeybindings


Updates
1.3:
- added "Save and Apply" button
- backend changes. added callbacks, cleaned up Register()

1.2:
- added a button for the Main Menu scene to access settings
- no longer need to wait for this mod to initialize before registering settings, it will start the coroutine for you.
- settings are no longer deleted and overwritten when settings version changes, instead tried to retrieve old settings first.

1.1:
- fixed scaling issues on non-16:9 resolutions, should now scale better for ultra-wide monitors
- mod list is now sorted alphabetically
- added SectionTitle option to BBSetting, to display a title above that setting in the menu

1.05:
- fixed a small bug with float settings which use a "%" symbol. the "%" would be cut off sometimes.

1.0:
- initial release