mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 02:45:32 +00:00
[Browser] Add ability for connect to passworded servers
This commit is contained in:
parent
0e92f43822
commit
6f2d12d2c6
4 changed files with 27 additions and 1 deletions
|
@ -125,6 +125,15 @@ void MainWindow::play()
|
|||
QStringList arguments;
|
||||
arguments.append(QLatin1String("--connect=") + sm->myData[sourceId].addr.toLatin1());
|
||||
|
||||
if(sm->myData[sourceId].needPassw)
|
||||
{
|
||||
bool ok;
|
||||
QString passw = QInputDialog::getText(this, "Connecting to: " + sm->myData[sourceId].addr, "Password: ", QLineEdit::Password, "", &ok);
|
||||
if(!ok)
|
||||
return;
|
||||
arguments.append(QLatin1String("--password=") + passw.toLatin1());
|
||||
}
|
||||
|
||||
if (mGameInvoker->startProcess(QLatin1String("tes3mp"), arguments, true))
|
||||
return qApp->quit();
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ void NetController::setData(QString address, QJsonObject server, ServerModel *mo
|
|||
|
||||
mi = model->index(0, ServerData::VERSION);
|
||||
model->setData(mi, server["version"].toString());
|
||||
|
||||
mi = model->index(0, ServerData::PASSW);
|
||||
model->setData(mi, server["passw"].toBool());
|
||||
|
||||
mi = model->index(0, ServerData::PING);
|
||||
|
||||
QStringList addr = address.split(":");
|
||||
|
@ -152,6 +156,7 @@ bool NetController::downloadInfo(QAbstractItemModel *pModel, QModelIndex index)
|
|||
qDebug() << server["players"].toInt();
|
||||
qDebug() << server["max_players"].toInt();
|
||||
qDebug() << server["version"].toString();
|
||||
qDebug() << server["passw"].toBool();
|
||||
|
||||
QVector<ServerData>::Iterator value = std::find_if(model->myData.begin(), model->myData.end(), pattern(iter.key()));
|
||||
if(value == model->myData.end())
|
||||
|
@ -213,6 +218,7 @@ void NetController::updateInfo()
|
|||
qDebug() << map["players"].toInt();
|
||||
qDebug() << map["max_players"].toInt();
|
||||
qDebug() << map["version"].toString();
|
||||
qDebug() << map["passw"].toBool();
|
||||
|
||||
sd->hostName = map["hostname"].toString();
|
||||
sd->modName = map["modname"].toString();
|
||||
|
|
|
@ -33,6 +33,9 @@ QVariant ServerModel::data(const QModelIndex &index, int role) const
|
|||
case ServerData::ADDR:
|
||||
var = sd.addr;
|
||||
break;
|
||||
case ServerData::PASSW:
|
||||
var = sd.needPassw;
|
||||
break;
|
||||
case ServerData::VERSION:
|
||||
var = sd.version;
|
||||
break;
|
||||
|
@ -78,6 +81,9 @@ QVariant ServerModel::headerData(int section, Qt::Orientation orientation, int r
|
|||
case ServerData::ADDR:
|
||||
var = "Address";
|
||||
break;
|
||||
case ServerData::PASSW:
|
||||
var = "P";
|
||||
break;
|
||||
case ServerData::VERSION:
|
||||
var = "Version";
|
||||
break;
|
||||
|
@ -126,6 +132,9 @@ bool ServerModel::setData(const QModelIndex &index, const QVariant &value, int r
|
|||
sd.addr = value.toString();
|
||||
ok = !sd.addr.isEmpty();
|
||||
break;
|
||||
case ServerData::PASSW:
|
||||
sd.needPassw = value.toBool();
|
||||
break;
|
||||
case ServerData::VERSION:
|
||||
sd.version = value.toString();
|
||||
ok = !sd.addr.isEmpty();
|
||||
|
@ -162,7 +171,7 @@ bool ServerModel::insertRows(int position, int count, const QModelIndex &index)
|
|||
beginInsertRows(QModelIndex(), position, position + count - 1);
|
||||
|
||||
for (int row = 0; row < count; ++row) {
|
||||
ServerData sd {"", -1, -1, -1, "", ""};
|
||||
ServerData sd {"", -1, -1, -1, "", "", false, 0};
|
||||
myData.insert(position, sd);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,10 +13,12 @@ struct ServerData
|
|||
int ping;
|
||||
QString hostName;
|
||||
QString modName;
|
||||
bool needPassw;
|
||||
QString version;
|
||||
enum IDS
|
||||
{
|
||||
ADDR,
|
||||
PASSW,
|
||||
HOSTNAME,
|
||||
PLAYERS,
|
||||
MAX_PLAYERS,
|
||||
|
|
Loading…
Reference in a new issue