StartGUI.cpp 987 B

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