diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-03 10:49:19 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-03 10:49:19 +0100 |
commit | ed8534e2d150428bcbc4a6df8940323ae8db2925 (patch) | |
tree | b8c2402d13a4de190539e781c037c69d779cf95a /mwe/events/include | |
parent | 5e833bba513d97c39f4e0d26b45a9095c32812a6 (diff) |
fixed gameloop double window and event poc is working again
Diffstat (limited to 'mwe/events/include')
-rw-r--r-- | mwe/events/include/inputSystem.h | 8 | ||||
-rw-r--r-- | mwe/events/include/uiObject.h | 19 | ||||
-rw-r--r-- | mwe/events/include/uiRenderer.h | 4 |
3 files changed, 22 insertions, 9 deletions
diff --git a/mwe/events/include/inputSystem.h b/mwe/events/include/inputSystem.h index 06db74c..c20562d 100644 --- a/mwe/events/include/inputSystem.h +++ b/mwe/events/include/inputSystem.h @@ -8,9 +8,17 @@ class InputSystem { public: InputSystem(); void registerButton(Button* button); + void registerText(Text* label); + void registerTextInput(TextInput* input); void processInput(); private: std::vector<Button*> buttons; + std::vector<TextInput*> textInputs; + std::vector<Text*> texts; void processMouseClick(int mouseX, int mouseY); + void processInputField(int mouseX, int mouseY); + void processKeyPress(Keycode); + void processTextInput(const std::string& text); + }; diff --git a/mwe/events/include/uiObject.h b/mwe/events/include/uiObject.h index 720d5c2..893232d 100644 --- a/mwe/events/include/uiObject.h +++ b/mwe/events/include/uiObject.h @@ -53,17 +53,18 @@ class Text : public UIObject{ TTF_Font *font; RGBColor color; }; -class TextInput : public UIObject{ - public: - TextInput (int width,int height); - std::string textBuffer; +class TextInput : public UIObject { +public: + TextInput(int width, int height); + std::string textBuffer; std::string placeholder; - size_t caretPosition; - bool isActive; + bool isActive = false; RGBColor textColor; RGBColor backgroundColor; - size_t maxLength; + size_t maxLength = 100; Alignment alignment; - TTF_Font* font; - EventHandler<TextSubmitEvent> onSubmit; + TTF_Font* font = nullptr; + std::function<void()> onSubmit; + std::function<void()> onFocus; }; + diff --git a/mwe/events/include/uiRenderer.h b/mwe/events/include/uiRenderer.h index 286ac1f..32acecf 100644 --- a/mwe/events/include/uiRenderer.h +++ b/mwe/events/include/uiRenderer.h @@ -1,15 +1,19 @@ #pragma once #include <SDL2/SDL.h> #include <SDL2/SDL_ttf.h> +#include <string> #include "uiObject.h" class UIRenderer { public: UIRenderer(SDL_Renderer* renderer); + ~UIRenderer(); + void render(UIObject* uiObject); private: SDL_Renderer* renderer; + TTF_Font* font; void renderButton(Button* button); void renderText(Text* text); |