mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-25 10:12:43 +00:00
b045608c89
## Description: Reduce HUD transparency for better readability by making the Control Panel, Attacks panel, Events/Chat panel, and Hover panel more opaque while keeping a subtle blur effect. ## Please complete the following: - [ x] I have added screenshots for all UI updates - [ ] I process any text displayed to the user through translateText() and I've added it to the en.json file - [ ] I have added relevant tests to the test directory - [x ] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: HulKiora Before : <img width="518" height="134" alt="image" src="https://github.com/user-attachments/assets/dd714a8e-5b8c-4754-b68d-a86a0f82afcf" /> After : <img width="519" height="138" alt="image" src="https://github.com/user-attachments/assets/828b88be-a071-474c-a4a2-80d1c679b3df" />
196 lines
6.6 KiB
TypeScript
196 lines
6.6 KiB
TypeScript
import { Colord } from "colord";
|
|
import { html, LitElement } from "lit";
|
|
import { customElement, state } from "lit/decorators.js";
|
|
import { EventBus } from "../../../core/EventBus";
|
|
import { GameMode, Team } from "../../../core/game/Game";
|
|
import { GameView } from "../../../core/game/GameView";
|
|
import { Platform } from "../../Platform";
|
|
import { getTranslatedPlayerTeamLabel, translateText } from "../../Utils";
|
|
import { ImmunityBarVisibleEvent } from "./ImmunityTimer";
|
|
import { Layer } from "./Layer";
|
|
import { SpawnBarVisibleEvent } from "./SpawnTimer";
|
|
import leaderboardRegularIcon from "/images/LeaderboardIconRegularWhite.svg?url";
|
|
import leaderboardSolidIcon from "/images/LeaderboardIconSolidWhite.svg?url";
|
|
import teamRegularIcon from "/images/TeamIconRegularWhite.svg?url";
|
|
import teamSolidIcon from "/images/TeamIconSolidWhite.svg?url";
|
|
|
|
@customElement("game-left-sidebar")
|
|
export class GameLeftSidebar extends LitElement implements Layer {
|
|
@state()
|
|
private isLeaderboardShow = false;
|
|
@state()
|
|
private isTeamLeaderboardShow = false;
|
|
@state()
|
|
private isVisible = false;
|
|
@state()
|
|
private isPlayerTeamLabelVisible = false;
|
|
@state()
|
|
private playerTeam: Team | null = null;
|
|
@state()
|
|
private spawnBarVisible = false;
|
|
@state()
|
|
private immunityBarVisible = false;
|
|
|
|
private playerColor: Colord = new Colord("#FFFFFF");
|
|
public game: GameView;
|
|
public eventBus: EventBus;
|
|
private _shownOnInit = false;
|
|
|
|
createRenderRoot() {
|
|
return this;
|
|
}
|
|
|
|
init() {
|
|
this.isVisible = true;
|
|
this.eventBus.on(SpawnBarVisibleEvent, (e) => {
|
|
this.spawnBarVisible = e.visible;
|
|
});
|
|
this.eventBus.on(ImmunityBarVisibleEvent, (e) => {
|
|
this.immunityBarVisible = e.visible;
|
|
});
|
|
if (this.isTeamGame) {
|
|
this.isPlayerTeamLabelVisible = true;
|
|
}
|
|
// Make it visible by default on large screens
|
|
if (Platform.isDesktopWidth) {
|
|
// lg breakpoint
|
|
this._shownOnInit = true;
|
|
}
|
|
this.requestUpdate();
|
|
}
|
|
|
|
tick() {
|
|
if (!this.playerTeam && this.game.myPlayer()?.team()) {
|
|
this.playerTeam = this.game.myPlayer()!.team();
|
|
if (this.playerTeam) {
|
|
this.playerColor = this.game
|
|
.config()
|
|
.theme()
|
|
.teamColor(this.playerTeam);
|
|
this.requestUpdate();
|
|
}
|
|
}
|
|
|
|
if (this._shownOnInit && !this.game.inSpawnPhase()) {
|
|
this._shownOnInit = false;
|
|
this.isLeaderboardShow = true;
|
|
this.requestUpdate();
|
|
}
|
|
|
|
if (!this.game.inSpawnPhase() && this.isPlayerTeamLabelVisible) {
|
|
this.isPlayerTeamLabelVisible = false;
|
|
this.requestUpdate();
|
|
}
|
|
}
|
|
|
|
private get barOffset(): number {
|
|
return (this.spawnBarVisible ? 7 : 0) + (this.immunityBarVisible ? 7 : 0);
|
|
}
|
|
|
|
private toggleLeaderboard(): void {
|
|
this.isLeaderboardShow = !this.isLeaderboardShow;
|
|
}
|
|
|
|
private toggleTeamLeaderboard(): void {
|
|
this.isTeamLeaderboardShow = !this.isTeamLeaderboardShow;
|
|
}
|
|
|
|
private get isTeamGame(): boolean {
|
|
return this.game?.config().gameConfig().gameMode === GameMode.Team;
|
|
}
|
|
|
|
render() {
|
|
return html`
|
|
<aside
|
|
class=${`fixed top-0 min-[1200px]:top-4 left-0 min-[1200px]:left-4 z-900 flex flex-col max-h-[calc(100vh-80px)] overflow-y-auto p-2 bg-gray-800/92 backdrop-blur-sm shadow-xs min-[1200px]:rounded-lg rounded-br-lg ${this.isLeaderboardShow || this.isTeamLeaderboardShow ? "max-[400px]:w-full max-[400px]:rounded-none" : ""} transition-all duration-300 ease-out transform ${
|
|
this.isVisible ? "translate-x-0" : "hidden"
|
|
}`}
|
|
style="margin-top: ${this.barOffset}px;"
|
|
>
|
|
<div class="flex items-center gap-4 xl:gap-6 text-white">
|
|
<div
|
|
class="cursor-pointer p-0.5 bg-gray-700/50 hover:bg-gray-600 border rounded-md border-slate-500 transition-colors"
|
|
@click=${this.toggleLeaderboard}
|
|
role="button"
|
|
tabindex="0"
|
|
@keydown=${(e: KeyboardEvent) => {
|
|
if (e.key === "Enter" || e.key === " " || e.code === "Space") {
|
|
e.preventDefault();
|
|
this.toggleLeaderboard();
|
|
}
|
|
}}
|
|
>
|
|
<img
|
|
src=${this.isLeaderboardShow
|
|
? leaderboardSolidIcon
|
|
: leaderboardRegularIcon}
|
|
alt=${translateText("help_modal.icon_alt_player_leaderboard") ||
|
|
"Player Leaderboard Icon"}
|
|
width="20"
|
|
height="20"
|
|
/>
|
|
</div>
|
|
${this.isTeamGame
|
|
? html`
|
|
<div
|
|
class="cursor-pointer p-0.5 bg-gray-700/50 hover:bg-gray-600 border rounded-md border-slate-500 transition-colors"
|
|
@click=${this.toggleTeamLeaderboard}
|
|
role="button"
|
|
tabindex="0"
|
|
@keydown=${(e: KeyboardEvent) => {
|
|
if (
|
|
e.key === "Enter" ||
|
|
e.key === " " ||
|
|
e.code === "Space"
|
|
) {
|
|
e.preventDefault();
|
|
this.toggleTeamLeaderboard();
|
|
}
|
|
}}
|
|
>
|
|
<img
|
|
src=${this.isTeamLeaderboardShow
|
|
? teamSolidIcon
|
|
: teamRegularIcon}
|
|
alt=${translateText(
|
|
"help_modal.icon_alt_team_leaderboard",
|
|
) || "Team Leaderboard Icon"}
|
|
width="20"
|
|
height="20"
|
|
/>
|
|
</div>
|
|
`
|
|
: null}
|
|
</div>
|
|
${this.isPlayerTeamLabelVisible
|
|
? html`
|
|
<div
|
|
class="flex items-center w-full text-white mt-2"
|
|
@contextmenu=${(e: Event) => e.preventDefault()}
|
|
>
|
|
${translateText("help_modal.ui_your_team")}
|
|
<span
|
|
style="--color: ${this.playerColor.toRgbString()}"
|
|
class="text-(--color)"
|
|
>
|
|
${getTranslatedPlayerTeamLabel(this.playerTeam)}
|
|
⦿
|
|
</span>
|
|
</div>
|
|
`
|
|
: null}
|
|
<div
|
|
class=${`block lg:flex flex-wrap overflow-x-auto min-w-0 w-full ${this.isLeaderboardShow && this.isTeamLeaderboardShow ? "gap-2" : ""}`}
|
|
>
|
|
<leader-board .visible=${this.isLeaderboardShow}></leader-board>
|
|
<team-stats
|
|
class="flex-1"
|
|
.visible=${this.isTeamLeaderboardShow && this.isTeamGame}
|
|
></team-stats>
|
|
</div>
|
|
<slot></slot>
|
|
</aside>
|
|
`;
|
|
}
|
|
}
|