DirectConnect.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #include "DirectConnect.h"
  2. #include "Initialisierung.h"
  3. #include "Globals.h"
  4. DirectConnect::DirectConnect( Bildschirm *zScreen )
  5. : Menu( zScreen )
  6. {
  7. elements.add( initTextFeld( 10, 10, 90, 20, TextFeld::Style::Text, "Adresse: " ) );
  8. elements.add( initTextFeld( 10, 35, 90, 20, TextFeld::Style::Text, "Port: " ) );
  9. address = initTextFeld( 100, 10, 200, 20, TextFeld::Style::TextFeld, "" );
  10. port = initTextFeld( 100, 35, 200, 20, TextFeld::Style::TextFeld, "" );
  11. port->setTastaturEreignis( _nurNummernTE );
  12. elements.add( address );
  13. elements.add( port );
  14. Knopf *login = initKnopf( 200, 60, 100, 20, Knopf::Style::Normal, "Beitreten" );
  15. login->setMausEreignis( [this, login]( void *p, void *o, MausEreignis me )
  16. {
  17. if( me.id == ME_RLinks )
  18. {
  19. login->removeStyle( Knopf::Style::Erlaubt );
  20. address->removeStyle( TextFeld::Style::Erlaubt );
  21. port->removeStyle( TextFeld::Style::Erlaubt );
  22. if( network->connect( address->zText()->getText(), (short)(int)*port->zText() ) )
  23. {
  24. currentGame = new World();
  25. hide();
  26. menuRegister->get( "game" )->show();
  27. }
  28. address->addStyle( TextFeld::Style::Erlaubt );
  29. port->addStyle( TextFeld::Style::Erlaubt );
  30. login->addStyle( Knopf::Style::Erlaubt );
  31. }
  32. return 1;
  33. } );
  34. elements.add( login );
  35. }