BlueGit

projects-timfalken-com meteors

feat: language picker and translated player-facing text (t1141)

The main menu shows the current flag at the bottom right. Choosing a
language applies every player-facing string, persists in localStorage
and a cookie, and is saved to the profile when you are logged in.
CJK fonts and wrapping keep longer translations on the screen.

timfa Grok Bot · pushed by timfa

Authored 2026-11-13 · 4 days ago

Hash
a2121005a5b708bc8f234056ff2771a181eedcc1
Parent
6d810496
9 files changed +416 −148
build/index.html +75 −69
@@ -1,5 +1,5 @@
1 1 <!DOCTYPE html>
2 <html lang="nl">
2 <html lang="en">
3 3 <head>
4 4 <meta charset="utf-8">
5 5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
@@ -17,133 +17,139 @@
17 17
18 18 <div id="menu" class="screen">
19 19 <h1>Meteors</h1>
20 <p class="tagline">Drie op een rij, en je blokjes krijgen raketmotoren.</p>
21 <button type="button" id="btn-play">Spelen</button>
22 <button type="button" id="btn-offline" class="btn-secondary">Offline Strijd</button>
23 <button type="button" id="btn-online" class="btn-secondary">Online spelen</button>
24 <button type="button" id="btn-designer" class="btn-secondary" hidden>Planeetontwerper</button>
25 <p id="last-score" class="last-score" hidden>Laatste score: <strong>0</strong></p>
26 <p class="hint">Sleep blokjes verticaal om ze te wisselen. Trek een blokje boven zijn kolom om het omhoog te duwen. Blokjes die het veld verlaten, leveren punten op.</p>
20 <p class="tagline" data-i18n="menu.tagline">Three in a row, and your blocks get rocket boosters.</p>
21 <button type="button" id="btn-play" data-i18n="menu.play">Play</button>
22 <button type="button" id="btn-offline" class="btn-secondary" data-i18n="menu.offline">Offline Battle</button>
23 <button type="button" id="btn-online" class="btn-secondary" data-i18n="menu.online">Play online</button>
24 <button type="button" id="btn-designer" class="btn-secondary" hidden data-i18n="menu.designer">Planet Designer</button>
25 <p id="last-score" class="last-score" hidden><span data-i18n="menu.lastScore">Last score:</span> <strong>0</strong></p>
26 <p class="hint" data-i18n="menu.hint">Drag blocks vertically to swap them. Pull a block above its column to launch it upward. Blocks that leave the field score points.</p>
27 27 <div id="menu-account" class="menu-account">
28 28 <p id="menu-guest">
29 <a id="menu-login" href="auth.php">Inloggen</a>
29 <a id="menu-login" href="auth.php" data-i18n="menu.login">Log in</a>
30 30 <span id="menu-local-login" hidden>
31 · lokale test:
31 · <span data-i18n="menu.localTest">local test:</span>
32 32 <a href="auth.php?test=1">test_user_1</a> ·
33 33 <a href="auth.php?test=2">test_user_2</a>
34 34 </span>
35 35 </p>
36 36 <p id="menu-user" hidden>
37 Ingelogd als <strong id="menu-name"></strong>
38 · Totaal: <strong id="menu-points">0</strong> punten
39 · <a id="menu-logout" href="logout.php">Uitloggen</a>
37 <span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="menu-name"></strong>
38 · <span data-i18n="menu.total">Total:</span> <strong id="menu-points">0</strong> <span data-i18n="menu.pointsWord">points</span>
39 · <a id="menu-logout" href="logout.php" data-i18n="menu.logout">Log out</a>
40 40 </p>
41 41 </div>
42 <div id="lang-picker" class="lang-picker">
43 <button type="button" id="lang-current" class="lang-current" aria-haspopup="listbox" aria-expanded="false" data-i18n-aria="lang.choose">
44 <img src="images/flags/gb.svg" alt="English" width="36" height="24">
45 </button>
46 <div id="lang-list" class="lang-list" role="listbox" hidden></div>
47 </div>
42 48 </div>
43 49
44 50 <div id="planet-select" class="screen" hidden>
45 <h1>Kies een veld</h1>
46 <p class="tagline">Elk veld is een planeet, met een eigen volk, zwaartekracht, lucht en massa.</p>
51 <h1 data-i18n="planet.title">Choose a field</h1>
52 <p class="tagline" data-i18n="planet.tagline">Each field is a planet, with its own people, gravity, air and mass.</p>
47 53 <div id="planet-grid" class="planet-grid" role="list"></div>
48 54 <div class="planet-actions">
49 <button type="button" id="btn-planet-go">Spelen</button>
50 <button type="button" id="btn-planet-back" class="btn-secondary">Terug</button>
55 <button type="button" id="btn-planet-go" data-i18n="menu.play">Play</button>
56 <button type="button" id="btn-planet-back" class="btn-secondary" data-i18n="planet.back">Back</button>
51 57 </div>
52 58 </div>
53 59
54 60 <div id="online-panel" class="screen" hidden>
55 <h1>Online</h1>
56 <p id="online-status" class="tagline">Even kijken of online spelen beschikbaar is…</p>
61 <h1 data-i18n="online.title">Online</h1>
62 <p id="online-status" class="tagline" data-i18n="online.checking">Checking whether online play is available…</p>
57 63 <p id="online-error" class="error" hidden></p>
58 64
59 65 <div id="online-unconfigured" hidden>
60 <p class="notice">Online spelen is nog niet ingesteld. De beheerder moet bij <a href="https://auth.timfalken.com/admin" target="_blank" rel="noopener">auth.timfalken.com/admin</a> het callback-pad <code>/meteors/callback.php</code> toevoegen (zelfde client als de andere sites op dit domein; het geheim <strong>niet</strong> opnieuw genereren) en dat geheim in <code>data/config.php</code> op de server zetten. Zie de README.</p>
61 <p>Je kunt wel alleen spelen.</p>
62 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
66 <p class="notice" data-i18n-html="online.unconfiguredHtml">Online play is not set up yet.</p>
67 <p data-i18n="online.canPlaySolo">You can still play solo.</p>
68 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
63 69 </div>
64 70
65 71 <div id="online-login" hidden>
66 <p>Om online te spelen log je in met je account op auth.timfalken.com.</p>
67 <a id="btn-login" class="button" href="auth.php">Inloggen</a>
68 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
72 <p data-i18n="online.loginPrompt">To play online, log in with your account on auth.timfalken.com.</p>
73 <a id="btn-login" class="button" href="auth.php" data-i18n="menu.login">Log in</a>
74 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
69 75 <p id="local-login" class="hint" hidden>
70 Lokale test:
76 <span data-i18n="online.localTest">Local test:</span>
71 77 <a href="auth.php?test=1">test_user_1</a> ·
72 78 <a href="auth.php?test=2">test_user_2</a>
73 79 </p>
74 80 </div>
75 81
76 82 <div id="online-home" hidden>
77 <p class="who">Ingelogd als <strong id="me-name"></strong> · <a href="logout.php">Uitloggen</a></p>
78 <button type="button" id="btn-create">Lobby maken</button>
83 <p class="who"><span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="me-name"></strong> · <a href="logout.php" data-i18n="menu.logout">Log out</a></p>
84 <button type="button" id="btn-create" data-i18n="online.createLobby">Create lobby</button>
79 85 <form id="join-form" class="join-form">
80 86 <label>
81 <span>Lobbycode</span>
87 <span data-i18n="online.lobbyCode">Lobby code</span>
82 88 <input id="join-code" type="text" maxlength="6" autocomplete="off" spellcheck="false" placeholder="ABCD">
83 89 </label>
84 <button type="submit" id="btn-join">Deelnemen</button>
90 <button type="submit" id="btn-join" data-i18n="online.join">Join</button>
85 91 </form>
86 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
92 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
87 93 </div>
88 94
89 95 <div id="online-lobby" hidden>
90 <p class="who">Ingelogd als <strong id="lobby-me-name"></strong></p>
91 <p class="lobby-code">Code: <strong id="lobby-code"></strong> <button type="button" id="btn-copy-code" class="btn-tiny">Kopieer</button></p>
92 <p class="hint lobby-planet-label">Jouw veld</p>
96 <p class="who"><span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="lobby-me-name"></strong></p>
97 <p class="lobby-code"><span data-i18n="online.code">Code:</span> <strong id="lobby-code"></strong> <button type="button" id="btn-copy-code" class="btn-tiny" data-i18n="online.copy">Copy</button></p>
98 <p class="hint lobby-planet-label" data-i18n="online.yourField">Your field</p>
93 99 <div id="lobby-planet-grid" class="planet-grid compact" role="list"></div>
94 100 <ul id="lobby-players" class="player-list"></ul>
95 101 <p id="lobby-hint" class="hint"></p>
96 102 <div class="lobby-actions">
97 <button type="button" id="btn-ready">Gereed</button>
98 <button type="button" id="btn-start" hidden>Starten</button>
99 <button type="button" id="btn-leave-lobby" class="btn-secondary">Verlaten</button>
103 <button type="button" id="btn-ready" data-i18n="online.ready">Ready</button>
104 <button type="button" id="btn-start" hidden data-i18n="online.start">Start</button>
105 <button type="button" id="btn-leave-lobby" class="btn-secondary" data-i18n="online.leave">Leave</button>
100 106 </div>
101 107 </div>
102 108 </div>
103 109
104 110 <div id="designer" class="screen" hidden>
105 <h1>Planeetontwerper</h1>
106 <p class="tagline">Totaal: <strong id="designer-points">0</strong> punten. Blokjes ontgrendel je door punten te verdienen — je geeft ze niet uit.</p>
111 <h1 data-i18n="designer.title">Planet Designer</h1>
112 <p class="tagline"><span data-i18n="designer.taglineBefore">Total:</span> <strong id="designer-points">0</strong> <span data-i18n="designer.taglineAfter">points. You unlock blocks by earning points — you do not spend them.</span></p>
107 113 <div id="designer-list" class="planet-grid" role="list"></div>
108 114 <div class="planet-actions">
109 <button type="button" id="btn-designer-new">Nieuwe planeet</button>
110 <button type="button" id="btn-designer-back" class="btn-secondary">Terug</button>
115 <button type="button" id="btn-designer-new" data-i18n="designer.new">New planet</button>
116 <button type="button" id="btn-designer-back" class="btn-secondary" data-i18n="designer.cancel">Back</button>
111 117 </div>
112 118 </div>
113 119
114 120 <div id="designer-edit" class="screen" hidden>
115 <h1 id="designer-edit-title">Nieuwe planeet</h1>
121 <h1 id="designer-edit-title" data-i18n="designer.createTitle">New planet</h1>
116 122 <form id="designer-form" class="designer-form" action="javascript:void(0)">
117 123 <label class="des-field">
118 <span>Naam van de planeet</span>
124 <span data-i18n="designer.name">Planet name</span>
119 125 <input id="des-name" type="text" maxlength="32" autocomplete="off" required>
120 126 </label>
121 127 <label class="des-field">
122 <span>Naam van de bevolking</span>
128 <span data-i18n="designer.people">People’s name</span>
123 129 <input id="des-people" type="text" maxlength="32" autocomplete="off" required>
124 130 </label>
125 131 <label class="des-field des-slider">
126 <span>Zwaartekracht</span>
132 <span data-i18n="designer.gravity">Gravity</span>
127 133 <input id="des-gravity" type="range" min="1" max="4" step="0.1" value="2">
128 134 <span id="des-gravity-val" class="des-val"></span>
129 135 </label>
130 136 <label class="des-field des-slider">
131 <span>Luchtweerstand</span>
137 <span data-i18n="designer.air">Air resistance</span>
132 138 <input id="des-air" type="range" min="1" max="5" step="0.1" value="3">
133 139 <span id="des-air-val" class="des-val"></span>
134 140 </label>
135 141 <label class="des-field des-slider">
136 <span>Massa</span>
142 <span data-i18n="designer.mass">Mass</span>
137 143 <input id="des-mass" type="range" min="0.5" max="3" step="0.1" value="1.5">
138 144 <span id="des-mass-val" class="des-val"></span>
139 145 </label>
140 146 <div id="des-power" class="des-power">Power 0%</div>
141 <p class="hint">Kies vijf blokjes. Klik op een vak om te wisselen.</p>
147 <p class="hint" data-i18n="designer.slotsHint">Choose five blocks. Click a slot to change it.</p>
142 148 <div id="des-slots" class="des-slots"></div>
143 149 <div class="planet-actions">
144 <button type="submit" id="btn-designer-save">Opslaan</button>
145 <button type="button" id="btn-designer-delete" class="btn-secondary" hidden>Verwijderen</button>
146 <button type="button" id="btn-designer-cancel" class="btn-secondary">Terug</button>
150 <button type="submit" id="btn-designer-save" data-i18n="designer.save">Save</button>
151 <button type="button" id="btn-designer-delete" class="btn-secondary" hidden data-i18n="designer.delete">Delete</button>
152 <button type="button" id="btn-designer-cancel" class="btn-secondary" data-i18n="designer.cancel">Back</button>
147 153 </div>
148 154 </form>
149 155 </div>
@@ -151,8 +157,8 @@
151 157 <div id="des-modal" class="des-modal" hidden aria-hidden="true" role="dialog" aria-labelledby="des-modal-title">
152 158 <div class="des-modal-card">
153 159 <div class="des-modal-head">
154 <h2 id="des-modal-title">Kies een blokje</h2>
155 <button type="button" id="des-modal-close" class="btn-tiny">Sluiten</button>
160 <h2 id="des-modal-title" data-i18n="designer.pickBlock">Choose a block</h2>
161 <button type="button" id="des-modal-close" class="btn-tiny" data-i18n="designer.close">Close</button>
156 162 </div>
157 163 <div id="des-modal-grid" class="des-block-grid"></div>
158 164 </div>
@@ -162,7 +168,7 @@
162 168
163 169 <div id="hud" hidden>
164 170 <div class="hud-left">
165 <div class="hud-label">Punten</div>
171 <div class="hud-label" data-i18n="hud.points">Points</div>
166 172 <div id="score">0</div>
167 173 </div>
168 174 <div class="hud-right">
@@ -170,9 +176,9 @@
170 176 <div id="planet-stats"></div>
171 177 </div>
172 178 <div id="offline-hud" class="hud-offline" hidden>
173 <span id="offline-round">Ronde 1</span>
179 <span id="offline-round">Round 1</span>
174 180 <span class="hud-sep">·</span>
175 <span id="offline-opponents">1 tegenstander</span>
181 <span id="offline-opponents">1 opponent</span>
176 182 <span class="hud-sep">·</span>
177 183 <span id="offline-skill">Skill 5%</span>
178 184 </div>
@@ -180,32 +186,32 @@
180 186 </div>
181 187
182 188 <div id="offline-result" class="screen overlay" hidden>
183 <h2>Offline Strijd</h2>
184 <p>Je hebt ronde <strong id="offline-reached">1</strong> bereikt.</p>
189 <h2 data-i18n="offline.resultTitle">Offline Battle</h2>
190 <p id="offline-reached-line">You reached round <strong id="offline-reached">1</strong>.</p>
185 191 <p id="offline-result-detail" class="tagline"></p>
186 <button type="button" id="btn-offline-menu">Terug naar het menu</button>
192 <button type="button" id="btn-offline-menu" data-i18n="offline.backMenu">Back to the menu</button>
187 193 </div>
188 194
189 195 <div id="game-over" class="screen overlay" hidden>
190 <h2>Je hebt verloren</h2>
191 <p>Alle kolommen zitten vast.</p>
192 <p class="go-score">Score: <strong id="go-score">0</strong></p>
196 <h2 data-i18n="gameover.title">You lost</h2>
197 <p data-i18n="gameover.detail">Every column is locked.</p>
198 <p class="go-score"><span data-i18n="gameover.score">Score:</span> <strong id="go-score">0</strong></p>
193 199 </div>
194 200
195 201 <div id="spectator" class="screen overlay" hidden>
196 <h2>Je ligt eruit</h2>
197 <p>Al je kolommen zitten vol. Je kunt toekijken of de wedstrijd verlaten.</p>
202 <h2 data-i18n="spectator.title">You’re out</h2>
203 <p data-i18n="spectator.detail">All your columns are full. You can watch or leave the match.</p>
198 204 <div class="lobby-actions">
199 <button type="button" id="btn-spectate">Toekijken</button>
200 <button type="button" id="btn-leave-game" class="btn-secondary">Verlaten</button>
205 <button type="button" id="btn-spectate" data-i18n="spectator.watch">Spectate</button>
206 <button type="button" id="btn-leave-game" class="btn-secondary" data-i18n="online.leave">Leave</button>
201 207 </div>
202 208 </div>
203 209
204 210 <div id="podium" class="screen overlay" hidden>
205 <h2>Gewonnen!</h2>
206 <p id="podium-title" class="tagline">De laatste speler staat overeind.</p>
211 <h2 data-i18n="podium.title">Victory!</h2>
212 <p id="podium-title" class="tagline" data-i18n="podium.subtitle">The last player is still standing.</p>
207 213 <ol id="podium-list" class="podium-list"></ol>
208 <p class="hint" id="podium-hint">Over 5 seconden teruggaan naar de lobby…</p>
214 <p class="hint" id="podium-hint">Returning to the lobby in 5 seconds…</p>
209 215 </div>
210 216
211 217 <script src="framework.js"></script>
@@ -1,5 +1,5 @@
1<!DOCTYPE html>
1<!DOCTYPE html>
2<html lang="nl">
2<html lang="en">
3<head>
3<head>
4 <meta charset="utf-8">
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
5 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
@@ -17,133 +17,139 @@
17
17
18 <div id="menu" class="screen">
18 <div id="menu" class="screen">
19 <h1>Meteors</h1>
19 <h1>Meteors</h1>
20 <p class="tagline">Drie op een rij, en je blokjes krijgen raketmotoren.</p>
20 <p class="tagline" data-i18n="menu.tagline">Three in a row, and your blocks get rocket boosters.</p>
21 <button type="button" id="btn-play">Spelen</button>
21 <button type="button" id="btn-play" data-i18n="menu.play">Play</button>
22 <button type="button" id="btn-offline" class="btn-secondary">Offline Strijd</button>
22 <button type="button" id="btn-offline" class="btn-secondary" data-i18n="menu.offline">Offline Battle</button>
23 <button type="button" id="btn-online" class="btn-secondary">Online spelen</button>
23 <button type="button" id="btn-online" class="btn-secondary" data-i18n="menu.online">Play online</button>
24 <button type="button" id="btn-designer" class="btn-secondary" hidden>Planeetontwerper</button>
24 <button type="button" id="btn-designer" class="btn-secondary" hidden data-i18n="menu.designer">Planet Designer</button>
25 <p id="last-score" class="last-score" hidden>Laatste score: <strong>0</strong></p>
25 <p id="last-score" class="last-score" hidden><span data-i18n="menu.lastScore">Last score:</span> <strong>0</strong></p>
26 <p class="hint">Sleep blokjes verticaal om ze te wisselen. Trek een blokje boven zijn kolom om het omhoog te duwen. Blokjes die het veld verlaten, leveren punten op.</p>
26 <p class="hint" data-i18n="menu.hint">Drag blocks vertically to swap them. Pull a block above its column to launch it upward. Blocks that leave the field score points.</p>
27 <div id="menu-account" class="menu-account">
27 <div id="menu-account" class="menu-account">
28 <p id="menu-guest">
28 <p id="menu-guest">
29 <a id="menu-login" href="auth.php">Inloggen</a>
29 <a id="menu-login" href="auth.php" data-i18n="menu.login">Log in</a>
30 <span id="menu-local-login" hidden>
30 <span id="menu-local-login" hidden>
31 · lokale test:
31 · <span data-i18n="menu.localTest">local test:</span>
32 <a href="auth.php?test=1">test_user_1</a> ·
32 <a href="auth.php?test=1">test_user_1</a> ·
33 <a href="auth.php?test=2">test_user_2</a>
33 <a href="auth.php?test=2">test_user_2</a>
34 </span>
34 </span>
35 </p>
35 </p>
36 <p id="menu-user" hidden>
36 <p id="menu-user" hidden>
37 Ingelogd als <strong id="menu-name"></strong>
37 <span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="menu-name"></strong>
38 · Totaal: <strong id="menu-points">0</strong> punten
38 · <span data-i18n="menu.total">Total:</span> <strong id="menu-points">0</strong> <span data-i18n="menu.pointsWord">points</span>
39 · <a id="menu-logout" href="logout.php">Uitloggen</a>
39 · <a id="menu-logout" href="logout.php" data-i18n="menu.logout">Log out</a>
40 </p>
40 </p>
41 </div>
41 </div>
42 <div id="lang-picker" class="lang-picker">
43 <button type="button" id="lang-current" class="lang-current" aria-haspopup="listbox" aria-expanded="false" data-i18n-aria="lang.choose">
44 <img src="images/flags/gb.svg" alt="English" width="36" height="24">
45 </button>
46 <div id="lang-list" class="lang-list" role="listbox" hidden></div>
47 </div>
42 </div>
48 </div>
43
49
44 <div id="planet-select" class="screen" hidden>
50 <div id="planet-select" class="screen" hidden>
45 <h1>Kies een veld</h1>
51 <h1 data-i18n="planet.title">Choose a field</h1>
46 <p class="tagline">Elk veld is een planeet, met een eigen volk, zwaartekracht, lucht en massa.</p>
52 <p class="tagline" data-i18n="planet.tagline">Each field is a planet, with its own people, gravity, air and mass.</p>
47 <div id="planet-grid" class="planet-grid" role="list"></div>
53 <div id="planet-grid" class="planet-grid" role="list"></div>
48 <div class="planet-actions">
54 <div class="planet-actions">
49 <button type="button" id="btn-planet-go">Spelen</button>
55 <button type="button" id="btn-planet-go" data-i18n="menu.play">Play</button>
50 <button type="button" id="btn-planet-back" class="btn-secondary">Terug</button>
56 <button type="button" id="btn-planet-back" class="btn-secondary" data-i18n="planet.back">Back</button>
51 </div>
57 </div>
52 </div>
58 </div>
53
59
54 <div id="online-panel" class="screen" hidden>
60 <div id="online-panel" class="screen" hidden>
55 <h1>Online</h1>
61 <h1 data-i18n="online.title">Online</h1>
56 <p id="online-status" class="tagline">Even kijken of online spelen beschikbaar is…</p>
62 <p id="online-status" class="tagline" data-i18n="online.checking">Checking whether online play is available…</p>
57 <p id="online-error" class="error" hidden></p>
63 <p id="online-error" class="error" hidden></p>
58
64
59 <div id="online-unconfigured" hidden>
65 <div id="online-unconfigured" hidden>
60 <p class="notice">Online spelen is nog niet ingesteld. De beheerder moet bij <a href="https://auth.timfalken.com/admin" target="_blank" rel="noopener">auth.timfalken.com/admin</a> het callback-pad <code>/meteors/callback.php</code> toevoegen (zelfde client als de andere sites op dit domein; het geheim <strong>niet</strong> opnieuw genereren) en dat geheim in <code>data/config.php</code> op de server zetten. Zie de README.</p>
66 <p class="notice" data-i18n-html="online.unconfiguredHtml">Online play is not set up yet.</p>
61 <p>Je kunt wel alleen spelen.</p>
67 <p data-i18n="online.canPlaySolo">You can still play solo.</p>
62 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
68 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
63 </div>
69 </div>
64
70
65 <div id="online-login" hidden>
71 <div id="online-login" hidden>
66 <p>Om online te spelen log je in met je account op auth.timfalken.com.</p>
72 <p data-i18n="online.loginPrompt">To play online, log in with your account on auth.timfalken.com.</p>
67 <a id="btn-login" class="button" href="auth.php">Inloggen</a>
73 <a id="btn-login" class="button" href="auth.php" data-i18n="menu.login">Log in</a>
68 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
74 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
69 <p id="local-login" class="hint" hidden>
75 <p id="local-login" class="hint" hidden>
70 Lokale test:
76 <span data-i18n="online.localTest">Local test:</span>
71 <a href="auth.php?test=1">test_user_1</a> ·
77 <a href="auth.php?test=1">test_user_1</a> ·
72 <a href="auth.php?test=2">test_user_2</a>
78 <a href="auth.php?test=2">test_user_2</a>
73 </p>
79 </p>
74 </div>
80 </div>
75
81
76 <div id="online-home" hidden>
82 <div id="online-home" hidden>
77 <p class="who">Ingelogd als <strong id="me-name"></strong> · <a href="logout.php">Uitloggen</a></p>
83 <p class="who"><span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="me-name"></strong> · <a href="logout.php" data-i18n="menu.logout">Log out</a></p>
78 <button type="button" id="btn-create">Lobby maken</button>
84 <button type="button" id="btn-create" data-i18n="online.createLobby">Create lobby</button>
79 <form id="join-form" class="join-form">
85 <form id="join-form" class="join-form">
80 <label>
86 <label>
81 <span>Lobbycode</span>
87 <span data-i18n="online.lobbyCode">Lobby code</span>
82 <input id="join-code" type="text" maxlength="6" autocomplete="off" spellcheck="false" placeholder="ABCD">
88 <input id="join-code" type="text" maxlength="6" autocomplete="off" spellcheck="false" placeholder="ABCD">
83 </label>
89 </label>
84 <button type="submit" id="btn-join">Deelnemen</button>
90 <button type="submit" id="btn-join" data-i18n="online.join">Join</button>
85 </form>
91 </form>
86 <button type="button" class="btn-secondary" data-back-menu>Terug</button>
92 <button type="button" class="btn-secondary" data-back-menu data-i18n="planet.back">Back</button>
87 </div>
93 </div>
88
94
89 <div id="online-lobby" hidden>
95 <div id="online-lobby" hidden>
90 <p class="who">Ingelogd als <strong id="lobby-me-name"></strong></p>
96 <p class="who"><span data-i18n="menu.loggedInAs">Logged in as</span> <strong id="lobby-me-name"></strong></p>
91 <p class="lobby-code">Code: <strong id="lobby-code"></strong> <button type="button" id="btn-copy-code" class="btn-tiny">Kopieer</button></p>
97 <p class="lobby-code"><span data-i18n="online.code">Code:</span> <strong id="lobby-code"></strong> <button type="button" id="btn-copy-code" class="btn-tiny" data-i18n="online.copy">Copy</button></p>
92 <p class="hint lobby-planet-label">Jouw veld</p>
98 <p class="hint lobby-planet-label" data-i18n="online.yourField">Your field</p>
93 <div id="lobby-planet-grid" class="planet-grid compact" role="list"></div>
99 <div id="lobby-planet-grid" class="planet-grid compact" role="list"></div>
94 <ul id="lobby-players" class="player-list"></ul>
100 <ul id="lobby-players" class="player-list"></ul>
95 <p id="lobby-hint" class="hint"></p>
101 <p id="lobby-hint" class="hint"></p>
96 <div class="lobby-actions">
102 <div class="lobby-actions">
97 <button type="button" id="btn-ready">Gereed</button>
103 <button type="button" id="btn-ready" data-i18n="online.ready">Ready</button>
98 <button type="button" id="btn-start" hidden>Starten</button>
104 <button type="button" id="btn-start" hidden data-i18n="online.start">Start</button>
99 <button type="button" id="btn-leave-lobby" class="btn-secondary">Verlaten</button>
105 <button type="button" id="btn-leave-lobby" class="btn-secondary" data-i18n="online.leave">Leave</button>
100 </div>
106 </div>
101 </div>
107 </div>
102 </div>
108 </div>
103
109
104 <div id="designer" class="screen" hidden>
110 <div id="designer" class="screen" hidden>
105 <h1>Planeetontwerper</h1>
111 <h1 data-i18n="designer.title">Planet Designer</h1>
106 <p class="tagline">Totaal: <strong id="designer-points">0</strong> punten. Blokjes ontgrendel je door punten te verdienen — je geeft ze niet uit.</p>
112 <p class="tagline"><span data-i18n="designer.taglineBefore">Total:</span> <strong id="designer-points">0</strong> <span data-i18n="designer.taglineAfter">points. You unlock blocks by earning points — you do not spend them.</span></p>
107 <div id="designer-list" class="planet-grid" role="list"></div>
113 <div id="designer-list" class="planet-grid" role="list"></div>
108 <div class="planet-actions">
114 <div class="planet-actions">
109 <button type="button" id="btn-designer-new">Nieuwe planeet</button>
115 <button type="button" id="btn-designer-new" data-i18n="designer.new">New planet</button>
110 <button type="button" id="btn-designer-back" class="btn-secondary">Terug</button>
116 <button type="button" id="btn-designer-back" class="btn-secondary" data-i18n="designer.cancel">Back</button>
111 </div>
117 </div>
112 </div>
118 </div>
113
119
114 <div id="designer-edit" class="screen" hidden>
120 <div id="designer-edit" class="screen" hidden>
115 <h1 id="designer-edit-title">Nieuwe planeet</h1>
121 <h1 id="designer-edit-title" data-i18n="designer.createTitle">New planet</h1>
116 <form id="designer-form" class="designer-form" action="javascript:void(0)">
122 <form id="designer-form" class="designer-form" action="javascript:void(0)">
117 <label class="des-field">
123 <label class="des-field">
118 <span>Naam van de planeet</span>
124 <span data-i18n="designer.name">Planet name</span>
119 <input id="des-name" type="text" maxlength="32" autocomplete="off" required>
125 <input id="des-name" type="text" maxlength="32" autocomplete="off" required>
120 </label>
126 </label>
121 <label class="des-field">
127 <label class="des-field">
122 <span>Naam van de bevolking</span>
128 <span data-i18n="designer.people">People’s name</span>
123 <input id="des-people" type="text" maxlength="32" autocomplete="off" required>
129 <input id="des-people" type="text" maxlength="32" autocomplete="off" required>
124 </label>
130 </label>
125 <label class="des-field des-slider">
131 <label class="des-field des-slider">
126 <span>Zwaartekracht</span>
132 <span data-i18n="designer.gravity">Gravity</span>
127 <input id="des-gravity" type="range" min="1" max="4" step="0.1" value="2">
133 <input id="des-gravity" type="range" min="1" max="4" step="0.1" value="2">
128 <span id="des-gravity-val" class="des-val"></span>
134 <span id="des-gravity-val" class="des-val"></span>
129 </label>
135 </label>
130 <label class="des-field des-slider">
136 <label class="des-field des-slider">
131 <span>Luchtweerstand</span>
137 <span data-i18n="designer.air">Air resistance</span>
132 <input id="des-air" type="range" min="1" max="5" step="0.1" value="3">
138 <input id="des-air" type="range" min="1" max="5" step="0.1" value="3">
133 <span id="des-air-val" class="des-val"></span>
139 <span id="des-air-val" class="des-val"></span>
134 </label>
140 </label>
135 <label class="des-field des-slider">
141 <label class="des-field des-slider">
136 <span>Massa</span>
142 <span data-i18n="designer.mass">Mass</span>
137 <input id="des-mass" type="range" min="0.5" max="3" step="0.1" value="1.5">
143 <input id="des-mass" type="range" min="0.5" max="3" step="0.1" value="1.5">
138 <span id="des-mass-val" class="des-val"></span>
144 <span id="des-mass-val" class="des-val"></span>
139 </label>
145 </label>
140 <div id="des-power" class="des-power">Power 0%</div>
146 <div id="des-power" class="des-power">Power 0%</div>
141 <p class="hint">Kies vijf blokjes. Klik op een vak om te wisselen.</p>
147 <p class="hint" data-i18n="designer.slotsHint">Choose five blocks. Click a slot to change it.</p>
142 <div id="des-slots" class="des-slots"></div>
148 <div id="des-slots" class="des-slots"></div>
143 <div class="planet-actions">
149 <div class="planet-actions">
144 <button type="submit" id="btn-designer-save">Opslaan</button>
150 <button type="submit" id="btn-designer-save" data-i18n="designer.save">Save</button>
145 <button type="button" id="btn-designer-delete" class="btn-secondary" hidden>Verwijderen</button>
151 <button type="button" id="btn-designer-delete" class="btn-secondary" hidden data-i18n="designer.delete">Delete</button>
146 <button type="button" id="btn-designer-cancel" class="btn-secondary">Terug</button>
152 <button type="button" id="btn-designer-cancel" class="btn-secondary" data-i18n="designer.cancel">Back</button>
147 </div>
153 </div>
148 </form>
154 </form>
149 </div>
155 </div>
@@ -151,8 +157,8 @@
151 <div id="des-modal" class="des-modal" hidden aria-hidden="true" role="dialog" aria-labelledby="des-modal-title">
157 <div id="des-modal" class="des-modal" hidden aria-hidden="true" role="dialog" aria-labelledby="des-modal-title">
152 <div class="des-modal-card">
158 <div class="des-modal-card">
153 <div class="des-modal-head">
159 <div class="des-modal-head">
154 <h2 id="des-modal-title">Kies een blokje</h2>
160 <h2 id="des-modal-title" data-i18n="designer.pickBlock">Choose a block</h2>
155 <button type="button" id="des-modal-close" class="btn-tiny">Sluiten</button>
161 <button type="button" id="des-modal-close" class="btn-tiny" data-i18n="designer.close">Close</button>
156 </div>
162 </div>
157 <div id="des-modal-grid" class="des-block-grid"></div>
163 <div id="des-modal-grid" class="des-block-grid"></div>
158 </div>
164 </div>
@@ -162,7 +168,7 @@
162
168
163 <div id="hud" hidden>
169 <div id="hud" hidden>
164 <div class="hud-left">
170 <div class="hud-left">
165 <div class="hud-label">Punten</div>
171 <div class="hud-label" data-i18n="hud.points">Points</div>
166 <div id="score">0</div>
172 <div id="score">0</div>
167 </div>
173 </div>
168 <div class="hud-right">
174 <div class="hud-right">
@@ -170,9 +176,9 @@
170 <div id="planet-stats"></div>
176 <div id="planet-stats"></div>
171 </div>
177 </div>
172 <div id="offline-hud" class="hud-offline" hidden>
178 <div id="offline-hud" class="hud-offline" hidden>
173 <span id="offline-round">Ronde 1</span>
179 <span id="offline-round">Round 1</span>
174 <span class="hud-sep">·</span>
180 <span class="hud-sep">·</span>
175 <span id="offline-opponents">1 tegenstander</span>
181 <span id="offline-opponents">1 opponent</span>
176 <span class="hud-sep">·</span>
182 <span class="hud-sep">·</span>
177 <span id="offline-skill">Skill 5%</span>
183 <span id="offline-skill">Skill 5%</span>
178 </div>
184 </div>
@@ -180,32 +186,32 @@
180 </div>
186 </div>
181
187
182 <div id="offline-result" class="screen overlay" hidden>
188 <div id="offline-result" class="screen overlay" hidden>
183 <h2>Offline Strijd</h2>
189 <h2 data-i18n="offline.resultTitle">Offline Battle</h2>
184 <p>Je hebt ronde <strong id="offline-reached">1</strong> bereikt.</p>
190 <p id="offline-reached-line">You reached round <strong id="offline-reached">1</strong>.</p>
185 <p id="offline-result-detail" class="tagline"></p>
191 <p id="offline-result-detail" class="tagline"></p>
186 <button type="button" id="btn-offline-menu">Terug naar het menu</button>
192 <button type="button" id="btn-offline-menu" data-i18n="offline.backMenu">Back to the menu</button>
187 </div>
193 </div>
188
194
189 <div id="game-over" class="screen overlay" hidden>
195 <div id="game-over" class="screen overlay" hidden>
190 <h2>Je hebt verloren</h2>
196 <h2 data-i18n="gameover.title">You lost</h2>
191 <p>Alle kolommen zitten vast.</p>
197 <p data-i18n="gameover.detail">Every column is locked.</p>
192 <p class="go-score">Score: <strong id="go-score">0</strong></p>
198 <p class="go-score"><span data-i18n="gameover.score">Score:</span> <strong id="go-score">0</strong></p>
193 </div>
199 </div>
194
200
195 <div id="spectator" class="screen overlay" hidden>
201 <div id="spectator" class="screen overlay" hidden>
196 <h2>Je ligt eruit</h2>
202 <h2 data-i18n="spectator.title">You’re out</h2>
197 <p>Al je kolommen zitten vol. Je kunt toekijken of de wedstrijd verlaten.</p>
203 <p data-i18n="spectator.detail">All your columns are full. You can watch or leave the match.</p>
198 <div class="lobby-actions">
204 <div class="lobby-actions">
199 <button type="button" id="btn-spectate">Toekijken</button>
205 <button type="button" id="btn-spectate" data-i18n="spectator.watch">Spectate</button>
200 <button type="button" id="btn-leave-game" class="btn-secondary">Verlaten</button>
206 <button type="button" id="btn-leave-game" class="btn-secondary" data-i18n="online.leave">Leave</button>
201 </div>
207 </div>
202 </div>
208 </div>
203
209
204 <div id="podium" class="screen overlay" hidden>
210 <div id="podium" class="screen overlay" hidden>
205 <h2>Gewonnen!</h2>
211 <h2 data-i18n="podium.title">Victory!</h2>
206 <p id="podium-title" class="tagline">De laatste speler staat overeind.</p>
212 <p id="podium-title" class="tagline" data-i18n="podium.subtitle">The last player is still standing.</p>
207 <ol id="podium-list" class="podium-list"></ol>
213 <ol id="podium-list" class="podium-list"></ol>
208 <p class="hint" id="podium-hint">Over 5 seconden teruggaan naar de lobby…</p>
214 <p class="hint" id="podium-hint">Returning to the lobby in 5 seconds…</p>
209 </div>
215 </div>
210
216
211 <script src="framework.js"></script>
217 <script src="framework.js"></script>
build/style.css +112 −1
@@ -9,7 +9,7 @@ html, body {
9 9 overflow: hidden;
10 10 background: #0b1020;
11 11 color: #e8eaf2;
12 font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
12 font-family: "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans JP", "Noto Sans", sans-serif;
13 13 touch-action: none;
14 14 overscroll-behavior: none;
15 15 -webkit-user-select: none;
@@ -862,3 +862,114 @@ a.button:is(:hover, :focus-visible) {
862 862 #designer-edit .hint, #designer .hint { margin: 8px auto 4px; }
863 863 #designer-edit .designer-form { max-width: 26rem; }
864 864 #designer-edit .planet-actions { margin-top: 12px; padding-bottom: 16px; }
865
866
867 /* —— t1141 i18n: flags, CJK, wrapping —— */
868 html[lang="ja"], html[lang="zh-Hans"], html[lang="ko"] {
869 line-height: 1.55;
870 }
871 #btn-play, #btn-offline, #btn-online, #btn-designer,
872 #btn-planet-go, #btn-create, #btn-join, #btn-ready, #btn-start,
873 #btn-designer-new, #btn-designer-save {
874 white-space: normal;
875 overflow-wrap: anywhere;
876 max-width: 92vw;
877 line-height: 1.2;
878 }
879 .lang-picker {
880 position: absolute;
881 right: max(12px, env(safe-area-inset-right, 0px));
882 bottom: max(12px, env(safe-area-inset-bottom, 0px));
883 z-index: 9;
884 display: flex;
885 flex-direction: column-reverse;
886 align-items: flex-end;
887 gap: 8px;
888 pointer-events: auto;
889 }
890 .lang-current {
891 appearance: none;
892 border: 1px solid rgba(200, 210, 240, 0.35);
893 background: rgba(16, 20, 40, 0.86);
894 border-radius: 8px;
895 padding: 6px 7px;
896 cursor: pointer;
897 line-height: 0;
898 box-shadow: 0 4px 14px rgba(0,0,0,0.4);
899 min-width: 52px;
900 min-height: 40px;
901 }
902 .lang-current img, .lang-option img {
903 display: block;
904 width: 36px;
905 height: 24px;
906 object-fit: cover;
907 border-radius: 3px;
908 /* flags are vector art, not pixel blocks */
909 image-rendering: auto;
910 box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
911 }
912 .lang-current:hover, .lang-current:focus-visible,
913 .lang-option:hover, .lang-option:focus-visible {
914 border-color: #ffe27a;
915 outline: none;
916 }
917 .lang-current[aria-expanded="true"] {
918 border-color: #ffe27a;
919 }
920 .lang-list {
921 display: flex;
922 flex-direction: column;
923 gap: 4px;
924 background: rgba(16, 14, 30, 0.96);
925 border: 1px solid #5a5470;
926 border-radius: 12px;
927 padding: 8px;
928 max-height: min(70vh, 28rem);
929 overflow-y: auto;
930 -webkit-overflow-scrolling: touch;
931 touch-action: pan-y;
932 box-shadow: 0 12px 32px rgba(0,0,0,0.45);
933 min-width: 11.5rem;
934 }
935 .lang-list[hidden] { display: none !important; }
936 .lang-option {
937 appearance: none;
938 display: flex;
939 align-items: center;
940 gap: 10px;
941 width: 100%;
942 border: 1px solid transparent;
943 background: transparent;
944 color: #e8eaf2;
945 font: inherit;
946 font-size: 0.95rem;
947 padding: 6px 8px;
948 border-radius: 8px;
949 cursor: pointer;
950 text-align: left;
951 min-height: 40px;
952 white-space: nowrap;
953 }
954 .lang-option.current {
955 border-color: #ffe27a;
956 background: rgba(40, 32, 16, 0.7);
957 }
958 .lang-option span {
959 overflow: hidden;
960 text-overflow: ellipsis;
961 }
962 @media (max-width: 520px) {
963 .lang-picker { right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
964 .lang-list { min-width: 10.5rem; }
965 .menu-account { padding-bottom: 48px; } /* room for the flag */
966 .hint { overflow-wrap: anywhere; }
967 .planet-card .planet-title, .planet-card .planet-people, .planet-card .planet-nums {
968 overflow-wrap: anywhere;
969 }
970 #designer .tagline, #designer-edit .tagline { overflow-wrap: anywhere; }
971 }
972 /* CJK in tight HUD */
973 #planet-name, #planet-stats, .hud-offline, .des-block-name, .des-val {
974 overflow-wrap: anywhere;
975 }
@@ -9,7 +9,7 @@ html, body {
9 overflow: hidden;
9 overflow: hidden;
10 background: #0b1020;
10 background: #0b1020;
11 color: #e8eaf2;
11 color: #e8eaf2;
12 font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
12 font-family: "Segoe UI", system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Noto Sans JP", "Noto Sans", sans-serif;
13 touch-action: none;
13 touch-action: none;
14 overscroll-behavior: none;
14 overscroll-behavior: none;
15 -webkit-user-select: none;
15 -webkit-user-select: none;
@@ -862,3 +862,114 @@ a.button:is(:hover, :focus-visible) {
862#designer-edit .hint, #designer .hint { margin: 8px auto 4px; }
862#designer-edit .hint, #designer .hint { margin: 8px auto 4px; }
863#designer-edit .designer-form { max-width: 26rem; }
863#designer-edit .designer-form { max-width: 26rem; }
864#designer-edit .planet-actions { margin-top: 12px; padding-bottom: 16px; }
864#designer-edit .planet-actions { margin-top: 12px; padding-bottom: 16px; }
865
866
867/* —— t1141 i18n: flags, CJK, wrapping —— */
868html[lang="ja"], html[lang="zh-Hans"], html[lang="ko"] {
869 line-height: 1.55;
870}
871#btn-play, #btn-offline, #btn-online, #btn-designer,
872#btn-planet-go, #btn-create, #btn-join, #btn-ready, #btn-start,
873#btn-designer-new, #btn-designer-save {
874 white-space: normal;
875 overflow-wrap: anywhere;
876 max-width: 92vw;
877 line-height: 1.2;
878}
879.lang-picker {
880 position: absolute;
881 right: max(12px, env(safe-area-inset-right, 0px));
882 bottom: max(12px, env(safe-area-inset-bottom, 0px));
883 z-index: 9;
884 display: flex;
885 flex-direction: column-reverse;
886 align-items: flex-end;
887 gap: 8px;
888 pointer-events: auto;
889}
890.lang-current {
891 appearance: none;
892 border: 1px solid rgba(200, 210, 240, 0.35);
893 background: rgba(16, 20, 40, 0.86);
894 border-radius: 8px;
895 padding: 6px 7px;
896 cursor: pointer;
897 line-height: 0;
898 box-shadow: 0 4px 14px rgba(0,0,0,0.4);
899 min-width: 52px;
900 min-height: 40px;
901}
902.lang-current img, .lang-option img {
903 display: block;
904 width: 36px;
905 height: 24px;
906 object-fit: cover;
907 border-radius: 3px;
908 /* flags are vector art, not pixel blocks */
909 image-rendering: auto;
910 box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
911}
912.lang-current:hover, .lang-current:focus-visible,
913.lang-option:hover, .lang-option:focus-visible {
914 border-color: #ffe27a;
915 outline: none;
916}
917.lang-current[aria-expanded="true"] {
918 border-color: #ffe27a;
919}
920.lang-list {
921 display: flex;
922 flex-direction: column;
923 gap: 4px;
924 background: rgba(16, 14, 30, 0.96);
925 border: 1px solid #5a5470;
926 border-radius: 12px;
927 padding: 8px;
928 max-height: min(70vh, 28rem);
929 overflow-y: auto;
930 -webkit-overflow-scrolling: touch;
931 touch-action: pan-y;
932 box-shadow: 0 12px 32px rgba(0,0,0,0.45);
933 min-width: 11.5rem;
934}
935.lang-list[hidden] { display: none !important; }
936.lang-option {
937 appearance: none;
938 display: flex;
939 align-items: center;
940 gap: 10px;
941 width: 100%;
942 border: 1px solid transparent;
943 background: transparent;
944 color: #e8eaf2;
945 font: inherit;
946 font-size: 0.95rem;
947 padding: 6px 8px;
948 border-radius: 8px;
949 cursor: pointer;
950 text-align: left;
951 min-height: 40px;
952 white-space: nowrap;
953}
954.lang-option.current {
955 border-color: #ffe27a;
956 background: rgba(40, 32, 16, 0.7);
957}
958.lang-option span {
959 overflow: hidden;
960 text-overflow: ellipsis;
961}
962@media (max-width: 520px) {
963 .lang-picker { right: max(8px, env(safe-area-inset-right, 0px)); bottom: max(8px, env(safe-area-inset-bottom, 0px)); }
964 .lang-list { min-width: 10.5rem; }
965 .menu-account { padding-bottom: 48px; } /* room for the flag */
966 .hint { overflow-wrap: anywhere; }
967 .planet-card .planet-title, .planet-card .planet-people, .planet-card .planet-nums {
968 overflow-wrap: anywhere;
969 }
970 #designer .tagline, #designer-edit .tagline { overflow-wrap: anywhere; }
971}
972/* CJK in tight HUD */
973#planet-name, #planet-stats, .hud-offline, .des-block-name, .des-val {
974 overflow-wrap: anywhere;
975}
server/auth.php +5 −3
@@ -1,6 +1,7 @@
1 1 <?php
2 2 declare(strict_types=1);
3 3 require __DIR__ . '/lib/bootstrap.php';
4 require __DIR__ . '/lib/I18n.php';
4 5
5 6 try {
6 7 if (localDev() && isset($_GET['test'])) {
@@ -26,7 +27,8 @@ try {
26 27 } catch (Throwable $e) {
27 28 http_response_code(503);
28 29 header('Content-Type: text/html; charset=utf-8');
29 echo '<!DOCTYPE html><meta charset="utf-8"><title>Meteors</title>';
30 echo '<p>Inloggen is nu niet mogelijk. ' . htmlspecialchars($e->getMessage()) . '</p>';
31 echo '<p><a href="index.html">Terug naar het spel</a></p>';
30 $lang = I18n::htmlLang();
31 echo '<!DOCTYPE html><html lang="' . htmlspecialchars($lang) . '"><meta charset="utf-8"><title>Meteors</title>';
32 echo '<p>' . htmlspecialchars(I18n::t('auth.unavailable')) . ' ' . htmlspecialchars($e->getMessage()) . '</p>';
33 echo '<p><a href="index.html">' . htmlspecialchars(I18n::t('auth.backToGame')) . '</a></p>';
32 34 }
@@ -1,6 +1,7 @@
1<?php
1<?php
2declare(strict_types=1);
2declare(strict_types=1);
3require __DIR__ . '/lib/bootstrap.php';
3require __DIR__ . '/lib/bootstrap.php';
4require __DIR__ . '/lib/I18n.php';
4
5
5try {
6try {
6 if (localDev() && isset($_GET['test'])) {
7 if (localDev() && isset($_GET['test'])) {
@@ -26,7 +27,8 @@ try {
26} catch (Throwable $e) {
27} catch (Throwable $e) {
27 http_response_code(503);
28 http_response_code(503);
28 header('Content-Type: text/html; charset=utf-8');
29 header('Content-Type: text/html; charset=utf-8');
29 echo '<!DOCTYPE html><meta charset="utf-8"><title>Meteors</title>';
30 $lang = I18n::htmlLang();
30 echo '<p>Inloggen is nu niet mogelijk. ' . htmlspecialchars($e->getMessage()) . '</p>';
31 echo '<!DOCTYPE html><html lang="' . htmlspecialchars($lang) . '"><meta charset="utf-8"><title>Meteors</title>';
31 echo '<p><a href="index.html">Terug naar het spel</a></p>';
32 echo '<p>' . htmlspecialchars(I18n::t('auth.unavailable')) . ' ' . htmlspecialchars($e->getMessage()) . '</p>';
33 echo '<p><a href="index.html">' . htmlspecialchars(I18n::t('auth.backToGame')) . '</a></p>';
32}
34}
server/callback.php +5 −3
@@ -1,6 +1,7 @@
1 1 <?php
2 2 declare(strict_types=1);
3 3 require __DIR__ . '/lib/bootstrap.php';
4 require __DIR__ . '/lib/I18n.php';
4 5
5 6 try {
6 7 $state = $_GET['state'] ?? null;
@@ -37,7 +38,8 @@ try {
37 38 } catch (Throwable $e) {
38 39 http_response_code(401);
39 40 header('Content-Type: text/html; charset=utf-8');
40 echo '<!DOCTYPE html><meta charset="utf-8"><title>Meteors</title>';
41 echo 'Inloggen is mislukt. ' . htmlspecialchars($e->getMessage());
42 echo ' <a href="auth.php">Opnieuw proberen</a> · <a href="index.html">Terug</a>';
41 $lang = I18n::htmlLang();
42 echo '<!DOCTYPE html><html lang="' . htmlspecialchars($lang) . '"><meta charset="utf-8"><title>Meteors</title>';
43 echo htmlspecialchars(I18n::t('auth.failed')) . ' ' . htmlspecialchars($e->getMessage());
44 echo ' <a href="auth.php">' . htmlspecialchars(I18n::t('auth.retry')) . '</a> · <a href="index.html">' . htmlspecialchars(I18n::t('auth.back')) . '</a>';
43 45 }
@@ -1,6 +1,7 @@
1<?php
1<?php
2declare(strict_types=1);
2declare(strict_types=1);
3require __DIR__ . '/lib/bootstrap.php';
3require __DIR__ . '/lib/bootstrap.php';
4require __DIR__ . '/lib/I18n.php';
4
5
5try {
6try {
6 $state = $_GET['state'] ?? null;
7 $state = $_GET['state'] ?? null;
@@ -37,7 +38,8 @@ try {
37} catch (Throwable $e) {
38} catch (Throwable $e) {
38 http_response_code(401);
39 http_response_code(401);
39 header('Content-Type: text/html; charset=utf-8');
40 header('Content-Type: text/html; charset=utf-8');
40 echo '<!DOCTYPE html><meta charset="utf-8"><title>Meteors</title>';
41 $lang = I18n::htmlLang();
41 echo 'Inloggen is mislukt. ' . htmlspecialchars($e->getMessage());
42 echo '<!DOCTYPE html><html lang="' . htmlspecialchars($lang) . '"><meta charset="utf-8"><title>Meteors</title>';
42 echo ' <a href="auth.php">Opnieuw proberen</a> · <a href="index.html">Terug</a>';
43 echo htmlspecialchars(I18n::t('auth.failed')) . ' ' . htmlspecialchars($e->getMessage());
44 echo ' <a href="auth.php">' . htmlspecialchars(I18n::t('auth.retry')) . '</a> · <a href="index.html">' . htmlspecialchars(I18n::t('auth.back')) . '</a>';
43}
45}
src/build.sh +5 −0
@@ -14,6 +14,7 @@ rm -f "$BUILD_FILE"
14 14
15 15 FILES=(
16 16 "$SRC_DIR/rng.js"
17 "$SRC_DIR/i18n.js"
17 18 "$SRC_DIR/planet.js"
18 19 "$SRC_DIR/blocks.js"
19 20 "$SRC_DIR/easing.js"
@@ -36,6 +37,9 @@ FILES=(
36 37 printf '%s' "var BLOCK_REGISTRY = "
37 38 cat "$ROOT/server/lib/blocks.json"
38 39 printf ';\n'
40 printf '%s' "var I18N_CATALOG = "
41 cat "$ROOT/server/lib/i18n.json"
42 printf ';\n'
39 43 } >> "$BUILD_FILE"
40 44
41 45 for file in "${FILES[@]}"
@@ -61,6 +65,7 @@ mkdir -p "$ROOT/build/lib"
61 65 cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
62 66 "$SERVER/lib/Planets.php" "$SERVER/lib/planets.json" \
63 67 "$SERVER/lib/Blocks.php" "$SERVER/lib/blocks.json" \
68 "$SERVER/lib/i18n.json" "$SERVER/lib/I18n.php" \
64 69 "$ROOT/build/lib/"
65 70 mkdir -p "$ROOT/build/data"
66 71 cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
@@ -14,6 +14,7 @@ rm -f "$BUILD_FILE"
14
14
15FILES=(
15FILES=(
16 "$SRC_DIR/rng.js"
16 "$SRC_DIR/rng.js"
17 "$SRC_DIR/i18n.js"
17 "$SRC_DIR/planet.js"
18 "$SRC_DIR/planet.js"
18 "$SRC_DIR/blocks.js"
19 "$SRC_DIR/blocks.js"
19 "$SRC_DIR/easing.js"
20 "$SRC_DIR/easing.js"
@@ -36,6 +37,9 @@ FILES=(
36 printf '%s' "var BLOCK_REGISTRY = "
37 printf '%s' "var BLOCK_REGISTRY = "
37 cat "$ROOT/server/lib/blocks.json"
38 cat "$ROOT/server/lib/blocks.json"
38 printf ';\n'
39 printf ';\n'
40 printf '%s' "var I18N_CATALOG = "
41 cat "$ROOT/server/lib/i18n.json"
42 printf ';\n'
39} >> "$BUILD_FILE"
43} >> "$BUILD_FILE"
40
44
41for file in "${FILES[@]}"
45for file in "${FILES[@]}"
@@ -61,6 +65,7 @@ mkdir -p "$ROOT/build/lib"
61cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
65cp -f "$SERVER/lib/bootstrap.php" "$SERVER/lib/Store.php" \
62 "$SERVER/lib/Planets.php" "$SERVER/lib/planets.json" \
66 "$SERVER/lib/Planets.php" "$SERVER/lib/planets.json" \
63 "$SERVER/lib/Blocks.php" "$SERVER/lib/blocks.json" \
67 "$SERVER/lib/Blocks.php" "$SERVER/lib/blocks.json" \
68 "$SERVER/lib/i18n.json" "$SERVER/lib/I18n.php" \
64 "$ROOT/build/lib/"
69 "$ROOT/build/lib/"
65mkdir -p "$ROOT/build/data"
70mkdir -p "$ROOT/build/data"
66cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
71cp -f "$SERVER/data/.htaccess" "$ROOT/build/data/.htaccess"
src/designer.js +24 −21
@@ -102,7 +102,7 @@ Designer.renderList = function ()
102 102 {
103 103 var empty = document.createElement('p');
104 104 empty.className = 'hint';
105 empty.textContent = 'Je hebt nog geen eigen planeten. Maak er een aan.';
105 empty.textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.empty') : 'You don’t have any planets of your own yet. Create one.';
106 106 box.appendChild(empty);
107 107 return;
108 108 }
@@ -127,8 +127,8 @@ Designer.renderList = function ()
127 127 + '<div class="planet-nums">' + Designer.esc(stats) + '</div>'
128 128 + '<div class="planet-swatches">' + swatches + '</div>'
129 129 + '<div class="designer-card-actions">'
130 + '<button type="button" class="btn-tiny" data-edit>Bewerken</button>'
131 + '<button type="button" class="btn-tiny btn-danger-lite" data-del>Verwijderen</button>'
130 + '<button type="button" class="btn-tiny" data-edit>' + ((typeof I18n !== 'undefined') ? I18n.t('designer.edit') : 'Edit') + '</button>'
131 + '<button type="button" class="btn-tiny btn-danger-lite" data-del>' + ((typeof I18n !== 'undefined') ? I18n.t('designer.delete') : 'Delete') + '</button>'
132 132 + '</div>';
133 133 (function (id)
134 134 {
@@ -145,13 +145,14 @@ Designer.confirmDelete = function (id)
145 145 {
146 146 var pl = Designer.planetById(id);
147 147 var name = pl ? pl.name : id;
148 if (!window.confirm('Wil je de planeet “' + name + '” verwijderen?'))
148 var q = (typeof I18n !== 'undefined') ? I18n.t('designer.confirmDelete', { name: name }) : ('Delete the planet “' + name + '”?');
149 if (!window.confirm(q))
149 150 { return; }
150 151 Online.deletePlanet(id).then(function (data)
151 152 {
152 153 if (!data || !data.ok)
153 154 {
154 window.alert((data && data.error) || 'Verwijderen is mislukt.');
155 window.alert((data && data.error && (typeof I18n !== 'undefined' ? I18n.error(data.error) : data.error)) || ((typeof I18n !== 'undefined') ? I18n.t('designer.deleteFailed') : 'Could not delete the planet.'));
155 156 return;
156 157 }
157 158 Designer.renderList();
@@ -196,7 +197,7 @@ Designer.openEdit = function (id)
196 197 document.getElementById('des-gravity').value = String(pl.jumpsToClear != null ? pl.jumpsToClear : 2);
197 198 document.getElementById('des-air').value = String(pl.fallTime != null ? pl.fallTime : 3);
198 199 document.getElementById('des-mass').value = String(pl.riseTime != null ? pl.riseTime : 1.5);
199 document.getElementById('designer-edit-title').textContent = 'Planeet bewerken';
200 document.getElementById('designer-edit-title').textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.editTitle') : 'Edit planet';
200 201 document.getElementById('btn-designer-delete').hidden = false;
201 202 }
202 203 else
@@ -207,7 +208,7 @@ Designer.openEdit = function (id)
207 208 document.getElementById('des-gravity').value = '2';
208 209 document.getElementById('des-air').value = '3';
209 210 document.getElementById('des-mass').value = '1.5';
210 document.getElementById('designer-edit-title').textContent = 'Nieuwe planeet';
211 document.getElementById('designer-edit-title').textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.createTitle') : 'New planet';
211 212 document.getElementById('btn-designer-delete').hidden = true;
212 213 }
213 214 hideIf('designer');
@@ -234,8 +235,8 @@ Designer.draftPlanet = function ()
234 235 }
235 236 var opts = {
236 237 id: Designer.editingId || 'draft',
237 name: (document.getElementById('des-name').value || 'Nieuwe planeet').trim() || 'Nieuwe planeet',
238 people: (document.getElementById('des-people').value || 'Volk').trim() || 'Volk',
238 name: (document.getElementById('des-name').value || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultName') : 'New planet')).trim() || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultName') : 'New planet'),
239 people: (document.getElementById('des-people').value || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultPeople') : 'People')).trim() || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultPeople') : 'People'),
239 240 jumpsToClear: jumps,
240 241 fallTime: fall,
241 242 riseTime: rise,
@@ -263,7 +264,7 @@ Designer.syncPreview = function ()
263 264 setText('des-mass-val', Number(document.getElementById('des-mass').value).toFixed(1)
264 265 + (d ? ' · F ' + Math.round(d.newtons) + ' N' : ''));
265 266 var power = d ? d.power : 0;
266 setText('des-power', 'Power ' + power + '%');
267 setText('des-power', (typeof I18n !== 'undefined') ? I18n.t('designer.power', { n: power }) : ('Power ' + power + '%'));
267 268 };
268 269
269 270 Designer.renderSlots = function ()
@@ -280,15 +281,16 @@ Designer.renderSlots = function ()
280 281 var btn = document.createElement('button');
281 282 btn.type = 'button';
282 283 btn.className = 'des-slot';
283 btn.setAttribute('aria-label', 'Blokje ' + (i + 1));
284 btn.setAttribute('aria-label', (typeof I18n !== 'undefined') ? I18n.t('designer.slotAria', { n: i + 1 }) : ('Block ' + (i + 1)));
284 285 if (b)
285 286 {
286 btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(b.name) + '">'
287 + '<span>' + Designer.esc(b.name) + '</span>';
287 var bname = (typeof I18n !== 'undefined') ? I18n.blockName(b.id, b.name) : b.name;
288 btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(bname) + '">'
289 + '<span>' + Designer.esc(bname) + '</span>';
288 290 }
289 291 else
290 292 {
291 btn.innerHTML = '<span class="des-slot-empty">Kies</span>';
293 btn.innerHTML = '<span class="des-slot-empty">' + ((typeof I18n !== 'undefined') ? I18n.t('designer.choose') : 'Choose') + '</span>';
292 294 }
293 295 (function (slot)
294 296 {
@@ -329,11 +331,12 @@ Designer.openModal = function (slot)
329 331 { cell.classList.add('used'); }
330 332 if (Designer.slots[slot] === b.id)
331 333 { cell.classList.add('current'); }
332 var title = b.name;
334 var bname = (typeof I18n !== 'undefined') ? I18n.blockName(b.id, b.name) : b.name;
335 var title = bname;
333 336 if (locked)
334 { title += ' — ' + b.threshold + ' punten nodig'; }
337 { title += ' — ' + ((typeof I18n !== 'undefined') ? I18n.t('designer.needPoints', { n: b.threshold }) : (b.threshold + ' points required')); }
335 338 else if (taken)
336 { title += ' — al in een ander vak'; }
339 { title += ' — ' + ((typeof I18n !== 'undefined') ? I18n.t('designer.alreadyUsed') : 'already in another slot'); }
337 340 cell.title = title;
338 341 cell.setAttribute('aria-label', title);
339 342 cell.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="">'
@@ -343,7 +346,7 @@ Designer.openModal = function (slot)
343 346 + '<path d="M6 8 V6 a3 3 0 0 1 6 0 v2" fill="none" stroke="#ffe27a" stroke-width="1.8" stroke-linecap="round"/>'
344 347 + '<circle cx="9" cy="12" r="1.2" fill="#1a1628"/>'
345 348 + '</svg></span>' : '')
346 + '<span class="des-block-name">' + Designer.esc(b.name) + '</span>'
349 + '<span class="des-block-name">' + Designer.esc(bname) + '</span>'
347 350 + (locked ? '<span class="des-block-need">' + b.threshold + '</span>' : '');
348 351 if (locked || taken)
349 352 { cell.disabled = true; }
@@ -383,14 +386,14 @@ Designer.save = function ()
383 386 var people = (document.getElementById('des-people').value || '').trim();
384 387 if (!name || !people)
385 388 {
386 window.alert('Vul een naam voor de planeet en voor de bevolking in.');
389 window.alert((typeof I18n !== 'undefined') ? I18n.t('designer.needNames') : 'Enter a name for the planet and for its people.');
387 390 return;
388 391 }
389 392 for (var i = 0; i < 5; i++)
390 393 {
391 394 if (!Designer.slots[i])
392 395 {
393 window.alert('Kies vijf blokjes.');
396 window.alert((typeof I18n !== 'undefined') ? I18n.t('designer.needFive') : 'Choose five blocks.');
394 397 return;
395 398 }
396 399 }
@@ -407,7 +410,7 @@ Designer.save = function ()
407 410 {
408 411 if (!data || !data.ok)
409 412 {
410 window.alert((data && data.error) || 'Opslaan is mislukt.');
413 window.alert((data && data.error && (typeof I18n !== 'undefined' ? I18n.error(data.error) : data.error)) || ((typeof I18n !== 'undefined') ? I18n.t('designer.saveFailed') : 'Could not save the planet.'));
411 414 return;
412 415 }
413 416 hideIf('designer-edit');
@@ -102,7 +102,7 @@ Designer.renderList = function ()
102 {
102 {
103 var empty = document.createElement('p');
103 var empty = document.createElement('p');
104 empty.className = 'hint';
104 empty.className = 'hint';
105 empty.textContent = 'Je hebt nog geen eigen planeten. Maak er een aan.';
105 empty.textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.empty') : 'You don’t have any planets of your own yet. Create one.';
106 box.appendChild(empty);
106 box.appendChild(empty);
107 return;
107 return;
108 }
108 }
@@ -127,8 +127,8 @@ Designer.renderList = function ()
127 + '<div class="planet-nums">' + Designer.esc(stats) + '</div>'
127 + '<div class="planet-nums">' + Designer.esc(stats) + '</div>'
128 + '<div class="planet-swatches">' + swatches + '</div>'
128 + '<div class="planet-swatches">' + swatches + '</div>'
129 + '<div class="designer-card-actions">'
129 + '<div class="designer-card-actions">'
130 + '<button type="button" class="btn-tiny" data-edit>Bewerken</button>'
130 + '<button type="button" class="btn-tiny" data-edit>' + ((typeof I18n !== 'undefined') ? I18n.t('designer.edit') : 'Edit') + '</button>'
131 + '<button type="button" class="btn-tiny btn-danger-lite" data-del>Verwijderen</button>'
131 + '<button type="button" class="btn-tiny btn-danger-lite" data-del>' + ((typeof I18n !== 'undefined') ? I18n.t('designer.delete') : 'Delete') + '</button>'
132 + '</div>';
132 + '</div>';
133 (function (id)
133 (function (id)
134 {
134 {
@@ -145,13 +145,14 @@ Designer.confirmDelete = function (id)
145{
145{
146 var pl = Designer.planetById(id);
146 var pl = Designer.planetById(id);
147 var name = pl ? pl.name : id;
147 var name = pl ? pl.name : id;
148 if (!window.confirm('Wil je de planeet “' + name + '” verwijderen?'))
148 var q = (typeof I18n !== 'undefined') ? I18n.t('designer.confirmDelete', { name: name }) : ('Delete the planet “' + name + '”?');
149 if (!window.confirm(q))
149 { return; }
150 { return; }
150 Online.deletePlanet(id).then(function (data)
151 Online.deletePlanet(id).then(function (data)
151 {
152 {
152 if (!data || !data.ok)
153 if (!data || !data.ok)
153 {
154 {
154 window.alert((data && data.error) || 'Verwijderen is mislukt.');
155 window.alert((data && data.error && (typeof I18n !== 'undefined' ? I18n.error(data.error) : data.error)) || ((typeof I18n !== 'undefined') ? I18n.t('designer.deleteFailed') : 'Could not delete the planet.'));
155 return;
156 return;
156 }
157 }
157 Designer.renderList();
158 Designer.renderList();
@@ -196,7 +197,7 @@ Designer.openEdit = function (id)
196 document.getElementById('des-gravity').value = String(pl.jumpsToClear != null ? pl.jumpsToClear : 2);
197 document.getElementById('des-gravity').value = String(pl.jumpsToClear != null ? pl.jumpsToClear : 2);
197 document.getElementById('des-air').value = String(pl.fallTime != null ? pl.fallTime : 3);
198 document.getElementById('des-air').value = String(pl.fallTime != null ? pl.fallTime : 3);
198 document.getElementById('des-mass').value = String(pl.riseTime != null ? pl.riseTime : 1.5);
199 document.getElementById('des-mass').value = String(pl.riseTime != null ? pl.riseTime : 1.5);
199 document.getElementById('designer-edit-title').textContent = 'Planeet bewerken';
200 document.getElementById('designer-edit-title').textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.editTitle') : 'Edit planet';
200 document.getElementById('btn-designer-delete').hidden = false;
201 document.getElementById('btn-designer-delete').hidden = false;
201 }
202 }
202 else
203 else
@@ -207,7 +208,7 @@ Designer.openEdit = function (id)
207 document.getElementById('des-gravity').value = '2';
208 document.getElementById('des-gravity').value = '2';
208 document.getElementById('des-air').value = '3';
209 document.getElementById('des-air').value = '3';
209 document.getElementById('des-mass').value = '1.5';
210 document.getElementById('des-mass').value = '1.5';
210 document.getElementById('designer-edit-title').textContent = 'Nieuwe planeet';
211 document.getElementById('designer-edit-title').textContent = (typeof I18n !== 'undefined') ? I18n.t('designer.createTitle') : 'New planet';
211 document.getElementById('btn-designer-delete').hidden = true;
212 document.getElementById('btn-designer-delete').hidden = true;
212 }
213 }
213 hideIf('designer');
214 hideIf('designer');
@@ -234,8 +235,8 @@ Designer.draftPlanet = function ()
234 }
235 }
235 var opts = {
236 var opts = {
236 id: Designer.editingId || 'draft',
237 id: Designer.editingId || 'draft',
237 name: (document.getElementById('des-name').value || 'Nieuwe planeet').trim() || 'Nieuwe planeet',
238 name: (document.getElementById('des-name').value || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultName') : 'New planet')).trim() || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultName') : 'New planet'),
238 people: (document.getElementById('des-people').value || 'Volk').trim() || 'Volk',
239 people: (document.getElementById('des-people').value || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultPeople') : 'People')).trim() || (typeof I18n !== 'undefined' ? I18n.t('designer.defaultPeople') : 'People'),
239 jumpsToClear: jumps,
240 jumpsToClear: jumps,
240 fallTime: fall,
241 fallTime: fall,
241 riseTime: rise,
242 riseTime: rise,
@@ -263,7 +264,7 @@ Designer.syncPreview = function ()
263 setText('des-mass-val', Number(document.getElementById('des-mass').value).toFixed(1)
264 setText('des-mass-val', Number(document.getElementById('des-mass').value).toFixed(1)
264 + (d ? ' · F ' + Math.round(d.newtons) + ' N' : ''));
265 + (d ? ' · F ' + Math.round(d.newtons) + ' N' : ''));
265 var power = d ? d.power : 0;
266 var power = d ? d.power : 0;
266 setText('des-power', 'Power ' + power + '%');
267 setText('des-power', (typeof I18n !== 'undefined') ? I18n.t('designer.power', { n: power }) : ('Power ' + power + '%'));
267};
268};
268
269
269Designer.renderSlots = function ()
270Designer.renderSlots = function ()
@@ -280,15 +281,16 @@ Designer.renderSlots = function ()
280 var btn = document.createElement('button');
281 var btn = document.createElement('button');
281 btn.type = 'button';
282 btn.type = 'button';
282 btn.className = 'des-slot';
283 btn.className = 'des-slot';
283 btn.setAttribute('aria-label', 'Blokje ' + (i + 1));
284 btn.setAttribute('aria-label', (typeof I18n !== 'undefined') ? I18n.t('designer.slotAria', { n: i + 1 }) : ('Block ' + (i + 1)));
284 if (b)
285 if (b)
285 {
286 {
286 btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(b.name) + '">'
287 var bname = (typeof I18n !== 'undefined') ? I18n.blockName(b.id, b.name) : b.name;
287 + '<span>' + Designer.esc(b.name) + '</span>';
288 btn.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="' + Designer.esc(bname) + '">'
289 + '<span>' + Designer.esc(bname) + '</span>';
288 }
290 }
289 else
291 else
290 {
292 {
291 btn.innerHTML = '<span class="des-slot-empty">Kies</span>';
293 btn.innerHTML = '<span class="des-slot-empty">' + ((typeof I18n !== 'undefined') ? I18n.t('designer.choose') : 'Choose') + '</span>';
292 }
294 }
293 (function (slot)
295 (function (slot)
294 {
296 {
@@ -329,11 +331,12 @@ Designer.openModal = function (slot)
329 { cell.classList.add('used'); }
331 { cell.classList.add('used'); }
330 if (Designer.slots[slot] === b.id)
332 if (Designer.slots[slot] === b.id)
331 { cell.classList.add('current'); }
333 { cell.classList.add('current'); }
332 var title = b.name;
334 var bname = (typeof I18n !== 'undefined') ? I18n.blockName(b.id, b.name) : b.name;
335 var title = bname;
333 if (locked)
336 if (locked)
334 { title += ' — ' + b.threshold + ' punten nodig'; }
337 { title += ' — ' + ((typeof I18n !== 'undefined') ? I18n.t('designer.needPoints', { n: b.threshold }) : (b.threshold + ' points required')); }
335 else if (taken)
338 else if (taken)
336 { title += ' — al in een ander vak'; }
339 { title += ' — ' + ((typeof I18n !== 'undefined') ? I18n.t('designer.alreadyUsed') : 'already in another slot'); }
337 cell.title = title;
340 cell.title = title;
338 cell.setAttribute('aria-label', title);
341 cell.setAttribute('aria-label', title);
339 cell.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="">'
342 cell.innerHTML = '<img src="' + Designer.esc(b.image) + '" alt="">'
@@ -343,7 +346,7 @@ Designer.openModal = function (slot)
343 + '<path d="M6 8 V6 a3 3 0 0 1 6 0 v2" fill="none" stroke="#ffe27a" stroke-width="1.8" stroke-linecap="round"/>'
346 + '<path d="M6 8 V6 a3 3 0 0 1 6 0 v2" fill="none" stroke="#ffe27a" stroke-width="1.8" stroke-linecap="round"/>'
344 + '<circle cx="9" cy="12" r="1.2" fill="#1a1628"/>'
347 + '<circle cx="9" cy="12" r="1.2" fill="#1a1628"/>'
345 + '</svg></span>' : '')
348 + '</svg></span>' : '')
346 + '<span class="des-block-name">' + Designer.esc(b.name) + '</span>'
349 + '<span class="des-block-name">' + Designer.esc(bname) + '</span>'
347 + (locked ? '<span class="des-block-need">' + b.threshold + '</span>' : '');
350 + (locked ? '<span class="des-block-need">' + b.threshold + '</span>' : '');
348 if (locked || taken)
351 if (locked || taken)
349 { cell.disabled = true; }
352 { cell.disabled = true; }
@@ -383,14 +386,14 @@ Designer.save = function ()
383 var people = (document.getElementById('des-people').value || '').trim();
386 var people = (document.getElementById('des-people').value || '').trim();
384 if (!name || !people)
387 if (!name || !people)
385 {
388 {
386 window.alert('Vul een naam voor de planeet en voor de bevolking in.');
389 window.alert((typeof I18n !== 'undefined') ? I18n.t('designer.needNames') : 'Enter a name for the planet and for its people.');
387 return;
390 return;
388 }
391 }
389 for (var i = 0; i < 5; i++)
392 for (var i = 0; i < 5; i++)
390 {
393 {
391 if (!Designer.slots[i])
394 if (!Designer.slots[i])
392 {
395 {
393 window.alert('Kies vijf blokjes.');
396 window.alert((typeof I18n !== 'undefined') ? I18n.t('designer.needFive') : 'Choose five blocks.');
394 return;
397 return;
395 }
398 }
396 }
399 }
@@ -407,7 +410,7 @@ Designer.save = function ()
407 {
410 {
408 if (!data || !data.ok)
411 if (!data || !data.ok)
409 {
412 {
410 window.alert((data && data.error) || 'Opslaan is mislukt.');
413 window.alert((data && data.error && (typeof I18n !== 'undefined' ? I18n.error(data.error) : data.error)) || ((typeof I18n !== 'undefined') ? I18n.t('designer.saveFailed') : 'Could not save the planet.'));
411 return;
414 return;
412 }
415 }
413 hideIf('designer-edit');
416 hideIf('designer-edit');
src/main.js +167 −43
@@ -112,6 +112,13 @@ window.onload = function ()
112 112 { game.images.flame.addAnimationCycle('burn', [0, 1, 2, 3], true); }
113 113 });
114 114
115 if (typeof I18n !== 'undefined')
116 {
117 I18n.init();
118 I18n.bindPicker();
119 I18n.onChange(function ()
120 { refreshAllUi(); });
121 }
115 122 bindOnlineUi();
116 123 bindOfflineUi();
117 124 bindPlanetSelect();
@@ -122,6 +129,7 @@ window.onload = function ()
122 129 {
123 130 Online.refresh().then(function ()
124 131 {
132 applyProfileLocale();
125 133 refreshMenuAccount();
126 134 restoreSelectedPlanet();
127 135 renderPlanetGrid('planet-grid', false);
@@ -753,7 +761,9 @@ function refreshHud ()
753 761 { return; }
754 762 document.getElementById('score').textContent = String(app.core.score);
755 763 var planet = app.planet;
756 document.getElementById('planet-name').textContent = planet.name + ' · ' + planet.people;
764 var pname = (typeof I18n !== 'undefined') ? I18n.planetName(planet) : planet.name;
765 var people = (typeof I18n !== 'undefined') ? I18n.peopleName(planet) : planet.people;
766 document.getElementById('planet-name').textContent = pname + ' · ' + people;
757 767 document.getElementById('planet-stats').textContent = Planet.formatStats(planet);
758 768 }
759 769
@@ -1438,16 +1448,31 @@ function showOfflineResult ()
1438 1448 app.offlineResultShown = true;
1439 1449 var battle = app.battle;
1440 1450 var reached = document.getElementById('offline-reached');
1441 if (reached)
1451 var sch = battle.schedule;
1452 var n = sch.opponents;
1453 var skill = Math.round(sch.skill * 100);
1454 var line = document.getElementById('offline-reached-line');
1455 if (line && typeof I18n !== 'undefined')
1456 { line.textContent = I18n.t('offline.reached', { n: battle.round }); }
1457 else if (reached)
1442 1458 { reached.textContent = String(battle.round); }
1443 1459 var detail = document.getElementById('offline-result-detail');
1444 1460 if (detail)
1445 1461 {
1446 var sch = battle.schedule;
1447 var n = sch.opponents;
1448 var noun = n === 1 ? 'tegenstander' : 'tegenstanders';
1449 detail.textContent = 'Je speelde tegen ' + n + ' ' + noun
1450 + ' met skill ' + Math.round(sch.skill * 100) + '%.';
1462 if (typeof I18n !== 'undefined')
1463 {
1464 detail.textContent = I18n.t('offline.detail', {
1465 n: n,
1466 opponents: I18n.plural('hud.opponent', n),
1467 skill: skill
1468 });
1469 }
1470 else
1471 {
1472 var noun = n === 1 ? 'opponent' : 'opponents';
1473 detail.textContent = 'You played against ' + n + ' ' + noun
1474 + ' at skill ' + skill + '%.';
1475 }
1451 1476 }
1452 1477 hideEl('game-over');
1453 1478 showEl('offline-result');
@@ -1467,16 +1492,32 @@ function refreshOfflineHud ()
1467 1492 el.hidden = false;
1468 1493 var sch = app.battle.schedule;
1469 1494 var n = sch.opponents;
1470 var noun = n === 1 ? 'tegenstander' : 'tegenstanders';
1471 1495 var r = document.getElementById('offline-round');
1472 1496 var o = document.getElementById('offline-opponents');
1473 1497 var s = document.getElementById('offline-skill');
1474 if (r)
1475 { r.textContent = 'Ronde ' + sch.round; }
1476 if (o)
1477 { o.textContent = n + ' ' + noun; }
1478 if (s)
1479 { s.textContent = 'Skill ' + Math.round(sch.skill * 100) + '%'; }
1498 if (typeof I18n !== 'undefined')
1499 {
1500 if (r)
1501 { r.textContent = I18n.t('hud.round', { n: sch.round }); }
1502 if (o)
1503 {
1504 o.textContent = I18n.t('hud.opponentsLine', {
1505 n: n, word: I18n.plural('hud.opponent', n)
1506 });
1507 }
1508 if (s)
1509 { s.textContent = I18n.t('hud.skill', { n: Math.round(sch.skill * 100) }); }
1510 }
1511 else
1512 {
1513 var noun = n === 1 ? 'opponent' : 'opponents';
1514 if (r)
1515 { r.textContent = 'Round ' + sch.round; }
1516 if (o)
1517 { o.textContent = n + ' ' + noun; }
1518 if (s)
1519 { s.textContent = 'Skill ' + Math.round(sch.skill * 100) + '%'; }
1520 }
1480 1521 }
1481 1522
1482 1523 function hideOfflineHud ()
@@ -1577,11 +1618,14 @@ function renderOfflineMinis ()
1577 1618 }
1578 1619 el.classList.toggle('eliminated', !!bot.eliminated);
1579 1620 var planetName = bot.planet && bot.planet.name ? bot.planet.name : '';
1621 var shownPlanet = planetName;
1622 if (bot.planet && typeof I18n !== 'undefined')
1623 { shownPlanet = I18n.planetName(bot.planet); }
1580 1624 el.querySelector('.mini-name').textContent = bot.name
1581 + (planetName ? ' · ' + planetName : '');
1625 + (shownPlanet ? ' · ' + shownPlanet : '');
1582 1626 el.querySelector('.mini-meta').textContent = bot.eliminated
1583 ? 'Uit'
1584 : ('Punten ' + (bot.score || 0));
1627 ? ((typeof I18n !== 'undefined') ? I18n.t('hud.out') : 'Out')
1628 : ((typeof I18n !== 'undefined') ? I18n.t('hud.miniPoints', { n: bot.score || 0 }) : ('Points ' + (bot.score || 0)));
1585 1629 var snap = bot.core ? bot.core.fieldSnapshot() : { blocks: [] };
1586 1630 if (typeof Online !== 'undefined' && Online._drawMini)
1587 1631 { Online._drawMini(canvas, snap, bot.planet); }
@@ -1749,13 +1793,21 @@ function showPodium (lobby)
1749 1793 {
1750 1794 var r = ranks[i];
1751 1795 var li = document.createElement('li');
1752 var medal = r.place === 1 ? '1e' : (r.place === 2 ? '2e' : (r.place === 3 ? '3e' : r.place + 'e'));
1753 li.textContent = medal + ' ' + r.name + ' · ' + r.score + ' punten';
1796 var medal = (typeof I18n !== 'undefined') ? I18n.place(r.place)
1797 : (r.place === 1 ? '1st' : (r.place === 2 ? '2nd' : (r.place === 3 ? '3rd' : r.place + 'th')));
1798 li.textContent = (typeof I18n !== 'undefined')
1799 ? I18n.t('podium.line', { place: medal, name: r.name, score: r.score })
1800 : (medal + ' ' + r.name + ' · ' + r.score + ' points');
1754 1801 list.appendChild(li);
1755 1802 }
1756 1803 var hint = document.getElementById('podium-hint');
1757 1804 var secs = (lobby && lobby.podium_seconds) || 5;
1758 hint.textContent = 'Over ' + secs + ' seconden teruggaan naar de lobby…';
1805 if (hint)
1806 {
1807 hint.textContent = (typeof I18n !== 'undefined')
1808 ? I18n.t('podium.hint', { n: secs })
1809 : ('Returning to the lobby in ' + secs + ' seconds…');
1810 }
1759 1811 }
1760 1812
1761 1813 function startOnlineMatch ()
@@ -1880,8 +1932,21 @@ function bindOnlineUi ()
1880 1932 document.getElementById('btn-copy-code').addEventListener('click', function ()
1881 1933 {
1882 1934 var code = document.getElementById('lobby-code').textContent;
1935 var btn = document.getElementById('btn-copy-code');
1936 var done = function ()
1937 {
1938 if (!btn)
1939 { return; }
1940 btn.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.copied') : 'Copied';
1941 setTimeout(function ()
1942 {
1943 btn.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.copy') : 'Copy';
1944 }, 1500);
1945 };
1883 1946 if (navigator.clipboard && navigator.clipboard.writeText)
1884 { navigator.clipboard.writeText(code); }
1947 { navigator.clipboard.writeText(code).then(done, done); }
1948 else
1949 { done(); }
1885 1950 });
1886 1951
1887 1952 document.getElementById('btn-spectate').addEventListener('click', function ()
@@ -1937,10 +2002,10 @@ function openOnlinePanel ()
1937 2002 hideEl('planet-select');
1938 2003 showEl('online-panel');
1939 2004 app.mode = 'online';
1940 setOnlineStatus('Even kijken of online spelen beschikbaar is…');
2005 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.checking') : 'Checking whether online play is available…');
1941 2006 if (typeof Online === 'undefined')
1942 2007 {
1943 showOnlineError('Online spelen is in deze build niet geladen. Je kunt wel alleen spelen.');
2008 showOnlineError((typeof I18n !== 'undefined') ? I18n.t('online.notLoaded') : 'Online play is not included in this build. You can still play solo.');
1944 2009 showOnly('online-unconfigured');
1945 2010 return;
1946 2011 }
@@ -1948,8 +2013,10 @@ function openOnlinePanel ()
1948 2013 {
1949 2014 if (!data || data.ok === false)
1950 2015 {
1951 var msg = (data && data.error) || 'Geen verbinding met de server.';
1952 showOnlineError(msg + ' Je kunt wel alleen spelen.');
2016 var msg = (data && data.error)
2017 ? ((typeof I18n !== 'undefined') ? I18n.error(data.error) : data.error)
2018 : ((typeof I18n !== 'undefined') ? I18n.t('error.connection') : 'No connection to the server.');
2019 showOnlineError(msg + ' ' + ((typeof I18n !== 'undefined') ? I18n.t('online.canPlaySolo') : 'You can still play solo.'));
1953 2020 if (data && data.configured === false)
1954 2021 { showOnly('online-unconfigured'); }
1955 2022 else
@@ -2003,16 +2070,16 @@ function renderOnline ()
2003 2070 { showPodium(Online.lobby); }
2004 2071 return;
2005 2072 }
2006 showOnlineError(Online.error);
2073 showOnlineError((typeof I18n !== 'undefined' && Online.error) ? I18n.error(Online.error) : Online.error);
2007 2074 if (!Online.configured && !Online.me && !Online.local)
2008 2075 {
2009 setOnlineStatus('Online spelen is nog niet ingesteld.');
2076 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusUnconfigured') : 'Online play is not set up yet.');
2010 2077 showOnly('online-unconfigured');
2011 2078 return;
2012 2079 }
2013 2080 if (!Online.me)
2014 2081 {
2015 setOnlineStatus('Log in om een lobby te maken of eraan deel te nemen.');
2082 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusLogin') : 'Log in to create a lobby or join one.');
2016 2083 showOnly('online-login');
2017 2084 document.getElementById('btn-login').style.display = '';
2018 2085 document.getElementById('btn-login').href = Online.loginUrl();
@@ -2021,7 +2088,7 @@ function renderOnline ()
2021 2088 }
2022 2089 if (Online.lobby)
2023 2090 {
2024 setOnlineStatus('Lobby');
2091 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusLobby') : 'Lobby');
2025 2092 showOnly('online-lobby');
2026 2093 document.getElementById('lobby-me-name').textContent = Online.me.name;
2027 2094 document.getElementById('lobby-code').textContent = Online.lobby.code;
@@ -2034,7 +2101,9 @@ function renderOnline ()
2034 2101 var li = document.createElement('li');
2035 2102 if (p.is_me)
2036 2103 { li.classList.add('you'); }
2037 var label = p.name + (p.is_host ? ' (host)' : '') + (p.is_me ? ' (jij)' : '');
2104 var host = (typeof I18n !== 'undefined') ? I18n.t('online.host') : 'host';
2105 var you = (typeof I18n !== 'undefined') ? I18n.t('online.you') : 'you';
2106 var label = p.name + (p.is_host ? ' (' + host + ')' : '') + (p.is_me ? ' (' + you + ')' : '');
2038 2107 var state = p.ready ? 'Gereed' : 'Wacht…';
2039 2108 var world = (p.planet && p.planet.name) ? (p.planet.name + ' · ' + p.planet.people) : '';
2040 2109 li.innerHTML = '<span>' + escapeText(label)
@@ -2045,24 +2114,26 @@ function renderOnline ()
2045 2114 }
2046 2115 renderPlanetGrid('lobby-planet-grid', true);
2047 2116 var me = Online.mePlayer();
2048 document.getElementById('btn-ready').textContent = (me && me.ready) ? 'Niet gereed' : 'Gereed';
2117 document.getElementById('btn-ready').textContent = (me && me.ready)
2118 ? ((typeof I18n !== 'undefined') ? I18n.t('online.notReady') : 'Not ready')
2119 : ((typeof I18n !== 'undefined') ? I18n.t('online.ready') : 'Ready');
2049 2120 var start = document.getElementById('btn-start');
2050 2121 start.hidden = !(Online.lobby && Online.me && Online.lobby.host_id === Online.me.id);
2051 2122 start.disabled = !Online.lobby.can_start;
2052 2123 var hint = document.getElementById('lobby-hint');
2053 2124 if (Online.lobby.status === 'playing')
2054 { hint.textContent = 'Het spel start…'; }
2125 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintStarting') : 'The game is starting…'; }
2055 2126 else if (players.length < 2)
2056 { hint.textContent = 'Wacht op minstens één andere speler. Deel de code.'; }
2127 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintNeedPlayers') : 'Wait for at least one other player. Share the code.'; }
2057 2128 else if (!Online.lobby.all_ready)
2058 { hint.textContent = 'Iedereen moet op Gereed drukken. De host start daarna.'; }
2129 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintNeedReady') : 'Everyone must press Ready. The host starts afterwards.'; }
2059 2130 else if (Online.lobby.can_start)
2060 { hint.textContent = 'Iedereen is gereed. Druk op Starten.'; }
2131 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintHostStart') : 'Everyone is ready. Press Start.'; }
2061 2132 else
2062 { hint.textContent = 'Wachten tot de host start.'; }
2133 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintWaitHost') : 'Waiting for the host to start.'; }
2063 2134 return;
2064 2135 }
2065 setOnlineStatus('Hoi ' + Online.me.name + '. Maak een lobby of val in met een code.');
2136 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusHome', { name: Online.me.name }) : ('Hi ' + Online.me.name + '. Create a lobby or join with a code.'));
2066 2137 showOnly('online-home');
2067 2138 document.getElementById('me-name').textContent = Online.me.name;
2068 2139 document.getElementById('local-login').hidden = !Online.local;
@@ -2134,7 +2205,7 @@ function openPlanetSelect (context)
2134 2205 renderPlanetGrid('planet-grid', false);
2135 2206 var go = document.getElementById('btn-planet-go');
2136 2207 if (go)
2137 { go.textContent = 'Spelen'; }
2208 { go.textContent = (typeof I18n !== 'undefined') ? I18n.t('menu.play') : 'Play'; }
2138 2209 }
2139 2210
2140 2211 function renderPlanetGrid (containerId, compact)
@@ -2160,14 +2231,20 @@ function renderPlanetGrid (containerId, compact)
2160 2231 var colors = pl.colors || [];
2161 2232 for (var c = 0; c < colors.length; c++)
2162 2233 {
2234 var cname = colors[c].name;
2235 if (typeof I18n !== 'undefined' && (colors[c].block || (!pl.custom && colors[c].name)))
2236 { cname = I18n.blockName(colors[c].block || (pl.id + '-' + colors[c].name), colors[c].name); }
2163 2237 swatches += '<img src="' + escapeText(colors[c].image) + '" alt="'
2164 + escapeText(colors[c].name) + '" title="' + escapeText(colors[c].name) + '">';
2238 + escapeText(cname) + '" title="' + escapeText(cname) + '">';
2165 2239 }
2166 btn.innerHTML = '<div class="planet-title">' + escapeText(pl.name) + '</div>'
2167 + '<div class="planet-people">' + escapeText(pl.people) + '</div>'
2240 var title = (typeof I18n !== 'undefined') ? I18n.planetName(pl) : pl.name;
2241 var people = (typeof I18n !== 'undefined') ? I18n.peopleName(pl) : pl.people;
2242 var badge = (typeof I18n !== 'undefined') ? I18n.t('planet.customBadge') : 'Yours';
2243 btn.innerHTML = '<div class="planet-title">' + escapeText(title) + '</div>'
2244 + '<div class="planet-people">' + escapeText(people) + '</div>'
2168 2245 + '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'
2169 2246 + '<div class="planet-swatches">' + swatches + '</div>'
2170 + (pl.custom ? '<span class="custom-badge">Eigen</span>' : '');
2247 + (pl.custom ? '<span class="custom-badge">' + escapeText(badge) + '</span>' : '');
2171 2248 btn.addEventListener('click', (function (id, isCompact)
2172 2249 {
2173 2250 return function ()
@@ -2245,7 +2322,7 @@ function refreshMenuAccount ()
2245 2322 { user.hidden = false; }
2246 2323 var name = document.getElementById('menu-name');
2247 2324 if (name)
2248 { name.textContent = me.name || me.id || 'speler'; }
2325 { name.textContent = me.name || me.id || ((typeof I18n !== 'undefined') ? I18n.t('menu.player') : 'player'); }
2249 2326 var pts = document.getElementById('menu-points');
2250 2327 if (pts)
2251 2328 { pts.textContent = String((typeof Online !== 'undefined' && Online.lifetimePoints) || 0); }
@@ -2289,3 +2366,50 @@ function finishPlaySession (score)
2289 2366 { refreshMenuAccount(); });
2290 2367 }
2291 2368
2369
2370
2371 function applyProfileLocale ()
2372 {
2373 if (typeof I18n === 'undefined' || typeof Online === 'undefined')
2374 { return; }
2375 if (Online.locale)
2376 { I18n.applyFromProfile(Online.locale); }
2377 else if (Online.me)
2378 { Online.setLocale(I18n.locale); }
2379 }
2380
2381 function refreshAllUi ()
2382 {
2383 if (typeof I18n !== 'undefined')
2384 { I18n.apply(); }
2385 refreshMenuAccount();
2386 if (typeof renderPlanetGrid === 'function')
2387 {
2388 renderPlanetGrid('planet-grid', false);
2389 renderPlanetGrid('lobby-planet-grid', true);
2390 }
2391 if (app && app.mode === 'online' && typeof renderOnline === 'function')
2392 { renderOnline(); }
2393 if (typeof Designer !== 'undefined')
2394 {
2395 var des = document.getElementById('designer');
2396 var edit = document.getElementById('designer-edit');
2397 if (des && !des.hidden)
2398 { Designer.renderList(); }
2399 if (edit && !edit.hidden)
2400 {
2401 Designer.syncPreview();
2402 Designer.renderSlots();
2403 var modal = document.getElementById('des-modal');
2404 if (modal && !modal.hidden)
2405 { Designer.openModal(Designer.openSlot); }
2406 }
2407 }
2408 if (app && app.mode === 'playing')
2409 {
2410 if (typeof refreshHud === 'function')
2411 { refreshHud(); }
2412 if (typeof refreshOfflineHud === 'function')
2413 { refreshOfflineHud(); }
2414 }
2415 }
@@ -112,6 +112,13 @@ window.onload = function ()
112 { game.images.flame.addAnimationCycle('burn', [0, 1, 2, 3], true); }
112 { game.images.flame.addAnimationCycle('burn', [0, 1, 2, 3], true); }
113 });
113 });
114
114
115 if (typeof I18n !== 'undefined')
116 {
117 I18n.init();
118 I18n.bindPicker();
119 I18n.onChange(function ()
120 { refreshAllUi(); });
121 }
115 bindOnlineUi();
122 bindOnlineUi();
116 bindOfflineUi();
123 bindOfflineUi();
117 bindPlanetSelect();
124 bindPlanetSelect();
@@ -122,6 +129,7 @@ window.onload = function ()
122 {
129 {
123 Online.refresh().then(function ()
130 Online.refresh().then(function ()
124 {
131 {
132 applyProfileLocale();
125 refreshMenuAccount();
133 refreshMenuAccount();
126 restoreSelectedPlanet();
134 restoreSelectedPlanet();
127 renderPlanetGrid('planet-grid', false);
135 renderPlanetGrid('planet-grid', false);
@@ -753,7 +761,9 @@ function refreshHud ()
753 { return; }
761 { return; }
754 document.getElementById('score').textContent = String(app.core.score);
762 document.getElementById('score').textContent = String(app.core.score);
755 var planet = app.planet;
763 var planet = app.planet;
756 document.getElementById('planet-name').textContent = planet.name + ' · ' + planet.people;
764 var pname = (typeof I18n !== 'undefined') ? I18n.planetName(planet) : planet.name;
765 var people = (typeof I18n !== 'undefined') ? I18n.peopleName(planet) : planet.people;
766 document.getElementById('planet-name').textContent = pname + ' · ' + people;
757 document.getElementById('planet-stats').textContent = Planet.formatStats(planet);
767 document.getElementById('planet-stats').textContent = Planet.formatStats(planet);
758}
768}
759
769
@@ -1438,16 +1448,31 @@ function showOfflineResult ()
1438 app.offlineResultShown = true;
1448 app.offlineResultShown = true;
1439 var battle = app.battle;
1449 var battle = app.battle;
1440 var reached = document.getElementById('offline-reached');
1450 var reached = document.getElementById('offline-reached');
1441 if (reached)
1451 var sch = battle.schedule;
1452 var n = sch.opponents;
1453 var skill = Math.round(sch.skill * 100);
1454 var line = document.getElementById('offline-reached-line');
1455 if (line && typeof I18n !== 'undefined')
1456 { line.textContent = I18n.t('offline.reached', { n: battle.round }); }
1457 else if (reached)
1442 { reached.textContent = String(battle.round); }
1458 { reached.textContent = String(battle.round); }
1443 var detail = document.getElementById('offline-result-detail');
1459 var detail = document.getElementById('offline-result-detail');
1444 if (detail)
1460 if (detail)
1445 {
1461 {
1446 var sch = battle.schedule;
1462 if (typeof I18n !== 'undefined')
1447 var n = sch.opponents;
1463 {
1448 var noun = n === 1 ? 'tegenstander' : 'tegenstanders';
1464 detail.textContent = I18n.t('offline.detail', {
1449 detail.textContent = 'Je speelde tegen ' + n + ' ' + noun
1465 n: n,
1450 + ' met skill ' + Math.round(sch.skill * 100) + '%.';
1466 opponents: I18n.plural('hud.opponent', n),
1467 skill: skill
1468 });
1469 }
1470 else
1471 {
1472 var noun = n === 1 ? 'opponent' : 'opponents';
1473 detail.textContent = 'You played against ' + n + ' ' + noun
1474 + ' at skill ' + skill + '%.';
1475 }
1451 }
1476 }
1452 hideEl('game-over');
1477 hideEl('game-over');
1453 showEl('offline-result');
1478 showEl('offline-result');
@@ -1467,16 +1492,32 @@ function refreshOfflineHud ()
1467 el.hidden = false;
1492 el.hidden = false;
1468 var sch = app.battle.schedule;
1493 var sch = app.battle.schedule;
1469 var n = sch.opponents;
1494 var n = sch.opponents;
1470 var noun = n === 1 ? 'tegenstander' : 'tegenstanders';
1471 var r = document.getElementById('offline-round');
1495 var r = document.getElementById('offline-round');
1472 var o = document.getElementById('offline-opponents');
1496 var o = document.getElementById('offline-opponents');
1473 var s = document.getElementById('offline-skill');
1497 var s = document.getElementById('offline-skill');
1474 if (r)
1498 if (typeof I18n !== 'undefined')
1475 { r.textContent = 'Ronde ' + sch.round; }
1499 {
1476 if (o)
1500 if (r)
1477 { o.textContent = n + ' ' + noun; }
1501 { r.textContent = I18n.t('hud.round', { n: sch.round }); }
1478 if (s)
1502 if (o)
1479 { s.textContent = 'Skill ' + Math.round(sch.skill * 100) + '%'; }
1503 {
1504 o.textContent = I18n.t('hud.opponentsLine', {
1505 n: n, word: I18n.plural('hud.opponent', n)
1506 });
1507 }
1508 if (s)
1509 { s.textContent = I18n.t('hud.skill', { n: Math.round(sch.skill * 100) }); }
1510 }
1511 else
1512 {
1513 var noun = n === 1 ? 'opponent' : 'opponents';
1514 if (r)
1515 { r.textContent = 'Round ' + sch.round; }
1516 if (o)
1517 { o.textContent = n + ' ' + noun; }
1518 if (s)
1519 { s.textContent = 'Skill ' + Math.round(sch.skill * 100) + '%'; }
1520 }
1480}
1521}
1481
1522
1482function hideOfflineHud ()
1523function hideOfflineHud ()
@@ -1577,11 +1618,14 @@ function renderOfflineMinis ()
1577 }
1618 }
1578 el.classList.toggle('eliminated', !!bot.eliminated);
1619 el.classList.toggle('eliminated', !!bot.eliminated);
1579 var planetName = bot.planet && bot.planet.name ? bot.planet.name : '';
1620 var planetName = bot.planet && bot.planet.name ? bot.planet.name : '';
1621 var shownPlanet = planetName;
1622 if (bot.planet && typeof I18n !== 'undefined')
1623 { shownPlanet = I18n.planetName(bot.planet); }
1580 el.querySelector('.mini-name').textContent = bot.name
1624 el.querySelector('.mini-name').textContent = bot.name
1581 + (planetName ? ' · ' + planetName : '');
1625 + (shownPlanet ? ' · ' + shownPlanet : '');
1582 el.querySelector('.mini-meta').textContent = bot.eliminated
1626 el.querySelector('.mini-meta').textContent = bot.eliminated
1583 ? 'Uit'
1627 ? ((typeof I18n !== 'undefined') ? I18n.t('hud.out') : 'Out')
1584 : ('Punten ' + (bot.score || 0));
1628 : ((typeof I18n !== 'undefined') ? I18n.t('hud.miniPoints', { n: bot.score || 0 }) : ('Points ' + (bot.score || 0)));
1585 var snap = bot.core ? bot.core.fieldSnapshot() : { blocks: [] };
1629 var snap = bot.core ? bot.core.fieldSnapshot() : { blocks: [] };
1586 if (typeof Online !== 'undefined' && Online._drawMini)
1630 if (typeof Online !== 'undefined' && Online._drawMini)
1587 { Online._drawMini(canvas, snap, bot.planet); }
1631 { Online._drawMini(canvas, snap, bot.planet); }
@@ -1749,13 +1793,21 @@ function showPodium (lobby)
1749 {
1793 {
1750 var r = ranks[i];
1794 var r = ranks[i];
1751 var li = document.createElement('li');
1795 var li = document.createElement('li');
1752 var medal = r.place === 1 ? '1e' : (r.place === 2 ? '2e' : (r.place === 3 ? '3e' : r.place + 'e'));
1796 var medal = (typeof I18n !== 'undefined') ? I18n.place(r.place)
1753 li.textContent = medal + ' ' + r.name + ' · ' + r.score + ' punten';
1797 : (r.place === 1 ? '1st' : (r.place === 2 ? '2nd' : (r.place === 3 ? '3rd' : r.place + 'th')));
1798 li.textContent = (typeof I18n !== 'undefined')
1799 ? I18n.t('podium.line', { place: medal, name: r.name, score: r.score })
1800 : (medal + ' ' + r.name + ' · ' + r.score + ' points');
1754 list.appendChild(li);
1801 list.appendChild(li);
1755 }
1802 }
1756 var hint = document.getElementById('podium-hint');
1803 var hint = document.getElementById('podium-hint');
1757 var secs = (lobby && lobby.podium_seconds) || 5;
1804 var secs = (lobby && lobby.podium_seconds) || 5;
1758 hint.textContent = 'Over ' + secs + ' seconden teruggaan naar de lobby…';
1805 if (hint)
1806 {
1807 hint.textContent = (typeof I18n !== 'undefined')
1808 ? I18n.t('podium.hint', { n: secs })
1809 : ('Returning to the lobby in ' + secs + ' seconds…');
1810 }
1759}
1811}
1760
1812
1761function startOnlineMatch ()
1813function startOnlineMatch ()
@@ -1880,8 +1932,21 @@ function bindOnlineUi ()
1880 document.getElementById('btn-copy-code').addEventListener('click', function ()
1932 document.getElementById('btn-copy-code').addEventListener('click', function ()
1881 {
1933 {
1882 var code = document.getElementById('lobby-code').textContent;
1934 var code = document.getElementById('lobby-code').textContent;
1935 var btn = document.getElementById('btn-copy-code');
1936 var done = function ()
1937 {
1938 if (!btn)
1939 { return; }
1940 btn.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.copied') : 'Copied';
1941 setTimeout(function ()
1942 {
1943 btn.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.copy') : 'Copy';
1944 }, 1500);
1945 };
1883 if (navigator.clipboard && navigator.clipboard.writeText)
1946 if (navigator.clipboard && navigator.clipboard.writeText)
1884 { navigator.clipboard.writeText(code); }
1947 { navigator.clipboard.writeText(code).then(done, done); }
1948 else
1949 { done(); }
1885 });
1950 });
1886
1951
1887 document.getElementById('btn-spectate').addEventListener('click', function ()
1952 document.getElementById('btn-spectate').addEventListener('click', function ()
@@ -1937,10 +2002,10 @@ function openOnlinePanel ()
1937 hideEl('planet-select');
2002 hideEl('planet-select');
1938 showEl('online-panel');
2003 showEl('online-panel');
1939 app.mode = 'online';
2004 app.mode = 'online';
1940 setOnlineStatus('Even kijken of online spelen beschikbaar is…');
2005 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.checking') : 'Checking whether online play is available…');
1941 if (typeof Online === 'undefined')
2006 if (typeof Online === 'undefined')
1942 {
2007 {
1943 showOnlineError('Online spelen is in deze build niet geladen. Je kunt wel alleen spelen.');
2008 showOnlineError((typeof I18n !== 'undefined') ? I18n.t('online.notLoaded') : 'Online play is not included in this build. You can still play solo.');
1944 showOnly('online-unconfigured');
2009 showOnly('online-unconfigured');
1945 return;
2010 return;
1946 }
2011 }
@@ -1948,8 +2013,10 @@ function openOnlinePanel ()
1948 {
2013 {
1949 if (!data || data.ok === false)
2014 if (!data || data.ok === false)
1950 {
2015 {
1951 var msg = (data && data.error) || 'Geen verbinding met de server.';
2016 var msg = (data && data.error)
1952 showOnlineError(msg + ' Je kunt wel alleen spelen.');
2017 ? ((typeof I18n !== 'undefined') ? I18n.error(data.error) : data.error)
2018 : ((typeof I18n !== 'undefined') ? I18n.t('error.connection') : 'No connection to the server.');
2019 showOnlineError(msg + ' ' + ((typeof I18n !== 'undefined') ? I18n.t('online.canPlaySolo') : 'You can still play solo.'));
1953 if (data && data.configured === false)
2020 if (data && data.configured === false)
1954 { showOnly('online-unconfigured'); }
2021 { showOnly('online-unconfigured'); }
1955 else
2022 else
@@ -2003,16 +2070,16 @@ function renderOnline ()
2003 { showPodium(Online.lobby); }
2070 { showPodium(Online.lobby); }
2004 return;
2071 return;
2005 }
2072 }
2006 showOnlineError(Online.error);
2073 showOnlineError((typeof I18n !== 'undefined' && Online.error) ? I18n.error(Online.error) : Online.error);
2007 if (!Online.configured && !Online.me && !Online.local)
2074 if (!Online.configured && !Online.me && !Online.local)
2008 {
2075 {
2009 setOnlineStatus('Online spelen is nog niet ingesteld.');
2076 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusUnconfigured') : 'Online play is not set up yet.');
2010 showOnly('online-unconfigured');
2077 showOnly('online-unconfigured');
2011 return;
2078 return;
2012 }
2079 }
2013 if (!Online.me)
2080 if (!Online.me)
2014 {
2081 {
2015 setOnlineStatus('Log in om een lobby te maken of eraan deel te nemen.');
2082 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusLogin') : 'Log in to create a lobby or join one.');
2016 showOnly('online-login');
2083 showOnly('online-login');
2017 document.getElementById('btn-login').style.display = '';
2084 document.getElementById('btn-login').style.display = '';
2018 document.getElementById('btn-login').href = Online.loginUrl();
2085 document.getElementById('btn-login').href = Online.loginUrl();
@@ -2021,7 +2088,7 @@ function renderOnline ()
2021 }
2088 }
2022 if (Online.lobby)
2089 if (Online.lobby)
2023 {
2090 {
2024 setOnlineStatus('Lobby');
2091 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusLobby') : 'Lobby');
2025 showOnly('online-lobby');
2092 showOnly('online-lobby');
2026 document.getElementById('lobby-me-name').textContent = Online.me.name;
2093 document.getElementById('lobby-me-name').textContent = Online.me.name;
2027 document.getElementById('lobby-code').textContent = Online.lobby.code;
2094 document.getElementById('lobby-code').textContent = Online.lobby.code;
@@ -2034,7 +2101,9 @@ function renderOnline ()
2034 var li = document.createElement('li');
2101 var li = document.createElement('li');
2035 if (p.is_me)
2102 if (p.is_me)
2036 { li.classList.add('you'); }
2103 { li.classList.add('you'); }
2037 var label = p.name + (p.is_host ? ' (host)' : '') + (p.is_me ? ' (jij)' : '');
2104 var host = (typeof I18n !== 'undefined') ? I18n.t('online.host') : 'host';
2105 var you = (typeof I18n !== 'undefined') ? I18n.t('online.you') : 'you';
2106 var label = p.name + (p.is_host ? ' (' + host + ')' : '') + (p.is_me ? ' (' + you + ')' : '');
2038 var state = p.ready ? 'Gereed' : 'Wacht…';
2107 var state = p.ready ? 'Gereed' : 'Wacht…';
2039 var world = (p.planet && p.planet.name) ? (p.planet.name + ' · ' + p.planet.people) : '';
2108 var world = (p.planet && p.planet.name) ? (p.planet.name + ' · ' + p.planet.people) : '';
2040 li.innerHTML = '<span>' + escapeText(label)
2109 li.innerHTML = '<span>' + escapeText(label)
@@ -2045,24 +2114,26 @@ function renderOnline ()
2045 }
2114 }
2046 renderPlanetGrid('lobby-planet-grid', true);
2115 renderPlanetGrid('lobby-planet-grid', true);
2047 var me = Online.mePlayer();
2116 var me = Online.mePlayer();
2048 document.getElementById('btn-ready').textContent = (me && me.ready) ? 'Niet gereed' : 'Gereed';
2117 document.getElementById('btn-ready').textContent = (me && me.ready)
2118 ? ((typeof I18n !== 'undefined') ? I18n.t('online.notReady') : 'Not ready')
2119 : ((typeof I18n !== 'undefined') ? I18n.t('online.ready') : 'Ready');
2049 var start = document.getElementById('btn-start');
2120 var start = document.getElementById('btn-start');
2050 start.hidden = !(Online.lobby && Online.me && Online.lobby.host_id === Online.me.id);
2121 start.hidden = !(Online.lobby && Online.me && Online.lobby.host_id === Online.me.id);
2051 start.disabled = !Online.lobby.can_start;
2122 start.disabled = !Online.lobby.can_start;
2052 var hint = document.getElementById('lobby-hint');
2123 var hint = document.getElementById('lobby-hint');
2053 if (Online.lobby.status === 'playing')
2124 if (Online.lobby.status === 'playing')
2054 { hint.textContent = 'Het spel start…'; }
2125 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintStarting') : 'The game is starting…'; }
2055 else if (players.length < 2)
2126 else if (players.length < 2)
2056 { hint.textContent = 'Wacht op minstens één andere speler. Deel de code.'; }
2127 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintNeedPlayers') : 'Wait for at least one other player. Share the code.'; }
2057 else if (!Online.lobby.all_ready)
2128 else if (!Online.lobby.all_ready)
2058 { hint.textContent = 'Iedereen moet op Gereed drukken. De host start daarna.'; }
2129 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintNeedReady') : 'Everyone must press Ready. The host starts afterwards.'; }
2059 else if (Online.lobby.can_start)
2130 else if (Online.lobby.can_start)
2060 { hint.textContent = 'Iedereen is gereed. Druk op Starten.'; }
2131 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintHostStart') : 'Everyone is ready. Press Start.'; }
2061 else
2132 else
2062 { hint.textContent = 'Wachten tot de host start.'; }
2133 { hint.textContent = (typeof I18n !== 'undefined') ? I18n.t('online.hintWaitHost') : 'Waiting for the host to start.'; }
2063 return;
2134 return;
2064 }
2135 }
2065 setOnlineStatus('Hoi ' + Online.me.name + '. Maak een lobby of val in met een code.');
2136 setOnlineStatus((typeof I18n !== 'undefined') ? I18n.t('online.statusHome', { name: Online.me.name }) : ('Hi ' + Online.me.name + '. Create a lobby or join with a code.'));
2066 showOnly('online-home');
2137 showOnly('online-home');
2067 document.getElementById('me-name').textContent = Online.me.name;
2138 document.getElementById('me-name').textContent = Online.me.name;
2068 document.getElementById('local-login').hidden = !Online.local;
2139 document.getElementById('local-login').hidden = !Online.local;
@@ -2134,7 +2205,7 @@ function openPlanetSelect (context)
2134 renderPlanetGrid('planet-grid', false);
2205 renderPlanetGrid('planet-grid', false);
2135 var go = document.getElementById('btn-planet-go');
2206 var go = document.getElementById('btn-planet-go');
2136 if (go)
2207 if (go)
2137 { go.textContent = 'Spelen'; }
2208 { go.textContent = (typeof I18n !== 'undefined') ? I18n.t('menu.play') : 'Play'; }
2138}
2209}
2139
2210
2140function renderPlanetGrid (containerId, compact)
2211function renderPlanetGrid (containerId, compact)
@@ -2160,14 +2231,20 @@ function renderPlanetGrid (containerId, compact)
2160 var colors = pl.colors || [];
2231 var colors = pl.colors || [];
2161 for (var c = 0; c < colors.length; c++)
2232 for (var c = 0; c < colors.length; c++)
2162 {
2233 {
2234 var cname = colors[c].name;
2235 if (typeof I18n !== 'undefined' && (colors[c].block || (!pl.custom && colors[c].name)))
2236 { cname = I18n.blockName(colors[c].block || (pl.id + '-' + colors[c].name), colors[c].name); }
2163 swatches += '<img src="' + escapeText(colors[c].image) + '" alt="'
2237 swatches += '<img src="' + escapeText(colors[c].image) + '" alt="'
2164 + escapeText(colors[c].name) + '" title="' + escapeText(colors[c].name) + '">';
2238 + escapeText(cname) + '" title="' + escapeText(cname) + '">';
2165 }
2239 }
2166 btn.innerHTML = '<div class="planet-title">' + escapeText(pl.name) + '</div>'
2240 var title = (typeof I18n !== 'undefined') ? I18n.planetName(pl) : pl.name;
2167 + '<div class="planet-people">' + escapeText(pl.people) + '</div>'
2241 var people = (typeof I18n !== 'undefined') ? I18n.peopleName(pl) : pl.people;
2242 var badge = (typeof I18n !== 'undefined') ? I18n.t('planet.customBadge') : 'Yours';
2243 btn.innerHTML = '<div class="planet-title">' + escapeText(title) + '</div>'
2244 + '<div class="planet-people">' + escapeText(people) + '</div>'
2168 + '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'
2245 + '<div class="planet-nums">' + escapeText(Planet.formatStats(pl)) + '</div>'
2169 + '<div class="planet-swatches">' + swatches + '</div>'
2246 + '<div class="planet-swatches">' + swatches + '</div>'
2170 + (pl.custom ? '<span class="custom-badge">Eigen</span>' : '');
2247 + (pl.custom ? '<span class="custom-badge">' + escapeText(badge) + '</span>' : '');
2171 btn.addEventListener('click', (function (id, isCompact)
2248 btn.addEventListener('click', (function (id, isCompact)
2172 {
2249 {
2173 return function ()
2250 return function ()
@@ -2245,7 +2322,7 @@ function refreshMenuAccount ()
2245 { user.hidden = false; }
2322 { user.hidden = false; }
2246 var name = document.getElementById('menu-name');
2323 var name = document.getElementById('menu-name');
2247 if (name)
2324 if (name)
2248 { name.textContent = me.name || me.id || 'speler'; }
2325 { name.textContent = me.name || me.id || ((typeof I18n !== 'undefined') ? I18n.t('menu.player') : 'player'); }
2249 var pts = document.getElementById('menu-points');
2326 var pts = document.getElementById('menu-points');
2250 if (pts)
2327 if (pts)
2251 { pts.textContent = String((typeof Online !== 'undefined' && Online.lifetimePoints) || 0); }
2328 { pts.textContent = String((typeof Online !== 'undefined' && Online.lifetimePoints) || 0); }
@@ -2289,3 +2366,50 @@ function finishPlaySession (score)
2289 { refreshMenuAccount(); });
2366 { refreshMenuAccount(); });
2290}
2367}
2291
2368
2369
2370
2371function applyProfileLocale ()
2372{
2373 if (typeof I18n === 'undefined' || typeof Online === 'undefined')
2374 { return; }
2375 if (Online.locale)
2376 { I18n.applyFromProfile(Online.locale); }
2377 else if (Online.me)
2378 { Online.setLocale(I18n.locale); }
2379}
2380
2381function refreshAllUi ()
2382{
2383 if (typeof I18n !== 'undefined')
2384 { I18n.apply(); }
2385 refreshMenuAccount();
2386 if (typeof renderPlanetGrid === 'function')
2387 {
2388 renderPlanetGrid('planet-grid', false);
2389 renderPlanetGrid('lobby-planet-grid', true);
2390 }
2391 if (app && app.mode === 'online' && typeof renderOnline === 'function')
2392 { renderOnline(); }
2393 if (typeof Designer !== 'undefined')
2394 {
2395 var des = document.getElementById('designer');
2396 var edit = document.getElementById('designer-edit');
2397 if (des && !des.hidden)
2398 { Designer.renderList(); }
2399 if (edit && !edit.hidden)
2400 {
2401 Designer.syncPreview();
2402 Designer.renderSlots();
2403 var modal = document.getElementById('des-modal');
2404 if (modal && !modal.hidden)
2405 { Designer.openModal(Designer.openSlot); }
2406 }
2407 }
2408 if (app && app.mode === 'playing')
2409 {
2410 if (typeof refreshHud === 'function')
2411 { refreshHud(); }
2412 if (typeof refreshOfflineHud === 'function')
2413 { refreshOfflineHud(); }
2414 }
2415}
src/online.js +20 −7
@@ -112,18 +112,18 @@ Online.request = function (action, body)
112 112 {
113 113 data = data || {};
114 114 if (!res.ok && !data.error)
115 { data.error = 'De server gaf ' + res.status; data.ok = false; }
115 { data.error = (typeof I18n !== 'undefined' ? I18n.t('error.serverStatus', { status: res.status }) : ('De server gaf ' + res.status)); data.ok = false; }
116 116 self._apply(data);
117 117 return data;
118 118 }, function ()
119 119 {
120 var fail = { ok: false, error: 'Geen geldig antwoord van de server.' };
120 var fail = { ok: false, error: (typeof I18n !== 'undefined' ? I18n.t('error.badResponse') : 'Geen geldig antwoord van de server.') };
121 121 self.error = fail.error;
122 122 return fail;
123 123 });
124 124 }).catch(function (err)
125 125 {
126 var fail = { ok: false, error: 'Geen verbinding met de server.' };
126 var fail = { ok: false, error: (typeof I18n !== 'undefined' ? I18n.t('error.connection') : 'Geen verbinding met de server.') };
127 127 self.error = fail.error;
128 128 return fail;
129 129 });
@@ -366,10 +366,23 @@ Online.renderMinis = function (container)
366 366 canvas.style.height = mz.h + 'px';
367 367 }
368 368 el.classList.toggle('eliminated', !!p.eliminated);
369 el.querySelector('.mini-name').textContent = p.name + (p.is_host ? ' (host)' : '');
370 el.querySelector('.mini-meta').textContent = p.eliminated
371 ? ('Uit' + (p.place ? ' · ' + p.place + 'e' : ''))
372 : ('Punten ' + (p.score || 0));
369 var hostTag = (typeof I18n !== 'undefined') ? I18n.t('online.host') : 'host';
370 el.querySelector('.mini-name').textContent = p.name + (p.is_host ? ' (' + hostTag + ')' : '');
371 if (p.eliminated)
372 {
373 var out = (typeof I18n !== 'undefined') ? I18n.t('hud.out') : 'Out';
374 if (p.place && typeof I18n !== 'undefined')
375 { out += ' · ' + I18n.place(p.place); }
376 else if (p.place)
377 { out += ' · ' + p.place; }
378 el.querySelector('.mini-meta').textContent = out;
379 }
380 else
381 {
382 el.querySelector('.mini-meta').textContent = (typeof I18n !== 'undefined')
383 ? I18n.t('hud.miniPoints', { n: p.score || 0 })
384 : ('Points ' + (p.score || 0));
385 }
373 386 this._drawMini(el.querySelector('canvas'), p.snapshot, p.planet);
374 387 }
375 388 for (var id in existing)
@@ -112,18 +112,18 @@ Online.request = function (action, body)
112 {
112 {
113 data = data || {};
113 data = data || {};
114 if (!res.ok && !data.error)
114 if (!res.ok && !data.error)
115 { data.error = 'De server gaf ' + res.status; data.ok = false; }
115 { data.error = (typeof I18n !== 'undefined' ? I18n.t('error.serverStatus', { status: res.status }) : ('De server gaf ' + res.status)); data.ok = false; }
116 self._apply(data);
116 self._apply(data);
117 return data;
117 return data;
118 }, function ()
118 }, function ()
119 {
119 {
120 var fail = { ok: false, error: 'Geen geldig antwoord van de server.' };
120 var fail = { ok: false, error: (typeof I18n !== 'undefined' ? I18n.t('error.badResponse') : 'Geen geldig antwoord van de server.') };
121 self.error = fail.error;
121 self.error = fail.error;
122 return fail;
122 return fail;
123 });
123 });
124 }).catch(function (err)
124 }).catch(function (err)
125 {
125 {
126 var fail = { ok: false, error: 'Geen verbinding met de server.' };
126 var fail = { ok: false, error: (typeof I18n !== 'undefined' ? I18n.t('error.connection') : 'Geen verbinding met de server.') };
127 self.error = fail.error;
127 self.error = fail.error;
128 return fail;
128 return fail;
129 });
129 });
@@ -366,10 +366,23 @@ Online.renderMinis = function (container)
366 canvas.style.height = mz.h + 'px';
366 canvas.style.height = mz.h + 'px';
367 }
367 }
368 el.classList.toggle('eliminated', !!p.eliminated);
368 el.classList.toggle('eliminated', !!p.eliminated);
369 el.querySelector('.mini-name').textContent = p.name + (p.is_host ? ' (host)' : '');
369 var hostTag = (typeof I18n !== 'undefined') ? I18n.t('online.host') : 'host';
370 el.querySelector('.mini-meta').textContent = p.eliminated
370 el.querySelector('.mini-name').textContent = p.name + (p.is_host ? ' (' + hostTag + ')' : '');
371 ? ('Uit' + (p.place ? ' · ' + p.place + 'e' : ''))
371 if (p.eliminated)
372 : ('Punten ' + (p.score || 0));
372 {
373 var out = (typeof I18n !== 'undefined') ? I18n.t('hud.out') : 'Out';
374 if (p.place && typeof I18n !== 'undefined')
375 { out += ' · ' + I18n.place(p.place); }
376 else if (p.place)
377 { out += ' · ' + p.place; }
378 el.querySelector('.mini-meta').textContent = out;
379 }
380 else
381 {
382 el.querySelector('.mini-meta').textContent = (typeof I18n !== 'undefined')
383 ? I18n.t('hud.miniPoints', { n: p.score || 0 })
384 : ('Points ' + (p.score || 0));
385 }
373 this._drawMini(el.querySelector('canvas'), p.snapshot, p.planet);
386 this._drawMini(el.querySelector('canvas'), p.snapshot, p.planet);
374 }
387 }
375 for (var id in existing)
388 for (var id in existing)
src/planet.js +3 −1
@@ -210,10 +210,12 @@ function defaultPlanet ()
210 210 function formatStats (planet)
211 211 {
212 212 var d = displayValues(planet);
213 var power = (typeof I18n !== 'undefined')
214 ? I18n.t('stats.powerLabel') : 'Power';
213 215 return 'g ' + d.gravity.toFixed(2)
214 216 + ' d ' + d.density.toFixed(2)
215 217 + ' F ' + Math.round(d.newtons) + ' N'
216 + ' Power ' + d.power + '%';
218 + ' ' + power + ' ' + d.power + '%';
217 219 }
218 220
219 221 function spriteKey (planet, colorIndex)
@@ -210,10 +210,12 @@ function defaultPlanet ()
210function formatStats (planet)
210function formatStats (planet)
211{
211{
212 var d = displayValues(planet);
212 var d = displayValues(planet);
213 var power = (typeof I18n !== 'undefined')
214 ? I18n.t('stats.powerLabel') : 'Power';
213 return 'g ' + d.gravity.toFixed(2)
215 return 'g ' + d.gravity.toFixed(2)
214 + ' d ' + d.density.toFixed(2)
216 + ' d ' + d.density.toFixed(2)
215 + ' F ' + Math.round(d.newtons) + ' N'
217 + ' F ' + Math.round(d.newtons) + ' N'
216 + ' Power ' + d.power + '%';
218 + ' ' + power + ' ' + d.power + '%';
217}
219}
218
220
219function spriteKey (planet, colorIndex)
221function spriteKey (planet, colorIndex)