#include "LiveEngineDialog.hpp"

LiveEngineDialog::LiveEngineDialog(wxWindow *parent, std::string engine_name)
    : LiveEngineDialogFB(parent), engine_name(engine_name) {
  lines_list->InsertColumn(0, "#", wxLIST_FORMAT_LEFT, 50);
  lines_list->InsertColumn(1, "Moves", wxLIST_FORMAT_LEFT, 300);
  current_engine->SetLabel(engine_name);
  StartEngine();
  Bind(wxEVT_BUTTON, &LiveEngineDialog::TogglePauseEngine, this, LIVE_ENGINE_PAUSE_BUTTON);
}

void LiveEngineDialog::StartEngine() {
  timer.Start(1000);
  timer.Bind(wxEVT_TIMER, &LiveEngineDialog::OnTimerTick, this);
}

void LiveEngineDialog::TogglePauseEngine(wxCommandEvent &event) {
  if (timer.IsRunning()) {
    timer.Stop();
    engine_pause_button->SetLabel("Continue");
  } else {
    timer.Start(1000);
    engine_pause_button->SetLabel("Pause");
  }
}

void LiveEngineDialog::OnTimerTick(wxTimerEvent &event) { wxLogDebug("Tick!"); }