mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-30 21:13:24 +00:00
0c7da790f1
## 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
106 lines
3.0 KiB
TypeScript
106 lines
3.0 KiB
TypeScript
import { html, LitElement } from "lit";
|
||
import { customElement, property, state } from "lit/decorators.js";
|
||
import { EventBus } from "../../../core/EventBus";
|
||
import { GameView } from "../../../core/game/GameView";
|
||
import { ReplaySpeedChangeEvent } from "../../InputHandler";
|
||
import {
|
||
defaultReplaySpeedMultiplier,
|
||
ReplaySpeedMultiplier,
|
||
} from "../../utilities/ReplaySpeedMultiplier";
|
||
import { translateText } from "../../Utils";
|
||
import { Layer } from "./Layer";
|
||
|
||
export class ShowReplayPanelEvent {
|
||
constructor(
|
||
public visible: boolean = true,
|
||
public isSingleplayer: boolean = false,
|
||
) {}
|
||
}
|
||
|
||
@customElement("replay-panel")
|
||
export class ReplayPanel extends LitElement implements Layer {
|
||
public game: GameView | undefined;
|
||
public eventBus: EventBus | undefined;
|
||
|
||
@property({ type: Boolean })
|
||
visible: boolean = false;
|
||
|
||
@state()
|
||
private _replaySpeedMultiplier: number = defaultReplaySpeedMultiplier;
|
||
|
||
@property({ type: Boolean })
|
||
isSingleplayer = false;
|
||
|
||
createRenderRoot() {
|
||
return this; // Enable Tailwind CSS
|
||
}
|
||
|
||
init() {
|
||
if (this.eventBus) {
|
||
this.eventBus.on(ShowReplayPanelEvent, (event: ShowReplayPanelEvent) => {
|
||
this.visible = event.visible;
|
||
this.isSingleplayer = event.isSingleplayer;
|
||
});
|
||
}
|
||
}
|
||
|
||
getTickIntervalMs() {
|
||
return 1000;
|
||
}
|
||
|
||
tick() {
|
||
if (!this.visible) return;
|
||
this.requestUpdate();
|
||
}
|
||
|
||
onReplaySpeedChange(value: ReplaySpeedMultiplier) {
|
||
this._replaySpeedMultiplier = value;
|
||
this.eventBus?.emit(new ReplaySpeedChangeEvent(value));
|
||
}
|
||
|
||
renderLayer(_ctx: CanvasRenderingContext2D) {}
|
||
shouldTransform() {
|
||
return false;
|
||
}
|
||
|
||
render() {
|
||
if (!this.visible) return html``;
|
||
|
||
return html`
|
||
<div
|
||
class="p-2 bg-gray-800/70 backdrop-blur-xs shadow-xs min-[1200px]:rounded-lg rounded-l-lg"
|
||
@contextmenu=${(e: Event) => e.preventDefault()}
|
||
>
|
||
<label class="block mb-2 text-white" translate="no">
|
||
${this.game?.config()?.isReplay()
|
||
? translateText("replay_panel.replay_speed")
|
||
: translateText("replay_panel.game_speed")}
|
||
</label>
|
||
<div class="grid grid-cols-4 gap-2">
|
||
${this.renderSpeedButton(ReplaySpeedMultiplier.slow, "×0.5")}
|
||
${this.renderSpeedButton(ReplaySpeedMultiplier.normal, "×1")}
|
||
${this.renderSpeedButton(ReplaySpeedMultiplier.fast, "×2")}
|
||
${this.renderSpeedButton(
|
||
ReplaySpeedMultiplier.fastest,
|
||
translateText("replay_panel.fastest_game_speed"),
|
||
)}
|
||
</div>
|
||
</div>
|
||
`;
|
||
}
|
||
|
||
private renderSpeedButton(value: ReplaySpeedMultiplier, label: string) {
|
||
const backgroundColor =
|
||
this._replaySpeedMultiplier === value ? "bg-blue-400" : "";
|
||
|
||
return html`
|
||
<button
|
||
class="py-0.5 px-1 text-sm text-white rounded-sm border transition border-gray-500 ${backgroundColor} hover:border-gray-200"
|
||
@click=${() => this.onReplaySpeedChange(value)}
|
||
>
|
||
${label}
|
||
</button>
|
||
`;
|
||
}
|
||
}
|