feat: read full chord actions every time

feat: add special view for compound chords
fix: make it possible to delete compound chords
fixes #94
This commit is contained in:
2024-02-05 20:39:05 +01:00
parent 046595b51f
commit 08f594d164
2 changed files with 18 additions and 5 deletions

View File

@@ -48,9 +48,7 @@ export function deserializeActions(native: bigint): number[] {
const actions = []
for (let i = 0; i < 12; i++) {
const action = Number(native & 0x3ffn)
if (action !== 0) {
actions.push(action)
}
actions.push(action)
native >>= 10n
}

View File

@@ -66,12 +66,19 @@
})
})
}
$: chordActions = chord?.actions.slice(chord.actions.lastIndexOf(0) + 1).toSorted(compare)
$: compoundIndices = chord?.actions.slice(0, chord.actions.indexOf(0))
$: {
console.log(chord?.actions, chordActions, compoundIndices)
}
</script>
<button
class:deleted={chord && chord.deleted}
class:edited={chord && chord.actionsChanged}
class:invalid={chord && chord.actions.toSorted(compare).some((it, i) => chord?.actions[i] !== it)}
class:invalid={chord && chordActions?.some((it, i) => chordActions?.[i] !== it)}
class="chord"
on:click={edit}
on:keydown={keydown}
@@ -82,7 +89,15 @@
{:else if !editing && !chord}
<span>{$LL.configure.chords.NEW_CHORD()}</span>
{/if}
<ActionString display="keys" actions={editing ? [...pressedKeys].sort(compare) : chord?.actions ?? []} />
{#if !editing}
{#each compoundIndices ?? [] as index}
<sub>{index}</sub>
{/each}
{#if compoundIndices?.length}
<span>&rarr;</span>
{/if}
{/if}
<ActionString display="keys" actions={editing ? [...pressedKeys].sort(compare) : chordActions ?? []} />
<button class="icon add" on:click|stopPropagation={addSpecial}>add_circle</button>
<sup></sup>
</button>