* Replace BxEvent.TITLE_INFO_READY with Event Bus

* Migrate more events

* Migrate stream events to event bus

* Migrate preset events

* Migrate more

* Fix dispatching "input" event twice in Number Stepper
This commit is contained in:
redphx
2024-12-08 17:55:44 +07:00
committed by GitHub
parent 160044c958
commit 79ebb1a817
22 changed files with 282 additions and 191 deletions

View File

@@ -10,10 +10,10 @@ import { hasGamepad } from "./gamepad";
import { MkbMappingPresetsTable } from "./local-db/mkb-mapping-presets-table";
import type { GamepadKey } from "@/enums/gamepad";
import { MkbPresetKey, MouseConstant } from "@/enums/mkb";
import { BxEvent } from "./bx-event";
import { KeyboardShortcutDefaultId, KeyboardShortcutsTable } from "./local-db/keyboard-shortcuts-table";
import { ShortcutAction } from "@/enums/shortcut-actions";
import { KeyHelper } from "@/modules/mkb/key-helper";
import { EventBus } from "./event-bus";
export type StreamSettingsData = {
@@ -110,7 +110,7 @@ export class StreamSettings {
}
StreamSettings.settings.deviceVibrationIntensity = intensity;
BxEvent.dispatch(window, BxEvent.DEVICE_VIBRATION_CHANGED);
EventBus.Script.emit('deviceVibrationUpdated', {});
}
static async refreshMkbSettings() {
@@ -148,7 +148,7 @@ export class StreamSettings {
settings.mkbPreset = converted;
setPref(PrefKey.MKB_P1_MAPPING_PRESET_ID, orgPreset.id);
BxEvent.dispatch(window, BxEvent.MKB_UPDATED);
EventBus.Script.emit('mkbSettingUpdated', {});
}
static async refreshKeyboardShortcuts() {
@@ -159,7 +159,7 @@ export class StreamSettings {
settings.keyboardShortcuts = null;
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId);
BxEvent.dispatch(window, BxEvent.KEYBOARD_SHORTCUTS_UPDATED);
EventBus.Script.emit('keyboardShortcutsUpdated', {});
return;
}
@@ -179,7 +179,7 @@ export class StreamSettings {
settings.keyboardShortcuts = converted;
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, orgPreset.id);
BxEvent.dispatch(window, BxEvent.KEYBOARD_SHORTCUTS_UPDATED);
EventBus.Script.emit('keyboardShortcutsUpdated', {});
}
static async refreshAllSettings() {