added saving
This commit is contained in:
@@ -20,7 +20,7 @@ export function createBeatStore() {
|
|||||||
const activeBeatIndex = ref(0);
|
const activeBeatIndex = ref(0);
|
||||||
const activeBeat = computed<Beat | null>(() => beats.value[activeBeatIndex.value] ?? null);
|
const activeBeat = computed<Beat | null>(() => beats.value[activeBeatIndex.value] ?? null);
|
||||||
const autoSave = ref(true);
|
const autoSave = ref(true);
|
||||||
const orientation = ref<'horizontal' | 'vertical' | null>(null);
|
const orientation = ref<'horizontal' | 'vertical'>('horizontal');
|
||||||
|
|
||||||
function resetActiveBeat(): void {
|
function resetActiveBeat(): void {
|
||||||
const current = activeBeat.value;
|
const current = activeBeat.value;
|
||||||
@@ -51,7 +51,7 @@ export function createBeatStore() {
|
|||||||
localStorage.setItem("drum-slayer-save", JSON.stringify({
|
localStorage.setItem("drum-slayer-save", JSON.stringify({
|
||||||
beats: serials,
|
beats: serials,
|
||||||
activeBeatIndex: activeBeatIndex.value,
|
activeBeatIndex: activeBeatIndex.value,
|
||||||
orientation: orientation.value,
|
orientation: orientation.value ?? 'horizontal',
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export function isValidTimeSigRange(sig: number): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isTrackSerial(serial: any): serial is TrackSerial {
|
function isTrackSerial(serial: any): serial is TrackSerial {
|
||||||
const correctTypes = typeof serial.name === "string" &&
|
const correctTypes = typeof serial.name === "string" &&
|
||||||
typeof serial.timeSigUp === "number" &&
|
typeof serial.timeSigUp === "number" &&
|
||||||
typeof serial.timeSigDown === "number" &&
|
typeof serial.timeSigDown === "number" &&
|
||||||
typeof serial.units === "object" &&
|
typeof serial.units === "object" &&
|
||||||
@@ -84,7 +84,7 @@ export function createTrack(options: TrackInitOptions) {
|
|||||||
const scope = effectScope();
|
const scope = effectScope();
|
||||||
return scope.run(() => {
|
return scope.run(() => {
|
||||||
const name = ref(options.name ?? 'New Track');
|
const name = ref(options.name ?? 'New Track');
|
||||||
const timeSig = reactive({ up: 4, down: 4 });
|
const timeSig = reactive({ up: options.timeSig?.up ?? 4, down: options.timeSig?.down ?? 4 });
|
||||||
const timeSigUp = computed({
|
const timeSigUp = computed({
|
||||||
get() {
|
get() {
|
||||||
return timeSig.up;
|
return timeSig.up;
|
||||||
@@ -105,7 +105,7 @@ export function createTrack(options: TrackInitOptions) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const unitRecord = shallowRef<TrackUnit[]>([]);
|
const unitRecord = shallowRef<TrackUnit[]>(options.units ?? []);
|
||||||
const barCount = ref(options.barCount ?? 4);
|
const barCount = ref(options.barCount ?? 4);
|
||||||
const loopLengthInternal = ref(options?.loopLength ?? timeSigUp.value * barCount.value);
|
const loopLengthInternal = ref(options?.loopLength ?? timeSigUp.value * barCount.value);
|
||||||
const loopLength = computed({
|
const loopLength = computed({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="beat" :class="{ vertical: false }">
|
<div class="beat" :class="{ vertical: false }">
|
||||||
<h2 class="beat-title">{{ beat!.name.value }}</h2>
|
<editable-text-field node-type="h3" class="beat-title" v-model="beat!.name.value" />
|
||||||
<div class="beat-main-container">
|
<div class="beat-main-container">
|
||||||
<div class="beat-titles-container">
|
<div class="beat-titles-container">
|
||||||
<div class="beat-track-title" v-for="title in titles">{{ title }}</div>
|
<div class="beat-track-title" v-for="title in titles">{{ title }}</div>
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
color: var(--color-title-light);
|
color: var(--color-title-light);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
padding-left: 16px;
|
margin-left: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vertical-mode .beat-title {
|
.vertical-mode .beat-title {
|
||||||
|
|||||||
@@ -46,6 +46,12 @@
|
|||||||
@click="resetActiveBeat">
|
@click="resetActiveBeat">
|
||||||
<icon icon-name="trash" color="var(--color-ui-neutral-dark)" />
|
<icon icon-name="trash" color="var(--color-ui-neutral-dark)" />
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
class="root-quick-access-button"
|
||||||
|
title="Reset all"
|
||||||
|
@click="save('localStorage')">
|
||||||
|
Save
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -83,6 +89,7 @@
|
|||||||
provide(BeatStoreKey, beatStore);
|
provide(BeatStoreKey, beatStore);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
save,
|
||||||
resetActiveBeat,
|
resetActiveBeat,
|
||||||
activeBeatIndex,
|
activeBeatIndex,
|
||||||
beats,
|
beats,
|
||||||
|
|||||||
@@ -3,25 +3,29 @@
|
|||||||
v-if="editing"
|
v-if="editing"
|
||||||
:value="modelValue"
|
:value="modelValue"
|
||||||
ref="inputField"
|
ref="inputField"
|
||||||
class="editable-text-field-view"
|
class="input editable-text-field-view"
|
||||||
type="text"
|
type="text"
|
||||||
@input="onInput"
|
@input="onInput"
|
||||||
@blur="onBlur"
|
@blur="onBlur"
|
||||||
@keyup="onKeyUp"
|
@keyup="onKeyUp"
|
||||||
/>
|
/>
|
||||||
<div
|
<component
|
||||||
v-else
|
v-else
|
||||||
class="editable-text-field-view"
|
:is="nodeType"
|
||||||
|
class="static editable-text-field-view"
|
||||||
@click="editing = true">
|
@click="editing = true">
|
||||||
{{ modelValue }}
|
{{ modelValue }}
|
||||||
</div>
|
</component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">import { ref, watch } from 'vue';
|
<script setup lang="ts">import { ref, watch } from 'vue';
|
||||||
const props = defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
|
nodeType?: string,
|
||||||
modelValue: string,
|
modelValue: string,
|
||||||
noEmpty?: boolean,
|
noEmpty?: boolean,
|
||||||
}>();
|
}>(), {
|
||||||
|
nodeType: 'div',
|
||||||
|
});
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'update:modelValue', value: string): true,
|
(e: 'update:modelValue', value: string): true,
|
||||||
@@ -53,19 +57,24 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style scoped lang="scss">
|
||||||
input.editable-text-field-view {
|
.editable-text-field-view {
|
||||||
width: fit-content;
|
min-width: 3em;
|
||||||
max-width: 200px;
|
padding: 0.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.editable-text-field-view {
|
.input.editable-text-field-view {
|
||||||
width: 100%;
|
color: black;
|
||||||
|
width: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.static.editable-text-field-view {
|
||||||
transition: background-color 200ms;
|
transition: background-color 200ms;
|
||||||
|
width: fit-content;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.editable-text-field-view:hover {
|
.static.editable-text-field-view:hover {
|
||||||
background-color: var(--color-ui-neutral-dark-hover);
|
background-color: var(--color-ui-neutral-dark-hover);
|
||||||
}
|
}
|
||||||
</style>"
|
</style>"
|
||||||
|
|||||||
Reference in New Issue
Block a user