Game.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "Game.h"
  2. #include "Initialisierung.h"
  3. #include "Globals.h"
  4. #include <AsynchronCall.h>
  5. #include <Bildschirm.h>
  6. Game::Game( Bildschirm* zScreen )
  7. : Menu( zScreen )
  8. {
  9. logout = initKnopf( 10, 10, 200, 20, Knopf::Style::Normal, "Verlassen" );
  10. logout->setMausEreignis( [this, zScreen]( void* p, void* o, MausEreignis me ) {
  11. if( me.id == ME_RLinks )
  12. {
  13. logout->removeStyle( Knopf::Style::Erlaubt );
  14. new AsynchronCall( [this, zScreen]() {
  15. if( network->leaveGame() )
  16. {
  17. currentGame->release();
  18. currentGame = 0;
  19. zScreen->lock();
  20. hide();
  21. menuRegister->get( "directConnect" )->show();
  22. zScreen->unlock();
  23. }
  24. logout->addStyle( Knopf::Style::Erlaubt );
  25. } );
  26. }
  27. return 1;
  28. } );
  29. elements.add( logout );
  30. debug = initTextFeld( 10, 40, 500, 40, TextFeld::Style::Text | TextFeld::Style::Mehrzeilig, "" );
  31. elements.add( debug );
  32. }
  33. void Game::updatePosition( Vec3<float> position, bool target, Vec3<int> targetPos )
  34. {
  35. Text txt = "Position: (";
  36. txt.setPrecision( 2 );
  37. txt += position.x;
  38. txt += ", ";
  39. txt += position.y;
  40. txt += ", ";
  41. txt += position.z;
  42. txt += ")";
  43. if( target )
  44. {
  45. txt += "\nTarget: (";
  46. txt += targetPos.x;
  47. txt += ", ";
  48. txt += targetPos.y;
  49. txt += ", ";
  50. txt += targetPos.z;
  51. txt += ")";
  52. }
  53. debug->setText( txt );
  54. }