mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Qt/NetPlay: Integrate NetPlayIndex
This commit is contained in:
@ -98,6 +98,7 @@ add_executable(dolphin-emu
|
||||
NetPlay/ChunkedProgressDialog.cpp
|
||||
NetPlay/GameListDialog.cpp
|
||||
NetPlay/MD5Dialog.cpp
|
||||
NetPlay/NetPlayBrowser.cpp
|
||||
NetPlay/NetPlayDialog.cpp
|
||||
NetPlay/NetPlaySetupDialog.cpp
|
||||
NetPlay/PadMappingDialog.cpp
|
||||
|
@ -146,6 +146,7 @@
|
||||
<QtMoc Include="NetPlay\ChunkedProgressDialog.h" />
|
||||
<QtMoc Include="NetPlay\GameListDialog.h" />
|
||||
<QtMoc Include="NetPlay\MD5Dialog.h" />
|
||||
<QtMoc Include="NetPlay\NetPlayBrowser.h" />
|
||||
<QtMoc Include="NetPlay\NetPlayDialog.h" />
|
||||
<QtMoc Include="NetPlay\NetPlaySetupDialog.h" />
|
||||
<QtMoc Include="NetPlay\PadMappingDialog.h" />
|
||||
@ -247,6 +248,7 @@
|
||||
<ClCompile Include="$(QtMocOutPrefix)MemoryWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MenuBar.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)ModalMessageBox.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)NetPlayBrowser.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)NetPlayDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)NetPlaySetupDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)NewBreakpointDialog.cpp" />
|
||||
@ -364,6 +366,7 @@
|
||||
<ClCompile Include="NetPlay\ChunkedProgressDialog.cpp" />
|
||||
<ClCompile Include="NetPlay\GameListDialog.cpp" />
|
||||
<ClCompile Include="NetPlay\MD5Dialog.cpp" />
|
||||
<ClCompile Include="NetPlay\NetPlayBrowser.cpp" />
|
||||
<ClCompile Include="NetPlay\NetPlayDialog.cpp" />
|
||||
<ClCompile Include="NetPlay\NetPlaySetupDialog.cpp" />
|
||||
<ClCompile Include="NetPlay\PadMappingDialog.cpp" />
|
||||
|
@ -80,6 +80,7 @@
|
||||
#include "DolphinQt/HotkeyScheduler.h"
|
||||
#include "DolphinQt/MainWindow.h"
|
||||
#include "DolphinQt/MenuBar.h"
|
||||
#include "DolphinQt/NetPlay/NetPlayBrowser.h"
|
||||
#include "DolphinQt/NetPlay/NetPlayDialog.h"
|
||||
#include "DolphinQt/NetPlay/NetPlaySetupDialog.h"
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
@ -449,6 +450,7 @@ void MainWindow::ConnectMenuBar()
|
||||
connect(m_menu_bar, &MenuBar::PerformOnlineUpdate, this, &MainWindow::PerformOnlineUpdate);
|
||||
connect(m_menu_bar, &MenuBar::BootWiiSystemMenu, this, &MainWindow::BootWiiSystemMenu);
|
||||
connect(m_menu_bar, &MenuBar::StartNetPlay, this, &MainWindow::ShowNetPlaySetupDialog);
|
||||
connect(m_menu_bar, &MenuBar::BrowseNetPlay, this, &MainWindow::ShowNetPlayBrowser);
|
||||
connect(m_menu_bar, &MenuBar::ShowFIFOPlayer, this, &MainWindow::ShowFIFOPlayer);
|
||||
connect(m_menu_bar, &MenuBar::ConnectWiiRemote, this, &MainWindow::OnConnectWiiRemote);
|
||||
|
||||
@ -1125,6 +1127,13 @@ void MainWindow::ShowNetPlaySetupDialog()
|
||||
m_netplay_setup_dialog->activateWindow();
|
||||
}
|
||||
|
||||
void MainWindow::ShowNetPlayBrowser()
|
||||
{
|
||||
auto* browser = new NetPlayBrowser(this);
|
||||
connect(browser, &NetPlayBrowser::Join, this, &MainWindow::NetPlayJoin);
|
||||
browser->exec();
|
||||
}
|
||||
|
||||
void MainWindow::ShowFIFOPlayer()
|
||||
{
|
||||
if (!m_fifo_window)
|
||||
|
@ -148,6 +148,7 @@ private:
|
||||
void ShowAboutDialog();
|
||||
void ShowHotkeyDialog();
|
||||
void ShowNetPlaySetupDialog();
|
||||
void ShowNetPlayBrowser();
|
||||
void ShowFIFOPlayer();
|
||||
void ShowMemcardManager();
|
||||
void ShowResourcePackManager();
|
||||
|
@ -241,6 +241,7 @@ void MenuBar::AddToolsMenu()
|
||||
gc_ipl->addAction(tr("PAL"), this, [this] { emit BootGameCubeIPL(DiscIO::Region::PAL); });
|
||||
|
||||
tools_menu->addAction(tr("Start &NetPlay..."), this, &MenuBar::StartNetPlay);
|
||||
tools_menu->addAction(tr("Browse &NetPlay Sessions...."), this, &MenuBar::BrowseNetPlay);
|
||||
tools_menu->addAction(tr("FIFO Player"), this, &MenuBar::ShowFIFOPlayer);
|
||||
|
||||
tools_menu->addSeparator();
|
||||
|
@ -61,6 +61,7 @@ signals:
|
||||
void FrameAdvance();
|
||||
void Screenshot();
|
||||
void StartNetPlay();
|
||||
void BrowseNetPlay();
|
||||
void StateLoad();
|
||||
void StateSave();
|
||||
void StateLoadSlot();
|
||||
|
243
Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp
Normal file
243
Source/Core/DolphinQt/NetPlay/NetPlayBrowser.cpp
Normal file
@ -0,0 +1,243 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt/NetPlay/NetPlayBrowser.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHeaderView>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSpacerItem>
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "Common/Version.h"
|
||||
|
||||
#include "Core/Config/NetplaySettings.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
|
||||
NetPlayBrowser::NetPlayBrowser(QWidget* parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("NetPlay Session Browser"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
CreateWidgets();
|
||||
ConnectWidgets();
|
||||
|
||||
resize(750, 500);
|
||||
|
||||
m_table_widget->verticalHeader()->setHidden(true);
|
||||
m_table_widget->setAlternatingRowColors(true);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void NetPlayBrowser::CreateWidgets()
|
||||
{
|
||||
auto* layout = new QVBoxLayout;
|
||||
|
||||
m_table_widget = new QTableWidget;
|
||||
|
||||
m_table_widget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
m_table_widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
m_region_combo = new QComboBox;
|
||||
|
||||
m_region_combo->addItem(tr("Any Region"));
|
||||
|
||||
for (const auto& region : NetPlayIndex::GetRegions())
|
||||
{
|
||||
m_region_combo->addItem(
|
||||
tr("%1 (%2)").arg(tr(region.second.c_str())).arg(QString::fromStdString(region.first)),
|
||||
QString::fromStdString(region.first));
|
||||
}
|
||||
|
||||
m_status_label = new QLabel;
|
||||
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
m_button_refresh = new QPushButton(tr("Refresh"));
|
||||
m_edit_name = new QLineEdit;
|
||||
m_edit_game_id = new QLineEdit;
|
||||
|
||||
m_radio_all = new QRadioButton(tr("Private and Public"));
|
||||
m_radio_private = new QRadioButton(tr("Private"));
|
||||
m_radio_public = new QRadioButton(tr("Public"));
|
||||
|
||||
m_radio_all->setChecked(true);
|
||||
|
||||
auto* filter_box = new QGroupBox(tr("Filters"));
|
||||
auto* filter_layout = new QGridLayout;
|
||||
filter_box->setLayout(filter_layout);
|
||||
|
||||
filter_layout->addWidget(new QLabel(tr("Region:")), 0, 0);
|
||||
filter_layout->addWidget(m_region_combo, 0, 1);
|
||||
filter_layout->addWidget(new QLabel(tr("Name:")), 1, 0);
|
||||
filter_layout->addWidget(m_edit_name, 1, 1, 1, -1);
|
||||
filter_layout->addWidget(new QLabel(tr("Game ID:")), 2, 0);
|
||||
filter_layout->addWidget(m_edit_game_id, 2, 1, 1, -1);
|
||||
filter_layout->addWidget(m_radio_all, 3, 1);
|
||||
filter_layout->addWidget(m_radio_public, 3, 2);
|
||||
filter_layout->addWidget(m_radio_private, 3, 3);
|
||||
filter_layout->addItem(new QSpacerItem(4, 1, QSizePolicy::Expanding), 2, 4);
|
||||
|
||||
layout->addWidget(m_table_widget);
|
||||
layout->addWidget(filter_box);
|
||||
layout->addWidget(m_status_label);
|
||||
layout->addWidget(m_button_box);
|
||||
|
||||
m_button_box->addButton(m_button_refresh, QDialogButtonBox::ResetRole);
|
||||
m_button_box->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void NetPlayBrowser::ConnectWidgets()
|
||||
{
|
||||
connect(m_button_box, &QDialogButtonBox::accepted, this, &NetPlayBrowser::accept);
|
||||
connect(m_button_box, &QDialogButtonBox::rejected, this, &NetPlayBrowser::reject);
|
||||
connect(m_button_refresh, &QPushButton::pressed, this, &NetPlayBrowser::Refresh);
|
||||
|
||||
connect(m_radio_all, &QRadioButton::toggled, this, &NetPlayBrowser::Refresh);
|
||||
connect(m_radio_private, &QRadioButton::toggled, this, &NetPlayBrowser::Refresh);
|
||||
|
||||
connect(m_edit_name, &QLineEdit::textChanged, this, &NetPlayBrowser::Refresh);
|
||||
connect(m_edit_game_id, &QLineEdit::textChanged, this, &NetPlayBrowser::Refresh);
|
||||
connect(m_table_widget, &QTableWidget::itemSelectionChanged, this,
|
||||
&NetPlayBrowser::OnSelectionChanged);
|
||||
}
|
||||
|
||||
void NetPlayBrowser::Refresh()
|
||||
{
|
||||
m_status_label->setText(tr("Refreshing..."));
|
||||
|
||||
m_table_widget->clear();
|
||||
m_table_widget->setColumnCount(6);
|
||||
m_table_widget->setHorizontalHeaderLabels(
|
||||
{tr("Region"), tr("Name"), tr("Password?"), tr("In-Game?"), tr("Game"), tr("Players")});
|
||||
m_table_widget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
m_table_widget->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
m_table_widget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
m_table_widget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
||||
m_table_widget->horizontalHeader()->setSectionResizeMode(4, QHeaderView::Stretch);
|
||||
|
||||
NetPlayIndex client;
|
||||
|
||||
std::map<std::string, std::string> filters;
|
||||
|
||||
filters["version"] = Common::scm_desc_str;
|
||||
|
||||
if (!m_edit_name->text().isEmpty())
|
||||
filters["name"] = m_edit_name->text().toStdString();
|
||||
|
||||
if (!m_edit_game_id->text().isEmpty())
|
||||
filters["game"] = m_edit_game_id->text().toStdString();
|
||||
|
||||
if (!m_radio_all->isChecked())
|
||||
filters["password"] = std::to_string(m_radio_private->isChecked());
|
||||
|
||||
if (m_region_combo->currentIndex() != 0)
|
||||
filters["region"] = m_region_combo->currentData().toString().toStdString();
|
||||
|
||||
auto entries = client.List(filters);
|
||||
|
||||
if (!entries)
|
||||
{
|
||||
m_status_label->setText(
|
||||
tr("Error obtaining session list: %1").arg(QString::fromStdString(client.GetLastError())));
|
||||
return;
|
||||
}
|
||||
|
||||
const int session_count = static_cast<int>(entries.value().size());
|
||||
|
||||
m_table_widget->setRowCount(session_count);
|
||||
|
||||
for (int i = 0; i < session_count; i++)
|
||||
{
|
||||
const auto& entry = entries.value()[i];
|
||||
|
||||
auto* region = new QTableWidgetItem(QString::fromStdString(entry.region));
|
||||
auto* name = new QTableWidgetItem(QString::fromStdString(entry.name));
|
||||
auto* password = new QTableWidgetItem(entry.has_password ? tr("Yes") : tr("No"));
|
||||
auto* in_game = new QTableWidgetItem(entry.in_game ? tr("Yes") : tr("No"));
|
||||
auto* game_id = new QTableWidgetItem(QString::fromStdString(entry.game_id));
|
||||
auto* player_count = new QTableWidgetItem(QStringLiteral("%1").arg(entry.player_count));
|
||||
|
||||
for (const auto& item : {region, name, password, game_id, player_count})
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
|
||||
m_table_widget->setItem(i, 0, region);
|
||||
m_table_widget->setItem(i, 1, name);
|
||||
m_table_widget->setItem(i, 2, password);
|
||||
m_table_widget->setItem(i, 3, in_game);
|
||||
m_table_widget->setItem(i, 4, game_id);
|
||||
m_table_widget->setItem(i, 5, player_count);
|
||||
}
|
||||
|
||||
m_status_label->setText(
|
||||
(session_count == 1 ? tr("%1 session found") : tr("%1 sessions found")).arg(session_count));
|
||||
|
||||
m_sessions = entries.value();
|
||||
}
|
||||
|
||||
void NetPlayBrowser::OnSelectionChanged()
|
||||
{
|
||||
m_button_box->button(QDialogButtonBox::Ok)
|
||||
->setEnabled(!m_table_widget->selectedItems().isEmpty());
|
||||
}
|
||||
|
||||
void NetPlayBrowser::accept()
|
||||
{
|
||||
const int index = m_table_widget->selectedItems()[0]->row();
|
||||
|
||||
NetPlaySession& session = m_sessions[index];
|
||||
|
||||
std::string server_id = session.server_id;
|
||||
|
||||
if (m_sessions[index].has_password)
|
||||
{
|
||||
auto* dialog = new QInputDialog(this);
|
||||
|
||||
dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
dialog->setWindowTitle(tr("Enter password"));
|
||||
dialog->setLabelText(tr("This session requires a password:"));
|
||||
dialog->setWindowModality(Qt::WindowModal);
|
||||
dialog->setTextEchoMode(QLineEdit::Password);
|
||||
|
||||
if (dialog->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
const std::string password = dialog->textValue().toStdString();
|
||||
|
||||
auto decrypted_id = session.DecryptID(password);
|
||||
|
||||
if (!decrypted_id)
|
||||
{
|
||||
ModalMessageBox::warning(this, tr("Error"), tr("Invalid password provided."));
|
||||
return;
|
||||
}
|
||||
|
||||
server_id = decrypted_id.value();
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_TRAVERSAL_CHOICE, session.method);
|
||||
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_CONNECT_PORT, session.port);
|
||||
|
||||
if (session.method == "traversal")
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_HOST_CODE, server_id);
|
||||
else
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_ADDRESS, server_id);
|
||||
|
||||
emit Join();
|
||||
}
|
52
Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h
Normal file
52
Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h
Normal file
@ -0,0 +1,52 @@
|
||||
// Copyright 2019 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#include "UICommon/NetPlayIndex.h"
|
||||
|
||||
class QComboBox;
|
||||
class QDialogButtonBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QRadioButton;
|
||||
class QTableWidget;
|
||||
|
||||
class NetPlayBrowser : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NetPlayBrowser(QWidget* parent = nullptr);
|
||||
|
||||
void accept() override;
|
||||
signals:
|
||||
void Join();
|
||||
|
||||
private:
|
||||
void CreateWidgets();
|
||||
void ConnectWidgets();
|
||||
|
||||
void Refresh();
|
||||
|
||||
void OnSelectionChanged();
|
||||
|
||||
QComboBox* m_region_combo;
|
||||
QLabel* m_status_label;
|
||||
QPushButton* m_button_refresh;
|
||||
QTableWidget* m_table_widget;
|
||||
QDialogButtonBox* m_button_box;
|
||||
QLineEdit* m_edit_name;
|
||||
QLineEdit* m_edit_game_id;
|
||||
|
||||
QRadioButton* m_radio_all;
|
||||
QRadioButton* m_radio_private;
|
||||
QRadioButton* m_radio_public;
|
||||
|
||||
std::vector<NetPlaySession> m_sessions;
|
||||
};
|
@ -22,6 +22,8 @@
|
||||
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
#include "UICommon/NetPlayIndex.h"
|
||||
|
||||
NetPlaySetupDialog::NetPlaySetupDialog(QWidget* parent)
|
||||
: QDialog(parent), m_game_list_model(Settings::Instance().GetGameListModel())
|
||||
{
|
||||
@ -30,6 +32,10 @@ NetPlaySetupDialog::NetPlaySetupDialog(QWidget* parent)
|
||||
|
||||
CreateMainLayout();
|
||||
|
||||
bool use_index = Config::Get(Config::NETPLAY_USE_INDEX);
|
||||
std::string index_region = Config::Get(Config::NETPLAY_INDEX_REGION);
|
||||
std::string index_name = Config::Get(Config::NETPLAY_INDEX_NAME);
|
||||
std::string index_password = Config::Get(Config::NETPLAY_INDEX_PASSWORD);
|
||||
std::string nickname = Config::Get(Config::NETPLAY_NICKNAME);
|
||||
std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
|
||||
int connect_port = Config::Get(Config::NETPLAY_CONNECT_PORT);
|
||||
@ -48,10 +54,21 @@ NetPlaySetupDialog::NetPlaySetupDialog(QWidget* parent)
|
||||
m_connect_port_box->setValue(connect_port);
|
||||
m_host_port_box->setValue(host_port);
|
||||
|
||||
m_host_force_port_check->setChecked(false);
|
||||
m_host_force_port_box->setValue(host_listen_port);
|
||||
m_host_force_port_box->setEnabled(false);
|
||||
|
||||
m_host_server_browser->setChecked(use_index);
|
||||
|
||||
m_host_server_region->setEnabled(use_index);
|
||||
m_host_server_region->setCurrentIndex(
|
||||
m_host_server_region->findData(QString::fromStdString(index_region)));
|
||||
|
||||
m_host_server_name->setEnabled(use_index);
|
||||
m_host_server_name->setText(QString::fromStdString(index_name));
|
||||
|
||||
m_host_server_password->setEnabled(use_index);
|
||||
m_host_server_password->setText(QString::fromStdString(index_password));
|
||||
|
||||
m_host_chunked_upload_limit_check->setChecked(enable_chunked_upload_limit);
|
||||
m_host_chunked_upload_limit_box->setValue(chunked_upload_limit);
|
||||
m_host_chunked_upload_limit_box->setEnabled(enable_chunked_upload_limit);
|
||||
@ -112,6 +129,10 @@ void NetPlaySetupDialog::CreateMainLayout()
|
||||
m_host_force_port_box = new QSpinBox;
|
||||
m_host_chunked_upload_limit_check = new QCheckBox(tr("Limit Chunked Upload Speed:"));
|
||||
m_host_chunked_upload_limit_box = new QSpinBox;
|
||||
m_host_server_browser = new QCheckBox(tr("Show in server browser"));
|
||||
m_host_server_name = new QLineEdit;
|
||||
m_host_server_password = new QLineEdit;
|
||||
m_host_server_region = new QComboBox;
|
||||
|
||||
#ifdef USE_UPNP
|
||||
m_host_upnp = new QCheckBox(tr("Forward port (UPnP)"));
|
||||
@ -128,17 +149,33 @@ void NetPlaySetupDialog::CreateMainLayout()
|
||||
m_host_chunked_upload_limit_check->setToolTip(tr(
|
||||
"This will limit the speed of chunked uploading per client, which is used for save sync."));
|
||||
|
||||
m_host_server_name->setToolTip(tr("Name of your session shown in the server browser"));
|
||||
m_host_server_name->setPlaceholderText(tr("Name"));
|
||||
m_host_server_password->setToolTip(tr("Password for joining your game (leave empty for none)"));
|
||||
m_host_server_password->setPlaceholderText(tr("Password"));
|
||||
|
||||
for (const auto& region : NetPlayIndex::GetRegions())
|
||||
{
|
||||
m_host_server_region->addItem(
|
||||
tr("%1 (%2)").arg(tr(region.second.c_str())).arg(QString::fromStdString(region.first)),
|
||||
QString::fromStdString(region.first));
|
||||
}
|
||||
|
||||
host_layout->addWidget(m_host_port_label, 0, 0);
|
||||
host_layout->addWidget(m_host_port_box, 0, 1);
|
||||
#ifdef USE_UPNP
|
||||
host_layout->addWidget(m_host_upnp, 0, 2);
|
||||
#endif
|
||||
host_layout->addWidget(m_host_games, 1, 0, 1, -1);
|
||||
host_layout->addWidget(m_host_force_port_check, 2, 0);
|
||||
host_layout->addWidget(m_host_force_port_box, 2, 1, Qt::AlignLeft);
|
||||
host_layout->addWidget(m_host_chunked_upload_limit_check, 3, 0);
|
||||
host_layout->addWidget(m_host_chunked_upload_limit_box, 3, 1, Qt::AlignLeft);
|
||||
host_layout->addWidget(m_host_button, 2, 2, 2, 1, Qt::AlignRight);
|
||||
host_layout->addWidget(m_host_server_browser, 1, 0);
|
||||
host_layout->addWidget(m_host_server_region, 1, 1);
|
||||
host_layout->addWidget(m_host_server_name, 1, 2);
|
||||
host_layout->addWidget(m_host_server_password, 1, 3);
|
||||
host_layout->addWidget(m_host_games, 2, 0, 1, -1);
|
||||
host_layout->addWidget(m_host_force_port_check, 3, 0);
|
||||
host_layout->addWidget(m_host_force_port_box, 3, 1, Qt::AlignLeft);
|
||||
host_layout->addWidget(m_host_chunked_upload_limit_check, 4, 0);
|
||||
host_layout->addWidget(m_host_chunked_upload_limit_box, 4, 1, Qt::AlignLeft);
|
||||
host_layout->addWidget(m_host_button, 4, 3, 2, 1, Qt::AlignRight);
|
||||
|
||||
host_widget->setLayout(host_layout);
|
||||
|
||||
@ -199,6 +236,11 @@ void NetPlaySetupDialog::ConnectWidgets()
|
||||
connect(m_button_box, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
connect(m_reset_traversal_button, &QPushButton::clicked, this,
|
||||
&NetPlaySetupDialog::ResetTraversalHost);
|
||||
connect(m_host_server_browser, &QCheckBox::toggled, this, [this](bool value) {
|
||||
m_host_server_region->setEnabled(value);
|
||||
m_host_server_name->setEnabled(value);
|
||||
m_host_server_password->setEnabled(value);
|
||||
});
|
||||
}
|
||||
|
||||
void NetPlaySetupDialog::SaveSettings()
|
||||
@ -224,6 +266,13 @@ void NetPlaySetupDialog::SaveSettings()
|
||||
m_host_chunked_upload_limit_check->isChecked());
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_CHUNKED_UPLOAD_LIMIT,
|
||||
m_host_chunked_upload_limit_box->value());
|
||||
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_USE_INDEX, m_host_server_browser->isChecked());
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_INDEX_REGION,
|
||||
m_host_server_region->currentData().toString().toStdString());
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_INDEX_NAME, m_host_server_name->text().toStdString());
|
||||
Config::SetBaseOrCurrent(Config::NETPLAY_INDEX_PASSWORD,
|
||||
m_host_server_password->text().toStdString());
|
||||
}
|
||||
|
||||
void NetPlaySetupDialog::OnConnectionTypeChanged(int index)
|
||||
@ -273,6 +322,12 @@ void NetPlaySetupDialog::accept()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_host_server_browser->isChecked() && m_host_server_name->text().isEmpty())
|
||||
{
|
||||
ModalMessageBox::critical(this, tr("Error"), tr("You must provide a name for your session!"));
|
||||
return;
|
||||
}
|
||||
|
||||
emit Host(items[0]->text());
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,10 @@ private:
|
||||
QSpinBox* m_host_force_port_box;
|
||||
QCheckBox* m_host_chunked_upload_limit_check;
|
||||
QSpinBox* m_host_chunked_upload_limit_box;
|
||||
QCheckBox* m_host_server_browser;
|
||||
QLineEdit* m_host_server_name;
|
||||
QLineEdit* m_host_server_password;
|
||||
QComboBox* m_host_server_region;
|
||||
|
||||
#ifdef USE_UPNP
|
||||
QCheckBox* m_host_upnp;
|
||||
|
Reference in New Issue
Block a user