Improve GUI and debug various classes

This commit is contained in:
Loic Guegan 2022-02-28 15:27:51 +01:00
parent 81d7a41962
commit cd2c9e5b47
8 changed files with 66 additions and 109 deletions

View file

@ -7,8 +7,7 @@ GameTab::GameTab(wxFrame *parent, Game *game)
: wxPanel(parent), game(game), TabInfos(TabInfos::GAME) {
// Splitter
wxSplitterWindow *splitter = new wxSplitterWindow(this, wxID_ANY);
splitter->SetMinimumPaneSize(100);
splitter->SetSashGravity(0.8);
// Panels
game->BuildAndVerify();
board_panel = new GameTabLeftPanel((wxFrame *)splitter, game);

View file

@ -13,13 +13,15 @@ GameTabLeftPanel::GameTabLeftPanel(wxFrame *parent, Game *game)
zoomin_button->SetBitmapLabel(LoadPNG("zoomin"));
zoomout_button->SetBitmapLabel(LoadPNG("zoomout"));
// Configure FEN field
fen_text_field->SetFont(wxFont(*wxSMALL_FONT).Bold());
Bind(PLAY_MOVE_EVENT, &GameTabLeftPanel::OnPlay, this, wxID_ANY);
Bind(PREVIOUS_MOVE_EVENT, &GameTabLeftPanel::OnPreviousMove, this, wxID_ANY);
Bind(NEXT_MOVE_EVENT, &GameTabLeftPanel::OnNextMove, this, wxID_ANY);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnSwap, this, SWAP_BTN);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomIn, this, ZOOM_IN_BTN);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnZoomOut, this, ZOOM_OUT_BTN);
Bind(wxEVT_BUTTON, &GameTabLeftPanel::OnCopyFEN, this, COPY_FEN_BTN);
}
void GameTabLeftPanel::OnPreviousMove(wxCommandEvent &event) {
@ -58,14 +60,6 @@ void GameTabLeftPanel::OnPlay(wxCommandEvent &event) {
Notify();
}
void GameTabLeftPanel::OnCopyFEN(wxCommandEvent &event) {
wxLogDebug("Clicked on copy fen");
if (wxTheClipboard->Open()) {
wxTheClipboard->SetData(new wxTextDataObject(game->GetFen()));
wxTheClipboard->Close();
}
}
void GameTabLeftPanel::Notify() {
std::string fen = game->GetFen();
std::map<char, std::uint8_t> captures;
@ -75,6 +69,7 @@ void GameTabLeftPanel::Notify() {
}
board_canvas->SetupBoard(chessarbiter::FENParser::Parse(fen).board,
game->IsBlackToPlay(), captures);
fen_text_field->SetValue(game->GetFen());
}
void GameTabLeftPanel::NotifyEditor() {

View file

@ -20,7 +20,6 @@ public:
void OnGotoMove(wxCommandEvent &event);
void OnPreviousMove(wxCommandEvent &event);
void OnNextMove(wxCommandEvent &event);
void OnCopyFEN(wxCommandEvent &event);
void OnZoomIn(wxCommandEvent &event);
void OnZoomOut(wxCommandEvent &event);
void OnSwap(wxCommandEvent &event);