ochess/src/ochess.cpp

49 lines
1.2 KiB
C++
Raw Normal View History

2022-02-23 18:11:55 +01:00
#include "ochess.hpp"
#include "MainWindow.hpp"
2022-12-26 16:23:14 +01:00
#include "base_tab/BaseTab.hpp"
2022-02-23 18:11:55 +01:00
bool MyApp::OnInit() {
wxImage::AddHandler(new wxPNGHandler);
MainWindow *frame = new MainWindow();
frame->Show(true);
return true;
}
2022-12-25 11:13:05 +01:00
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);
}
2022-12-27 18:33:21 +01:00
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
}
2022-12-30 16:24:44 +01:00
void MyApp::NewGame(std::shared_ptr<Game> g){
MainWindow *w=((MainWindow *)this->GetTopWindow());
w->NewGame(g);
}
2022-12-26 16:23:14 +01:00
2022-02-23 18:11:55 +01:00
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));
}
2022-12-24 10:26:05 +01:00
long TabInfos::tab_count=0;
void TabInfos::Link(TabInfos *tab){
this->is_linked=true;
this->linked_id=tab->id;
2022-12-30 15:58:13 +01:00
this->OnLink();
2022-12-24 10:26:05 +01:00
}