mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Cleaning code
This commit is contained in:
parent
d87b42dcd6
commit
32fdf9272e
6 changed files with 14 additions and 17 deletions
|
@ -48,7 +48,6 @@ MainWindow::MainWindow()
|
||||||
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
|
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
|
||||||
wxID_ANY);
|
wxID_ANY);
|
||||||
Bind(REFRESH_TAB_TITLE, &MainWindow::OnRefreshTabTitle, this, wxID_ANY);
|
Bind(REFRESH_TAB_TITLE, &MainWindow::OnRefreshTabTitle, this, wxID_ANY);
|
||||||
Bind(NEW_GAME_EVENT, &MainWindow::OnNewGame, this, wxID_ANY);
|
|
||||||
Bind(wxEVT_CLOSE_WINDOW, &MainWindow::OnClose, this);
|
Bind(wxEVT_CLOSE_WINDOW, &MainWindow::OnClose, this);
|
||||||
Bind(CLOSE_TAB_EVENT, &MainWindow::OnCloseTabEvent, this, wxID_ANY);
|
Bind(CLOSE_TAB_EVENT, &MainWindow::OnCloseTabEvent, this, wxID_ANY);
|
||||||
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
||||||
|
@ -234,12 +233,6 @@ void MainWindow::NewGame(bool useFen) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnNewGame(wxCommandEvent &event) {
|
|
||||||
TabInfos *tab = (TabInfos*)event.GetClientData();
|
|
||||||
TabInfos *i=NewGame(tab->GetGame());
|
|
||||||
i->Link(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
|
void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
|
||||||
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetCurrentPage());
|
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetCurrentPage());
|
||||||
if (infos->type != TabInfos::GAME) {
|
if (infos->type != TabInfos::GAME) {
|
||||||
|
|
|
@ -19,11 +19,9 @@ class MainWindow : public MainFrame {
|
||||||
|
|
||||||
void OnClose(wxCloseEvent &e);
|
void OnClose(wxCloseEvent &e);
|
||||||
void NewGame(bool useFen);
|
void NewGame(bool useFen);
|
||||||
void OnNewGame(wxCommandEvent &event);
|
|
||||||
void OpenFile();
|
void OpenFile();
|
||||||
void OnPageChange(wxAuiNotebookEvent &event);
|
void OnPageChange(wxAuiNotebookEvent &event);
|
||||||
void OnRefreshTabTitle(wxCommandEvent &event);
|
void OnRefreshTabTitle(wxCommandEvent &event);
|
||||||
TabInfos* NewGame(std::shared_ptr<Game> game);
|
|
||||||
void OpenSettings();
|
void OpenSettings();
|
||||||
void NewEngine();
|
void NewEngine();
|
||||||
void OnCloseTabEvent(wxCommandEvent &event);
|
void OnCloseTabEvent(wxCommandEvent &event);
|
||||||
|
@ -34,5 +32,6 @@ class MainWindow : public MainFrame {
|
||||||
void AddPage(wxWindow* window, TabInfos* infos);
|
void AddPage(wxWindow* window, TabInfos* infos);
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
|
TabInfos* NewGame(std::shared_ptr<Game> game);
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
};
|
};
|
|
@ -6,14 +6,17 @@ BaseGameTab::BaseGameTab(wxFrame *parent, std::shared_ptr<GameBase> base)
|
||||||
|
|
||||||
glm=std::make_shared<GameListManager>(game_list);
|
glm=std::make_shared<GameListManager>(game_list);
|
||||||
Reset(base);
|
Reset(base);
|
||||||
|
search_terms->SetHint("e.g: Paul Morphy");
|
||||||
|
|
||||||
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnDelete, this, ID_DELETE_BUTTON);
|
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnDelete, this, ID_DELETE_BUTTON);
|
||||||
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnApplyFilter, this, ID_APPLY_FILTER_BUTTON);
|
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnApplyFilter, this, ID_APPLY_FILTER_BUTTON);
|
||||||
this->Bind(wxEVT_TEXT_ENTER, &BaseGameTab::OnApplyFilter, this, ID_SEARCH_TERMS);
|
this->Bind(wxEVT_TEXT_ENTER, &BaseGameTab::OnApplyFilter, this, ID_SEARCH_TERMS);
|
||||||
|
this->Bind(wxEVT_LIST_COL_CLICK, [g=glm](wxListEvent& e){
|
||||||
search_terms->SetHint("e.g: Paul Morphy");
|
g->SortBy(e.GetColumn());
|
||||||
|
}, wxID_ANY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BaseGameTab::OnApplyFilter(wxCommandEvent &event){
|
void BaseGameTab::OnApplyFilter(wxCommandEvent &event){
|
||||||
wxString terms=search_terms->GetValue();
|
wxString terms=search_terms->GetValue();
|
||||||
if(terms.length()>0){
|
if(terms.length()>0){
|
||||||
|
|
|
@ -30,12 +30,7 @@ void BaseTab::OnOpenGame(wxListEvent &event){
|
||||||
std::shared_ptr<Game> g = games_tab->OpenGame(gameid,event.GetIndex());
|
std::shared_ptr<Game> g = games_tab->OpenGame(gameid,event.GetIndex());
|
||||||
if(g){
|
if(g){
|
||||||
game=g;
|
game=g;
|
||||||
// Ask MainFrame to open a new game
|
wxGetApp().NewGame(this,g);
|
||||||
// TODO: Simplify that is, use wxWidget main app to do it
|
|
||||||
wxCommandEvent newGameEvent(NEW_GAME_EVENT, GetId());
|
|
||||||
newGameEvent.SetEventObject(this);
|
|
||||||
newGameEvent.SetClientData((TabInfos*)this);
|
|
||||||
ProcessEvent(newGameEvent);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,12 @@ std::vector<TabInfos *> MyApp::ListTabInfos() {
|
||||||
return (tinfos);
|
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);
|
wxIMPLEMENT_APP(MyApp);
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ class MyApp : public wxApp {
|
||||||
public:
|
public:
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
std::vector<TabInfos *> ListTabInfos();
|
std::vector<TabInfos *> ListTabInfos();
|
||||||
|
void NewGame(TabInfos *tabsrc,std::shared_ptr<Game> g);
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDECLARE_APP(MyApp);
|
wxDECLARE_APP(MyApp);
|
||||||
|
|
Loading…
Add table
Reference in a new issue