aboutsummaryrefslogtreecommitdiff
path: root/src/ochess.cpp
blob: e9dd94facaa9320d7cd8833a3cd267ac50c55dde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "ochess.hpp"
#include "MainWindow.hpp"
#include "base_tab/BaseTab.hpp"

bool MyApp::OnInit() {
  wxImage::AddHandler(new wxPNGHandler);

  MainWindow *frame = new MainWindow();
  frame->Show(true);
  return true;
}

std::vector<TabInfos *> MyApp::ListTabInfos() {
  std::vector<TabInfos *> tinfos;
  wxAuiNotebook *notebook=((MainWindow *)this->GetTopWindow())->notebook;
  for (int i = 0; i < notebook->GetPageCount(); i++) {
    tinfos.push_back(dynamic_cast<TabInfos *>(notebook->GetPage(i)));
  }
  return (tinfos);
}

void MyApp::NewGame(TabInfos *tabsrc,std::shared_ptr<Game> g){
  MainWindow *w=((MainWindow *)this->GetTopWindow());
  TabInfos *i=w->NewGame(g);
  i->Link(tabsrc); // Link opened game to tabsrc
}


wxIMPLEMENT_APP(MyApp);

void Abort(std::string msg) {
  wxMessageDialog *dial = new wxMessageDialog(NULL, wxString(msg), wxT("Error"),
                                              wxOK | wxICON_ERROR);
  dial->ShowModal();
  wxLogFatalError(wxString(msg));
}

long TabInfos::tab_count=0;
void TabInfos::Link(TabInfos *tab){
  this->is_linked=true;
  this->linked_id=tab->id;
}