2020-10-17 11:12:00 +00:00
|
|
|
<template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<FormBase>
|
|
|
|
<FormRange v-model:value="masterVolume" :min="0" :max="1" :step="0.05">
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label><Fa :icon="volumeIcon" :key="volumeIcon"/> {{ $ts.masterVolume }}</template>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormRange>
|
|
|
|
|
|
|
|
<FormGroup>
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #label>{{ $ts.sounds }}</template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<FormButton v-for="type in Object.keys(sounds)" :key="type" :center="false" @click="edit(type)">
|
|
|
|
{{ $t('_sfx.' + type) }}
|
2020-12-26 01:47:36 +00:00
|
|
|
<template #suffix>{{ sounds[type].type || $ts.none }}</template>
|
2020-11-25 12:31:34 +00:00
|
|
|
<template #suffixIcon><Fa :icon="faChevronDown"/></template>
|
|
|
|
</FormButton>
|
|
|
|
</FormGroup>
|
|
|
|
|
2020-12-26 01:47:36 +00:00
|
|
|
<FormButton @click="reset()" danger><Fa :icon="faRedo"/> {{ $ts.default }}</FormButton>
|
2020-11-25 12:31:34 +00:00
|
|
|
</FormBase>
|
2020-10-17 11:12:00 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
2020-11-25 12:31:34 +00:00
|
|
|
import { faMusic, faPlay, faVolumeUp, faVolumeMute, faChevronDown, faRedo } from '@fortawesome/free-solid-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import FormRange from '@client/components/form/range.vue';
|
|
|
|
import FormSelect from '@client/components/form/select.vue';
|
|
|
|
import FormBase from '@client/components/form/base.vue';
|
|
|
|
import FormButton from '@client/components/form/button.vue';
|
|
|
|
import FormGroup from '@client/components/form/group.vue';
|
|
|
|
import * as os from '@client/os';
|
|
|
|
import { ColdDeviceStorage } from '@client/store';
|
|
|
|
import { playFile } from '@client/scripts/sound';
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
const soundsTypes = [
|
2020-10-17 11:12:00 +00: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 12:31:34 +00:00
|
|
|
'syuilo/kick',
|
|
|
|
'syuilo/snare',
|
2020-10-17 11:12:00 +00:00
|
|
|
'aisha/1',
|
|
|
|
'aisha/2',
|
|
|
|
'aisha/3',
|
|
|
|
'noizenecio/kick_gaba',
|
|
|
|
'noizenecio/kick_gaba2',
|
|
|
|
];
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-11-25 12:31:34 +00:00
|
|
|
FormSelect,
|
|
|
|
FormButton,
|
|
|
|
FormBase,
|
|
|
|
FormRange,
|
|
|
|
FormGroup,
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-11-25 12:31:34 +00:00
|
|
|
INFO: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.sounds,
|
2020-11-25 12:31:34 +00:00
|
|
|
icon: faMusic
|
|
|
|
},
|
|
|
|
sounds: {},
|
|
|
|
faMusic, faPlay, faVolumeUp, faVolumeMute, faChevronDown, faRedo,
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2020-11-25 12:31:34 +00:00
|
|
|
masterVolume: { // TODO: (外部)関数にcomputedを使うのはアレなので直す
|
2020-12-19 01:55:52 +00:00
|
|
|
get() { return ColdDeviceStorage.get('sound_masterVolume'); },
|
|
|
|
set(value) { ColdDeviceStorage.set('sound_masterVolume', value); }
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
2020-11-25 12:31:34 +00:00
|
|
|
volumeIcon() {
|
|
|
|
return this.masterVolume === 0 ? faVolumeMute : faVolumeUp;
|
|
|
|
}
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
created() {
|
2020-12-19 01:55:52 +00: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');
|
|
|
|
this.sounds.reversiPutBlack = ColdDeviceStorage.get('sound_reversiPutBlack');
|
|
|
|
this.sounds.reversiPutWhite = ColdDeviceStorage.get('sound_reversiPutWhite');
|
2020-11-25 12:31:34 +00:00
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
mounted() {
|
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
},
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-11-25 12:31:34 +00: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 01:47:36 +00:00
|
|
|
label: x == null ? this.$ts.none : x,
|
2020-11-25 12:31:34 +00:00
|
|
|
})),
|
2020-12-26 01:47:36 +00:00
|
|
|
label: this.$ts.sound,
|
2020-11-25 12:31:34 +00:00
|
|
|
default: this.sounds[type].type,
|
|
|
|
},
|
|
|
|
volume: {
|
|
|
|
type: 'range',
|
|
|
|
mim: 0,
|
|
|
|
max: 1,
|
|
|
|
step: 0.05,
|
2020-12-26 01:47:36 +00:00
|
|
|
label: this.$ts.volume,
|
2020-11-25 12:31:34 +00:00
|
|
|
default: this.sounds[type].volume
|
|
|
|
},
|
|
|
|
listen: {
|
|
|
|
type: 'button',
|
2020-12-26 01:47:36 +00:00
|
|
|
content: this.$ts.listen,
|
2020-11-25 12:31:34 +00:00
|
|
|
action: (_, values) => {
|
|
|
|
playFile(values.type, values.volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
const v = {
|
|
|
|
type: result.type,
|
|
|
|
volume: result.volume,
|
|
|
|
};
|
2020-10-17 11:12:00 +00:00
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
ColdDeviceStorage.set('sound_' + type, v);
|
2020-11-25 12:31:34 +00:00
|
|
|
this.sounds[type] = v;
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
|
|
|
|
2020-11-25 12:31:34 +00:00
|
|
|
reset() {
|
|
|
|
for (const sound of Object.keys(this.sounds)) {
|
2020-12-19 01:55:52 +00:00
|
|
|
const v = ColdDeviceStorage.default['sound_' + sound];
|
|
|
|
ColdDeviceStorage.set('sound_' + sound, v);
|
2020-11-25 12:31:34 +00:00
|
|
|
this.sounds[sound] = v;
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|