Dark mode: Light, Dark or Auto under Settings › Theme (#80)
A device preference (localStorage sot-theme, never in the save), applied by a small script in <head> before the first paint, so there is no flash; Auto follows prefers-color-scheme live, and a choice reaches other tabs and the NOC window. Panels, HUD, drawers, toasts, modals, the phone tab bar, charts, puzzles, the architect and Pie Control take their colours from custom properties with night values (AA text contrast); light tints keep their old colour as the fallback, so the light look is unchanged. Both map renderers read a light and a dark palette (96-map/15-palette.js): sea, land, clouds, coastlines, labels and the tube outline. A theme switch repaints the cached layers once (the WebGL land buffers are rebuilt once); nothing changes per frame. The multiplayer leaderboard's own row and the menu rank badge follow the theme too.
This commit is contained in:
parent
95aa9b6532
commit
2cd6b71198
49 changed files with 645 additions and 155 deletions
|
|
@ -8,6 +8,7 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
- Your intern can upgrade optical transport: a new standing order moves full, busy fiber to a bigger line system, or trades its smallest channels for bigger optics. Pick a line system, and every fiber on a smaller one is moved up to it. A line system swap takes the fiber down for a day, so the intern only does it where the traffic gets around it and no customer rides it, one a night.
|
||||
- Copies of the game you host yourself can now have multiplayer: friends join your session with a six-character code and build their networks next to yours in the same world, with a leaderboard, a feed with chat, saves kept on your server and a link to carry a network to another device. It needs the small session server that comes with the source code, so the game at seriesoftub.es stays single-player.
|
||||
- Dark mode: pick Light, Dark or Auto (follows your device) under Settings › Theme. The panels, the NOC dashboard and the map all go dark, with a night-time sea and land, and the setting is kept on your device (#80).
|
||||
- Your intern can standardize your routers on a model you choose: pick it in Keep routers ahead, and every POP on a smaller model is swapped to it, the busiest first, within the monthly budget. Every setting in the Standing orders sheet is now a list to pick from instead of a button to tap through.
|
||||
- Set a build standard for your whole network: routers, a second building and a generator at every POP, LAGs, exchange ports and PNIs, line systems, optics and wave sizes, all in one sheet. New POPs get the POP part the day they open, the sheet shows what is below the standard and what fixing it costs, one tap brings everything up, and the new "Keep to the build standard" order has your intern do it a few jobs a day with money to spare. Find it in the menu, the Standing orders sheet and every POP's router section.
|
||||
|
||||
|
|
|
|||
|
|
@ -38,13 +38,13 @@ hoisted across files, and top-level statements run in path order. Find code by n
|
|||
| `88-days/` | `dayTick()`, new offers, badges, `checkGoals()` |
|
||||
| `90-actions/` | The `ACT` map, one file per area (`const ACT` in `10-interface.js`, `Object.assign(ACT,…)` in the rest), and their helpers |
|
||||
| `91-save.js`, `92-audio.js` | Save, export and import; sound effects |
|
||||
| `93-ui/` | DOM helpers (`$`, `btn`, `morph`), the phone tab bar, install pitch, HUD, left panel, city and link panels, decommissioning |
|
||||
| `93-ui/` | DOM helpers (`$`, `btn`, `morph`), the theme (light, dark or Auto: `15-theme.js`), the phone tab bar, install pitch, HUD, left panel, city and link panels, decommissioning |
|
||||
| `94-dashboard/` | Scenario and level progress, where to meet a network, customers and connections overviews, cities with no POP yet, lease swaps, the NOC dashboard and its own window for a second display (`90-noc-window.js`: this page at `?noc=<slot>`, a read-only copy of `S` and `R` over a BroadcastChannel, clicks sent back to the game; `91-noc-wall.js`: its wallboard), the bank, hints |
|
||||
| `95-modals/` | Toasts, notifications, modals, title screen, what's new, help, the link and own-cable modals |
|
||||
| `96-map/` | The canvas: resize, land and clouds, settings, level of detail, link geometry, how each tube looks, the WebGL map (the default, 2D as fallback: context, background, tubes, and the sprite atlas cities, labels and markers are drawn from, in 2D too), `draw()`, the world layer, cities, input and click delegation |
|
||||
| `96-map/` | The canvas: resize, the map's colours per theme (`15-palette.js`), land and clouds, settings, level of detail, link geometry, how each tube looks, the WebGL map (the default, 2D as fallback: context, background, tubes, and the sprite atlas cities, labels and markers are drawn from, in 2D too), `draw()`, the world layer, cities, input and click delegation |
|
||||
| `99-loop.js` | `frame()` and `boot()` |
|
||||
|
||||
`src/styles/` holds the CSS the same way: base, HUD, drawers, toasts, modal, tablet, then phone.
|
||||
`src/styles/` holds the CSS the same way: base, the dark theme's colours (`05-theme.css`), HUD, drawers, toasts, modal, tablet, then phone.
|
||||
|
||||
`src/agent/` is the agent facade (`window.TUBES`): the typed commands, reads and screens the MCP server plays
|
||||
through. It is assembled into the **development page** only (`npm run dev`, the MCP server, tests that ask for it);
|
||||
|
|
|
|||
|
|
@ -4540,12 +4540,15 @@
|
|||
"settings.always_2d":"Immer 2D",
|
||||
"settings.an_early_heads_up_below_60":"Eine frühe Warnung unter 60 % Zufriedenheit, lange bevor sie wütend sind.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto zeichnet die Karte mit deiner Grafikkarte, wenn der Browser es erlaubt, damit auch große Netze flüssig bleiben. Immer 2D läuft überall, ist auf großen Karten aber langsamer.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto folgt der Hell- oder Dunkel-Einstellung deines Geräts. Dunkel schont nachts die Augen und auf OLED-Bildschirmen den Akku.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto folgt der Einstellung „Bewegung reduzieren“ deines Geräts. Aus friert die Karte ein: keine wandernden Pakete, kein Pulsieren, kein schwebender Text.",
|
||||
"settings.customers_and_alerts":"Kunden und Warnungen",
|
||||
"settings.dark":"Dunkel",
|
||||
"settings.diagnostic_info":"Diagnoseinfos",
|
||||
"settings.display_and_sound":"Anzeige und Ton",
|
||||
"settings.for_bug_reports_shows_your_screen":"Für Fehlerberichte: zeigt in einer Ecke die Größe deines Bildschirms, wie die Karte gezeichnet wird (Grafikkarte oder 2D, und warum) und wie schnell.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Eine KI soll dieses Spiel spielen",
|
||||
"settings.light":"Hell",
|
||||
"settings.map_drawing":"Kartendarstellung",
|
||||
"settings.n_min":"{n} Min.",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4559,6 +4562,7 @@
|
|||
"settings.the_agent_moves_it":"Der Agent stellt sie",
|
||||
"settings.the_clock_while_an_agent_plays":"Die Uhr, während ein Agent spielt",
|
||||
"settings.the_game_stops_so_you_can":"Das Spiel hält an, damit du ihren Dienst reparieren kannst, bevor sie kündigen. Am nützlichsten bei hoher Geschwindigkeit.",
|
||||
"settings.theme":"Design",
|
||||
"settings.this_browser_cannot_so_the_map":"Dieser Browser kann das nicht, also wird die Karte in 2D gezeichnet.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Bei unzufriedenen Kunden warnen",
|
||||
"settings.while_agent_mode_is_on_the":"Solange der Agenten-Modus an ist, gehört die Uhr nicht dir. Mit Tempo läuft sie von selbst und lässt sich von Hand nicht anhalten, auch nicht durch ein offenes Fenster (deins eingeschlossen), und sie wartet, solange kein Agent verbunden ist. Oder der Agent stellt sie, und nichts passiert, bis er nach Tagen fragt. Die Seite verbindet sich mit dem lokalen Agenten-Relay (npm run dev bringt eins mit), damit Tools wie der MCP-Server dieses Spiel spielen können, während du zusiehst.",
|
||||
|
|
|
|||
|
|
@ -4538,12 +4538,15 @@
|
|||
"settings.always_2d":"Siempre 2D",
|
||||
"settings.an_early_heads_up_below_60":"Un aviso temprano por debajo del 60 % de felicidad, mucho antes de que estén furiosos.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto dibuja el mapa con tu tarjeta gráfica cuando el navegador lo permite, y así las redes grandes siguen fluidas. Siempre 2D funciona en todas partes, pero va más lento en mapas grandes.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto sigue el ajuste claro u oscuro de tu dispositivo. El oscuro descansa la vista de noche y ahorra batería en pantallas OLED.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto sigue el ajuste de reducir movimiento de tu dispositivo. Desactivado congela el mapa: sin paquetes en movimiento, pulsos ni texto flotante.",
|
||||
"settings.customers_and_alerts":"Clientes y alertas",
|
||||
"settings.dark":"Oscuro",
|
||||
"settings.diagnostic_info":"Información de diagnóstico",
|
||||
"settings.display_and_sound":"Pantalla y sonido",
|
||||
"settings.for_bug_reports_shows_your_screen":"Para informar de fallos: muestra en una esquina el tamaño de tu pantalla, cómo se dibuja el mapa (tarjeta gráfica o 2D, y por qué) y a qué velocidad.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Deja que un agente de IA juegue",
|
||||
"settings.light":"Claro",
|
||||
"settings.map_drawing":"Dibujo del mapa",
|
||||
"settings.n_min":"{n} min",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4557,6 +4560,7 @@
|
|||
"settings.the_agent_moves_it":"Lo mueve el agente",
|
||||
"settings.the_clock_while_an_agent_plays":"El reloj mientras juega un agente",
|
||||
"settings.the_game_stops_so_you_can":"El juego se detiene para que arregles su servicio antes de que cancelen. Muy útil a alta velocidad.",
|
||||
"settings.theme":"Tema",
|
||||
"settings.this_browser_cannot_so_the_map":"Este navegador no puede, así que el mapa se dibuja en 2D.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Avisar cuando un cliente se descontenta",
|
||||
"settings.while_agent_mode_is_on_the":"Mientras el modo agente está activo, el reloj no es tuyo. Con un ritmo, corre solo y no se puede pausar a mano, ni siquiera con una ventana abierta (las tuyas incluidas), y espera mientras no haya ningún agente conectado. O lo mueve el agente, y no pasa nada hasta que pide días. La página se conecta al relay local de agentes (npm run dev trae uno), para que herramientas como el servidor MCP jueguen esta partida mientras miras.",
|
||||
|
|
|
|||
|
|
@ -4538,12 +4538,15 @@
|
|||
"settings.always_2d":"Toujours en 2D",
|
||||
"settings.an_early_heads_up_below_60":"Une alerte précoce sous 60 % de satisfaction, bien avant qu’il soit furieux.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto dessine la carte avec ta carte graphique quand le navigateur le permet, ce qui garde les grands réseaux fluides. Toujours en 2D marche partout mais rame sur les grandes cartes.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto suit le réglage clair ou sombre de ton appareil. Le sombre repose les yeux la nuit et économise la batterie sur les écrans OLED.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto suit le réglage « réduire les animations » de ton appareil. Inactif fige la carte : plus de paquets en mouvement, de pulsations ni de texte flottant.",
|
||||
"settings.customers_and_alerts":"Clients et alertes",
|
||||
"settings.dark":"Sombre",
|
||||
"settings.diagnostic_info":"Infos de diagnostic",
|
||||
"settings.display_and_sound":"Affichage et son",
|
||||
"settings.for_bug_reports_shows_your_screen":"Pour signaler un bug : affiche dans un coin la taille de ton écran, comment la carte est dessinée (carte graphique ou 2D, et pourquoi) et à quelle vitesse.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Laisser un agent IA jouer",
|
||||
"settings.light":"Clair",
|
||||
"settings.map_drawing":"Dessin de la carte",
|
||||
"settings.n_min":"{n} min",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4557,6 +4560,7 @@
|
|||
"settings.the_agent_moves_it":"L'agent l'avance",
|
||||
"settings.the_clock_while_an_agent_plays":"L'horloge pendant qu'un agent joue",
|
||||
"settings.the_game_stops_so_you_can":"Le jeu s’arrête pour que tu répares leur service avant qu’ils résilient. Surtout utile à grande vitesse.",
|
||||
"settings.theme":"Thème",
|
||||
"settings.this_browser_cannot_so_the_map":"Ce navigateur ne peut pas, la carte est donc dessinée en 2D.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Prévenir quand un client devient mécontent",
|
||||
"settings.while_agent_mode_is_on_the":"Tant que le mode agent est actif, l'horloge n'est plus à toi. Avec un rythme, elle tourne toute seule et ne peut pas être mise en pause à la main, pas même par une fenêtre ouverte (les tiennes comprises), et elle attend tant qu'aucun agent n'est connecté. Ou bien c'est l'agent qui l'avance, et rien ne se passe tant qu'il ne demande pas de jours. La page se connecte au relais local pour agents (npm run dev en lance un), pour que des outils comme le serveur MCP jouent cette partie pendant que tu regardes.",
|
||||
|
|
|
|||
|
|
@ -4538,12 +4538,15 @@
|
|||
"settings.always_2d":"Sempre 2D",
|
||||
"settings.an_early_heads_up_below_60":"Un avviso in anticipo sotto il 60% di soddisfazione, molto prima che siano furiosi.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto disegna la mappa con la tua scheda grafica quando il browser lo consente, così anche le reti grandi restano fluide. Sempre 2D funziona ovunque ma è più lento sulle mappe grandi.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto segue l’impostazione chiara o scura del tuo dispositivo. Lo scuro riposa gli occhi di notte e fa risparmiare batteria sugli schermi OLED.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto segue l’impostazione “riduci movimento” del tuo dispositivo. Off congela la mappa: niente pacchetti in movimento, pulsazioni o testo fluttuante.",
|
||||
"settings.customers_and_alerts":"Clienti e avvisi",
|
||||
"settings.dark":"Scuro",
|
||||
"settings.diagnostic_info":"Info di diagnostica",
|
||||
"settings.display_and_sound":"Schermo e audio",
|
||||
"settings.for_bug_reports_shows_your_screen":"Per segnalare bug: mostra in un angolo le dimensioni dello schermo, come viene disegnata la mappa (scheda grafica o 2D, e perché) e a che velocità.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Lascia giocare un agente IA",
|
||||
"settings.light":"Chiaro",
|
||||
"settings.map_drawing":"Disegno della mappa",
|
||||
"settings.n_min":"{n} min",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4557,6 +4560,7 @@
|
|||
"settings.the_agent_moves_it":"Lo muove l'agente",
|
||||
"settings.the_clock_while_an_agent_plays":"L'orologio mentre gioca un agente",
|
||||
"settings.the_game_stops_so_you_can":"Il gioco si ferma così puoi sistemare il servizio prima che disdicano. Utilissimo ad alta velocità.",
|
||||
"settings.theme":"Tema",
|
||||
"settings.this_browser_cannot_so_the_map":"Questo browser non può, quindi la mappa è disegnata in 2D.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Avvisa quando un cliente diventa scontento",
|
||||
"settings.while_agent_mode_is_on_the":"Finché la modalità agente è attiva, l'orologio non è tuo. Con un ritmo va da solo e non si può fermare a mano, nemmeno con una finestra aperta (comprese le tue), e aspetta finché non è collegato nessun agente. Oppure lo muove l'agente, e non succede nulla finché non chiede dei giorni. La pagina si collega al relay locale per agenti (npm run dev ne avvia uno), così strumenti come il server MCP possono giocare questa partita mentre guardi.",
|
||||
|
|
|
|||
|
|
@ -4538,12 +4538,15 @@
|
|||
"settings.always_2d":"Sempre 2D",
|
||||
"settings.an_early_heads_up_below_60":"Um aviso antecipado abaixo de 60% de satisfação, bem antes de ficarem furiosos.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto desenha o mapa com sua placa de vídeo quando o navegador permite, o que mantém redes grandes fluidas. Sempre 2D funciona em qualquer lugar, mas é mais lento em mapas grandes.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto segue a configuração clara ou escura do seu aparelho. O escuro descansa os olhos à noite e economiza bateria em telas OLED.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto segue a configuração de reduzir movimento do seu aparelho. Desligado congela o mapa: sem pacotes andando, pulsos ou texto flutuante.",
|
||||
"settings.customers_and_alerts":"Clientes e alertas",
|
||||
"settings.dark":"Escuro",
|
||||
"settings.diagnostic_info":"Informações de diagnóstico",
|
||||
"settings.display_and_sound":"Tela e som",
|
||||
"settings.for_bug_reports_shows_your_screen":"Para reportar bugs: mostra em um canto o tamanho da sua tela, como o mapa é desenhado (placa de vídeo ou 2D, e por quê) e a que velocidade.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Deixa um agente de IA jogar",
|
||||
"settings.light":"Claro",
|
||||
"settings.map_drawing":"Desenho do mapa",
|
||||
"settings.n_min":"{n} min",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4557,6 +4560,7 @@
|
|||
"settings.the_agent_moves_it":"O agente move-o",
|
||||
"settings.the_clock_while_an_agent_plays":"O relógio enquanto um agente joga",
|
||||
"settings.the_game_stops_so_you_can":"O jogo para para você consertar o serviço antes que cancelem. Muito útil em alta velocidade.",
|
||||
"settings.theme":"Tema",
|
||||
"settings.this_browser_cannot_so_the_map":"Este navegador não consegue, então o mapa é desenhado em 2D.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Avisar quando um cliente ficar insatisfeito",
|
||||
"settings.while_agent_mode_is_on_the":"Enquanto o modo agente estiver ligado, o relógio não é teu. Com um ritmo, corre sozinho e não pode ser parado à mão, nem por uma janela aberta (as tuas incluídas), e espera enquanto nenhum agente estiver ligado. Ou é o agente que o move, e nada acontece até ele pedir dias. A página liga-se ao relay local de agentes (npm run dev traz um), para que ferramentas como o servidor MCP joguem este jogo enquanto vês.",
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ const API_DENY={
|
|||
start:'start',newgame:'start',cont:'start',toTitle:'start',resetAsk:'start',
|
||||
exportSave:'files',importGo:'files',importPick:'files',slotExport:'files',
|
||||
slotBack:'slots',slotDel:'slots',slotDelGo:'slots',slotMenu:'slots',slotRetry:'slots',slotSpace:'slots',slotSwitch:'slots',slotTake:'slots',
|
||||
animSet:'prefs',langSet:'prefs',mapSet:'prefs',menu:'prefs',mute:'prefs',prefSet:'prefs',settings:'prefs',settingsClose:'prefs',soundSet:'prefs',vpSet:'prefs',
|
||||
animSet:'prefs',langSet:'prefs',mapSet:'prefs',menu:'prefs',mute:'prefs',prefSet:'prefs',settings:'prefs',settingsClose:'prefs',soundSet:'prefs',themeSet:'prefs',vpSet:'prefs',
|
||||
mpDoor:'mp',mpBack:'mp',mpStart:'mp',mpJoin:'mp',mpOpen:'mp',mpShare:'mp',mpCopyLink:'mp',mpChat:'mp',mpLeaveAsk:'mp',mpLeave:'mp',mpNewer:'mp',mpKeep:'mp',
|
||||
install:'browser',share:'browser',shareDl:'browser',shareGo:'browser',traceCopy:'browser',updateLater:'browser',updateNow:'browser',wsShare:'browser',pzShare:'browser',
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function confTick(d){S.confReg=S.confReg||{};
|
|||
toast(tr('conferences.conf_in_city_you_shook_a',{conf:esc(cf.n),city:esc(CITY[cf.c].name),n:CONF_DAYS,region:esc(REG[reg])})+(sp?' '+tr('conferences.your_logo_was_on_every_lanyard',{region:esc(REG[reg])}):'')+(cf.cap?' '+tr('conferences.carriers_took_your_card_expect_big'):'')+extra,'goal');sfx('coin');}
|
||||
capDealTick(d);}
|
||||
function confSection(){const up=upcomingConfs(75).slice(0,3),cb=S.conf&&S.conf.until>S.day?S.conf:null;if(!up.length&&!cb)return '';
|
||||
return `<h3 style="font-size:15px;margin:10px 0 4px">${tr('common.conferences')}</h3>${cb?`<div class="inc" style="background:#EAF7EE"><div class="nm">${tr('conferences.name_glow_n_days_left',{name:esc(cb.name),n:cb.until-S.day})}</div><div class="meta">${tr('conferences.selective_networks_in_region_need',{region:esc(REG[cb.reg])})}${cb.sp?' '+tr('conferences.as_a_sponsor_you_also_get',{region:esc(REG[cb.reg])}):''}</div></div>`:''}${up.map(confRow).join('')}`;}
|
||||
return `<h3 style="font-size:15px;margin:10px 0 4px">${tr('common.conferences')}</h3>${cb?`<div class="inc" style="background:var(--tint-g,#EAF7EE)"><div class="nm">${tr('conferences.name_glow_n_days_left',{name:esc(cb.name),n:cb.until-S.day})}</div><div class="meta">${tr('conferences.selective_networks_in_region_need',{region:esc(REG[cb.reg])})}${cb.sp?' '+tr('conferences.as_a_sponsor_you_also_get',{region:esc(REG[cb.reg])}):''}</div></div>`:''}${up.map(confRow).join('')}`;}
|
||||
function confRow(cf){const reg=S.confReg&&S.confReg[cf.key],open=cf.day>S.day,sp=confSp(cf),cost=confCost(cf),lk=cf.cap&&glassLvl()<CAP_LV;
|
||||
const tags=(reg==='sp'?'<span class="tag st on">'+tr('conferences.sponsor')+'</span>':reg?'<span class="tag st on">'+tr('common.registered')+'</span>':open?'':'<span class="tag st">'+tr('common.registration_closed')+'</span>');
|
||||
const btns=!open||reg==='sp'?'':(reg?'':lk?btn(tr('sites_and_service.level_n',{n:CAP_LV}),'confGo',{key:cf.key},'sm',true):btn(tr('conferences.attend_cost',{cost:fmt$(cost)}),'confGo',{key:cf.key},'sm',S.cash<cost))+(sp?btn(tr('conferences.sponsor_cost',{cost:fmt$(CONF_SP-(reg?CONF_COST:0))}),'confSponsor',{key:cf.key},'pink sm',S.cash<CONF_SP-(reg?CONF_COST:0)):'');
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ function seatOffer(c,d){const rs=(c?SEAT_ROUTES[c]||[]:Object.values(SEAT_ROUTES
|
|||
if(!rs.length)return null;const r=rs[hstr(S.asn+'|seat|'+d)%rs.length];return {a:r[0],b:r[1],name:r[2],km:seatKm(r[0],r[1]),exp:d+SEAT_EXP};}
|
||||
function seatConf(c){if(S.seatOff||lvl()<SEAT_LV||S.scn)return;S.seatOff=seatOffer(c,S.day);if(S.seatOff)toast(tr('specialist.a_consortium_is_selling_seats_on',{name:esc(S.seatOff.name),a:CITY[S.seatOff.a].name,b:CITY[S.seatOff.b].name}),'goal',[{l:tr('common.show_me'),act:'leftTab',args:{t:'deals'}}]);}
|
||||
function seatSection(){const o=S.seatOff;if(!o||o.exp<=S.day)return '';const pop=[o.a,o.b].filter(c=>!S.pops[c]).reduce((x,c)=>x+newPopCost(c),0);
|
||||
return `<div class="inc" style="background:#E6F4FF"><div class="nm">🚢 ${tr('specialist.consortium_seat_name',{name:esc(o.name)})}</div><div class="meta">${tr('specialist.a_b_km_km_ready_in',{a:CITY[o.a].name,b:CITY[o.b].name,km:o.km.toLocaleString(),n:seatDays(o.km),ms:linkLat({kind:'df',own:true,sub:true,km:o.km,seaDesign:'standard'}).toFixed(1)})} · ${tr('ui.n_d_left',{n:o.exp-S.day})}</div>
|
||||
return `<div class="inc" style="background:var(--tint-b,#E6F4FF)"><div class="nm">🚢 ${tr('specialist.consortium_seat_name',{name:esc(o.name)})}</div><div class="meta">${tr('specialist.a_b_km_km_ready_in',{a:CITY[o.a].name,b:CITY[o.b].name,km:o.km.toLocaleString(),n:seatDays(o.km),ms:linkLat({kind:'df',own:true,sub:true,km:o.km,seaDesign:'standard'}).toFixed(1)})} · ${tr('ui.n_d_left',{n:o.exp-S.day})}</div>
|
||||
<div class="meta">${tr('specialist.your_own_fiber_pairs_on_a')}${pop?' '+tr('specialist.includes_pops_at_the_landings_price',{price:fmt$(pop)}):''}</div>
|
||||
<div class="btns">${SEAT_N.map(n=>{const c=seatCost(o.km,n)+pop;return btn(`${trn('specialist.n_fiber_pairs',n)} <small>${fmt$(c)} · ${tr('common.price_mo',{price:fmt$(seatMo(o.km,n))})}</small>`,'seatBuy',{n},'sm',S.cash<c);}).join('')}${btn(tr('common.decline'),'seatNo',{},'ghost sm')}</div></div>`;}
|
||||
function seatPanel(l){if(!l.seat)return '';return `<div class="kv"><span>${tr('specialist.consortium_seat')}</span><b>${esc(l.cname||'')} · ${trn('specialist.n_fiber_pairs',Math.max(1,l.pairs|0))}</b></div><p class="note">${tr('specialist.the_consortium_runs_the_cable_your')}</p>`;}
|
||||
|
|
@ -97,8 +97,8 @@ function charterAsk(){if(!charterDue()||!$('modal').hidden||window.__TUBES_TEST_
|
|||
function charterCard(){if(S.scn||S.mode!=='normal')return '';
|
||||
if(broker())return baronCard();
|
||||
if(charter()!=='boutique')return '';
|
||||
if(S.solWon)return `<div class="inc" style="background:#EAF7EE"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.won_on_date_your_own_glass',{date:dateStr(S.solWon)})}</div></div>`;
|
||||
const r=solRoutes();return `<div class="inc" style="background:#EEF0FF"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.routes_r_of_n_beat_the',{r:Math.min(r.length,SOL_ROUTES),n:SOL_ROUTES,c:Math.min(solCust(),SOL_CUST),m:SOL_CUST})}</div>${r.slice(0,SOL_ROUTES).map(x=>`<div class="meta">✓ ${CITY[x.a].name} ⇄ ${CITY[x.b].name}: ${tr('common.ms_ms_one_way',{ms:x.o.toFixed(1)})} < ${x.l.toFixed(1)}</div>`).join('')}</div>`;}
|
||||
if(S.solWon)return `<div class="inc" style="background:var(--tint-g,#EAF7EE)"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.won_on_date_your_own_glass',{date:dateStr(S.solWon)})}</div></div>`;
|
||||
const r=solRoutes();return `<div class="inc" style="background:var(--tint-v,#EEF0FF)"><div class="nm">⚡ ${tr('specialist.speed_of_light')}</div><div class="meta">${tr('specialist.routes_r_of_n_beat_the',{r:Math.min(r.length,SOL_ROUTES),n:SOL_ROUTES,c:Math.min(solCust(),SOL_CUST),m:SOL_CUST})}</div>${r.slice(0,SOL_ROUTES).map(x=>`<div class="meta">✓ ${CITY[x.a].name} ⇄ ${CITY[x.b].name}: ${tr('common.ms_ms_one_way',{ms:x.o.toFixed(1)})} < ${x.l.toFixed(1)}</div>`).join('')}</div>`;}
|
||||
// Once a day: seats expire or call, the boutique checks its win and carriers call the broker.
|
||||
function specDay(d){if(broker())brokerDay(d);if(S.seatOff&&S.seatOff.exp<=d)S.seatOff=null;
|
||||
if(!S.seatOff&&!S.scn&&S.mode!=='puzzle'&&lvl()>=SEAT_LV&&hstr(S.asn+'|seatcall|'+d)%SEAT_ODDS===0)seatConf(null);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ function glassChain(g){const by={};for(const l of S.links)if(ownGlassL(l)&&dfCap
|
|||
return Object.values(by).some(s=>s.size>=2);}
|
||||
const baronOk=()=>cableConts()>=BARON_CONT&&capSalesMo()>=BARON_MO;
|
||||
// On the goals tab, under the charter: how far Glass Baron is.
|
||||
function baronCard(){if(S.baronWon)return `<div class="inc" style="background:#EAF7EE"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.won_on_date',{date:dateStr(S.baronWon)})}</div></div>`;
|
||||
return `<div class="inc" style="background:#E6F4FF"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.progress',{c:Math.min(cableConts(),BARON_CONT),n:BARON_CONT,mo:fmt$(capSalesMo()),m:fmt$(BARON_MO)})}</div></div>`;}
|
||||
function baronCard(){if(S.baronWon)return `<div class="inc" style="background:var(--tint-g,#EAF7EE)"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.won_on_date',{date:dateStr(S.baronWon)})}</div></div>`;
|
||||
return `<div class="inc" style="background:var(--tint-b,#E6F4FF)"><div class="nm">🌊 ${tr('broker.glass_baron')}</div><div class="meta">${tr('broker.progress',{c:Math.min(cableConts(),BARON_CONT),n:BARON_CONT,mo:fmt$(capSalesMo()),m:fmt$(BARON_MO)})}</div></div>`;}
|
||||
function showBaronWin(){openModal(`<h1 style="font-family:var(--display);font-size:40px;margin:0">🌊 ${tr('broker.glass_baron')}</h1><p class="tagline">${tr('broker.win_text',{name:esc(S.name),asn:S.asn,days:S.day,n:BARON_CONT,mo:fmt$(capSalesMo())})}</p><div class="btns">${btn(tr('help.share_my_network'),'share',{},'pink')}${btn(tr('common.keep_playing'),'closeModal',{},'ghost')}</div>`);}
|
||||
/* Carriers call the broker now and then (about three times a year, from day 60) with a capacity deal on a route the
|
||||
capacity conferences trade: the same deals at the same terms, without the trip. Picked by a hash of the day, so a
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ function ddosDone(a){if(!a||a.done)return;a.done=1;if(a.worst===undefined&&S.pop
|
|||
function ddosPanel(){return S?ddosAll().filter(a=>S.pops[a.city]).map(ddosOne).join(''):'';}
|
||||
const ddCities=l=>{const u=[...new Set(l)];return u.slice(0,3).map(c=>CITY[c].name).join(', ')+(u.length>3?' +'+(u.length-3):'');};
|
||||
function ddosOne(a){const V=DDOS_VEC[a.vec]||{n:'?',fs:false},m=ddosReport(a),row=(ok,t)=>`<div class="meta">${ok===true?'✓':ok===false?'~':'—'} ${t}</div>`;
|
||||
let h=`<div class="inc ddos" style="background:#FFE2E6;border:1px solid #FF8A9A"><div class="nm">🚨 ${tr('ddos.card_title',{g:fmtG(a.gbps),vec:esc(V.n)})}</div>
|
||||
let h=`<div class="inc ddos" style="background:var(--tint-r,#FFE2E6);border:1px solid #FF8A9A"><div class="nm">🚨 ${tr('ddos.card_title',{g:fmtG(a.gbps),vec:esc(V.n)})}</div>
|
||||
<div class="meta"><b>${esc(ddosWho(a))}</b> · ${tr('ui.n_d_left',{n:Math.max(1,a.until-S.day)})}${a.carpet?' · '+tr('ddos.carpet'):''}</div>`;
|
||||
if(!m)return h+'</div>';
|
||||
const engIdle=hasScrub()&&!a.bh&&m.eng<1&&S.scrubMode==='ondemand'&&S.ddosAuto&&S.ddosAuto.scrub===false&&a.eng===undefined;
|
||||
|
|
|
|||
|
|
@ -50,4 +50,4 @@ function mkLeave(why){const M=S.monkey,d=S.day,ok=!why&&M.n>0&&M.hurt===0;M.on=0
|
|||
if(typeof mkEnd==='function')mkEnd(ok,true);}
|
||||
// The NOC tab's card while it is here.
|
||||
function mkCard(){if(!mkOn())return '';const M=S.monkey,c=mkBananaCost();
|
||||
return `<div class="inc" style="background:#FFF1D6;border:1px solid #FFC56B"><div class="nm">🐒 ${tr('chaos_monkey.loose')}</div><div class="meta">${tr('chaos_monkey.card',{n:Math.max(1,M.until-S.day),s:M.n,hurt:M.hurt})}</div><div class="btns">${btn(tr('chaos_monkey.banana',{cost:fmt$(c)}),'mkBanana',{},'sm',S.cash<c)}</div></div>`;}
|
||||
return `<div class="inc" style="background:var(--tint-o,#FFF1D6);border:1px solid #FFC56B"><div class="nm">🐒 ${tr('chaos_monkey.loose')}</div><div class="meta">${tr('chaos_monkey.card',{n:Math.max(1,M.until-S.day),s:M.n,hurt:M.hurt})}</div><div class="btns">${btn(tr('chaos_monkey.banana',{cost:fmt$(c)}),'mkBanana',{},'sm',S.cash<c)}</div></div>`;}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ const ACT={
|
|||
leaseSwap:({a,b,src})=>{if(!S.pops[a]||!S.pops[b]||a===b)return;$('dash').hidden=true;UI.lmode='df';UI.dfSrc=['lease','build','cable'].includes(src)?src:isSub(a,b)?'cable':'build';UI.dfSys=glassLvl()>=3?'roadm':'lite';openLinkModal(a,b);},
|
||||
dashLink:({id})=>{$('dash').hidden=true;selectLink(id);focusLink(id);},
|
||||
mapSet:({v})=>{if(!['auto','2d'].includes(v))return;mapGl(v==='auto');refreshSettings();},
|
||||
themeSet:({v})=>{if(!themePick(v))return;refreshSettings();},
|
||||
animSet:({v})=>{if(!['auto','on','off'].includes(v))return;UI.anim=v;try{localStorage.setItem('sot-anim',v);}catch(e){}applyAnim();refreshSettings();},
|
||||
soundSet:({v})=>{UI.muted=v==='off';try{localStorage.setItem('sot-mute',UI.muted?'1':'0');}catch(e){}renderHUD();refreshSettings();},
|
||||
langSet:({v})=>{if(!Object.hasOwn(LANGS,v)||v===LANG)return;try{localStorage.setItem('sot-lang',v);}catch(e){}save(true);location.reload();},
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ Object.assign(ACT,{
|
|||
// open anything in it. Everything but these and the pz* actions does nothing while a puzzle is on. The main game's
|
||||
// routing controls (metric, standby, the redundancy check) work in a puzzle too, and their changes can be undone.
|
||||
// This file is the last of the actions, so every one is here to wrap.
|
||||
const PZ_ACTS=new Set(['animSet','closeModal','closePanel','help','helpClose','install','keepPlaying','langSet','linkCheck','mapSet','menu','metricMode','metricSet','mute','prefSet','puzzleDoor','puzzleMenu','selLink','setMetric','setStandby','settings','settingsClose','soundSet','speed','updateLater','updateNow','vpSet','whatsNewShow']);
|
||||
const PZ_ACTS=new Set(['animSet','closeModal','closePanel','help','helpClose','install','keepPlaying','langSet','linkCheck','mapSet','menu','metricMode','metricSet','mute','prefSet','puzzleDoor','puzzleMenu','selLink','setMetric','setStandby','settings','settingsClose','soundSet','speed','themeSet','updateLater','updateNow','vpSet','whatsNewShow']);
|
||||
const PZ_UNDO=new Set(['metricMode','metricSet','setMetric','setStandby']);
|
||||
for(const k of Object.keys(ACT)){const f=ACT[k];if(PZ_UNDO.has(k))ACT[k]=a=>{if(pzOn())pzSnap();return f(a);};else if(!PZ_ACTS.has(k)&&!/^pz[A-Z]/.test(k))ACT[k]=a=>pzOn()?undefined:f(a);}
|
||||
|
|
|
|||
27
src/game/93-ui/15-theme.js
Normal file
27
src/game/93-ui/15-theme.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ---------- Light or dark (#80) ----------
|
||||
Settings › Theme: Auto follows the device's light or dark setting, or the player picks one. A choice per device
|
||||
(localStorage sot-theme, like the animation and map settings), not part of the save. The page's <head> reads it and
|
||||
sets <html data-theme> before the first paint, so a dark screen never flashes light; this keeps it in step when the
|
||||
choice or the device's setting changes. The panels follow at once (CSS custom properties, 00-base.css); the map
|
||||
keeps pictures painted in the old colours, so it paints them again, once (themeRepaint()). */
|
||||
const THEME_OPTS=['auto','light','dark'],THEME_BAR={light:'#57C4E5',dark:'#0E2A44'}; // the browser bar: --sea
|
||||
const THEME={pref:'auto',dark:false,mq:null,on:null};
|
||||
function themeRead(){let v=null;try{v=localStorage.getItem('sot-theme');}catch(e){}return THEME_OPTS.includes(v)?v:'auto';}
|
||||
const themeSys=()=>{try{return !!(THEME.mq&&THEME.mq.matches);}catch(e){return false;}};
|
||||
// The page's colours from the choice (and the device's setting, on Auto). A switch repaints the map's cached pictures.
|
||||
function themeApply(repaint=true){const dark=THEME.pref==='dark'||(THEME.pref==='auto'&&themeSys()),was=THEME.dark,R0=document.documentElement;
|
||||
THEME.dark=dark;R0.setAttribute('data-theme',dark?'dark':'light');
|
||||
for(const [n,v] of [['theme-color',THEME_BAR[dark?'dark':'light']],['color-scheme',dark?'dark':'light']]){const m=document.querySelector(`meta[name="${n}"]`);if(m)m.setAttribute('content',v);}
|
||||
if(repaint&&was!==dark)themeRepaint();return dark;}
|
||||
function themePick(v){if(!THEME_OPTS.includes(v))return false;THEME.pref=v;try{v==='auto'?localStorage.removeItem('sot-theme'):localStorage.setItem('sot-theme',v);}catch(e){}themeApply();return true;}
|
||||
// Reads the choice and listens to the device's setting, which Auto follows as it changes (a phone at dusk).
|
||||
function themeInit(){THEME.pref=themeRead();THEME.on=()=>{if(THEME.pref==='auto')themeApply();};
|
||||
try{THEME.mq=window.matchMedia?matchMedia('(prefers-color-scheme: dark)'):null;}catch(e){}
|
||||
const q=THEME.mq;if(q){try{q.addEventListener?q.addEventListener('change',THEME.on):q.addListener(THEME.on);}catch(e){}}
|
||||
THEME.dark=document.documentElement.getAttribute('data-theme')==='dark';return themeApply(false);}
|
||||
/* What the map painted in the old colours: the land (the 2D picture, the card's coastlines), every sprite (labels,
|
||||
cities), the Pie globe unless the player chose its day or night. All painted again on the next frame, not every frame. */
|
||||
function themeRepaint(){WL.key=null;FRAME.length=0;UI.drawnAt=0;spritesReset();glLandDrop();
|
||||
let g=null;try{g=localStorage.getItem('sot-globe');}catch(e){}if(!g){PG.night=THEME.dark;PG.g=null;PG.dirty=true;}}
|
||||
// Picked in another tab: this one follows, and so does the NOC window on a second screen.
|
||||
if(!RW_IN){themeInit();addEventListener('storage',e=>{if(e.key==='sot-theme'||e.key===null){THEME.pref=themeRead();themeApply();}});}
|
||||
|
|
@ -8,7 +8,7 @@ function installRow(){if(isStandalone())return '';
|
|||
return `<div class="row icard"><div class="grow"><div class="nm">📲 ${tr('install.best_played_as_an_app')}</div><div class="meta">${tr('install.full_screen_works_offline_one_tap')}${isIOS()?' '+tr('install.install_it_before_you_start_a'):''}</div></div>${btn(tr('common.install'),'install',{},'pink sm')}</div>`;}
|
||||
/* Phones get a real pitch before a new game: an installed app is full screen, works offline, and on iPhone
|
||||
keeps its save away from Safari's clean-ups. Storage is separate on iOS, so installing first matters. */
|
||||
const SHARE_SVG='<svg width="16" height="18" viewBox="0 0 16 18" aria-hidden="true"><path d="M8 1v10M4.5 4.5 8 1l3.5 3.5M5 7H2.5v9.5h11V7H11" fill="none" stroke="#1E2640" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
||||
const SHARE_SVG='<svg width="16" height="18" viewBox="0 0 16 18" aria-hidden="true"><path d="M8 1v10M4.5 4.5 8 1l3.5 3.5M5 7H2.5v9.5h11V7H11" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
||||
const needPitch=()=>isPhone()&&!isStandalone();
|
||||
function installSteps(){
|
||||
if(isIOS())return `<ol class="isteps"><li>${tr('install.tap_share_icon_in_the_browser',{icon:SHARE_SVG})}</li><li>${tr('install.tap_add_to_home_screen_you')}</li><li>${tr('install.open_series_of_tubes_from_your')}</li></ol>`;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ function renderLeft(){checkLayer();
|
|||
}else if(UI.left==='deals'){
|
||||
{const st=custStats();if(st.n)h+=`<div class="row" style="margin-bottom:8px"><div class="grow"><div class="nm">${tr('common.your_customers')} <span class="meta">${st.n} · ${tr('hud_and_panels.happiness_p',{p:Math.round(st.avg)})}</span></div><div class="bar ${moodCls(st.avg)}"><i style="width:${st.avg}%"></i></div>${st.unhappy?`<div class="why">${trn('hud_and_panels.n_unhappy_customer_price_mo_at',st.unhappy,{price:fmt$(st.risk)})}</div>`:''}</div>${btn(st.unhappy?tr('common.see_who'):tr('common.all_customers'),'custOpen',{sad:st.unhappy?1:0},st.unhappy?'pink sm':'ghost sm')}</div>`;}
|
||||
h+=salesCard()+clDealsHtml()+confSection()+seatSection();
|
||||
{const lv=S.lvl||1,nx=LEVELS[lv];h+=`<div class="inc" style="background:#FFF6CF"><div class="nm">${tr('hud_and_panels.customer_level_lv_name',{lv,name:LEVELS[lv-1].n})}</div><div class="meta">${nx?tr('hud_and_panels.next_req_unlocks_what',{req:nx.req,what:lc1(nx.unlock)}):tr('common.every_customer_type_is_unlocked_go')}</div></div>`;}
|
||||
{const lv=S.lvl||1,nx=LEVELS[lv];h+=`<div class="inc" style="background:var(--tint-y,#FFF6CF)"><div class="nm">${tr('hud_and_panels.customer_level_lv_name',{lv,name:LEVELS[lv-1].n})}</div><div class="meta">${nx?tr('hud_and_panels.next_req_unlocks_what',{req:nx.req,what:lc1(nx.unlock)}):tr('common.every_customer_type_is_unlocked_go')}</div></div>`;}
|
||||
if(!S.offers.length)h+=`<p class="empty">${tr('hud_and_panels.no_open_offers_right_now_businesses')}</p>`;
|
||||
for(const o of S.offers.slice().sort((a,b)=>a.exp-b.exp)){const has=bHas(o);
|
||||
h+=`<div class="row"><div class="grow"><div class="nm">${esc(o.name)}</div><div class="meta">${esc(BIZ_T[o.type].l)} · ${CITY[o.city].name}${o.city2?' ⇄ '+CITY[o.city2].name:''} · <b>${bTerms(o)}</b> · ${tr('ui.n_d_left',{n:o.exp-S.day})}${(o.reqs||[]).length?` · ${trn('hud_and_panels.n_special_requirement',o.reqs.length)}`:''}</div>${o.refN?`<div class="meta">${tr('lifecycle.referred_by',{name:esc(o.refN)})}</div>`:''}${spotWhy(o)}${bRisk(o)}${reqList(o)}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function linkTrial(id){const save=S,live=R,hot=UI.hotMap,cache=TE_CACHE;
|
|||
}finally{S=save;R=live;UI.hotMap=hot;TE_CACHE=cache;}}
|
||||
function linkCheckModal(l){const t=linkTrial(l.id);if(!t)return;
|
||||
const title=t.split?tr('link_panels.this_backhoe_wins'):t.loss>.01?tr('link_panels.connected_but_tight'):tr('link_panels.one_backhoe_is_not_enough');
|
||||
openModal(`<div style="display:flex;align-items:center;justify-content:space-between;gap:10px"><h2>${tr('common.redundancy_check')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="eyebrow">${esc(CITY[l.a].name)} ⇄ ${esc(CITY[l.b].name)} · ${dateStr(t.day)}</p><div class="inc" style="background:${t.split?'#FFE3E3':t.loss>.01?'#FFF6CF':'#EAF7EE'}"><div class="nm">${title}</div><p class="lead">${t.split?tr('link_panels.no_alternate_backbone_path_connects'):t.loss>.01?tr('link_panels.an_alternate_path_exists_but_current'):tr('link_panels.with_current_demand_and_routing_this')}</p><div class="kv"><span>${tr('link_panels.additional_traffic_lost')}</span><b>${fmtG(t.loss)}</b></div></div>${t.losses.length?`<h3>${tr('common.service_affected')}</h3>${t.losses.map(x=>`<div class="kv"><span>${esc(x.name)}</span><b>−${fmtG(x.g)}</b></div>`).join('')}`:''}${t.busy.length?`<h3>${tr('link_panels.full_links_during_the_test')}</h3>${t.busy.slice(0,6).map(x=>`<div class="kv"><span>${esc(x.name)}</span><b>${fmtG(x.g)} / ${fmtG(x.cap)}</b></div>`).join('')}`:''}<p class="note">${tr('link_panels.snapshot_only_one_selected_link')}</p><div class="btns">${btn(tr('common.close'),'closeModal',{},'ghost')}</div>`,'link-check');}
|
||||
openModal(`<div style="display:flex;align-items:center;justify-content:space-between;gap:10px"><h2>${tr('common.redundancy_check')}</h2><button class="x" data-act="closeModal" aria-label="${tr('common.close')}">×</button></div><p class="eyebrow">${esc(CITY[l.a].name)} ⇄ ${esc(CITY[l.b].name)} · ${dateStr(t.day)}</p><div class="inc" style="background:${t.split?'var(--tint-r,#FFE3E3)':t.loss>.01?'var(--tint-y,#FFF6CF)':'var(--tint-g,#EAF7EE)'}"><div class="nm">${title}</div><p class="lead">${t.split?tr('link_panels.no_alternate_backbone_path_connects'):t.loss>.01?tr('link_panels.an_alternate_path_exists_but_current'):tr('link_panels.with_current_demand_and_routing_this')}</p><div class="kv"><span>${tr('link_panels.additional_traffic_lost')}</span><b>${fmtG(t.loss)}</b></div></div>${t.losses.length?`<h3>${tr('common.service_affected')}</h3>${t.losses.map(x=>`<div class="kv"><span>${esc(x.name)}</span><b>−${fmtG(x.g)}</b></div>`).join('')}`:''}${t.busy.length?`<h3>${tr('link_panels.full_links_during_the_test')}</h3>${t.busy.slice(0,6).map(x=>`<div class="kv"><span>${esc(x.name)}</span><b>${fmtG(x.g)} / ${fmtG(x.cap)}</b></div>`).join('')}`:''}<p class="note">${tr('link_panels.snapshot_only_one_selected_link')}</p><div class="btns">${btn(tr('common.close'),'closeModal',{},'ghost')}</div>`,'link-check');}
|
||||
function linkCheckControl(l){return `<section><h3>${tr('common.redundancy_check')}</h3><p class="note">${tr('link_panels.what_happens_if_this_link_fails')}</p>${btn(tr('common.check_redundancy'),'linkCheck',{id:l.id},'ghost sm',linkDown(l))}</section>`;}
|
||||
// At its own POP a carrier's port always takes that carrier's traffic (25-direct-egress.js). From POPs with no port of it, the
|
||||
// traffic goes to the nearest transit port, or across your network to this one. Only worth asking when something else could take it.
|
||||
|
|
@ -169,7 +169,7 @@ function svgChart(rows,stackKeys,lines,fmtY,id){
|
|||
for(let j=0;j<=3;j++){const v=ymax*j/3,yy=y(v);g+=`<line x1="${L}" x2="${W-Rr}" y1="${yy}" y2="${yy}" stroke="#D5DEEC" stroke-width="1"/><text x="${L-6}" y="${yy+3}" text-anchor="end" font-size="10" fill="#55608A" font-weight="700">${fmtY(v)}</text>`;}
|
||||
const base=rows.map(()=>0);
|
||||
for(const k of stackKeys){const top=rows.map((r,i)=>base[i]+(r[k]||0));let d=`M${x(0)},${y(top[0])}`;for(let i=1;i<rows.length;i++)d+=`L${x(i)},${y(top[i])}`;for(let i=rows.length-1;i>=0;i--)d+=`L${x(i)},${y(base[i])}`;g+=`<path d="${d}Z" fill="${EGC[k][1]}" fill-opacity=".85" stroke="#1E2640" stroke-width=".8"/>`;top.forEach((v,i)=>base[i]=v);}
|
||||
for(const ln of lines){let d='';rows.forEach((r,i)=>{d+=(i?'L':'M')+x(i)+','+y(r[ln.k]||0);});g+=`<path d="${d}" fill="none" stroke="${ln.col}" stroke-width="2.5" ${ln.dash?'stroke-dasharray="5 4"':''} stroke-linejoin="round"/>`;const last=rows[rows.length-1][ln.k]||0;g+=`<circle cx="${x(rows.length-1)}" cy="${y(last)}" r="3.5" fill="${ln.col}" stroke="#1E2640" stroke-width="1.5"/>`;}
|
||||
for(const ln of lines){let d='';rows.forEach((r,i)=>{d+=(i?'L':'M')+x(i)+','+y(r[ln.k]||0);});g+=`<path d="${d}" fill="none" style="stroke:${ln.col}" stroke-width="2.5" ${ln.dash?'stroke-dasharray="5 4"':''} stroke-linejoin="round"/>`;const last=rows[rows.length-1][ln.k]||0;g+=`<circle cx="${x(rows.length-1)}" cy="${y(last)}" r="3.5" style="fill:${ln.col}" stroke="#1E2640" stroke-width="1.5"/>`;}
|
||||
g+=`<text x="${L}" y="${H-5}" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[0].d)}</text><text x="${W-Rr}" y="${H-5}" text-anchor="end" font-size="10" fill="#55608A" font-weight="700">${dateStr(rows[rows.length-1].d)}</text>`;
|
||||
return `<svg class="chart" viewBox="0 0 ${W} ${H}" role="img"${id?` data-ch="${id}"`:''}>${g}</svg>`;}
|
||||
// For a network you currently reach over transit: the cheapest way to move it to peering.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function renderDash(){checkLayer();
|
|||
const tile=(l,v,sub)=>`<div class="tile"><div class="lbl">${l}</div><div class="val">${v}</div>${sub?`<div class="sub">${sub}</div>`:''}</div>`;
|
||||
let h=`<div style="display:flex;align-items:center;gap:10px"><div><div class="eyebrow">AS${S.asn} · ${esc(S.name)} · ${tierLabel()}</div><h2 style="font-size:28px">${tr('common.noc_dashboard')}</h2></div><button class="x" data-act="dashClose" aria-label="${tr('common.close')}">×</button></div>`+dashTabs();const DT=UI.dtab||'overview';if(DT==='overview')h+=`
|
||||
<div class="dgrid">${tile(tr('common.traffic_now'),fmtG(R.served),tr('dashboard.of_g_wanted',{g:fmtG(R.demand)}))}${tile(tr('common.peak'),fmtG(S.stats.peak))}${tile(tr('dashboard.delivered_30_days'),(up*100).toFixed(1)+'%',up>=0.999?tr('dashboard.five_nines_ish'):up>=0.99?tr('dashboard.two_nines_and_change'):tr('dashboard.customers_are_upset'))}${tile(tr('common.peering_ratio'),pct(R.peerShare||0),tr('dashboard.caches_pnis_and_ix'))}${tile(tr('dashboard.monthly_p_l'),`<span style="color:${net>=0?'var(--eye)':'var(--bad)'}">${net>=0?'+':''}${fmt$(net)}</span>`,tr('dashboard.in_in_out_out',{in:fmt$(R.revMo),out:fmt$(R.costMo)}))}${tile(tr('common.incidents'),S.stats.incidents,tr('dashboard.n_shrugged_off',{n:S.stats.survived}))}</div>
|
||||
<div class="dcols"><div class="panel2"><h3>${tr('dashboard.traffic_by_way_out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'#1E2640',dash:true}],v=>fmtCap(Math.round(v)),'traffic')}${chartLegend('traffic',k=>k==='dem'?'':' '+pct((R.egT[k]||0)/tot))}</div>
|
||||
<div class="dcols"><div class="panel2"><h3>${tr('dashboard.traffic_by_way_out')}</h3>${svgChart(rows,['c','p','ix','t','l2'],[{k:'dem',col:'var(--text)',dash:true}],v=>fmtCap(Math.round(v)),'traffic')}${chartLegend('traffic',k=>k==='dem'?'':' '+pct((R.egT[k]||0)/tot))}</div>
|
||||
<div class="panel2"><h3>${tr('dashboard.money_per_month')}</h3>${svgChart(rows,[],[{k:'rev',col:'#16A866'},{k:'cost',col:'#FF4D5E'}],v=>fmt$(v),'money')}${chartLegend('money')}
|
||||
<h3 style="margin-top:8px">${tr('dashboard.where_the_money_goes')}</h3>${Object.entries(R.cost).filter(([k,v])=>v>0).sort((a,b)=>b[1]-a[1]).map(([k,v])=>`<div class="kv"><span>${{pops:tr('dashboard.pops_and_routers'),links:tr('dashboard.waves_and_fiber'),transit:tr('common.transit'),ix:tr('common.ix_ports'),pni:tr('common.pnis'),caches:tr('common.cache_power'),nni:tr('common.fabric_ports'),optical:tr('dashboard.amp_huts_and_spares'),loans:tr('common.loan_repayments'),revshare:tr('dashboard.investor_revenue_share'),extras:tr('dashboard.licenses_and_scrubbing'),wholesale:tr('dashboard.nearly_broadband_network_wholesale'),levy:tr('dashboard.regional_broadband_levy'),pie:tr('pie.costs_row')}[k]||k}</span><b>${tr('common.price_mo',{price:fmt$(v)})}</b></div>`).join('')}</div></div>`;
|
||||
const tT=(R.egT.t||0)||1;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
/* The NOC charts: legend entries switch a series on and off (the scale follows what is left), and hovering or
|
||||
touching a chart shows every visible series on that day. View state only: UI.chartOff is never saved. */
|
||||
const CHARTS={
|
||||
traffic:{stack:['c','p','ix','t','l2'],lines:['dem'],fmt:v=>fmtG(v),name:k=>k==='dem'?tr('common.demand'):EGC[k][0],col:k=>k==='dem'?'#1E2640':EGC[k][1]},
|
||||
traffic:{stack:['c','p','ix','t','l2'],lines:['dem'],fmt:v=>fmtG(v),name:k=>k==='dem'?tr('common.demand'):EGC[k][0],col:k=>k==='dem'?'var(--text)':EGC[k][1]},
|
||||
mix:{stack:['c','p','ix','t'],lines:[],fmt:v=>fmtG(v),name:k=>EGC[k][0],col:k=>EGC[k][1]}, // the Traffic tab's table
|
||||
money:{stack:[],lines:['rev','cost'],fmt:v=>fmt$(v),name:k=>k==='rev'?tr('common.revenue'):tr('common.costs'),col:k=>k==='rev'?'#16A866':'#FF4D5E'}
|
||||
};
|
||||
const chartKeys=C=>[...C.stack,...C.lines];
|
||||
// The demand line's key is a dashed outline, in the line's own colour (dark ink by day, light text at night).
|
||||
function chartLegend(id,label){const C=CHARTS[id],off=(UI.chartOff&&UI.chartOff[id])||{};
|
||||
return `<div class="legend">${chartKeys(C).map(k=>`<button class="lg${off[k]?' off':''}" aria-pressed="${!off[k]}" data-act="chartToggle" data-args="${esc(JSON.stringify({c:id,k}))}"><i style="background:${k==='dem'?'#fff;border-style:dashed':C.col(k)}"></i>${C.name(k)}${label?label(k):''}</button>`).join('')}</div>`;}
|
||||
return `<div class="legend">${chartKeys(C).map(k=>`<button class="lg${off[k]?' off':''}" aria-pressed="${!off[k]}" data-act="chartToggle" data-args="${esc(JSON.stringify({c:id,k}))}"><i style="background:${k==='dem'?`var(--paper);border-style:dashed;border-color:${C.col(k)}`:C.col(k)}"></i>${C.name(k)}${label?label(k):''}</button>`).join('')}</div>`;}
|
||||
Object.assign(ACT,{
|
||||
chartToggle:({c,k})=>{const C=CHARTS[c];if(!C||!chartKeys(C).includes(k))return;
|
||||
const off=((UI.chartOff=UI.chartOff||{})[c]=UI.chartOff[c]||{});if(off[k])delete off[k];else off[k]=1;
|
||||
|
|
|
|||
11
src/game/96-map/15-palette.js
Normal file
11
src/game/96-map/15-palette.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/* The map's colours by theme (#80): the cartoon day, and a night under the same stickers (cities and markers keep
|
||||
theirs; a dark outline round a white sticker reads on either). Both renderers read them when they paint: the 2D map
|
||||
in drawFrame()/paintWorld(), the card in glBegin()/glFrame() (glPal()). Labels: the pill, its text and its edge.
|
||||
What is only an outline turns light at night, or it would vanish into the dark land and sea: the tubes' casing
|
||||
(casing) and a puzzle's stepping-stone ring (via). */
|
||||
const MAP_PAL={
|
||||
light:{sea:'#62CBEA',sea2:'#43AED6',wave:'rgba(255,255,255,.45)',cloud:'rgba(255,255,255,.55)',shadow:'rgba(20,90,130,.35)',sand:'#F8E6A8',land:'#9BDA6C',hill:'#86CB5B',shine:'rgba(255,255,255,.18)',coast:'#1E2640',
|
||||
pill:'#FFFFFF',pillInk:'#1E2640',pillEdge:'#1E2640',halo:'rgba(255,255,255,.85)',casing:'#1E2640',via:'rgba(30,38,64,.7)'},
|
||||
dark:{sea:'#173E5E',sea2:'#0B2440',wave:'rgba(160,210,255,.14)',cloud:'rgba(200,220,255,.1)',shadow:'rgba(0,0,0,.35)',sand:'#4E5440',land:'#2E5A3A',hill:'#284F31',shine:'rgba(255,255,255,.05)',coast:'#081020',
|
||||
pill:'#1A2340',pillInk:'#E9EFFB',pillEdge:'#070B16',halo:'rgba(8,16,32,.85)',casing:'#A9B7D8',via:'rgba(233,239,251,.75)'}};
|
||||
const MPAL=()=>THEME.dark?MAP_PAL.dark:MAP_PAL.light;
|
||||
|
|
@ -31,6 +31,7 @@ function settingsHtml(){const seg=(lab,act,cur,opts,note)=>`<div class="setline"
|
|||
${seg(tr('settings.pause_on_outages_that_hurt'),'prefSet',cur('pauseIncident'),onoff('pauseIncident'),tr('settings.stops_the_game_when_a_failure'))}
|
||||
${seg(tr('settings.quiet_notifications'),'prefSet',cur('quiet'),onoff('quiet'),tr('settings.only_trouble_and_milestones_pop_up'))}
|
||||
<h3 class="sub4">${tr('settings.display_and_sound')}</h3>
|
||||
${seg(tr('settings.theme'),'themeSet',THEME.pref,[['auto',tr('common.auto')],['light',tr('settings.light')],['dark',tr('settings.dark')]],tr('settings.auto_follows_your_device_s_light'))}
|
||||
${seg(tr('common.animations'),'animSet',UI.anim||'auto',[['auto',tr('common.auto')],['on',tr('common.on')],['off',tr('common.off')]],tr('settings.auto_follows_your_device_s_reduce'))}
|
||||
${seg(tr('settings.map_drawing'),'mapSet',GLX.want?'auto':'2d',[['auto',tr('common.auto')],['2d',tr('settings.always_2d')]],tr('settings.auto_draws_the_map_with_your')+(GLX.want&&!glCan()?' '+tr('settings.this_browser_cannot_so_the_map'):''))}
|
||||
${seg(tr('common.sound'),'soundSet',UI.muted?'off':'on',[['on',tr('common.on')],['off',tr('common.off')]])}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ function drawCables(ks){const G=glOn(),z=cam.z,selC=UI.drag&&UI.drag.mode==='lin
|
|||
const ar=arOn();for(const cp of CABLE_PAIRS){const C=CAB[cp.cid],hot=!!selC&&(cp.a===selC||cp.b===selC);if(!hot&&cached&&z<1.7)continue;if(ar&&!hot&&!(arKind(cp.a)&&arKind(cp.b)))continue;const col=cableCol(C);
|
||||
for(const k of ks){const sp=cp.pts.map(p=>toS(p[0],p[1],k));let mn=Infinity,mx=-Infinity;for(const q of sp){if(q[0]<mn)mn=q[0];if(q[0]>mx)mx=q[0];}if(mx<-20||mn>CW+20)continue;
|
||||
if(!G&&(hot||!cached)){ctx.globalAlpha=hot?0.95:0.4;ctx.strokeStyle=col;ctx.lineWidth=hot?3:1.6;ctx.lineJoin='round';ctx.setLineDash(C.age==='old'?[6,5]:[]);ctx.beginPath();ctx.moveTo(sp[0][0],sp[0][1]);for(let i=1;i<sp.length;i++)ctx.lineTo(sp[i][0],sp[i][1]);ctx.stroke();ctx.setLineDash([]);}
|
||||
if((hot||(z>=1.7&&!ar))&&lbOk(sp[Math.floor(sp.length/2)][0],sp[Math.floor(sp.length/2)][1]-8,labW(C.name),sp,hot)){const m=sp[Math.floor(sp.length/2)];ctx.globalAlpha=hot?1:0.75;textStamp(C.name,ctx.font,10,labW(C.name),col,'rgba(255,255,255,.85)',3,m[0],m[1]-8);}
|
||||
if((hot||(z>=1.7&&!ar))&&lbOk(sp[Math.floor(sp.length/2)][0],sp[Math.floor(sp.length/2)][1]-8,labW(C.name),sp,hot)){const m=sp[Math.floor(sp.length/2)];ctx.globalAlpha=hot?1:0.75;textStamp(C.name,ctx.font,10,labW(C.name),col,MPAL().halo,3,m[0],m[1]-8);}
|
||||
ctx.globalAlpha=1;}}}
|
||||
function bezGeom(l,at){const A=CITY[l.a],B=CITY[l.b];const i=at!==undefined?at:lineIdx(l);const key=l.id+'|b'+i;const hit=GEO.get(key);if(hit)return hit;
|
||||
const bx=A.x+wrapDx(A.x,B.x),by=B.y;const dx=bx-A.x,dy=by-A.y,len=Math.hypot(dx,dy)||1;let nx=-dy/len,ny=dx/len;if(ny>0){nx=-nx;ny=-ny;}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@
|
|||
the 2D map paints them (drawFrame(), paintWorld()) and in the same colours. The land and the cables are geometry
|
||||
built once, so panning and zooming repaint nothing; only the waves and the clouds move. */
|
||||
const glPm=s=>{const [r,g,b,a]=glColor(s);return [r*a,g*a,b*a,a];}; // premultiplied, as the card blends
|
||||
const SEA_TOP=glPm('#62CBEA'),SEA_BOT=glPm('#43AED6'),CLOUD_COL=glPm('rgba(255,255,255,.55)');
|
||||
const LAND_SHADOW=glPm('rgba(20,90,130,.35)'),LAND_GRASS=glPm('#9BDA6C'),HILL_COL=glPm('#86CB5B'),HILL_SHINE=glPm('rgba(255,255,255,.18)');
|
||||
// The theme's colours (MPAL(), 15-palette.js) as the card takes them, worked out again only when the theme changes.
|
||||
const GLP={m:null};
|
||||
function glPal(){const m=MPAL();if(GLP.m!==m)Object.assign(GLP,{m,seaTop:glPm(m.sea),seaBot:glPm(m.sea2),cloud:glPm(m.cloud),shadow:glPm(m.shadow),grass:glPm(m.land),
|
||||
hill:glPm(m.hill),shine:glPm(m.shine),wave:glColor(m.wave),sand:glColor(m.sand),edge:glColor(m.coast),casing:glColor(m.casing)});return GLP;}
|
||||
// The land's fill: a fan of triangles per coastline, counted in the stencil (how many times the coasts wind round each
|
||||
// pixel: glLandFill()), then one cover where the count is not zero. uOff shifts it in CSS px (the shadow).
|
||||
const FAN_VS=GL_HEAD+GL_CLIP+`layout(location=0) in vec2 aV;uniform vec2 uView,uOff;uniform vec3 uCam;
|
||||
|
|
@ -49,7 +51,7 @@ function coastLevel(z){const want=Math.floor(Math.log2(Math.max(z,1/64))),cur=GL
|
|||
function coastFan(P,out){let a=0;const n=P.length;for(let i=0;i<n;i++){const p=P[i],q=P[(i+1)%n];a+=p[0]*q[1]-q[0]*p[1];}
|
||||
const s=a<0?1:0;for(let i=1;i+1<n;i++){const b=P[i+s],c=P[i+1-s];out.push(P[0][0],P[0][1],b[0],b[1],c[0],c[1]);}return out;}
|
||||
function glLandGeo(gl,far,lv){const key=(far?'far':'all')+(lv===undefined?'':'@'+lv);let G=GLX.land[key];if(G)return G;
|
||||
const keep=far?new Set(LANDP_FAR):null,tol=lv===undefined?0:COAST_TOL/Math.pow(2,lv),fan=[],sand=[],edge=[],SAND=glColor('#F8E6A8'),EDGE=glColor('#1E2640');
|
||||
const keep=far?new Set(LANDP_FAR):null,tol=lv===undefined?0:COAST_TOL/Math.pow(2,lv),fan=[],sand=[],edge=[],P=glPal(),SAND=P.sand,EDGE=P.edge;
|
||||
COAST.forEach((ring,ri)=>{if(keep&&!keep.has(LANDP_ALL[ri]))return;if(ring.length<3)return;
|
||||
const P=coastSimplify(coastPts(ri),tol);if(P.length<4)return;
|
||||
coastFan(P,fan);
|
||||
|
|
@ -57,10 +59,14 @@ function glLandGeo(gl,far,lv){const key=(far?'far':'all')+(lv===undefined?'':'@'
|
|||
const s0=sand.length/LINE_STRIDE;for(let i=0;i+1<P.length;i++){glSeg(sand,P[i],P[i+1],0,10,0,LINE_ROUND,SAND);glSeg(edge,P[i],P[i+1],0,2.5,0,LINE_ROUND,EDGE);}
|
||||
const s1=sand.length/LINE_STRIDE;glJoin(sand,s0,s1,true);glJoin(edge,s0,s1,true);});
|
||||
const hills=[],shine=[];for(const [x,y,r] of HILLS){hills.push(x,y,r*1.4,r*.8);shine.push(x-r*.3,y-r*.25,r*.6,r*.3);}
|
||||
const F=a=>new Float32Array(a);
|
||||
G={fan:glVao(gl,[2],0,F(fan)).v,nFan:fan.length/2,sand:glVao(gl,[4,4,4,4],1,F(sand)).v,edge:glVao(gl,[4,4,4,4],1,F(edge)).v,nSeg:sand.length/LINE_STRIDE,
|
||||
hills:glVao(gl,[4],1,F(hills)).v,shine:glVao(gl,[4],1,F(shine)).v,nHill:HILLS.length};
|
||||
// The buffers are kept with the land, so a theme change can let them go (the coastlines' colours are in them).
|
||||
const bufs=[],V=(sz,div,a)=>{const x=glVao(gl,sz,div,new Float32Array(a));bufs.push(x);return x.v;};
|
||||
G={fan:V([2],0,fan),nFan:fan.length/2,sand:V([4,4,4,4],1,sand),edge:V([4,4,4,4],1,edge),nSeg:sand.length/LINE_STRIDE,
|
||||
hills:V([4],1,hills),shine:V([4],1,shine),nHill:HILLS.length,bufs};
|
||||
glMem(gl,'the land');return GLX.land[key]=G;}
|
||||
// A theme change (themeRepaint()): every level of the land is built again, in the new colours, when next drawn.
|
||||
function glLandDrop(){const gl=GLX.gl,L=GLX.land;GLX.land={};if(!gl||!L)return;
|
||||
try{if(gl.isContextLost())return;for(const G of Object.values(L))for(const x of G.bufs||[]){gl.deleteVertexArray(x.v);gl.deleteBuffer(x.b);}}catch(e){}}
|
||||
// Fills the land's shape (shifted by ox, oy CSS px) with one colour, for every copy of the map.
|
||||
// The stencil counts the coasts' windings (+1 for a triangle facing one way, -1 the other: coastFan()), as the 2D
|
||||
// canvas's nonzero rule does; counting only odd or even made two overlapping coasts cancel out into sea.
|
||||
|
|
@ -75,16 +81,15 @@ function glLandFill(gl,G,ks,ox,oy,col){const P=GLX.fan;gl.enable(gl.STENCIL_TEST
|
|||
function glEllipses(gl,vao,n,ks,col){const P=GLX.ell;gl.useProgram(P.p);gl.bindVertexArray(vao);gl.uniform2f(P.u.uView,CW,CH);gl.uniform1f(P.u.uDpr,DPR);gl.uniform4fv(P.u.uCol,col);
|
||||
for(const k of ks){gl.uniform3f(P.u.uCam,cam.x-k*W,cam.y,cam.z);gl.drawArraysInstanced(gl.TRIANGLE_STRIP,0,4,n);}}
|
||||
// In paintWorld()'s order: the shadow (5, 7 px down and right), the sand, the grass, the hills, the coastline.
|
||||
function glLand(gl,ks){const G=glLandGeo(gl,lodFar(),coastLevel(cam.z));
|
||||
glLandFill(gl,G,ks,5,7,LAND_SHADOW);
|
||||
function glLand(gl,ks){const G=glLandGeo(gl,lodFar(),coastLevel(cam.z)),P=glPal();
|
||||
glLandFill(gl,G,ks,5,7,P.shadow);
|
||||
glLines(gl,G.sand,G.nSeg,ks);
|
||||
glLandFill(gl,G,ks,0,0,LAND_GRASS);
|
||||
glEllipses(gl,G.hills,G.nHill,ks,HILL_COL);glEllipses(gl,G.shine,G.nHill,ks,HILL_SHINE);
|
||||
glLandFill(gl,G,ks,0,0,P.grass);
|
||||
glEllipses(gl,G.hills,G.nHill,ks,P.hill);glEllipses(gl,G.shine,G.nHill,ks,P.shine);
|
||||
glLines(gl,G.edge,G.nSeg,ks);}
|
||||
// The waves: each one two quadratic curves of four segments, swaying with the map's clock as in drawFrame(). They are
|
||||
// written into the same array every frame (no garbage for the collector to pick up while you play).
|
||||
const WAVE_COL=glColor('rgba(255,255,255,.45)');
|
||||
function glWaves(gl,now,ks){const A=GLX.wa||(GLX.wa=new Float32Array(WAVES.length*8*LINE_STRIDE)),ph0=now/900;let m=0;
|
||||
function glWaves(gl,now,ks){const A=GLX.wa||(GLX.wa=new Float32Array(WAVES.length*8*LINE_STRIDE)),ph0=now/900,WAVE_COL=glPal().wave;let m=0;
|
||||
for(const [x,y,ph] of WAVES){const o=Math.sin(ph0+ph*6)*3,m0=m;
|
||||
// Two curves: up from x-9 to x, then down to x+9 (no array literals per wave: they were garbage every frame).
|
||||
for(let c=0;c<2;c++){const x0=x+o+(c?0:-9),cx=x0+4.5,cy=y+(c?4:-4),x1=x0+9;let px=x0,py=y;
|
||||
|
|
@ -100,7 +105,7 @@ function glClouds(gl,now,ks){const need=ks.length*CLOUDS.length*12;if(!need)retu
|
|||
const F=A.subarray(0,n),P=GLX.circ;gl.bindBuffer(gl.ARRAY_BUFFER,GLX.cl.b);gl.bufferData(gl.ARRAY_BUFFER,F,gl.DYNAMIC_DRAW);
|
||||
gl.enable(gl.STENCIL_TEST);gl.stencilFunc(gl.ALWAYS,1,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.REPLACE);gl.colorMask(false,false,false,false);
|
||||
gl.useProgram(P.p);gl.bindVertexArray(GLX.cl.v);gl.uniform2f(P.u.uView,CW,CH);gl.uniform3f(P.u.uCam,cam.x,cam.y,cam.z);gl.drawArraysInstanced(gl.TRIANGLE_STRIP,0,4,F.length/4);
|
||||
gl.colorMask(true,true,true,true);gl.stencilFunc(gl.EQUAL,1,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);glFill(gl,CLOUD_COL);gl.disable(gl.STENCIL_TEST);}
|
||||
gl.colorMask(true,true,true,true);gl.stencilFunc(gl.EQUAL,1,255);gl.stencilOp(gl.KEEP,gl.KEEP,gl.KEEP);glFill(gl,glPal().cloud);gl.disable(gl.STENCIL_TEST);}
|
||||
// The cables, as drawCables() strokes them: rebuilt only when the highlighted city or the architect view changes.
|
||||
function glCables(gl,ks,selC,ar){const key=[selC,ar];
|
||||
if(!GLX.ckey||key.some((v,i)=>v!==GLX.ckey[i])){const A=[];
|
||||
|
|
@ -119,7 +124,7 @@ function glBegin(now,ks){const gl=GLX.gl,c=GLX.c,f=GLX.f;glShow(true);GLS.frame=
|
|||
gl.viewport(0,0,c.width,c.height);gl.clearColor(0,0,0,0);gl.clearDepth(1);gl.clearStencil(0);gl.colorMask(true,true,true,true);gl.depthMask(true);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT|gl.STENCIL_BUFFER_BIT);
|
||||
gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA);gl.disable(gl.DEPTH_TEST);gl.disable(gl.STENCIL_TEST);
|
||||
glFill(gl,SEA_TOP,SEA_BOT);
|
||||
const P=glPal();glFill(gl,P.seaTop,P.seaBot);
|
||||
glLand(gl,ks);
|
||||
glWaves(gl,now,ks);
|
||||
glClouds(gl,now,ks);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ function glJoin(A,i0,i1,closed){closed=closed&&i1-i0>2;
|
|||
meet, their round ends overlap: each keeps only its side of the corner's bisector, so a see-through line (the
|
||||
halo, the cables, the waves, the fiber's dots) is blended once there, as the 2D canvas strokes a path once. */
|
||||
const GL_LINE_VS=GL_HEAD+GL_CLIP+`layout(location=0) in vec4 aSeg;layout(location=1) in vec4 aP;layout(location=2) in vec4 aC;layout(location=3) in vec4 aN;
|
||||
uniform vec2 uView;uniform vec3 uCam;uniform float uWMul,uDpr,uBusy;uniform int uPass;
|
||||
uniform vec2 uView;uniform vec3 uCam,uCas;uniform float uWMul,uDpr,uBusy;uniform int uPass;
|
||||
out vec2 vLoc;out float vLen,vS0,vHalf,vButt;flat out vec4 vCol,vK;flat out vec2 vDash,vEnd;
|
||||
// The corner's bisector between directions u and v, in the segment's own frame (t along it, n across), and whether there is one.
|
||||
vec3 cut(vec2 u,vec2 v,vec2 t,vec2 n){vec2 m=u+v;float l=length(m);if(length(u)<.5||length(v)<.5||l<1e-3)return vec3(0.);m/=l;return vec3(dot(t,m),dot(n,m),1.);}
|
||||
|
|
@ -32,7 +32,7 @@ vec2 dashOf(int k){${LDASH.map((d,i)=>d.length?`if(k==${i})return vec2(${d[0]}.,
|
|||
void main(){vec2 h=uView*.5,a=(aSeg.xy-uCam.xy)*uCam.z+h,b=(aSeg.zw-uCam.xy)*uCam.z+h;
|
||||
float w=aP.y*uWMul,hw=w*.5;int fl=int(aP.w+.5);vec4 col=vec4(aC.yzw,1.);vec2 dash=dashOf(int(aP.z+.5));bool skip=false;
|
||||
if(uPass==${LP.halo}){hw=(w+14.)*.5;col=vec4(1.,79./255.,154./255.,.35);dash=vec2(0.);skip=(fl&${LINE_SEL})==0;}
|
||||
else if(uPass==${LP.casing}){hw=(w+4.)*.5;col=vec4(30./255.,38./255.,64./255.,1.);}
|
||||
else if(uPass==${LP.casing}){hw=(w+4.)*.5;col=vec4(uCas,1.);}
|
||||
else if(uPass==${LP.dots}){hw=max(1.,w*.25)*.5;col=vec4(1.,1.,1.,.75);dash=dashOf(5);skip=(fl&${LINE_FIBER})==0||uBusy>.5;}
|
||||
else if(uPass==${LP.plain})col.a=aC.x;
|
||||
if(skip){gl_Position=vec4(2.,2.,2.,1.);return;}
|
||||
|
|
@ -103,7 +103,9 @@ function glFrame(ML,ks,far,busy,now,sc){const gl=GLX.gl;
|
|||
if(net)glBuild(ML.LG,ML.GM,ML.looks);
|
||||
if(net||GLX.key[1]!==selId){glHalo(ML.LG,ML.GM,ML.looks,selId);GLX.key=[ML,selId];}
|
||||
gl.enable(gl.BLEND);gl.blendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA);gl.enable(gl.DEPTH_TEST);gl.depthFunc(gl.LEQUAL);gl.depthMask(true);
|
||||
const L=GLX.line,K=GLX.pk,wm=sc*(far?0.5:1),lines=(pass,v=GLX.lv.v,n=GLX.nSeg)=>{gl.useProgram(L.p);gl.bindVertexArray(v);gl.uniform1f(L.u.uBusy,busy?1:0);gl.uniform1i(L.u.uPass,pass);
|
||||
// The casing is the theme's (glPal()), a uniform: the tubes' buffers keep only their own colours.
|
||||
const L=GLX.line,K=GLX.pk,wm=sc*(far?0.5:1),cas=glPal().casing,lines=(pass,v=GLX.lv.v,n=GLX.nSeg)=>{gl.useProgram(L.p);gl.bindVertexArray(v);gl.uniform1f(L.u.uBusy,busy?1:0);gl.uniform1i(L.u.uPass,pass);
|
||||
gl.uniform3f(L.u.uCas,cas[0],cas[1],cas[2]);
|
||||
for(const k of ks){glSet(gl,L,k,wm);gl.drawArraysInstanced(gl.TRIANGLE_STRIP,0,4,n);}};
|
||||
if(GLX.nSeg)for(const pass of [LP.casing,LP.colour,LP.dots])lines(pass);
|
||||
if(GLX.nPk){gl.useProgram(K.p);gl.bindVertexArray(GLX.pv.v);gl.activeTexture(gl.TEXTURE0);gl.bindTexture(gl.TEXTURE_2D,GLX.tex);gl.uniform1i(K.u.uPts,0);
|
||||
|
|
@ -111,11 +113,11 @@ function glFrame(ML,ks,far,busy,now,sc){const gl=GLX.gl;
|
|||
// The selection's halo goes over earlier tubes but under its own line and later ones, as in 2D.
|
||||
if(GLX.nHalo){gl.depthFunc(gl.LESS);gl.depthMask(false);lines(LP.halo,GLX.hv.v,GLX.nHalo);gl.depthMask(true);}
|
||||
gl.bindVertexArray(null);}
|
||||
// The link being dragged out (x,y in CSS px): the dark dotted line, then the pink one running along it, over the tubes
|
||||
// and, since the pictures are drawn after it, under the cities, as in 2D.
|
||||
const DRAG_INK=glColor('#1E2640'),DRAG_PINK=glColor('#FF4F9A');
|
||||
// The link being dragged out (x,y in CSS px): the dotted line in the tubes' casing colour, then the pink one running
|
||||
// along it, over the tubes and, since the pictures are drawn after it, under the cities, as in 2D.
|
||||
const DRAG_PINK=glColor('#FF4F9A');
|
||||
function glDrag(ax,ay,tx,ty,now){const gl=GLX.gl,A=GLX.da||(GLX.da=new Float32Array(2*LINE_STRIDE)),z=cam.z,mx=x=>(x-CW/2)/z+cam.x,my=y=>(y-CH/2)/z+cam.y;
|
||||
glSegAt(A,0,mx(ax),my(ay),mx(tx),my(ty),0,7,7,LINE_ROUND,1,DRAG_INK);
|
||||
glSegAt(A,0,mx(ax),my(ay),mx(tx),my(ty),0,7,7,LINE_ROUND,1,glPal().casing);
|
||||
glSegAt(A,1,mx(ax),my(ay),mx(tx),my(ty),-now/30/z,4,7,LINE_ROUND,1,DRAG_PINK);
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,GLX.dv.b);gl.bufferData(gl.ARRAY_BUFFER,A,gl.DYNAMIC_DRAW);
|
||||
gl.disable(gl.DEPTH_TEST);glLines(gl,GLX.dv.v,2,[0]);gl.bindVertexArray(null);}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,21 @@ function drawFrame(now){
|
|||
// WebGL on: the sea, land, waves, clouds and cables are on the card (glBegin); the 2D canvas below them stays empty.
|
||||
// Off (2D chosen, no game, a puzzle, the card given up), its layers are hidden here, before anything can return early.
|
||||
if(G){try{glBegin(now,ks);}catch(e){throw glErr(e);}}
|
||||
else{glShow(false);GLX.c0clean=false;const wl=worldLayer(z);
|
||||
else{glShow(false);GLX.c0clean=false;const wl=worldLayer(z),mp=MPAL();
|
||||
ctx.setTransform(DPR,0,0,DPR,0,0);
|
||||
// sea
|
||||
const g=ctx.createLinearGradient(0,0,0,CH);g.addColorStop(0,'#62CBEA');g.addColorStop(1,'#43AED6');ctx.fillStyle=g;ctx.fillRect(0,0,CW,CH);
|
||||
const g=ctx.createLinearGradient(0,0,0,CH);g.addColorStop(0,mp.sea);g.addColorStop(1,mp.sea2);ctx.fillStyle=g;ctx.fillRect(0,0,CW,CH);
|
||||
for(const k of ks){
|
||||
ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));
|
||||
// waves: one path, one stroke
|
||||
ctx.strokeStyle='rgba(255,255,255,.45)';ctx.lineWidth=2/z;ctx.lineCap='round';ctx.beginPath();
|
||||
ctx.strokeStyle=mp.wave;ctx.lineWidth=2/z;ctx.lineCap='round';ctx.beginPath();
|
||||
const ph0=now/900;for(const [x,y,ph] of WAVES){const o=Math.sin(ph0+ph*6)*3;ctx.moveTo(x-9+o,y);ctx.quadraticCurveTo(x-4.5+o,y-4,x+o,y);ctx.quadraticCurveTo(x+4.5+o,y+4,x+9+o,y);}ctx.stroke();
|
||||
}
|
||||
for(const k of ks){if(wl)drawWorldLayer(wl,k,z,ks[0]);else{ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));paintWorld(ctx,z,false);}}
|
||||
for(const k of ks){
|
||||
ctx.setTransform(DPR*z,0,0,DPR*z,DPR*((k*W-cam.x)*z+CW/2),DPR*((-cam.y)*z+CH/2));
|
||||
// clouds
|
||||
ctx.fillStyle='rgba(255,255,255,.55)';ctx.beginPath();
|
||||
ctx.fillStyle=mp.cloud;ctx.beginPath();
|
||||
for(const c of CLOUDS){const x=((c.x+now/1000*c.v)%(W+200))-100,y=c.y;ctx.moveTo(x+16*c.s,y);ctx.arc(x,y,16*c.s,0,7);ctx.moveTo(x+38*c.s,y-8*c.s);ctx.arc(x+18*c.s,y-8*c.s,20*c.s,0,7);ctx.moveTo(x+55*c.s,y);ctx.arc(x+40*c.s,y,15*c.s,0,7);}ctx.fill();
|
||||
}
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ function drawFrame(now){
|
|||
drawCables(ks);
|
||||
// links
|
||||
AR_PILLS.length=0;
|
||||
const far=lodFar(),ML=mapLinks(day),LG=ML.LG,GM=ML.GM,PI=ML.PI,busy=linesOnScreen(GM,ks)>MAP_BUSY;
|
||||
const far=lodFar(),ML=mapLinks(day),LG=ML.LG,GM=ML.GM,PI=ML.PI,busy=linesOnScreen(GM,ks)>MAP_BUSY,cas=MPAL().casing;
|
||||
// WebGL on: the card draws every line and packet now, and the rest (labels, markers, cities…) goes on the overlay.
|
||||
if(G)try{glFrame(ML,ks,far,busy,now,sc);}catch(e){throw glErr(e);}
|
||||
for(let gi=0;gi<LG.length;gi++){const grp=LG[gi],{l,many,up,cap,load,df,bld,cut,dark,vx,w0,col,dash,pk}=ML.looks[gi],gm=GM[gi];
|
||||
|
|
@ -62,10 +62,10 @@ function drawFrame(now){
|
|||
const path=()=>{ctx.beginPath();ctx.moveTo(SX[0],SY[0]);for(let i=1;i<np;i++)ctx.lineTo(SX[i],SY[i]);};
|
||||
ctx.lineCap='round';ctx.lineJoin='round';
|
||||
if(sel){ctx.strokeStyle='rgba(255,79,154,.35)';ctx.lineWidth=w+14;path();ctx.stroke();}
|
||||
ctx.strokeStyle='#1E2640';ctx.lineWidth=w+4;ctx.setLineDash(LDASH[dash]);path();ctx.stroke();
|
||||
ctx.strokeStyle=cas;ctx.lineWidth=w+4;ctx.setLineDash(LDASH[dash]);path();ctx.stroke();
|
||||
ctx.strokeStyle=col;ctx.lineWidth=w;ctx.stroke();ctx.setLineDash([]);
|
||||
// Architect runs: tubes sharing one trench are drawn as strands of one bundle (one snip takes them all).
|
||||
if(pz&&many){ctx.strokeStyle='#1E2640';ctx.lineWidth=1.3;for(let j=1;j<grp.length;j++){const d=w*(j/grp.length-0.5);ctx.beginPath();for(let i=0;i<np;i++){const a=Math.max(0,i-1),b=Math.min(np-1,i+1),dx=SX[b]-SX[a],dy=SY[b]-SY[a],n=Math.hypot(dx,dy)||1,x=SX[i]-dy/n*d,y=SY[i]+dx/n*d;i?ctx.lineTo(x,y):ctx.moveTo(x,y);}ctx.stroke();}path();}
|
||||
if(pz&&many){ctx.strokeStyle=cas;ctx.lineWidth=1.3;for(let j=1;j<grp.length;j++){const d=w*(j/grp.length-0.5);ctx.beginPath();for(let i=0;i<np;i++){const a=Math.max(0,i-1),b=Math.min(np-1,i+1),dx=SX[b]-SX[a],dy=SY[b]-SY[a],n=Math.hypot(dx,dy)||1,x=SX[i]-dy/n*d,y=SY[i]+dx/n*d;i?ctx.lineTo(x,y):ctx.moveTo(x,y);}ctx.stroke();}path();}
|
||||
// Still the same path: strokes keep it, so the dotted fiber line goes on top without building it again.
|
||||
if(df&&!bld&&!dark&&!busy){ctx.strokeStyle='rgba(255,255,255,.75)';ctx.lineWidth=Math.max(1,w*0.25);ctx.setLineDash([1,6]);ctx.stroke();ctx.setLineDash([]);}
|
||||
const at=t=>polyAtXY(SX,SY,gm.cum,t);
|
||||
|
|
@ -75,7 +75,7 @@ function drawFrame(now){
|
|||
[mxx,my]=at(.5);}
|
||||
if(bld){if(far)stamp('bldfar',12,12,6,6,1,mxx,my,g=>{g.fillStyle='#FF8A3D';g.strokeStyle='#1E2640';g.lineWidth=1.5;g.beginPath();g.arc(0,0,4,0,7);g.fill();g.stroke();});else drawCone(mxx,my,now);}
|
||||
else if(cut&&!vx){if(far)stamp('cutfar',14,14,7,7,1,mxx,my,g=>{g.fillStyle='#FF4D5E';g.strokeStyle='#1E2640';g.lineWidth=1.5;g.beginPath();g.arc(0,0,5,0,7);g.fill();g.stroke();g.fillStyle='#fff';g.font='900 8px Nunito, sans-serif';g.textAlign='center';g.textBaseline='middle';g.fillText('!',0,0.5);});else if(!arPz)drawBackhoe(mxx,my,now,l.sub);}
|
||||
else if(sel||(pz?!S.ar:z>0.9&&!busy)){const t=lab||(lab=pz?pzLinkLab(grp,up||[l],load,cap):many?groupLabel(grp,up):capName(l));ctx.font='800 11px "Baloo 2", sans-serif';let tw=LINKW.get(t);if(tw===undefined)LINKW.set(t,tw=ctx.measureText(t).width+10);pill(t,ctx.font,tw,17,8,'#fff','#1E2640','#1E2640',2,mxx,my-0.5,1.5);}
|
||||
else if(sel||(pz?!S.ar:z>0.9&&!busy)){const t=lab||(lab=pz?pzLinkLab(grp,up||[l],load,cap):many?groupLabel(grp,up):capName(l));ctx.font='800 11px "Baloo 2", sans-serif';let tw=LINKW.get(t);if(tw===undefined)LINKW.set(t,tw=ctx.measureText(t).width+10);const mp=MPAL();pill(t,ctx.font,tw,17,8,mp.pill,mp.pillInk,mp.pillEdge,2,mxx,my-0.5,1.5);}
|
||||
// Every puzzle: say whether the tubes between two cities share one trench or take separate paths.
|
||||
if(pz&&!cut&&!bld&&(many||arPaths(l)>1)&&(many||lineIdx(l,PI.get(edgeKey(l)))===0))AR_PILLS.push([mxx,my+(sel||!S.ar?19:0),many?tr('architect.n_in_one_trench',{n:grp.length}):'✓ '+tr('architect.n_paths',{n:arPaths(l)}),many]);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ function drawFrame(now){
|
|||
if(UI.snap){const B=CITY[UI.snap.id];const wx=A.x+wrapDx(A.x,B.x);for(const k of [-1,1]){const [px,py]=toS(A.x,A.y,k),[qx]=toS(wx,B.y,k);if(Math.abs(qx-CW/2)<Math.abs(tx-CW/2)){ax=px;ay=py;tx=qx;}}}
|
||||
// On the card it goes under the cities and their labels, as in 2D (the overlay would put it over them).
|
||||
if(G)try{glDrag(ax,ay,tx,ty,now);}catch(e){throw glErr(e);}
|
||||
else{ctx.strokeStyle='#1E2640';ctx.lineWidth=7;ctx.lineCap='round';ctx.setLineDash(LDASH[7]);ctx.beginPath();ctx.moveTo(ax,ay);ctx.lineTo(tx,ty);ctx.stroke();
|
||||
else{ctx.strokeStyle=MPAL().casing;ctx.lineWidth=7;ctx.lineCap='round';ctx.setLineDash(LDASH[7]);ctx.beginPath();ctx.moveTo(ax,ay);ctx.lineTo(tx,ty);ctx.stroke();
|
||||
ctx.strokeStyle='#FF4F9A';ctx.lineWidth=4;ctx.lineDashOffset=-now/30;ctx.stroke();ctx.setLineDash([]);ctx.lineDashOffset=0;}
|
||||
if(UI.snap&&UI.snap.id!==UI.drag.from){const b=UI.snap.id,km=kmBetween(UI.drag.from,b),sub=isSub(UI.drag.from,b);
|
||||
const t=`${km.toLocaleString()} km${sub?' · '+tr('common.subsea'):''} · ${sub&&!cablesFor(UI.drag.from,b).length?tr('draw.no_cable_lands_here'):tr('draw.from_price_mo',{price:fmt$(waveMo(km,sub,0))})}`;
|
||||
|
|
@ -141,13 +141,13 @@ function linesOnScreen(GM,ks){let n=0;for(const gm of GM){const b=gm.box||(gm.bo
|
|||
function ptsBox(pts){let a=Infinity,b=Infinity,c=-Infinity,d=-Infinity;for(const p of pts){if(p[0]<a)a=p[0];if(p[1]<b)b=p[1];if(p[0]>c)c=p[0];if(p[1]>d)d=p[1];}return [a,b,c,d];}
|
||||
function drawCone(x,y,now){stamp('cone',26,28,13,13,1,x,y-12+Math.sin(now/300)*1.5,()=>{ctx.strokeStyle='#1E2640';ctx.lineWidth=2;ctx.fillStyle='#FF8A3D';ctx.beginPath();ctx.moveTo(-7,9);ctx.lineTo(0,-10);ctx.lineTo(7,9);ctx.closePath();ctx.fill();ctx.stroke();ctx.fillStyle='#fff';ctx.fillRect(-4,-1,8,3);ctx.fillStyle='#1E2640';rr(-10,8,20,4,2);ctx.fill();});}
|
||||
// Static land + cable map, rendered once per zoom bucket into an offscreen canvas.
|
||||
function paintWorld(c,z,withCables){const LANDP=lodFar()?LANDP_FAR:LANDP_ALL;
|
||||
for(const o of [0,W,-W]){c.save();c.translate(o+5/z,7/z);c.fillStyle='rgba(20,90,130,.35)';for(const p of LANDP)c.fill(p);c.restore();}
|
||||
c.strokeStyle='#F8E6A8';c.lineWidth=10/z;c.lineJoin='round';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||||
c.fillStyle='#9BDA6C';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.fill(p);c.restore();}
|
||||
c.fillStyle='#86CB5B';c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x+r*1.4,y);c.ellipse(x,y,r*1.4,r*.8,0,0,Math.PI*2);}c.fill();
|
||||
c.fillStyle='rgba(255,255,255,.18)';c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x-r*.3+r*.6,y-r*.25);c.ellipse(x-r*.3,y-r*.25,r*.6,r*.3,0,0,Math.PI*2);}c.fill();
|
||||
c.strokeStyle='#1E2640';c.lineWidth=2.5/z;for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||||
function paintWorld(c,z,withCables){const LANDP=lodFar()?LANDP_FAR:LANDP_ALL,mp=MPAL();
|
||||
for(const o of [0,W,-W]){c.save();c.translate(o+5/z,7/z);c.fillStyle=mp.shadow;for(const p of LANDP)c.fill(p);c.restore();}
|
||||
c.strokeStyle=mp.sand;c.lineWidth=10/z;c.lineJoin='round';for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||||
c.fillStyle=mp.land;for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.fill(p);c.restore();}
|
||||
c.fillStyle=mp.hill;c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x+r*1.4,y);c.ellipse(x,y,r*1.4,r*.8,0,0,Math.PI*2);}c.fill();
|
||||
c.fillStyle=mp.shine;c.beginPath();for(const [x,y,r] of HILLS){c.moveTo(x-r*.3+r*.6,y-r*.25);c.ellipse(x-r*.3,y-r*.25,r*.6,r*.3,0,0,Math.PI*2);}c.fill();
|
||||
c.strokeStyle=mp.coast;c.lineWidth=2.5/z;for(const o of [0,W,-W]){c.save();c.translate(o,0);for(const p of LANDP)c.stroke(p);c.restore();}
|
||||
if(withCables)for(const off of [0,W,-W]){c.save();c.translate(off,0);for(const cp of CABLE_PAIRS){const C=CAB[cp.cid];c.globalAlpha=0.4;c.strokeStyle=cableCol(C);c.lineWidth=1.6/z;c.lineJoin='round';c.setLineDash(C.age==='old'?[6/z,5/z]:[]);c.beginPath();c.moveTo(cp.pts[0][0],cp.pts[0][1]);for(let i=1;i<cp.pts.length;i++)c.lineTo(cp.pts[i][0],cp.pts[i][1]);c.stroke();}c.restore();}
|
||||
c.globalAlpha=1;c.setLineDash([]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ function drawCityFar(C,sx,sy,sc,now,lyOverride){
|
|||
stamp(m.k,36,36,18,18,1,sx,sy,()=>cityFarStatic(C,p,down,sel,hov,ph));
|
||||
if(CM.dish&&CM.dish.has(C.id))dishBadge(sx+(p?10:6),sy+(p?6:5),CM.dish.get(C.id),CM.dl&&CM.dl[C.id]);
|
||||
if(lyOverride!==null&&(p||sel||hov)){ctx.font=`800 ${p?12:11}px "Baloo 2", sans-serif`;const t=C.name,wk=C.id+(p?1:0);let tw=LBLF.get(wk);if(tw===undefined)LBLF.set(wk,tw=ctx.measureText(t).width+12);const ly=lyOverride==null?sy+15:lyOverride;
|
||||
pill(t,ctx.font,tw,16,8,p?'#FF4F9A':'#FFFFFF',p?'#FFFFFF':'#1E2640','#1E2640',1.6,sx,ly,1);}
|
||||
const mp=MPAL();pill(t,ctx.font,tw,16,8,p?'#FF4F9A':mp.pill,p?'#FFFFFF':mp.pillInk,mp.pillEdge,1.6,sx,ly,1);}
|
||||
}
|
||||
function cityFarStatic(C,p,down,sel,hov,ph){ctx.strokeStyle='#1E2640';
|
||||
if(sel){ctx.strokeStyle='#FF4F9A';ctx.lineWidth=2.5;ctx.setLineDash([4,4]);ctx.lineDashOffset=-ph;ctx.beginPath();ctx.arc(0,0,p?14:9,0,7);ctx.stroke();ctx.setLineDash([]);ctx.lineDashOffset=0;ctx.strokeStyle='#1E2640';}
|
||||
|
|
@ -141,7 +141,7 @@ function drawCity(C,sx,sy,sc,now,lyOverride,dem){
|
|||
// label
|
||||
if((cam.z>=0.62||p||sel||hov)&&(lyOverride!==null||hov)){
|
||||
ctx.font=`800 ${p?13:12}px "Baloo 2", sans-serif`;const t=C.name,tw=LBLW[C.id+(p?1:0)]||(LBLW[C.id+(p?1:0)]=ctx.measureText(t).width+14),ly=lyOverride==null?sy+16*sc+8:lyOverride;
|
||||
pill(t,ctx.font,tw,19,9,p?'#FF4F9A':'#FFFFFF',p?'#FFFFFF':'#1E2640','#1E2640',2,sx,ly+0.5,0.5);
|
||||
const mp=MPAL();pill(t,ctx.font,tw,19,9,p?'#FF4F9A':mp.pill,p?'#FFFFFF':mp.pillInk,mp.pillEdge,2,sx,ly+0.5,0.5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function pzDrawCity(v,sc,now){const k=pzKind(v.C.id);
|
|||
const r=(CM.far?16:34)*sc,y=v.sy-(CM.far?0:6*sc),p=S.pops[v.C.id];
|
||||
ctx.save();ctx.lineWidth=3;
|
||||
if(k==='avoid'){ctx.strokeStyle='#FF4D5E';ctx.beginPath();ctx.arc(v.sx,y,r,0,7);ctx.moveTo(v.sx-r*.7,y-r*.7);ctx.lineTo(v.sx+r*.7,y+r*.7);ctx.stroke();}
|
||||
else{const a=animOn()?.55+.35*Math.sin(now/300):.8,gold=S.ar&&S.ar.gold.includes(v.C.id),dk=S.ar&&arDarkNow(v.C.id);ctx.strokeStyle=dk?`rgba(255,77,94,${a})`:gold?`rgba(224,160,0,${p?1:a})`:k==='goal'?`rgba(255,79,154,${p?1:a})`:'rgba(30,38,64,.7)';if(gold||dk)ctx.lineWidth=5;if(k==='via')ctx.setLineDash([5,5]);
|
||||
else{const a=animOn()?.55+.35*Math.sin(now/300):.8,gold=S.ar&&S.ar.gold.includes(v.C.id),dk=S.ar&&arDarkNow(v.C.id);ctx.strokeStyle=dk?`rgba(255,77,94,${a})`:gold?`rgba(224,160,0,${p?1:a})`:k==='goal'?`rgba(255,79,154,${p?1:a})`:MPAL().via;if(gold||dk)ctx.lineWidth=5;if(k==='via')ctx.setLineDash([5,5]);
|
||||
ctx.fillStyle=k==='goal'&&!p?'rgba(255,210,63,.35)':'rgba(255,255,255,.25)';ctx.beginPath();ctx.arc(v.sx,y,r,0,7);ctx.fill();ctx.stroke();ctx.setLineDash([]);}
|
||||
ctx.restore();drawCity(v.C,v.sx,v.sy,sc,now,v.ly===null?undefined:v.ly,v.dem);
|
||||
const b=k==='goal'&&!CM.far?pzBadge(v.C.id):'';if(b){ctx.font=`${Math.round(15*sc)}px sans-serif`;ctx.textAlign='center';ctx.textBaseline='middle';ctx.fillText(b,v.sx-r*.75,y-r*.75);}} // top left: the IX badge has the top right
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ const PG_ST={
|
|||
const PG={cv:null,ctx:null,get:null,raf:0,last:0,t:0,yaw:-20,tilt:18,vy:0,drag:null,night:null,anim:true,dirty:true,
|
||||
data:null,dAt:-1e9,sig:'',sm:[],dish:[],fl:[],hi:null,pads:[],lch:[],fly:[],on:null,g:null,frames:0,m:new Float64Array(9)};
|
||||
let PG_LAND=null,PG_LAND_DIR=null,PG_TURN=1,PG_GRID=null,PG_LIGHT=null,PG_STAR=null;
|
||||
const pgNightPref=()=>{if(PG.night===null){try{PG.night=localStorage.getItem('sot-globe')==='night';}catch(e){PG.night=false;}}return PG.night;};
|
||||
// Day or night as the player last chose it; until then, as the theme (#80).
|
||||
const pgNightPref=()=>{if(PG.night===null){try{const g=localStorage.getItem('sot-globe');PG.night=g?g==='night':THEME.dark;}catch(e){PG.night=THEME.dark;}}return PG.night;};
|
||||
// Unit vectors for the land rings (LANDS_LL), the graticule, city lights and stars: worked out once, on first open.
|
||||
function pgUnit(lo,la,a,i){const b=la*PG_D,c=Math.cos(b),o=lo*PG_D;a[i]=c*Math.cos(o);a[i+1]=c*Math.sin(o);a[i+2]=Math.sin(b);}
|
||||
// One land ring, clipped to the near side (as map libraries clip). The coast runs to where it meets the horizon; from there the
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ let PD={t:0,b:null};
|
|||
document.addEventListener('pointerdown',e=>{PD={t:performance.now(),b:e.target.closest('[data-act]')};},true);
|
||||
function tapOk(e,b){if(!e.isTrusted||!PD.t||e.detail===0)return true;const now=performance.now();if(now-PD.t>4000)return true;
|
||||
if(PD.b!==b)return false;if((UI.layerAt||0)>PD.t)return false;const ts=b.closest('.toast');if(ts&&PD.t-(+ts.dataset.born||0)<500)return false;return true;}
|
||||
document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;if(!$('modal').hidden&&!b.closest('#modal'))return;if(!tapOk(e,b))return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','keys','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','mapSet','soundSet','langSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','presetSet','chaosSet','puzzleDoor','puzzleMenu','pzStart','pzArStart','pzWeekly','scenarios','startScn','startWeekly','settings','settingsClose','prefSet','vpSet','install','pitchSkip','slotMenu','slotExport','slotDel','slotDelGo','slotBack','slotSwitch','slotTake','slotSpace','toTitle','mpDoor','mpBack','mpStart','mpJoin'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);});
|
||||
document.addEventListener('click',e=>{const b=e.target.closest('[data-act]');if(!b||b.disabled)return;if(!$('modal').hidden&&!b.closest('#modal'))return;if(!tapOk(e,b))return;audioInit();const fn=ACT[b.dataset.act];if(!fn)return;if(!S&&!['start','keys','randomName','pickStart','cont','help','helpClose','newgame','mute','animSet','mapSet','soundSet','langSet','themeSet','closeModal','speed','bankClose','whatsNewShow','updateNow','updateLater','importPick','importGo','modeSet','presetSet','chaosSet','puzzleDoor','puzzleMenu','pzStart','pzArStart','pzWeekly','scenarios','startScn','startWeekly','settings','settingsClose','prefSet','vpSet','install','pitchSkip','slotMenu','slotExport','slotDel','slotDelGo','slotBack','slotSwitch','slotTake','slotSpace','toTitle','mpDoor','mpBack','mpStart','mpJoin'].includes(b.dataset.act))return;let a={};try{a=JSON.parse(b.dataset.args||'{}');}catch(_){}fn(a);});
|
||||
|
||||
|
|
|
|||
|
|
@ -4539,12 +4539,15 @@
|
|||
"settings.always_2d":"Always 2D",
|
||||
"settings.an_early_heads_up_below_60":"An early heads-up below 60% happiness, long before they are furious.",
|
||||
"settings.auto_draws_the_map_with_your":"Auto draws the map with your graphics card when the browser allows it, which keeps big networks smooth. Always 2D works everywhere but is slower on big maps.",
|
||||
"settings.auto_follows_your_device_s_light":"Auto follows your device’s light or dark setting. Dark is easier on the eyes at night and saves battery on OLED screens.",
|
||||
"settings.auto_follows_your_device_s_reduce":"Auto follows your device’s reduce-motion setting. Off freezes the map: no moving packets, pulses or floating text.",
|
||||
"settings.customers_and_alerts":"Customers and alerts",
|
||||
"settings.dark":"Dark",
|
||||
"settings.diagnostic_info":"Diagnostic info",
|
||||
"settings.display_and_sound":"Display and sound",
|
||||
"settings.for_bug_reports_shows_your_screen":"For bug reports: shows in a corner your screen's size, how the map is drawn (graphics card or 2D, and why) and how fast.",
|
||||
"settings.let_an_ai_agent_drive_this_game":"Let an AI agent drive this game",
|
||||
"settings.light":"Light",
|
||||
"settings.map_drawing":"Map drawing",
|
||||
"settings.n_min":"{n} min",
|
||||
"settings.n_sec":"{n} s",
|
||||
|
|
@ -4558,6 +4561,7 @@
|
|||
"settings.the_agent_moves_it":"The agent moves it",
|
||||
"settings.the_clock_while_an_agent_plays":"The clock while an agent plays",
|
||||
"settings.the_game_stops_so_you_can":"The game stops so you can fix their service before they cancel. Most useful at high speed.",
|
||||
"settings.theme":"Theme",
|
||||
"settings.this_browser_cannot_so_the_map":"This browser cannot, so the map is drawn in 2D.",
|
||||
"settings.warn_when_a_customer_gets_unhappy":"Warn when a customer gets unhappy",
|
||||
"settings.while_agent_mode_is_on_the":"While agent mode is on, the clock is not yours. With a pace it runs by itself and cannot be paused by hand, not even by an open window (yours included), and it waits while no agent is connected. Or the agent moves it, and nothing happens until it asks for days. The page connects to the local agent relay (npm run dev hosts one), so tools like the MCP server can drive this game while you watch.",
|
||||
|
|
|
|||
|
|
@ -85,6 +85,15 @@
|
|||
"author": { "@type": "Person", "name": "Frederic Jung", "url": "https://github.com/fjaeckel" }
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
// Theme (Settings › Theme, 93-ui/15-theme.js): the player's choice, else the device's, set before the first paint so a dark
|
||||
// screen never flashes light. Site data blocked (localStorage throws or is missing) still leaves the device's setting.
|
||||
// The colours are the light and dark --sea.
|
||||
(function(){var t=null,d=false,m;try{t=localStorage.getItem('sot-theme');}catch(e){}
|
||||
try{d=t==='dark'||t!=='light'&&!!(window.matchMedia&&matchMedia('(prefers-color-scheme: dark)').matches);}catch(e){}
|
||||
document.documentElement.setAttribute('data-theme',d?'dark':'light');
|
||||
if(d){m=document.querySelector('meta[name="theme-color"]');if(m)m.setAttribute('content','#0E2A44');m=document.querySelector('meta[name="color-scheme"]');if(m)m.setAttribute('content','dark');}})();
|
||||
</script>
|
||||
<style>
|
||||
<!-- @include styles -->
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
/* Layout: full-bleed cartoon world map on canvas; sticker-style panels float above it (HUD top, goals left, inspector right / bottom sheet on phones). Single committed bright look. */
|
||||
/* Layout: full-bleed cartoon world map on canvas; sticker-style panels float above it (HUD top, goals left, inspector right / bottom sheet on phones).
|
||||
Two looks, light and dark (05-theme.css): --ink is the stickers' dark outline (and text on bright fills) in both,
|
||||
--text the text on the panels. */
|
||||
:root{
|
||||
--sea:#57C4E5; --sea2:#3AA6CF; --wave:#9BE2F2; --land:#9BDA6C; --land2:#7FC455; --sand:#F8E6A8;
|
||||
--ink:#1E2640; --ink2:#55608A; --paper:#FFFFFF; --soft:#EEF5FB; --line:#D5DEEC;
|
||||
--ink:#1E2640; --ink2:#55608A; --text:#1E2640; --paper:#FFFFFF; --soft:#EEF5FB; --line:#D5DEEC;
|
||||
--me:#FF4F9A; --sun:#FFD23F; --ok:#22C47A; --warn:#FFAA1F; --bad:#FF4D5E;
|
||||
--t1:#7B61FF; --t2:#2F8CFF; --cdn:#FF8A3D; --eye:#16A866;
|
||||
--display:'Baloo 2','Trebuchet MS',system-ui,sans-serif;
|
||||
|
|
@ -14,7 +16,7 @@ body{margin:0}
|
|||
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
||||
.ver{font-size:11.5px;color:var(--ink2);margin-top:10px}
|
||||
.ver a{color:inherit}
|
||||
body{background:var(--sea);color:var(--ink);font-family:var(--body);overflow:hidden;font-size:14px;-webkit-font-smoothing:antialiased}
|
||||
body{background:var(--sea);color:var(--text);font-family:var(--body);overflow:hidden;font-size:14px;-webkit-font-smoothing:antialiased}
|
||||
#map{position:fixed;inset:0;width:100%;height:100%;touch-action:none;display:block;cursor:grab}
|
||||
#map.linking{cursor:crosshair}
|
||||
/* The WebGL tubes and the 2D overlay above them (58-webgl-links.js): pictures only, the map underneath takes the pointer. */
|
||||
|
|
|
|||
23
src/styles/05-theme.css
Normal file
23
src/styles/05-theme.css
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/* Dark (#80): <html data-theme="dark">, set by the page's <head> from Settings › Theme (93-ui/15-theme.js). The panels take
|
||||
the night colours of the NOC window: dark paper, light text, the stickers' outlines darker still. Light tints (a goal
|
||||
to work on, a toast, a pick) are written where they are used as var(--tint-…, light colour): only this look sets them.
|
||||
Text on bright fills (yellow buttons, warning tags) stays dark ink in both looks. */
|
||||
:root[data-theme="dark"]{
|
||||
color-scheme:dark;
|
||||
--sea:#0E2A44; --ink:#070B16; --ink2:#A9B7D8; --text:#E9EFFB; --paper:#1A2340; --soft:#232E50; --line:#364470; --eye:#2BC987;
|
||||
--tint-y:#3B3418; --tint-g:#173B2C; --tint-r:#45212B; --tint-p:#43213D; --tint-b:#17324F; --tint-v:#2C2752; --tint-o:#42301A;
|
||||
--tint-n:#252F4C; --tint-nl:var(--line); --tx-red:#FF8E9B; --tx-amber:#FFB65C;
|
||||
scrollbar-color:#4A5B8E transparent;
|
||||
}
|
||||
/* The green of good news is lighter as text on dark paper; a tag keeps the deeper green under its white letters. */
|
||||
:root[data-theme="dark"] .tag.eye{background:#16A866}
|
||||
/* A ghost button on dark paper: a shade lighter, so it still reads as a button. */
|
||||
:root[data-theme="dark"] .b.ghost,:root[data-theme="dark"] .x{background:var(--soft)}
|
||||
/* The dropdowns' arrow is a picture: drawn again in the light text colour. */
|
||||
:root[data-theme="dark"] select.pick{background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23E9EFFB' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
|
||||
/* Badge variants: the frost and the fire, at night. */
|
||||
:root[data-theme="dark"] .bdg.on.v-freeze{background:linear-gradient(160deg,#15344C,#0F4562);box-shadow:0 2px 0 #5BC0EB,inset 0 0 0 2px var(--paper)}
|
||||
:root[data-theme="dark"] .bdg.on.v-bgp{background:linear-gradient(160deg,#3E2A16,#55280F)}
|
||||
:root[data-theme="dark"] .bdg.v-bgp .bv,:root[data-theme="dark"] .bdg.on.v-bgp .bv{color:#FF8A5C}
|
||||
:root[data-theme="dark"] .bdg.v-freeze .bv{color:#7FD3F5}
|
||||
:root[data-theme="dark"] .legend .lg:hover{background:rgba(233,239,251,.08)}
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
#hNoc{position:relative}#hNoc .badge{position:absolute;top:-8px;right:-8px;background:var(--me);color:#fff;border:2.5px solid var(--ink);border-radius:10px;font:900 11px Nunito,sans-serif;padding:0 6px;line-height:16px}
|
||||
.speed{flex-direction:row;align-items:center;gap:4px;padding:4px 6px}
|
||||
.speed button{border:2.5px solid var(--ink);background:var(--paper);border-radius:9px;min-width:34px;height:32px;font-family:var(--display);font-weight:800;cursor:pointer;font-size:13px}
|
||||
.speed button.on{background:var(--sun)}
|
||||
.speed button.on{background:var(--sun);color:var(--ink)}
|
||||
.spacer{flex:1}
|
||||
.noc{cursor:pointer;border:3px solid var(--ink)}
|
||||
.hotk{display:inline-flex;align-items:center;justify-content:center;min-width:24px;height:24px;padding:0 4px;border-radius:12px;border:2px solid var(--ink,#1E2640);font:900 11px Nunito,sans-serif;margin-right:8px;color:#fff;background:#FF4D5E}
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
.noc.hot{background:var(--bad);color:#fff;animation:throb 1s ease-in-out infinite}
|
||||
.noc.hot .lbl{color:#FFE1E4}
|
||||
#hCust .cnt{display:inline-block;min-width:18px;padding:0 5px;border-radius:9px;background:var(--bad);color:#fff;font-size:11px;line-height:18px;text-align:center;vertical-align:3px;margin-left:2px}
|
||||
#hCust.hot{background:#FFE1E4}
|
||||
#hCust.hot{background:var(--tint-r,#FFE1E4)}
|
||||
@keyframes throb{50%{transform:scale(1.05)}}
|
||||
.minibar{height:6px;border-radius:4px;background:var(--line);overflow:hidden;margin-top:2px;width:100%}
|
||||
.minibar i{display:block;height:100%;background:var(--ok)}
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
.x{margin-left:auto;border:2.5px solid var(--ink);background:var(--paper);border-radius:10px;width:32px;height:32px;font-size:20px;line-height:1;cursor:pointer;font-weight:900;flex:none}
|
||||
.facts{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
|
||||
.fact{background:var(--soft);border:2px solid var(--ink);border-radius:9px;padding:1px 8px;font-size:12px;font-weight:700}
|
||||
.fact.bad{background:#FFE3E3}.latwarn{background:#FFF1F1;border:2px solid #FF5A5F;border-radius:10px;padding:8px 10px;margin:6px 0;font-size:13px;line-height:1.4}
|
||||
.fact.ixf{background:#FFF3C4}
|
||||
.fact.bad{background:var(--tint-r,#FFE3E3)}.latwarn{background:var(--tint-r,#FFF1F1);border:2px solid #FF5A5F;border-radius:10px;padding:8px 10px;margin:6px 0;font-size:13px;line-height:1.4}
|
||||
.fact.ixf{background:var(--tint-y,#FFF3C4)}
|
||||
.fact.mine{background:var(--me);color:#fff}
|
||||
.fact.down{background:var(--bad);color:#fff}
|
||||
section{padding:10px 0;border-bottom:2px dashed var(--line)}
|
||||
|
|
@ -37,13 +37,13 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap:
|
|||
.row .nm{font-weight:800;font-size:13.5px;line-height:1.2}
|
||||
.row .meta{font-size:11.5px;color:var(--ink2);line-height:1.3}
|
||||
.btns{display:flex;flex-wrap:wrap;gap:5px;margin-top:5px}
|
||||
.why{font-size:11px;color:#B23A48;font-weight:700;margin-top:3px;line-height:1.3}
|
||||
.why{font-size:11px;color:var(--tx-red,#B23A48);font-weight:700;margin-top:3px;line-height:1.3}
|
||||
|
||||
.b{font-family:var(--display);font-weight:800;border:2.5px solid var(--ink);border-radius:11px;background:var(--sun);box-shadow:0 3px 0 var(--ink);padding:4px 11px 3px;cursor:pointer;font-size:14px;line-height:1.2;white-space:nowrap;transition:transform .06s}
|
||||
.b{font-family:var(--display);font-weight:800;border:2.5px solid var(--ink);border-radius:11px;background:var(--sun);box-shadow:0 3px 0 var(--ink);padding:4px 11px 3px;cursor:pointer;font-size:14px;line-height:1.2;white-space:nowrap;transition:transform .06s;color:var(--ink)}
|
||||
.b:hover{filter:brightness(1.05)}
|
||||
.b:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
|
||||
.b:disabled{opacity:.42;cursor:not-allowed;transform:none;box-shadow:0 3px 0 var(--ink)}
|
||||
.b.ghost{background:var(--paper)}
|
||||
.b.ghost{background:var(--paper);color:var(--text)}
|
||||
.b.pink{background:var(--me);color:#fff}
|
||||
.b.red{background:var(--bad);color:#fff}
|
||||
.b.green{background:var(--ok);color:#fff}
|
||||
|
|
@ -52,14 +52,14 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap:
|
|||
.b small{font-family:var(--body);font-weight:800;font-size:10.5px;opacity:.85;margin-left:3px}
|
||||
|
||||
.logo{width:30px;height:30px;border-radius:50%;background:var(--c);border:2.5px solid var(--ink);display:grid;place-items:center;color:#fff;font-family:var(--display);font-weight:800;font-size:11px;flex:none;letter-spacing:-.02em}
|
||||
.tag{display:inline-block;border:1.8px solid var(--ink);border-radius:7px;padding:0 5px;font-size:10px;font-weight:900;letter-spacing:.03em;text-transform:uppercase;vertical-align:1px;color:#fff;background:var(--ink2)}
|
||||
.tag{display:inline-block;border:1.8px solid var(--ink);border-radius:7px;padding:0 5px;font-size:10px;font-weight:900;letter-spacing:.03em;text-transform:uppercase;vertical-align:1px;color:#fff;background:#55608A}
|
||||
.tag.t1{background:var(--t1)} .tag.t2{background:var(--t2)} .tag.cdn{background:var(--cdn)} .tag.eye{background:var(--eye)}
|
||||
.tag.open{background:var(--ok)} .tag.selective{background:var(--warn);color:var(--ink)} .tag.restrictive{background:var(--bad)} .tag.paid{background:var(--me)}
|
||||
.tag.st{background:var(--paper);color:var(--ink)}
|
||||
.tag.st{background:var(--paper);color:var(--text)}
|
||||
/* PNI list (#175): one status chip per network, a one-line value, folded groups. Chips wrap on narrow screens. */
|
||||
.tag.worth{background:var(--warn);color:var(--ink)}
|
||||
.pchips{display:flex;flex-wrap:wrap;gap:4px;margin:3px 0}
|
||||
.pchip{display:inline-block;max-width:100%;border:1.5px solid var(--ink);border-radius:999px;padding:0 7px;font-size:11px;font-weight:800;line-height:1.5;background:var(--paper);color:var(--ink);overflow-wrap:anywhere}
|
||||
.pchip{display:inline-block;max-width:100%;border:1.5px solid var(--ink);border-radius:999px;padding:0 7px;font-size:11px;font-weight:800;line-height:1.5;background:var(--paper);color:var(--text);overflow-wrap:anywhere}
|
||||
.pchip.pk-here,.pchip.pk-else{background:var(--ok);color:#fff}
|
||||
.pchip.pk-ix{background:var(--t2);color:#fff}
|
||||
.pchip.pk-none{background:var(--bad);color:#fff}
|
||||
|
|
@ -79,12 +79,12 @@ section h3{font-size:17px;margin-bottom:6px;display:flex;align-items:center;gap:
|
|||
.goal .ck{width:22px;height:22px;border:2.5px solid var(--ink);border-radius:7px;flex:none;display:grid;place-items:center;font-weight:900;background:var(--paper);font-size:13px}
|
||||
.goal.done .ck{background:var(--ok);color:#fff}
|
||||
.goal.done .gt{text-decoration:line-through;color:var(--ink2)}
|
||||
.goal.cur{background:#FFF6CF;margin:0 -14px;padding:9px 14px;border-top:2px solid var(--ink);border-bottom:2px solid var(--ink)}
|
||||
.goal.cur{background:var(--tint-y,#FFF6CF);margin:0 -14px;padding:9px 14px;border-top:2px solid var(--ink);border-bottom:2px solid var(--ink)}
|
||||
.goal .gt{font-weight:900;font-size:13.5px}
|
||||
.goal .gd{font-size:12px;color:var(--ink2);line-height:1.4;margin-top:2px}
|
||||
.goal .gr{font-size:11px;font-weight:900;color:var(--eye);margin-top:2px}
|
||||
.empty{color:var(--ink2);font-size:12.5px;line-height:1.45;padding:6px 0}
|
||||
.inc{border:2.5px solid var(--ink);border-radius:12px;padding:8px 10px;margin-bottom:8px;background:#FFF0F1}
|
||||
.inc{border:2.5px solid var(--ink);border-radius:12px;padding:8px 10px;margin-bottom:8px;background:var(--tint-r,#FFF0F1)}
|
||||
.inc .nm{font-weight:900}
|
||||
.inc .meta{font-size:12px;color:var(--ink2);margin-top:2px;line-height:1.35}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
/* toasts */
|
||||
#toasts{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom,0px) + 14px);display:flex;flex-direction:column-reverse;gap:8px;z-index:8;width:min(460px,calc(100% - 32px));pointer-events:none}
|
||||
.toast{pointer-events:none;background:var(--paper);border:3px solid var(--ink);border-radius:14px;box-shadow:3px 3px 0 var(--ink);padding:9px 12px;display:flex;gap:10px;align-items:center;animation:pop .25s cubic-bezier(.3,1.6,.6,1)}
|
||||
.toast.good{background:#DFFBEA} .toast.bad{background:#FFE1E4} .toast.goal{background:#FFF3C4}
|
||||
.toast.good{background:var(--tint-g,#DFFBEA)} .toast.bad{background:var(--tint-r,#FFE1E4)} .toast.goal{background:var(--tint-y,#FFF3C4)}
|
||||
.toast .b{pointer-events:auto}
|
||||
.seg{display:flex;flex-wrap:wrap;gap:6px}
|
||||
.seg .b{white-space:normal;text-align:left}
|
||||
/* A segmented control: one framed row of equal tabs, the active one filled like the HUD's speed buttons (Pie Control). */
|
||||
.segc{display:flex;gap:3px;padding:3px;margin:6px 0 10px;border:3px solid var(--ink);border-radius:14px;background:var(--soft);box-shadow:3px 3px 0 var(--ink)}
|
||||
.segc button{flex:1 1 0;min-width:0;min-height:40px;padding:3px 2px;border:2.5px solid transparent;border-radius:10px;background:none;color:var(--ink);font-family:var(--display);font-weight:800;font-size:min(13.5px,3.6vw);line-height:1.1;cursor:pointer;overflow-wrap:anywhere;hyphens:auto}
|
||||
.segc button{flex:1 1 0;min-width:0;min-height:40px;padding:3px 2px;border:2.5px solid transparent;border-radius:10px;background:none;color:var(--text);font-family:var(--display);font-weight:800;font-size:min(13.5px,3.6vw);line-height:1.1;cursor:pointer;overflow-wrap:anywhere;hyphens:auto}
|
||||
.segc button:hover{background:var(--paper)}
|
||||
.segc button.on{background:var(--sun);border-color:var(--ink)}
|
||||
.segc button.on{background:var(--sun);border-color:var(--ink);color:var(--ink)}
|
||||
.segc button:focus-visible{outline:3px solid var(--me);outline-offset:1px}
|
||||
.toast .tx{flex:1;font-size:13px;line-height:1.35}
|
||||
.toast .tx b{font-family:var(--display);font-size:14.5px}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* Standing orders: the intern's card in the NOC and the Ops sheet */
|
||||
.ops-card{border:2px solid #8E5CF7;background:#F7F2FF;border-radius:12px;padding:8px 10px;margin:8px 0}
|
||||
.ops-card{border:2px solid #8E5CF7;background:var(--tint-v,#F7F2FF);border-radius:12px;padding:8px 10px;margin:8px 0}
|
||||
.ops-card .nm{font-weight:800}
|
||||
.ops-o{border:2px solid var(--line);border-radius:12px;padding:8px 10px;margin:8px 0;background:var(--paper)}
|
||||
.ops-o.on{border-color:var(--ok)}
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
.ops-p .b{white-space:normal;text-align:left;min-height:36px}
|
||||
/* A setting is a list to pick from: two to a row on a phone, the list as wide as its column. */
|
||||
.ops-sel{display:flex;flex-direction:column;gap:2px;flex:1 1 140px;min-width:0;font:800 12px Nunito,sans-serif;color:var(--ink2)}
|
||||
.ops-sel select{width:100%;min-height:36px;font:700 14px Nunito,sans-serif;color:var(--ink);background:var(--paper);padding:4px 6px;border:2px solid var(--ink);border-radius:8px}
|
||||
.ops-sel select{width:100%;min-height:36px;font:700 14px Nunito,sans-serif;color:var(--text);background:var(--paper);padding:4px 6px;border:2px solid var(--ink);border-radius:8px}
|
||||
.ops-log{white-space:pre-wrap;font-size:11.5px;max-height:160px;overflow:auto}
|
||||
.ops-mood{margin:6px 0 0;font-style:italic;font-size:13px;color:var(--ink2)}
|
||||
.ops-rep{border-left:3px solid #8E5CF7;background:#F7F2FF;border-radius:0 8px 8px 0;padding:6px 8px;margin:6px 0;font-size:13px;line-height:1.35;overflow-wrap:anywhere}
|
||||
.ops-rep{border-left:3px solid #8E5CF7;background:var(--tint-v,#F7F2FF);border-radius:0 8px 8px 0;padding:6px 8px;margin:6px 0;font-size:13px;line-height:1.35;overflow-wrap:anywhere}
|
||||
.ops-rep .eyebrow{margin-bottom:2px}
|
||||
/* Pie Control's Company tab ends with the Founder's feed: a quiet section, older posts folded away. */
|
||||
.pie-feed{border-top:2px solid var(--line);margin-top:12px;padding-top:4px}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
.pft-cr,.pft-d{margin:6px 0}
|
||||
.pft-cr .kv span,.pft-d .kv span{min-width:0;overflow-wrap:anywhere}
|
||||
.pft-list{display:flex;flex-direction:column;gap:6px}
|
||||
.pft-row{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:6px 10px;border:2px solid var(--line);border-radius:12px;background:var(--paper);color:var(--ink);font:inherit;text-align:left;cursor:pointer;box-sizing:border-box}
|
||||
.pft-row{display:flex;align-items:center;gap:8px;width:100%;min-height:44px;padding:6px 10px;border:2px solid var(--line);border-radius:12px;background:var(--paper);color:var(--text);font:inherit;text-align:left;cursor:pointer;box-sizing:border-box}
|
||||
.pft-row.on{border-color:var(--me);box-shadow:0 0 0 2px var(--me) inset}
|
||||
.pft-ic{font-size:20px;flex:none}
|
||||
.pft-m{flex:1;min-width:0;display:flex;flex-direction:column}
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
.seg.site{margin-top:4px;align-items:center}
|
||||
.seg.site .meta{margin-right:4px}
|
||||
.badges{display:grid;grid-template-columns:repeat(auto-fill,minmax(118px,1fr));gap:6px}
|
||||
.bdg{border:2px solid #C9CEDD;border-radius:12px;padding:6px 7px;background:#F3F4F8;opacity:.6;display:flex;flex-direction:column;gap:1px;min-width:0}
|
||||
.bdg{border:2px solid var(--tint-nl,#C9CEDD);border-radius:12px;padding:6px 7px;background:var(--tint-n,#F3F4F8);opacity:.6;display:flex;flex-direction:column;gap:1px;min-width:0}
|
||||
.bdg .bi{font-size:20px;filter:grayscale(1)}
|
||||
.bdg .bt{font:800 12.5px/1.2 "Baloo 2",sans-serif;color:var(--ink)}
|
||||
.bdg .bt{font:800 12.5px/1.2 "Baloo 2",sans-serif;color:var(--text)}
|
||||
.bdg .br{font:900 10px Nunito,sans-serif;color:var(--rc);text-transform:uppercase;letter-spacing:.04em}
|
||||
.bdg .bd{font-size:11px;color:#5A6280;line-height:1.25}
|
||||
.bdg .bd{font-size:11px;color:var(--ink2);line-height:1.25}
|
||||
.bdg.ever{opacity:.85;border-style:dashed;border-color:var(--rc)}
|
||||
.bdg.on{opacity:1;border-color:var(--rc);background:#fff;box-shadow:0 2px 0 var(--rc)}
|
||||
.bdg.on{opacity:1;border-color:var(--rc);background:var(--paper);box-shadow:0 2px 0 var(--rc)}
|
||||
.bdg.on .bi,.bdg.ever .bi{filter:none}
|
||||
.bdg .bv{font:900 10px Nunito,sans-serif;letter-spacing:.02em}
|
||||
.bdg.on.v-freeze{background:linear-gradient(160deg,#F2FBFF,#D6F1FC);border-color:#5BC0EB;box-shadow:0 2px 0 #5BC0EB,inset 0 0 0 2px #fff}
|
||||
|
|
@ -17,19 +17,19 @@
|
|||
.bdg.v-bgp .bv{color:#C8102E}
|
||||
.bdg.ever.v-freeze{border-color:#5BC0EB}.bdg.ever.v-bgp{border-color:#FF5A1F}
|
||||
.bshelf{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 8px}
|
||||
.bsh{font:800 12px Nunito,sans-serif;border:2px solid #C9CEDD;border-radius:999px;padding:2px 9px;background:#fff;white-space:nowrap}
|
||||
.bsh{font:800 12px Nunito,sans-serif;border:2px solid var(--tint-nl,#C9CEDD);border-radius:999px;padding:2px 9px;background:var(--paper);white-space:nowrap}
|
||||
.bsh.v-freeze{border-color:#5BC0EB}.bsh.v-oncall{border-color:#FFD23F}.bsh.v-bgp{border-color:#FF5A1F}
|
||||
.bsh.cur{box-shadow:0 2px 0 var(--ink)}
|
||||
.bvt.v-freeze{color:#2A8DB8;font-weight:900}.bvt.v-bgp{color:#FF5A1F;font-weight:900}
|
||||
.scn{display:flex;gap:10px;align-items:center;border:2px solid #DDE1EC;border-radius:12px;padding:8px 10px;margin-top:8px}
|
||||
.scn.wk{border-color:var(--me);background:#FFF0F6}
|
||||
.scn{display:flex;gap:10px;align-items:center;border:2px solid var(--tint-nl,#DDE1EC);border-radius:12px;padding:8px 10px;margin-top:8px}
|
||||
.scn.wk{border-color:var(--me);background:var(--tint-p,#FFF0F6)}
|
||||
.scn .nm{font-weight:900}
|
||||
.term{background:#1E2640;color:#7CFFB2;font:600 12px/1.5 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;padding:10px 12px;border-radius:10px;overflow-x:auto;white-space:pre;margin:8px 0}
|
||||
.trsel{display:flex;flex-wrap:wrap;gap:8px;align-items:flex-end;margin-top:8px}
|
||||
.trsel label{display:flex;flex-direction:column;font:800 12px Nunito,sans-serif;gap:2px}
|
||||
.trsel select{font:700 14px Nunito,sans-serif;padding:4px 6px;border:2px solid var(--ink);border-radius:8px;max-width:240px}
|
||||
.fact.trb{cursor:pointer;font:inherit;border:2px solid var(--ink);background:#fff}
|
||||
#coach{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 74px);z-index:16;width:min(520px,calc(100% - 24px));background:#fff;border:3px solid var(--ink);border-radius:14px;box-shadow:0 4px 0 var(--ink);padding:8px 10px;display:flex;gap:8px;align-items:center}
|
||||
.fact.trb{cursor:pointer;font:inherit;border:2px solid var(--ink);background:var(--paper)}
|
||||
#coach{position:fixed;left:50%;transform:translateX(-50%);top:calc(env(safe-area-inset-top,0px) + 74px);z-index:16;width:min(520px,calc(100% - 24px));background:var(--paper);border:3px solid var(--ink);border-radius:14px;box-shadow:0 4px 0 var(--ink);padding:8px 10px;display:flex;gap:8px;align-items:center}
|
||||
#coach .ct{flex:1;font-weight:800;font-size:14px;line-height:1.35}
|
||||
#coach .cs{display:block;font:900 10px Nunito,sans-serif;color:var(--me);text-transform:uppercase;letter-spacing:.05em}
|
||||
.coach-glow{animation:coachglow 1s ease-in-out infinite;position:relative;z-index:2}
|
||||
|
|
@ -43,13 +43,13 @@
|
|||
.btns.tcta .b{margin:0;display:flex;align-items:center;justify-content:center;text-align:center;line-height:1.15;white-space:normal;hyphens:auto;-webkit-hyphens:auto;min-height:40px;padding:4px 6px;font-size:14px}
|
||||
.btns.tcta .b.big{grid-column:1/-1;font-size:18px;padding:7px 18px 5px}
|
||||
/* Dropdowns that look like the game's buttons. 16px text: iOS zooms into anything smaller when it is tapped. */
|
||||
select.pick{-webkit-appearance:none;appearance:none;font:800 16px var(--display);color:var(--ink);background:var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231E2640' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;border:3px solid var(--ink);border-radius:12px;padding:6px 36px 6px 12px;min-height:44px;cursor:pointer;box-shadow:0 3px 0 var(--ink)}
|
||||
select.pick{-webkit-appearance:none;appearance:none;font:800 16px var(--display);color:var(--text);background:var(--soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%231E2640' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;border:3px solid var(--ink);border-radius:12px;padding:6px 36px 6px 12px;min-height:44px;cursor:pointer;box-shadow:0 3px 0 var(--ink)}
|
||||
select.pick:focus-visible{outline:3px solid #FF4F9A;outline-offset:2px}
|
||||
label.f+select.pick{width:100%}
|
||||
.thb{font:inherit;font-weight:900;background:none;border:0;padding:0;cursor:pointer;color:inherit}
|
||||
.ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:#FFF6EC;border-radius:6px}
|
||||
.ibx{border:2px solid var(--line,#DDE3EE);border-radius:12px;padding:8px 10px;margin:8px 0;background:#fff}.ibx .nm{font-weight:800}
|
||||
.aibtn{background:linear-gradient(90deg,#8E5CF7,#E84FA8);color:#fff}.aisay{background:#F3ECFF;border:2px solid #8E5CF7;border-radius:10px;padding:8px 10px;color:var(--ink)}
|
||||
.ttop{margin:4px 0;padding:4px 8px;border-left:3px solid #FF8A3D;background:var(--tint-o,#FFF6EC);border-radius:6px}
|
||||
.ibx{border:2px solid var(--line,#DDE3EE);border-radius:12px;padding:8px 10px;margin:8px 0;background:var(--paper)}.ibx .nm{font-weight:800}
|
||||
.aibtn{background:linear-gradient(90deg,#8E5CF7,#E84FA8);color:#fff}.aisay{background:var(--tint-v,#F3ECFF);border:2px solid #8E5CF7;border-radius:10px;padding:8px 10px;color:var(--text)}
|
||||
.tehelp h3{margin:14px 0 4px}.tehelp ul{margin:4px 0;padding-left:18px}.tehelp li{margin:4px 0;font-size:13.5px;line-height:1.4}.tehelp dt{margin-top:8px}.tehelp dd{margin:2px 0 0;font-size:13px;line-height:1.4;color:var(--ink2)}.tehelp code{font:600 12.5px ui-monospace,Menlo,Consolas,monospace;background:#1E2640;color:#E6F0FF;border-radius:6px;padding:1px 6px;word-break:break-word}
|
||||
.terec{display:flex;align-items:center;gap:10px;justify-content:space-between;border-top:2px dashed var(--line,#DDE3EE);padding:8px 0}.terec .btn{flex:none}
|
||||
.tecode{width:100%;box-sizing:border-box;font:600 13px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#1E2640;color:#E6F0FF;border:3px solid var(--ink);border-radius:10px;padding:10px;margin-top:8px;resize:vertical;tab-size:2}
|
||||
|
|
@ -79,7 +79,7 @@ label.f+select.pick{width:100%}
|
|||
.loan{border:2.5px solid var(--ink);border-radius:14px;padding:10px 12px;margin-top:10px;display:flex;gap:10px;align-items:flex-start}
|
||||
.loan .grow{flex:1;min-width:0}
|
||||
.loan .terms{display:flex;flex-wrap:wrap;gap:6px;margin:6px 0}
|
||||
.grade{font-family:var(--display);font-weight:800;font-size:30px;line-height:1;border:3px solid var(--ink);border-radius:12px;padding:4px 10px;background:var(--sun)}
|
||||
.grade{font-family:var(--display);font-weight:800;font-size:30px;line-height:1;border:3px solid var(--ink);border-radius:12px;padding:4px 10px;background:var(--sun);color:var(--ink)}
|
||||
#dash{position:fixed;inset:0;background:rgba(30,38,64,.35);z-index:15;overflow:auto;padding:calc(env(safe-area-inset-top,0px) + 12px) max(12px,env(safe-area-inset-right,0px)) 16px max(12px,env(safe-area-inset-left,0px))}
|
||||
#dashCard{max-width:980px;margin:0 auto;padding:16px 18px 18px;background:var(--paper)}
|
||||
.dgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:8px;margin:10px 0}
|
||||
|
|
@ -110,18 +110,18 @@ label.f+select.pick{width:100%}
|
|||
.title-art h1 span{color:var(--me)}
|
||||
.tagline{color:var(--ink2);font-size:14.5px;line-height:1.45;margin:10px 0 14px}
|
||||
label.f{display:block;font-weight:900;font-size:12px;letter-spacing:.06em;text-transform:uppercase;color:var(--ink2);margin:12px 0 5px}
|
||||
input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radius:12px;padding:8px 12px;font-family:var(--display);font-weight:800;font-size:18px;background:var(--soft);color:var(--ink);-webkit-text-fill-color:var(--ink)}
|
||||
input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radius:12px;padding:8px 12px;font-family:var(--display);font-weight:800;font-size:18px;background:var(--soft);color:var(--text);-webkit-text-fill-color:var(--text)}
|
||||
.network-name{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
|
||||
.network-name{flex-wrap:nowrap}.nmwrap{position:relative;flex:1 1 auto;min-width:0}.nmwrap input.t{width:100%;padding-right:44px;font-size:16px}
|
||||
.reroll{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:32px;height:32px;border-radius:50%;border:2px solid var(--ink);background:#22C47A;color:#fff;font:900 18px/1 var(--display);cursor:pointer;padding:0;display:flex;align-items:center;justify-content:center}.reroll:active{transform:translateY(-50%) rotate(-90deg)}
|
||||
.asnwrap{display:flex;align-items:center;gap:4px;flex:0 0 auto;font:800 14px var(--display);color:var(--ink2)}.asnwrap input.t{width:92px;font-size:15px;padding:8px 6px}.asnwrap input.t::placeholder{color:var(--ink2);opacity:.7}.asnwrap input.t.bad{border-color:#E03A3A;background:#FFE8E8}
|
||||
.asnwrap{display:flex;align-items:center;gap:4px;flex:0 0 auto;font:800 14px var(--display);color:var(--ink2)}.asnwrap input.t{width:92px;font-size:15px;padding:8px 6px}.asnwrap input.t::placeholder{color:var(--ink2);opacity:.7}.asnwrap input.t.bad{border-color:#E03A3A;background:var(--tint-r,#FFE8E8)}
|
||||
.metric-in{display:flex;gap:6px;align-items:center;margin-top:6px}.metric-in input.t{flex:1 1 120px;width:auto;min-width:0;font-size:16px;padding:4px 10px}
|
||||
.plug{display:flex;gap:12px;align-items:center;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;margin:10px 0 4px;background:var(--soft);box-shadow:0 3px 0 var(--ink);color:var(--ink);text-decoration:none}
|
||||
.plug:hover{background:#FFF6D6}.plug .pi{font-size:30px;line-height:1}.plug b{font-family:var(--display);font-size:16px}.plug .meta{display:block;margin-top:2px}.plug .go{margin-left:auto;font-weight:900;white-space:nowrap}
|
||||
.plug{display:flex;gap:12px;align-items:center;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;margin:10px 0 4px;background:var(--soft);box-shadow:0 3px 0 var(--ink);color:var(--text);text-decoration:none}
|
||||
.plug:hover{background:var(--tint-y,#FFF6D6)}.plug .pi{font-size:30px;line-height:1}.plug b{font-family:var(--display);font-size:16px}.plug .meta{display:block;margin-top:2px}.plug .go{margin-left:auto;font-weight:900;white-space:nowrap}
|
||||
.starts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.starts .start:last-child:nth-child(odd){grid-column:1/-1}
|
||||
.start{border:3px solid var(--ink);border-radius:14px;padding:8px 10px;background:var(--paper);cursor:pointer;text-align:left;box-shadow:0 3px 0 var(--ink)}
|
||||
.starts.one{grid-template-columns:1fr}
|
||||
.start.on{background:#FFE3F0;border-color:var(--me);box-shadow:0 3px 0 var(--me)}
|
||||
.start.on{background:var(--tint-p,#FFE3F0);border-color:var(--me);box-shadow:0 3px 0 var(--me)}
|
||||
.start b{font-family:var(--display);font-size:17px;display:block}
|
||||
.start span{font-size:12px;color:var(--ink2);line-height:1.3;display:block}
|
||||
/* Home cities: compact tiles stacked in one column, the dropdown for any other city last. */
|
||||
|
|
@ -132,13 +132,13 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
.door i,.preset i,.chs i{font-style:normal;font-size:26px;line-height:1.1}
|
||||
.door b,.preset b,.chs b{font-family:var(--display);font-size:18px;line-height:1.1}
|
||||
.door span,.preset span,.chs span{font-size:12.5px;color:var(--ink2);line-height:1.3}
|
||||
.door.on,.preset.on,.chs.on{background:#FFE3F0;border-color:var(--me);box-shadow:0 4px 0 var(--me)}
|
||||
.door.on,.preset.on,.chs.on{background:var(--tint-p,#FFE3F0);border-color:var(--me);box-shadow:0 4px 0 var(--me)}
|
||||
.door.on::after,.preset.on::after,.chs.on::after{content:"✓";position:absolute;top:6px;right:9px;font:900 15px var(--display);color:var(--me)}
|
||||
.door[data-door=puzzle],.door[data-door=scn]{background:var(--soft)}
|
||||
.presets{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px}
|
||||
.preset small{font-size:11px;color:var(--ink2);line-height:1.3;margin-top:4px;border-top:2px dashed var(--line);padding-top:4px}
|
||||
.preset[data-preset=bgp].on{background:#FFE9D6;border-color:#FF6A2B;box-shadow:0 4px 0 #FF6A2B}.preset[data-preset=bgp].on::after{color:#FF6A2B}
|
||||
.preset[data-preset=freeze].on{background:#E2F5FF;border-color:var(--sea2);box-shadow:0 4px 0 var(--sea2)}.preset[data-preset=freeze].on::after{color:var(--sea2)}
|
||||
.preset[data-preset=bgp].on{background:var(--tint-o,#FFE9D6);border-color:#FF6A2B;box-shadow:0 4px 0 #FF6A2B}.preset[data-preset=bgp].on::after{color:#FF6A2B}
|
||||
.preset[data-preset=freeze].on{background:var(--tint-b,#E2F5FF);border-color:var(--sea2);box-shadow:0 4px 0 var(--sea2)}.preset[data-preset=freeze].on::after{color:var(--sea2)}
|
||||
.chaos{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
|
||||
.chs{padding:7px 8px 6px}.chs i{font-size:20px}.chs b{font-size:15px}.chs span{font-size:11px}
|
||||
.lockn{margin:8px 0 0}
|
||||
|
|
@ -152,7 +152,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
.setline select.pick{min-height:36px;padding:4px 30px 4px 10px;border-width:2px;border-radius:10px;box-shadow:0 2px 0 var(--ink);background-position:right 9px center}
|
||||
.tiers{display:grid;gap:7px;margin-top:10px}
|
||||
.tierbtn{display:flex;align-items:center;gap:10px;border:3px solid var(--ink);border-radius:13px;padding:8px 12px;background:var(--paper);cursor:pointer;box-shadow:0 3px 0 var(--ink);text-align:left}
|
||||
.tierbtn:hover{background:#FFF6CF}
|
||||
.tierbtn:hover{background:var(--tint-y,#FFF6CF)}
|
||||
.tierbtn:disabled{opacity:.4;cursor:not-allowed}
|
||||
.tierbtn .sz{font-family:var(--display);font-weight:800;font-size:22px;width:70px}
|
||||
.tierbtn .grow{flex:1}
|
||||
|
|
@ -169,7 +169,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
.slots{display:flex;flex-direction:column;gap:7px;margin-bottom:6px;max-height:min(46vh,330px);overflow:auto;padding:2px 2px 5px}
|
||||
.slot{display:flex;align-items:stretch;border:3px solid var(--ink);border-radius:16px;background:var(--paper);box-shadow:0 4px 0 var(--ink);flex:none;transition:transform .08s ease,box-shadow .08s ease}
|
||||
.slot:active{transform:translateY(3px);box-shadow:0 1px 0 var(--ink)}
|
||||
.slot.top{background:#FFE3F0;border-color:var(--me);box-shadow:0 4px 0 var(--me)}
|
||||
.slot.top{background:var(--tint-p,#FFE3F0);border-color:var(--me);box-shadow:0 4px 0 var(--me)}
|
||||
.slot.busy{background:var(--soft);border-style:dashed}
|
||||
.slot.broken{opacity:.75;border-style:dashed}
|
||||
.slot-go{flex:1;min-width:0;display:flex;align-items:center;gap:10px;background:none;border:0;padding:8px 6px 8px 11px;font:inherit;color:inherit;text-align:left;cursor:pointer;min-height:52px}
|
||||
|
|
@ -181,7 +181,7 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
.slot.busy .tag{color:var(--ink2)}
|
||||
.slot .sm{flex:none;display:flex;flex-direction:column;align-items:flex-end;text-align:right}
|
||||
.slot .sm em{font:800 15px var(--display);font-style:normal}
|
||||
.slot-more{flex:none;width:44px;border:0;border-left:2px dashed var(--line);background:none;font:900 22px var(--display);color:var(--ink);cursor:pointer;border-radius:0 13px 13px 0}
|
||||
.slot-more{flex:none;width:44px;border:0;border-left:2px dashed var(--line);background:none;font:900 22px var(--display);color:var(--text);cursor:pointer;border-radius:0 13px 13px 0}
|
||||
.slot-more:hover,.slot-go:hover{background:rgba(255,79,154,.06)}
|
||||
.slot-go:focus-visible,.slot-more:focus-visible{outline:3px solid #FF4F9A;outline-offset:-3px}
|
||||
.ibx.space{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.ibx.space .btns{margin:0}
|
||||
|
|
@ -194,21 +194,21 @@ h2 .rn{font-size:18px;vertical-align:middle;padding:2px 4px}
|
|||
.tcont .b{white-space:normal;max-width:100%;overflow-wrap:anywhere;line-height:1.15}
|
||||
#modalCard{overflow-x:hidden}
|
||||
.menu-tiles{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-top:10px}
|
||||
.mtile{border:3px solid var(--ink);border-radius:14px;background:var(--paper);box-shadow:0 3px 0 var(--ink);padding:8px 4px 7px;display:flex;flex-direction:column;align-items:center;gap:2px;cursor:pointer;font:800 13px/1.15 var(--display);color:var(--ink);text-align:center;min-height:68px;justify-content:center}
|
||||
.mtile{border:3px solid var(--ink);border-radius:14px;background:var(--paper);box-shadow:0 3px 0 var(--ink);padding:8px 4px 7px;display:flex;flex-direction:column;align-items:center;gap:2px;cursor:pointer;font:800 13px/1.15 var(--display);color:var(--text);text-align:center;min-height:68px;justify-content:center}
|
||||
.mtile i{font-style:normal;font-size:22px;line-height:1}.mtile:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
|
||||
.menu-links{margin:12px 0 0;text-align:center;line-height:2;color:var(--ink2)}
|
||||
.menu-links .lnk{background:none;border:0;padding:4px 2px;font-weight:700;font-size:14px;font-family:inherit;color:var(--ink2);text-decoration:underline;text-underline-offset:3px;cursor:pointer}
|
||||
.menu-plugs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:12px}
|
||||
.mplug{border:2px solid var(--line);border-radius:12px;padding:8px 10px;font-weight:700;font-size:13px;line-height:1.25;color:var(--ink);text-decoration:none;background:var(--soft);display:flex;align-items:center}
|
||||
.mplug{border:2px solid var(--line);border-radius:12px;padding:8px 10px;font-weight:700;font-size:13px;line-height:1.25;color:var(--text);text-decoration:none;background:var(--soft);display:flex;align-items:center}
|
||||
/* Find a city: big tap targets, the first result (what Enter picks) highlighted. */
|
||||
.findlist{margin-top:8px}
|
||||
.findrow{width:100%;text-align:left;background:none;border:0;border-top:1px solid var(--line);font:inherit;color:var(--ink);min-height:48px;padding:6px 8px;cursor:pointer;border-radius:0}
|
||||
.findrow{width:100%;text-align:left;background:none;border:0;border-top:1px solid var(--line);font:inherit;color:var(--text);min-height:48px;padding:6px 8px;cursor:pointer;border-radius:0}
|
||||
.findrow .nm,.findrow .meta{display:block}
|
||||
.findrow.on{background:var(--soft);border-radius:10px}
|
||||
.findrow:hover{background:var(--soft)}
|
||||
/* The charter picker (36-specialist.js): three big choices, one tap each, nothing else to close it with. */
|
||||
.chpick h2{margin:2px 0 4px}.chpick .tagline{margin:0 0 6px}
|
||||
.chopt{display:flex;align-items:flex-start;gap:12px;width:100%;margin-top:8px;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;background:var(--paper);box-shadow:0 3px 0 var(--ink);font:inherit;color:var(--ink);text-align:left;cursor:pointer}
|
||||
.chopt{display:flex;align-items:flex-start;gap:12px;width:100%;margin-top:8px;border:3px solid var(--ink);border-radius:14px;padding:10px 12px;background:var(--paper);box-shadow:0 3px 0 var(--ink);font:inherit;color:var(--text);text-align:left;cursor:pointer}
|
||||
.chopt:hover,.chopt:focus-visible{background:var(--soft)}.chopt:active{transform:translateY(2px);box-shadow:0 1px 0 var(--ink)}
|
||||
.chi{font-size:28px;line-height:1.1;flex:none}.cht{display:flex;flex-direction:column;gap:2px;min-width:0}
|
||||
.cht b{font:800 17px/1.2 var(--display)}.cht span{font-size:13px;line-height:1.35;color:var(--ink2)}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
.mpboard,.mpfeed{display:flex;flex-direction:column;gap:4px}
|
||||
.mpfeed{max-height:220px;overflow:auto;margin-top:6px}
|
||||
.mprow{display:flex;align-items:center;gap:8px;border:2px solid var(--line);border-radius:12px;padding:6px 10px;min-width:0}
|
||||
.mprow.me{border-color:var(--me);background:#FFF2F8}
|
||||
.mprow.me{border-color:var(--me);background:var(--tint-p,#FFF2F8)}
|
||||
.mprow .grow,.mpf .grow{min-width:0;overflow-wrap:anywhere}
|
||||
.mprow b{font-family:var(--display);font-size:15px}
|
||||
.mprk{font:900 15px var(--display);width:20px;text-align:center;flex:0 0 auto}
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
/* No room for the chip on a phone (it is hide-sm), nor on a tablet whose top bar still wraps at fitHud's last step:
|
||||
where you stand shows as a badge on the menu button, which also opens the session. */
|
||||
#hud .menubtn{position:relative}
|
||||
.mpbadge{display:none;position:absolute;top:-8px;right:-8px;background:var(--paper);color:var(--ink);border:2.5px solid var(--ink);border-radius:10px;font:900 11px Nunito,sans-serif;padding:0 5px;line-height:16px;pointer-events:none}
|
||||
.mpbadge{display:none;position:absolute;top:-8px;right:-8px;background:var(--paper);color:var(--text);border:2.5px solid var(--ink);border-radius:10px;font:900 11px Nunito,sans-serif;padding:0 5px;line-height:16px;pointer-events:none}
|
||||
#hud.fit3 .mpchip{display:none !important}
|
||||
#hud.fit3 .mpbadge{display:block}
|
||||
@media (max-width:760px){
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
.chtip div span{margin-left:auto;padding-left:10px;font-variant-numeric:tabular-nums}
|
||||
.chtip i{width:9px;height:9px;border-radius:3px;border:1px solid #fff}
|
||||
.chtip .tot{border-top:1px solid rgba(255,255,255,.35);margin-top:4px;padding-top:3px}
|
||||
.chcur{position:fixed;z-index:59;pointer-events:none;width:0;border-left:1px dashed var(--ink)}
|
||||
.chcur{position:fixed;z-index:59;pointer-events:none;width:0;border-left:1px dashed var(--text)}
|
||||
/* The charts' grid and axis labels follow the theme (their attributes give the light look's colours). */
|
||||
.chart line{stroke:var(--line)}.chart text{fill:var(--ink2)}
|
||||
.mix[data-mix]{cursor:help}
|
||||
.nw-chart[data-ch]{touch-action:pan-y;cursor:crosshair}
|
||||
.noc-window .chtip{border:1px solid #3A4A78}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ body.noc-window [data-act="dashClose"]{display:none}
|
|||
.nw-bar{height:7px;border-radius:9px;background:#26324F;overflow:hidden;margin:3px 0}
|
||||
.nw-bar i{display:block;height:100%;border-radius:9px}
|
||||
.nw-pc{font-family:var(--display);font-size:16px;min-width:42px;text-align:right}
|
||||
.nw-btns{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:4px;--ink:#1E2640;--paper:#fff;color:#1E2640}
|
||||
.nw-btns{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:4px;--ink:#1E2640;--paper:#fff;--soft:#EEF5FB;--text:#1E2640;color:#1E2640}
|
||||
.nw-btns .meta{color:#9FB0D3}
|
||||
.nw-row{display:flex;align-items:center;gap:8px;padding:4px 0}
|
||||
.nw-row .nw-pm{flex:1}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
(play, speed, goals, deals, NOC, networks), and bottom sheets you drag up, down or away. */
|
||||
html,body{overscroll-behavior:none}
|
||||
.dtabs{position:sticky;top:-12px;z-index:3;display:flex;gap:6px;overflow-x:auto;margin:10px -4px 4px;padding:8px 4px;background:var(--paper);border-bottom:2.5px solid var(--ink);scrollbar-width:none}
|
||||
.dtabs button{flex:0 0 auto;font:800 13px Nunito,sans-serif;border:2.5px solid var(--ink);border-radius:999px;background:#fff;padding:5px 12px;cursor:pointer;color:var(--ink)}
|
||||
.dtabs button{flex:0 0 auto;font:800 13px Nunito,sans-serif;border:2.5px solid var(--ink);border-radius:999px;background:var(--paper);padding:5px 12px;cursor:pointer;color:var(--text)}
|
||||
.dtabs button.on{background:var(--pink,#FF4F9A);color:#fff}
|
||||
.dtabs .cnt{display:inline-block;margin-left:5px;min-width:16px;padding:0 4px;border-radius:8px;background:var(--bad);color:#fff;font-size:10.5px;line-height:16px;text-align:center}
|
||||
.pcard{border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;margin:0 0 10px;background:#FFF6CF}
|
||||
.pcard{border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;margin:0 0 10px;background:var(--tint-y,#FFF6CF)}
|
||||
.pcard .pt{font-weight:900;font-size:15px;margin:1px 0 2px}.pcard .kv{margin-top:5px}.pcard .bar{margin-top:2px}
|
||||
.pcard.lv{background:#EAF6FF}
|
||||
.pitch{list-style:none;padding:0;margin:10px 0}.pitch li{margin:7px 0;line-height:1.38;font-size:14px}.pitch li.warn{background:#FFF4D6;border:2px solid var(--ink);border-radius:10px;padding:6px 8px}
|
||||
.pcard.lv{background:var(--tint-b,#EAF6FF)}
|
||||
.pitch{list-style:none;padding:0;margin:10px 0}.pitch li{margin:7px 0;line-height:1.38;font-size:14px}.pitch li.warn{background:var(--tint-y,#FFF4D6);border:2px solid var(--ink);border-radius:10px;padding:6px 8px}
|
||||
.isteps{padding-left:22px;margin:8px 0 4px}.isteps li{margin:5px 0;line-height:1.38;font-size:14px}.isteps svg{vertical-align:-3px}
|
||||
.icard{margin:8px 0 10px;border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;background:#FFF4D6}
|
||||
.icard{margin:8px 0 10px;border:2.5px solid var(--ink);border-radius:14px;padding:8px 10px;background:var(--tint-y,#FFF4D6)}
|
||||
/* iPhone home-screen app with a viewport shorter than the screen: the page box takes the real screen height
|
||||
and becomes the containing block for everything fixed, so bottom-anchored UI reaches the bottom. */
|
||||
html.iosfix,html.iosfix body{height:var(--app-h)}
|
||||
|
|
@ -29,10 +29,10 @@ button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transpar
|
|||
#leftToggle{display:none !important}
|
||||
#tabbar{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:9;height:var(--tabbar);padding:6px max(6px,env(safe-area-inset-right,0px)) env(safe-area-inset-bottom,0px) max(6px,env(safe-area-inset-left,0px));background:var(--paper);border-top:3px solid var(--ink);box-sizing:border-box;gap:2px;align-items:stretch}
|
||||
#tabbar button{flex:1 1 0;min-width:0;border:0;background:transparent;border-radius:12px;font:inherit;font-weight:900;font-size:10.5px;color:var(--ink2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;padding:2px 0;position:relative}
|
||||
#tabbar button .ic{font-size:19px;line-height:1.05;color:var(--ink)}
|
||||
#tabbar button.on{background:var(--soft);color:var(--ink)}
|
||||
#tabbar button .ic{font-size:19px;line-height:1.05;color:var(--text)}
|
||||
#tabbar button.on{background:var(--soft);color:var(--text)}
|
||||
#tabbar button.play .ic{font-size:21px}
|
||||
#tabbar button.play.paused{background:#FFE3F0}
|
||||
#tabbar button.play.paused{background:var(--tint-p,#FFE3F0)}
|
||||
#tabbar .cnt{position:absolute;top:2px;right:calc(50% - 22px);min-width:16px;height:16px;padding:0 4px;border-radius:8px;background:var(--me);color:#fff;font-size:10px;line-height:16px;box-sizing:border-box}
|
||||
#tabbar .cnt.red{background:var(--bad)}
|
||||
#tabbar .cnt.dot{min-width:0;width:10px;height:10px;padding:0;top:6px;right:calc(50% - 16px)}
|
||||
|
|
@ -85,7 +85,7 @@ button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transpar
|
|||
}
|
||||
/* Installed as an app: no browser chrome, so leave room for the notch and the home indicator. */
|
||||
@media (display-mode: standalone){
|
||||
body{background:#57C4E5}
|
||||
body{background:var(--sea)}
|
||||
}
|
||||
/* Whatever the language, the HUD stays on one row: fitHud() drops chips until it fits. */
|
||||
#hud.fit1 .hide-md2,#hud.fit2 .hide-md{display:none !important}
|
||||
|
|
|
|||
|
|
@ -4,20 +4,20 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
#pzBox .pzh{display:flex;align-items:center;gap:8px}#pzBox h3{font-size:19px}
|
||||
.pzj{margin:4px 0 6px;font-size:12.5px;color:var(--ink2);line-height:1.35}
|
||||
.pzs{display:flex;gap:6px;margin:6px 0}.pzs span{flex:1;display:flex;flex-direction:column;align-items:center;border:2.5px solid var(--ink);border-radius:11px;padding:3px 0;font-size:20px;filter:grayscale(1);opacity:.45;transition:transform .25s,opacity .25s}
|
||||
.pzs span small{font:900 10px var(--body);text-transform:uppercase;letter-spacing:.05em}.pzs span.on{filter:none;opacity:1;background:#FFF3C4;transform:scale(1.05)}
|
||||
.pzck{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0}.pzc{font-weight:900;font-size:12px;border:2px solid var(--ink);border-radius:999px;padding:1px 8px;background:#fff}
|
||||
.pzs span small{font:900 10px var(--body);text-transform:uppercase;letter-spacing:.05em}.pzs span.on{filter:none;opacity:1;background:var(--tint-y,#FFF3C4);transform:scale(1.05)}
|
||||
.pzck{display:flex;flex-wrap:wrap;gap:5px;margin:6px 0}.pzc{font-weight:900;font-size:12px;border:2px solid var(--ink);border-radius:999px;padding:1px 8px;background:var(--paper)}
|
||||
.pzc i{font-style:normal}
|
||||
.pzc.s1{background:#FFE3F0}.pzc.s2{background:var(--ok);color:#fff}
|
||||
.pzc.s1{background:var(--tint-p,#FFE3F0)}.pzc.s2{background:var(--ok);color:#fff}
|
||||
.pzsrc{font-size:12px;font-weight:800;color:var(--ink2);margin:4px 0}
|
||||
.pzfl{margin:4px 0 6px}.pzf{margin:4px 0;padding:3px 6px;border:2px solid var(--line);border-radius:10px}.pzf.ok{border-color:var(--ok)}
|
||||
.pzf .kv{font-size:12px;gap:6px}.pzf .bar{margin:2px 0}.pzf .meta .bad{color:var(--bad);font-weight:900}.pzf .seg.pzrt{margin-top:3px}
|
||||
.pzpair{border-top:2px dashed var(--line);padding-top:4px;margin-top:4px}.pzhave{font-size:13px;font-weight:800;margin:6px 0;padding:4px 8px;border-radius:10px;background:#FFF4D6}
|
||||
.pznote{font-weight:800;font-size:13.5px;margin:8px 0;padding:8px 10px;border:2.5px solid var(--ink);border-radius:12px;background:#FFF3C4}
|
||||
.row.on{background:#FFE3F0;border-radius:10px}
|
||||
.pzpair{border-top:2px dashed var(--line);padding-top:4px;margin-top:4px}.pzhave{font-size:13px;font-weight:800;margin:6px 0;padding:4px 8px;border-radius:10px;background:var(--tint-y,#FFF4D6)}
|
||||
.pznote{font-weight:800;font-size:13.5px;margin:8px 0;padding:8px 10px;border:2.5px solid var(--ink);border-radius:12px;background:var(--tint-y,#FFF3C4)}
|
||||
.row.on{background:var(--tint-p,#FFE3F0);border-radius:10px}
|
||||
.pztw{font-size:12.5px;font-weight:800;color:var(--bad);margin:3px 0}.pztw.ok{color:var(--eye)}.pztw.rule{color:var(--ink2)}
|
||||
.pzbud{margin:6px 0}.pzbud .kv{font-size:12.5px}
|
||||
.pzn1{font-size:12.5px;font-weight:800;margin:6px 0;padding:4px 8px;border:2px solid var(--line);border-radius:10px;color:var(--ink2)}
|
||||
.pzn1.on{border-color:var(--ok);background:#DFFBEA;color:var(--ink);animation:pzglow 1.6s ease-in-out infinite}.pzn1.bad{border-color:var(--warn);background:#FFF4D6;color:var(--ink)}
|
||||
.pzn1.on{border-color:var(--ok);background:var(--tint-g,#DFFBEA);color:var(--text);animation:pzglow 1.6s ease-in-out infinite}.pzn1.bad{border-color:var(--warn);background:var(--tint-y,#FFF4D6);color:var(--text)}
|
||||
@keyframes pzglow{50%{box-shadow:0 0 0 4px rgba(34,196,122,.25)}}
|
||||
#pzBox .btns{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px}
|
||||
#pzBox .grab{display:none}
|
||||
|
|
@ -30,9 +30,9 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pzgi{width:24px;flex:none;text-align:center;font-size:16px}.pzgi i{font-style:normal;display:inline-block;width:20px;height:20px;border:2px solid var(--line);border-radius:50%;font:900 11px/16px var(--body);color:var(--ink2);box-sizing:border-box}
|
||||
.pzgv{font-size:12.5px;font-weight:800;color:var(--ink2);white-space:nowrap}
|
||||
.pzgoal.done b{font-weight:700;color:var(--ink2)}.pzgoal:not(.done):not(.cur){opacity:.6}
|
||||
.pzgoal.cur{background:#FFF4D6;border:2px solid var(--warn);border-radius:12px;padding:6px 8px;margin:3px 0}
|
||||
.pzgoal.cur{background:var(--tint-y,#FFF4D6);border:2px solid var(--warn);border-radius:12px;padding:6px 8px;margin:3px 0}
|
||||
.pzgh{font-size:13px;line-height:1.4;margin:3px 0 1px 32px}#pzBox .pzgh .pzshow{margin:2px 0 0 2px;padding:2px 10px;min-height:0;vertical-align:middle}
|
||||
.pzchips{display:flex;flex-wrap:wrap;gap:5px;margin:4px 0}.pzchip{font-size:12px;font-weight:800;border:2px solid var(--ok);border-radius:999px;padding:1px 9px;background:#fff;white-space:nowrap}.pzchip b{font-weight:900}
|
||||
.pzchips{display:flex;flex-wrap:wrap;gap:5px;margin:4px 0}.pzchip{font-size:12px;font-weight:800;border:2px solid var(--ok);border-radius:999px;padding:1px 9px;background:var(--paper);white-space:nowrap}.pzchip b{font-weight:900}
|
||||
.pzprog{margin:6px 0 4px}.pzpack{font-size:17px;margin:14px 0 2px}.pzst{font-size:12px;letter-spacing:-1px;white-space:nowrap}
|
||||
.scn.lock{opacity:.5}
|
||||
.pzres{position:relative}.pzstars{display:flex;justify-content:center;gap:10px;margin:10px 0 2px}
|
||||
|
|
@ -61,20 +61,20 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pzd-nm{flex:1 1 auto;min-width:0;font:800 15px/1.2 var(--display);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.pzd-stars{display:flex;gap:2px;flex:none}
|
||||
.pzd-st{display:inline-grid;place-items:center;width:22px;height:22px;border:2px solid var(--line);border-radius:50%;font:900 11px var(--body);color:var(--ink2);box-sizing:border-box}
|
||||
.pzd-st.on{border:0;font-size:17px}.pzd-st.cur{border-color:var(--warn);background:#FFF4D6;color:var(--ink)}
|
||||
.pzd-st.on{border:0;font-size:17px}.pzd-st.cur{border-color:var(--warn);background:var(--tint-y,#FFF4D6);color:var(--text)}
|
||||
.pzd-bud{flex:none;font-weight:900;font-size:12.5px;font-variant-numeric:tabular-nums;white-space:nowrap}.pzd-bud.bad{color:var(--bad)}
|
||||
#pzBox.dock .pzd-bar .b.sm{min-width:36px;min-height:36px;padding:2px 8px;font-size:16px}
|
||||
.pzd-goal{display:flex;align-items:center;gap:8px;margin-top:6px;padding:5px 8px;background:#FFF4D6;border:2px solid var(--warn);border-radius:12px}
|
||||
.pzd-goal.done{background:#DFFBEA;border-color:var(--ok)}.pzd-goal.bad{background:#FFE6E9;border-color:var(--bad)}
|
||||
.pzd-goal{display:flex;align-items:center;gap:8px;margin-top:6px;padding:5px 8px;background:var(--tint-y,#FFF4D6);border:2px solid var(--warn);border-radius:12px}
|
||||
.pzd-goal.done{background:var(--tint-g,#DFFBEA);border-color:var(--ok)}.pzd-goal.bad{background:var(--tint-r,#FFE6E9);border-color:var(--bad)}
|
||||
#pzBox.dock .arsteps{margin:6px 0 4px}#pzBox.dock .arsteps i{height:6px}#pzBox.dock .arbrief{font-size:13px;margin:0 0 2px}
|
||||
#pzBox.dock .arsites{display:contents}#pzBox.dock .arsite{font-size:12px;padding:2px 8px}
|
||||
body.pz.sheet-open #pzBox.dock .arbrief,body.pz.sheet-open #pzBox.dock .arsteps{display:none}
|
||||
.pzd-goal{flex-wrap:wrap}.pzd-gi{flex:none;font-size:16px}.pzd-gt{flex:1 1 170px;min-width:0;font-size:13px;line-height:1.3}.pzd-gt b{font-weight:800}
|
||||
.pzd-ga{flex:none;display:flex;flex-direction:column;gap:4px}#pzBox.dock .pzd-ga{margin-left:auto}#pzBox.dock .pzd-ga .b{min-height:32px;padding:2px 10px;font-size:13px;white-space:nowrap}
|
||||
.pzd-chips{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}
|
||||
.pzd-chip{font:800 12px/1.2 var(--body);color:var(--ink);background:#fff;border:2px solid var(--line);border-radius:999px;padding:3px 8px;white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
|
||||
.pzd-chip{font:800 12px/1.2 var(--body);color:var(--text);background:var(--paper);border:2px solid var(--line);border-radius:999px;padding:3px 8px;white-space:nowrap;max-width:100%;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
|
||||
.pzd-chip b{font-weight:900;font-variant-numeric:tabular-nums}.pzd-chip .bad{color:var(--bad)}
|
||||
.pzd-chip.ok{border-color:var(--ok);background:#DFFBEA}.pzd-chip.part{border-color:var(--warn);background:#FFF4D6}.pzd-chip.none{border-color:var(--bad);background:#FFE6E9}
|
||||
.pzd-chip.ok{border-color:var(--ok);background:var(--tint-g,#DFFBEA)}.pzd-chip.part{border-color:var(--warn);background:var(--tint-y,#FFF4D6)}.pzd-chip.none{border-color:var(--bad);background:var(--tint-r,#FFE6E9)}
|
||||
.pzd-chip.rule{cursor:default;color:var(--ink2)}
|
||||
/* The card: as tall as its tab, under the bar at most; tabs keep each part short enough to need no scrolling. */
|
||||
body.pz #panel{max-height:calc(100% - var(--pzdock,60px) - 18px - env(safe-area-inset-top,0px)) !important}
|
||||
|
|
@ -85,14 +85,14 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pzd-body{padding:0 14px calc(10px + env(safe-area-inset-bottom,0px))}
|
||||
.pzd-tabs{display:flex;gap:4px;margin:6px 0 8px;border-bottom:2px solid var(--line)}
|
||||
.pzd-tabs button{flex:1;font:800 13px var(--body);color:var(--ink2);background:none;border:0;border-bottom:3px solid transparent;margin-bottom:-2px;padding:6px 2px;min-height:36px}
|
||||
.pzd-tabs button.on{color:var(--ink);border-bottom-color:var(--me)}
|
||||
.pzd-row{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1.5px dashed var(--line);font-size:13px}.pzd-row .grow{min-width:0}.pzd-row.on{background:#FFE3F0;border-radius:8px}
|
||||
.pzd-tabs button.on{color:var(--text);border-bottom-color:var(--me)}
|
||||
.pzd-row{display:flex;align-items:center;gap:8px;padding:4px 0;border-bottom:1.5px dashed var(--line);font-size:13px}.pzd-row .grow{min-width:0}.pzd-row.on{background:var(--tint-p,#FFE3F0);border-radius:8px}
|
||||
.pzd-to{flex-wrap:wrap}.pzd-foot{justify-content:flex-end}
|
||||
.pzd-models{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:5px;margin-top:6px}
|
||||
.pzd-model{display:flex;flex-direction:column;align-items:flex-start;gap:0;text-align:left;font:inherit;color:var(--ink);background:#fff;border:2px solid var(--ink);border-radius:10px;padding:3px 7px;min-width:0;cursor:pointer}
|
||||
.pzd-model{display:flex;flex-direction:column;align-items:flex-start;gap:0;text-align:left;font:inherit;color:var(--text);background:var(--paper);border:2px solid var(--ink);border-radius:10px;padding:3px 7px;min-width:0;cursor:pointer}
|
||||
.pzd-mh{display:flex;gap:6px;width:100%;align-items:baseline}.pzd-mh b{flex:1 1 auto;min-width:0;font-size:12.5px;font-weight:900;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pzd-mh span{flex:none;font-weight:900;font-size:12.5px}
|
||||
.pzd-model small{font-size:11px;color:var(--ink2);line-height:1.25;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.pzd-model.on{background:#FFE3F0;border-color:var(--me)}.pzd-model:disabled:not(.on){opacity:.45;border-color:var(--line)}
|
||||
.pzd-model.on{background:var(--tint-p,#FFE3F0);border-color:var(--me)}.pzd-model:disabled:not(.on){opacity:.45;border-color:var(--line)}
|
||||
.pzd-rt{margin:6px 0 0}.pzd-rt .b{min-height:34px}
|
||||
.pzd-tiers{display:grid;grid-template-columns:1fr 1fr;gap:6px}.pzd-tiers .b{margin:0;display:flex;flex-direction:column;align-items:center;gap:0;white-space:normal;line-height:1.15;padding:4px 6px}.pzd-tiers .b small{font-size:11px}
|
||||
/* What a routing metric does, and the redundancy check's question, are on the desktop card; here the buttons speak. */
|
||||
|
|
@ -110,4 +110,4 @@ body.pz #hud .chip:not(.brand):not(.speed),body.pz #hud .speed button:not(#muteB
|
|||
.pznew{display:inline-block;font:900 10.5px/1.2 var(--body);font-style:normal;text-transform:uppercase;letter-spacing:.04em;background:var(--me);color:#fff;border:2px solid var(--ink);border-radius:999px;padding:1px 7px;white-space:nowrap;vertical-align:1px}
|
||||
.door .pznew{position:absolute;top:-9px;right:8px;transform:rotate(4deg);animation:pznew 2.4s ease-in-out infinite}
|
||||
@keyframes pznew{50%{transform:rotate(-3deg) scale(1.08)}}
|
||||
.scn.wk{flex-wrap:wrap}.scn.wk .grow{min-width:0;flex:1 1 200px}.pzcd{font-weight:800;color:var(--ink)}
|
||||
.scn.wk{flex-wrap:wrap}.scn.wk .grow{min-width:0;flex:1 1 200px}.pzcd{font-weight:800;color:var(--text)}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,18 @@
|
|||
/* Architect runs (prototype): the brief, its sites, the review line */
|
||||
.arsteps{display:flex;gap:4px;margin:4px 0 6px}.arsteps i{flex:1;height:7px;border:2px solid var(--ink);border-radius:99px;background:#fff}
|
||||
.arsteps{display:flex;gap:4px;margin:4px 0 6px}.arsteps i{flex:1;height:7px;border:2px solid var(--ink);border-radius:99px;background:var(--paper)}
|
||||
.arsteps i.done{background:var(--ok)}.arsteps i.on{background:#FFD23F}
|
||||
.arbrief{margin:2px 0 8px;font-size:14.5px;font-weight:800;line-height:1.35}
|
||||
.arsites{display:flex;flex-wrap:wrap;gap:5px;margin:4px 0 6px}
|
||||
.arsite{font-weight:900;font-size:12px;border:2px solid var(--line);border-radius:999px;padding:1px 8px;background:#fff;color:var(--ink2)}
|
||||
.arsite.ok{border-color:var(--ok);color:var(--ink)}.arsite.gold{border-color:#E5484D;background:#FFE8E8}
|
||||
.arline{font-size:12.5px;font-weight:800;margin:3px 0;color:var(--ink2)}.arline.ok{color:var(--ink)}.arline.bad{color:var(--bad)}
|
||||
.arsite{font-weight:900;font-size:12px;border:2px solid var(--line);border-radius:999px;padding:1px 8px;background:var(--paper);color:var(--ink2)}
|
||||
.arsite.ok{border-color:var(--ok);color:var(--text)}.arsite.gold{border-color:#E5484D;background:var(--tint-r,#FFE8E8)}
|
||||
.arline{font-size:12.5px;font-weight:800;margin:3px 0;color:var(--ink2)}.arline.ok{color:var(--text)}.arline.bad{color:var(--bad)}
|
||||
.arshape{font-size:12.5px;font-weight:900;margin:4px 0}
|
||||
.arrev{font-size:12.5px;font-weight:800;margin:6px 0;padding:5px 8px;border:2px solid var(--line);border-radius:10px;color:var(--ink2)}
|
||||
.arrev.on{border-color:#FF8A3D;background:#FFF0E3;color:var(--ink)}.arrev.ok{border-color:var(--ok);background:#DFFBEA;color:var(--ink)}
|
||||
.arrev.bad{border-color:var(--bad);background:#FFE6E9;color:var(--ink)}
|
||||
.arrev.on{border-color:#FF8A3D;background:var(--tint-o,#FFF0E3);color:var(--text)}.arrev.ok{border-color:var(--ok);background:var(--tint-g,#DFFBEA);color:var(--text)}
|
||||
.arrev.bad{border-color:var(--bad);background:var(--tint-r,#FFE6E9);color:var(--text)}
|
||||
#pzBox .arbtns .b.big{flex:1 1 100%}
|
||||
.artubes{display:flex;justify-content:space-between;align-items:center;font-size:12.5px;font-weight:800;margin:4px 0}.artubes b{font-size:15px;letter-spacing:2px;color:var(--me)}
|
||||
.artubes em{font-style:normal;font-size:11.5px;letter-spacing:0;color:#B86A00}.artubes.over b{color:#B86A00}
|
||||
.artubes em{font-style:normal;font-size:11.5px;letter-spacing:0;color:var(--tx-amber,#B86A00)}.artubes.over b{color:var(--tx-amber,#B86A00)}
|
||||
/* Laptops and up: a bigger card, easier to read at a glance */
|
||||
@media (min-width:761px) and (min-height:501px){
|
||||
#pzBox.ar{width:390px;padding:14px 18px 16px}
|
||||
|
|
@ -24,4 +24,4 @@
|
|||
#pzBox.ar .artubes b{font-size:19px}#pzBox.ar .pzbud .bar{height:12px}
|
||||
#pzBox.ar .arbtns .b.sm{font-size:13px;padding:5px 11px}
|
||||
}
|
||||
.arsite small{font-weight:800;opacity:.75}.arsite.thin{border-color:var(--bad);background:#FFE6E9;color:var(--ink)}
|
||||
.arsite small{font-weight:800;opacity:.75}.arsite.thin{border-color:var(--bad);background:var(--tint-r,#FFE6E9);color:var(--text)}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ test('src: partials follow the layout rules (docs/adr/0002-one-page-assembled-at
|
|||
for (const dev of [false, true]) {
|
||||
const { html, map } = assemble({ dev });
|
||||
assert.equal((html.match(/^const ACT=\{$/gm) || []).length, 1, 'ACT is declared once; other action files use Object.assign(ACT,{…})');
|
||||
assert.equal([...new JSDOM(html).window.document.scripts].filter((s) => !s.attributes.length).length, 2, 'the language loader and the game: one inline game script');
|
||||
assert.equal([...new JSDOM(html).window.document.scripts].filter((s) => !s.attributes.length).length, 3, 'the theme, the language loader and the game: one inline game script');
|
||||
assert.ok(map.length > 50 && map.every((m) => m.to >= m.from), 'the line map covers every partial');
|
||||
}
|
||||
});
|
||||
|
|
|
|||
380
tests/dark-mode.test.js
Normal file
380
tests/dark-mode.test.js
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
// Dark mode (#80): Settings › Theme is Auto (the device's light or dark setting), Light or Dark, a choice kept on the
|
||||
// device (localStorage sot-theme), never in the save. The page's <head> sets <html data-theme> before the first paint;
|
||||
// the panels follow through CSS custom properties, and the map paints its sea, land, clouds and labels in the night
|
||||
// colours in both renderers, painting its cached layers again once when the theme changes (not on every frame).
|
||||
// jsdom has no matchMedia: the tests lend the page one, before it is parsed (the harness's browser hook) or after.
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const { load, browser, flush } = require('./harness');
|
||||
const { assemble } = require('../scripts/lib/page');
|
||||
|
||||
// A device setting the test can flip: matchMedia('(prefers-color-scheme: dark)') with change listeners.
|
||||
const device = (dark) => {
|
||||
const q = { matches: dark, media: '(prefers-color-scheme: dark)', fns: [],
|
||||
addEventListener(t, f) { if (t === 'change') this.fns.push(f); }, removeEventListener(t, f) { this.fns = this.fns.filter((x) => x !== f); },
|
||||
set(v) { this.matches = v; for (const f of this.fns.slice()) f({ matches: v }); } };
|
||||
return { q, attach(w) { w.matchMedia = (m) => (/prefers-color-scheme:\s*dark/.test(m) ? q : { matches: false, addEventListener() {}, removeEventListener() {} }); } };
|
||||
};
|
||||
const meta = (doc, n) => doc.querySelector(`meta[name="${n}"]`).getAttribute('content');
|
||||
// WCAG contrast between two #RRGGBB colours.
|
||||
const lum = (h) => { h = h.replace('#', ''); const c = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16) / 255).map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4)); return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]; };
|
||||
const cr = (a, b) => { const x = lum(a), y = lum(b); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); };
|
||||
// Only the page's <head>, up to its styles, as the browser runs it before the first paint: the game script at the end
|
||||
// of <body> (which sets the theme as well, but late) is not there. ls: what window.localStorage gives, or throws.
|
||||
const headOnly = (dark, ls) => {
|
||||
const html = assemble().html, head = html.slice(0, html.indexOf('<style>')) + '</head><body></body></html>';
|
||||
const dom = new JSDOM(head, { runScripts: 'dangerously', url: 'https://tests.invalid/', beforeParse(w) {
|
||||
device(dark).attach(w);
|
||||
if (ls) Object.defineProperty(w, 'localStorage', { configurable: true, get: () => ls(w) });
|
||||
} });
|
||||
const doc = dom.window.document, r = [doc.documentElement.getAttribute('data-theme'), meta(doc, 'theme-color'), meta(doc, 'color-scheme')];
|
||||
dom.window.close();
|
||||
return r;
|
||||
};
|
||||
const DARK = ['dark', '#0E2A44', 'dark'], LIGHT = ['light', '#57C4E5', 'light'];
|
||||
const started = "ACT.start({});if(UI.pendGame)ACT.pitchSkip();S.nextFail=S.nextEvent=1e9;UI.speed=0;closeModal();compute();renderAll();";
|
||||
|
||||
test('the choice applies at boot, from the <head>, before the page is painted', () => {
|
||||
for (const [storage, want, pref] of [[{ 'sot-theme': 'dark' }, 'dark', 'dark'], [{ 'sot-theme': 'light' }, 'light', 'light'], [{}, 'light', 'auto'], [{ 'sot-theme': 'neon' }, 'light', 'auto']]) {
|
||||
const { dom, ev, errors } = load({ storage });
|
||||
const doc = dom.window.document;
|
||||
assert.equal(doc.documentElement.getAttribute('data-theme'), want, JSON.stringify(storage));
|
||||
assert.equal(meta(doc, 'theme-color'), want === 'dark' ? '#0E2A44' : '#57C4E5', 'the browser bar follows');
|
||||
assert.equal(meta(doc, 'color-scheme'), want);
|
||||
assert.equal(ev('THEME.pref'), pref);
|
||||
assert.equal(ev('THEME.dark'), want === 'dark');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
}
|
||||
// The script that sets it sits in the <head>, before the styles: nothing is painted in the wrong colours first.
|
||||
const doc = load().dom.window.document, head = [...doc.head.children];
|
||||
const s = head.findIndex((e) => e.tagName === 'SCRIPT' && /sot-theme/.test(e.textContent)), st = head.findIndex((e) => e.tagName === 'STYLE');
|
||||
assert.ok(s >= 0 && s < st, 'the theme script runs before the stylesheet');
|
||||
// Auto with a dark device: dark from the first paint as well.
|
||||
const d = device(true), h = load({ browser: d });
|
||||
assert.equal(h.dom.window.document.documentElement.getAttribute('data-theme'), 'dark');
|
||||
assert.equal(h.ev('THEME.dark'), true);
|
||||
assert.deepEqual(h.errors, []);
|
||||
});
|
||||
|
||||
test('the <head> alone sets the theme, and a dark device stays dark when the site\'s storage is blocked', () => {
|
||||
const saved = (v) => () => ({ getItem: (k) => (k === 'sot-theme' ? v : null) });
|
||||
assert.deepEqual(headOnly(true), DARK, 'Auto on a dark device');
|
||||
assert.deepEqual(headOnly(false), LIGHT, 'Auto on a light device');
|
||||
assert.deepEqual(headOnly(false, saved('dark')), DARK, 'Dark chosen');
|
||||
assert.deepEqual(headOnly(true, saved('light')), LIGHT, 'Light chosen');
|
||||
// Cookies and site data blocked (Chrome, sandboxed frames: a SecurityError), storage switched off (Firefox: null),
|
||||
// or a getItem that throws: the device's setting still decides, before the first paint.
|
||||
const blocked = [(w) => { throw new w.DOMException('The operation is insecure.', 'SecurityError'); }, () => null, () => ({ getItem() { throw new Error('denied'); } })];
|
||||
for (const ls of blocked) {
|
||||
assert.deepEqual(headOnly(true, ls), DARK, `dark device, blocked storage (${ls})`);
|
||||
assert.deepEqual(headOnly(false, ls), LIGHT, `light device, blocked storage (${ls})`);
|
||||
}
|
||||
// The whole page with blocked storage on a dark device: dark, on Auto.
|
||||
const blockedDevice = { attach(w) { device(true).attach(w); Object.defineProperty(w, 'localStorage', { configurable: true, get() { throw new w.DOMException('The operation is insecure.', 'SecurityError'); } }); } };
|
||||
const { dom, ev, errors } = load({ browser: blockedDevice });
|
||||
assert.equal(dom.window.document.documentElement.getAttribute('data-theme'), 'dark');
|
||||
assert.deepEqual(JSON.parse(ev('JSON.stringify([THEME.pref,THEME.dark])')), ['auto', true]);
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
});
|
||||
|
||||
test('Auto follows the device when its setting changes; Light and Dark do not', () => {
|
||||
const d = device(false), { dom, ev, errors } = load({ browser: d });
|
||||
const root = dom.window.document.documentElement;
|
||||
ev(started);
|
||||
assert.equal(root.getAttribute('data-theme'), 'light');
|
||||
d.q.set(true);
|
||||
assert.equal(root.getAttribute('data-theme'), 'dark', 'the device went dark');
|
||||
assert.equal(ev('THEME.dark'), true);
|
||||
assert.equal(meta(dom.window.document, 'theme-color'), '#0E2A44');
|
||||
d.q.set(false);
|
||||
assert.equal(root.getAttribute('data-theme'), 'light', 'and light again');
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
d.q.set(true); d.q.set(false);
|
||||
assert.equal(root.getAttribute('data-theme'), 'dark', 'Dark stays dark whatever the device says');
|
||||
ev("ACT.themeSet({v:'light'})");
|
||||
d.q.set(true);
|
||||
assert.equal(root.getAttribute('data-theme'), 'light', 'Light stays light');
|
||||
ev("ACT.themeSet({v:'auto'})");
|
||||
assert.equal(root.getAttribute('data-theme'), 'dark', 'Auto takes the device setting at once');
|
||||
assert.equal(d.q.fns.length, 1, 'one listener');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a choice made in one tab reaches the others (the NOC window on a second screen too)', async () => {
|
||||
const b = browser(), A = load({ browser: b }), B = load({ browser: b });
|
||||
A.ev("ACT.themeSet({v:'dark'})");
|
||||
await flush();
|
||||
assert.equal(B.dom.window.document.documentElement.getAttribute('data-theme'), 'dark');
|
||||
assert.equal(B.ev('THEME.pref'), 'dark');
|
||||
A.ev("ACT.themeSet({v:'auto'})");
|
||||
await flush();
|
||||
assert.equal(B.dom.window.document.documentElement.getAttribute('data-theme'), 'light');
|
||||
assert.deepEqual([...A.errors, ...B.errors], []);
|
||||
for (const h of [A, B]) h.dom.window.close();
|
||||
});
|
||||
|
||||
test('Settings › Theme: three choices, on the title screen and in a game, kept on the device and not in the save', () => {
|
||||
const { dom, ev, errors } = load();
|
||||
const doc = dom.window.document, root = doc.documentElement;
|
||||
const row = () => [...doc.querySelectorAll('#modalCard [data-act="themeSet"]')].map((b) => [JSON.parse(b.dataset.args).v, b.textContent, b.className.includes('pink')]);
|
||||
// The title screen: no game yet, the button still works.
|
||||
ev('ACT.settings({})');
|
||||
assert.deepEqual(row(), [['auto', 'Auto', true], ['light', 'Light', false], ['dark', 'Dark', false]]);
|
||||
doc.querySelector('#modalCard [data-act="themeSet"][data-args*="dark"]').click();
|
||||
assert.equal(root.getAttribute('data-theme'), 'dark');
|
||||
assert.equal(ev("localStorage.getItem('sot-theme')"), 'dark');
|
||||
assert.deepEqual(row().map((r) => r[2]), [false, false, true], 'the settings show the new choice');
|
||||
ev("ACT.settingsClose({})");
|
||||
// In a game: the choice is not part of it.
|
||||
ev(started);
|
||||
const before = ev('JSON.stringify(S)');
|
||||
ev("ACT.settings({});ACT.themeSet({v:'light'})");
|
||||
assert.equal(root.getAttribute('data-theme'), 'light');
|
||||
assert.equal(ev("localStorage.getItem('sot-theme')"), 'light');
|
||||
assert.equal(ev('JSON.stringify(S)'), before, 'the save is untouched');
|
||||
ev("ACT.themeSet({v:'auto'})");
|
||||
assert.equal(ev("localStorage.getItem('sot-theme')"), null, 'Auto is the default: nothing kept');
|
||||
ev("ACT.themeSet({v:'sepia'});ACT.themeSet({})");
|
||||
assert.equal(ev('THEME.pref'), 'auto', 'anything else is ignored');
|
||||
// A puzzle keeps its settings working.
|
||||
assert.ok(ev("PZ_ACTS.has('themeSet')"));
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the map paints sea, land, clouds and labels in the theme\'s colours, in 2D, and paints its cached land again once', () => {
|
||||
const { ev, errors } = load({ storage: { 'sot-map': '2d' } });
|
||||
ev(started + "const h=CITY[S.home];cam.x=h.x;cam.y=h.y;cam.z=1.4;");
|
||||
// What paintWorld() fills and strokes, on a recording context.
|
||||
const world = () => JSON.parse(ev(`(()=>{const r={f:[],s:[],save(){},restore(){},translate(){},beginPath(){},moveTo(){},lineTo(){},ellipse(){},setLineDash(){},
|
||||
fill(){this.f.push(this.fillStyle);},stroke(){this.s.push(this.strokeStyle);}};paintWorld(r,1.4,false);return JSON.stringify({f:[...new Set(r.f)],s:[...new Set(r.s)]});})()`));
|
||||
const P = JSON.parse(ev('JSON.stringify(MAP_PAL)'));
|
||||
let w = world();
|
||||
assert.deepEqual(w.f, [P.light.shadow, P.light.land, P.light.hill, P.light.shine]);
|
||||
assert.deepEqual(w.s, [P.light.sand, P.light.coast]);
|
||||
// The sea's gradient, the waves and the clouds of a 2D frame, and the labels' pills.
|
||||
ev(`window.__sea=[];CTX0.createLinearGradient=()=>({addColorStop:(o,c)=>__sea.push(c)});window.__pills=[];const __p=pill;pill=function(t,f,w,h,r,fill,ink,edge){__pills.push(fill+'/'+ink+'/'+edge);return __p.apply(this,arguments);};
|
||||
window.__paints=0;const __pw=paintWorld;paintWorld=function(){__paints++;return __pw.apply(this,arguments);};`);
|
||||
const frame = (t) => JSON.parse(ev(`(()=>{__sea.length=0;__pills.length=0;__paints=0;draw(${t});return JSON.stringify({sea:__sea.slice(),pills:[...new Set(__pills)],paints:__paints,wave:CTX0.strokeStyle});})()`));
|
||||
let f = frame(1000);
|
||||
assert.deepEqual(f.sea, [P.light.sea, P.light.sea2]);
|
||||
assert.ok(f.pills.includes(`${P.light.pill}/${P.light.pillInk}/${P.light.pillEdge}`), 'city labels on white pills');
|
||||
assert.equal(frame(1000).paints, 0, 'nothing changed: the land is not painted again');
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
assert.equal(ev('WL.key'), null, 'the land picture is let go');
|
||||
assert.equal(ev('SPRC.size'), 0, 'and every sprite painted in the old colours');
|
||||
w = world();
|
||||
assert.deepEqual(w.f, [P.dark.shadow, P.dark.land, P.dark.hill, P.dark.shine]);
|
||||
assert.deepEqual(w.s, [P.dark.sand, P.dark.coast]);
|
||||
f = frame(1016);
|
||||
assert.deepEqual(f.sea, [P.dark.sea, P.dark.sea2]);
|
||||
assert.equal(f.paints, 1, 'the land is painted again, once');
|
||||
assert.ok(f.pills.includes(`${P.dark.pill}/${P.dark.pillInk}/${P.dark.pillEdge}`), 'city labels on dark pills');
|
||||
assert.ok(!f.pills.includes(`${P.light.pill}/${P.light.pillInk}/${P.light.pillEdge}`), 'no light label left');
|
||||
assert.ok(f.pills.some((p) => p.startsWith('#FF4F9A/')), 'your POPs keep their pink labels');
|
||||
assert.equal(frame(1016).paints, 0, 'and not on the next frame');
|
||||
// Paused and unmoved, the map is drawn again for the theme (mapStill() would otherwise keep the old frame).
|
||||
ev("FRAME.length=0;mapStill(0,performance.now());UI.drawnAt=performance.now();");
|
||||
assert.equal(ev('mapStill(0,performance.now())'), true, 'an unchanged frame is skipped');
|
||||
ev("ACT.themeSet({v:'light'})");
|
||||
assert.equal(ev('mapStill(0,performance.now())'), false, 'a theme change draws the map again');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// A WebGL2 stand-in that records calls (as tests/webgl-map.test.js).
|
||||
const STUB = `(()=>{const calls=[];const gl=new Proxy({calls},{get(t,k){if(k in t)return t[k];if(typeof k==='string'&&/^[A-Z_0-9]+$/.test(k))return k;
|
||||
if(k==='isContextLost')return ()=>false;return (...a)=>{calls.push([k,...a]);return {};};}});
|
||||
const c=document.getElementById('mapgl'),f=document.getElementById('mapfx');
|
||||
const P=()=>({p:{},u:{}}),B=()=>({v:{},b:{}});
|
||||
Object.assign(GLX,{want:true,dead:false,gl,c,f,fx:f.getContext('2d'),line:P(),pk:P(),fill:P(),fan:P(),ell:P(),land:{},circ:P(),tex:{},lv:B(),hv:B(),pv:B(),cb:B(),wv:B(),dv:B(),cl:B(),empty:{},key:[],gpu:'stub'});return gl;})()`;
|
||||
|
||||
test('on the graphics card too: the sea, the land and its coastlines in the theme\'s colours, built again once', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(started + "const h=CITY[S.home];cam.x=h.x;cam.y=h.y;cam.z=1.4;");
|
||||
ev(STUB);
|
||||
const pm = (s) => JSON.parse(ev(`JSON.stringify(glPm(${JSON.stringify(s)}))`));
|
||||
const P = JSON.parse(ev('JSON.stringify(MAP_PAL)'));
|
||||
// The colours sent with uniform4fv (sea, land, hills, clouds) and the coastline colours in the land's buffers.
|
||||
const frame = (t) => JSON.parse(ev(`(()=>{GLX.gl.calls.length=0;draw(${t});const c=GLX.gl.calls;
|
||||
const u=c.filter(x=>x[0]==='uniform4fv').map(x=>Array.from(x[2]).map(v=>Math.round(v*1e4)/1e4).join(','));
|
||||
const lines=c.filter(x=>x[0]==='bufferData'&&x[3]==='STATIC_DRAW'&&x[2]&&x[2].length%LINE_STRIDE===0&&x[2].length>LINE_STRIDE*1000).map(x=>[x[2][9],x[2][10],x[2][11]].map(v=>Math.round(v*1e4)/1e4).join(','));
|
||||
return JSON.stringify({u:[...new Set(u)],lines,del:c.filter(x=>x[0]==='deleteBuffer').length,land:Object.keys(GLX.land).length});})()`));
|
||||
const key = (a) => a.map((v) => Math.round(v * 1e4) / 1e4).join(',');
|
||||
const rgb = (s) => key(JSON.parse(ev(`JSON.stringify(glColor(${JSON.stringify(s)}).slice(0,3))`)));
|
||||
let f = frame(1000);
|
||||
assert.equal(ev('glOn()'), true);
|
||||
for (const k of ['sea', 'sea2', 'land', 'hill', 'shadow', 'cloud']) assert.ok(f.u.includes(key(pm(P.light[k]))), `light ${k} on the card`);
|
||||
assert.ok(f.lines.includes(rgb(P.light.sand)) && f.lines.includes(rgb(P.light.coast)), 'light sand and coastline in the land buffers');
|
||||
assert.equal(frame(1016).lines.length, 0, 'an ordinary frame uploads no land');
|
||||
assert.equal(ev('glPal()===glPal()&&GLP.m===MAP_PAL.light'), true, 'the colours are worked out once, not per frame');
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
assert.equal(ev('Object.keys(GLX.land).length'), 0, 'the land is let go');
|
||||
assert.ok(ev("GLX.gl.calls.filter(x=>x[0]==='deleteBuffer').length") > 0, 'its buffers freed');
|
||||
f = frame(1032);
|
||||
for (const k of ['sea', 'sea2', 'land', 'hill', 'shadow', 'cloud']) assert.ok(f.u.includes(key(pm(P.dark[k]))), `dark ${k} on the card`);
|
||||
assert.ok(!f.u.includes(key(pm(P.light.sea))), 'no light sea left');
|
||||
assert.ok(f.lines.includes(rgb(P.dark.sand)) && f.lines.includes(rgb(P.dark.coast)), 'dark sand and coastline in the new land buffers');
|
||||
assert.equal(f.land, 1, 'one level of land built for the view');
|
||||
assert.equal(frame(1048).lines.length, 0, 'and only once');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
// Two tubes that were nearly lost at night: a dark fiber with no channels lit yet, and a virtual circuit on the ccn
|
||||
// fabric (thin, dotted, purple). Every tube is drawn over its casing, which the theme gives (MAP_PAL.*.casing).
|
||||
const TUBES = "S.links.push({id:'unlit',a:'fra',b:'ams',kind:'df',own:false,sys:'dwdm',ch:[],cable:null,km:kmBetween('fra','ams'),sub:false,mo:1000,trench:'t-unlit',ready:0,day:0,cut:0,spares:false},"
|
||||
+ "{id:'vc',a:'fra',b:'lon',kind:'vxc',prov:'ccn',vt:1,km:kmBetween('fra','lon'),sub:false,mo:0,cut:0,day:0});compute();cam.x=CITY.fra.x;cam.y=CITY.fra.y;cam.z=1.4;";
|
||||
const tubeCols = (ev) => JSON.parse(ev("JSON.stringify(Object.fromEntries(['unlit','vc'].map(id=>[id,linkLook([S.links.find(l=>l.id===id)],S.day).col])))"));
|
||||
|
||||
test('every tube keeps an outline that stands out from the land and the sea, by night as by day', () => {
|
||||
const { ev, errors } = load({ storage: { 'sot-map': '2d' } });
|
||||
ev(started + TUBES);
|
||||
const P = JSON.parse(ev('JSON.stringify(MAP_PAL)')), col = tubeCols(ev);
|
||||
assert.equal(ev('linkLook([S.links.find(l=>l.id==="unlit")],S.day).dark'), true, 'an unlit dark fiber');
|
||||
assert.equal(col.vc, ev('FAB.ccn.col'), 'the ccn fabric\'s colour');
|
||||
// The casing is what parts a tube from the map: 3:1 at least on the land and both ends of the sea, in either theme.
|
||||
// The cores sit inside it, so they must stand out from it (the unlit fiber and the purple circuit are the darkest).
|
||||
for (const t of ['light', 'dark']) {
|
||||
for (const bg of ['land', 'sea', 'sea2']) assert.ok(cr(P[t].casing, P[t][bg]) >= 3, `${t}: the casing on the ${bg}: ${cr(P[t].casing, P[t][bg]).toFixed(2)}`);
|
||||
for (const [k, c] of Object.entries(col)) assert.ok(cr(c, P[t].casing) >= 2.5, `${t}: the ${k} core in its casing: ${cr(c, P[t].casing).toFixed(2)}`);
|
||||
}
|
||||
// In 2D: each core is stroked right over its casing, in the theme's colour, and a switch changes it on the next frame.
|
||||
ev("window.__st=[];CTX0.stroke=function(){__st.push(this.strokeStyle);};");
|
||||
const strokes = (t) => JSON.parse(ev(`(()=>{__st.length=0;draw(${t});return JSON.stringify(__st);})()`));
|
||||
const under = (st, c) => st.flatMap((x, i) => (x === c && i ? [st[i - 1]] : []));
|
||||
let st = strokes(1000);
|
||||
for (const c of Object.values(col)) assert.deepEqual([...new Set(under(st, c))], [P.light.casing], `light: ${c} over the light casing`);
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
st = strokes(1016);
|
||||
for (const c of Object.values(col)) assert.deepEqual([...new Set(under(st, c))], [P.dark.casing], `dark: ${c} over the dark casing`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('on the graphics card the tubes\' casing is the theme\'s too (a uniform: the tubes\' buffers are not rebuilt)', () => {
|
||||
const { ev, errors } = load();
|
||||
ev(started + TUBES);
|
||||
ev(STUB);
|
||||
const P = JSON.parse(ev('JSON.stringify(MAP_PAL)'));
|
||||
assert.ok(ev('GL_LINE_VS').includes('col=vec4(uCas,1.)'), 'the casing pass takes its colour from uCas');
|
||||
assert.ok(!ev('GL_LINE_VS').includes('30./255.'), 'no casing colour left in the line shader');
|
||||
ev("GLX.line.u.uCas='uCas'");
|
||||
const rgb = (s) => JSON.parse(ev(`JSON.stringify(glColor(${JSON.stringify(s)}).slice(0,3))`)).map((v) => Math.round(v * 1e4) / 1e4).join(',');
|
||||
const frame = (t) => JSON.parse(ev(`(()=>{GLX.gl.calls.length=0;draw(${t});const c=GLX.gl.calls;
|
||||
return JSON.stringify({cas:[...new Set(c.filter(x=>x[0]==='uniform3f'&&x[1]==='uCas').map(x=>x.slice(2).map(v=>Math.round(v*1e4)/1e4).join(',')))],
|
||||
tubes:c.filter(x=>x[0]==='bufferData'&&x[1]===GLX.lv.b).length,seg:GLX.nSeg});})()`));
|
||||
let f = frame(1000);
|
||||
assert.equal(ev('glOn()'), true);
|
||||
assert.ok(f.seg > 0, 'tubes on the card');
|
||||
assert.deepEqual(f.cas, [rgb(P.light.casing)]);
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
f = frame(1016);
|
||||
assert.deepEqual(f.cas, [rgb(P.dark.casing)], 'the dark casing on the next frame');
|
||||
assert.equal(f.tubes, 0, 'without building the tubes again');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('a puzzle\'s stepping stones keep a dashed ring that reads on the night land and sea', () => {
|
||||
const { ev, errors } = load();
|
||||
ev("localStorage.removeItem('sot-puzzles');pzBegin(pzDef('baltic'));closeModal();");
|
||||
assert.equal(ev("pzKind('hel')"), 'via', 'Helsinki is the stepping stone');
|
||||
const P = JSON.parse(ev('JSON.stringify(MAP_PAL)'));
|
||||
// An rgba() ring over a solid background, as the eye sees it.
|
||||
const over = (rgba, bg) => { const [r, g, b, a] = rgba.match(/[\d.]+/g).map(Number), h = bg.replace('#', '');
|
||||
return '#' + [r, g, b].map((v, i) => Math.round(v * a + parseInt(h.slice(i * 2, i * 2 + 2), 16) * (1 - a)).toString(16).padStart(2, '0')).join(''); };
|
||||
for (const t of ['light', 'dark']) for (const bg of ['land', 'sea']) {
|
||||
const c = cr(over(P[t].via, P[t][bg]), P[t][bg]);
|
||||
assert.ok(c >= 3, `${t}: the stepping-stone ring on the ${bg}: ${c.toFixed(2)}`);
|
||||
}
|
||||
// The ring a frame strokes (dashed 5,5) is the theme's.
|
||||
ev("window.__st=[];window.__d='';CTX0.setLineDash=function(a){__d=String(a);};CTX0.stroke=function(){__st.push(this.strokeStyle+'|'+__d);};");
|
||||
const rings = (t) => JSON.parse(ev(`(()=>{__st.length=0;cam.x=CITY.hel.x;cam.y=CITY.hel.y;cam.z=2;draw(${t});return JSON.stringify([...new Set(__st.filter(s=>s.endsWith('|5,5')).map(s=>s.split('|')[0]))]);})()`));
|
||||
assert.deepEqual(rings(1000), [P.light.via]);
|
||||
ev("ACT.themeSet({v:'dark'})");
|
||||
assert.deepEqual(rings(1016), [P.dark.via]);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('the Pie globe starts at night in the dark theme, unless the player picked day or night', () => {
|
||||
let h = load({ storage: { 'sot-theme': 'dark' } });
|
||||
assert.equal(h.ev('pgNightPref()'), true);
|
||||
h.ev("ACT.themeSet({v:'light'})");
|
||||
assert.equal(h.ev('PG.night'), false, 'it follows the theme while the player has not chosen');
|
||||
h = load({ storage: { 'sot-theme': 'dark', 'sot-globe': 'day' } });
|
||||
assert.equal(h.ev('pgNightPref()'), false, 'the player\'s day view stays');
|
||||
h.ev("ACT.themeSet({v:'light'});ACT.themeSet({v:'dark'})");
|
||||
assert.equal(h.ev('PG.night'), false);
|
||||
assert.deepEqual(h.errors, []);
|
||||
});
|
||||
|
||||
test('dark on a phone (360 px): the settings row, the panels and every language', () => {
|
||||
for (const lang of ['en', 'de', 'fr']) {
|
||||
const { dom, ev, errors } = load({ lang: lang === 'en' ? undefined : lang, storage: { 'sot-theme': 'dark' } });
|
||||
const doc = dom.window.document;
|
||||
ev("window.innerWidth=360;window.innerHeight=740;" + started + "ACT.launchBB({city:S.home});UI.sel={type:'city',id:S.home};renderAll();ACT.settings({});");
|
||||
const line = doc.querySelector('#modalCard [data-act="themeSet"]').closest('.setline');
|
||||
assert.ok(line, 'the Theme row is a settings line');
|
||||
assert.equal(line.querySelectorAll('[data-act="themeSet"]').length, 3);
|
||||
const names = [...line.querySelectorAll('[data-act="themeSet"]')].map((b) => b.textContent);
|
||||
if (lang === 'de') assert.deepEqual(names, ['Auto', 'Hell', 'Dunkel']);
|
||||
if (lang === 'fr') assert.deepEqual(names, ['Auto', 'Clair', 'Sombre']);
|
||||
ev("ACT.settingsClose({});ACT.dash({})");
|
||||
for (const id of ['hud', 'panelBody', 'leftBody', 'dashCard', 'tabbar']) {
|
||||
const t = doc.getElementById(id).textContent;
|
||||
assert.doesNotMatch(t, /\b(settings|common)\.[a-z0-9_]+\b|undefined|NaN/, `${lang} ${id}`);
|
||||
}
|
||||
assert.equal(ev('isPhone()'), true);
|
||||
assert.equal(doc.documentElement.getAttribute('data-theme'), 'dark');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
}
|
||||
});
|
||||
|
||||
// The styles: every dark token the panels use is defined, and text on the dark panels passes WCAG AA (4.5:1).
|
||||
test('the dark look defines every token it is used with, and its text reads (AA)', () => {
|
||||
const html = assemble().html, css = html.slice(html.indexOf('<style>'), html.indexOf('</style>'));
|
||||
const block = (sel) => { const i = css.indexOf(sel + '{'); assert.ok(i >= 0, sel); return css.slice(i, css.indexOf('}', i)); };
|
||||
const dark = block(':root[data-theme="dark"]'), light = block(':root');
|
||||
const val = (b, k) => { const m = new RegExp(`--${k}:\\s*([^;\\n]+);`).exec(b); return m && m[1].trim(); };
|
||||
// Every var(--tint-…, light) and var(--tx-…, light) in the styles and the game's own markup has a dark value.
|
||||
const src = css + fs.readdirSync(path.join(__dirname, '..', 'src', 'game'), { recursive: true }).filter((f) => f.endsWith('.js')).map((f) => fs.readFileSync(path.join(__dirname, '..', 'src', 'game', f), 'utf8')).join('\n');
|
||||
const used = new Set([...src.matchAll(/var\(--((?:tint|tx)-[a-z]+),\s*#[0-9A-Fa-f]{3,6}\)/g)].map((m) => m[1]));
|
||||
assert.ok(used.size >= 8, `tints in use (${[...used]})`);
|
||||
for (const k of used) assert.ok(val(dark, k), `--${k} has a dark value`);
|
||||
// Every plain var(--x) in the styles is defined for the light look (dark only overrides).
|
||||
for (const m of css.matchAll(/var\(--([a-z0-9-]+)\)/g)) if (!/^(tabbar|app-h|c|rc|d|x|t|r|dl|pzdock)$/.test(m[1])) assert.ok(val(light, m[1]), `--${m[1]} is defined`);
|
||||
const bgs = ['paper', 'soft', 'tint-y', 'tint-g', 'tint-r', 'tint-p', 'tint-b', 'tint-v', 'tint-o', 'tint-n'].map((k) => [k, val(dark, k)]);
|
||||
for (const t of ['text', 'ink2', 'eye']) for (const [k, b] of bgs) assert.ok(cr(val(dark, t), b) >= 4.5, `--${t} on --${k}: ${cr(val(dark, t), b).toFixed(2)}`);
|
||||
for (const t of ['tx-red', 'tx-amber']) assert.ok(cr(val(dark, t), val(dark, 'paper')) >= 4.5, `--${t} on the dark paper`);
|
||||
// The outline stays dark in both looks, so text on bright fills (yellow buttons, warning tags) keeps reading.
|
||||
assert.ok(cr(val(dark, 'ink'), '#FFD23F') >= 7, 'dark ink on the yellow buttons');
|
||||
// Badge labels (10px, so 4.5:1) on their night cards: each variant's gradient, and the dimmed card of one not earned now.
|
||||
const rules = css.replace(/\/\*[\s\S]*?\*\//g, '').split('}').map((r) => { const i = r.indexOf('{'); return i < 0 ? null : { sel: r.slice(0, i).split(',').map((x) => x.trim()), body: r.slice(i + 1) }; }).filter(Boolean);
|
||||
const decl = (sel, prop) => { let v = null; for (const r of rules) if (r.sel.includes(sel)) { const m = new RegExp(`(?:^|;)\\s*${prop}\\s*:\\s*([^;]+)`).exec(r.body); if (m) v = m[1].trim(); } return v; };
|
||||
const D = ':root[data-theme="dark"] ';
|
||||
for (const v of ['freeze', 'bgp']) {
|
||||
const label = decl(D + `.bdg.v-${v} .bv`, 'color') || decl(`.bdg.v-${v} .bv`, 'color'), stops = decl(D + `.bdg.on.v-${v}`, 'background').match(/#[0-9A-Fa-f]{6}/g);
|
||||
assert.ok(label && stops.length >= 2, v);
|
||||
for (const b of [...stops, val(dark, 'tint-n')]) assert.ok(cr(label, b) >= 4.5, `the ${v} badge label ${label} on ${b}: ${cr(label, b).toFixed(2)}`);
|
||||
}
|
||||
// The dashboard's Demand key is an outline in its line's colour (--text): dark ink by day as before, light at night.
|
||||
assert.equal(val(light, 'text'), val(light, 'ink'), 'by day the key looks as it always did');
|
||||
assert.ok(cr(val(dark, 'text'), val(dark, 'paper')) >= 3, 'at night the key\'s outline shows on the card');
|
||||
});
|
||||
|
||||
test('the dashboard\'s Demand key matches its dashed line, by night too', () => {
|
||||
const { dom, ev, errors } = load({ storage: { 'sot-theme': 'dark' } });
|
||||
ev(started + "for(let i=0;i<3;i++)dayTick();ACT.dash({});");
|
||||
const card = dom.window.document.getElementById('dashCard');
|
||||
const line = card.querySelector('svg path[stroke-dasharray="5 4"]');
|
||||
assert.ok(line, 'the dashed Demand line');
|
||||
const stroke = /stroke:\s*([^;"]+)/.exec(line.getAttribute('style'))[1].trim();
|
||||
const key = [...card.querySelectorAll('.legend .lg')].find((b) => JSON.parse(b.dataset.args).k === 'dem').querySelector('i');
|
||||
assert.equal(key.style.borderStyle, 'dashed');
|
||||
assert.equal(key.style.borderColor, stroke, 'the key is outlined in the line\'s own colour');
|
||||
assert.equal(stroke, 'var(--text)');
|
||||
assert.deepEqual(errors, []);
|
||||
dom.window.close();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue