diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 11:10:31 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-14 11:10:31 +0100 |
commit | 6e13510f3c6d4155707f748d237bb1fa05243450 (patch) | |
tree | b21ca972d14aac56b7c58c85c54d8a2fd1278a7e /mwe/events/src | |
parent | 319d511135da1b58acb78ca939d7ee01fee4bbf3 (diff) | |
parent | be1e97bc7a494963ab1567492fafcda99e36f683 (diff) |
merge `master` into `loek/audio`
Diffstat (limited to 'mwe/events/src')
-rw-r--r-- | mwe/events/src/event.cpp | 31 | ||||
-rw-r--r-- | mwe/events/src/main.cpp | 4 | ||||
-rw-r--r-- | mwe/events/src/uiObject.cpp | 13 |
3 files changed, 36 insertions, 12 deletions
diff --git a/mwe/events/src/event.cpp b/mwe/events/src/event.cpp index 0c9f3ed..8ffa0b1 100644 --- a/mwe/events/src/event.cpp +++ b/mwe/events/src/event.cpp @@ -23,7 +23,9 @@ void Event::markHandled() { isHandled = true; } // KeyPressedEvent class methods KeyPressedEvent::KeyPressedEvent(int keycode) - : Event("KeyPressedEvent"), key(keycode), repeatCount(0) {} + : Event("KeyPressedEvent"), + key(keycode), + repeatCount(0) {} Keycode KeyPressedEvent::getKeyCode() const { return key; } @@ -31,13 +33,16 @@ int KeyPressedEvent::getRepeatCount() const { return repeatCount; } // KeyReleasedEvent class methods KeyReleasedEvent::KeyReleasedEvent(int keycode) - : Event("KeyReleasedEvent"), key(keycode) {} + : Event("KeyReleasedEvent"), + key(keycode) {} Keycode KeyReleasedEvent::getKeyCode() const { return key; } // MousePressedEvent class methods MousePressedEvent::MousePressedEvent(int mouseX, int mouseY) - : Event("MousePressedEvent"), mouseX(mouseX), mouseY(mouseY) {} + : Event("MousePressedEvent"), + mouseX(mouseX), + mouseY(mouseY) {} std::pair<int, int> MousePressedEvent::getMousePosition() const { return {mouseX, mouseY}; @@ -45,26 +50,36 @@ std::pair<int, int> MousePressedEvent::getMousePosition() const { //Collision event CollisionEvent::CollisionEvent(Collision collision) - : collisionData(collision), Event("CollisionEvent") {} + : collisionData(collision), + Event("CollisionEvent") {} Collision CollisionEvent::getCollisionData() const { return this->collisionData; } TextSubmitEvent::TextSubmitEvent(std::string text) - : text(text), Event("TextSubmitEvent") {} + : text(text), + Event("TextSubmitEvent") {} std::string TextSubmitEvent::getText() const { return this->text; } MouseReleasedEvent::MouseReleasedEvent(int x, int y, MouseButton button) - : mouseX(x), mouseY(y), button(button), Event("MouseReleased") {} + : mouseX(x), + mouseY(y), + button(button), + Event("MouseReleased") {} std::pair<int, int> MouseReleasedEvent::getMousePosition() const { return {mouseX, mouseY}; } MouseClickEvent::MouseClickEvent(int x, int y, MouseButton button) - : mouseX(x), mouseY(y), button(button), Event("MouseClickEvent") {} + : mouseX(x), + mouseY(y), + button(button), + Event("MouseClickEvent") {} MouseMovedEvent::MouseMovedEvent(int x, int y) - : mouseX(x), mouseY(y), Event("MouseMovedEvent") {} + : mouseX(x), + mouseY(y), + Event("MouseMovedEvent") {} std::pair<int, int> MouseClickEvent::getMousePosition() const { return {mouseX, mouseY}; } diff --git a/mwe/events/src/main.cpp b/mwe/events/src/main.cpp index d49cf74..f4e7390 100644 --- a/mwe/events/src/main.cpp +++ b/mwe/events/src/main.cpp @@ -11,7 +11,9 @@ class PlayerDamagedEvent : public Event { public: PlayerDamagedEvent(int damage, int playerID) - : Event("PlayerDamaged"), damage(damage), playerID(playerID) {} + : Event("PlayerDamaged"), + damage(damage), + playerID(playerID) {} REGISTER_EVENT_TYPE(PlayerDamagedEvent); diff --git a/mwe/events/src/uiObject.cpp b/mwe/events/src/uiObject.cpp index 8405469..947d1a2 100644 --- a/mwe/events/src/uiObject.cpp +++ b/mwe/events/src/uiObject.cpp @@ -7,7 +7,9 @@ UIObject::UIObject(int width, int height) : width(width), height(height) {} Button::Button(int width, int height) : UIObject(width, height) {} Text::Text(int width, int height) - : UIObject(width, height), size(12), font(nullptr), + : UIObject(width, height), + size(12), + font(nullptr), color{255, 255, 255} { // Default size and color alignment.horizontal = Alignment::Horizontal::CENTER; alignment.vertical = Alignment::Vertical::MIDDLE; @@ -15,8 +17,13 @@ Text::Text(int width, int height) } TextInput::TextInput(int width, int height) - : UIObject(width, height), textBuffer(""), placeholder(""), isActive(false), - textColor{255, 255, 255}, backgroundColor{0, 0, 0}, maxLength(100), + : UIObject(width, height), + textBuffer(""), + placeholder(""), + isActive(false), + textColor{255, 255, 255}, + backgroundColor{0, 0, 0}, + maxLength(100), font(nullptr) { alignment.horizontal = Alignment::Horizontal::LEFT; alignment.vertical = Alignment::Vertical::TOP; |