90 lines
3.3 KiB
Vue
90 lines
3.3 KiB
Vue
|
|
<script setup lang="ts">
|
||
|
|
// Preferences: how circuits look and sound. They belong to the project.
|
||
|
|
import type { CrossingStyle } from '~/lib/logic/types'
|
||
|
|
|
||
|
|
const ed = useEditor()
|
||
|
|
const close = () => (ed.dialog.value = null)
|
||
|
|
const settings = computed(() => ed.project.value.settings)
|
||
|
|
|
||
|
|
const CROSSINGS: { value: CrossingStyle; label: string }[] = [
|
||
|
|
{ value: 'bow', label: 'Bow' },
|
||
|
|
{ value: 'triangle', label: 'Triangle' },
|
||
|
|
{ value: 'bridge', label: 'Bridge' },
|
||
|
|
{ value: 'gap', label: 'Gap' },
|
||
|
|
{ value: 'plain', label: 'Plain' },
|
||
|
|
]
|
||
|
|
|
||
|
|
function set<K extends keyof typeof settings.value>(key: K, value: (typeof settings.value)[K]) {
|
||
|
|
settings.value[key] = value
|
||
|
|
ed.persist()
|
||
|
|
}
|
||
|
|
</script>
|
||
|
|
|
||
|
|
<template>
|
||
|
|
<div class="modal-backdrop" @click.self="close">
|
||
|
|
<div class="modal" role="dialog" aria-labelledby="settings-title">
|
||
|
|
<div class="flex items-start justify-between gap-4">
|
||
|
|
<h2 id="settings-title">Settings</h2>
|
||
|
|
<button class="tb-btn" title="Close" @click="close"><Icon name="lucide:x" class="size-4" /></button>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h3>Display</h3>
|
||
|
|
<div class="field">
|
||
|
|
<span>Gate symbols</span>
|
||
|
|
<div class="seg">
|
||
|
|
<button :class="{ active: settings.symbols === 'iec' }" @click="set('symbols', 'iec')">IEC 60617 (DIN)</button>
|
||
|
|
<button :class="{ active: settings.symbols === 'ansi' }" @click="set('symbols', 'ansi')">ANSI (US)</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="field">
|
||
|
|
<span>Where unconnected wires cross</span>
|
||
|
|
<div class="crossings">
|
||
|
|
<button
|
||
|
|
v-for="c in CROSSINGS"
|
||
|
|
:key="c.value"
|
||
|
|
class="crossing"
|
||
|
|
:class="{ active: (settings.crossing ?? 'bow') === c.value }"
|
||
|
|
:title="c.label"
|
||
|
|
@click="set('crossing', c.value)"
|
||
|
|
>
|
||
|
|
<EditorCrossingIcon :style="c.value" />
|
||
|
|
<span>{{ c.label }}</span>
|
||
|
|
</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<label class="check">
|
||
|
|
<input type="checkbox" :checked="settings.flow" @change="set('flow', !settings.flow)" />
|
||
|
|
Animate current flow on wires that carry a 1
|
||
|
|
</label>
|
||
|
|
<label class="check">
|
||
|
|
<input type="checkbox" :checked="!!settings.tidy" @change="ed.setTidy(!settings.tidy)" />
|
||
|
|
Tidy wiring: sorted parallel runs, one trunk per signal, fewer crossings
|
||
|
|
</label>
|
||
|
|
|
||
|
|
<h3>Sound</h3>
|
||
|
|
<div class="flex items-center gap-2">
|
||
|
|
<button class="icon-btn" :title="ed.sound.value.on ? 'Turn sound off' : 'Turn sound on'" @click="ed.setSound({ on: !ed.sound.value.on })">
|
||
|
|
<Icon :name="ed.sound.value.on ? 'lucide:volume-2' : 'lucide:volume-x'" class="size-4" />
|
||
|
|
</button>
|
||
|
|
<input
|
||
|
|
type="range"
|
||
|
|
min="0"
|
||
|
|
max="1"
|
||
|
|
step="0.05"
|
||
|
|
class="grow"
|
||
|
|
:value="ed.sound.value.volume"
|
||
|
|
:disabled="!ed.sound.value.on"
|
||
|
|
aria-label="Volume"
|
||
|
|
@change="ed.setSound({ volume: Number(($event.target as HTMLInputElement).value) })"
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<label class="check mt-2">
|
||
|
|
<input type="checkbox" :checked="ed.sound.value.ticks" :disabled="!ed.sound.value.on" @change="ed.setSound({ ticks: !ed.sound.value.ticks })" />
|
||
|
|
Tick on every clock cycle (up to 8 Hz)
|
||
|
|
</label>
|
||
|
|
|
||
|
|
<button class="btn btn-primary mt-4" @click="close">Done</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</template>
|