diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index bd5c0246b6..b773b9e7a8 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -88,6 +88,7 @@ void SConfig::SaveSettings() SaveInterfaceSettings(ini); SaveGameListSettings(ini); SaveCoreSettings(ini); + SaveSlippiSettings(ini); SaveMovieSettings(ini); SaveDSPSettings(ini); SaveInputSettings(ini); @@ -252,6 +253,16 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("CustomRTCValue", m_customRTCValue); } +void SConfig::SaveSlippiSettings(IniFile& ini) +{ + IniFile::Section* slippi = ini.GetOrCreateSection("Slippi"); + + slippi->Set("OnlineDelay", m_slippiOnlineDelay); + slippi->Set("SaveReplays", m_slippiSaveReplays); + slippi->Set("ReplayMonthFolders", m_slippiReplayMonthFolders); + slippi->Set("ReplayDir", m_strSlippiReplayDir); +} + void SConfig::SaveMovieSettings(IniFile& ini) { IniFile::Section* movie = ini.GetOrCreateSection("Movie"); @@ -364,6 +375,7 @@ void SConfig::LoadSettings() LoadInterfaceSettings(ini); LoadGameListSettings(ini); LoadCoreSettings(ini); + LoadSlippiSettings(ini); LoadMovieSettings(ini); LoadDSPSettings(ini); LoadInputSettings(ini); @@ -533,6 +545,19 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("CustomRTCValue", &m_customRTCValue, 946684800); } +void SConfig::LoadSlippiSettings(IniFile& ini) +{ + IniFile::Section* slippi = ini.GetOrCreateSection("Slippi"); + + slippi->Get("OnlineDelay", &m_slippiOnlineDelay, 2); + slippi->Get("SaveReplays", &m_slippiSaveReplays, true); + slippi->Get("ReplayMonthFolders", &m_slippiReplayMonthFolders, false); + std::string default_replay_dir = File::GetHomeDirectory() + DIR_SEP + "Slippi"; + slippi->Get("ReplayDir", &m_strSlippiReplayDir, default_replay_dir); + if (m_strSlippiReplayDir.empty()) + m_strSlippiReplayDir = default_replay_dir; +} + void SConfig::LoadMovieSettings(IniFile& ini) { IniFile::Section* movie = ini.GetOrCreateSection("Movie"); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index f97e96bc90..35d503bd75 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -146,7 +146,7 @@ struct SConfig bool bWii = false; bool m_is_mios = false; - // Slippi + // Slippi std::string m_strSlippiInput; int m_slippiOnlineDelay = 2; bool m_slippiSaveReplays = true; @@ -348,6 +348,7 @@ private: void SaveInterfaceSettings(IniFile& ini); void SaveGameListSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini); + void SaveSlippiSettings(IniFile& ini); void SaveDSPSettings(IniFile& ini); void SaveInputSettings(IniFile& ini); void SaveMovieSettings(IniFile& ini); @@ -362,6 +363,7 @@ private: void LoadInterfaceSettings(IniFile& ini); void LoadGameListSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini); + void LoadSlippiSettings(IniFile& ini); void LoadDSPSettings(IniFile& ini); void LoadInputSettings(IniFile& ini); void LoadMovieSettings(IniFile& ini); diff --git a/Source/Core/DolphinQt/Settings/SlippiPane.cpp b/Source/Core/DolphinQt/Settings/SlippiPane.cpp index bc2d82f66e..2f412228b7 100644 --- a/Source/Core/DolphinQt/Settings/SlippiPane.cpp +++ b/Source/Core/DolphinQt/Settings/SlippiPane.cpp @@ -13,6 +13,8 @@ #include #include +#include "Core/ConfigManager.h" + SlippiPane::SlippiPane(QWidget* parent) : QWidget(parent) { CreateLayout(); @@ -20,12 +22,13 @@ SlippiPane::SlippiPane(QWidget* parent) : QWidget(parent) void SlippiPane::BrowseReplayFolder() { - QString dir = QDir::toNativeSeparators( - QFileDialog::getExistingDirectory(this, tr("Select a Directory"), QDir::currentPath())); + QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( + this, tr("Select Replay Folder"), + QString::fromStdString(SConfig::GetInstance().m_strSlippiReplayDir))); if (!dir.isEmpty()) { m_replay_folder_edit->setText(dir); - // XXX set replay folder + SConfig::GetInstance().m_strSlippiReplayDir = dir.toStdString(); } } @@ -44,16 +47,27 @@ void SlippiPane::CreateLayout() m_enable_replay_save_checkbox->setToolTip( tr("Enable this to make Slippi automatically save .slp recordings of your games.")); replay_settings_layout->addWidget(m_enable_replay_save_checkbox); + m_enable_replay_save_checkbox->setChecked(SConfig::GetInstance().m_slippiSaveReplays); + connect(m_enable_replay_save_checkbox, &QCheckBox::toggled, this, + [](bool checked) { SConfig::GetInstance().m_slippiSaveReplays = checked; }); m_enable_monthly_replay_folders_checkbox = new QCheckBox(tr("Save Replays to Monthly Subfolders")); m_enable_monthly_replay_folders_checkbox->setToolTip( tr("Enable this to save your replays into subfolders by month (YYYY-MM).")); replay_settings_layout->addWidget(m_enable_monthly_replay_folders_checkbox); + m_enable_monthly_replay_folders_checkbox->setChecked( + SConfig::GetInstance().m_slippiReplayMonthFolders); + connect(m_enable_monthly_replay_folders_checkbox, &QCheckBox::toggled, this, + [](bool checked) { SConfig::GetInstance().m_slippiReplayMonthFolders = checked; }); auto* replay_folder_layout = new QGridLayout(); - m_replay_folder_edit = new QLineEdit(); // XXX fill in default string + m_replay_folder_edit = + new QLineEdit(QString::fromStdString(SConfig::GetInstance().m_strSlippiReplayDir)); m_replay_folder_edit->setToolTip(tr("Choose where your Slippi replay files are saved.")); + connect(m_replay_folder_edit, &QLineEdit::editingFinished, [this] { + SConfig::GetInstance().m_strSlippiReplayDir = m_replay_folder_edit->text().toStdString(); + }); QPushButton* replay_folder_open = new QPushButton(QStringLiteral("...")); connect(replay_folder_open, &QPushButton::clicked, this, &SlippiPane::BrowseReplayFolder); replay_folder_layout->addWidget(new QLabel(tr("Replay Folder:")), 0, 0); @@ -73,4 +87,7 @@ void SlippiPane::CreateLayout() "Increasing this can cause unplayable input delay, and lowering it " "can cause visual artifacts/lag.")); online_settings_layout->addRow(tr("Delay Frames:"), m_delay_spin); + m_delay_spin->setValue(SConfig::GetInstance().m_slippiOnlineDelay); + connect(m_delay_spin, qOverload(&QSpinBox::valueChanged), this, + [](int delay) { SConfig::GetInstance().m_slippiOnlineDelay = delay; }); }