Release Healer Man 0.1.29
This commit is contained in:
1 parent
8c9809d3e0
commit
544c1bee91
120 files changed
+4363
-1036
No files matched your search
@@ -0,0 +1,27 @@
|
||||
import { type InputBindings, type InputDevice, INPUT_ACTIONS, replaceInputBinding } from "../input/keybinds";
|
||||
import { type UiPreferences } from "./uiLayout";
|
||||
|
||||
/** PC bar keys live with their UI layout so loading a template also loads its keys. */
|
||||
export function profileInputBindings(preferences: UiPreferences, device: InputDevice): InputBindings {
|
||||
if (device === "controller") return { ...preferences.keybinds.controller };
|
||||
const result = { ...preferences.keybinds.pc };
|
||||
preferences.current.pc.bars.forEach((bar, b) => bar.slots.forEach((slot, s) => { result[`bar:${b}:${s}`] = slot.key; }));
|
||||
return result;
|
||||
}
|
||||
export function withProfileInputBindings(preferences: UiPreferences, device: InputDevice, bindings: InputBindings): UiPreferences {
|
||||
const layout = preferences.current.pc;
|
||||
return {
|
||||
...preferences,
|
||||
keybinds: { ...preferences.keybinds, [device]: { ...bindings } },
|
||||
current: device !== "pc" ? preferences.current : { ...preferences.current, pc: {
|
||||
...layout, bars: layout.bars.map((bar, b) => ({ ...bar, slots: bar.slots.map((slot, s) => ({ ...slot, key: bindings[`bar:${b}:${s}`] ?? null })) })),
|
||||
} },
|
||||
};
|
||||
}
|
||||
export function restoreMovementBindings(preferences: UiPreferences, device: InputDevice): UiPreferences {
|
||||
let bindings = profileInputBindings(preferences, device);
|
||||
for (const entry of INPUT_ACTIONS.filter((entry) => entry.id.startsWith("move-") || entry.id === "jump")) {
|
||||
bindings = replaceInputBinding(bindings, device, entry.id, entry[device]);
|
||||
}
|
||||
return withProfileInputBindings(preferences, device, bindings);
|
||||
}
|
||||
Reference in new issue
Block a user