update
This commit is contained in:
@@ -9,7 +9,7 @@ export const DrumSlayerSaveSchema = z.object({
|
||||
});
|
||||
export type DrumSlayerSave = z.infer<typeof DrumSlayerSaveSchema>;
|
||||
|
||||
function defaultMainBeatGroup(manager: BeatManager): Beat {
|
||||
function createDefaultMainBeatGroup(manager: BeatManager): Beat {
|
||||
const defaultSettings = {
|
||||
manager,
|
||||
barCount: 2,
|
||||
@@ -33,14 +33,14 @@ export function createBeatStore() {
|
||||
},
|
||||
};
|
||||
|
||||
const beats = shallowRef<Beat[]>([ defaultMainBeatGroup(manager) ]);
|
||||
const beats = shallowRef<Beat[]>([ createDefaultMainBeatGroup(manager) ]);
|
||||
const activeBeatIndex = ref(0);
|
||||
const activeBeat = computed<Beat | null>(() => beats.value[activeBeatIndex.value] ?? null);
|
||||
const orientation = ref<"horizontal" | "vertical">("horizontal");
|
||||
|
||||
function resetActiveBeat(): void {
|
||||
const current = activeBeat.value;
|
||||
beats.value[activeBeatIndex.value] = defaultMainBeatGroup(manager);
|
||||
beats.value[activeBeatIndex.value] = createDefaultMainBeatGroup(manager);
|
||||
current?.destroy();
|
||||
triggerRef(beats);
|
||||
}
|
||||
@@ -52,10 +52,11 @@ export function createBeatStore() {
|
||||
triggerRef(beats);
|
||||
}
|
||||
|
||||
function addNewBeat(): void {
|
||||
const newBeat = defaultMainBeatGroup(manager);
|
||||
beats.value.push(newBeat);
|
||||
function addNewBeat(): number {
|
||||
const newBeat = createDefaultMainBeatGroup(manager);
|
||||
const newIndex = beats.value.push(newBeat);
|
||||
triggerRef(beats);
|
||||
return newIndex - 1;
|
||||
}
|
||||
|
||||
function save(destination: "localStorage"): void {
|
||||
@@ -111,7 +112,7 @@ export function createBeatStore() {
|
||||
const savedItem = localStorage.getItem("drum-slayer-save");
|
||||
if (savedItem) {
|
||||
const serial = JSON.parse(savedItem);
|
||||
beats.value = [defaultMainBeatGroup(manager)];
|
||||
beats.value = [createDefaultMainBeatGroup(manager)];
|
||||
loadFromSave(serial);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user