aboutsummaryrefslogtreecommitdiff
path: root/src/game_tab/GameTab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game_tab/GameTab.cpp')
-rw-r--r--src/game_tab/GameTab.cpp17
1 files changed, 17 insertions, 0 deletions
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> 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> 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();