wz; } public function enter(array $params = []): void { $this->wz->attach($this->engine); if (!empty($params['fresh'])) { $this->engine->storage->delete(WinZik::SETTINGS); $this->wz->reset(); } parent::enter($params); } protected function loaded(array $params = []): void { $view = $this->view; $view->wz = $this->wz; $view->open = function (string $what): void { match ($what) { 'about' => $this->scenes()->push(AboutScene::class), // the interface of 2001 (its skinned windows): MainForm stays in it while phoneUi is 'original' 'original' => $this->scenes()->switchTo(MainForm::class, [], false), default => null, }; }; if (!empty($params['phone'])) { $view->phone = is_array($params['phone']) ? array_map('floatval', array_values($params['phone'])) : [390.0, 844.0]; } $this->wz->ui['lyrics']['visible'] = false; $this->wz->greet(); $this->setFocus($view); if (isset($params['screen'])) { $view->go((string)$params['screen']); } if (isset($params['sheet'])) { $view->openSheet((string)$params['sheet']); } if (!empty($params['demo'])) { $this->wz->playIndex(0); } if (isset($params['play'])) { $this->wz->playIndex((int)$params['play']); } if (isset($params['seek'])) { $this->wz->seek((float)$params['seek']); } } public function resume(mixed $result = null): void { $this->setFocus($this->view); } protected function tick(float $dt): void { $player = $this->wz->player; $before = $player->state === Player::PLAYING && $player->file !== null ? ['file' => $player->file, 'line' => $this->wz->playlist->active, 'at' => $player->position, 'length' => $player->duration()] : null; $acted = $this->view->acted; $this->view->acted = false; $this->wz->tick($dt); // Répéter: the song that just ended by itself plays again (a song changed by the user is not) if ($before !== null && !$acted && $this->view->repeat() && $before['length'] > 0 && $before['at'] >= $before['length'] - 1.5 && ($player->file !== $before['file'] || $player->position < $before['at'] - 1)) { $line = $this->wz->playlist->items[$before['line']] ?? null; if ($line !== null && $this->wz->path($line) === $before['file']) { $this->wz->playIndex($before['line']); } } } public function exit(): void { $this->wz->save(); } }