Merge pull request #3676 from jroweboy/minor-mp-ui-fix
Minor multiplayer ui fixes
This commit is contained in:
commit
252e5f173d
@ -13,6 +13,7 @@
|
||||
#include "citra_qt/game_list_p.h"
|
||||
#include "citra_qt/multiplayer/client_room.h"
|
||||
#include "citra_qt/multiplayer/message.h"
|
||||
#include "citra_qt/multiplayer/state.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/announce_multiplayer_session.h"
|
||||
#include "ui_client_room.h"
|
||||
@ -57,11 +58,8 @@ void ClientRoomWindow::OnStateChange(const Network::RoomMember::State& state) {
|
||||
}
|
||||
|
||||
void ClientRoomWindow::Disconnect() {
|
||||
if (!NetworkMessage::WarnDisconnect()) {
|
||||
return;
|
||||
}
|
||||
if (auto member = Network::GetRoomMember().lock()) {
|
||||
member->Leave();
|
||||
auto parent = static_cast<MultiplayerState*>(parentWidget());
|
||||
if (parent->OnCloseRoom()) {
|
||||
ui->chat->AppendStatusMessage(tr("Disconnected"));
|
||||
close();
|
||||
}
|
||||
|
@ -51,8 +51,14 @@ void DirectConnectWindow::Connect() {
|
||||
return;
|
||||
}
|
||||
if (const auto member = Network::GetRoomMember().lock()) {
|
||||
if (member->IsConnected() && !NetworkMessage::WarnDisconnect()) {
|
||||
// Prevent the user from trying to join a room while they are already joining.
|
||||
if (member->GetState() == Network::RoomMember::State::Joining) {
|
||||
return;
|
||||
} else if (member->GetState() == Network::RoomMember::State::Joined) {
|
||||
// And ask if they want to leave the room if they are already in one.
|
||||
if (!NetworkMessage::WarnDisconnect()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (static_cast<ConnectionType>(ui->connection_type->currentIndex())) {
|
||||
|
@ -74,7 +74,9 @@ void HostRoomWindow::Host() {
|
||||
return;
|
||||
}
|
||||
if (auto member = Network::GetRoomMember().lock()) {
|
||||
if (member->IsConnected()) {
|
||||
if (member->GetState() == Network::RoomMember::State::Joining) {
|
||||
return;
|
||||
} else if (member->GetState() == Network::RoomMember::State::Joined) {
|
||||
auto parent = static_cast<MultiplayerState*>(parentWidget());
|
||||
if (!parent->OnCloseRoom()) {
|
||||
close();
|
||||
|
@ -26,7 +26,6 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
|
||||
// setup the watcher for background connections
|
||||
watcher = new QFutureWatcher<void>;
|
||||
connect(watcher, &QFutureWatcher<void>::finished, [&] { joining = false; });
|
||||
|
||||
model = new QStandardItemModel(ui->room_list);
|
||||
proxy = new LobbyFilterProxyModel(this, game_list);
|
||||
@ -51,7 +50,6 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
ui->nickname->setText(UISettings::values.nickname);
|
||||
|
||||
// UI Buttons
|
||||
MultiplayerState* p = reinterpret_cast<MultiplayerState*>(parent);
|
||||
connect(ui->refresh_list, &QPushButton::pressed, this, &Lobby::RefreshLobby);
|
||||
connect(ui->games_owned, &QCheckBox::stateChanged, proxy,
|
||||
&LobbyFilterProxyModel::SetFilterOwned);
|
||||
@ -84,10 +82,17 @@ void Lobby::OnExpandRoom(const QModelIndex& index) {
|
||||
}
|
||||
|
||||
void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||
if (joining) {
|
||||
return;
|
||||
if (const auto member = Network::GetRoomMember().lock()) {
|
||||
// Prevent the user from trying to join a room while they are already joining.
|
||||
if (member->GetState() == Network::RoomMember::State::Joining) {
|
||||
return;
|
||||
} else if (member->GetState() == Network::RoomMember::State::Joined) {
|
||||
// And ask if they want to leave the room if they are already in one.
|
||||
if (!NetworkMessage::WarnDisconnect()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
joining = true;
|
||||
QModelIndex index = source;
|
||||
// If the user double clicks on a child row (aka the player list) then use the parent instead
|
||||
if (source.parent() != QModelIndex()) {
|
||||
@ -97,13 +102,6 @@ void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if (const auto member = Network::GetRoomMember().lock()) {
|
||||
if (member->IsConnected()) {
|
||||
if (!NetworkMessage::WarnDisconnect()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get a password to pass if the room is password protected
|
||||
QModelIndex password_index = proxy->index(index.row(), Column::ROOM_NAME);
|
||||
|
@ -89,7 +89,6 @@ private:
|
||||
std::unique_ptr<Ui::Lobby> ui;
|
||||
QFutureWatcher<void>* watcher;
|
||||
Validation validation;
|
||||
bool joining = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -147,6 +147,7 @@ bool MultiplayerState::OnCloseRoom() {
|
||||
// if you are in a room, leave it
|
||||
if (auto member = Network::GetRoomMember().lock()) {
|
||||
member->Leave();
|
||||
NGLOG_DEBUG(Frontend, "Left the room (as a client)");
|
||||
}
|
||||
|
||||
// if you are hosting a room, also stop hosting
|
||||
@ -155,6 +156,7 @@ bool MultiplayerState::OnCloseRoom() {
|
||||
}
|
||||
room->Destroy();
|
||||
announce_multiplayer_session->Stop();
|
||||
NGLOG_DEBUG(Frontend, "Closed the room (as a server)");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include "core/announce_multiplayer_session.h"
|
||||
#include "network/network.h"
|
||||
|
||||
class QStandardItemModel;
|
||||
@ -13,9 +14,6 @@ class HostRoomWindow;
|
||||
class ClientRoomWindow;
|
||||
class DirectConnectWindow;
|
||||
class ClickableLabel;
|
||||
namespace Core {
|
||||
class AnnounceMultiplayerSession;
|
||||
}
|
||||
|
||||
class MultiplayerState : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
Loading…
Reference in New Issue
Block a user