Skip to content

Commit

Permalink
Update GitHub Actions and the SFML example
Browse files Browse the repository at this point in the history
  • Loading branch information
eXpl0it3r committed Feb 15, 2024
1 parent 0455a60 commit f596cfe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ jobs:
fail-fast: false
matrix:
platform:
- { name: Windows VS2019, os: windows-latest }
- { name: Linux GCC, os: ubuntu-latest }
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: MacOS XCode, os: macos-latest }
- { name: Windows VS2022, os: windows-2022 }
- { name: Linux GCC, os: ubuntu-22.04 }
- { name: Linux Clang, os: ubuntu-22.04, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
- { name: macOS x64, os: macos-14, flags: -DCMAKE_OSX_ARCHITECTURES=x86_64 }
- { name: macOS M1, os: macos-14, flags: -DCMAKE_OSX_ARCHITECTURES=arm64 }

steps:
- name: PubBus - Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: SFML - Install Linux Dependencies
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libgl1-mesa-dev libegl1-mesa-dev

- name: SFML - Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: SFML/SFML
path: SFML
Expand Down
4 changes: 2 additions & 2 deletions examples/SFML/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
find_package(SFML 2.5 COMPONENTS graphics REQUIRED)
find_package(SFML 3.0 COMPONENTS Graphics REQUIRED)

add_executable(SFML "SFML.cpp" "Messages.hpp")

target_include_directories(SFML PRIVATE "${CMAKE_SOURCE_DIR}/include")
target_link_libraries(SFML sfml-graphics)
target_link_libraries(SFML SFML::Graphics)

if(PUBBUS_INSTALL_EXAMPLE)
install(TARGETS SFML RUNTIME DESTINATION examples)
Expand Down
3 changes: 2 additions & 1 deletion examples/SFML/Messages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct KeyMessage : pub::Message

Type type;
sf::Keyboard::Key code;
sf::Keyboard::Scancode scancode;
bool alt;
bool control;
bool shift;
Expand All @@ -40,7 +41,7 @@ struct KeyMessage : pub::Message

struct TextMessage : pub::Message
{
sf::Uint32 unicode;
std::uint32_t unicode;
};

struct MouseMoveMessage : pub::Message
Expand Down
15 changes: 8 additions & 7 deletions examples/SFML/SFML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class PositionText final : public sf::Drawable
{
public:
explicit PositionText(const sf::Font& font)
: m_text{ "0, 0", font }
: m_text{ font, "0, 0" }
{

}
Expand All @@ -27,7 +27,7 @@ class PositionText final : public sf::Drawable

void onMouseScroll(const MouseWheelScrollMessage& message)
{
m_text.setString(std::to_string(message.wheel) + ": " + std::to_string(message.delta));
m_text.setString(std::to_string(static_cast<int>(message.wheel)) + ": " + std::to_string(message.delta));
}

private:
Expand All @@ -43,7 +43,7 @@ class ButtonText final : public sf::Drawable
{
public:
explicit ButtonText(const sf::Font& font)
: m_text{ "Pressed / Released", font }
: m_text{ font, "Pressed / Released" }
{

}
Expand All @@ -56,17 +56,17 @@ class ButtonText final : public sf::Drawable
void onKeyEvent(const KeyMessage& message)
{
const auto type = message.type == KeyMessage::Type::Pressed ? "Pressed"s : "Released"s;
m_text.setString(type + ": " + std::to_string(message.code));
m_text.setString(type + ": " + std::to_string(static_cast<int>(message.code)) + " / " + std::to_string(static_cast<int>(message.scancode)));
}

void onMouseEvent(const MouseButtonMessage& message)
{
const auto type = message.type == MouseButtonMessage::Type::Pressed ? "Pressed"s : "Released"s;
m_text.setString(type + ": " + std::to_string(message.button));
m_text.setString(type + ": " + std::to_string(static_cast<int>(message.button)));
}

private:
void draw(sf::RenderTarget& target, const sf::RenderStates states) const override final
void draw(sf::RenderTarget& target, const sf::RenderStates& states) const override final
{
target.draw(m_text, states);
}
Expand All @@ -76,7 +76,7 @@ class ButtonText final : public sf::Drawable

int main()
{
sf::RenderWindow window({ 800, 600 }, "PubBus SFML Test");
sf::RenderWindow window(sf::VideoMode{{ 800, 600 }}, "PubBus SFML Test");
window.setFramerateLimit(60);

sf::Font font;
Expand Down Expand Up @@ -134,6 +134,7 @@ int main()
bus.publish(KeyMessage{
.type = event.type == sf::Event::KeyPressed ? KeyMessage::Type::Pressed : KeyMessage::Type::Released,
.code = event.key.code,
.scancode = event.key.scancode,
.alt = event.key.alt,
.control = event.key.control,
.shift = event.key.shift,
Expand Down

0 comments on commit f596cfe

Please sign in to comment.