mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Add game list manager
This commit is contained in:
parent
05ffd7c9e5
commit
8e01d5b96a
4 changed files with 46 additions and 18 deletions
|
@ -9,13 +9,7 @@ BaseGameTab::BaseGameTab(wxFrame *parent, std::string base_file, TabInfos *main_
|
||||||
: TabBase_TabGames(parent), base_file(base_file),
|
: TabBase_TabGames(parent), base_file(base_file),
|
||||||
base(NULL),main_tab(main_tab) {
|
base(NULL),main_tab(main_tab) {
|
||||||
|
|
||||||
game_list->InsertColumn(0, L"id", wxLIST_FORMAT_LEFT, 50);
|
glm=new GameListManager(game_list);
|
||||||
game_list->InsertColumn(1, L"White", wxLIST_FORMAT_LEFT, 200);
|
|
||||||
game_list->InsertColumn(2, L"Black", wxLIST_FORMAT_LEFT, 200);
|
|
||||||
game_list->InsertColumn(3, L"Event", wxLIST_FORMAT_LEFT, 150);
|
|
||||||
game_list->InsertColumn(4, L"Round", wxLIST_FORMAT_LEFT, 100);
|
|
||||||
game_list->InsertColumn(5, L"Result", wxLIST_FORMAT_LEFT, 200);
|
|
||||||
game_list->InsertColumn(6, L"ECO", wxLIST_FORMAT_LEFT, 200);
|
|
||||||
|
|
||||||
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnDelete, this, ID_DELETE_BUTTON);
|
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnDelete, this, ID_DELETE_BUTTON);
|
||||||
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnSave, this, ID_SAVE_BUTTON);
|
this->Bind(wxEVT_BUTTON, &BaseGameTab::OnSave, this, ID_SAVE_BUTTON);
|
||||||
|
@ -130,17 +124,14 @@ void BaseGameTab::LoadFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base != NULL) {
|
if (base != NULL) {
|
||||||
long id = 0;
|
|
||||||
while (base->NextGame()) {
|
while (base->NextGame()) {
|
||||||
long index =
|
glm->AddGame(
|
||||||
game_list->InsertItem(0, std::to_string(id)); // want this for col. 1
|
base->GetTag("White"),
|
||||||
game_list->SetItem(index, 1, base->GetTag("White"));
|
base->GetTag("Black"),
|
||||||
game_list->SetItem(index, 2, base->GetTag("Black"));
|
base->GetTag("Event"),
|
||||||
game_list->SetItem(index, 3, base->GetTag("Event"));
|
base->GetTag("Round"),
|
||||||
game_list->SetItem(index, 4, base->GetTag("Round"));
|
base->GetTag("Result"),
|
||||||
game_list->SetItem(index, 5, base->GetTag("Result"));
|
base->GetTag("ECO"));
|
||||||
game_list->SetItem(index, 6, base->GetTag("ECO"));
|
|
||||||
id++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
#include "gamebase/GameBase.hpp"
|
#include "gamebase/GameBase.hpp"
|
||||||
#include "gamebase/PGNGameBase.hpp"
|
#include "gamebase/PGNGameBase.hpp"
|
||||||
#include "ochess.hpp"
|
#include "GameListManager.hpp"
|
||||||
|
|
||||||
// Foreign events
|
// Foreign events
|
||||||
wxDECLARE_EVENT(OPEN_GAME_EVENT, wxCommandEvent);
|
wxDECLARE_EVENT(OPEN_GAME_EVENT, wxCommandEvent);
|
||||||
|
@ -14,9 +14,11 @@ class BaseGameTab : public TabBase_TabGames {
|
||||||
std::unordered_map<long, std::shared_ptr<Game>> edited;
|
std::unordered_map<long, std::shared_ptr<Game>> edited;
|
||||||
std::string base_file;
|
std::string base_file;
|
||||||
TabInfos *main_tab;
|
TabInfos *main_tab;
|
||||||
|
GameListManager *glm;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BaseGameTab(wxFrame *parent, std::string base_file, TabInfos *main_tab);
|
BaseGameTab(wxFrame *parent, std::string base_file, TabInfos *main_tab);
|
||||||
|
~BaseGameTab() {delete(glm);};
|
||||||
|
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
void LoadFile();
|
void LoadFile();
|
||||||
|
|
24
src/base_tab/GameListManager.cpp
Normal file
24
src/base_tab/GameListManager.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#include "GameListManager.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
GameListManager::GameListManager(wxListCtrl *game_list): game_list(game_list), game_counter(0) {
|
||||||
|
game_list->InsertColumn(0, L"Id", wxLIST_FORMAT_LEFT, 50);
|
||||||
|
game_list->InsertColumn(1, L"White", wxLIST_FORMAT_LEFT, 200);
|
||||||
|
game_list->InsertColumn(2, L"Black", wxLIST_FORMAT_LEFT, 200);
|
||||||
|
game_list->InsertColumn(3, L"Event", wxLIST_FORMAT_LEFT, 150);
|
||||||
|
game_list->InsertColumn(4, L"Round", wxLIST_FORMAT_LEFT, 100);
|
||||||
|
game_list->InsertColumn(5, L"Result", wxLIST_FORMAT_LEFT, 200);
|
||||||
|
game_list->InsertColumn(6, L"ECO", wxLIST_FORMAT_LEFT, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameListManager::AddGame(CType W,CType B,CType Evt,CType Rnd, CType Res, CType Eco){
|
||||||
|
long index =
|
||||||
|
game_list->InsertItem(0, std::to_string(game_counter)); // want this for col. 1
|
||||||
|
game_list->SetItem(index, 1, W);
|
||||||
|
game_list->SetItem(index, 2, B);
|
||||||
|
game_list->SetItem(index, 3, Evt);
|
||||||
|
game_list->SetItem(index, 4, Rnd);
|
||||||
|
game_list->SetItem(index, 5, Res);
|
||||||
|
game_list->SetItem(index, 6, Eco);
|
||||||
|
game_counter++;
|
||||||
|
}
|
11
src/base_tab/GameListManager.hpp
Normal file
11
src/base_tab/GameListManager.hpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include "ochess.hpp"
|
||||||
|
|
||||||
|
typedef std::string CType;
|
||||||
|
|
||||||
|
class GameListManager {
|
||||||
|
wxListCtrl *game_list;
|
||||||
|
long game_counter;
|
||||||
|
public:
|
||||||
|
GameListManager(wxListCtrl *game_list);
|
||||||
|
void AddGame(CType W,CType B,CType Evt,CType Rnd, CType Res, CType Eco);
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue