1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Initial support for themes, sound improvements

This commit is contained in:
tobspr
2020-05-16 09:49:00 +02:00
parent 236859baa1
commit 7870f011b8
20 changed files with 137 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
import { BaseHUDPart } from "../base_hud_part";
import { makeDiv, randomInt } from "../../../core/utils";
import { SOUNDS } from "../../../platform/sound";
export class HUDGameMenu extends BaseHUDPart {
initialize() {}
@@ -60,12 +61,13 @@ export class HUDGameMenu extends BaseHUDPart {
this.trackClicks(this.saveButton, this.startSave);
this.musicButton.classList.toggle("muted", this.root.app.settings.getAllSettings().musicMuted);
this.sfxButton.classList.toggle("muted", this.root.app.settings.getAllSettings().musicMuted);
this.sfxButton.classList.toggle("muted", this.root.app.settings.getAllSettings().soundsMuted);
this.root.signals.gameSaved.add(this.onGameSaved, this);
}
update() {
let playSound = false;
for (let i = 0; i < this.badgesToUpdate.length; ++i) {
const { badge, button, badgeElement, lastRenderAmount } = this.badgesToUpdate[i];
const amount = badge();
@@ -73,10 +75,18 @@ export class HUDGameMenu extends BaseHUDPart {
if (amount > 0) {
badgeElement.innerText = amount;
}
// Check if the badge increased
if (amount > lastRenderAmount) {
playSound = true;
}
this.badgesToUpdate[i].lastRenderAmount = amount;
button.classList.toggle("hasBadge", amount > 0);
}
}
if (playSound) {
this.root.soundProxy.playUi(SOUNDS.badgeNotification);
}
}
onGameSaved() {