FujiAPI / Fuji

Celeste 64 Mod Loader
30 stars 10 forks source link

Setting Up Mod Controls API #93

Closed jasminegamedev closed 2 months ago

jasminegamedev commented 2 months ago

This PR adds a new way for mods to create their own virtual buttons and sticks, and add their own default bindings for them. It also reworks how default bindings work in general for more flexibility, and better mod support.

Now, to add virtual buttons, modders just have to add something like this to their mod settings file:

[DefaultBinding(Keys.LeftControl)]
[DefaultBinding(Axes.LeftTrigger, 0.4f, false)]
[SettingName("Crouch")]
public VirtualButton CrouchButton { get; set; } = new VirtualButton("Crouch");

[DefaultStickBinding(StickDirection.Up, Keys.W)]
[DefaultStickBinding(StickDirection.Up, Axes.RightY, 0.0f, true)]
[DefaultStickBinding(StickDirection.Down, Keys.S)]
[DefaultStickBinding(StickDirection.Down, Axes.RightY, 0.0f, false)]
[DefaultStickBinding(StickDirection.Left, Keys.S)]
[DefaultStickBinding(StickDirection.Left, Axes.RightX, 0.0f, true)]
[DefaultStickBinding(StickDirection.Right, Keys.D)]
[DefaultStickBinding(StickDirection.Right, Axes.RightX, 0.0f, false)]
[SettingName("Dash")]
public VirtualStick Dash { get; set; } = new VirtualStick("Dash", VirtualAxis.Overlaps.TakeNewer, 0.35f);

They can add as many default bindings as they want, and support either keyboard or controller.

This PR also makes a new Mod Controller binding menu, which is very similar to the normal controls binding menu. This menu can be found as part of the Mod Settings page for the mod, and players can set separately for keyboard and controller.