From 2045a1250a3ae04d7b9ea8e97317e62f55b69247 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Fri, 30 Dec 2022 15:58:13 +0100 Subject: Improve UI --- src/game_tab/GameTab.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/game_tab/GameTab.cpp') diff --git a/src/game_tab/GameTab.cpp b/src/game_tab/GameTab.cpp index 27f7638..a9a12da 100644 --- a/src/game_tab/GameTab.cpp +++ b/src/game_tab/GameTab.cpp @@ -26,6 +26,7 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr game) board_panel->Notify(false, false); editor_panel->Notify(); + board_panel->Bind(wxEVT_TOOL,&GameTab::OnToolClick,this); Bind(REFRESH_TAB_TITLE, &GameTab::OnRefreshTabTitle, this, wxID_ANY); Bind(GAME_CHANGE, &GameTab::OnGameChange, this, wxID_ANY); splitter->Bind(wxEVT_KEY_DOWN, [p=this,bp=board_panel,ed=editor_panel](wxKeyEvent &e){ @@ -46,6 +47,22 @@ GameTab::GameTab(wxFrame *parent, std::shared_ptr game) }); } +void GameTab::OnToolClick(wxCommandEvent &event){ + short id=event.GetId(); + if(id==0){ + if(!related_file.size()>0){ + wxFileDialog + newFileDialog(this, _("Save Game"), "", "", + "PGN files (*.pgn)|*.pgn", wxFD_SAVE|wxFD_OVERWRITE_PROMPT); + if (newFileDialog.ShowModal() == wxID_CANCEL) + return; + // Create and open new db + related_file = newFileDialog.GetPath().ToStdString(); + } + SaveGame(related_file,game); + } +} + void GameTab::OnGameChange(wxCommandEvent &event) { board_panel->Notify(false,false); editor_panel->Notify(); -- cgit v1.2.3