mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-03-16 10:38:32 +01:00
citra_qt: Allow to set server address on room_create
1
This commit is contained in:
parent
43dbe42b29
commit
abca0803d1
@ -3,12 +3,16 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <future>
|
#include <future>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QHostInfo>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
#include <QNetworkInterface>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
#include "citra_qt/game_list_p.h"
|
#include "citra_qt/game_list_p.h"
|
||||||
@ -49,6 +53,7 @@ HostRoomWindow::HostRoomWindow(Core::System& system_, QWidget* parent, QStandard
|
|||||||
|
|
||||||
// Connect all the widgets to the appropriate events
|
// Connect all the widgets to the appropriate events
|
||||||
connect(ui->host, &QPushButton::clicked, this, &HostRoomWindow::Host);
|
connect(ui->host, &QPushButton::clicked, this, &HostRoomWindow::Host);
|
||||||
|
connect(ui->copy_ip_button, &QPushButton::clicked, this, &HostRoomWindow::CopyIPToClipboard);
|
||||||
|
|
||||||
// Restore the settings:
|
// Restore the settings:
|
||||||
ui->username->setText(UISettings::values.room_nickname);
|
ui->username->setText(UISettings::values.room_nickname);
|
||||||
@ -68,6 +73,8 @@ HostRoomWindow::HostRoomWindow(Core::System& system_, QWidget* parent, QStandard
|
|||||||
ui->game_list->setCurrentIndex(index);
|
ui->game_list->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
ui->room_description->setText(UISettings::values.room_description);
|
ui->room_description->setText(UISettings::values.room_description);
|
||||||
|
|
||||||
|
SetLocalIPAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
HostRoomWindow::~HostRoomWindow() = default;
|
HostRoomWindow::~HostRoomWindow() = default;
|
||||||
@ -130,6 +137,7 @@ void HostRoomWindow::Host() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui->host->setDisabled(true);
|
ui->host->setDisabled(true);
|
||||||
|
std::string ip_address = ui->server_address_box->text().toStdString();
|
||||||
|
|
||||||
auto game_name = ui->game_list->currentData(Qt::DisplayRole).toString();
|
auto game_name = ui->game_list->currentData(Qt::DisplayRole).toString();
|
||||||
auto game_id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong();
|
auto game_id = ui->game_list->currentData(GameListItemPath::ProgramIdRole).toLongLong();
|
||||||
@ -141,11 +149,12 @@ void HostRoomWindow::Host() {
|
|||||||
ban_list = UISettings::values.ban_list;
|
ban_list = UISettings::values.ban_list;
|
||||||
}
|
}
|
||||||
if (auto room = Network::GetRoom().lock()) {
|
if (auto room = Network::GetRoom().lock()) {
|
||||||
bool created = room->Create(ui->room_name->text().toStdString(),
|
bool created =
|
||||||
ui->room_description->toPlainText().toStdString(), "",
|
room->Create(ui->room_name->text().toStdString(),
|
||||||
static_cast<u16>(port), password, ui->max_player->value(),
|
ui->room_description->toPlainText().toStdString(), ip_address,
|
||||||
NetSettings::values.citra_username, game_name.toStdString(),
|
static_cast<u16>(port), password, ui->max_player->value(),
|
||||||
game_id, CreateVerifyBackend(is_public), ban_list);
|
NetSettings::values.citra_username, game_name.toStdString(), game_id,
|
||||||
|
CreateVerifyBackend(is_public), ban_list);
|
||||||
if (!created) {
|
if (!created) {
|
||||||
NetworkMessage::ErrorManager::ShowError(
|
NetworkMessage::ErrorManager::ShowError(
|
||||||
NetworkMessage::ErrorManager::COULD_NOT_CREATE_ROOM);
|
NetworkMessage::ErrorManager::COULD_NOT_CREATE_ROOM);
|
||||||
@ -193,8 +202,8 @@ void HostRoomWindow::Host() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
member->Join(ui->username->text().toStdString(), Service::CFG::GetConsoleIdHash(system),
|
member->Join(ui->username->text().toStdString(), Service::CFG::GetConsoleIdHash(system),
|
||||||
"127.0.0.1", static_cast<u16>(port), 0, Network::NoPreferredMac, password,
|
ip_address.c_str(), static_cast<u16>(port), 0, Network::NoPreferredMac,
|
||||||
token);
|
password, token);
|
||||||
|
|
||||||
// Store settings
|
// Store settings
|
||||||
UISettings::values.room_nickname = ui->username->text();
|
UISettings::values.room_nickname = ui->username->text();
|
||||||
@ -234,3 +243,26 @@ bool ComboBoxProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
|
|||||||
auto rightData = right.data(GameListItemPath::TitleRole).toString();
|
auto rightData = right.data(GameListItemPath::TitleRole).toString();
|
||||||
return leftData.compare(rightData) < 0;
|
return leftData.compare(rightData) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HostRoomWindow::SetLocalIPAddress() {
|
||||||
|
QString local_ip;
|
||||||
|
|
||||||
|
foreach (const QHostAddress& address, QNetworkInterface::allAddresses()) {
|
||||||
|
if (address.protocol() == QAbstractSocket::IPv4Protocol &&
|
||||||
|
address != QHostAddress(QHostAddress::LocalHost)) {
|
||||||
|
local_ip = address.toString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!local_ip.isEmpty()) {
|
||||||
|
ui->server_address_box->setText(local_ip);
|
||||||
|
} else {
|
||||||
|
ui->server_address_box->setPlaceholderText(tr("Enter Server Address"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void HostRoomWindow::CopyIPToClipboard() {
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(ui->server_address_box->text());
|
||||||
|
}
|
||||||
|
@ -49,6 +49,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Host();
|
void Host();
|
||||||
|
void SetLocalIPAddress();
|
||||||
|
void CopyIPToClipboard();
|
||||||
std::unique_ptr<Network::VerifyUser::Backend> CreateVerifyBackend(bool use_validation) const;
|
std::unique_ptr<Network::VerifyUser::Backend> CreateVerifyBackend(bool use_validation) const;
|
||||||
|
|
||||||
std::unique_ptr<Ui::HostRoom> ui;
|
std::unique_ptr<Ui::HostRoom> ui;
|
||||||
|
@ -7,13 +7,34 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>607</width>
|
<width>607</width>
|
||||||
<height>211</height>
|
<height>236</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Create Room</string>
|
<string>Create Room</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="server_address_label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Server Address:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="server_address_box"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="copy_ip_button">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="settings" native="true">
|
<widget class="QWidget" name="settings" native="true">
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout">
|
||||||
@ -31,38 +52,38 @@
|
|||||||
<property name="labelAlignment">
|
<property name="labelAlignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Room Name</string>
|
<string>Room Name</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="room_name">
|
<widget class="QLineEdit" name="room_name">
|
||||||
<property name="maxLength">
|
<property name="maxLength">
|
||||||
<number>50</number>
|
<number>50</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Preferred Application</string>
|
<string>Preferred Application</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="game_list"/>
|
<widget class="QComboBox" name="game_list"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Max Players</string>
|
<string>Max Players</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QSpinBox" name="max_player">
|
<widget class="QSpinBox" name="max_player">
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
@ -82,9 +103,6 @@
|
|||||||
<property name="labelAlignment">
|
<property name="labelAlignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLineEdit" name="username"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -92,6 +110,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="username"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Password</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="password">
|
<widget class="QLineEdit" name="password">
|
||||||
<property name="echoMode">
|
<property name="echoMode">
|
||||||
@ -102,6 +130,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Port</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="port">
|
<widget class="QLineEdit" name="port">
|
||||||
<property name="inputMethodHints">
|
<property name="inputMethodHints">
|
||||||
@ -112,20 +147,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Port</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user