mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Now engine list in game tab is updated properly
This commit is contained in:
parent
6c34ef20fb
commit
711fce41c7
4 changed files with 21 additions and 13 deletions
|
@ -44,8 +44,6 @@ MainWindow::MainWindow()
|
||||||
engineMenu->Append(6, "New", "Create a new engine configuration");
|
engineMenu->Append(6, "New", "Create a new engine configuration");
|
||||||
manageMenu = new wxMenu;
|
manageMenu = new wxMenu;
|
||||||
engineMenu->AppendSubMenu(manageMenu, "Manage");
|
engineMenu->AppendSubMenu(manageMenu, "Manage");
|
||||||
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
|
|
||||||
OnRefreshEngineList(dummy);
|
|
||||||
|
|
||||||
/// Menu bar
|
/// Menu bar
|
||||||
menuBar = new wxMenuBar;
|
menuBar = new wxMenuBar;
|
||||||
|
@ -78,6 +76,8 @@ MainWindow::MainWindow()
|
||||||
"/home/loic/.local/bin/stockfish");
|
"/home/loic/.local/bin/stockfish");
|
||||||
notebook->AddPage(bt, bt->GetLabel());
|
notebook->AddPage(bt, bt->GetLabel());
|
||||||
notebook->SetSelection(notebook->GetPageIndex(bt));*/
|
notebook->SetSelection(notebook->GetPageIndex(bt));*/
|
||||||
|
wxCommandEvent dummy(REFRESH_ENGINE_LIST, GetId());
|
||||||
|
OnRefreshEngineList(dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
||||||
|
@ -131,8 +131,8 @@ void MainWindow::OnRefreshEngineList(wxCommandEvent &event) {
|
||||||
id++;
|
id++;
|
||||||
} while (conf->GetNextGroup(engine_name, index));
|
} while (conf->GetNextGroup(engine_name, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIG_CLOSE(conf);
|
CONFIG_CLOSE(conf);
|
||||||
|
ApplyPreferences(); // Propagate motifications
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::NewEngine() {
|
void MainWindow::NewEngine() {
|
||||||
|
|
|
@ -50,4 +50,5 @@ void GameTab::OnRefreshTabTitle(wxCommandEvent &event) {
|
||||||
|
|
||||||
void GameTab::ApplyPreferences() {
|
void GameTab::ApplyPreferences() {
|
||||||
board_panel->ApplyPreferences();
|
board_panel->ApplyPreferences();
|
||||||
|
editor_panel->ApplyPreferences();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,17 +15,7 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game)
|
||||||
tags_list->InsertColumn(1, L"Value", wxLIST_FORMAT_LEFT, 500);
|
tags_list->InsertColumn(1, L"Value", wxLIST_FORMAT_LEFT, 500);
|
||||||
tagTextCtrl->SetHint("Tag");
|
tagTextCtrl->SetHint("Tag");
|
||||||
valueTextCtrl->SetHint("Value");
|
valueTextCtrl->SetHint("Value");
|
||||||
CONFIG_OPEN(conf);
|
|
||||||
conf->SetPath("engines/");
|
|
||||||
wxString engine_name;
|
|
||||||
long index;
|
|
||||||
if (conf->GetFirstGroup(engine_name, index)) {
|
|
||||||
do {
|
|
||||||
engine_list->Append(engine_name);
|
|
||||||
} while (conf->GetNextGroup(engine_name, index));
|
|
||||||
}
|
|
||||||
|
|
||||||
CONFIG_CLOSE(conf);
|
|
||||||
RefreshTagsList();
|
RefreshTagsList();
|
||||||
|
|
||||||
// Bind events
|
// Bind events
|
||||||
|
@ -44,6 +34,7 @@ EditorPanel::EditorPanel(wxFrame *parent, Game *game)
|
||||||
wxID_ANY);
|
wxID_ANY);
|
||||||
this->Bind(wxEVT_BUTTON, &EditorPanel::OnApply, this, UPDATE_BTN);
|
this->Bind(wxEVT_BUTTON, &EditorPanel::OnApply, this, UPDATE_BTN);
|
||||||
this->Bind(wxEVT_BUTTON, &EditorPanel::OnDelete, this, DELETE_BTN);
|
this->Bind(wxEVT_BUTTON, &EditorPanel::OnDelete, this, DELETE_BTN);
|
||||||
|
ApplyPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorPanel::OnTagSelected(wxListEvent &event) {
|
void EditorPanel::OnTagSelected(wxListEvent &event) {
|
||||||
|
@ -146,6 +137,21 @@ void EditorPanel::Notify() {
|
||||||
editor_canvas->SetMoves(game->GetMoves(), m);
|
editor_canvas->SetMoves(game->GetMoves(), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorPanel::ApplyPreferences() {
|
||||||
|
engine_list->Clear();
|
||||||
|
CONFIG_OPEN(conf);
|
||||||
|
conf->SetPath("engines/");
|
||||||
|
wxString engine_name;
|
||||||
|
long index;
|
||||||
|
if (conf->GetFirstGroup(engine_name, index)) {
|
||||||
|
do {
|
||||||
|
engine_list->Append(engine_name);
|
||||||
|
} while (conf->GetNextGroup(engine_name, index));
|
||||||
|
}
|
||||||
|
|
||||||
|
CONFIG_CLOSE(conf);
|
||||||
|
}
|
||||||
|
|
||||||
void EditorPanel::RefreshTagsList() {
|
void EditorPanel::RefreshTagsList() {
|
||||||
tags_list->DeleteAllItems();
|
tags_list->DeleteAllItems();
|
||||||
for (std::string s : game->ListTags()) {
|
for (std::string s : game->ListTags()) {
|
||||||
|
|
|
@ -36,4 +36,5 @@ public:
|
||||||
void OnDelete(wxCommandEvent &event);
|
void OnDelete(wxCommandEvent &event);
|
||||||
void OnPreviousMove(wxCommandEvent &event);
|
void OnPreviousMove(wxCommandEvent &event);
|
||||||
void OnNextMove(wxCommandEvent &event);
|
void OnNextMove(wxCommandEvent &event);
|
||||||
|
void ApplyPreferences();
|
||||||
};
|
};
|
Loading…
Add table
Reference in a new issue