2022-12-25 15:26:16 +01:00
|
|
|
#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);
|
|
|
|
}
|
|
|
|
|
2022-12-25 16:29:17 +01:00
|
|
|
void GameListManager::AddGame(CType White,CType Black,CType Event,CType Round, CType Result, CType Eco){
|
|
|
|
// Update rows elements
|
|
|
|
rows.push_back({White,Black,Event,Round,Result,Eco});
|
|
|
|
// Display the row
|
|
|
|
DisplayRow(game_counter);
|
2022-12-25 15:26:16 +01:00
|
|
|
game_counter++;
|
|
|
|
}
|
2022-12-25 15:51:00 +01:00
|
|
|
|
2022-12-25 16:29:17 +01:00
|
|
|
void GameListManager::DisplayRow(long id){
|
|
|
|
RType row=rows[id];
|
|
|
|
long index =
|
|
|
|
game_list->InsertItem(game_counter, std::to_string(id)); // want this for col. 1
|
|
|
|
game_list->SetItem(index, 1, row.White);
|
|
|
|
game_list->SetItem(index, 2, row.Black);
|
|
|
|
game_list->SetItem(index, 3, row.Event);
|
|
|
|
game_list->SetItem(index, 4, row.Round);
|
|
|
|
game_list->SetItem(index, 5, row.Result);
|
|
|
|
game_list->SetItem(index, 6, row.Eco);
|
|
|
|
}
|
|
|
|
|
2022-12-25 15:51:00 +01:00
|
|
|
void GameListManager::Clear(){
|
|
|
|
game_list->DeleteAllItems();
|
2022-12-25 16:39:54 +01:00
|
|
|
rows.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameListManager::ClearDisplayedRow(){
|
|
|
|
game_list->DeleteAllItems();
|
2022-12-25 15:51:00 +01:00
|
|
|
}
|