RoundsWithFriendSettingsUI
Utilities for adding a settings menu to the RWF lobby UI.
About this mod Author’s original text
Rounds With Friends Settings UI
Provides functionality for adding mod menus to the RWF lobby.
- Change Log
- Usage
- Hard Dependency
- Soft Dependency
- Documentation
- FAQ
Change Log
v 0.0.1
- Public Release
Usage
While having the ability to change settings within a lobby is nice, a mod may not necessarily want to depend on having Rounds With Friends installed, let alone require having this mod installed as well. With this in mind, here's the two ways to depend on the mod.
For either method used, you need to add this mod as a reference/dependency inside of Visual Studio.
Hard Dependency
A hard dependency requires that you add [BepInDependency("com.willuwontu.rounds.rwfsettingsui")] to the BaseUnityPlugin of your mod.
Additionally, you need to add this mod to your manifest.
This will allow you to make use of RWFSettingsUI.RegisterMenu() within your mod without any worries of crashes due to having code not loaded in.
Examples
An example of how to call this function can be seen in Will's Wacky Game Modes.
SettingsUI.RWFSettingsUI.RegisterMenu(ModName, NewGUI);
This registers a menu with the following parameters:
- The menu's name is "Will's Wacky GameModes" (ModName)
- It sets the action used to create the contents of the menu as the NewGUI method.
Soft Dependency
A soft dependency makes use of how BaseUnityPlugin's work to load in another mod from the same assembly.
To do so, it requires that you create a class that inherits from the CompatibilityHandler class, and add the [BepInPlugin] and [BepInDependency] attributes to it. Note, the class already has a [BepInDependency("com.willuwontu.rounds.rwfsettingsui")] attribute, so you only need to add a [BepInDependency] for your mod.
Example
Examples of how to use the class can be seen in the CompatibilityHandlers folder. In this case, the Pick N' Cards compatibility handler looks like this:
[BepInDependency("pykess.rounds.plugins.pickncards")]
[BepInPlugin(ModId, ModName, Version)]
internal class PickNCompat: CompatibilityHandler
{
private const string ModId = "com.willuwontu.rounds.rwfsettingsui.compatibility.pickn";
private const string ModName = "Rounds With Friends Settings UI - Pick N Compatibility Handler";
public const string Version = "0.0.0"; // What version are we on (major.minor.patch)?
public override string MenuName => "Pick N Cards";
public override void GUI(GameObject menu)
{
var instance = this.gameObject.GetComponent();
var newgui = typeof(PickNCards.PickNCards).GetMethod("NewGUI", BindingFlags.Default | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod);
newgui.Invoke(instance, new object { menu });
}
}
The [BepInPlugin] and [BepInDependency] attributes declare the class as a plugin that should be loaded in, and let it know that it needs to wait for pick n cards to be loaded in first. Note, the ModId needs to be unique to the compatibility handler.
We then declare the name for the menu by overriding the MenuName property of the class.
Finally, we declare the GUI method for the class. In this case, since we're attempting to use a private method outside of our assembly, we need to use System.Reflection in order to access it. Normally though, since you'd be creating this class in the same assembly as your mod, you'd be able to simply run the action you normally use to set-up your menu.
However, this does allow you to create different menu's for players while they're in a lobby, or make use of the EnterMenuAction method to adjust how the menu looks based on if they're the master client or not.
Documentation
RWFSettingsUI
public Class RWFSettingsUI: BaseUnityPlugin
Description
The base class for this mod, used to register the menus via Hard Dependency.
Methods
RegisterMenu
public static void RegisterMenu(string name, Action guiAction, bool hostOnly = true, UnityAction enterMenuAction = null, UnityAction returnToLobbyAction = null)
Description
Registers a menu to add to the list of lobby menus.
Pa
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: