diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index 685af6594a..151cf2c194 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -1347,6 +1347,16 @@ bool NetPlayServer::StartGame() return true; } +void NetPlayServer::AbortGameStart() +{ + if (m_start_pending) + { + m_dialog->OnGameStartAborted(); + ChunkedDataAbort(); + m_start_pending = false; + } +} + // called from ---GUI--- thread bool NetPlayServer::SyncSaveData() { diff --git a/Source/Core/Core/NetPlayServer.h b/Source/Core/Core/NetPlayServer.h index 0c749845e6..dc0390945e 100644 --- a/Source/Core/Core/NetPlayServer.h +++ b/Source/Core/Core/NetPlayServer.h @@ -52,6 +52,7 @@ public: bool DoAllPlayersHaveIPLDump() const; bool StartGame(); bool RequestStartGame(); + void AbortGameStart(); PadMappingArray GetPadMapping() const; void SetPadMapping(const PadMappingArray& mappings); diff --git a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp index 2a295a0298..6149a30a84 100644 --- a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.cpp @@ -53,15 +53,18 @@ void ChunkedProgressDialog::CreateWidgets() m_main_layout = new QVBoxLayout; m_progress_box = new QGroupBox; m_progress_layout = new QVBoxLayout; + m_button_box = new QDialogButtonBox(QDialogButtonBox::NoButton); m_progress_box->setLayout(m_progress_layout); m_main_layout->addWidget(m_progress_box); + m_main_layout->addWidget(m_button_box); setLayout(m_main_layout); } void ChunkedProgressDialog::ConnectWidgets() { + connect(m_button_box, &QDialogButtonBox::rejected, this, &ChunkedProgressDialog::reject); } 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) 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()) { 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)))); m_progress_bars[pid]->setValue(prog); } + +void ChunkedProgressDialog::reject() +{ + auto server = Settings::Instance().GetNetPlayServer(); + + if (server) + server->AbortGameStart(); + + QDialog::reject(); +} diff --git a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h index 794c26ac3e..4a8a96a287 100644 --- a/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h +++ b/Source/Core/DolphinQt/NetPlay/ChunkedProgressDialog.h @@ -12,6 +12,7 @@ #include "Common/CommonTypes.h" +class QDialogButtonBox; class QGroupBox; class QLabel; class QProgressBar; @@ -27,6 +28,8 @@ public: void show(const QString& title, u64 data_size, const std::vector& players); void SetProgress(int pid, u64 progress); + void reject() override; + private: void CreateWidgets(); void ConnectWidgets(); @@ -38,4 +41,5 @@ private: QGroupBox* m_progress_box; QVBoxLayout* m_progress_layout; QVBoxLayout* m_main_layout; + QDialogButtonBox* m_button_box; }; diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index 814aafdf39..08d025b285 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -1096,7 +1096,7 @@ void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u6 { QueueOnObject(this, [this, title, data_size, players] { 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); }); @@ -1104,7 +1104,7 @@ void NetPlayDialog::ShowChunkedProgressDialog(const std::string& title, const u6 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)