diff options
| author | 2022-08-27 03:41:19 +0200 | |
|---|---|---|
| committer | 2022-08-27 03:41:19 +0200 | |
| commit | 2b6ac4463c06cfdf50b1d150311a217d2ee11688 (patch) | |
| tree | b3c6e200499949a98a42b05f96bcc01134ca2ef5 /src | |
| parent | core/socket_proxy: Correct broadcast behavior (diff) | |
| download | yuzu-2b6ac4463c06cfdf50b1d150311a217d2ee11688.tar.gz yuzu-2b6ac4463c06cfdf50b1d150311a217d2ee11688.tar.xz yuzu-2b6ac4463c06cfdf50b1d150311a217d2ee11688.zip | |
yuzu/multiplayer: Warn when game is running or no network interface is selected
Diffstat (limited to 'src')
| -rw-r--r-- | src/yuzu/main.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/direct_connect.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/direct_connect.h | 4 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/host_room.cpp | 16 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/host_room.h | 4 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/lobby.cpp | 19 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/lobby.h | 4 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/message.cpp | 10 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/message.h | 9 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/state.cpp | 12 | ||||
| -rw-r--r-- | src/yuzu/multiplayer/state.h | 4 |
11 files changed, 81 insertions, 19 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index e103df977..a85adc072 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -860,7 +860,7 @@ void GMainWindow::InitializeWidgets() { | |||
| 860 | }); | 860 | }); |
| 861 | 861 | ||
| 862 | multiplayer_state = new MultiplayerState(this, game_list->GetModel(), ui->action_Leave_Room, | 862 | multiplayer_state = new MultiplayerState(this, game_list->GetModel(), ui->action_Leave_Room, |
| 863 | ui->action_Show_Room, system->GetRoomNetwork()); | 863 | ui->action_Show_Room, *system); |
| 864 | multiplayer_state->setVisible(false); | 864 | multiplayer_state->setVisible(false); |
| 865 | 865 | ||
| 866 | // Create status bar | 866 | // Create status bar |
diff --git a/src/yuzu/multiplayer/direct_connect.cpp b/src/yuzu/multiplayer/direct_connect.cpp index 4c0ea0a6b..65b5f0b9d 100644 --- a/src/yuzu/multiplayer/direct_connect.cpp +++ b/src/yuzu/multiplayer/direct_connect.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <QString> | 8 | #include <QString> |
| 9 | #include <QtConcurrent/QtConcurrentRun> | 9 | #include <QtConcurrent/QtConcurrentRun> |
| 10 | #include "common/settings.h" | 10 | #include "common/settings.h" |
| 11 | #include "core/internal_network/network_interface.h" | ||
| 11 | #include "network/network.h" | 12 | #include "network/network.h" |
| 12 | #include "ui_direct_connect.h" | 13 | #include "ui_direct_connect.h" |
| 13 | #include "yuzu/main.h" | 14 | #include "yuzu/main.h" |
| @@ -20,9 +21,10 @@ | |||
| 20 | 21 | ||
| 21 | enum class ConnectionType : u8 { TraversalServer, IP }; | 22 | enum class ConnectionType : u8 { TraversalServer, IP }; |
| 22 | 23 | ||
| 23 | DirectConnectWindow::DirectConnectWindow(Network::RoomNetwork& room_network_, QWidget* parent) | 24 | DirectConnectWindow::DirectConnectWindow(Core::System& system_, QWidget* parent) |
| 24 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), | 25 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), |
| 25 | ui(std::make_unique<Ui::DirectConnect>()), room_network{room_network_} { | 26 | ui(std::make_unique<Ui::DirectConnect>()), system{system_}, room_network{ |
| 27 | system.GetRoomNetwork()} { | ||
| 26 | 28 | ||
| 27 | ui->setupUi(this); | 29 | ui->setupUi(this); |
| 28 | 30 | ||
| @@ -53,10 +55,20 @@ void DirectConnectWindow::RetranslateUi() { | |||
| 53 | } | 55 | } |
| 54 | 56 | ||
| 55 | void DirectConnectWindow::Connect() { | 57 | void DirectConnectWindow::Connect() { |
| 58 | if (!Network::GetSelectedNetworkInterface()) { | ||
| 59 | NetworkMessage::ErrorManager::ShowError( | ||
| 60 | NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED); | ||
| 61 | return; | ||
| 62 | } | ||
| 56 | if (!ui->nickname->hasAcceptableInput()) { | 63 | if (!ui->nickname->hasAcceptableInput()) { |
| 57 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID); | 64 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID); |
| 58 | return; | 65 | return; |
| 59 | } | 66 | } |
| 67 | if (system.IsPoweredOn()) { | ||
| 68 | if (!NetworkMessage::WarnGameRunning()) { | ||
| 69 | return; | ||
| 70 | } | ||
| 71 | } | ||
| 60 | if (const auto member = room_network.GetRoomMember().lock()) { | 72 | if (const auto member = room_network.GetRoomMember().lock()) { |
| 61 | // Prevent the user from trying to join a room while they are already joining. | 73 | // Prevent the user from trying to join a room while they are already joining. |
| 62 | if (member->GetState() == Network::RoomMember::State::Joining) { | 74 | if (member->GetState() == Network::RoomMember::State::Joining) { |
diff --git a/src/yuzu/multiplayer/direct_connect.h b/src/yuzu/multiplayer/direct_connect.h index 4e1043053..defa4f4ec 100644 --- a/src/yuzu/multiplayer/direct_connect.h +++ b/src/yuzu/multiplayer/direct_connect.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <QDialog> | 7 | #include <QDialog> |
| 8 | #include <QFutureWatcher> | 8 | #include <QFutureWatcher> |
| 9 | #include "core/core.h" | ||
| 9 | #include "yuzu/multiplayer/validation.h" | 10 | #include "yuzu/multiplayer/validation.h" |
| 10 | 11 | ||
| 11 | namespace Ui { | 12 | namespace Ui { |
| @@ -16,7 +17,7 @@ class DirectConnectWindow : public QDialog { | |||
| 16 | Q_OBJECT | 17 | Q_OBJECT |
| 17 | 18 | ||
| 18 | public: | 19 | public: |
| 19 | explicit DirectConnectWindow(Network::RoomNetwork& room_network_, QWidget* parent = nullptr); | 20 | explicit DirectConnectWindow(Core::System& system_, QWidget* parent = nullptr); |
| 20 | ~DirectConnectWindow(); | 21 | ~DirectConnectWindow(); |
| 21 | 22 | ||
| 22 | void RetranslateUi(); | 23 | void RetranslateUi(); |
| @@ -39,5 +40,6 @@ private: | |||
| 39 | QFutureWatcher<void>* watcher; | 40 | QFutureWatcher<void>* watcher; |
| 40 | std::unique_ptr<Ui::DirectConnect> ui; | 41 | std::unique_ptr<Ui::DirectConnect> ui; |
| 41 | Validation validation; | 42 | Validation validation; |
| 43 | Core::System& system; | ||
| 42 | Network::RoomNetwork& room_network; | 44 | Network::RoomNetwork& room_network; |
| 43 | }; | 45 | }; |
diff --git a/src/yuzu/multiplayer/host_room.cpp b/src/yuzu/multiplayer/host_room.cpp index 8e7a81291..ad7dcc36d 100644 --- a/src/yuzu/multiplayer/host_room.cpp +++ b/src/yuzu/multiplayer/host_room.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <QtConcurrent/QtConcurrentRun> | 12 | #include <QtConcurrent/QtConcurrentRun> |
| 13 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 14 | #include "common/settings.h" | 14 | #include "common/settings.h" |
| 15 | #include "core/internal_network/network_interface.h" | ||
| 15 | #include "network/announce_multiplayer_session.h" | 16 | #include "network/announce_multiplayer_session.h" |
| 16 | #include "ui_host_room.h" | 17 | #include "ui_host_room.h" |
| 17 | #include "yuzu/game_list_p.h" | 18 | #include "yuzu/game_list_p.h" |
| @@ -27,10 +28,11 @@ | |||
| 27 | 28 | ||
| 28 | HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, | 29 | HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list, |
| 29 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, | 30 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, |
| 30 | Network::RoomNetwork& room_network_) | 31 | Core::System& system_) |
| 31 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), | 32 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), |
| 32 | ui(std::make_unique<Ui::HostRoom>()), | 33 | ui(std::make_unique<Ui::HostRoom>()), |
| 33 | announce_multiplayer_session(session), room_network{room_network_} { | 34 | announce_multiplayer_session(session), system{system_}, room_network{ |
| 35 | system.GetRoomNetwork()} { | ||
| 34 | ui->setupUi(this); | 36 | ui->setupUi(this); |
| 35 | 37 | ||
| 36 | // set up validation for all of the fields | 38 | // set up validation for all of the fields |
| @@ -105,6 +107,11 @@ std::unique_ptr<Network::VerifyUser::Backend> HostRoomWindow::CreateVerifyBacken | |||
| 105 | } | 107 | } |
| 106 | 108 | ||
| 107 | void HostRoomWindow::Host() { | 109 | void HostRoomWindow::Host() { |
| 110 | if (!Network::GetSelectedNetworkInterface()) { | ||
| 111 | NetworkMessage::ErrorManager::ShowError( | ||
| 112 | NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED); | ||
| 113 | return; | ||
| 114 | } | ||
| 108 | if (!ui->username->hasAcceptableInput()) { | 115 | if (!ui->username->hasAcceptableInput()) { |
| 109 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID); | 116 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::USERNAME_NOT_VALID); |
| 110 | return; | 117 | return; |
| @@ -121,6 +128,11 @@ void HostRoomWindow::Host() { | |||
| 121 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::GAME_NOT_SELECTED); | 128 | NetworkMessage::ErrorManager::ShowError(NetworkMessage::ErrorManager::GAME_NOT_SELECTED); |
| 122 | return; | 129 | return; |
| 123 | } | 130 | } |
| 131 | if (system.IsPoweredOn()) { | ||
| 132 | if (!NetworkMessage::WarnGameRunning()) { | ||
| 133 | return; | ||
| 134 | } | ||
| 135 | } | ||
| 124 | if (auto member = room_network.GetRoomMember().lock()) { | 136 | if (auto member = room_network.GetRoomMember().lock()) { |
| 125 | if (member->GetState() == Network::RoomMember::State::Joining) { | 137 | if (member->GetState() == Network::RoomMember::State::Joining) { |
| 126 | return; | 138 | return; |
diff --git a/src/yuzu/multiplayer/host_room.h b/src/yuzu/multiplayer/host_room.h index a968042d0..63c0d2333 100644 --- a/src/yuzu/multiplayer/host_room.h +++ b/src/yuzu/multiplayer/host_room.h | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include <QSortFilterProxyModel> | 8 | #include <QSortFilterProxyModel> |
| 9 | #include <QStandardItemModel> | 9 | #include <QStandardItemModel> |
| 10 | #include <QVariant> | 10 | #include <QVariant> |
| 11 | #include "core/core.h" | ||
| 11 | #include "network/network.h" | 12 | #include "network/network.h" |
| 12 | #include "yuzu/multiplayer/chat_room.h" | 13 | #include "yuzu/multiplayer/chat_room.h" |
| 13 | #include "yuzu/multiplayer/validation.h" | 14 | #include "yuzu/multiplayer/validation.h" |
| @@ -35,7 +36,7 @@ class HostRoomWindow : public QDialog { | |||
| 35 | public: | 36 | public: |
| 36 | explicit HostRoomWindow(QWidget* parent, QStandardItemModel* list, | 37 | explicit HostRoomWindow(QWidget* parent, QStandardItemModel* list, |
| 37 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, | 38 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, |
| 38 | Network::RoomNetwork& room_network_); | 39 | Core::System& system_); |
| 39 | ~HostRoomWindow(); | 40 | ~HostRoomWindow(); |
| 40 | 41 | ||
| 41 | /** | 42 | /** |
| @@ -54,6 +55,7 @@ private: | |||
| 54 | QStandardItemModel* game_list; | 55 | QStandardItemModel* game_list; |
| 55 | ComboBoxProxyModel* proxy; | 56 | ComboBoxProxyModel* proxy; |
| 56 | Validation validation; | 57 | Validation validation; |
| 58 | Core::System& system; | ||
| 57 | Network::RoomNetwork& room_network; | 59 | Network::RoomNetwork& room_network; |
| 58 | }; | 60 | }; |
| 59 | 61 | ||
diff --git a/src/yuzu/multiplayer/lobby.cpp b/src/yuzu/multiplayer/lobby.cpp index 1cc518279..c5fb846c7 100644 --- a/src/yuzu/multiplayer/lobby.cpp +++ b/src/yuzu/multiplayer/lobby.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <QtConcurrent/QtConcurrentRun> | 6 | #include <QtConcurrent/QtConcurrentRun> |
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "core/internal_network/network_interface.h" | ||
| 9 | #include "network/network.h" | 10 | #include "network/network.h" |
| 10 | #include "ui_lobby.h" | 11 | #include "ui_lobby.h" |
| 11 | #include "yuzu/game_list_p.h" | 12 | #include "yuzu/game_list_p.h" |
| @@ -22,11 +23,11 @@ | |||
| 22 | #endif | 23 | #endif |
| 23 | 24 | ||
| 24 | Lobby::Lobby(QWidget* parent, QStandardItemModel* list, | 25 | Lobby::Lobby(QWidget* parent, QStandardItemModel* list, |
| 25 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, | 26 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, Core::System& system_) |
| 26 | Network::RoomNetwork& room_network_) | ||
| 27 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), | 27 | : QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint), |
| 28 | ui(std::make_unique<Ui::Lobby>()), | 28 | ui(std::make_unique<Ui::Lobby>()), |
| 29 | announce_multiplayer_session(session), room_network{room_network_} { | 29 | announce_multiplayer_session(session), system{system_}, room_network{ |
| 30 | system.GetRoomNetwork()} { | ||
| 30 | ui->setupUi(this); | 31 | ui->setupUi(this); |
| 31 | 32 | ||
| 32 | // setup the watcher for background connections | 33 | // setup the watcher for background connections |
| @@ -114,6 +115,18 @@ void Lobby::OnExpandRoom(const QModelIndex& index) { | |||
| 114 | } | 115 | } |
| 115 | 116 | ||
| 116 | void Lobby::OnJoinRoom(const QModelIndex& source) { | 117 | void Lobby::OnJoinRoom(const QModelIndex& source) { |
| 118 | if (!Network::GetSelectedNetworkInterface()) { | ||
| 119 | NetworkMessage::ErrorManager::ShowError( | ||
| 120 | NetworkMessage::ErrorManager::NO_INTERFACE_SELECTED); | ||
| 121 | return; | ||
| 122 | } | ||
| 123 | |||
| 124 | if (system.IsPoweredOn()) { | ||
| 125 | if (!NetworkMessage::WarnGameRunning()) { | ||
| 126 | return; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 117 | if (const auto member = room_network.GetRoomMember().lock()) { | 130 | if (const auto member = room_network.GetRoomMember().lock()) { |
| 118 | // Prevent the user from trying to join a room while they are already joining. | 131 | // Prevent the user from trying to join a room while they are already joining. |
| 119 | if (member->GetState() == Network::RoomMember::State::Joining) { | 132 | if (member->GetState() == Network::RoomMember::State::Joining) { |
diff --git a/src/yuzu/multiplayer/lobby.h b/src/yuzu/multiplayer/lobby.h index 02cc766e4..49fd4c473 100644 --- a/src/yuzu/multiplayer/lobby.h +++ b/src/yuzu/multiplayer/lobby.h | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <QSortFilterProxyModel> | 9 | #include <QSortFilterProxyModel> |
| 10 | #include <QStandardItemModel> | 10 | #include <QStandardItemModel> |
| 11 | #include "common/announce_multiplayer_room.h" | 11 | #include "common/announce_multiplayer_room.h" |
| 12 | #include "core/core.h" | ||
| 12 | #include "network/announce_multiplayer_session.h" | 13 | #include "network/announce_multiplayer_session.h" |
| 13 | #include "network/network.h" | 14 | #include "network/network.h" |
| 14 | #include "yuzu/multiplayer/validation.h" | 15 | #include "yuzu/multiplayer/validation.h" |
| @@ -30,7 +31,7 @@ class Lobby : public QDialog { | |||
| 30 | public: | 31 | public: |
| 31 | explicit Lobby(QWidget* parent, QStandardItemModel* list, | 32 | explicit Lobby(QWidget* parent, QStandardItemModel* list, |
| 32 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, | 33 | std::shared_ptr<Core::AnnounceMultiplayerSession> session, |
| 33 | Network::RoomNetwork& room_network_); | 34 | Core::System& system_); |
| 34 | ~Lobby() override; | 35 | ~Lobby() override; |
| 35 | 36 | ||
| 36 | /** | 37 | /** |
| @@ -94,6 +95,7 @@ private: | |||
| 94 | std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; | 95 | std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session; |
| 95 | QFutureWatcher<void>* watcher; | 96 | QFutureWatcher<void>* watcher; |
| 96 | Validation validation; | 97 | Validation validation; |
| 98 | Core::System& system; | ||
| 97 | Network::RoomNetwork& room_network; | 99 | Network::RoomNetwork& room_network; |
| 98 | }; | 100 | }; |
| 99 | 101 | ||
diff --git a/src/yuzu/multiplayer/message.cpp b/src/yuzu/multiplayer/message.cpp index 94d7a38b8..758b5b731 100644 --- a/src/yuzu/multiplayer/message.cpp +++ b/src/yuzu/multiplayer/message.cpp | |||
| @@ -49,6 +49,9 @@ const ConnectionError ErrorManager::PERMISSION_DENIED( | |||
| 49 | QT_TR_NOOP("You do not have enough permission to perform this action.")); | 49 | QT_TR_NOOP("You do not have enough permission to perform this action.")); |
| 50 | const ConnectionError ErrorManager::NO_SUCH_USER(QT_TR_NOOP( | 50 | const ConnectionError ErrorManager::NO_SUCH_USER(QT_TR_NOOP( |
| 51 | "The user you are trying to kick/ban could not be found.\nThey may have left the room.")); | 51 | "The user you are trying to kick/ban could not be found.\nThey may have left the room.")); |
| 52 | const ConnectionError ErrorManager::NO_INTERFACE_SELECTED( | ||
| 53 | QT_TR_NOOP("No network interface is selected.\nPlease go to Configure -> System -> Network and " | ||
| 54 | "make a selection.")); | ||
| 52 | 55 | ||
| 53 | static bool WarnMessage(const std::string& title, const std::string& text) { | 56 | static bool WarnMessage(const std::string& title, const std::string& text) { |
| 54 | return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()), | 57 | return QMessageBox::Ok == QMessageBox::warning(nullptr, QObject::tr(title.c_str()), |
| @@ -60,6 +63,13 @@ void ErrorManager::ShowError(const ConnectionError& e) { | |||
| 60 | QMessageBox::critical(nullptr, tr("Error"), tr(e.GetString().c_str())); | 63 | QMessageBox::critical(nullptr, tr("Error"), tr(e.GetString().c_str())); |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 66 | bool WarnGameRunning() { | ||
| 67 | return WarnMessage( | ||
| 68 | QT_TR_NOOP("Game already running"), | ||
| 69 | QT_TR_NOOP("Joining a room when the game is already running is discouraged " | ||
| 70 | "and can cause the room feature not to work correctly.\nProceed anyway?")); | ||
| 71 | } | ||
| 72 | |||
| 63 | bool WarnCloseRoom() { | 73 | bool WarnCloseRoom() { |
| 64 | return WarnMessage( | 74 | return WarnMessage( |
| 65 | QT_TR_NOOP("Leave Room"), | 75 | QT_TR_NOOP("Leave Room"), |
diff --git a/src/yuzu/multiplayer/message.h b/src/yuzu/multiplayer/message.h index 812495c72..f038b9a1f 100644 --- a/src/yuzu/multiplayer/message.h +++ b/src/yuzu/multiplayer/message.h | |||
| @@ -43,11 +43,20 @@ public: | |||
| 43 | static const ConnectionError IP_COLLISION; | 43 | static const ConnectionError IP_COLLISION; |
| 44 | static const ConnectionError PERMISSION_DENIED; | 44 | static const ConnectionError PERMISSION_DENIED; |
| 45 | static const ConnectionError NO_SUCH_USER; | 45 | static const ConnectionError NO_SUCH_USER; |
| 46 | static const ConnectionError NO_INTERFACE_SELECTED; | ||
| 46 | /** | 47 | /** |
| 47 | * Shows a standard QMessageBox with a error message | 48 | * Shows a standard QMessageBox with a error message |
| 48 | */ | 49 | */ |
| 49 | static void ShowError(const ConnectionError& e); | 50 | static void ShowError(const ConnectionError& e); |
| 50 | }; | 51 | }; |
| 52 | |||
| 53 | /** | ||
| 54 | * Show a standard QMessageBox with a warning message about joining a room when | ||
| 55 | * the game is already running | ||
| 56 | * return true if the user wants to close the network connection | ||
| 57 | */ | ||
| 58 | bool WarnGameRunning(); | ||
| 59 | |||
| 51 | /** | 60 | /** |
| 52 | * Show a standard QMessageBox with a warning message about leaving the room | 61 | * Show a standard QMessageBox with a warning message about leaving the room |
| 53 | * return true if the user wants to close the network connection | 62 | * return true if the user wants to close the network connection |
diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp index dba76b22b..d1a68b182 100644 --- a/src/yuzu/multiplayer/state.cpp +++ b/src/yuzu/multiplayer/state.cpp | |||
| @@ -19,10 +19,9 @@ | |||
| 19 | #include "yuzu/util/clickable_label.h" | 19 | #include "yuzu/util/clickable_label.h" |
| 20 | 20 | ||
| 21 | MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_, | 21 | MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_list_model_, |
| 22 | QAction* leave_room_, QAction* show_room_, | 22 | QAction* leave_room_, QAction* show_room_, Core::System& system_) |
| 23 | Network::RoomNetwork& room_network_) | ||
| 24 | : QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_), | 23 | : QWidget(parent), game_list_model(game_list_model_), leave_room(leave_room_), |
| 25 | show_room(show_room_), room_network{room_network_} { | 24 | show_room(show_room_), system{system_}, room_network{system.GetRoomNetwork()} { |
| 26 | if (auto member = room_network.GetRoomMember().lock()) { | 25 | if (auto member = room_network.GetRoomMember().lock()) { |
| 27 | // register the network structs to use in slots and signals | 26 | // register the network structs to use in slots and signals |
| 28 | state_callback_handle = member->BindOnStateChanged( | 27 | state_callback_handle = member->BindOnStateChanged( |
| @@ -208,15 +207,14 @@ static void BringWidgetToFront(QWidget* widget) { | |||
| 208 | 207 | ||
| 209 | void MultiplayerState::OnViewLobby() { | 208 | void MultiplayerState::OnViewLobby() { |
| 210 | if (lobby == nullptr) { | 209 | if (lobby == nullptr) { |
| 211 | lobby = new Lobby(this, game_list_model, announce_multiplayer_session, room_network); | 210 | lobby = new Lobby(this, game_list_model, announce_multiplayer_session, system); |
| 212 | } | 211 | } |
| 213 | BringWidgetToFront(lobby); | 212 | BringWidgetToFront(lobby); |
| 214 | } | 213 | } |
| 215 | 214 | ||
| 216 | void MultiplayerState::OnCreateRoom() { | 215 | void MultiplayerState::OnCreateRoom() { |
| 217 | if (host_room == nullptr) { | 216 | if (host_room == nullptr) { |
| 218 | host_room = | 217 | host_room = new HostRoomWindow(this, game_list_model, announce_multiplayer_session, system); |
| 219 | new HostRoomWindow(this, game_list_model, announce_multiplayer_session, room_network); | ||
| 220 | } | 218 | } |
| 221 | BringWidgetToFront(host_room); | 219 | BringWidgetToFront(host_room); |
| 222 | } | 220 | } |
| @@ -279,7 +277,7 @@ void MultiplayerState::OnOpenNetworkRoom() { | |||
| 279 | 277 | ||
| 280 | void MultiplayerState::OnDirectConnectToRoom() { | 278 | void MultiplayerState::OnDirectConnectToRoom() { |
| 281 | if (direct_connect == nullptr) { | 279 | if (direct_connect == nullptr) { |
| 282 | direct_connect = new DirectConnectWindow(room_network, this); | 280 | direct_connect = new DirectConnectWindow(system, this); |
| 283 | } | 281 | } |
| 284 | BringWidgetToFront(direct_connect); | 282 | BringWidgetToFront(direct_connect); |
| 285 | } | 283 | } |
diff --git a/src/yuzu/multiplayer/state.h b/src/yuzu/multiplayer/state.h index 23960414e..3921f2fc3 100644 --- a/src/yuzu/multiplayer/state.h +++ b/src/yuzu/multiplayer/state.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <QWidget> | 6 | #include <QWidget> |
| 7 | #include "core/core.h" | ||
| 7 | #include "network/announce_multiplayer_session.h" | 8 | #include "network/announce_multiplayer_session.h" |
| 8 | #include "network/network.h" | 9 | #include "network/network.h" |
| 9 | 10 | ||
| @@ -19,7 +20,7 @@ class MultiplayerState : public QWidget { | |||
| 19 | 20 | ||
| 20 | public: | 21 | public: |
| 21 | explicit MultiplayerState(QWidget* parent, QStandardItemModel* game_list, QAction* leave_room, | 22 | explicit MultiplayerState(QWidget* parent, QStandardItemModel* game_list, QAction* leave_room, |
| 22 | QAction* show_room, Network::RoomNetwork& room_network_); | 23 | QAction* show_room, Core::System& system_); |
| 23 | ~MultiplayerState(); | 24 | ~MultiplayerState(); |
| 24 | 25 | ||
| 25 | /** | 26 | /** |
| @@ -86,6 +87,7 @@ private: | |||
| 86 | Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle; | 87 | Network::RoomMember::CallbackHandle<Network::RoomMember::Error> error_callback_handle; |
| 87 | 88 | ||
| 88 | bool show_notification = false; | 89 | bool show_notification = false; |
| 90 | Core::System& system; | ||
| 89 | Network::RoomNetwork& room_network; | 91 | Network::RoomNetwork& room_network; |
| 90 | }; | 92 | }; |
| 91 | 93 | ||