From fe9d3c3d64ba2d955fa08c84bbf4f736fab95946 Mon Sep 17 00:00:00 2001 From: Andrio Celos Date: Tue, 11 Oct 2022 10:40:05 +1100 Subject: [PATCH] Enhance lobby UI --- TableturfBattleClient/src/Pages/LobbyPage.ts | 13 +++---- TableturfBattleClient/src/app.ts | 2 +- TableturfBattleClient/tableturf.css | 36 ++++++++++++++++++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/TableturfBattleClient/src/Pages/LobbyPage.ts b/TableturfBattleClient/src/Pages/LobbyPage.ts index d579a35..f4da04c 100644 --- a/TableturfBattleClient/src/Pages/LobbyPage.ts +++ b/TableturfBattleClient/src/Pages/LobbyPage.ts @@ -43,14 +43,15 @@ function clearReady() { } function updatePlayerListItem(playerIndex: number) { - const player = currentGame != null ? currentGame.players[playerIndex] : null; const listItem = playerListItems[playerIndex]; - if (player != null) { + if (!currentGame?.players || playerIndex >= currentGame.players.length) { + listItem.className = 'empty'; + listItem.innerText = 'Waiting...'; + } else { + const player = currentGame.players[playerIndex]; listItem.innerText = player.name; - if (player.isReady) - listItem.innerText += ' (Ready)'; - } else - listItem.innerText = "Waiting..."; + listItem.className = player.isReady ? 'filled ready' : 'filled'; + } } function updateDeckCount() { diff --git a/TableturfBattleClient/src/app.ts b/TableturfBattleClient/src/app.ts index 1b93cff..dcd8cf7 100644 --- a/TableturfBattleClient/src/app.ts +++ b/TableturfBattleClient/src/app.ts @@ -109,9 +109,9 @@ function setupWebSocket(gameID: string, myPlayerIndex: number | null) { playerListItems.splice(0); for (let i = 0; i < currentGame.maxPlayers; i++) { var el = document.createElement('li'); - el.innerText = i < currentGame.players.length ? currentGame.players[i].name : 'Waiting...'; playerListItems.push(el); playerList.appendChild(el); + updatePlayerListItem(i); } for (let i = 0; i < playerBars.length; i++) { diff --git a/TableturfBattleClient/tableturf.css b/TableturfBattleClient/tableturf.css index b342048..ab5cf7c 100644 --- a/TableturfBattleClient/tableturf.css +++ b/TableturfBattleClient/tableturf.css @@ -64,6 +64,8 @@ footer { #lobbyPlayerListSection { overflow-y: auto; + height: calc(100vh - 16px); + box-sizing: border-box; } #lobbyStageSection, #lobbyDeckSection { @@ -72,6 +74,40 @@ footer { box-sizing: border-box; } +#playerList { + padding-left: 0; + list-style: none; +} + +#playerList li { + width: calc(100% - 3em); + margin: 0.5em 1em; + background: #111; + border-radius: 0.5em; + padding: 0.5em; + text-shadow: 1px 1px black; +} + +#playerList .filled { + background: var(--special-colour-1); + position: relative; + animation: 0.33s linear playerListFlyIn; +} + +#playerList .ready::after { + content: '\2714'; + position: absolute; + bottom: 0; + right: 0.5em; + font-weight: bold; + font-size: x-large; +} + +@keyframes playerListFlyIn { + from { left: -100%; } + to { left: 0; } +} + /* Stages */ #stageList {