phone = !empty($params['phone']) || Platform::isPhoneApp(); $updater = $this->wz->updater; $this->updating = $updater !== null && $updater->enabled() && (bool)($this->wz->options['autoUpdate'] ?? true); if ($this->updating) { $updater->check(); } $this->wz->greet(); if (!($this->wz->options['splash'] ?? true)) { $this->scenes()->switchTo(self::main($this->wz), [], false); } } public function update(float $dt): void { parent::update($dt); $updater = $this->wz->updater; if ($this->updating && $updater !== null) { if ($updater->state === 'installed' && $updater->relaunch()) { // the new version is in place: it starts at once, this one ends $this->wz->save(); $this->engine->quit(); return; } // the check waits 5 seconds at most (no network: the player opens), a download as long as it takes (3 minutes at most) $waiting = ($updater->state === 'checking' && $this->time < 5) || ($updater->state === 'installing' && $this->time < 180); if ($waiting) { return; } } if ($this->time >= $this->seconds() || ($this->time > ($this->phone ? self::PHONE_SKIP : 0.3) && $this->anyInput())) { $this->scenes()->switchTo(self::main($this->wz)); } } /** How long the splash stays (seconds). */ public function seconds(): float { return $this->phone ? self::PHONE_SECONDS : self::SECONDS; } /** The splash is drawn on the whole screen of a phone, turned a quarter. */ public function phone(): bool { return $this->phone; } /** The line of the splash while the update is looked for / downloaded, '' otherwise. */ public function updateLine(): string { $u = $this->wz->updater; if (!$this->updating || $u === null) { return ''; } return match ($u->state) { 'checking' => "Recherche d'une mise à jour...", 'installing' => sprintf('Mise à jour vers WinZik %s : %d %%', $u->version, (int)round($u->progress * 100)), 'installed' => 'Redémarrage sur WinZik ' . $u->version . '...', default => '', }; } public function render(Renderer $r): void { if ($this->phone) { $this->renderPhone($r); return; } // Form15 (507 x 170 pixels): the picture alone; its light blue border was ANDed with the screen behind it // (BitBlt of the desktop, SRCAND): see-through, the wallpaper slightly tinted (on the teal desktop of Windows: the // desktop itself). So nothing is drawn around the picture, and the yellow line is written on it (Label1). $x = (FullScreen::W - self::PICTURE_W) / 2; $y = 160; $c = $this->canvas($r, '#008080', $this->wz->native !== null ? [$x, $y, (float)self::PICTURE_W, (float)self::PICTURE_H] : null); $this->drawPicture($c, $x, $y); } /** * The phone held upright: the picture is much wider than tall, so it is drawn turned a quarter (like the karaoke of * the original interface, Desktop::renderTurned()), as big as the screen's height allows: drawn in a texture as wide * as the screen is tall, then copied at 90° (its top on the right edge). The teal of the desktop of 2001 around it. */ private function renderPhone(Renderer $r): void { $r->clear('#008080'); $sdl = $this->sdl(); [$w, $h] = [$r->getWidth(), $r->getHeight()]; [$tw, $th] = $w <= $h ? [$h, $w] : [$w, $h]; // a screen already on its side: drawn as it is if ($this->turnedSize !== [$tw, $th] || !$sdl->hasTexture('winzik-splash-turned')) { if ($sdl->hasTexture('winzik-splash-turned')) { $sdl->releaseTexture('winzik-splash-turned'); } $sdl->createTexture('winzik-splash-turned', $tw, $th); $this->turnedSize = [$tw, $th]; } $texture = $sdl->getTexture('winzik-splash-turned')['texture']; [$ox, $oy] = $r->translation(); $before = $r->setTarget($texture); $r->translate(-$ox, -$oy); $r->clear('#008080'); $c = new Canvas($r, $sdl); $c->skin = $this->wz->skin; $c->scale = min($tw / self::PICTURE_W, $th / self::PICTURE_H); $c->at(($tw / $c->scale - self::PICTURE_W) / 2, ($th / $c->scale - self::PICTURE_H) / 2); $this->drawPicture($c, 0, 0); $r->translate($ox, $oy); $r->setTarget($before); $r->copy($texture, null, ($w - $tw) / 2, ($h - $th) / 2, $tw, $th, false, false, $w <= $h ? 90.0 : 0.0); } /** Form15's picture at (x, y) with its yellow lines: what is loaded (or the update), the version. */ private function drawPicture(Canvas $c, float $x, float $y): void { $c->file($this->engine->config->path('assets/images/winzik.png'), $x, $y, self::PICTURE_W, self::PICTURE_H); $seconds = $this->seconds(); $step = self::STEPS[min(count(self::STEPS) - 1, (int)($this->time / $seconds * count(self::STEPS)))]; if ($this->wz->firstStart && $step === 'Chargement de la configuration') { $step = "Premier démarage ; création d'un fichier CFG"; } $update = $this->updateLine(); if ($update !== '') { $step = $update; } if (($this->wz->options['splashSteps'] ?? true) || $update !== '') { $c->text($step, $x + 7, $y + 135, 10, '#ffff00'); // afc = 1: Form15.Label1 (Left 240, Top 2160 twips) } $c->text('v' . $this->wz->version(), $x + 482, $y + 135, 10, '#ffff00', 'right'); } }