StartGUI.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "client/gui/StartGUI.h"
  2. #include "client/rendering/Engine.h"
  3. StartGUI::StartGUI()
  4. : info(base.addLabel("Connect to server ...")), address(base.addInput()),
  5. connect(base.addButton("Connect ...")) {
  6. address.text.setActive(true);
  7. address.text.fill("127.0.0.1");
  8. }
  9. void StartGUI::tick() {
  10. base.tick();
  11. }
  12. void StartGUI::render() {
  13. base.updateScale();
  14. Vector2 size = Vector2(BaseGUI::FIXED_SIZE[0] - 80.0f, 110.0f);
  15. Vector2 pos = (base.scaledSize - size) * 0.5f;
  16. info.base.pos = pos;
  17. info.base.size = Vector2(size[0], 30.0f);
  18. address.base.pos = pos + Vector2(40.0f, 30.0f);
  19. address.base.size = Vector2(size[0] - 80.0f, 30.0f);
  20. connect.base.pos = pos + Vector2(40.0f, 70.0f);
  21. connect.base.size = Vector2(size[0] - 80.0f, 30.0f);
  22. Engine::renderer.renderRectangle(pos, size, Color4(0x50, 0x50, 0x50, 0xFF));
  23. base.render();
  24. }
  25. bool StartGUI::getAddress(Address& a) const {
  26. if(connect.base.pressed) {
  27. address.text.toString(a);
  28. return true;
  29. }
  30. return false;
  31. }