forked from teamnwah/openmw-tes3coop
[Browser] Do not try to open window if server is no more reachable
This commit is contained in:
parent
c8eb0f0eae
commit
ec5d1b7a86
3 changed files with 11 additions and 7 deletions
|
@ -121,7 +121,13 @@ void MainWindow::play()
|
||||||
|
|
||||||
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
|
int sourceId = proxyModel->mapToSource(proxyModel->index(id, ServerData::ADDR)).row();
|
||||||
infoDialog.Server(sm->myData[sourceId].addr);
|
infoDialog.Server(sm->myData[sourceId].addr);
|
||||||
infoDialog.refresh();
|
|
||||||
|
if (!infoDialog.refresh())
|
||||||
|
{
|
||||||
|
queryHelper->refresh();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(!infoDialog.exec())
|
if(!infoDialog.exec())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ void ServerInfoDialog::Server(QString addr)
|
||||||
this->addr = addr;
|
this->addr = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerInfoDialog::refresh()
|
bool ServerInfoDialog::refresh()
|
||||||
{
|
{
|
||||||
QStringList list = addr.split(':');
|
QStringList list = addr.split(':');
|
||||||
auto sd = QueryClient::Get().Update(SystemAddress(list[0].toLatin1(), list[1].toUShort()));
|
auto sd = QueryClient::Get().Update(SystemAddress(list[0].toLatin1(), list[1].toUShort()));
|
||||||
|
@ -43,15 +43,11 @@ void ServerInfoDialog::refresh()
|
||||||
listPlayers->clear();
|
listPlayers->clear();
|
||||||
|
|
||||||
for(auto player : sd.second.players)
|
for(auto player : sd.second.players)
|
||||||
{
|
|
||||||
listPlayers->addItem(QString::fromStdString(player));
|
listPlayers->addItem(QString::fromStdString(player));
|
||||||
};
|
|
||||||
|
|
||||||
listPlugins->clear();
|
listPlugins->clear();
|
||||||
for(auto plugin : sd.second.plugins)
|
for(auto plugin : sd.second.plugins)
|
||||||
{
|
|
||||||
listPlugins->addItem(QString::fromStdString(plugin.name));
|
listPlugins->addItem(QString::fromStdString(plugin.name));
|
||||||
}
|
|
||||||
|
|
||||||
listRules->clear();
|
listRules->clear();
|
||||||
const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"};
|
const static vector<std::string> defaultRules {"gamemode", "maxPlayers", "name", "passw", "players", "version"};
|
||||||
|
@ -68,5 +64,7 @@ void ServerInfoDialog::refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
lblPlayers->setText(QString::number(sd.second.players.size()) + " / " + QString::number(sd.second.GetMaxPlayers()));
|
lblPlayers->setText(QString::number(sd.second.players.size()) + " / " + QString::number(sd.second.GetMaxPlayers()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
virtual ~ServerInfoDialog();
|
virtual ~ServerInfoDialog();
|
||||||
void Server(QString addr);
|
void Server(QString addr);
|
||||||
public slots:
|
public slots:
|
||||||
void refresh();
|
bool refresh();
|
||||||
private:
|
private:
|
||||||
QString addr;
|
QString addr;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue