From aa437d9805b2f1c810d117788be3aaac1259f788 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Mon, 27 Dec 2021 19:39:35 +0100 Subject: [PATCH] Config: Port Movie settings to new config system. --- Source/Core/Core/Config/MainSettings.cpp | 10 +++++++ Source/Core/Core/Config/MainSettings.h | 10 +++++++ .../Core/ConfigLoaders/IsSettingSaveable.cpp | 2 +- Source/Core/Core/ConfigManager.cpp | 28 ------------------- Source/Core/Core/ConfigManager.h | 9 ------ Source/Core/Core/Movie.cpp | 4 +-- Source/Core/DolphinQt/MenuBar.cpp | 23 +++++++-------- Source/Core/VideoCommon/FrameDump.cpp | 3 +- Source/Core/VideoCommon/RenderBase.cpp | 22 ++++++++------- 9 files changed, 49 insertions(+), 62 deletions(-) diff --git a/Source/Core/Core/Config/MainSettings.cpp b/Source/Core/Core/Config/MainSettings.cpp index 9cb6a71266..3521b59a8a 100644 --- a/Source/Core/Core/Config/MainSettings.cpp +++ b/Source/Core/Core/Config/MainSettings.cpp @@ -260,4 +260,14 @@ const Info MAIN_AUTOUPDATE_UPDATE_TRACK{{System::Main, "AutoUpdate" const Info MAIN_AUTOUPDATE_HASH_OVERRIDE{{System::Main, "AutoUpdate", "HashOverride"}, ""}; +// Main.Movie + +const Info MAIN_MOVIE_PAUSE_MOVIE{{System::Main, "Movie", "PauseMovie"}, false}; +const Info MAIN_MOVIE_MOVIE_AUTHOR{{System::Main, "Movie", "Author"}, ""}; +const Info MAIN_MOVIE_DUMP_FRAMES{{System::Main, "Movie", "DumpFrames"}, false}; +const Info MAIN_MOVIE_DUMP_FRAMES_SILENT{{System::Main, "Movie", "DumpFramesSilent"}, false}; +const Info MAIN_MOVIE_SHOW_INPUT_DISPLAY{{System::Main, "Movie", "ShowInputDisplay"}, false}; +const Info MAIN_MOVIE_SHOW_RTC{{System::Main, "Movie", "ShowRTC"}, false}; +const Info MAIN_MOVIE_SHOW_RERECORD{{System::Main, "Movie", "ShowRerecord"}, false}; + } // namespace Config diff --git a/Source/Core/Core/Config/MainSettings.h b/Source/Core/Core/Config/MainSettings.h index 60706765a0..a0795729ff 100644 --- a/Source/Core/Core/Config/MainSettings.h +++ b/Source/Core/Core/Config/MainSettings.h @@ -220,4 +220,14 @@ extern const Info MAIN_FIFOPLAYER_LOOP_REPLAY; extern const Info MAIN_AUTOUPDATE_UPDATE_TRACK; extern const Info MAIN_AUTOUPDATE_HASH_OVERRIDE; +// Main.Movie + +extern const Info MAIN_MOVIE_PAUSE_MOVIE; +extern const Info MAIN_MOVIE_MOVIE_AUTHOR; +extern const Info MAIN_MOVIE_DUMP_FRAMES; +extern const Info MAIN_MOVIE_DUMP_FRAMES_SILENT; +extern const Info MAIN_MOVIE_SHOW_INPUT_DISPLAY; +extern const Info MAIN_MOVIE_SHOW_RTC; +extern const Info MAIN_MOVIE_SHOW_RERECORD; + } // namespace Config diff --git a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp index 8bb37908a4..4abd8ee147 100644 --- a/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp +++ b/Source/Core/Core/ConfigLoaders/IsSettingSaveable.cpp @@ -27,7 +27,7 @@ bool IsSettingSaveable(const Config::Location& config_location) { for (const std::string_view section : {"NetPlay", "General", "GBA", "Display", "Network", "Analytics", "AndroidOverlayButtons", - "DSP", "GameList", "FifoPlayer", "AutoUpdate"}) + "DSP", "GameList", "FifoPlayer", "AutoUpdate", "Movie"}) { if (config_location.section == section) return true; diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 6124deb877..445b93132a 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -91,7 +91,6 @@ void SConfig::SaveSettings() SaveGeneralSettings(ini); SaveInterfaceSettings(ini); SaveCoreSettings(ini); - SaveMovieSettings(ini); SaveInputSettings(ini); SaveBluetoothPassthroughSettings(ini); SaveUSBPassthroughSettings(ini); @@ -199,19 +198,6 @@ void SConfig::SaveCoreSettings(IniFile& ini) core->Set("CustomRTCValue", m_customRTCValue); } -void SConfig::SaveMovieSettings(IniFile& ini) -{ - IniFile::Section* movie = ini.GetOrCreateSection("Movie"); - - movie->Set("PauseMovie", m_PauseMovie); - movie->Set("Author", m_strMovieAuthor); - movie->Set("DumpFrames", m_DumpFrames); - movie->Set("DumpFramesSilent", m_DumpFramesSilent); - movie->Set("ShowInputDisplay", m_ShowInputDisplay); - movie->Set("ShowRTC", m_ShowRTC); - movie->Set("ShowRerecord", m_ShowRerecord); -} - void SConfig::SaveInputSettings(IniFile& ini) { IniFile::Section* input = ini.GetOrCreateSection("Input"); @@ -270,7 +256,6 @@ void SConfig::LoadSettings() LoadGeneralSettings(ini); LoadInterfaceSettings(ini); LoadCoreSettings(ini); - LoadMovieSettings(ini); LoadInputSettings(ini); LoadBluetoothPassthroughSettings(ini); LoadUSBPassthroughSettings(ini); @@ -383,19 +368,6 @@ void SConfig::LoadCoreSettings(IniFile& ini) core->Get("CustomRTCValue", &m_customRTCValue, 946684800); } -void SConfig::LoadMovieSettings(IniFile& ini) -{ - IniFile::Section* movie = ini.GetOrCreateSection("Movie"); - - movie->Get("PauseMovie", &m_PauseMovie, false); - movie->Get("Author", &m_strMovieAuthor, ""); - movie->Get("DumpFrames", &m_DumpFrames, false); - movie->Get("DumpFramesSilent", &m_DumpFramesSilent, false); - movie->Get("ShowInputDisplay", &m_ShowInputDisplay, false); - movie->Get("ShowRTC", &m_ShowRTC, false); - movie->Get("ShowRerecord", &m_ShowRerecord, false); -} - void SConfig::LoadInputSettings(IniFile& ini) { IniFile::Section* input = ini.GetOrCreateSection("Input"); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index 51ec5d2a40..65540cad46 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -224,15 +224,8 @@ struct SConfig bool m_use_builtin_title_database = true; std::string m_WirelessMac; - bool m_PauseMovie; - bool m_ShowRerecord; bool m_ShowLag; bool m_ShowFrameCount; - bool m_ShowRTC; - std::string m_strMovieAuthor; - bool m_DumpFrames; - bool m_DumpFramesSilent; - bool m_ShowInputDisplay; bool m_PauseOnFocusLost; @@ -265,7 +258,6 @@ private: void SaveInterfaceSettings(IniFile& ini); void SaveCoreSettings(IniFile& ini); void SaveInputSettings(IniFile& ini); - void SaveMovieSettings(IniFile& ini); void SaveBluetoothPassthroughSettings(IniFile& ini); void SaveUSBPassthroughSettings(IniFile& ini); void SaveJitDebugSettings(IniFile& ini); @@ -274,7 +266,6 @@ private: void LoadInterfaceSettings(IniFile& ini); void LoadCoreSettings(IniFile& ini); void LoadInputSettings(IniFile& ini); - void LoadMovieSettings(IniFile& ini); void LoadBluetoothPassthroughSettings(IniFile& ini); void LoadUSBPassthroughSettings(IniFile& ini); void LoadJitDebugSettings(IniFile& ini); diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index ac1df71bbf..609dd0e0c2 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -574,7 +574,7 @@ bool BeginRecordingInput(const ControllerTypeArray& controllers, } s_playMode = MODE_RECORDING; - s_author = SConfig::GetInstance().m_strMovieAuthor; + s_author = Config::Get(Config::MAIN_MOVIE_MOVIE_AUTHOR); s_temp_input.clear(); s_currentByte = 0; @@ -1328,7 +1328,7 @@ void EndPlayInput(bool cont) Core::QueueHostJob([=] { Core::UpdateWantDeterminism(); - if (was_running && !SConfig::GetInstance().m_PauseMovie) + if (was_running && !Config::Get(Config::MAIN_MOVIE_PAUSE_MOVIE)) CPU::EnableStepping(false); }); } diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index c3d303044c..6776731980 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -746,15 +746,15 @@ void MenuBar::AddMovieMenu() auto* pause_at_end = movie_menu->addAction(tr("Pause at End of Movie")); pause_at_end->setCheckable(true); - pause_at_end->setChecked(SConfig::GetInstance().m_PauseMovie); + pause_at_end->setChecked(Config::Get(Config::MAIN_MOVIE_PAUSE_MOVIE)); connect(pause_at_end, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_PauseMovie = value; }); + [](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_PAUSE_MOVIE, value); }); auto* rerecord_counter = movie_menu->addAction(tr("Show Rerecord Counter")); rerecord_counter->setCheckable(true); - rerecord_counter->setChecked(SConfig::GetInstance().m_ShowRerecord); + rerecord_counter->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD)); connect(rerecord_counter, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_ShowRerecord = value; }); + [](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_RERECORD, value); }); auto* lag_counter = movie_menu->addAction(tr("Show Lag Counter")); lag_counter->setCheckable(true); @@ -770,23 +770,24 @@ void MenuBar::AddMovieMenu() auto* input_display = movie_menu->addAction(tr("Show Input Display")); input_display->setCheckable(true); - input_display->setChecked(SConfig::GetInstance().m_ShowInputDisplay); - connect(input_display, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_ShowInputDisplay = value; }); + input_display->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY)); + connect(input_display, &QAction::toggled, [](bool value) { + Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY, value); + }); auto* system_clock = movie_menu->addAction(tr("Show System Clock")); system_clock->setCheckable(true); - system_clock->setChecked(SConfig::GetInstance().m_ShowRTC); + system_clock->setChecked(Config::Get(Config::MAIN_MOVIE_SHOW_RTC)); connect(system_clock, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_ShowRTC = value; }); + [](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_SHOW_RTC, value); }); movie_menu->addSeparator(); auto* dump_frames = movie_menu->addAction(tr("Dump Frames")); dump_frames->setCheckable(true); - dump_frames->setChecked(SConfig::GetInstance().m_DumpFrames); + dump_frames->setChecked(Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES)); connect(dump_frames, &QAction::toggled, - [](bool value) { SConfig::GetInstance().m_DumpFrames = value; }); + [](bool value) { Config::SetBaseOrCurrent(Config::MAIN_MOVIE_DUMP_FRAMES, value); }); auto* dump_audio = movie_menu->addAction(tr("Dump Audio")); dump_audio->setCheckable(true); diff --git a/Source/Core/VideoCommon/FrameDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp index 08041a7177..9a8e3b4e1f 100644 --- a/Source/Core/VideoCommon/FrameDump.cpp +++ b/Source/Core/VideoCommon/FrameDump.cpp @@ -25,6 +25,7 @@ extern "C" { #include "Common/Logging/Log.h" #include "Common/MsgHandler.h" +#include "Core/Config/MainSettings.h" #include "Core/ConfigManager.h" #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" @@ -93,7 +94,7 @@ std::string GetDumpPath(const std::string& extension, std::time_t time, u32 inde // Ask to delete file. if (File::Exists(path)) { - if (SConfig::GetInstance().m_DumpFramesSilent || + if (Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES_SILENT) || AskYesNoFmtT("Delete the existing file '{0}'?", path)) { File::Delete(path); diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 31cfd36aee..2a1d861ac5 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -39,6 +39,7 @@ #include "Common/Timer.h" #include "Core/Config/GraphicsSettings.h" +#include "Core/Config/MainSettings.h" #include "Core/Config/NetplaySettings.h" #include "Core/Config/SYSCONFSettings.h" #include "Core/ConfigManager.h" @@ -575,9 +576,10 @@ void Renderer::DrawDebugText() ImGui::End(); } - const bool show_movie_window = config.m_ShowFrameCount | config.m_ShowLag | - config.m_ShowInputDisplay | config.m_ShowRTC | - config.m_ShowRerecord; + const bool show_movie_window = config.m_ShowFrameCount || config.m_ShowLag || + Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY) || + Config::Get(Config::MAIN_MOVIE_SHOW_RTC) || + Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD); if (show_movie_window) { // Position under the FPS display. @@ -603,11 +605,11 @@ void Renderer::DrawDebugText() } if (SConfig::GetInstance().m_ShowLag) ImGui::Text("Lag: %" PRIu64 "\n", Movie::GetCurrentLagCount()); - if (SConfig::GetInstance().m_ShowInputDisplay) + if (Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY)) ImGui::TextUnformatted(Movie::GetInputDisplay().c_str()); - if (SConfig::GetInstance().m_ShowRTC) + if (Config::Get(Config::MAIN_MOVIE_SHOW_RTC)) ImGui::TextUnformatted(Movie::GetRTCDisplay().c_str()); - if (SConfig::GetInstance().m_ShowRerecord) + if (Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD)) ImGui::TextUnformatted(Movie::GetRerecords().c_str()); } ImGui::End(); @@ -1452,7 +1454,7 @@ bool Renderer::IsFrameDumping() const if (m_screenshot_request.IsSet()) return true; - if (SConfig::GetInstance().m_DumpFrames) + if (Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES)) return true; return false; @@ -1659,7 +1661,7 @@ void Renderer::FrameDumpThreadFunc() m_screenshot_completed.Set(); } - if (SConfig::GetInstance().m_DumpFrames) + if (Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES)) { if (!frame_dump_started) { @@ -1670,7 +1672,7 @@ void Renderer::FrameDumpThreadFunc() // Stop frame dumping if we fail to start. if (!frame_dump_started) - SConfig::GetInstance().m_DumpFrames = false; + Config::SetCurrent(Config::MAIN_MOVIE_DUMP_FRAMES, false); } // If we failed to start frame dumping, don't write a frame. @@ -1741,7 +1743,7 @@ std::string Renderer::GetFrameDumpNextImageFileName() const bool Renderer::StartFrameDumpToImage(const FrameDump::FrameData&) { m_frame_dump_image_counter = 1; - if (!SConfig::GetInstance().m_DumpFramesSilent) + if (!Config::Get(Config::MAIN_MOVIE_DUMP_FRAMES_SILENT)) { // Only check for the presence of the first image to confirm overwriting. // A previous run will always have at least one image, and it's safe to assume that if the user