Add wxwidgets module with initial implementation and integrate into CMake build system. Improve asset management in sfml module.

This commit is contained in:
2026-03-06 13:46:06 +01:00
parent 8c726d9cb5
commit ce7dd786ea
9 changed files with 109 additions and 7 deletions
Generated
+1 -1
View File
@@ -1 +1 @@
CMakeSFMLProject
wxwidgets
+1 -1
View File
@@ -3,7 +3,7 @@
<component name="CMakePythonSetting">
<option name="pythonIntegrationState" value="YES" />
</component>
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$/cpp/sfml">
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$/cpp/wxwidgets">
<contentRoot DIR="$PROJECT_DIR$" />
</component>
</project>
Generated
+12
View File
@@ -2,5 +2,17 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/flac-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/freetype-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/freetype-src/subprojects/dlg" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/ogg-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/sfml-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-debug/_deps/vorbis-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/flac-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/freetype-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/freetype-src/subprojects/dlg" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/ogg-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/sfml-src" vcs="Git" />
<mapping directory="$PROJECT_DIR$/cpp/sfml/cmake-build-release/_deps/vorbis-src" vcs="Git" />
</component>
</project>
+2
View File
@@ -6,3 +6,5 @@ add_subdirectory(pointer)
add_subdirectory(classes)
add_subdirectory(containers)
add_subdirectory(misc)
add_subdirectory(sfml)
add_subdirectory(wxwidgets)
+4 -1
View File
@@ -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)
file(COPY assets DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+12
View File
@@ -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
+4 -3
View File
@@ -1,6 +1,7 @@
#include <SFML/Graphics.hpp>
#include <vector>
#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 );
+12
View File
@@ -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})
+60
View File
@@ -0,0 +1,60 @@
#include <wx/wx.h>
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!");
}