NetPlay: Properly save Hosting GUI settings
This commit is contained in:
parent
480972612c
commit
550aa93ed0
|
@ -35,4 +35,19 @@ const ConfigInfo<bool> NETPLAY_USE_UPNP{{System::Main, "NetPlay", "UseUPNP"}, fa
|
|||
|
||||
const ConfigInfo<bool> NETPLAY_ENABLE_QOS{{System::Main, "NetPlay", "EnableQoS"}, true};
|
||||
|
||||
const ConfigInfo<u32> NETPLAY_BUFFER_SIZE{{System::Main, "NetPlay", "BufferSize"}, 5};
|
||||
const ConfigInfo<u32> NETPLAY_CLIENT_BUFFER_SIZE{{System::Main, "NetPlay", "BufferSizeClient"}, 1};
|
||||
|
||||
const ConfigInfo<bool> NETPLAY_WRITE_SAVE_SDCARD_DATA{
|
||||
{System::Main, "NetPlay", "WriteSaveSDCardData"}, false};
|
||||
const ConfigInfo<bool> NETPLAY_LOAD_WII_SAVE{{System::Main, "NetPlay", "LoadWiiSave"}, false};
|
||||
const ConfigInfo<bool> NETPLAY_SYNC_SAVES{{System::Main, "NetPlay", "SyncSaves"}, true};
|
||||
const ConfigInfo<bool> NETPLAY_RECORD_INPUTS{{System::Main, "NetPlay", "RecordInputs"}, false};
|
||||
const ConfigInfo<bool> NETPLAY_REDUCE_POLLING_RATE{{System::Main, "NetPlay", "ReducePollingRate"},
|
||||
false};
|
||||
const ConfigInfo<bool> NETPLAY_STRICT_SETTINGS_SYNC{{System::Main, "NetPlay", "StrictSettingsSync"},
|
||||
false};
|
||||
const ConfigInfo<bool> NETPLAY_HOST_INPUT_AUTHORITY{{System::Main, "NetPlay", "HostInputAuthority"},
|
||||
false};
|
||||
|
||||
} // namespace Config
|
||||
|
|
|
@ -31,4 +31,15 @@ extern const ConfigInfo<bool> NETPLAY_USE_UPNP;
|
|||
|
||||
extern const ConfigInfo<bool> NETPLAY_ENABLE_QOS;
|
||||
|
||||
extern const ConfigInfo<u32> NETPLAY_BUFFER_SIZE;
|
||||
extern const ConfigInfo<u32> NETPLAY_CLIENT_BUFFER_SIZE;
|
||||
|
||||
extern const ConfigInfo<bool> NETPLAY_WRITE_SAVE_SDCARD_DATA;
|
||||
extern const ConfigInfo<bool> NETPLAY_LOAD_WII_SAVE;
|
||||
extern const ConfigInfo<bool> NETPLAY_SYNC_SAVES;
|
||||
extern const ConfigInfo<bool> NETPLAY_RECORD_INPUTS;
|
||||
extern const ConfigInfo<bool> NETPLAY_REDUCE_POLLING_RATE;
|
||||
extern const ConfigInfo<bool> NETPLAY_STRICT_SETTINGS_SYNC;
|
||||
extern const ConfigInfo<bool> NETPLAY_HOST_INPUT_AUTHORITY;
|
||||
|
||||
} // namespace Config
|
||||
|
|
|
@ -1093,16 +1093,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
|
||||
{
|
||||
|
@ -1114,9 +1116,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,
|
||||
|
@ -1128,8 +1138,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);
|
||||
|
|
|
@ -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<void (QSpinBox::*)(int)>(&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<const UICommon::GameFile> 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] {
|
||||
|
|
|
@ -58,6 +58,9 @@ public:
|
|||
bool IsRecording() override;
|
||||
std::string FindGame(const std::string& game) override;
|
||||
std::shared_ptr<const UICommon::GameFile> 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;
|
||||
|
|
Loading…
Reference in New Issue