lobbyroomrequest_moc.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * lobbyroomrequest_moc.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "lobbyroomrequest_moc.h"
  11. #include "ui_lobbyroomrequest_moc.h"
  12. LobbyRoomRequest::LobbyRoomRequest(SocketLobby & socket, const QString & room, const QMap<QString, QString> & mods, QWidget *parent) :
  13. QDialog(parent),
  14. ui(new Ui::LobbyRoomRequest),
  15. socketLobby(socket),
  16. mods(mods)
  17. {
  18. ui->setupUi(this);
  19. ui->nameEdit->setText(room);
  20. if(!room.isEmpty())
  21. {
  22. ui->nameEdit->setReadOnly(true);
  23. ui->totalPlayers->setEnabled(false);
  24. }
  25. show();
  26. }
  27. LobbyRoomRequest::~LobbyRoomRequest()
  28. {
  29. delete ui;
  30. }
  31. void LobbyRoomRequest::on_buttonBox_accepted()
  32. {
  33. if(ui->nameEdit->isReadOnly())
  34. {
  35. socketLobby.requestJoinSession(ui->nameEdit->text(), ui->passwordEdit->text(), mods);
  36. }
  37. else
  38. {
  39. if(!ui->nameEdit->text().isEmpty())
  40. {
  41. int totalPlayers = ui->totalPlayers->currentIndex() + 2; //where 2 is a minimum amount of players
  42. socketLobby.requestNewSession(ui->nameEdit->text(), totalPlayers, ui->passwordEdit->text(), mods);
  43. }
  44. }
  45. }