diff --git a/resources/lang/en.json b/resources/lang/en.json index d61250b2b..48dde128e 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -494,7 +494,8 @@ "nation": "Nation", "player": "Player", "team": "Team", - "d_troops": "Defending troops", + "alliance_timeout": "Alliance ends in", + "troops": "Troops", "a_troops": "Attacking troops", "gold": "Gold", "ports": "Ports", diff --git a/src/client/PublicLobby.ts b/src/client/PublicLobby.ts index e94ed794b..3c186be1f 100644 --- a/src/client/PublicLobby.ts +++ b/src/client/PublicLobby.ts @@ -1,6 +1,6 @@ import { LitElement, html } from "lit"; import { customElement, state } from "lit/decorators.js"; -import { translateText } from "../client/Utils"; +import { renderDuration, translateText } from "../client/Utils"; import { GameMapType, GameMode } from "../core/game/Game"; import { GameID, GameInfo } from "../core/Schemas"; import { generateID } from "../core/Util"; @@ -104,9 +104,7 @@ export class PublicLobby extends LitElement { const timeRemaining = Math.max(0, Math.floor((start - Date.now()) / 1000)); // Format time to show minutes and seconds - const minutes = Math.floor(timeRemaining / 60); - const seconds = timeRemaining % 60; - const timeDisplay = minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`; + const timeDisplay = renderDuration(timeRemaining); const teamCount = lobby.gameConfig.gameMode === GameMode.Team diff --git a/src/client/Utils.ts b/src/client/Utils.ts index 494109fbd..32335190f 100644 --- a/src/client/Utils.ts +++ b/src/client/Utils.ts @@ -2,6 +2,16 @@ import IntlMessageFormat from "intl-messageformat"; import { MessageType } from "../core/game/Game"; import { LangSelector } from "./LangSelector"; +export function renderDuration(totalSeconds: number): string { + if (totalSeconds <= 0) return "0s"; + const minutes = Math.floor(totalSeconds / 60); + const seconds = totalSeconds % 60; + let time = ""; + if (minutes > 0) time += `${minutes}min `; + time += `${seconds}s`; + return time.trim(); +} + export function renderTroops(troops: number): string { return renderNumber(troops / 10); } diff --git a/src/client/graphics/layers/PlayerInfoOverlay.ts b/src/client/graphics/layers/PlayerInfoOverlay.ts index dab035023..b99c587c8 100644 --- a/src/client/graphics/layers/PlayerInfoOverlay.ts +++ b/src/client/graphics/layers/PlayerInfoOverlay.ts @@ -1,7 +1,14 @@ import { LitElement, TemplateResult, html } from "lit"; import { ref } from "lit-html/directives/ref.js"; import { customElement, property, state } from "lit/decorators.js"; -import { translateText } from "../../../client/Utils"; +import allianceIcon from "../../../../resources/images/AllianceIcon.svg"; +import portIcon from "../../../../resources/images/AnchorIcon.png"; +import warshipIcon from "../../../../resources/images/BattleshipIconWhite.svg"; +import cityIcon from "../../../../resources/images/CityIconWhite.svg"; +import factoryIcon from "../../../../resources/images/FactoryIconWhite.svg"; +import goldCoinIcon from "../../../../resources/images/GoldCoinIcon.svg"; +import missileSiloIcon from "../../../../resources/images/MissileSiloUnit.png"; +import samLauncherIcon from "../../../../resources/images/SamLauncherIconWhite.svg"; import { renderPlayerFlag } from "../../../core/CustomFlag"; import { EventBus } from "../../../core/EventBus"; import { @@ -12,9 +19,15 @@ import { UnitType, } from "../../../core/game/Game"; import { TileRef } from "../../../core/game/GameMap"; +import { AllianceView } from "../../../core/game/GameUpdates"; import { GameView, PlayerView, UnitView } from "../../../core/game/GameView"; import { ContextMenuEvent, MouseMoveEvent } from "../../InputHandler"; -import { renderNumber, renderTroops } from "../../Utils"; +import { + renderDuration, + renderNumber, + renderTroops, + translateText, +} from "../../Utils"; import { TransformHandler } from "../TransformHandler"; import { Layer } from "./Layer"; import { CloseRadialMenuEvent } from "./RadialMenu"; @@ -175,37 +188,83 @@ export class PlayerInfoOverlay extends LitElement implements Layer { private displayUnitCount( player: PlayerView, type: UnitType, + icon: string, description: string, ) { return !this.game.config().isUnitDisabled(type) - ? html`