Adds a check to the bgm-bar display to prevent it from being displayed in case of an empty value (#3007)

This commit is contained in:
Dakurei 2024-07-13 20:31:49 +02:00 committed by GitHub
parent 5852cae36b
commit 35bbbcb484
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -62,6 +62,16 @@ export default class BgmBar extends Phaser.GameObjects.Container {
@param {boolean} visible Whether to show or hide the BGM bar.
*/
public toggleBgmBar(visible: boolean): void {
/*
Prevents the bar from being displayed if musicText is completely empty.
This can be the case, for example, when the game's 1st music track takes a long time to reach the client,
and the menu is opened before it is played.
*/
if (this.musicText.text === "") {
this.setVisible(false);
return;
}
if (!(this.scene as BattleScene).showBgmBar) {
this.setVisible(false);
return;