Skip to content

Commit

Permalink
Merge pull request #324 from pap-24/badges-in-spectate-menu
Browse files Browse the repository at this point in the history
Badge display in spectate menu (uiManager.ts & game.css)
  • Loading branch information
hsanger authored Jun 5, 2024
2 parents c277147 + 32a0e76 commit e0de4d6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
10 changes: 9 additions & 1 deletion client/src/scripts/managers/uiManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,16 @@ export class UIManager {
if (data.dirty.id) {
this.game.spectating = data.spectating;
if (data.spectating) {
// Read the badge.
const badge = this.getPlayerBadge(data.id);

// Badge HTML-string
const badgeText = badge ? `<img class="badge-icon" src="./img/game/badges/${badge.idString}.svg" alt="${badge.name} badge">` : "";

$("#game-over-overlay").fadeOut();
$("#spectating-msg-player").html(this.getPlayerName(data.id));

// Player Name + Badge.
$("#spectating-msg-player").html(this.getPlayerName(data.id) + badgeText);
}
$("#spectating-container").toggle(data.spectating);
}
Expand Down
20 changes: 18 additions & 2 deletions client/src/scss/pages/client/game.scss
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@

#spectating-msg {
text-align: center;
display: flex;
/*display: flex; - Not needed.*/

font-weight: bold;
font-size: 30px;
Expand All @@ -770,7 +770,23 @@
}

#spectating-msg-player {
margin-left: 8px;
display: inline; /* Changed from "flex" to "inline". */
margin-left: 3px; /* Changed. (Original is 8px) */
}

/* Added. */
.badge-icon {
vertical-align: middle;
width: 30px;
height: 30px;
margin-left: 1px;
margin-right: 4px;
margin-bottom: 3px;

@media screen and (max-width: $screen_large) {
width: 16px;
height: 16px;
}
}
}

Expand Down

0 comments on commit e0de4d6

Please sign in to comment.