#include "ochess.hpp" #include "MainWindow.hpp" #include "base_tab/BaseTab.hpp" bool MyApp::OnInit() { wxImage::AddHandler(new wxPNGHandler); // Check config version CONFIG_OPEN(conf); wxString version=conf->Read("version",CONFIG_VERSION); conf->Write("version",version); // Setup config file version wxLogDebug("Starting ochess with configuration file version %s",version); CONFIG_CLOSE(conf); // Advertise for configuration file version if(version != CONFIG_VERSION) SHOW_DIALOG_INFO("Configuration files version missmatch. Expected "+std::string(CONFIG_VERSION)+" but got "+version+".\nPlease remove the current configuration file as it may crash the application."); // Main frame MainWindow *frame = new MainWindow(); frame->Show(true); return true; } std::vector MyApp::ListTabInfos() { std::vector tinfos; wxAuiNotebook *notebook=((MainWindow *)this->GetTopWindow())->notebook; for (int i = 0; i < notebook->GetPageCount(); i++) { tinfos.push_back(dynamic_cast(notebook->GetPage(i))); } return (tinfos); } Openings& MyApp::GetBook() { return Book; } void MyApp::NewGame(TabInfos *tabsrc,std::shared_ptr g){ MainWindow *w=((MainWindow *)this->GetTopWindow()); TabInfos *i=w->NewGame(g); i->Link(tabsrc); // Link opened game to tabsrc } void MyApp::NewGame(std::shared_ptr g){ MainWindow *w=((MainWindow *)this->GetTopWindow()); w->NewGame(g); } 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; this->OnLink(); }