✨ (viewer) Signal preference updates

This commit is contained in:
coyotte508 2021-12-01 23:05:39 +01:00
commit 9d8ca1e244
2 changed files with 11 additions and 2 deletions

View file

@ -1200,11 +1200,17 @@ export default class Game extends Vue {
}
toggleSound() {
this.preferences.sound = !this.preferences.sound;
const newSound = !this.preferences.sound;
this.emitter.emit('update:preference', { name: 'sound', value: newSound });
this.preferences.sound = newSound;
}
toggleHelp() {
this.preferences.disableHelp = !this.preferences.disableHelp;
const newVal = !this.preferences.disableHelp;
this.emitter.emit('update:preference', { name: 'disableHelp', value: newVal });
this.preferences.disableHelp = newVal;
}
showLog() {

View file

@ -28,6 +28,9 @@ function launch(selector: string) {
params.emitter.on('move', (move: Move) => item.emit('move', move));
params.emitter.on('addLog', (data: string[]) => item.emit('addLog', data));
params.emitter.on('replaceLog', (data: string[]) => item.emit('replaceLog', data));
params.emitter.on('update:preference', (data: { name: string; value: any }) =>
item.emit('update:preference', data)
);
item.addListener('state', (data) => {
params.state = data;