#pragma once
#ifdef DEBUG
#include "common/debuger.hpp"
#include "image/image.hpp"
#include "scene.hpp"
#include "scene-state.hpp"
//! сцена настроек отладчика
class Scene_debuger: public Scene {
public:
  explicit Scene_debuger(Scene* pv = nullptr): Scene(pv) {
    a83::log("goto scene DEBUGER");
    menu.add(new item_flag(U"hits = ", &debuger::status, DBG_HITS,
      []()->bool { debuger::status ^= DBG_HITS; return true; }));
    menu.add(new item_flag(U"pos = ", &debuger::status, DBG_POS,
      []()->bool { debuger::status ^= DBG_POS; return true; }));
    menu.add(new item_flag(U"godmod = ", &debuger::status, DBG_GODMOD,
      []()->bool {
        debuger::status ^= DBG_GODMOD;
        if (debuger::status & DBG_GODMOD)
          p_plr->flags |= (EF_NO_KILL | EF_NO_COLLIDE);
        else
          p_plr->flags &= ~(EF_NO_KILL | EF_NO_COLLIDE);
        return true;
      }));
    menu.add(new item_flag(U"no enemy = ", &debuger::status, DBG_NO_ENEMY,
      []()->bool { debuger::status ^= DBG_NO_ENEMY; return true; }));
    menu.init(5,20, 160,70, 5,5, 7);
  }
  ~Scene_debuger() { a83::log("exit from scene DEBUGER"); }
  void update(float dt) override {
    input();
    if (ifSelected) {
      menu.accept();
      ifSelected = false;
    }
    Scene::update(dt);
  }
  void draw() override { menu.print(Game::screen); }
private:
  nocopy(Scene_debuger);
  Menu menu = {};
  bool ifSelected = false; ///< if 1, item selected
  void input() {
    if (Game::menu_press(KEY_ESCAPE)
    or Game::menu_press(KEY_DEBUG))
      set_scene(scene_st::PREV);
    if (Game::menu_press(KEY_UP))
      menu.up();
    if (Game::menu_press(KEY_DOWN))
      menu.down();
    if (Game::menu_press(KEY_LEFT))
      menu.param_sub();
    if (Game::menu_press(KEY_RIGHT))
      menu.param_plus();
    if (Game::menu_press(KEY_ENABLE))
      ifSelected = true;
  } // input
}; // Scene_debuger
#endif