generated from kianzarrin/NodeController
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
kianzarrin edited this page Mar 27, 2021
·
20 revisions
for external mods that want to register UUI buttons please look at the example mod: https://github.com/kianzarrin/UnifiedUI/blob/master/ExampleMod/ExampleMod.cs#L79.
please contact me on discord to ask about your specific use case.
using UnifiedUI.Helpers;
sprites = UserMod.instance.GetFullPath("Resources", "sprites.png"); // returns Path/To/Mod/Resaources/sprites.png
var button = UUIHelpers.RegisterToolButton(
name: "MyModButton",
groupName: null, // default group
tooltip: "some tooltip",
spritefile: sprites,
tool: mytool,
activationKey: ActivationHotKey,
avtiveKeys: new Dectionary<SavedInputKey,bool>() {InModHotKey, null} );
- pressing the ActivationHotkey enables your mod.
- if your tool is active, UUI will prevent other mods from using their
activationKey
if it collides with yourInModHotKey
var customButton = UUIHelpers.RegisterCustomButton(
name: "MyModButton",
groupName: null, // default group
tooltip: "some tooltip",
spritefile: sprites,
onToggle:(value)=> value ? MyWindow.Open() : MyWindow.Close();
onToolChanged: null);
MyWindow.Start() => customButton.IsActive = true;
MyWindow.OnDestroy() => customButton.IsActive = false;
If you do not wish to register button and only wish to register hotkeys.
Dictionary<SavedInputKey, bool> activeKeys = new Dictionary<SavedInputKey, bool>(){
{hotkey1,false}, // must be manually set to true when hotkey is active to prevent other mods from using this.
{hotkey2,false}, // must be manually set to true when hotkey is active to prevent other mods from using this.
}
RegisterHotkeys(
onToggle: ToggleMod,
activationKey = new SavedInputKey(...),
activeKeys = dict) {
if (!IsUUIEnabled()) return;
var Register = CreateDelegate<RegisterHotkeysHandler>(GetUUI(), "Register");
Register(
onToggle: onToggle,
activationKey: activationKey, // pressing the hotkey triggers on toggle (if there is not collision with another mod
activeKeys: activeKeys); // does nothing but prevent other mods from triggering the activation hotkey.
}