RoundsWithFriendSettingsUI
Utilities for adding a settings menu to the RWF lobby UI.
模組介紹 作者原文
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
安裝與使用 安裝:BepInEx 外掛
- 本站下載的壓縮包就是模組本體,通常是 BepInEx 外掛(解壓後得到 .dll 或外掛資料夾)。
- 建議流程:用社群模組管理器(如 r2modman)選中本遊戲後匯入該模組,管理器會自動裝好 BepInEx 前置並處理依賴。
- 手動流程:先在遊戲目錄裝好 BepInEx 載入器,再把解壓出的 .dll 或外掛資料夾放進 BepInEx/plugins/。
- 啟動遊戲,BepInEx 控制台會列印載入日誌;確認這個模組出現在日誌裡即為安裝成功。
帶「前置依賴」的模組需要一併安裝,否則不會載入。功能開關通常在遊戲內或外掛自帶的設定檔裡調整。
下面這些內容需要先安裝,否則該模組不會生效: