Outward
0 of 0

File information

Last updated

Original upload

Created by

Stian

Uploaded by

kongenav

Virus scan

Safe to use

Tags for this mod

About this mod

Helping modders easily add keybindings for their mods

Requirements
Permissions and credits
Changelogs
Donations
Adding native keybindings to your mod is a little involved and requires a technique that you may not have had to use before in Outward mods.

This project contains a class called CustomKeybindings with a single public method for you to call, called AddAction(). When you call this method, everything is set up for you and your action is added to the game like the default keybindings, and you can then listen for your keybindings in an appropriate place.

Huge thanks to stimmedcow who documented his research on adding quick slots. His project set me on the right path to learning how keybindings work in Outward.

Like what you see here? You can support me on Patreon.

Usage

To use the CustomKeybindings class, you must add two new references to your project:

  • MonoMod.RuntimeDetour.dll
  • Rewired_Core.dll

These references have already been added in the example project provided in the download.

You can add as many actions as you want with AddAction(), though you probably want to keep it low.

Some notes about implementation & distribution

I have gone a bit beyond what is absolutely necessary to implement custom keybindings so that you the modder only have a single method to call to add actions. I have copiously commented the CustomKeybindings class so that you can understand what's going on.

I also want to mention that although the example project uses Partiality, the CustomKeybindings class does not use or depend on Partiality, but does use and depend on an auxiliary part of MonoMod called RuntimeDetour, which is the heart of the HookGen functionality that Partiality calls on to create the hooks you may already be familiar with.

In other words, you can use CustomKeybindings without using Partiality and without referencing HOOKS-Assembly-CSharp.dll.

You can read more about MonoMod's RuntimeDetour and HookGen here.

On a different note. I have wondered how this functionality should be distributed. Should I compile the class as a .dll for you to reference in your project? Should I set up the example project to embed the CustomKeybindings.dll in your mod's .dll so that it doesn't overwrite other mod's CustomKeybindings.dll in the Mods folder?

Ultimately I wasn't happy making any of these choices for you, so I give you the raw source. The community may eventually figure out how to deal with issues like these. Until then, just include CustomKeybindings.cs in your build and it'll become part of your mod's .dll.

The example project is based upon Outward Mod Project Template, which you can use if you want a project without custom keybindings.

Known limitations

If you name your action exactly the same as another action from another mod, then, even though both actions will show up separately in the keybindings menu, only one of the keybindings will work, and it will cause both actions to happen.

This can be worked around in the implementation, but doing so complicates the usage of the class for an edge case with little practical value. So: Just do your best to avoid naming conflicts.

Using Partiality Launcher

To install and activate your mod in Outward you must use Partiality Launcher.

  • Download Partiality Launcher
  • Unzip PartialityLauncher.zip & open PartialityLauncher.bat
  • In Partiality Launcher click File, Open Game & find Outward.exe (normally C:\Program Files (x86)\Steam\steamapps\common\Outward)
  • Now you have a new folder called Mods where Outward.exe is
  • (Optional) If the "APPID of the game" is empty, put 794260 (Outward's Steam AppID)
  • Put your mod's .dll file in the Mods folder
  • In Partiality Launcher click Refresh Mod List
  • Tick your .dll file
  • Click Apply Mods
  • Done!

You will not have to reuse Partiality Launcher except when you add more mods to the Mods folder, but if you experience weird issues, you can use Partiality Launcher to "Refresh Mod List", "Clear Mod Metadata" & "Apply Mods".