2022-11-29 17:42:09 +02:00
|
|
|
/*
|
|
|
|
* lobbyroomrequest_moc.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2022-11-10 02:20:44 +02:00
|
|
|
#include "lobbyroomrequest_moc.h"
|
|
|
|
#include "ui_lobbyroomrequest_moc.h"
|
|
|
|
|
2022-11-17 01:15:26 +02:00
|
|
|
LobbyRoomRequest::LobbyRoomRequest(SocketLobby & socket, const QString & room, const QMap<QString, QString> & mods, QWidget *parent) :
|
2022-11-10 02:20:44 +02:00
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::LobbyRoomRequest),
|
2022-11-17 01:15:26 +02:00
|
|
|
socketLobby(socket),
|
|
|
|
mods(mods)
|
2022-11-10 02:20:44 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->nameEdit->setText(room);
|
|
|
|
if(!room.isEmpty())
|
|
|
|
{
|
|
|
|
ui->nameEdit->setReadOnly(true);
|
|
|
|
ui->totalPlayers->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
2022-12-25 13:19:16 +02:00
|
|
|
void LobbyRoomRequest::changeEvent(QEvent *event)
|
|
|
|
{
|
|
|
|
if ( event->type() == QEvent::LanguageChange)
|
|
|
|
{
|
|
|
|
ui->retranslateUi(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-10 02:20:44 +02:00
|
|
|
LobbyRoomRequest::~LobbyRoomRequest()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyRoomRequest::on_buttonBox_accepted()
|
|
|
|
{
|
|
|
|
if(ui->nameEdit->isReadOnly())
|
|
|
|
{
|
2022-11-17 01:15:26 +02:00
|
|
|
socketLobby.requestJoinSession(ui->nameEdit->text(), ui->passwordEdit->text(), mods);
|
2022-11-10 02:20:44 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!ui->nameEdit->text().isEmpty())
|
|
|
|
{
|
|
|
|
int totalPlayers = ui->totalPlayers->currentIndex() + 2; //where 2 is a minimum amount of players
|
2022-11-17 01:15:26 +02:00
|
|
|
socketLobby.requestNewSession(ui->nameEdit->text(), totalPlayers, ui->passwordEdit->text(), mods);
|
2022-11-10 02:20:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|