#include "cardslot.h"
#include "menu.h"
#include "pixelstream.h"

using namespace menus;

CardMenu::CardMenu(lib::Display& display, lib::Flash& flash, uint16_t card) :
  Menu(display, flash),
  card(card)
{
  draw();
}

void CardMenu::onTick(float dt) {}
void CardMenu::onResume() { draw(); }

void CardMenu::onLeftPressed() {}
void CardMenu::onLeftHeld() {}

void CardMenu::onMenuPressed() { pop_menu(3); }
void CardMenu::onMenuHeld() {}

void CardMenu::onRightPressed() {}
void CardMenu::onRightHeld() {}

void CardMenu::draw()
{
  CardSlot slot(*flash, card);
  display->set_update_area(0, 0, 240, 320);
  auto pixels = display->pixels();

  for (int i = 0; i < CardSlot::IMAGE_PAGE_COUNT; i++)
  {
    flash->read_page(i + slot.get_image_start_page_index());
    pixels.write(flash->page(), lib::Flash::Page::SIZE);
  }
}
