#pragma once
#include "scene.hpp"
#include "UI/menu.hpp"
#include "level/level.hpp"
//! сцена проигрыша с 29 вариантами выхода
class Scene_gameover: public Scene {
protected:
  Menu menu = {};
  bool ifSelected = false; ///< if 1, item selected
public:
  explicit Scene_gameover(Scene *pv = nullptr): Scene(pv) {
    a83::log("goto scene GAME_OVER");
    // TODO locale
    menu.add(new item_text(U"Continue", []()->bool {
      set_scene(scene_st::PREV);
      return false; }));
    menu.add(new item_text(U"Exit", []()->bool {
      set_scene(scene_st::PREVx2);
      return false; }));
    menu.init(120,100, 58,30, 0,0, 9);
  }
  ~Scene_gameover() { a83::log("exit from scene GAME_OVER"); }
  void update(float dt) override {
    input();
    if (ifSelected) {
      menu.accept();
      ifSelected = false;
      //p_player->score = 0; // TODO
    }
    Scene::update(dt);
  }
  void draw() override {
    Game::screen.fill(Color::BLACK);
    menu.print(Game::screen);
    Game::font->print(Game::screen, 120,72, U"GAME OVER", false, 0,0,
      &Image::print_diff);
    /*Game::font.print_diff(Game::screen, 120,85, "SCORE: "
      + a83::n2s(p_player->score)); TODO*/
  }
private:
  nocopy(Scene_gameover);
  void input() {
    if (Game::menu_press(KEY_UP)) menu.up();
    if (Game::menu_press(KEY_DOWN)) menu.down();
    if (Game::menu_press(KEY_ENABLE)) ifSelected = true;
  }
};