mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Improve GUI and debug various classes
This commit is contained in:
parent
81d7a41962
commit
cd2c9e5b47
8 changed files with 66 additions and 109 deletions
|
@ -13,49 +13,34 @@ wxDEFINE_EVENT(REFRESH_ENGINE_LIST, wxCommandEvent);
|
|||
/// ---------- MainWindow ----------
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: wxFrame(NULL, wxID_ANY, "OChess: The Open Chess software",
|
||||
wxDefaultPosition, wxSize(1500, 1000)),
|
||||
: MainFrame(NULL, wxID_ANY, "OChess: The Open Chess software",
|
||||
wxDefaultPosition, wxSize(1500, 1000)),
|
||||
prefsEditor(NULL) {
|
||||
CreateStatusBar();
|
||||
SetStatusText("OChess");
|
||||
|
||||
/// File menu
|
||||
wxMenu *menuFile = new wxMenu;
|
||||
menuFile->Append(1, "Open", "Open file");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(10, "Save", "Save current game");
|
||||
menuFile->Append(11, "Save As", "Save current game as");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(4, "Settings", "Configure OChess");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(wxID_EXIT);
|
||||
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->AppendSeparator();
|
||||
menu_file->Append(wxID_EXIT);
|
||||
|
||||
// Game menu
|
||||
menuGame = new wxMenu;
|
||||
menuGame->Append(2, "New", "Create new game");
|
||||
menuGame->Append(3, "New from FEN", "Create new game using FEN");
|
||||
menu_game->Append(2, "New", "Create new game");
|
||||
menu_game->Append(3, "New from FEN", "Create new game using FEN");
|
||||
|
||||
// Game base menu
|
||||
wxMenu *menuBase = new wxMenu;
|
||||
menuBase->Append(5, "New", "Create new database");
|
||||
menu_db->Append(5, "New", "Create new database");
|
||||
|
||||
// Engine menu
|
||||
wxMenu *engineMenu = new wxMenu;
|
||||
engineMenu->Append(6, "New", "Create a new engine configuration");
|
||||
menu_engine->Append(6, "New", "Create a new engine configuration");
|
||||
manageMenu = new wxMenu;
|
||||
engineMenu->AppendSubMenu(manageMenu, "Manage");
|
||||
|
||||
/// Menu bar
|
||||
menuBar = new wxMenuBar;
|
||||
menuBar->Append(menuFile, "&File");
|
||||
menuBar->Append(menuGame, "&Game");
|
||||
menuBar->Append(menuBase, "&Database");
|
||||
menuBar->Append(engineMenu, "&Engines");
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
// Create the wxNotebook widget
|
||||
notebook = new wxAuiNotebook(this, wxID_ANY);
|
||||
NewGame(new Game());
|
||||
menu_engine->AppendSubMenu(manageMenu, "Manage");
|
||||
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
|
||||
OnRefreshEngineList(dummy);
|
||||
|
||||
Bind(wxEVT_AUINOTEBOOK_PAGE_CHANGED, &MainWindow::OnPageChange, this,
|
||||
wxID_ANY);
|
||||
|
@ -66,18 +51,8 @@ MainWindow::MainWindow()
|
|||
Bind(wxEVT_MENU, &MainWindow::OnMenuItemClick, this, wxID_ANY);
|
||||
Bind(REFRESH_ENGINE_LIST, &MainWindow::OnRefreshEngineList, this, wxID_ANY);
|
||||
|
||||
/*BaseTab *bt = new BaseTab((wxFrame *)notebook,
|
||||
"/home/loic/hartwig_tests.pgn"); notebook->AddPage(bt, bt->GetLabel());
|
||||
notebook->SetSelection(notebook->GetPageIndex(bt));*/
|
||||
/*
|
||||
EngineTab *bt =
|
||||
new EngineTab((wxWindow *)notebook,
|
||||
new uciadapter::UCI("/home/loic/.local/bin/stockfish"),
|
||||
"/home/loic/.local/bin/stockfish");
|
||||
notebook->AddPage(bt, bt->GetLabel());
|
||||
notebook->SetSelection(notebook->GetPageIndex(bt));*/
|
||||
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
|
||||
OnRefreshEngineList(dummy);
|
||||
// Add new game tab by default
|
||||
NewGame(new Game());
|
||||
}
|
||||
|
||||
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
||||
|
@ -108,6 +83,8 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
|
|||
NewGame(true);
|
||||
} else if (id == 4) {
|
||||
OpenSettings();
|
||||
} else if (id == 5) {
|
||||
OpenFile();
|
||||
} else if (id == 6) {
|
||||
NewEngine();
|
||||
}
|
||||
|
@ -222,8 +199,8 @@ void MainWindow::OnPageChange(wxAuiNotebookEvent &event) {
|
|||
TabInfos *infos = dynamic_cast<TabInfos *>(notebook->GetCurrentPage());
|
||||
if (infos->type != TabInfos::GAME) {
|
||||
for (short i = 10; i < 20; i++) {
|
||||
if (menuGame->FindChildItem(i) != NULL) {
|
||||
menuGame->Enable(i, false);
|
||||
if (menu_game->FindChildItem(i) != NULL) {
|
||||
menu_game->Enable(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue