BaseGUI.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef BASE_GUI_H
  2. #define BASE_GUI_H
  3. #include "client/input/Controller.h"
  4. #include "client/rendering/Renderer.h"
  5. #include "client/rendering/ShaderMatrix.h"
  6. #include "gaming-core/input/TextInput.h"
  7. #include "gaming-core/math/Vector.h"
  8. #include "gaming-core/utils/List.h"
  9. #include "gaming-core/utils/Size.h"
  10. struct BaseGUI final {
  11. static const Vector2 FIXED_SIZE;
  12. const Size& size;
  13. TextInput*& textInput;
  14. const Controller& controller;
  15. float scale;
  16. Vector2 scaledSize;
  17. struct Input final {
  18. Vector2 pos;
  19. Vector2 size;
  20. TextInput text;
  21. };
  22. List<Input> inputs;
  23. BaseGUI(const Size& size, TextInput*& textInput,
  24. const Controller& controller);
  25. void tick();
  26. void updateScale(ShaderMatrix& sm);
  27. void render(float lag, ShaderMatrix& sm, Renderer& r);
  28. Vector2 round(const Vector2& v) const;
  29. void drawString(Renderer& r, const Vector2& pos, const char* s);
  30. Input& addInput();
  31. void drawCenteredString(Renderer& r, const Vector2& pos,
  32. const Vector2& size, const char* text);
  33. bool isIn(const Vector2& pos, const Vector2& size,
  34. const Vector2& point) const;
  35. };
  36. #endif