refactor: sepia on menu open

This commit is contained in:
cha0s 2019-04-21 23:22:59 -05:00
parent c7998a7668
commit db861f60a3

View File

@ -66,14 +66,8 @@ export class App extends decorate(class {}) {
this.roomView = new RoomView(this.room, this.stage.renderer);
this.stage.addChild(this.roomView);
this.on('darknessChanged', this.applyLighting, this);
this.on('isFocusedChanged', () => {
if (this.isFocused) {
this.stage.removeAllFilters();
}
else {
this.stage.sepia();
}
})
this.on('isFocusedChanged', this.applyMuting, this)
this.on('isMenuOpenedChanged', this.applyMuting, this)
// Listen for new entities.
this.room.on('entityAdded', this.onRoomEntityAdded, this);
// Input.
@ -136,6 +130,15 @@ export class App extends decorate(class {}) {
}
}
applyMuting() {
if (!this.isFocused || this.isMenuOpened) {
this.stage.sepia();
}
else {
this.stage.removeAllFilters();
}
}
calculateDarkness() {
let darkness = 0;
if (this.worldTime.hour >= 21 || this.worldTime.hour < 4) {
@ -226,7 +229,7 @@ export class App extends decorate(class {}) {
case 'F2':
this.isDebugging = !this.isDebugging;
break;
case 'Escape':
case 'e':
this.isMenuOpened = !this.isMenuOpened;
break;
}