2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<div class="_formRoot">
|
|
|
|
<FormRange v-model="masterVolume" :min="0" :max="1" :step="0.05" :text-converter="(v) => `${Math.floor(v * 100)}%`" class="_formBlock">
|
|
|
|
<template #label>{{ $ts.masterVolume }}</template>
|
2020-11-25 14:31:34 +02:00
|
|
|
</FormRange>
|
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormSection>
|
2020-12-26 03:47:36 +02:00
|
|
|
<template #label>{{ $ts.sounds }}</template>
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormLink v-for="type in Object.keys(sounds)" :key="type" style="margin-bottom: 8px;" @click="edit(type)">
|
2020-11-25 14:31:34 +02:00
|
|
|
{{ $t('_sfx.' + type) }}
|
2020-12-26 03:47:36 +02:00
|
|
|
<template #suffix>{{ sounds[type].type || $ts.none }}</template>
|
2021-04-20 17:22:59 +03:00
|
|
|
<template #suffixIcon><i class="fas fa-chevron-down"></i></template>
|
2021-11-28 13:07:37 +02:00
|
|
|
</FormLink>
|
|
|
|
</FormSection>
|
2020-11-25 14:31:34 +02:00
|
|
|
|
2021-11-28 13:07:37 +02:00
|
|
|
<FormButton danger class="_formBlock" @click="reset()"><i class="fas fa-redo"></i> {{ $ts.default }}</FormButton>
|
|
|
|
</div>
|
2020-10-17 14:12:00 +03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2021-11-28 13:07:37 +02:00
|
|
|
import FormRange from '@/components/form/range.vue';
|
|
|
|
import FormButton from '@/components/ui/button.vue';
|
|
|
|
import FormLink from '@/components/form/link.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { ColdDeviceStorage } from '@/store';
|
|
|
|
import { playFile } from '@/scripts/sound';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
const soundsTypes = [
|
2020-10-17 14:12:00 +03:00
|
|
|
null,
|
|
|
|
'syuilo/up',
|
|
|
|
'syuilo/down',
|
|
|
|
'syuilo/pope1',
|
|
|
|
'syuilo/pope2',
|
|
|
|
'syuilo/waon',
|
|
|
|
'syuilo/popo',
|
|
|
|
'syuilo/triple',
|
|
|
|
'syuilo/poi1',
|
|
|
|
'syuilo/poi2',
|
|
|
|
'syuilo/pirori',
|
|
|
|
'syuilo/pirori-wet',
|
|
|
|
'syuilo/pirori-square-wet',
|
|
|
|
'syuilo/square-pico',
|
|
|
|
'syuilo/reverved',
|
|
|
|
'syuilo/ryukyu',
|
2020-11-25 14:31:34 +02:00
|
|
|
'syuilo/kick',
|
|
|
|
'syuilo/snare',
|
2021-08-14 12:19:25 +03:00
|
|
|
'syuilo/queue-jammed',
|
2020-10-17 14:12:00 +03:00
|
|
|
'aisha/1',
|
|
|
|
'aisha/2',
|
|
|
|
'aisha/3',
|
|
|
|
'noizenecio/kick_gaba',
|
|
|
|
'noizenecio/kick_gaba2',
|
|
|
|
];
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-11-28 13:07:37 +02:00
|
|
|
FormLink,
|
2020-11-25 14:31:34 +02:00
|
|
|
FormButton,
|
|
|
|
FormRange,
|
2021-11-28 13:07:37 +02:00
|
|
|
FormSection,
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 06:54:12 +03:00
|
|
|
[symbols.PAGE_INFO]: {
|
2020-12-26 03:47:36 +02:00
|
|
|
title: this.$ts.sounds,
|
2021-09-29 18:50:45 +03:00
|
|
|
icon: 'fas fa-music',
|
|
|
|
bg: 'var(--bg)',
|
2020-11-25 14:31:34 +02:00
|
|
|
},
|
|
|
|
sounds: {},
|
2020-10-17 14:12:00 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-11-25 14:31:34 +02:00
|
|
|
masterVolume: { // TODO: (外部)関数にcomputedを使うのはアレなので直す
|
2020-12-19 03:55:52 +02:00
|
|
|
get() { return ColdDeviceStorage.get('sound_masterVolume'); },
|
|
|
|
set(value) { ColdDeviceStorage.set('sound_masterVolume', value); }
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
2020-11-25 14:31:34 +02:00
|
|
|
volumeIcon() {
|
2021-04-20 17:22:59 +03:00
|
|
|
return this.masterVolume === 0 ? 'fas fa-volume-mute' : 'fas fa-volume-up';
|
2020-11-25 14:31:34 +02:00
|
|
|
}
|
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
created() {
|
2020-12-19 03:55:52 +02:00
|
|
|
this.sounds.note = ColdDeviceStorage.get('sound_note');
|
|
|
|
this.sounds.noteMy = ColdDeviceStorage.get('sound_noteMy');
|
|
|
|
this.sounds.notification = ColdDeviceStorage.get('sound_notification');
|
|
|
|
this.sounds.chat = ColdDeviceStorage.get('sound_chat');
|
|
|
|
this.sounds.chatBg = ColdDeviceStorage.get('sound_chatBg');
|
|
|
|
this.sounds.antenna = ColdDeviceStorage.get('sound_antenna');
|
|
|
|
this.sounds.channel = ColdDeviceStorage.get('sound_channel');
|
2020-11-25 14:31:34 +02:00
|
|
|
},
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
methods: {
|
|
|
|
async edit(type) {
|
|
|
|
const { canceled, result } = await os.form(this.$t('_sfx.' + type), {
|
|
|
|
type: {
|
|
|
|
type: 'enum',
|
|
|
|
enum: soundsTypes.map(x => ({
|
|
|
|
value: x,
|
2020-12-26 03:47:36 +02:00
|
|
|
label: x == null ? this.$ts.none : x,
|
2020-11-25 14:31:34 +02:00
|
|
|
})),
|
2020-12-26 03:47:36 +02:00
|
|
|
label: this.$ts.sound,
|
2020-11-25 14:31:34 +02:00
|
|
|
default: this.sounds[type].type,
|
|
|
|
},
|
|
|
|
volume: {
|
|
|
|
type: 'range',
|
|
|
|
mim: 0,
|
|
|
|
max: 1,
|
|
|
|
step: 0.05,
|
2021-12-04 13:35:08 +02:00
|
|
|
textConverter: (v) => `${Math.floor(v * 100)}%`,
|
2020-12-26 03:47:36 +02:00
|
|
|
label: this.$ts.volume,
|
2020-11-25 14:31:34 +02:00
|
|
|
default: this.sounds[type].volume
|
|
|
|
},
|
|
|
|
listen: {
|
|
|
|
type: 'button',
|
2020-12-26 03:47:36 +02:00
|
|
|
content: this.$ts.listen,
|
2020-11-25 14:31:34 +02:00
|
|
|
action: (_, values) => {
|
|
|
|
playFile(values.type, values.volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
const v = {
|
|
|
|
type: result.type,
|
|
|
|
volume: result.volume,
|
|
|
|
};
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2020-12-19 03:55:52 +02:00
|
|
|
ColdDeviceStorage.set('sound_' + type, v);
|
2020-11-25 14:31:34 +02:00
|
|
|
this.sounds[type] = v;
|
2020-10-17 14:12:00 +03:00
|
|
|
},
|
|
|
|
|
2020-11-25 14:31:34 +02:00
|
|
|
reset() {
|
|
|
|
for (const sound of Object.keys(this.sounds)) {
|
2020-12-19 03:55:52 +02:00
|
|
|
const v = ColdDeviceStorage.default['sound_' + sound];
|
|
|
|
ColdDeviceStorage.set('sound_' + sound, v);
|
2020-11-25 14:31:34 +02:00
|
|
|
this.sounds[sound] = v;
|
2020-10-17 14:12:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|