From 2585dc3cab48ccad0cfa0c63354662d656c86c46 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Sun, 3 Nov 2024 13:34:27 +0100 Subject: `make format` --- mwe/audio/miniaudio/main.cpp | 6 +- mwe/events/include/event.h | 26 ++--- mwe/events/include/eventHandler.h | 1 - mwe/events/include/gameObject.h | 2 +- mwe/events/include/iKeyListener.h | 19 ++-- mwe/events/include/iMouseListener.h | 23 ++--- mwe/events/include/inputSystem.h | 27 +++--- mwe/events/include/keyCodes.h | 16 ++-- mwe/events/include/keyListenerTest.h | 8 +- mwe/events/include/loopManager.h | 6 +- mwe/events/include/mouseListenerTest.h | 12 +-- mwe/events/include/uiObject.h | 74 +++++++------- mwe/events/include/uiRenderer.h | 18 ++-- mwe/events/include/window.h | 30 +++--- mwe/events/src/event.cpp | 29 +++--- mwe/events/src/iKeyListener.cpp | 19 ++-- mwe/events/src/iMouseListener.cpp | 35 ++++--- mwe/events/src/inputSystem.cpp | 162 +++++++++++++++---------------- mwe/events/src/keyListenerTest.cpp | 14 ++- mwe/events/src/loopManager.cpp | 22 ++--- mwe/events/src/main.cpp | 13 +-- mwe/events/src/mouseListenerTest.cpp | 26 ++--- mwe/events/src/uiObject.cpp | 30 +++--- mwe/events/src/uiRenderer.cpp | 170 +++++++++++++++++---------------- mwe/events/src/window.cpp | 72 +++++++------- mwe/gameloop/include/loopManager.h | 2 +- mwe/gameloop/src/loopManager.cpp | 9 +- 27 files changed, 422 insertions(+), 449 deletions(-) (limited to 'mwe') diff --git a/mwe/audio/miniaudio/main.cpp b/mwe/audio/miniaudio/main.cpp index bf31898..5c4f667 100644 --- a/mwe/audio/miniaudio/main.cpp +++ b/mwe/audio/miniaudio/main.cpp @@ -33,12 +33,10 @@ int main() { ma_sound_start(&sfx[2]); ma_sound_start(&bgm); // this actually resumes now this_thread::sleep_for(500ms); - for (unsigned i = 0; i < 3; i++) - ma_sound_seek_to_pcm_frame(&sfx[i], 0); + for (unsigned i = 0; i < 3; i++) ma_sound_seek_to_pcm_frame(&sfx[i], 0); // 5. play all samples simultaniously - for (unsigned i = 0; i < 3; i++) - ma_sound_start(&sfx[i]); + for (unsigned i = 0; i < 3; i++) ma_sound_start(&sfx[i]); this_thread::sleep_for(1000ms); ma_engine_uninit(&engine); diff --git a/mwe/events/include/event.h b/mwe/events/include/event.h index 62d8974..16c75bf 100644 --- a/mwe/events/include/event.h +++ b/mwe/events/include/event.h @@ -6,8 +6,6 @@ #include #include #include -#include "keyCodes.h" -#include "customTypes.h" class UUIDGenerator { public: static std::uint32_t getUniqueID() { @@ -66,16 +64,16 @@ public: }; class MouseClickEvent : public Event { public: - MouseClickEvent(int x, int y, MouseButton button); - + MouseClickEvent(int x, int y, MouseButton button); + REGISTER_EVENT_TYPE("KeyClickedEvent"); std::pair getMousePosition() const; - MouseButton getButton() const { return button; } + MouseButton getButton() const { return button; } private: - int mouseX = 0; + int mouseX = 0; int mouseY = 0; - MouseButton button; + MouseButton button; }; // KeyReleasedEvent class class KeyReleasedEvent : public Event { @@ -112,6 +110,7 @@ public: std::pair getMousePosition() const; MouseButton getMouseButton() const; + private: int mouseX = 0; int mouseY = 0; @@ -124,6 +123,7 @@ public: REGISTER_EVENT_TYPE(MouseMovedEvent) std::pair getMousePosition() const; + private: int mouseX = 0; int mouseY = 0; @@ -141,20 +141,20 @@ private: }; class TextSubmitEvent : public Event { public: - TextSubmitEvent(std::string submittedText); + TextSubmitEvent(std::string submittedText); - REGISTER_EVENT_TYPE(TextSubmitEvent) + REGISTER_EVENT_TYPE(TextSubmitEvent) - std::string getText() const; + std::string getText() const; private: - std::string text; + std::string text; }; class ShutDownEvent : public Event { public: - ShutDownEvent() : Event("ShutDownEvent"){}; + ShutDownEvent() : Event("ShutDownEvent") {}; - REGISTER_EVENT_TYPE(ShutDownEvent) + REGISTER_EVENT_TYPE(ShutDownEvent) private: }; diff --git a/mwe/events/include/eventHandler.h b/mwe/events/include/eventHandler.h index 7d8f20a..aa8f63b 100644 --- a/mwe/events/include/eventHandler.h +++ b/mwe/events/include/eventHandler.h @@ -3,7 +3,6 @@ #include #include - template using EventHandler = std::function; diff --git a/mwe/events/include/gameObject.h b/mwe/events/include/gameObject.h index de5f3fe..48e239b 100644 --- a/mwe/events/include/gameObject.h +++ b/mwe/events/include/gameObject.h @@ -3,7 +3,7 @@ #include class GameObject { public: - GameObject(){} + GameObject() {} // template // void addSpriteComponent(Args &&... args); diff --git a/mwe/events/include/iKeyListener.h b/mwe/events/include/iKeyListener.h index 5f39ece..5fee2eb 100644 --- a/mwe/events/include/iKeyListener.h +++ b/mwe/events/include/iKeyListener.h @@ -1,21 +1,20 @@ #pragma once #include "event.h" -#include "eventManager.h" #include "eventHandler.h" +#include "eventManager.h" class IKeyListener { public: - virtual ~IKeyListener(); - virtual void onKeyPressed(const KeyPressedEvent& event) = 0; - virtual void onKeyReleased(const KeyReleasedEvent& event) = 0; + virtual ~IKeyListener(); + virtual void onKeyPressed(const KeyPressedEvent & event) = 0; + virtual void onKeyReleased(const KeyReleasedEvent & event) = 0; protected: - void subscribeEvents(int listenerId = 0); - void unsubscribeEvents(int listenerId = 0); + void subscribeEvents(int listenerId = 0); + void unsubscribeEvents(int listenerId = 0); void activate(int listenerId = 0) { subscribeEvents(listenerId); } - void deactivate(int listenerId = 0) { unsubscribeEvents(listenerId); } + void deactivate(int listenerId = 0) { unsubscribeEvents(listenerId); } private: - EventHandler keyPressedHandler; - EventHandler keyReleasedHandler; + EventHandler keyPressedHandler; + EventHandler keyReleasedHandler; }; - diff --git a/mwe/events/include/iMouseListener.h b/mwe/events/include/iMouseListener.h index 7d840c1..5b1181c 100644 --- a/mwe/events/include/iMouseListener.h +++ b/mwe/events/include/iMouseListener.h @@ -5,19 +5,20 @@ class IMouseListener { public: - virtual ~IMouseListener(); + virtual ~IMouseListener(); + + virtual void onMouseClicked(const MouseClickEvent & event) = 0; + virtual void onMousePressed(const MousePressedEvent & event) = 0; + virtual void onMouseReleased(const MouseReleasedEvent & event) = 0; + virtual void onMouseMoved(const MouseMovedEvent & event) = 0; - virtual void onMouseClicked(const MouseClickEvent& event) = 0; - virtual void onMousePressed(const MousePressedEvent& event) = 0; - virtual void onMouseReleased(const MouseReleasedEvent& event) = 0; - virtual void onMouseMoved(const MouseMovedEvent& event) = 0; protected: - void subscribeEvents(int listenerId = 0); - void unsubscribeEvents(int listenerId = 0); + void subscribeEvents(int listenerId = 0); + void unsubscribeEvents(int listenerId = 0); private: - EventHandler mouseClickHandler; - EventHandler mousePressHandler; - EventHandler mouseReleaseHandler; - EventHandler mouseMoveHandler; + EventHandler mouseClickHandler; + EventHandler mousePressHandler; + EventHandler mouseReleaseHandler; + EventHandler mouseMoveHandler; }; diff --git a/mwe/events/include/inputSystem.h b/mwe/events/include/inputSystem.h index c20562d..3e53b7c 100644 --- a/mwe/events/include/inputSystem.h +++ b/mwe/events/include/inputSystem.h @@ -1,24 +1,23 @@ #pragma once -#include -#include "uiObject.h" #include "event.h" -#include "keyCodes.h" #include "eventManager.h" +#include "keyCodes.h" +#include "uiObject.h" +#include class InputSystem { public: - InputSystem(); - void registerButton(Button* button); - void registerText(Text* label); - void registerTextInput(TextInput* input); - void processInput(); + InputSystem(); + void registerButton(Button * button); + void registerText(Text * label); + void registerTextInput(TextInput * input); + void processInput(); private: - std::vector buttons; - std::vector textInputs; - std::vector texts; - void processMouseClick(int mouseX, int mouseY); + std::vector