mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 22:45:34 +00:00
[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();
|
||||
infoDialog.Server(sm->myData[sourceId].addr);
|
||||
infoDialog.refresh();
|
||||
|
||||
if (!infoDialog.refresh())
|
||||
{
|
||||
queryHelper->refresh();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!infoDialog.exec())
|
||||
return;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void ServerInfoDialog::Server(QString addr)
|
|||
this->addr = addr;
|
||||
}
|
||||
|
||||
void ServerInfoDialog::refresh()
|
||||
bool ServerInfoDialog::refresh()
|
||||
{
|
||||
QStringList list = addr.split(':');
|
||||
auto sd = QueryClient::Get().Update(SystemAddress(list[0].toLatin1(), list[1].toUShort()));
|
||||
|
@ -43,15 +43,11 @@ void ServerInfoDialog::refresh()
|
|||
listPlayers->clear();
|
||||
|
||||
for(auto player : sd.second.players)
|
||||
{
|
||||
listPlayers->addItem(QString::fromStdString(player));
|
||||
};
|
||||
|
||||
listPlugins->clear();
|
||||
for(auto plugin : sd.second.plugins)
|
||||
{
|
||||
listPlugins->addItem(QString::fromStdString(plugin.name));
|
||||
}
|
||||
|
||||
listRules->clear();
|
||||
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()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ public:
|
|||
virtual ~ServerInfoDialog();
|
||||
void Server(QString addr);
|
||||
public slots:
|
||||
void refresh();
|
||||
bool refresh();
|
||||
private:
|
||||
QString addr;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue