diff --git a/.idea/.name b/.idea/.name index 3c2b3e6..32e40d2 100644 --- a/.idea/.name +++ b/.idea/.name @@ -1 +1 @@ -CMakeSFMLProject \ No newline at end of file +wxwidgets \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 4cc4eae..ecf41e5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..4620162 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,5 +2,17 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ecf25da..ede290c 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -6,3 +6,5 @@ add_subdirectory(pointer) add_subdirectory(classes) add_subdirectory(containers) add_subdirectory(misc) +add_subdirectory(sfml) +add_subdirectory(wxwidgets) diff --git a/cpp/sfml/CMakeLists.txt b/cpp/sfml/CMakeLists.txt index d8498aa..d2e72fd 100644 --- a/cpp/sfml/CMakeLists.txt +++ b/cpp/sfml/CMakeLists.txt @@ -16,8 +16,11 @@ add_executable(main src/main.cpp src/elements/Paddle.cpp src/elements/Paddle.h src/elements/Ball.cpp - src/elements/Ball.h) + src/elements/Ball.h + src/assets_ids.h) target_compile_features(main PRIVATE cxx_std_17) target_link_libraries(main PRIVATE SFML::Graphics) -set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT main) \ No newline at end of file +set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT main) + +file(COPY assets DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) \ No newline at end of file diff --git a/cpp/sfml/src/assets_ids.h b/cpp/sfml/src/assets_ids.h new file mode 100644 index 0000000..797817d --- /dev/null +++ b/cpp/sfml/src/assets_ids.h @@ -0,0 +1,12 @@ +// +// Created by David Hackbarth on 06.03.26. +// + +#ifndef CMAKESFMLPROJECT_ASSETS_IDS_H +#define CMAKESFMLPROJECT_ASSETS_IDS_H + +#define IDLE "assets/Characters/Default/character_green_idle.png" +#define WALK(frame, color) std::string("assets/Characters/Default/character_") + \ + std::string(color) + std::string("_walk_") + std::string(frame) + std::string(".png") + +#endif //CMAKESFMLPROJECT_ASSETS_IDS_H \ No newline at end of file diff --git a/cpp/sfml/src/main.cpp b/cpp/sfml/src/main.cpp index b14ca3d..c5f4c1a 100644 --- a/cpp/sfml/src/main.cpp +++ b/cpp/sfml/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include "elements/Paddle.h" +#include "assets_ids.h" int main() { @@ -23,9 +24,9 @@ int main() drawables.push_back( &player2.getShape() ); // sprite - sf::Texture idleTexture("/Users/hacky/Projects/HWR/hwr2024_b/cpp/sfml/assets/Characters/Default/character_green_idle.png"); - sf::Texture walk1Texture("/Users/hacky/Projects/HWR/hwr2024_b/cpp/sfml/assets/Characters/Default/character_green_walk_a.png"); - sf::Texture walk2Texture("/Users/hacky/Projects/HWR/hwr2024_b/cpp/sfml/assets/Characters/Default/character_green_walk_b.png"); + sf::Texture idleTexture(IDLE); + sf::Texture walk1Texture(WALK("a", "green")); + sf::Texture walk2Texture(WALK("b", "green")); sf::Sprite character(idleTexture); character.setPosition( { 300.f, 220.f } ); drawables.push_back( &character ); diff --git a/cpp/wxwidgets/CMakeLists.txt b/cpp/wxwidgets/CMakeLists.txt new file mode 100644 index 0000000..fe26693 --- /dev/null +++ b/cpp/wxwidgets/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 4.1) +project(wxwidgets LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 20) + +find_package(wxWidgets REQUIRED COMPONENTS net core base) +if(wxWidgets_USE_FILE) + include(${wxWidgets_USE_FILE}) +endif() + +add_executable(wxwidgets src/main.cpp) +target_link_libraries(wxwidgets ${wxWidgets_LIBRARIES}) \ No newline at end of file diff --git a/cpp/wxwidgets/src/main.cpp b/cpp/wxwidgets/src/main.cpp new file mode 100644 index 0000000..9a8b379 --- /dev/null +++ b/cpp/wxwidgets/src/main.cpp @@ -0,0 +1,60 @@ +#include + +class App : public wxApp { +public: + bool OnInit() override; +}; + +wxIMPLEMENT_APP(App); + +class MainWindow : public wxFrame { +public: + MainWindow(); + +private: + void OnShowMenuButtonClick(wxCommandEvent& event); +}; + +bool App::OnInit() { + MainWindow* mainWindow = new MainWindow(); + mainWindow->Show(); + return true; +} + +enum AppIds { + ID_LOWEST = 0, + + ID_SHOW +}; + +MainWindow::MainWindow() : wxFrame(nullptr, wxID_ANY, "Unsere kleine App") { + wxMenu* menu = new wxMenu(); + menu->Append(ID_SHOW, "Zeige Nachricht"); + menu->Append(wxID_EXIT); + + wxMenuBar* menuBar = new wxMenuBar(); + menuBar->Append(menu, "&Datei"); + + SetMenuBar(menuBar); + + Bind(wxEVT_MENU, &MainWindow::OnShowMenuButtonClick, this, ID_SHOW); + + wxBoxSizer* mainVertical = new wxBoxSizer(wxVERTICAL); + wxStaticText* label = new wxStaticText(this, wxID_ANY, "Hallo Welt!"); + mainVertical->Add(label); + mainVertical->Add(new wxStaticText(this, wxID_ANY, "Hallo Welt!")); + mainVertical->Add(new wxStaticText(this, wxID_ANY, "Hallo Welt!")); + + wxBoxSizer* buttonBar = new wxBoxSizer(wxHORIZONTAL); + buttonBar->Add(new wxButton(this, ID_SHOW, "Zeige Nachricht")); + buttonBar->Add(new wxButton(this, ID_SHOW, "Zeige Nachricht")); + buttonBar->Add(new wxButton(this, ID_SHOW, "Zeige Nachricht")); + + mainVertical->Add(buttonBar); + + SetSizer(mainVertical); +} + +void MainWindow::OnShowMenuButtonClick(wxCommandEvent& event) { + wxMessageBox("Hallo Welt!"); +} \ No newline at end of file