NetPlay: Add cancel button for chunked data transfers
This commit is contained in:
parent
7870704087
commit
c90df946ba
|
@ -1347,6 +1347,16 @@ bool NetPlayServer::StartGame()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetPlayServer::AbortGameStart()
|
||||||
|
{
|
||||||
|
if (m_start_pending)
|
||||||
|
{
|
||||||
|
m_dialog->OnGameStartAborted();
|
||||||
|
ChunkedDataAbort();
|
||||||
|
m_start_pending = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// called from ---GUI--- thread
|
// called from ---GUI--- thread
|
||||||
bool NetPlayServer::SyncSaveData()
|
bool NetPlayServer::SyncSaveData()
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
bool DoAllPlayersHaveIPLDump() const;
|
bool DoAllPlayersHaveIPLDump() const;
|
||||||
bool StartGame();
|
bool StartGame();
|
||||||
bool RequestStartGame();
|
bool RequestStartGame();
|
||||||
|
void AbortGameStart();
|
||||||
|
|
||||||
PadMappingArray GetPadMapping() const;
|
PadMappingArray GetPadMapping() const;
|
||||||
void SetPadMapping(const PadMappingArray& mappings);
|
void SetPadMapping(const PadMappingArray& mappings);
|
||||||
|
|
|
@ -53,15 +53,18 @@ void ChunkedProgressDialog::CreateWidgets()
|
||||||
m_main_layout = new QVBoxLayout;
|
m_main_layout = new QVBoxLayout;
|
||||||
m_progress_box = new QGroupBox;
|
m_progress_box = new QGroupBox;
|
||||||
m_progress_layout = new QVBoxLayout;
|
m_progress_layout = new QVBoxLayout;
|
||||||
|
m_button_box = new QDialogButtonBox(QDialogButtonBox::NoButton);
|
||||||
|
|
||||||
m_progress_box->setLayout(m_progress_layout);
|
m_progress_box->setLayout(m_progress_layout);
|
||||||
|
|
||||||
m_main_layout->addWidget(m_progress_box);
|
m_main_layout->addWidget(m_progress_box);
|
||||||
|
m_main_layout->addWidget(m_button_box);
|
||||||
setLayout(m_main_layout);
|
setLayout(m_main_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkedProgressDialog::ConnectWidgets()
|
void ChunkedProgressDialog::ConnectWidgets()
|
||||||
{
|
{
|
||||||
|
connect(m_button_box, &QDialogButtonBox::rejected, this, &ChunkedProgressDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
|
void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
|
||||||
|
@ -89,6 +92,21 @@ void ChunkedProgressDialog::show(const QString& title, const u64 data_size,
|
||||||
if (!client)
|
if (!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (Settings::Instance().GetNetPlayServer())
|
||||||
|
{
|
||||||
|
m_button_box->setStandardButtons(QDialogButtonBox::Cancel);
|
||||||
|
QPushButton* cancel_button = m_button_box->button(QDialogButtonBox::Cancel);
|
||||||
|
cancel_button->setAutoDefault(false);
|
||||||
|
cancel_button->setDefault(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_button_box->setStandardButtons(QDialogButtonBox::Close);
|
||||||
|
QPushButton* close_button = m_button_box->button(QDialogButtonBox::Close);
|
||||||
|
close_button->setAutoDefault(false);
|
||||||
|
close_button->setDefault(false);
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto* player : client->GetPlayers())
|
for (const auto* player : client->GetPlayers())
|
||||||
{
|
{
|
||||||
if (std::find(players.begin(), players.end(), player->pid) == players.end())
|
if (std::find(players.begin(), players.end(), player->pid) == players.end())
|
||||||
|
@ -121,3 +139,13 @@ void ChunkedProgressDialog::SetProgress(const int pid, const u64 progress)
|
||||||
QString::fromStdString(StringFromFormat("%.2f", total))));
|
QString::fromStdString(StringFromFormat("%.2f", total))));
|
||||||
m_progress_bars[pid]->setValue(prog);
|
m_progress_bars[pid]->setValue(prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChunkedProgressDialog::reject()
|
||||||
|
{
|
||||||
|
auto server = Settings::Instance().GetNetPlayServer();
|
||||||
|
|
||||||
|
if (server)
|
||||||
|
server->AbortGameStart();
|
||||||
|
|
||||||
|
QDialog::reject();
|
||||||
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
|
||||||
|
class QDialogButtonBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QProgressBar;
|
class QProgressBar;
|
||||||
|
@ -27,6 +28,8 @@ public:
|
||||||
void show(const QString& title, u64 data_size, const std::vector<int>& players);
|
void show(const QString& title, u64 data_size, const std::vector<int>& players);
|
||||||
void SetProgress(int pid, u64 progress);
|
void SetProgress(int pid, u64 progress);
|
||||||
|
|
||||||
|
void reject() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateWidgets();
|
void CreateWidgets();
|
||||||
void ConnectWidgets();
|
void ConnectWidgets();
|
||||||
|
@ -38,4 +41,5 @@ private:
|
||||||
QGroupBox* m_progress_box;
|
QGroupBox* m_progress_box;
|
||||||
QVBoxLayout* m_progress_layout;
|
QVBoxLayout* m_progress_layout;
|
||||||
QVBoxLayout* m_main_layout;
|
QVBoxLayout* m_main_layout;
|
||||||
|
QDialogButtonBox* m_button_box;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1096,7 +1096,7 @@ void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u6
|
||||||
{
|
{
|
||||||
QueueOnObject(this, [this, title, data_size, players] {
|
QueueOnObject(this, [this, title, data_size, players] {
|
||||||
if (m_chunked_progress_dialog->isVisible())
|
if (m_chunked_progress_dialog->isVisible())
|
||||||
m_chunked_progress_dialog->close();
|
m_chunked_progress_dialog->done(QDialog::Accepted);
|
||||||
|
|
||||||
m_chunked_progress_dialog->show(QString::fromStdString(title), data_size, players);
|
m_chunked_progress_dialog->show(QString::fromStdString(title), data_size, players);
|
||||||
});
|
});
|
||||||
|
@ -1104,7 +1104,7 @@ void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u6
|
||||||
|
|
||||||
void NetPlayDialog::HideChunkedProgressDialog()
|
void NetPlayDialog::HideChunkedProgressDialog()
|
||||||
{
|
{
|
||||||
QueueOnObject(this, [this] { m_chunked_progress_dialog->close(); });
|
QueueOnObject(this, [this] { m_chunked_progress_dialog->done(QDialog::Accepted); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetPlayDialog::SetChunkedProgress(const int pid, const u64 progress)
|
void NetPlayDialog::SetChunkedProgress(const int pid, const u64 progress)
|
||||||
|
|
Loading…
Reference in New Issue