mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Update db management
This commit is contained in:
parent
418b2e7f60
commit
d298c59206
5 changed files with 42 additions and 13 deletions
|
@ -9,6 +9,8 @@ wxDEFINE_EVENT(REFRESH_TAB_TITLE, wxCommandEvent);
|
|||
wxDEFINE_EVENT(NEW_GAME_EVENT, wxCommandEvent);
|
||||
wxDEFINE_EVENT(CLOSE_TAB_EVENT, wxCommandEvent);
|
||||
wxDEFINE_EVENT(REFRESH_ENGINE_LIST, wxCommandEvent);
|
||||
wxDEFINE_EVENT(CLOSE_LINKED_TAB, wxCommandEvent);
|
||||
|
||||
|
||||
/// ---------- MainWindow ----------
|
||||
|
||||
|
@ -50,6 +52,7 @@ MainWindow::MainWindow()
|
|||
Bind(CLOSE_TAB_EVENT, &MainWindow::OnCloseTabEvent, this, wxID_ANY);
|
||||
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
||||
Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY);
|
||||
Bind(CLOSE_LINKED_TAB, &MainWindow::OnCloseTabLinkedTo, this, wxID_ANY);
|
||||
|
||||
// Add new game tab by default
|
||||
NewGame(std::shared_ptr<Game>(new Game()));
|
||||
|
@ -69,6 +72,11 @@ void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
|||
notebook->DeletePage(notebook->GetSelection());
|
||||
}
|
||||
|
||||
void MainWindow::OnCloseTabLinkedTo(wxCommandEvent &event){
|
||||
TabInfos *infos=(TabInfos*)event.GetClientData();
|
||||
CloseTabLinkedTo(infos->id);
|
||||
}
|
||||
|
||||
void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
|
||||
std::uint32_t id = event.GetId();
|
||||
if (id == wxID_EXIT) {
|
||||
|
@ -132,8 +140,7 @@ void MainWindow::NewEngine() {
|
|||
try {
|
||||
engine = new uciadapter::UCI(path);
|
||||
EngineTab *bt = new EngineTab((wxWindow *)notebook, engine, path);
|
||||
notebook->AddPage(bt, bt->GetLabel());
|
||||
notebook->SetSelection(notebook->GetPageIndex(bt));
|
||||
AddPage(bt,bt);
|
||||
} catch (...) {
|
||||
SHOW_DIALOG_ERROR("Could not communicate with the engine");
|
||||
}
|
||||
|
@ -173,11 +180,16 @@ void MainWindow::OnClose(wxCloseEvent &e) {
|
|||
}
|
||||
|
||||
void MainWindow::CloseTabLinkedTo(long id){
|
||||
for(int i=0;i<notebook->GetPageCount();i++){
|
||||
int i=0;
|
||||
while(i<notebook->GetPageCount()){
|
||||
wxWindow *page=notebook->GetPage(i);
|
||||
TabInfos* infos=(TabInfos*)page->GetClientData();
|
||||
if(infos->is_linked && infos->linked_id==id){
|
||||
notebook->DeletePage(i);
|
||||
i=0; // Restart to page 0 since notebook updated
|
||||
}
|
||||
else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,8 +202,7 @@ void MainWindow::OpenFile() {
|
|||
std::string path = openFileDialog.GetPath().ToStdString();
|
||||
// Test base tab
|
||||
BaseTab *bt = new BaseTab((wxFrame *)notebook, path);
|
||||
notebook->AddPage(bt, bt->GetLabel());
|
||||
notebook->SetSelection(notebook->GetPageIndex(bt));
|
||||
AddPage(bt,bt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue