Skip to content

Commit

Permalink
chore: use new setting variables for regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
JLaferri committed Nov 15, 2023
1 parent 5c6849a commit 59265d0
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
10 changes: 6 additions & 4 deletions Source/Core/Core/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,15 @@ void SConfig::SaveCoreSettings(IniFile &ini)
core->Set("SlippiEnableSpectator", m_enableSpectator);
core->Set("SlippiSpectatorLocalPort", m_spectator_local_port);
core->Set("SlippiSaveReplays", m_slippiSaveReplays);
core->Set("SlippiRegenerateReplays", m_slippiRegenerateReplays);
core->Set("SlippiEnableQuickChat", m_slippiEnableQuickChat);
core->Set("SlippiForceNetplayPort", m_slippiForceNetplayPort);
core->Set("SlippiNetplayPort", m_slippiNetplayPort);
core->Set("SlippiForceLanIp", m_slippiForceLanIp);
core->Set("SlippiLanIp", m_slippiLanIp);
core->Set("SlippiReplayMonthFolders", m_slippiReplayMonthFolders);
core->Set("SlippiReplayDir", m_strSlippiReplayDir);
core->Set("SlippiReplayRegenerateDir", m_strSlippiRegenerateReplayDir);
core->Set("SlippiPlaybackDisplayFrameIndex", m_slippiEnableFrameIndex);
core->Set("BlockingPipes", m_blockingPipes);
core->Set("MemcardAPath", m_strMemoryCardA);
Expand Down Expand Up @@ -627,11 +629,8 @@ void SConfig::LoadCoreSettings(IniFile &ini)
core->Get("SlippiEnableSpectator", &m_enableSpectator, true);
core->Get("SlippiSpectatorLocalPort", &m_spectator_local_port, 51441);
core->Get("SlippiOnlineDelay", &m_slippiOnlineDelay, 2);
#ifdef IS_PLAYBACK
core->Get("SlippiSaveReplays", &m_slippiSaveReplays, false);
#else
core->Get("SlippiSaveReplays", &m_slippiSaveReplays, true);
#endif
core->Get("SlippiRegenerateReplays", &m_slippiRegenerateReplays, false);
core->Get("SlippiEnableQuickChat", &m_slippiEnableQuickChat, SLIPPI_CHAT_ON);
core->Get("SlippiForceNetplayPort", &m_slippiForceNetplayPort, false);
core->Get("SlippiNetplayPort", &m_slippiNetplayPort, 2626);
Expand All @@ -642,6 +641,9 @@ void SConfig::LoadCoreSettings(IniFile &ini)
core->Get("SlippiReplayDir", &m_strSlippiReplayDir, default_replay_dir);
if (m_strSlippiReplayDir.empty())
m_strSlippiReplayDir = default_replay_dir;
core->Get("SlippiReplayRegenerateDir", &m_strSlippiRegenerateReplayDir, default_replay_dir);
if (m_strSlippiRegenerateReplayDir.empty())
m_strSlippiRegenerateReplayDir = default_replay_dir;
core->Get("SlippiPlaybackDisplayFrameIndex", &m_slippiEnableFrameIndex, false);
core->Get("BlockingPipes", &m_blockingPipes, false);
core->Get("MemcardAPath", &m_strMemoryCardA);
Expand Down
6 changes: 2 additions & 4 deletions Source/Core/Core/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,12 @@ struct SConfig : NonCopyable
bool bMeleeForceWidescreen = false;

// Slippi
#ifdef IS_PLAYBACK
bool m_slippiSaveReplays = false;
#else
bool m_slippiSaveReplays = true;
#endif
bool m_slippiRegenerateReplays = false;
int m_slippiEnableQuickChat = SLIPPI_CHAT_ON;
bool m_slippiReplayMonthFolders = false;
std::string m_strSlippiReplayDir;
std::string m_strSlippiRegenerateReplayDir;
bool m_slippiForceNetplayPort = false;
int m_slippiNetplayPort;
bool m_slippiForceLanIp = false;
Expand Down
20 changes: 19 additions & 1 deletion Source/Core/Core/HW/EXI_DeviceSlippi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,13 @@ std::vector<u8> CEXISlippi::generateMetadata()

void CEXISlippi::writeToFileAsync(u8 *payload, u32 length, std::string fileOption)
{
if (!SConfig::GetInstance().m_slippiSaveReplays)
#ifndef IS_PLAYBACK
bool shouldSaveReplays = SConfig::GetInstance().m_slippiSaveReplays;
#else
bool shouldSaveReplays = SConfig::GetInstance().m_slippiRegenerateReplays;
#endif

if (!shouldSaveReplays)
{
return;
}
Expand Down Expand Up @@ -628,13 +634,23 @@ void CEXISlippi::createNewFile()
closeFile();
}

#ifndef IS_PLAYBACK
std::string dirpath = SConfig::GetInstance().m_strSlippiReplayDir;
// in case the config value just gets lost somehow
if (dirpath.empty())
{
SConfig::GetInstance().m_strSlippiReplayDir = File::GetHomeDirectory() + DIR_SEP + "Slippi";
dirpath = SConfig::GetInstance().m_strSlippiReplayDir;
}
#else
std::string dirpath = SConfig::GetInstance().m_strSlippiRegenerateReplayDir;
// in case the config value just gets lost somehow
if (dirpath.empty())
{
SConfig::GetInstance().m_strSlippiRegenerateReplayDir = File::GetHomeDirectory() + DIR_SEP + "Slippi";
dirpath = SConfig::GetInstance().m_strSlippiRegenerateReplayDir;
}
#endif

// Remove a trailing / or \\ if the user managed to have that in their config
char dirpathEnd = dirpath.back();
Expand All @@ -646,6 +662,7 @@ void CEXISlippi::createNewFile()
// First, ensure that the root Slippi replay directory is created
File::CreateFullPath(dirpath + "/");

#ifndef IS_PLAYBACK
// Now we have a dir such as /home/Replays but we need to make one such
// as /home/Replays/2020-06 if month categorization is enabled
if (SConfig::GetInstance().m_slippiReplayMonthFolders)
Expand All @@ -663,6 +680,7 @@ void CEXISlippi::createNewFile()
// Ensure that the subfolder directory is created
File::CreateDir(dirpath);
}
#endif

std::string filepath = dirpath + DIR_SEP + generateFileName();
INFO_LOG(SLIPPI, "EXI_DeviceSlippi.cpp: Creating new replay file %s", filepath.c_str());
Expand Down
40 changes: 13 additions & 27 deletions Source/Core/DolphinWX/Config/SlippiConfigPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,9 @@ SlippiPlaybackConfigPane::SlippiPlaybackConfigPane(wxWindow *parent, wxWindowID
void SlippiPlaybackConfigPane::InitializeGUI()
{
// Slippi settings
m_replay_enable_checkbox = new wxCheckBox(this, wxID_ANY, _("Regenerate Slippi Replays"));
m_replay_enable_checkbox->SetToolTip(
_("Enable this to regenerate .slp recordings of your games. Does not need to be enabled to use spectator service for powering custom HUDs."));

m_replay_month_folders_checkbox = new wxCheckBox(this, wxID_ANY, _("Save Replays to Monthly Subfolders"));
m_replay_month_folders_checkbox->SetToolTip(
_("Enable this to save your replays into subfolders by month (YYYY-MM)."));
m_replay_regenerate_checkbox = new wxCheckBox(this, wxID_ANY, _("Regenerate Slippi Replays (off if unsure)"));
m_replay_regenerate_checkbox->SetToolTip(
_("Enable this to regenerate .slp recordings of your games. Does NOT need to be enabled to use slp event monitoring service for powering custom HUDs."));

m_replay_directory_picker =
new wxDirPickerCtrl(this, wxID_ANY, wxEmptyString, _("Slippi Replay Folder:"), wxDefaultPosition, wxDefaultSize,
Expand All @@ -458,12 +454,10 @@ void SlippiPlaybackConfigPane::InitializeGUI()
sbSlippiPlaybackSettings->AddSpacer(space5);

wxGridBagSizer *const sSlippiReplaySettings = new wxGridBagSizer(space5, space5);
sSlippiReplaySettings->Add(m_replay_enable_checkbox, wxGBPosition(0, 0), wxGBSpan(1, 2));
sSlippiReplaySettings->Add(m_replay_month_folders_checkbox, wxGBPosition(1, 0), wxGBSpan(1, 2),
wxRESERVE_SPACE_EVEN_IF_HIDDEN);
sSlippiReplaySettings->Add(new wxStaticText(this, wxID_ANY, _("Replay folder:")), wxGBPosition(2, 0), wxDefaultSpan,
sSlippiReplaySettings->Add(m_replay_regenerate_checkbox, wxGBPosition(0, 0), wxGBSpan(1, 2));
sSlippiReplaySettings->Add(new wxStaticText(this, wxID_ANY, _("Replay folder:")), wxGBPosition(1, 0), wxDefaultSpan,
wxALIGN_CENTER_VERTICAL);
sSlippiReplaySettings->Add(m_replay_directory_picker, wxGBPosition(2, 1), wxDefaultSpan, wxEXPAND);
sSlippiReplaySettings->Add(m_replay_directory_picker, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND);
sSlippiReplaySettings->AddGrowableCol(1);

wxStaticBoxSizer *const sbSlippiReplaySettings =
Expand All @@ -487,18 +481,16 @@ void SlippiPlaybackConfigPane::LoadGUIValues()
{
const SConfig &startup_params = SConfig::GetInstance();

m_replay_enable_checkbox->SetValue(startup_params.m_slippiSaveReplays);
m_replay_month_folders_checkbox->SetValue(startup_params.m_slippiReplayMonthFolders);
m_replay_directory_picker->SetPath(StrToWxStr(startup_params.m_strSlippiReplayDir));
m_replay_regenerate_checkbox->SetValue(startup_params.m_slippiRegenerateReplays);
m_replay_directory_picker->SetPath(StrToWxStr(startup_params.m_strSlippiRegenerateReplayDir));
m_display_frame_index->SetValue(startup_params.m_slippiEnableFrameIndex);
}

void SlippiPlaybackConfigPane::BindEvents()
{
m_display_frame_index->Bind(wxEVT_CHECKBOX, &SlippiPlaybackConfigPane::OnDisplayFrameIndexToggle, this);

m_replay_enable_checkbox->Bind(wxEVT_CHECKBOX, &SlippiPlaybackConfigPane::OnReplaySavingToggle, this);
m_replay_month_folders_checkbox->Bind(wxEVT_CHECKBOX, &SlippiPlaybackConfigPane::OnReplayMonthFoldersToggle, this);
m_replay_regenerate_checkbox->Bind(wxEVT_CHECKBOX, &SlippiPlaybackConfigPane::OnReplayRegenerateToggle, this);
m_replay_directory_picker->Bind(wxEVT_DIRPICKER_CHANGED, &SlippiPlaybackConfigPane::OnReplayDirChanged, this);
}

Expand All @@ -508,20 +500,14 @@ void SlippiPlaybackConfigPane::OnDisplayFrameIndexToggle(wxCommandEvent &event)
SConfig::GetInstance().m_slippiEnableFrameIndex = enableFrameIndex;
}

void SlippiPlaybackConfigPane::OnReplaySavingToggle(wxCommandEvent &event)
void SlippiPlaybackConfigPane::OnReplayRegenerateToggle(wxCommandEvent &event)
{
bool enableReplays = m_replay_enable_checkbox->IsChecked();

SConfig::GetInstance().m_slippiSaveReplays = enableReplays;
}
bool enableReplays = m_replay_regenerate_checkbox->IsChecked();

void SlippiPlaybackConfigPane::OnReplayMonthFoldersToggle(wxCommandEvent &event)
{
SConfig::GetInstance().m_slippiReplayMonthFolders =
m_replay_enable_checkbox->IsChecked() && m_replay_month_folders_checkbox->IsChecked();
SConfig::GetInstance().m_slippiRegenerateReplays = enableReplays;
}

void SlippiPlaybackConfigPane::OnReplayDirChanged(wxCommandEvent &event)
{
SConfig::GetInstance().m_strSlippiReplayDir = WxStrToStr(m_replay_directory_picker->GetPath());
SConfig::GetInstance().m_strSlippiRegenerateReplayDir = WxStrToStr(m_replay_directory_picker->GetPath());
}
6 changes: 2 additions & 4 deletions Source/Core/DolphinWX/Config/SlippiConfigPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,11 @@ class SlippiPlaybackConfigPane final : public wxPanel

wxStaticText *m_slippi_delay_frames_txt;
wxTextCtrl *m_slippi_netplay_lan_ip_ctrl;
wxCheckBox *m_replay_enable_checkbox;
wxCheckBox *m_replay_month_folders_checkbox;
wxCheckBox *m_replay_regenerate_checkbox;
wxDirPickerCtrl *m_replay_directory_picker;
wxCheckBox *m_display_frame_index;

void OnDisplayFrameIndexToggle(wxCommandEvent &event);
void OnReplaySavingToggle(wxCommandEvent &event);
void OnReplayMonthFoldersToggle(wxCommandEvent &event);
void OnReplayRegenerateToggle(wxCommandEvent &event);
void OnReplayDirChanged(wxCommandEvent &event);
};

0 comments on commit 59265d0

Please sign in to comment.