feat: place opponent minis beside the field on wide screens (t1125)
layout() uses MiniLayout, positions #minis.sides absolutely, and clips #flights-back so enemy-to-enemy arcs pass behind the field. Offline and online minis share the planned canvas size.
@@ -12,6 +12,7 @@
12
12
</head>
13
13
<body>
14
14
<div id="stars" aria-hidden="true"></div>
15
<div id="flights-back" aria-hidden="true"></div>
15
16
<div id="flights" aria-hidden="true"></div>
16
17
17
18
<div id="menu" class="screen">
@@ -12,6 +12,7 @@12
</head>12
</head>13
<body>13
<body>14
<div id="stars" aria-hidden="true"></div>14
<div id="stars" aria-hidden="true"></div>15
<div id="flights-back" aria-hidden="true"></div>15
<div id="flights" aria-hidden="true"></div>16
<div id="flights" aria-hidden="true"></div>16
17
17
<div id="menu" class="screen">18
<div id="menu" class="screen">@@ -46,7 +46,7 @@ html, body {
46
46
text-align: center;
47
47
}
48
48
49
.screen[hidden], #hud[hidden], #game-over[hidden], #online-panel[hidden], #minis[hidden], #spectator[hidden], #podium[hidden], #flights[hidden], #planet-select[hidden], #offline-result[hidden], #offline-hud[hidden], #chain-indicator[hidden] { display: none !important; }
49
.screen[hidden], #hud[hidden], #game-over[hidden], #online-panel[hidden], #minis[hidden], #spectator[hidden], #podium[hidden], #flights[hidden], #flights-back[hidden], #planet-select[hidden], #offline-result[hidden], #offline-hud[hidden], #chain-indicator[hidden] { display: none !important; }
50
50
51
51
h1 {
52
52
font-size: clamp(48px, 14vw, 96px);
@@ -350,6 +350,22 @@ a.button:is(:hover, :focus-visible) {
350
350
padding: 6px 8px 0;
351
351
pointer-events: none;
352
352
}
353
#minis.sides {
354
inset: 0;
355
display: block;
356
padding: 0;
357
overflow: visible;
358
max-height: none;
359
gap: 0;
360
}
361
#minis.sides .mini {
362
position: absolute;
363
margin: 0;
364
min-width: 0;
365
}
366
#minis.sides .mini-name {
367
max-width: 100%;
368
}
353
369
.mini {
354
370
text-align: center;
355
371
color: #c5cae0;
@@ -382,7 +398,17 @@ a.button:is(:hover, :focus-visible) {
382
398
pointer-events: none;
383
399
overflow: visible;
384
400
}
385
#flights .flight {
401
/* Enemy-to-enemy arcs: above the starfield and minis, but the field
402
rectangle is clipped out so they pass behind the player's field (t1125). */
403
#flights-back {
404
position: fixed;
405
inset: 0;
406
z-index: 5;
407
pointer-events: none;
408
overflow: visible;
409
}
410
#flights .flight,
411
#flights-back .flight {
386
412
position: fixed;
387
413
top: 0;
388
414
left: 0;
@@ -46,7 +46,7 @@ html, body {46
text-align: center;46
text-align: center;47
}47
}48
48
49
.screen[hidden], #hud[hidden], #game-over[hidden], #online-panel[hidden], #minis[hidden], #spectator[hidden], #podium[hidden], #flights[hidden], #planet-select[hidden], #offline-result[hidden], #offline-hud[hidden], #chain-indicator[hidden] { display: none !important; }49
.screen[hidden], #hud[hidden], #game-over[hidden], #online-panel[hidden], #minis[hidden], #spectator[hidden], #podium[hidden], #flights[hidden], #flights-back[hidden], #planet-select[hidden], #offline-result[hidden], #offline-hud[hidden], #chain-indicator[hidden] { display: none !important; }50
50
51
h1 {51
h1 {52
font-size: clamp(48px, 14vw, 96px);52
font-size: clamp(48px, 14vw, 96px);@@ -350,6 +350,22 @@ a.button:is(:hover, :focus-visible) {350
padding: 6px 8px 0;350
padding: 6px 8px 0;351
pointer-events: none;351
pointer-events: none;352
}352
}353
#minis.sides {354
inset: 0;355
display: block;356
padding: 0;357
overflow: visible;358
max-height: none;359
gap: 0;360
}361
#minis.sides .mini {362
position: absolute;363
margin: 0;364
min-width: 0;365
}366
#minis.sides .mini-name {367
max-width: 100%;368
}353
.mini {369
.mini {354
text-align: center;370
text-align: center;355
color: #c5cae0;371
color: #c5cae0;@@ -382,7 +398,17 @@ a.button:is(:hover, :focus-visible) {382
pointer-events: none;398
pointer-events: none;383
overflow: visible;399
overflow: visible;384
}400
}385
#flights .flight {401
/* Enemy-to-enemy arcs: above the starfield and minis, but the field402
rectangle is clipped out so they pass behind the player's field (t1125). */403
#flights-back {404
position: fixed;405
inset: 0;406
z-index: 5;407
pointer-events: none;408
overflow: visible;409
}410
#flights .flight,411
#flights-back .flight {386
position: fixed;412
position: fixed;387
top: 0;413
top: 0;388
left: 0;414
left: 0;@@ -278,13 +278,122 @@ function placeTile (obj, col, y)
278
278
obj.transform.size = { x: t, y: t };
279
279
}
280
280
281
function opponentCount ()
282
{
283
if (app.offline && app.battle && app.battle.bots)
284
{ return app.battle.bots.length; }
285
if (app.online && typeof Online !== 'undefined' && Online.opponents)
286
{ return Online.opponents().length; }
287
return 0;
288
}
289
290
function currentMiniSize ()
291
{
292
if (app.miniLayout && app.miniLayout.mini)
293
{ return { w: app.miniLayout.mini.w, h: app.miniLayout.mini.h }; }
294
var n = opponentCount();
295
var mode = (app.miniLayout && app.miniLayout.mode) || 'top';
296
if (typeof MiniLayout !== 'undefined' && MiniLayout.canvasSize)
297
{ return MiniLayout.canvasSize(n, mode, 0); }
298
if (n >= 10)
299
{ return { w: 40, h: 52 }; }
300
if (n >= 6)
301
{ return { w: 56, h: 73 }; }
302
return { w: 80, h: 104 };
303
}
304
305
function applyMinisContainer (plan)
306
{
307
var minis = document.getElementById('minis');
308
if (!minis)
309
{ return; }
310
var n = plan ? plan.n : 0;
311
minis.classList.toggle('crowded', n > 5);
312
if (!plan || n === 0 || plan.mode !== 'sides')
313
{
314
minis.classList.remove('sides');
315
minis.style.top = (app.hudH || 56) + 'px';
316
minis.style.maxHeight = (plan && plan.miniH ? plan.miniH : 0) + 'px';
317
minis.style.bottom = '';
318
minis.style.left = '';
319
minis.style.right = '';
320
var kids = minis.querySelectorAll('.mini');
321
for (var i = 0; i < kids.length; i++)
322
{
323
kids[i].style.left = '';
324
kids[i].style.top = '';
325
kids[i].style.width = '';
326
kids[i].style.position = '';
327
}
328
return;
329
}
330
minis.classList.add('sides');
331
minis.style.top = '0';
332
minis.style.bottom = '0';
333
minis.style.left = '0';
334
minis.style.right = '0';
335
minis.style.maxHeight = 'none';
336
}
337
338
function applyMinisLayout ()
339
{
340
var plan = app.miniLayout;
341
var minis = document.getElementById('minis');
342
if (!minis)
343
{ return; }
344
applyMinisContainer(plan);
345
if (!plan || plan.mode !== 'sides')
346
{ return; }
347
var positions = plan.positions || [];
348
var kids = minis.querySelectorAll('.mini');
349
for (var i = 0; i < positions.length && i < kids.length; i++)
350
{
351
var p = positions[i];
352
var el = kids[i];
353
el.style.position = 'absolute';
354
el.style.left = p.x + 'px';
355
el.style.top = p.y + 'px';
356
el.style.width = p.w + 'px';
357
var canvas = el.querySelector('canvas');
358
if (canvas)
359
{
360
canvas.style.width = p.canvasW + 'px';
361
canvas.style.height = p.canvasH + 'px';
362
}
363
}
364
}
365
366
function applyFlightsBackClip ()
367
{
368
var back = document.getElementById('flights-back');
369
if (!back)
370
{ return; }
371
var x = app.fieldX || 0;
372
var y = app.fieldY || 0;
373
var w = app.fieldW || 0;
374
var h = app.fieldH || 0;
375
if (!w || !h)
376
{
377
back.style.clipPath = '';
378
return;
379
}
380
// Even-odd polygon: full viewport with a hole over the player's field,
381
// so enemy-to-enemy arcs travel behind the field (t1125).
382
back.style.clipPath = 'polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, '
383
+ x + 'px ' + y + 'px, ' + (x + w) + 'px ' + y + 'px, '
384
+ (x + w) + 'px ' + (y + h) + 'px, ' + x + 'px ' + (y + h) + 'px, '
385
+ x + 'px ' + y + 'px)';
386
}
387
281
388
function layoutIfNeeded ()
282
389
{
283
390
if (app.core && app.core.drag)
284
391
{ return; }
285
392
var vw = window.innerWidth || 320;
286
393
var vh = window.innerHeight || 480;
287
if (app._layoutVw === vw && app._layoutVh === vh && app.scene && app.tile)
394
var n = (app.online || app.offline) ? opponentCount() : 0;
395
if (app._layoutVw === vw && app._layoutVh === vh && app._layoutN === n
396
&& app.scene && app.tile)
288
397
{ return; }
289
398
layout();
290
399
}
@@ -295,8 +404,10 @@ function layout ()
295
404
{ return; }
296
405
var vw = window.innerWidth || 320;
297
406
var vh = window.innerHeight || 480;
407
var n = (app.online || app.offline) ? opponentCount() : 0;
298
408
app._layoutVw = vw;
299
409
app._layoutVh = vh;
410
app._layoutN = n;
300
411
var safeTop = 0;
301
412
try
302
413
{
@@ -305,30 +416,34 @@ function layout ()
305
416
}
306
417
catch (e) { /* ignore */ }
307
418
app.hudH = Math.max(56, Math.round(vh * 0.09) + safeTop);
308
app.miniH = 0;
309
if (app.online || app.offline)
310
{
311
var nBots = (app.battle && app.battle.bots) ? app.battle.bots.length : 2;
312
var share = nBots > 6 ? 0.26 : 0.20;
313
app.miniH = Math.min(nBots > 6 ? 180 : 150, Math.max(86, Math.round(vh * share)));
314
}
315
419
var margin = Math.max(6, Math.round(Math.min(vw, vh) * 0.015));
316
var availW = Math.max(80, vw - margin * 2);
317
var availH = Math.max(80, vh - app.hudH - app.miniH - margin);
318
app.tile = Math.max(14, Math.floor(Math.min(availW / 10, availH / 13)));
319
app.fieldW = app.tile * 10;
320
app.fieldH = app.tile * 13;
321
app.fieldX = Math.floor((vw - app.fieldW) / 2);
322
var topBand = app.hudH + app.miniH;
323
app.fieldY = topBand + Math.floor((vh - topBand - app.fieldH - margin / 2) / 2);
324
if (app.fieldY < topBand)
325
{ app.fieldY = topBand; }
326
var minis = document.getElementById('minis');
327
if (minis)
420
var plan;
421
if (typeof MiniLayout !== 'undefined' && MiniLayout.plan)
422
{ plan = MiniLayout.plan(vw, vh, n, app.hudH, margin); }
423
else
328
424
{
329
minis.style.top = app.hudH + 'px';
330
minis.style.maxHeight = app.miniH + 'px';
425
plan = {
426
mode: 'top',
427
tile: 14,
428
fieldW: 140,
429
fieldH: 182,
430
fieldX: Math.floor((vw - 140) / 2),
431
fieldY: app.hudH,
432
miniH: n > 0 ? 100 : 0,
433
mini: { w: 80, h: 104 },
434
positions: [],
435
n: n
436
};
331
437
}
438
app.miniLayout = plan;
439
app.miniH = plan.miniH;
440
app.tile = plan.tile;
441
app.fieldW = plan.fieldW;
442
app.fieldH = plan.fieldH;
443
app.fieldX = plan.fieldX;
444
app.fieldY = plan.fieldY;
445
applyMinisLayout();
446
applyFlightsBackClip();
332
447
333
448
if (app.scene)
334
449
{
@@ -1164,6 +1279,7 @@ function tickOnline (dt)
1164
1279
}
1165
1280
Online.tickFlights();
1166
1281
Online.renderMinis(document.getElementById('minis'));
1282
applyMinisLayout();
1167
1283
}
1168
1284
1169
1285
@@ -1242,7 +1358,8 @@ function tickOffline (dt)
1242
1358
y: s.y,
1243
1359
color: s.color,
1244
1360
startX: start.x,
1245
startY: start.y
1361
startY: start.y,
1362
from_id: s.from_id
1246
1363
};
1247
1364
}
1248
1365
Online.spawnFlights(result.flights, locals);
@@ -1356,16 +1473,20 @@ function miniViewportCenter (botId)
1356
1473
if (!el)
1357
1474
{ return { x: window.innerWidth / 2, y: 40 }; }
1358
1475
var rect = el.getBoundingClientRect();
1476
var plan = app.miniLayout;
1477
if (plan && plan.mode === 'sides')
1478
{
1479
var mid = plan.fieldX + plan.fieldW / 2;
1480
if (rect.left + rect.width / 2 < mid)
1481
{ return { x: rect.right, y: rect.top + rect.height / 2 }; }
1482
return { x: rect.left, y: rect.top + rect.height / 2 };
1483
}
1359
1484
return { x: rect.left + rect.width / 2, y: rect.bottom };
1360
1485
}
1361
1486
1362
1487
function offlineMiniSize (n)
1363
1488
{
1364
if (n >= 10)
1365
{ return { w: 40, h: 52 }; }
1366
if (n >= 6)
1367
{ return { w: 56, h: 73 }; }
1368
return { w: 80, h: 104 };
1489
return currentMiniSize();
1369
1490
}
1370
1491
1371
1492
function updateOfflineMinis (dt, force)
@@ -1428,6 +1549,7 @@ function renderOfflineMinis ()
1428
1549
if (!seen[id])
1429
1550
{ existing[id].remove(); }
1430
1551
}
1552
applyMinisLayout();
1431
1553
}
1432
1554
1433
1555
function buildColumnWarn ()
@@ -278,13 +278,122 @@ function placeTile (obj, col, y)278
obj.transform.size = { x: t, y: t };278
obj.transform.size = { x: t, y: t };279
}279
}280
280
281
function opponentCount ()282
{283
if (app.offline && app.battle && app.battle.bots)284
{ return app.battle.bots.length; }285
if (app.online && typeof Online !== 'undefined' && Online.opponents)286
{ return Online.opponents().length; }287
return 0;288
}289
290
function currentMiniSize ()291
{292
if (app.miniLayout && app.miniLayout.mini)293
{ return { w: app.miniLayout.mini.w, h: app.miniLayout.mini.h }; }294
var n = opponentCount();295
var mode = (app.miniLayout && app.miniLayout.mode) || 'top';296
if (typeof MiniLayout !== 'undefined' && MiniLayout.canvasSize)297
{ return MiniLayout.canvasSize(n, mode, 0); }298
if (n >= 10)299
{ return { w: 40, h: 52 }; }300
if (n >= 6)301
{ return { w: 56, h: 73 }; }302
return { w: 80, h: 104 };303
}304
305
function applyMinisContainer (plan)306
{307
var minis = document.getElementById('minis');308
if (!minis)309
{ return; }310
var n = plan ? plan.n : 0;311
minis.classList.toggle('crowded', n > 5);312
if (!plan || n === 0 || plan.mode !== 'sides')313
{314
minis.classList.remove('sides');315
minis.style.top = (app.hudH || 56) + 'px';316
minis.style.maxHeight = (plan && plan.miniH ? plan.miniH : 0) + 'px';317
minis.style.bottom = '';318
minis.style.left = '';319
minis.style.right = '';320
var kids = minis.querySelectorAll('.mini');321
for (var i = 0; i < kids.length; i++)322
{323
kids[i].style.left = '';324
kids[i].style.top = '';325
kids[i].style.width = '';326
kids[i].style.position = '';327
}328
return;329
}330
minis.classList.add('sides');331
minis.style.top = '0';332
minis.style.bottom = '0';333
minis.style.left = '0';334
minis.style.right = '0';335
minis.style.maxHeight = 'none';336
}337
338
function applyMinisLayout ()339
{340
var plan = app.miniLayout;341
var minis = document.getElementById('minis');342
if (!minis)343
{ return; }344
applyMinisContainer(plan);345
if (!plan || plan.mode !== 'sides')346
{ return; }347
var positions = plan.positions || [];348
var kids = minis.querySelectorAll('.mini');349
for (var i = 0; i < positions.length && i < kids.length; i++)350
{351
var p = positions[i];352
var el = kids[i];353
el.style.position = 'absolute';354
el.style.left = p.x + 'px';355
el.style.top = p.y + 'px';356
el.style.width = p.w + 'px';357
var canvas = el.querySelector('canvas');358
if (canvas)359
{360
canvas.style.width = p.canvasW + 'px';361
canvas.style.height = p.canvasH + 'px';362
}363
}364
}365
366
function applyFlightsBackClip ()367
{368
var back = document.getElementById('flights-back');369
if (!back)370
{ return; }371
var x = app.fieldX || 0;372
var y = app.fieldY || 0;373
var w = app.fieldW || 0;374
var h = app.fieldH || 0;375
if (!w || !h)376
{377
back.style.clipPath = '';378
return;379
}380
// Even-odd polygon: full viewport with a hole over the player's field,381
// so enemy-to-enemy arcs travel behind the field (t1125).382
back.style.clipPath = 'polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, '383
+ x + 'px ' + y + 'px, ' + (x + w) + 'px ' + y + 'px, '384
+ (x + w) + 'px ' + (y + h) + 'px, ' + x + 'px ' + (y + h) + 'px, '385
+ x + 'px ' + y + 'px)';386
}387
281
function layoutIfNeeded ()388
function layoutIfNeeded ()282
{389
{283
if (app.core && app.core.drag)390
if (app.core && app.core.drag)284
{ return; }391
{ return; }285
var vw = window.innerWidth || 320;392
var vw = window.innerWidth || 320;286
var vh = window.innerHeight || 480;393
var vh = window.innerHeight || 480;287
if (app._layoutVw === vw && app._layoutVh === vh && app.scene && app.tile)394
var n = (app.online || app.offline) ? opponentCount() : 0;395
if (app._layoutVw === vw && app._layoutVh === vh && app._layoutN === n396
&& app.scene && app.tile)288
{ return; }397
{ return; }289
layout();398
layout();290
}399
}@@ -295,8 +404,10 @@ function layout ()295
{ return; }404
{ return; }296
var vw = window.innerWidth || 320;405
var vw = window.innerWidth || 320;297
var vh = window.innerHeight || 480;406
var vh = window.innerHeight || 480;407
var n = (app.online || app.offline) ? opponentCount() : 0;298
app._layoutVw = vw;408
app._layoutVw = vw;299
app._layoutVh = vh;409
app._layoutVh = vh;410
app._layoutN = n;300
var safeTop = 0;411
var safeTop = 0;301
try412
try302
{413
{@@ -305,30 +416,34 @@ function layout ()305
}416
}306
catch (e) { /* ignore */ }417
catch (e) { /* ignore */ }307
app.hudH = Math.max(56, Math.round(vh * 0.09) + safeTop);418
app.hudH = Math.max(56, Math.round(vh * 0.09) + safeTop);308
app.miniH = 0;309
if (app.online || app.offline)310
{311
var nBots = (app.battle && app.battle.bots) ? app.battle.bots.length : 2;312
var share = nBots > 6 ? 0.26 : 0.20;313
app.miniH = Math.min(nBots > 6 ? 180 : 150, Math.max(86, Math.round(vh * share)));314
}315
var margin = Math.max(6, Math.round(Math.min(vw, vh) * 0.015));419
var margin = Math.max(6, Math.round(Math.min(vw, vh) * 0.015));316
var availW = Math.max(80, vw - margin * 2);420
var plan;317
var availH = Math.max(80, vh - app.hudH - app.miniH - margin);421
if (typeof MiniLayout !== 'undefined' && MiniLayout.plan)318
app.tile = Math.max(14, Math.floor(Math.min(availW / 10, availH / 13)));422
{ plan = MiniLayout.plan(vw, vh, n, app.hudH, margin); }319
app.fieldW = app.tile * 10;423
else320
app.fieldH = app.tile * 13;321
app.fieldX = Math.floor((vw - app.fieldW) / 2);322
var topBand = app.hudH + app.miniH;323
app.fieldY = topBand + Math.floor((vh - topBand - app.fieldH - margin / 2) / 2);324
if (app.fieldY < topBand)325
{ app.fieldY = topBand; }326
var minis = document.getElementById('minis');327
if (minis)328
{424
{329
minis.style.top = app.hudH + 'px';425
plan = {330
minis.style.maxHeight = app.miniH + 'px';426
mode: 'top',427
tile: 14,428
fieldW: 140,429
fieldH: 182,430
fieldX: Math.floor((vw - 140) / 2),431
fieldY: app.hudH,432
miniH: n > 0 ? 100 : 0,433
mini: { w: 80, h: 104 },434
positions: [],435
n: n436
};331
}437
}438
app.miniLayout = plan;439
app.miniH = plan.miniH;440
app.tile = plan.tile;441
app.fieldW = plan.fieldW;442
app.fieldH = plan.fieldH;443
app.fieldX = plan.fieldX;444
app.fieldY = plan.fieldY;445
applyMinisLayout();446
applyFlightsBackClip();332
447
333
if (app.scene)448
if (app.scene)334
{449
{@@ -1164,6 +1279,7 @@ function tickOnline (dt)1164
}1279
}1165
Online.tickFlights();1280
Online.tickFlights();1166
Online.renderMinis(document.getElementById('minis'));1281
Online.renderMinis(document.getElementById('minis'));1282
applyMinisLayout();1167
}1283
}1168
1284
1169
1285
@@ -1242,7 +1358,8 @@ function tickOffline (dt)1242
y: s.y,1358
y: s.y,1243
color: s.color,1359
color: s.color,1244
startX: start.x,1360
startX: start.x,1245
startY: start.y1361
startY: start.y,1362
from_id: s.from_id1246
};1363
};1247
}1364
}1248
Online.spawnFlights(result.flights, locals);1365
Online.spawnFlights(result.flights, locals);@@ -1356,16 +1473,20 @@ function miniViewportCenter (botId)1356
if (!el)1473
if (!el)1357
{ return { x: window.innerWidth / 2, y: 40 }; }1474
{ return { x: window.innerWidth / 2, y: 40 }; }1358
var rect = el.getBoundingClientRect();1475
var rect = el.getBoundingClientRect();1476
var plan = app.miniLayout;1477
if (plan && plan.mode === 'sides')1478
{1479
var mid = plan.fieldX + plan.fieldW / 2;1480
if (rect.left + rect.width / 2 < mid)1481
{ return { x: rect.right, y: rect.top + rect.height / 2 }; }1482
return { x: rect.left, y: rect.top + rect.height / 2 };1483
}1359
return { x: rect.left + rect.width / 2, y: rect.bottom };1484
return { x: rect.left + rect.width / 2, y: rect.bottom };1360
}1485
}1361
1486
1362
function offlineMiniSize (n)1487
function offlineMiniSize (n)1363
{1488
{1364
if (n >= 10)1489
return currentMiniSize();1365
{ return { w: 40, h: 52 }; }1366
if (n >= 6)1367
{ return { w: 56, h: 73 }; }1368
return { w: 80, h: 104 };1369
}1490
}1370
1491
1371
function updateOfflineMinis (dt, force)1492
function updateOfflineMinis (dt, force)@@ -1428,6 +1549,7 @@ function renderOfflineMinis ()1428
if (!seen[id])1549
if (!seen[id])1429
{ existing[id].remove(); }1550
{ existing[id].remove(); }1430
}1551
}1552
applyMinisLayout();1431
}1553
}1432
1554
1433
function buildColumnWarn ()1555
function buildColumnWarn ()