Fix player list not showing in lobby. Fix host and direct connect crashing citra
This commit is contained in:
parent
01b49b7e78
commit
2be02f221d
11 changed files with 68 additions and 31 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include "citra_qt/multiplayer/message.h"
|
#include "citra_qt/multiplayer/message.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/announce_multiplayer_session.h"
|
#include "core/announce_multiplayer_session.h"
|
||||||
|
#include "ui_chat_room.h"
|
||||||
|
|
||||||
class ChatMessage {
|
class ChatMessage {
|
||||||
public:
|
public:
|
||||||
|
@ -102,6 +103,8 @@ ChatRoom::ChatRoom(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::C
|
||||||
connect(ui->send_message, &QPushButton::pressed, this, &ChatRoom::OnSendChat);
|
connect(ui->send_message, &QPushButton::pressed, this, &ChatRoom::OnSendChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChatRoom::~ChatRoom() = default;
|
||||||
|
|
||||||
void ChatRoom::Clear() {
|
void ChatRoom::Clear() {
|
||||||
ui->chat_history->clear();
|
ui->chat_history->clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "ui_chat_room.h"
|
|
||||||
|
namespace Ui {
|
||||||
|
class ChatRoom;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class AnnounceMultiplayerSession;
|
class AnnounceMultiplayerSession;
|
||||||
|
@ -29,6 +32,7 @@ public:
|
||||||
void SetPlayerList(const Network::RoomMember::MemberList& member_list);
|
void SetPlayerList(const Network::RoomMember::MemberList& member_list);
|
||||||
void Clear();
|
void Clear();
|
||||||
void AppendStatusMessage(const QString& msg);
|
void AppendStatusMessage(const QString& msg);
|
||||||
|
~ChatRoom();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnRoomUpdate(const Network::RoomInformation& info);
|
void OnRoomUpdate(const Network::RoomInformation& info);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "citra_qt/multiplayer/message.h"
|
#include "citra_qt/multiplayer/message.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/announce_multiplayer_session.h"
|
#include "core/announce_multiplayer_session.h"
|
||||||
|
#include "ui_client_room.h"
|
||||||
|
|
||||||
ClientRoomWindow::ClientRoomWindow(QWidget* parent)
|
ClientRoomWindow::ClientRoomWindow(QWidget* parent)
|
||||||
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
|
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowSystemMenuHint),
|
||||||
|
@ -41,6 +42,8 @@ ClientRoomWindow::ClientRoomWindow(QWidget* parent)
|
||||||
UpdateView();
|
UpdateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClientRoomWindow::~ClientRoomWindow() = default;
|
||||||
|
|
||||||
void ClientRoomWindow::OnRoomUpdate(const Network::RoomInformation& info) {
|
void ClientRoomWindow::OnRoomUpdate(const Network::RoomInformation& info) {
|
||||||
UpdateView();
|
UpdateView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "citra_qt/multiplayer/chat_room.h"
|
#include "citra_qt/multiplayer/chat_room.h"
|
||||||
#include "ui_client_room.h"
|
|
||||||
|
namespace Ui {
|
||||||
|
class ClientRoom;
|
||||||
|
}
|
||||||
|
|
||||||
class ClientRoomWindow : public QDialog {
|
class ClientRoomWindow : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ClientRoomWindow(QWidget* parent);
|
explicit ClientRoomWindow(QWidget* parent);
|
||||||
|
~ClientRoomWindow();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void OnRoomUpdate(const Network::RoomInformation&);
|
void OnRoomUpdate(const Network::RoomInformation&);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "citra_qt/ui_settings.h"
|
#include "citra_qt/ui_settings.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
#include "ui_direct_connect.h"
|
||||||
|
|
||||||
enum class ConnectionType : u8 { TraversalServer, IP };
|
enum class ConnectionType : u8 { TraversalServer, IP };
|
||||||
|
|
||||||
|
@ -30,11 +31,11 @@ DirectConnectWindow::DirectConnectWindow(QWidget* parent)
|
||||||
watcher = new QFutureWatcher<void>;
|
watcher = new QFutureWatcher<void>;
|
||||||
connect(watcher, &QFutureWatcher<void>::finished, this, &DirectConnectWindow::OnConnection);
|
connect(watcher, &QFutureWatcher<void>::finished, this, &DirectConnectWindow::OnConnection);
|
||||||
|
|
||||||
ui->nickname->setValidator(Validation::get().nickname);
|
ui->nickname->setValidator(validation.GetNickname());
|
||||||
ui->nickname->setText(UISettings::values.nickname);
|
ui->nickname->setText(UISettings::values.nickname);
|
||||||
ui->ip->setValidator(Validation::get().ip);
|
ui->ip->setValidator(validation.GetIP());
|
||||||
ui->ip->setText(UISettings::values.ip);
|
ui->ip->setText(UISettings::values.ip);
|
||||||
ui->port->setValidator(Validation::get().port);
|
ui->port->setValidator(validation.GetPort());
|
||||||
ui->port->setText(UISettings::values.port);
|
ui->port->setText(UISettings::values.port);
|
||||||
|
|
||||||
// TODO(jroweboy): Show or hide the connection options based on the current value of the combo
|
// TODO(jroweboy): Show or hide the connection options based on the current value of the combo
|
||||||
|
@ -42,6 +43,8 @@ DirectConnectWindow::DirectConnectWindow(QWidget* parent)
|
||||||
connect(ui->connect, &QPushButton::pressed, this, &DirectConnectWindow::Connect);
|
connect(ui->connect, &QPushButton::pressed, this, &DirectConnectWindow::Connect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DirectConnectWindow::~DirectConnectWindow() = default;
|
||||||
|
|
||||||
void DirectConnectWindow::Connect() {
|
void DirectConnectWindow::Connect() {
|
||||||
if (!ui->nickname->hasAcceptableInput()) {
|
if (!ui->nickname->hasAcceptableInput()) {
|
||||||
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
||||||
|
|
|
@ -7,13 +7,18 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include "ui_direct_connect.h"
|
#include "citra_qt/multiplayer/validation.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DirectConnect;
|
||||||
|
}
|
||||||
|
|
||||||
class DirectConnectWindow : public QDialog {
|
class DirectConnectWindow : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DirectConnectWindow(QWidget* parent = nullptr);
|
explicit DirectConnectWindow(QWidget* parent = nullptr);
|
||||||
|
~DirectConnectWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -32,4 +37,5 @@ private:
|
||||||
|
|
||||||
QFutureWatcher<void>* watcher;
|
QFutureWatcher<void>* watcher;
|
||||||
std::unique_ptr<Ui::DirectConnect> ui;
|
std::unique_ptr<Ui::DirectConnect> ui;
|
||||||
|
Validation validation;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/announce_multiplayer_session.h"
|
#include "core/announce_multiplayer_session.h"
|
||||||
#include "core/settings.h"
|
#include "core/settings.h"
|
||||||
|
#include "ui_host_room.h"
|
||||||
|
|
||||||
HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session)
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session)
|
||||||
|
@ -28,9 +29,9 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// set up validation for all of the fields
|
// set up validation for all of the fields
|
||||||
ui->room_name->setValidator(Validation::get().room_name);
|
ui->room_name->setValidator(validation.GetRoomName());
|
||||||
ui->username->setValidator(Validation::get().nickname);
|
ui->username->setValidator(validation.GetNickname());
|
||||||
ui->port->setValidator(Validation::get().port);
|
ui->port->setValidator(validation.GetPort());
|
||||||
ui->port->setPlaceholderText(QString::number(Network::DefaultRoomPort));
|
ui->port->setPlaceholderText(QString::number(Network::DefaultRoomPort));
|
||||||
|
|
||||||
// Create a proxy to the game list to display the list of preferred games
|
// Create a proxy to the game list to display the list of preferred games
|
||||||
|
@ -57,6 +58,8 @@ HostRoomWindow::HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HostRoomWindow::~HostRoomWindow() = default;
|
||||||
|
|
||||||
void HostRoomWindow::Host() {
|
void HostRoomWindow::Host() {
|
||||||
if (!ui->username->hasAcceptableInput()) {
|
if (!ui->username->hasAcceptableInput()) {
|
||||||
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
NetworkMessage::ShowError(NetworkMessage::USERNAME_NOT_VALID);
|
||||||
|
|
|
@ -10,8 +10,12 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include "citra_qt/multiplayer/chat_room.h"
|
#include "citra_qt/multiplayer/chat_room.h"
|
||||||
|
#include "citra_qt/multiplayer/validation.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
#include "ui_host_room.h"
|
|
||||||
|
namespace Ui {
|
||||||
|
class HostRoom;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class AnnounceMultiplayerSession;
|
class AnnounceMultiplayerSession;
|
||||||
|
@ -28,6 +32,7 @@ class HostRoomWindow : public QDialog {
|
||||||
public:
|
public:
|
||||||
explicit HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
explicit HostRoomWindow(QWidget* parent, QStandardItemModel* list,
|
||||||
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
std::shared_ptr<Core::AnnounceMultiplayerSession> session);
|
||||||
|
~HostRoomWindow();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
|
@ -50,6 +55,7 @@ private:
|
||||||
QStandardItemModel* game_list;
|
QStandardItemModel* game_list;
|
||||||
ComboBoxProxyModel* proxy;
|
ComboBoxProxyModel* proxy;
|
||||||
std::unique_ptr<Ui::HostRoom> ui;
|
std::unique_ptr<Ui::HostRoom> ui;
|
||||||
|
Validation validation;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -47,7 +47,7 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||||
ui->room_list->setExpandsOnDoubleClick(false);
|
ui->room_list->setExpandsOnDoubleClick(false);
|
||||||
ui->room_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
ui->room_list->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
ui->nickname->setValidator(Validation::get().nickname);
|
ui->nickname->setValidator(validation.GetNickname());
|
||||||
ui->nickname->setText(UISettings::values.nickname);
|
ui->nickname->setText(UISettings::values.nickname);
|
||||||
|
|
||||||
// UI Buttons
|
// UI Buttons
|
||||||
|
@ -189,7 +189,6 @@ void Lobby::OnRefreshLobby() {
|
||||||
first_item->appendRow(new LobbyItemExpandedMemberList(members));
|
first_item->appendRow(new LobbyItemExpandedMemberList(members));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
proxy->setSourceModel(model);
|
|
||||||
|
|
||||||
// Reenable the refresh button and resize the columns
|
// Reenable the refresh button and resize the columns
|
||||||
ui->refresh_list->setEnabled(true);
|
ui->refresh_list->setEnabled(true);
|
||||||
|
@ -200,10 +199,10 @@ void Lobby::OnRefreshLobby() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the member list child items to span all columns
|
// Set the member list child items to span all columns
|
||||||
for (int i = 0; i < model->rowCount(); i++) {
|
for (int i = 0; i < proxy->rowCount(); i++) {
|
||||||
auto parent = model->item(i, 0);
|
auto parent = model->item(i, 0);
|
||||||
if (parent->hasChildren()) {
|
if (parent->hasChildren()) {
|
||||||
ui->room_list->setFirstColumnSpanned(0, parent->index(), true);
|
ui->room_list->setFirstColumnSpanned(0, proxy->index(i, 0), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include "citra_qt/multiplayer/validation.h"
|
||||||
#include "common/announce_multiplayer_room.h"
|
#include "common/announce_multiplayer_room.h"
|
||||||
#include "core/announce_multiplayer_session.h"
|
#include "core/announce_multiplayer_session.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
@ -104,6 +105,7 @@ private:
|
||||||
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
std::weak_ptr<Core::AnnounceMultiplayerSession> announce_multiplayer_session;
|
||||||
std::unique_ptr<Ui::Lobby> ui;
|
std::unique_ptr<Ui::Lobby> ui;
|
||||||
QFutureWatcher<void>* watcher;
|
QFutureWatcher<void>* watcher;
|
||||||
|
Validation validation;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -9,36 +9,40 @@
|
||||||
|
|
||||||
class Validation {
|
class Validation {
|
||||||
public:
|
public:
|
||||||
static Validation get() {
|
Validation()
|
||||||
static Validation validation;
|
: room_name(room_name_regex), nickname(nickname_regex), ip(ip_regex), port(0, 65535) {}
|
||||||
return validation;
|
|
||||||
}
|
~Validation() = default;
|
||||||
|
|
||||||
~Validation() {
|
const QValidator* GetRoomName() const {
|
||||||
delete room_name;
|
return &room_name;
|
||||||
delete nickname;
|
}
|
||||||
delete ip;
|
const QValidator* GetNickname() const {
|
||||||
delete port;
|
return &nickname;
|
||||||
|
}
|
||||||
|
const QValidator* GetIP() const {
|
||||||
|
return &ip;
|
||||||
|
}
|
||||||
|
const QValidator* GetPort() const {
|
||||||
|
return &port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
/// room name can be alphanumeric and " " "_" "." and "-"
|
/// room name can be alphanumeric and " " "_" "." and "-"
|
||||||
QRegExp room_name_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
QRegExp room_name_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
||||||
const QValidator* room_name = new QRegExpValidator(room_name_regex);
|
QRegExpValidator room_name;
|
||||||
|
|
||||||
/// nickname can be alphanumeric and " " "_" "." and "-"
|
/// nickname can be alphanumeric and " " "_" "." and "-"
|
||||||
QRegExp nickname_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
QRegExp nickname_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
||||||
const QValidator* nickname = new QRegExpValidator(nickname_regex);
|
QRegExpValidator nickname;
|
||||||
|
|
||||||
/// ipv4 address only
|
/// ipv4 address only
|
||||||
// TODO remove this when we support hostnames in direct connect
|
// TODO remove this when we support hostnames in direct connect
|
||||||
QRegExp ip_regex = QRegExp(
|
QRegExp ip_regex = QRegExp(
|
||||||
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|"
|
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|"
|
||||||
"2[0-4][0-9]|25[0-5])");
|
"2[0-4][0-9]|25[0-5])");
|
||||||
const QValidator* ip = new QRegExpValidator(ip_regex);
|
QRegExpValidator ip;
|
||||||
|
|
||||||
/// port must be between 0 and 65535
|
/// port must be between 0 and 65535
|
||||||
const QValidator* port = new QIntValidator(0, 65535);
|
QIntValidator port;
|
||||||
|
|
||||||
private:
|
|
||||||
Validation() = default;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue