diff --git a/Source/Core/Core/Config/NetplaySettings.cpp b/Source/Core/Core/Config/NetplaySettings.cpp index 4336c95cef..a4235ad03e 100644 --- a/Source/Core/Core/Config/NetplaySettings.cpp +++ b/Source/Core/Core/Config/NetplaySettings.cpp @@ -35,4 +35,19 @@ const ConfigInfo NETPLAY_USE_UPNP{{System::Main, "NetPlay", "UseUPNP"}, fa const ConfigInfo NETPLAY_ENABLE_QOS{{System::Main, "NetPlay", "EnableQoS"}, true}; +const ConfigInfo NETPLAY_BUFFER_SIZE{{System::Main, "NetPlay", "BufferSize"}, 5}; +const ConfigInfo NETPLAY_CLIENT_BUFFER_SIZE{{System::Main, "NetPlay", "BufferSizeClient"}, 1}; + +const ConfigInfo NETPLAY_WRITE_SAVE_SDCARD_DATA{ + {System::Main, "NetPlay", "WriteSaveSDCardData"}, false}; +const ConfigInfo NETPLAY_LOAD_WII_SAVE{{System::Main, "NetPlay", "LoadWiiSave"}, false}; +const ConfigInfo NETPLAY_SYNC_SAVES{{System::Main, "NetPlay", "SyncSaves"}, true}; +const ConfigInfo NETPLAY_RECORD_INPUTS{{System::Main, "NetPlay", "RecordInputs"}, false}; +const ConfigInfo NETPLAY_REDUCE_POLLING_RATE{{System::Main, "NetPlay", "ReducePollingRate"}, + false}; +const ConfigInfo NETPLAY_STRICT_SETTINGS_SYNC{{System::Main, "NetPlay", "StrictSettingsSync"}, + false}; +const ConfigInfo NETPLAY_HOST_INPUT_AUTHORITY{{System::Main, "NetPlay", "HostInputAuthority"}, + false}; + } // namespace Config diff --git a/Source/Core/Core/Config/NetplaySettings.h b/Source/Core/Core/Config/NetplaySettings.h index 71af0ff6a8..90dcec5d23 100644 --- a/Source/Core/Core/Config/NetplaySettings.h +++ b/Source/Core/Core/Config/NetplaySettings.h @@ -31,4 +31,15 @@ extern const ConfigInfo NETPLAY_USE_UPNP; extern const ConfigInfo NETPLAY_ENABLE_QOS; +extern const ConfigInfo NETPLAY_BUFFER_SIZE; +extern const ConfigInfo NETPLAY_CLIENT_BUFFER_SIZE; + +extern const ConfigInfo NETPLAY_WRITE_SAVE_SDCARD_DATA; +extern const ConfigInfo NETPLAY_LOAD_WII_SAVE; +extern const ConfigInfo NETPLAY_SYNC_SAVES; +extern const ConfigInfo NETPLAY_RECORD_INPUTS; +extern const ConfigInfo NETPLAY_REDUCE_POLLING_RATE; +extern const ConfigInfo NETPLAY_STRICT_SETTINGS_SYNC; +extern const ConfigInfo NETPLAY_HOST_INPUT_AUTHORITY; + } // namespace Config diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index edf395d078..ec15365e55 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -1156,16 +1156,18 @@ bool MainWindow::NetPlayJoin() return false; } + auto server = Settings::Instance().GetNetPlayServer(); + // Settings const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE); const bool is_traversal = traversal_choice == "traversal"; std::string host_ip; u16 host_port; - if (Settings::Instance().GetNetPlayServer()) + if (server) { host_ip = "127.0.0.1"; - host_port = Settings::Instance().GetNetPlayServer()->GetPort(); + host_port = server->GetPort(); } else { @@ -1177,9 +1179,17 @@ bool MainWindow::NetPlayJoin() const std::string traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER); const u16 traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT); const std::string nickname = Config::Get(Config::NETPLAY_NICKNAME); + const bool host_input_authority = Config::Get(Config::NETPLAY_HOST_INPUT_AUTHORITY); + + if (server) + { + server->SetHostInputAuthority(host_input_authority); + if (!host_input_authority) + server->AdjustPadBufferSize(Config::Get(Config::NETPLAY_BUFFER_SIZE)); + } // Create Client - const bool is_hosting_netplay = Settings::Instance().GetNetPlayServer() != nullptr; + const bool is_hosting_netplay = server != nullptr; Settings::Instance().ResetNetPlayClient(new NetPlay::NetPlayClient( host_ip, host_port, m_netplay_dialog, nickname, NetPlay::NetTraversalConfig{is_hosting_netplay ? false : is_traversal, traversal_host, @@ -1191,8 +1201,8 @@ bool MainWindow::NetPlayJoin() return false; } - if (Settings::Instance().GetNetPlayServer() != nullptr) - Settings::Instance().GetNetPlayServer()->SetNetPlayUI(m_netplay_dialog); + if (server != nullptr) + server->SetNetPlayUI(m_netplay_dialog); m_netplay_setup_dialog->close(); m_netplay_dialog->show(nickname, is_traversal); diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp index 5edd279c9d..dc6b847b61 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.cpp @@ -71,6 +71,25 @@ NetPlayDialog::NetPlayDialog(QWidget* parent) CreateChatLayout(); CreatePlayersLayout(); CreateMainLayout(); + + const int buffer_size = Config::Get(Config::NETPLAY_BUFFER_SIZE); + const bool write_save_sdcard_data = Config::Get(Config::NETPLAY_WRITE_SAVE_SDCARD_DATA); + const bool load_wii_save = Config::Get(Config::NETPLAY_LOAD_WII_SAVE); + const bool sync_saves = Config::Get(Config::NETPLAY_SYNC_SAVES); + const bool record_inputs = Config::Get(Config::NETPLAY_RECORD_INPUTS); + const bool reduce_polling_rate = Config::Get(Config::NETPLAY_REDUCE_POLLING_RATE); + const bool strict_settings_sync = Config::Get(Config::NETPLAY_STRICT_SETTINGS_SYNC); + const bool host_input_authority = Config::Get(Config::NETPLAY_HOST_INPUT_AUTHORITY); + + m_buffer_size_box->setValue(buffer_size); + m_save_sd_box->setChecked(write_save_sdcard_data); + m_load_wii_box->setChecked(load_wii_save); + m_sync_save_data_box->setChecked(sync_saves); + m_record_input_box->setChecked(record_inputs); + m_reduce_polling_rate_box->setChecked(reduce_polling_rate); + m_strict_settings_sync_box->setChecked(strict_settings_sync); + m_host_input_authority_box->setChecked(host_input_authority); + ConnectWidgets(); auto& settings = Settings::Instance().GetQSettings(); @@ -306,6 +325,18 @@ void NetPlayDialog::ConnectWidgets() DisplayMessage(tr("Stopped game"), "red"); } }); + + // SaveSettings() - Save Hosting-Dialog Settings + + connect(m_buffer_size_box, static_cast(&QSpinBox::valueChanged), this, + &NetPlayDialog::SaveSettings); + connect(m_save_sd_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_load_wii_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_sync_save_data_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_record_input_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_reduce_polling_rate_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_strict_settings_sync_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); + connect(m_host_input_authority_box, &QCheckBox::stateChanged, this, &NetPlayDialog::SaveSettings); } void NetPlayDialog::OnChat() @@ -802,7 +833,7 @@ void NetPlayDialog::OnHostInputAuthorityChanged(bool enabled) m_buffer_label->setHidden(!enable_buffer); if (enabled) - m_buffer_size_box->setValue(1); + m_buffer_size_box->setValue(Config::Get(Config::NETPLAY_CLIENT_BUFFER_SIZE)); } }); DisplayMessage(enabled ? tr("Host input authority enabled") : tr("Host input authority disabled"), @@ -910,6 +941,26 @@ std::shared_ptr NetPlayDialog::FindGameFile(const std: return nullptr; } +void NetPlayDialog::SaveSettings() +{ + if (m_host_input_authority) + { + if (!IsHosting()) + Config::SetBase(Config::NETPLAY_CLIENT_BUFFER_SIZE, m_buffer_size_box->value()); + } + else + { + Config::SetBase(Config::NETPLAY_BUFFER_SIZE, m_buffer_size_box->value()); + } + Config::SetBase(Config::NETPLAY_WRITE_SAVE_SDCARD_DATA, m_save_sd_box->isChecked()); + Config::SetBase(Config::NETPLAY_LOAD_WII_SAVE, m_load_wii_box->isChecked()); + Config::SetBase(Config::NETPLAY_SYNC_SAVES, m_sync_save_data_box->isChecked()); + Config::SetBase(Config::NETPLAY_RECORD_INPUTS, m_record_input_box->isChecked()); + Config::SetBase(Config::NETPLAY_REDUCE_POLLING_RATE, m_reduce_polling_rate_box->isChecked()); + Config::SetBase(Config::NETPLAY_STRICT_SETTINGS_SYNC, m_strict_settings_sync_box->isChecked()); + Config::SetBase(Config::NETPLAY_HOST_INPUT_AUTHORITY, m_host_input_authority_box->isChecked()); +} + void NetPlayDialog::ShowMD5Dialog(const std::string& file_identifier) { QueueOnObject(this, [this, file_identifier] { diff --git a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h index d666e8c33b..0f6537f4d5 100644 --- a/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h +++ b/Source/Core/DolphinQt/NetPlay/NetPlayDialog.h @@ -58,6 +58,9 @@ public: bool IsRecording() override; std::string FindGame(const std::string& game) override; std::shared_ptr FindGameFile(const std::string& game) override; + + void SaveSettings(); + void ShowMD5Dialog(const std::string& file_identifier) override; void SetMD5Progress(int pid, int progress) override; void SetMD5Result(int pid, const std::string& result) override;