Move BLANK_PRESET_DATA to Table class

This commit is contained in:
redphx
2024-12-24 06:43:08 +07:00
parent c1786d3fba
commit 907e595b1e
12 changed files with 103 additions and 78 deletions

View File

@@ -6,6 +6,7 @@ export abstract class BasePresetsTable<T extends PresetRecord> extends BaseLocal
protected abstract TABLE_PRESETS: string;
protected abstract DEFAULT_PRESETS: PresetRecords<T>;
protected abstract readonly DEFAULT_PRESET_ID: number;
abstract readonly BLANK_PRESET_DATA: T['data'];
async newPreset(name: string, data: T['data']) {
const newRecord = { name, data } as T;

View File

@@ -1,4 +1,4 @@
import type { ControllerCustomizationPresetRecord, PresetRecords } from "@/types/presets";
import type { ControllerCustomizationPresetData, ControllerCustomizationPresetRecord, PresetRecords } from "@/types/presets";
import { LocalDb } from "./local-db";
import { BasePresetsTable } from "./base-presets-table";
import { GamepadKey } from "@/enums/gamepad";
@@ -40,6 +40,17 @@ export class ControllerCustomizationsTable extends BasePresetsTable<ControllerCu
},
};
protected DEFAULT_PRESET_ID = ControllerCustomizationDefaultPresetId.DEFAULT;
readonly BLANK_PRESET_DATA = {
mapping: {},
settings: {
leftTriggerRange: [0, 100],
rightTriggerRange: [0, 100],
leftStickDeadzone: [0, 100],
rightStickDeadzone: [0, 100],
vibrationIntensity: 100,
},
} satisfies ControllerCustomizationPresetData;
protected DEFAULT_PRESET_ID = ControllerCustomizationDefaultPresetId.DEFAULT;
}

View File

@@ -52,6 +52,10 @@ export class ControllerShortcutsTable extends BasePresetsTable<ControllerShortcu
},
};
readonly BLANK_PRESET_DATA = {
mapping: {},
};
protected readonly DEFAULT_PRESET_ID = ControllerShortcutDefaultId.DEFAULT;
private constructor() {

View File

@@ -36,6 +36,10 @@ export class KeyboardShortcutsTable extends BasePresetsTable<KeyboardShortcutPre
},
};
readonly BLANK_PRESET_DATA = {
mapping: {},
};
protected readonly DEFAULT_PRESET_ID = KeyboardShortcutDefaultId.DEFAULT;
private constructor() {

View File

@@ -117,6 +117,17 @@ export class MkbMappingPresetsTable extends BasePresetsTable<MkbPresetRecord> {
},
},
};
readonly BLANK_PRESET_DATA = {
mapping: {},
mouse: {
[MkbPresetKey.MOUSE_MAP_TO]: MouseMapTo.RS,
[MkbPresetKey.MOUSE_SENSITIVITY_X]: 100,
[MkbPresetKey.MOUSE_SENSITIVITY_Y]: 100,
[MkbPresetKey.MOUSE_DEADZONE_COUNTERWEIGHT]: 20,
},
};
protected readonly DEFAULT_PRESET_ID = MkbMappingDefaultPresetId.DEFAULT;
private constructor() {