fit($foot, 13, 856 - 2 * Canvas::PAD, 2); $lh = max(13.0, $c->minPx / max(0.01, $c->s), 13 * $c->boost); $footH = $lh * 1.15 * count($fit['lines']); $label = $touch ? 'Touche l\'écran pour commencer' : 'Entrée, Échap ou clic pour continuer'; $pw = min(856.0, max(300.0, $c->measure($label, 13) + 40)); $ph = max(22.0, $lh + 8); $bottom = max(686.0, 632 + $footH + 6 + $ph + 6); $c->rect(0, 0, Canvas::W, Canvas::H, [4, 8, 12, 170]); $c->panel(28, 34, 904, min(716.0, $bottom) - 34, 232, [255, 196, 80, 220]); $c->text('Commandes', 52, 48, 28, [255, 255, 255]); $c->text($first ? 'Rob Calder reprend conscience. Voici comment le guider — ce panneau revient avec H ou F1, et depuis la pause.' : 'Ce panneau s\'ouvre avec H ou F1, et depuis le menu de pause.', 52, 84, 14, [190, 204, 216]); $c->line(904, 52, 918, 66, [210, 220, 230], 2); $c->line(918, 52, 904, 66, [210, 220, 230], 2); $c->hit(892, 40, 36, 36, 'close'); $cols = [ ['CLAVIER ET SOURIS', self::KEYBOARD, 52.0, 330.0], ['MANETTE', self::PAD, 398.0, 250.0], ['ÉCRAN TACTILE', self::TOUCH, 664.0, 250.0], ]; if ($touch) { // on a phone (big text) only the touch controls, on the whole width: a keyboard is not there $cols = [['ÉCRAN TACTILE', self::TOUCH, 52.0, 852.0]]; } $row = max(26.0, $c->lineH(13, 1.0) + 8); foreach ($cols as [$title, $rows, $x, $w]) { $c->text($title, $x, 116, 13, [255, 204, 110]); $c->rect($x, 134, $w + 4, 1, [255, 255, 255, 40]); $y = 144.0; $wide = $title === 'CLAVIER ET SOURIS' || $touch; foreach ($rows as [$keys, $what]) { $kx = $x; foreach (explode(' / ', $keys) as $i => $k) { if ($i > 0) { $c->text('/', $kx + 2, $y + 4, 12, [130, 144, 158], 'left', false); $kx += 12; } $kx += self::cap($c, $kx, $y, $k) + 4; } $tx = (float) max((float) $x + ($wide ? 150.0 : 96.0), $kx + 6.0); $h = $c->textBox($what, $tx - Canvas::PAD, $y + 3, $x + $w - $tx + 2 * Canvas::PAD, 13, [226, 232, 238], 'left', 2, 1.15); $y += max($row, $h + 3); } } $c->rect(52, 626, 856, 1, [255, 255, 255, 40]); $c->textBox($foot, 48, 632, 864, 13, [170, 186, 200], 'left', 2, 1.15); $blink = 0.65 + 0.35 * sin($time * 4); $py = min(716.0, $bottom) - $ph - 6; $c->pill(480 - $pw / 2, $py, $pw, $ph, [255, 196, 80, (int) (200 * $blink)]); $c->text($label, 480, $py + ($ph - $lh) / 2, 13, [30, 24, 14], 'center', false); $c->hit(480 - $pw / 2, $py - 4, $pw, $ph + 8, 'close'); } /** A key cap; returns its width. */ public static function cap(Canvas $c, float $x, float $y, string $k): float { $w = max(22.0, $c->measure($k, 12) + 14); $h = max(20.0, $c->lineH(12, 1.0) + 4); $c->rect($x, $y + 2, $w, $h + 1, [0, 0, 0, 120]); $c->rect($x, $y, $w, $h, [226, 230, 236, 235]); $c->rect($x, $y, $w, 2, [255, 255, 255, 255]); $c->rect($x, $y + $h - 3, $w, 3, [170, 178, 188, 255]); $c->box($x, $y, $w, $h); $c->text($k, $x + $w / 2, $y + ($h - $c->lineH(12, 1.0)) / 2 + 1, 12, [20, 26, 34], 'center', false); return $w; } }