@@ -10,10 +10,13 @@ import {
1010 Trios ,
1111} from "../core/game/Game" ;
1212import { PublicGameInfo , PublicGames } from "../core/Schemas" ;
13+ import { HostLobbyModal } from "./HostLobbyModal" ;
14+ import { JoinLobbyModal } from "./JoinLobbyModal" ;
1315import { PublicLobbySocket } from "./LobbySocket" ;
1416import { JoinLobbyEvent } from "./Main" ;
17+ import { SinglePlayerModal } from "./SinglePlayerModal" ;
1518import { terrainMapFileLoader } from "./TerrainMapFileLoader" ;
16- import { renderDuration , translateText } from "./Utils" ;
19+ import { getMapName , renderDuration , translateText } from "./Utils" ;
1720
1821const CARD_BG = "bg-[color-mix(in_oklab,var(--frenchBlue)_70%,black)]" ;
1922
@@ -145,31 +148,24 @@ export class GameModeSelector extends LitElement {
145148
146149 private openRankedMenu = ( ) => {
147150 if ( ! this . validateUsername ( ) ) return ;
148-
149- const modal = document . getElementById ( "page-ranked" ) as any ;
150- if ( window . showPage ) {
151- window . showPage ( "page-ranked" ) ;
152- } else if ( modal ) {
153- document . getElementById ( "page-play" ) ?. classList . add ( "hidden" ) ;
154- modal . classList . remove ( "hidden" ) ;
155- modal . classList . add ( "block" ) ;
156- }
157- modal ?. open ?.( ) ;
151+ window . showPage ?.( "page-ranked" ) ;
158152 } ;
159153
160154 private openSinglePlayerModal = ( ) => {
161155 if ( ! this . validateUsername ( ) ) return ;
162- ( document . querySelector ( "single-player-modal" ) as any ) ?. open ( ) ;
156+ (
157+ document . querySelector ( "single-player-modal" ) as SinglePlayerModal
158+ ) ?. open ( ) ;
163159 } ;
164160
165161 private openHostLobby = ( ) => {
166162 if ( ! this . validateUsername ( ) ) return ;
167- ( document . querySelector ( "host-lobby-modal" ) as any ) ?. open ( ) ;
163+ ( document . querySelector ( "host-lobby-modal" ) as HostLobbyModal ) ?. open ( ) ;
168164 } ;
169165
170166 private openJoinLobby = ( ) => {
171167 if ( ! this . validateUsername ( ) ) return ;
172- ( document . querySelector ( "join-lobby-modal" ) as any ) ?. open ( ) ;
168+ ( document . querySelector ( "join-lobby-modal" ) as JoinLobbyModal ) ?. open ( ) ;
173169 } ;
174170
175171 private renderSmallActionCard ( title : string , onClick : ( ) => void ) {
@@ -188,15 +184,11 @@ export class GameModeSelector extends LitElement {
188184 titleContent : string | TemplateResult ,
189185 ) {
190186 const mapType = lobby . gameConfig ! . gameMap as GameMapType ;
191- const mapImageSrc = terrainMapFileLoader . getMapData ( mapType ) . webpPathSync ( ) ;
192- // TODO: plus or minus
187+ const mapImageSrc = terrainMapFileLoader . getMapData ( mapType ) . webpPath ;
193188 const start = lobby . startsAt - this . timeOffset ;
194189 const timeRemaining = Math . max ( 0 , Math . floor ( ( start - Date . now ( ) ) / 1000 ) ) ;
195190 const timeDisplay = renderDuration ( timeRemaining ) ;
196- const gameMap = lobby . gameConfig ?. gameMap ;
197- const mapName = gameMap
198- ? translateText ( `map.${ gameMap . toLowerCase ( ) . replace ( / [ \s . ] + / g, "" ) } ` )
199- : null ;
191+ const mapName = getMapName ( lobby . gameConfig ?. gameMap ) ;
200192
201193 const modifierLabels = this . getModifierLabels (
202194 lobby . gameConfig ?. publicGameModifiers ,
@@ -215,7 +207,7 @@ export class GameModeSelector extends LitElement {
215207 ${ mapImageSrc
216208 ? html `< img
217209 src ="${ mapImageSrc } "
218- alt ="${ mapName ?? gameMap ?? "map" } "
210+ alt ="${ mapName ?? lobby . gameConfig ?. gameMap ?? "map" } "
219211 draggable ="false "
220212 class ="absolute inset-0 w-full h-full object-contain object-center scale-[1.05] pointer-events-none "
221213 /> `
@@ -288,10 +280,6 @@ export class GameModeSelector extends LitElement {
288280 ) ;
289281 }
290282
291- private getLobbyTitle ( lobby : PublicGameInfo ) : string {
292- return this . getBaseModeTitle ( lobby ) ;
293- }
294-
295283 private getModifierLabels ( mods : PublicGameModifiers | undefined ) : string [ ] {
296284 if ( ! mods ) return [ ] ;
297285 return [
@@ -302,7 +290,7 @@ export class GameModeSelector extends LitElement {
302290 ] . filter ( ( x ) : x is string => ! ! x ) ;
303291 }
304292
305- private getBaseModeTitle ( lobby : PublicGameInfo ) : string {
293+ private getLobbyTitle ( lobby : PublicGameInfo ) : string {
306294 const config = lobby . gameConfig ! ;
307295 if ( config . gameMode === GameMode . FFA ) {
308296 return translateText ( "game_mode.ffa" ) ;
0 commit comments