import { html, LitElement } from "lit"; import { customElement, state } from "lit/decorators.js"; import exitIcon from "../../../../resources/images/ExitIconWhite.svg"; import pauseIcon from "../../../../resources/images/PauseIconWhite.svg"; import playIcon from "../../../../resources/images/PlayIconWhite.svg"; import replayRegularIcon from "../../../../resources/images/ReplayRegularIconWhite.svg"; import replaySolidIcon from "../../../../resources/images/ReplaySolidIconWhite.svg"; import { EventBus } from "../../../core/EventBus"; import { GameType } from "../../../core/game/Game"; import { GameView } from "../../../core/game/GameView"; import { PauseGameEvent } from "../../Transport"; import { Layer } from "./Layer"; @customElement("game-right-sidebar") export class GameRightSidebar extends LitElement implements Layer { public game: GameView; public eventBus: EventBus; @state() private _isSinglePlayer: boolean = false; @state() private _isReplayVisible: boolean = false; @state() private _isVisible: boolean = true; @state() private isPaused: boolean = false; @state() private isExistButtonVisible: boolean = true; createRenderRoot() { return this; } init() { this._isSinglePlayer = this.game?.config()?.gameConfig()?.gameType === GameType.Singleplayer || this.game.config().isReplay(); this._isVisible = true; this.game.inSpawnPhase(); this.requestUpdate(); } tick() { if (!this.game.inSpawnPhase()) { this.isExistButtonVisible = false; } } private toggleReplayPanel(): void { this._isReplayVisible = !this._isReplayVisible; } private onPauseButtonClick() { this.isPaused = !this.isPaused; this.eventBus.emit(new PauseGameEvent(this.isPaused)); } private onExitButtonClick() { const isAlive = this.game.myPlayer()?.isAlive(); if (isAlive) { const isConfirmed = confirm("Are you sure you want to exit the game?"); if (!isConfirmed) return; } // redirect to the home page window.location.href = "/"; } render() { return html` `; } }