#pragma once
#include "menu.hpp"
//! как bool, только с отдельными битами
class item_flag: public MenuItem {
protected:
  utf32 str = {};
  uint* pVal = nullptr;
  uint flag = 0;
  void_callback pFunc = nullptr;
public:
  nocopy(item_flag);
  explicit item_flag(CN(utf32) s, uint* p, uint _flag,
  void_callback f = nullptr): str(s), pVal(p), flag(_flag), pFunc(f)
    { IFERROR(!p, "menu item add: num pointer is null"); }
  void print(Font* pFont, Image& dst, int XPos = 0, int YPos = 0) const override
    { pFont->print(dst, XPos, YPos, str + yn2s<utf32>(*pVal & flag)); }
  bool accept() override {
    if (pFunc)
      return pFunc();
    return true;
  }
  void plus() override { accept(); }
  void sub() override { accept(); }
};