diff --git a/assets/Wiz.png b/assets/Wiz.png new file mode 100644 index 0000000000000000000000000000000000000000..e7178b418e824031973480a86d4d9eaea3cfa451 Binary files /dev/null and b/assets/Wiz.png differ diff --git a/assets/Wizard_big.png b/assets/Wizard_big.png new file mode 100644 index 0000000000000000000000000000000000000000..fa80da4f29adb57d4584d37f2bbe2a8747675b95 Binary files /dev/null and b/assets/Wizard_big.png differ diff --git a/assets/Wizard_round.png b/assets/Wizard_round.png new file mode 100644 index 0000000000000000000000000000000000000000..cab3a4cdc1ee4b867eaa04d2f7721f4a24b092b4 Binary files /dev/null and b/assets/Wizard_round.png differ diff --git a/sockpp/.idea/misc.xml b/sockpp/.idea/misc.xml index 7c97963d2d1a016ddd8c06b1c90e8fabc2eb002d..e1cf7631feaa774ad45c8353b06dcf2280910a18 100644 --- a/sockpp/.idea/misc.xml +++ b/sockpp/.idea/misc.xml @@ -1,5 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="BackendCodeEditorMiscSettings"> + <option name="/Default/RiderDebugger/RiderRestoreDecompile/RestoreDecompileSetting/@EntryValue" value="false" type="bool" /> + <option name="/Default/Housekeeping/GlobalSettingsUpgraded/IsUpgraded/@EntryValue" value="true" type="bool" /> + <option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexedValue" value="true" type="bool" /> + <option name="/Default/Housekeeping/FeatureSuggestion/FeatureSuggestionManager/DisabledSuggesters/=SwitchToGoToActionSuggester/@EntryIndexRemoved" /> + <option name="/Default/Environment/Hierarchy/GeneratedFilesCacheKey/Timestamp/@EntryValue" value="3" type="long" /> + </component> <component name="CMakePythonSetting"> <option name="pythonIntegrationState" value="YES" /> </component> diff --git a/src/client/panels/ConnectionPanel.cpp b/src/client/panels/ConnectionPanel.cpp index 45ac101800d83bb32636b363aacc2c25c844d54b..0a1a16c13499acf5320a7c2254d04a689869c24a 100644 --- a/src/client/panels/ConnectionPanel.cpp +++ b/src/client/panels/ConnectionPanel.cpp @@ -1,68 +1,102 @@ #include "ConnectionPanel.h" - +#include <wx/image.h> #include "../uiElements/ImagePanel.h" -#include "../../common/network/default.conf" #include "../GameController.h" - +#include <wx/dcbuffer.h> ConnectionPanel::ConnectionPanel(wxWindow* parent) : wxPanel(parent, wxID_ANY) { - wxColor white = wxColor(255, 255, 255); - this->SetBackgroundColour(white); + // Load the background image + _backgroundImage.LoadFile("./assets/Wizard_big.png", wxBITMAP_TYPE_ANY); + // Set background paint style and bind paint/resize events + this->SetBackgroundStyle(wxBG_STYLE_PAINT); + this->Bind(wxEVT_PAINT, &ConnectionPanel::OnPaint, this); + this->Bind(wxEVT_SIZE, &ConnectionPanel::OnSize, this); + + // Main vertical layout for input fields and button wxBoxSizer* verticalLayout = new wxBoxSizer(wxVERTICAL); - ImagePanel* logo = new ImagePanel(this, "assets/wizard_logo.png", wxBITMAP_TYPE_ANY, wxDefaultPosition, wxSize(200, 250)); - verticalLayout->Add(logo, 0, wxALIGN_CENTER | wxTOP | wxLEFT | wxRIGHT, 10); - - this->_serverAddressField = new InputField( - this, // parent element - "Server address:", // label - 100, // width of label - default_server_host, // default value (variable from "default.conf") - 240 // width of field - ); - verticalLayout->Add(this->_serverAddressField, 0, wxTOP | wxLEFT | wxRIGHT, 10); - - this->_serverPortField = new InputField( - this, // parent element - "Server port:", // label - 100, // width of label - wxString::Format("%i", default_port), // default value (variable from "default.conf") - 240 // width of field - ); - verticalLayout->Add(this->_serverPortField, 0, wxTOP | wxLEFT | wxRIGHT, 10); - - this->_playerNameField = new InputField( - this, // parent element - "Player name:", // label - 100, // width of label - "", // default value - 240 // width of field - ); - verticalLayout->Add(this->_playerNameField, 0, wxTOP | wxLEFT | wxRIGHT, 10); - - wxButton* connectButton = new wxButton(this, wxID_ANY, "Connect", wxDefaultPosition, wxSize(100, 40)); + int fieldSpacing = 10; // Space between input fields and button + + // Default values for server host and port + wxString default_server_host = "127.0.0.1"; + int default_port = 50505; + + // Server Address Input Field + this->_serverAddressField = new InputField(this, "Server address:", 100, default_server_host, 240); + this->_serverAddressField->SetLabelTextColour(wxColour(255, 255, 255)); // Set label text color to white + verticalLayout->Add(this->_serverAddressField, 0, wxALL | wxEXPAND, fieldSpacing); + + // Server Port Input Field + this->_serverPortField = new InputField(this, "Server port:", 100, wxString::Format("%i", default_port), 240); + this->_serverPortField->SetLabelTextColour(wxColour(255, 255, 255)); // Set label text color to white + verticalLayout->Add(this->_serverPortField, 0, wxALL | wxEXPAND, fieldSpacing); + + // Player Name Input Field + this->_playerNameField = new InputField(this, "Player name:", 100, "", 240); + this->_playerNameField->SetLabelTextColour(wxColour(255, 255, 255)); // Set label text color to white + verticalLayout->Add(this->_playerNameField, 0, wxALL | wxEXPAND, fieldSpacing); + + // Connect Button with custom style + wxButton* connectButton = new wxButton(this, wxID_ANY, "Connect", wxDefaultPosition, wxDefaultSize); + connectButton->SetForegroundColour(wxColour(225, 225, 225)); // Set button text color + connectButton->SetBackgroundColour(wxColour(102, 0, 51)); // Set button background color + connectButton->SetWindowStyleFlag(wxBORDER_SIMPLE); // Set border style connectButton->Bind(wxEVT_BUTTON, [](wxCommandEvent& event) { - GameController::connectToServer(); + GameController::connectToServer(); // Call the connect method when clicked }); - verticalLayout->Add(connectButton, 0, wxALIGN_RIGHT | wxALL, 10); + verticalLayout->Add(connectButton, 0, wxALIGN_CENTER | wxALL, fieldSpacing); - this->SetSizerAndFit(verticalLayout); + // Create a centered layout to ensure everything is vertically and horizontally centered + wxBoxSizer* centeredLayout = new wxBoxSizer(wxVERTICAL); + centeredLayout->AddStretchSpacer(1); // Add flexible space above the vertical layout + centeredLayout->Add(verticalLayout, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL); + centeredLayout->AddStretchSpacer(1); // Add flexible space below the vertical layout + + // Set the centered layout as the sizer for this panel + this->SetSizer(centeredLayout); +} + +void ConnectionPanel::OnPaint(wxPaintEvent& event) { + wxAutoBufferedPaintDC dc(this); + wxSize panelSize = this->GetClientSize(); + + if (_backgroundImage.IsOk()) { + // Scale the background image to match the panel size + wxImage image = _backgroundImage.ConvertToImage(); + wxImage scaledImage = image.Scale(panelSize.GetWidth(), panelSize.GetHeight(), wxIMAGE_QUALITY_HIGH); + wxBitmap scaledBitmap(scaledImage); + + // Draw the scaled background image + dc.DrawBitmap(scaledBitmap, 0, 0, true); + } else { + // Fallback: Draw a light blue background if the image is not loaded + dc.SetBrush(wxBrush(wxColour(200, 200, 255))); + dc.DrawRectangle(wxPoint(0, 0), panelSize); + } } +void ConnectionPanel::OnSize(wxSizeEvent& event) { + wxSize panelSize = this->GetClientSize(); + + // Update the layout to adjust widget positions and sizes + this->Layout(); + event.Skip(); // Pass the resize event to allow further processing +} +// Retrieve the server address entered by the user wxString ConnectionPanel::getServerAddress() { return this->_serverAddressField->getValue(); } - +// Retrieve the server port entered by the user wxString ConnectionPanel::getServerPort() { return this->_serverPortField->getValue(); } - +// Retrieve the player name entered by the user wxString ConnectionPanel::getPlayerName() { return this->_playerNameField->getValue(); -} +} \ No newline at end of file diff --git a/src/client/panels/ConnectionPanel.h b/src/client/panels/ConnectionPanel.h index 3e60b88bbcaf99e0c35c3e4da1d97a11d8afbf99..24dda2b61473a1abe66eb89a9082adf799b7a797 100644 --- a/src/client/panels/ConnectionPanel.h +++ b/src/client/panels/ConnectionPanel.h @@ -15,6 +15,10 @@ public: wxString getPlayerName(); private: + void OnPaint(wxPaintEvent& event); + void OnSize(wxSizeEvent& event); + + wxBitmap _backgroundImage; InputField* _serverAddressField; InputField* _serverPortField; InputField* _playerNameField; diff --git a/src/client/panels/MainGamePanel.cpp b/src/client/panels/MainGamePanel.cpp index 25e9ac93712716474cb3911cd7bbddec887ca573..4625318c32b42e3dc495cafb05681d554b120ec7 100644 --- a/src/client/panels/MainGamePanel.cpp +++ b/src/client/panels/MainGamePanel.cpp @@ -29,7 +29,6 @@ void MainGamePanel::buildGameState(game_state* gameState, player* me) { double anglePerPlayer = MainGamePanel::twoPi / (double) numberOfPlayers; - // show all other players for(int i = 1; i < numberOfPlayers; i++) { // get player at i-th position after myself @@ -196,8 +195,14 @@ void MainGamePanel::buildCardPiles(game_state* gameState, player *me) { } else { // if the game did not start yet, show a back side of a card in the center (only for the mood) - wxPoint cardPosition = MainGamePanel::tableCenter - (MainGamePanel::cardSize / 2); - new ImagePanel(this, "assets/wizard_back.png", wxBITMAP_TYPE_ANY, cardPosition, MainGamePanel::cardSize); + //wxPoint cardPosition = MainGamePanel::tableCenter - (MainGamePanel::cardSize / 2); + + // Definieren Sie eine neue Kartengröße, die größer ist + wxSize largerCardSize = MainGamePanel::cardSize ; // Verdoppelt die Größe + + //Berechnen Sie die neue Position basierend auf der größeren Kartengröße + wxPoint cardPosition = MainGamePanel::tableCenter - (largerCardSize ); + new ImagePanel(this, "../assets/Wizard_round.png", wxBITMAP_TYPE_ANY, cardPosition, MainGamePanel::cardSize); } } @@ -239,6 +244,7 @@ void MainGamePanel::buildThisPlayer(game_state* gameState, player* me) { wxALIGN_CENTER, true ); + playerName->SetForegroundColour(wxColour(0, 206, 209)); innerLayout->Add(playerName, 0, wxALIGN_CENTER); // if the game has not yet started we say so @@ -250,10 +256,13 @@ void MainGamePanel::buildThisPlayer(game_state* gameState, player* me) { wxSize(200, 18), wxALIGN_CENTER ); + playerPoints->SetForegroundColour(wxColour(0, 206, 209)); innerLayout->Add(playerPoints, 0, wxALIGN_CENTER | wxBOTTOM, 8); // show button that allows our player to start the game wxButton* startGameButton = new wxButton(this, wxID_ANY, "Start Game!", wxDefaultPosition, wxSize(160, 64)); + startGameButton->SetBackgroundColour(wxColour(0, 206, 209)); + startGameButton->SetForegroundColour(wxColour(102, 0, 51)); startGameButton->Bind(wxEVT_BUTTON, [](wxCommandEvent& event) { GameController::startGame(); }); diff --git a/src/client/uiElements/InputField.cpp b/src/client/uiElements/InputField.cpp index 1df821651adb1632f070044a70c9d4c022c9932f..50ece90e32fb961a4b8667829072e5db2f49c2c7 100644 --- a/src/client/uiElements/InputField.cpp +++ b/src/client/uiElements/InputField.cpp @@ -26,8 +26,13 @@ InputField::InputField(wxWindow* parent, const wxString& labelText, int labelWid this->SetSizerAndFit(horizontalLayout); } +void InputField::SetLabelTextColour(const wxColour& colour) { + _label->SetForegroundColour(colour); + _label->Refresh(); +} wxString InputField::getValue() { return this->_field->GetValue(); -} \ No newline at end of file + +} diff --git a/src/client/uiElements/InputField.h b/src/client/uiElements/InputField.h index d65ea7b37466a1efb8fb913d631ec0a2912b0f1d..ae12ee70147c4760b18055e2dd30bcafc0d5496d 100644 --- a/src/client/uiElements/InputField.h +++ b/src/client/uiElements/InputField.h @@ -9,11 +9,11 @@ class InputField : public wxPanel { public: InputField(wxWindow* parent, const wxString& labelText, int labelWidth, const wxString& fieldValue, int fieldWidth); wxString getValue(); + void SetLabelTextColour(const wxColour& colour); private: wxStaticText* _label; wxTextCtrl* _field; - }; diff --git a/src/client/windows/GameWindow.cpp b/src/client/windows/GameWindow.cpp index 2ae355986977023fc72f3015e6443606024adbf2..22b454ff1b5b2a0b1792df76f15943442743ff26 100644 --- a/src/client/windows/GameWindow.cpp +++ b/src/client/windows/GameWindow.cpp @@ -7,7 +7,7 @@ GameWindow::GameWindow(const wxString& title, const wxPoint& pos, const wxSize& this->_mainLayout = new wxBoxSizer(wxVERTICAL); wxBoxSizer* outerLayout = new wxBoxSizer(wxHORIZONTAL); - outerLayout->Add(this->_mainLayout, 1, wxCENTER); + outerLayout->Add(this->_mainLayout, 1, wxEXPAND | wxALL, 20); this->SetSizerAndFit(outerLayout); this->_currentPanel = nullptr; @@ -15,7 +15,7 @@ GameWindow::GameWindow(const wxString& title, const wxPoint& pos, const wxSize& this->_statusBar = this->CreateStatusBar(1); // Set background - wxColor lightBlue = wxColor(213, 231, 239); + wxColor lightBlue = wxColor(102, 0, 51); this->SetBackgroundColour(lightBlue); // Set the minimum size of the window. The user won't be able to resize the window to a size smaller than this @@ -39,7 +39,7 @@ void GameWindow::showPanel(wxPanel* panel) { } // add new panel - this->_mainLayout->Add(panel, 0, wxALIGN_CENTER | wxALL, 20); // 20 pixel spacing + this->_mainLayout->Add(panel, 1, wxEXPAND | wxALL, 20); // Verwenden von wxEXPAND panel->Show(true); this->_currentPanel = panel;