mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-17 00:01:14 +00:00
## Description: - **Dynamic sidebar offset for top bars** - GameLeftSidebar, GameRightSidebar, and PlayerInfoOverlay now shift down when SpawnTimer and/or ImmunityTimer bars are visible (7px per bar). Implemented via events. - **Fixed text overflow** in HeadsUpMessage.ts (Random spawn message is long) - **Fixed inconsistent text sizing** in EventsDisplay - **Alliance icon horizontal** in PlayerInfoOverlay so the size of the overlay doesn't change if there is an alliance - **Nation relation coloring** - Nation player names are now colored based on their relation - **Background & Blur Unification** - **Border Radius & Page Edge Gap Standardization** - **EventsDisplay collapsed button:** Fixed badge hidden / inline-block CSS conflict (conditional rendering), added gap-2 between text and badge - **Right panel spacing:** Changed right container from sm:w-1/2 to sm:flex-1 to fill remaining space - **Leaderboard**: Rounded grid corners (rounded-lg overflow-hidden), removed last-row border, added `willUpdate` for auto-refresh on hide/show click, plus button styled to match toggle buttons - Other little CSS fixes (margins etc) Showcase: (Note the red mexico name on betrayal) https://github.com/user-attachments/assets/f0ed91de-3a07-4564-a209-3d7723edee55 Two progress bars at the top, mobile UI not cut off: https://github.com/user-attachments/assets/83f1fd64-ceab-4a74-8d16-6e1eeea1709d HeadsUpMessage text overflow fixed, SpawnTimer does not cut off the PlayerInfoOverlay: <img width="516" height="929" alt="Screenshot 2026-02-14 214410" src="https://github.com/user-attachments/assets/74f0edea-8c01-4394-a3d0-a3245922e0da" /> Previous: <img width="306" height="118" alt="Screenshot 2026-02-14 213705" src="https://github.com/user-attachments/assets/a7c7e8f3-f0e8-4213-8a8f-4f3677e9fc98" /> Smaller event panel text: <img width="594" height="975" alt="Screenshot 2026-02-14 215738" src="https://github.com/user-attachments/assets/33e80570-9260-40b0-b810-c71eda4861fc" /> ## Please complete the following: - [X] I have added screenshots for all UI updates - [X] I process any text displayed to the user through translateText() and I've added it to the en.json file - [X] 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: FloPinguin
127 lines
3.4 KiB
TypeScript
127 lines
3.4 KiB
TypeScript
import { LitElement, html } from "lit";
|
|
import { customElement } from "lit/decorators.js";
|
|
import { EventBus, GameEvent } from "../../../core/EventBus";
|
|
import { GameMode, Team } from "../../../core/game/Game";
|
|
import { GameView } from "../../../core/game/GameView";
|
|
import { TransformHandler } from "../TransformHandler";
|
|
import { Layer } from "./Layer";
|
|
|
|
export class SpawnBarVisibleEvent implements GameEvent {
|
|
constructor(public readonly visible: boolean) {}
|
|
}
|
|
|
|
@customElement("spawn-timer")
|
|
export class SpawnTimer extends LitElement implements Layer {
|
|
public game: GameView;
|
|
public eventBus: EventBus;
|
|
public transformHandler: TransformHandler;
|
|
|
|
private ratios = [0];
|
|
private _barVisible = false;
|
|
private colors = ["rgba(0, 128, 255, 0.7)", "rgba(0, 0, 0, 0.5)"];
|
|
|
|
private isVisible = false;
|
|
|
|
createRenderRoot() {
|
|
this.style.position = "fixed";
|
|
this.style.top = "0";
|
|
this.style.left = "0";
|
|
this.style.width = "100%";
|
|
this.style.height = "7px";
|
|
this.style.zIndex = "1000";
|
|
this.style.pointerEvents = "none";
|
|
return this;
|
|
}
|
|
|
|
init() {
|
|
this.isVisible = true;
|
|
}
|
|
|
|
tick() {
|
|
if (this.game.inSpawnPhase()) {
|
|
// During spawn phase, only one segment filling full width
|
|
this.ratios = [
|
|
this.game.ticks() / this.game.config().numSpawnPhaseTurns(),
|
|
];
|
|
this.colors = ["rgba(0, 128, 255, 0.7)"];
|
|
} else {
|
|
this.ratios = [];
|
|
this.colors = [];
|
|
|
|
if (this.game.config().gameConfig().gameMode === GameMode.Team) {
|
|
const teamTiles: Map<Team, number> = new Map();
|
|
for (const player of this.game.players()) {
|
|
const team = player.team();
|
|
if (team === null) continue;
|
|
const tiles = teamTiles.get(team) ?? 0;
|
|
teamTiles.set(team, tiles + player.numTilesOwned());
|
|
}
|
|
|
|
const theme = this.game.config().theme();
|
|
const total = sumIterator(teamTiles.values());
|
|
if (total > 0) {
|
|
for (const [team, count] of teamTiles) {
|
|
const ratio = count / total;
|
|
this.ratios.push(ratio);
|
|
this.colors.push(theme.teamColor(team).toRgbString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.requestUpdate();
|
|
this.emitBarVisibility();
|
|
}
|
|
|
|
private emitBarVisibility() {
|
|
const nowVisible = this.isVisible && this.ratios.length > 0;
|
|
if (nowVisible !== this._barVisible) {
|
|
this._barVisible = nowVisible;
|
|
this.eventBus?.emit(new SpawnBarVisibleEvent(this._barVisible));
|
|
}
|
|
}
|
|
|
|
shouldTransform(): boolean {
|
|
return false;
|
|
}
|
|
|
|
render() {
|
|
if (!this.isVisible) {
|
|
return html``;
|
|
}
|
|
|
|
if (this.ratios.length === 0 || this.colors.length === 0) {
|
|
return html``;
|
|
}
|
|
|
|
if (
|
|
!this.game.inSpawnPhase() &&
|
|
this.game.config().gameConfig().gameMode !== GameMode.Team
|
|
) {
|
|
return html``;
|
|
}
|
|
|
|
return html`
|
|
<div class="w-full h-full flex z-999">
|
|
${this.ratios.map((ratio, i) => {
|
|
const color = this.colors[i] || "rgba(0, 0, 0, 0.5)";
|
|
return html`
|
|
<div
|
|
class="h-full transition-all duration-100 ease-in-out w-(--width) bg-(--bg)"
|
|
style="--width: ${ratio * 100}%; --bg: ${color};"
|
|
></div>
|
|
`;
|
|
})}
|
|
</div>
|
|
`;
|
|
}
|
|
}
|
|
|
|
function sumIterator(values: MapIterator<number>) {
|
|
let total = 0;
|
|
for (const value of values) {
|
|
total += value;
|
|
}
|
|
return total;
|
|
}
|