aboutsummaryrefslogtreecommitdiff
path: root/src/MainWindow.cpp
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2022-12-28 07:21:30 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2022-12-28 07:21:30 +0100
commit214d46b8e26ae88b13f9a1a9083d36ce83671d46 (patch)
treeb6d9e4a4cbfc3d9b772367f987807fa7ebbd076b /src/MainWindow.cpp
parent4eeb110f807cd175fc778a5c19e9964589b4d885 (diff)
Improve user experience
Diffstat (limited to 'src/MainWindow.cpp')
-rw-r--r--src/MainWindow.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 6fb73c3..e5f11f9 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -21,25 +21,23 @@ MainWindow::MainWindow()
SetStatusText("OChess");
/// File menu
- menu_file->Append(1, "Open", "Open file");
- menu_file->AppendSeparator();
- menu_file->Append(10, "Save", "Save current game");
- menu_file->Append(11, "Save As", "Save current game as");
- menu_file->AppendSeparator();
- menu_file->Append(4, "Settings", "Configure OChess");
+ menu_file->Append(1, "Settings", "Configure OChess");
menu_file->AppendSeparator();
menu_file->Append(wxID_EXIT);
// Game menu
menu_game->Append(2, "New", "Create new game");
- menu_game->Append(3, "New from FEN", "Create new game using FEN");
+ menu_game->Append(3, "New from position", "Create new game using FEN");
+ menu_game->Append(4, "Open", "Open first game of a file");
// Game base menu
- menu_db->Append(7, "New", "Create database");
- menu_db->Append(5, "Open", "Open database");
+ menu_db->Append(5, "New", "Create database");
+ menu_db->Append(6, "Open", "Open database");
// Engine menu
- menu_engine->Append(6, "New", "Create a new engine configuration");
+ menu_engine->Append(7, "New", "Create a new engine configuration");
+ menu_engine->AppendSeparator();
+ // Dynamically build manage submenu
manageMenu = new wxMenu;
menu_engine->AppendSubMenu(manageMenu, "Manage");
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
@@ -58,6 +56,8 @@ MainWindow::MainWindow()
// Add new game tab by default
NewGame(std::shared_ptr<Game>(new Game()));
+
+
// Temporary TO REMOVE JUST FOR TESTS:
/*BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/pgn/Milov.pgn");
this->AddPage(bt,bt);
@@ -105,8 +105,7 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
std::uint32_t id = event.GetId();
if (id == wxID_EXIT) {
Close(true);
- } else if (id >= 100) {
- wxLogDebug("Engine selected!");
+ } else if (id >= 100) { // Engine from manage menu
wxMenuItemList items = manageMenu->GetMenuItems();
for (wxMenuItem *item : items) {
if (item->GetId() == id) {
@@ -117,19 +116,21 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
notebook->SetSelection(notebook->GetPageIndex(bt));
}
}
- } else if (id == 1) {
- OpenFile();
- } else if (id == 2) {
+ } else if (id == 1) { // Settings
+ OpenSettings();
+ } else if (id == 2) { // New game
NewGame(false);
- } else if (id == 3) {
+ } else if (id == 3) { // New game from FEN
NewGame(true);
- } else if (id == 4) {
- OpenSettings();
- } else if (id == 5) {
- OpenFile();
- } else if (id == 6) {
- NewEngine();
- } else if (id == 7) {
+ } else if (id == 4) { // Open first game
+ wxFileDialog openFileDialog(this, _("Open single game"), "", "",
+ "PGN files (*.pgn)|*.pgn",
+ wxFD_OPEN | wxFD_FILE_MUST_EXIST);
+ if (openFileDialog.ShowModal() != wxID_CANCEL) {
+ std::string path = openFileDialog.GetPath().ToStdString();
+ NewGame(OpenGameX(path,0));
+ }
+ } else if (id == 5) { // Create database
wxFileDialog
newFileDialog(this, _("Create database file"), "", "",
"PGN files (*.pgn)|*.pgn", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
@@ -139,6 +140,18 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
std::string path = newFileDialog.GetPath().ToStdString();
BaseTab *bt = new BaseTab((wxFrame *)notebook, path);
AddPage(bt,bt);
+ } else if (id == 6) { // Open Database
+ wxFileDialog openFileDialog(this, _("Open database"), "", "",
+ "PGN files (*.pgn)|*.pgn",
+ wxFD_OPEN | wxFD_FILE_MUST_EXIST);
+ if (openFileDialog.ShowModal() != wxID_CANCEL) {
+ std::string path = openFileDialog.GetPath().ToStdString();
+ // Test base tab
+ BaseTab *bt = new BaseTab((wxFrame *)notebook, path);
+ AddPage(bt,bt);
+ }
+ } else if (id == 7) { // Create new engine
+ NewEngine();
}
}
@@ -205,18 +218,6 @@ void MainWindow::OnClose(wxCloseEvent &e) {
}
-void MainWindow::OpenFile() {
- wxFileDialog openFileDialog(this, _("Open file"), "", "",
- "PGN files (*.pgn)|*.pgn",
- wxFD_OPEN | wxFD_FILE_MUST_EXIST);
- if (openFileDialog.ShowModal() != wxID_CANCEL) {
- std::string path = openFileDialog.GetPath().ToStdString();
- // Test base tab
- BaseTab *bt = new BaseTab((wxFrame *)notebook, path);
- AddPage(bt,bt);
- }
-}
-
void MainWindow::NewGame(bool useFen) {
if (useFen) {
wxTextEntryDialog *dial =