From 8629aa29aad5105298a6bde00682e84a3280e6c5 Mon Sep 17 00:00:00 2001
From: hwinter <hwinter@student.ethz.ch>
Date: Fri, 13 Dec 2024 17:03:15 +0100
Subject: [PATCH] buttons

---
 src/client/panels/MainGamePanelWizard.cpp  | 37 ++++++++++++++++------
 src/client/panels/MainGamePanelWizard.h    |  3 +-
 src/client/panels/TrickEstimationPanel.cpp | 25 +++++++++++++--
 src/client/panels/TrickEstimationPanel.h   |  2 +-
 4 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/src/client/panels/MainGamePanelWizard.cpp b/src/client/panels/MainGamePanelWizard.cpp
index 1e20c66..ced27ad 100644
--- a/src/client/panels/MainGamePanelWizard.cpp
+++ b/src/client/panels/MainGamePanelWizard.cpp
@@ -142,44 +142,63 @@ void MainGamePanelWizard::buildGameState(game_state* gameState, player* me)
     this->buildOtherPlayers(sizer, gameState, me, myPosition);
 
     // show button to display score board
-    this->buildScoreBoardButton(sizer, gameState);
+    this->buildScoreLeaveButtons(sizer, gameState);
 
     // show button to leave game
-    this->buildLeaveGameButton(sizer, gameState);
+    // this->buildLeaveGameButton(sizer, gameState);
 
     // update Layout
     this->Layout();
 }
 
-void MainGamePanelWizard::buildScoreBoardButton(wxGridBagSizer *sizer, game_state* gameState) {
+void MainGamePanelWizard::buildScoreLeaveButtons(wxGridBagSizer *sizer, game_state* gameState) {
     wxGBSizerItem* item = sizer->FindItemAtPosition(wxGBPosition(3,3));
     wxPanel* panel = dynamic_cast<wxPanel*>(item->GetWindow());
 
     if (gameState->is_started()) {
         wxBoxSizer *sizer_vert = new wxBoxSizer(wxVERTICAL);
         panel->SetSizer(sizer_vert);
+        auto sizer_hor = new wxBoxSizer(wxHORIZONTAL);
+        sizer_vert->Add(sizer_hor, 1, wxALIGN_LEFT);
 
         wxButton *scoreBoardButton = new wxButton(panel, wxID_ANY, "ScoreBoard");
-        sizer_vert->Add(scoreBoardButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+        scoreBoardButton->SetMinSize(wxSize(90, 35));
+        sizer_hor->Add(scoreBoardButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
+
+        scoreBoardButton->SetBackgroundColour(wxColour(50,0,51));  // Set background color to blue
+        scoreBoardButton->SetForegroundColour(*wxWHITE);
 
         scoreBoardButton->Bind(wxEVT_BUTTON, [gameState](wxCommandEvent &event) {
             ScoreBoardDialog scoreBoard(nullptr, "ScoreBoard", "Here will be the scoreboard", gameState);
             scoreBoard.ShowModal();
         });
+
+        wxButton *leaveGameButton = new wxButton(panel, wxID_ANY, "Leave Game");
+        leaveGameButton->SetMinSize(wxSize(90, 35));
+        sizer_hor->Add(leaveGameButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
+
+        leaveGameButton->SetBackgroundColour(wxColour(50,0,51));  // Set background color to blue
+        leaveGameButton->SetForegroundColour(*wxWHITE);
+
+        leaveGameButton->Bind(wxEVT_BUTTON, [gameState](wxCommandEvent &event) {
+            GameController::leaveGame();
+        });
     }
 
 }
 
+/*
 void MainGamePanelWizard::buildLeaveGameButton(wxGridBagSizer *sizer, game_state* gameState) {
-    wxGBSizerItem* item = sizer->FindItemAtPosition(wxGBPosition(3,4));
+    wxGBSizerItem* item = sizer->FindItemAtPosition(wxGBPosition(3,3));
     wxPanel* panel = dynamic_cast<wxPanel*>(item->GetWindow());
 
     if (gameState->is_started()) {
-        wxBoxSizer *sizer_vert = new wxBoxSizer(wxVERTICAL);
-        panel->SetSizer(sizer_vert);
+        wxSizer* sizer_vert = panel->GetSizer();
+        // wxBoxSizer *sizer_vert = new wxBoxSizer(wxVERTICAL);
+        // panel->SetSizer(sizer_vert);
 
         wxButton *leaveGameButton = new wxButton(panel, wxID_ANY, "Leave Game");
-        sizer_vert->Add(leaveGameButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+        sizer_vert->Add(leaveGameButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 1);
 
         leaveGameButton->Bind(wxEVT_BUTTON, [gameState](wxCommandEvent &event) {
             GameController::leaveGame();
@@ -187,7 +206,7 @@ void MainGamePanelWizard::buildLeaveGameButton(wxGridBagSizer *sizer, game_state
     }
 
 }
-
+*/
 void MainGamePanelWizard::buildOtherPlayers(wxGridBagSizer* sizer, game_state* gameState, player* me, int myPosition)
 {
     std::vector<player*> players = gameState->get_players();
diff --git a/src/client/panels/MainGamePanelWizard.h b/src/client/panels/MainGamePanelWizard.h
index 2950112..01831b0 100644
--- a/src/client/panels/MainGamePanelWizard.h
+++ b/src/client/panels/MainGamePanelWizard.h
@@ -20,8 +20,7 @@ private:
     void buildTrickPile(wxGridBagSizer* sizer, game_state* gameState, player *me);
     void buildTrumpCard(wxGridBagSizer* sizer, game_state* gameState);
 
-    void buildScoreBoardButton(wxGridBagSizer* sizer, game_state* gameState);
-    void buildLeaveGameButton(wxGridBagSizer *sizer, game_state* gameState);
+    void buildScoreLeaveButtons(wxGridBagSizer* sizer, game_state* gameState);
 
     wxSize const panelSize = wxSize(960, 680); // also set in the constructor implementation
     wxSize const cardSize = wxSize(70, 108);
diff --git a/src/client/panels/TrickEstimationPanel.cpp b/src/client/panels/TrickEstimationPanel.cpp
index 34cb20d..277d4d2 100644
--- a/src/client/panels/TrickEstimationPanel.cpp
+++ b/src/client/panels/TrickEstimationPanel.cpp
@@ -100,27 +100,46 @@ void TrickEstimationPanel::buildGameState(game_state* gameState, player* me)
 
     this->buildTrumpColor(sizer, gameState);
 
-    this->buildScoreBoardButton(sizer, gameState);
+    this->buildScoreLeaveButtons(sizer, gameState);
 
     this->Layout();
 }
 
 
-void TrickEstimationPanel::buildScoreBoardButton(wxGridBagSizer *sizer, game_state* gameState) {
+void TrickEstimationPanel::buildScoreLeaveButtons(wxGridBagSizer *sizer, game_state* gameState) {
     wxGBSizerItem* item = sizer->FindItemAtPosition(wxGBPosition(2,2));
     wxPanel* panel = dynamic_cast<wxPanel*>(item->GetWindow());
 
     wxBoxSizer* sizer_vert = new wxBoxSizer(wxVERTICAL);
     panel->SetSizer(sizer_vert);
+    auto sizer_hor = new wxBoxSizer(wxHORIZONTAL);
+    sizer_vert->Add(sizer_hor, 1, wxALIGN_CENTER);
 
     wxButton* scoreBoardButton = new wxButton(panel, wxID_ANY, "ScoreBoard");
-    sizer_vert->Add(scoreBoardButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+    scoreBoardButton->SetMinSize(wxSize(90, 35));
+
+    scoreBoardButton->SetBackgroundColour(wxColour(50,0,51));  // Set background color to blue
+    scoreBoardButton->SetForegroundColour(*wxWHITE);
+
+
+    sizer_hor->Add(scoreBoardButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
 
     scoreBoardButton->Bind(wxEVT_BUTTON, [gameState](wxCommandEvent& event) {
         ScoreBoardDialog scoreBoard(nullptr, "ScoreBoard", "Here will be the scoreboard", gameState);
         scoreBoard.ShowModal();
     });
 
+    wxButton *leaveGameButton = new wxButton(panel, wxID_ANY, "Leave Game");
+    leaveGameButton->SetMinSize(wxSize(90, 35));
+    sizer_hor->Add(leaveGameButton, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 3);
+
+    leaveGameButton->SetBackgroundColour(wxColour(50,0,51));  // Set background color to blue
+    leaveGameButton->SetForegroundColour(*wxWHITE);
+
+    leaveGameButton->Bind(wxEVT_BUTTON, [gameState](wxCommandEvent &event) {
+        GameController::leaveGame();
+    });
+
 }
 
 
diff --git a/src/client/panels/TrickEstimationPanel.h b/src/client/panels/TrickEstimationPanel.h
index f8d9ef6..bd42b4f 100644
--- a/src/client/panels/TrickEstimationPanel.h
+++ b/src/client/panels/TrickEstimationPanel.h
@@ -27,7 +27,7 @@ private:
     void buildThisPlayer(wxGridBagSizer* sizer, game_state* gameState, player* me);
     void buildOtherPlayers(wxGridBagSizer* sizer, game_state* gameState, int myPosition);
 
-    void buildScoreBoardButton(wxGridBagSizer* sizer, game_state* gameState);
+    void buildScoreLeaveButtons(wxGridBagSizer* sizer, game_state* gameState);
 
     InputField* _trickEstimateField;
 };
-- 
GitLab