StartGUI.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.clear().append("127.0.0.1");
  7. }
  8. void StartGUI::tick() {
  9. base.tick();
  10. }
  11. void StartGUI::render() {
  12. base.updateScale();
  13. Vector2 size = Vector2(BaseGUI::FIXED_SIZE[0] - 80.0f, 110.0f);
  14. Vector2 pos = (base.scaledSize - size) * 0.5f;
  15. info.base.pos = pos;
  16. info.base.size = Vector2(size[0], 30.0f);
  17. address.base.pos = pos + Vector2(40.0f, 30.0f);
  18. address.base.size = Vector2(size[0] - 80.0f, 30.0f);
  19. connect.base.pos = pos + Vector2(40.0f, 70.0f);
  20. connect.base.size = Vector2(size[0] - 80.0f, 30.0f);
  21. Engine::renderer.renderRectangle(pos, size, Color4(0x50, 0x50, 0x50, 0xFF));
  22. base.render();
  23. }
  24. bool StartGUI::getAddress(Address& a) const {
  25. if(connect.base.pressed) {
  26. address.text.toString(a);
  27. return true;
  28. }
  29. return false;
  30. }