From 8d424b114ae98243744a118e44d38e0a40645682 Mon Sep 17 00:00:00 2001
From: Fog <christhecoolist@gmail.com>
Date: Sun, 12 Oct 2014 23:53:10 -0400
Subject: [PATCH] Move bDumpFrames to SConfig (and it's references)

---
 Source/Core/Core/ConfigManager.cpp                   |  2 ++
 Source/Core/Core/ConfigManager.h                     |  1 +
 Source/Core/DolphinWX/FrameTools.cpp                 |  6 +++---
 Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp  |  1 -
 Source/Core/VideoBackends/D3D/Render.cpp             |  6 +++---
 Source/Core/VideoBackends/OGL/Render.cpp             | 12 ++++++------
 Source/Core/VideoBackends/Software/DebugUtil.cpp     |  4 +++-
 Source/Core/VideoBackends/Software/SWVideoConfig.cpp |  1 -
 Source/Core/VideoBackends/Software/SWVideoConfig.h   |  1 -
 Source/Core/VideoCommon/RenderBase.cpp               |  3 ++-
 Source/Core/VideoCommon/VideoConfig.h                |  1 -
 11 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp
index 8d0f8d2cb0..901b5012d9 100644
--- a/Source/Core/Core/ConfigManager.cpp
+++ b/Source/Core/Core/ConfigManager.cpp
@@ -327,6 +327,7 @@ void SConfig::SaveMovieSettings(IniFile& ini)
 
 	movie->Set("PauseMovie", m_PauseMovie);
 	movie->Set("Author", m_strMovieAuthor);
+	movie->Set("DumpFrames", m_DumpFrames);
 }
 
 void SConfig::SaveDSPSettings(IniFile& ini)
@@ -554,6 +555,7 @@ void SConfig::LoadMovieSettings(IniFile& ini)
 
 	movie->Get("PauseMovie", &m_PauseMovie, false);
 	movie->Get("Author", &m_strMovieAuthor, "");
+	movie->Get("DumpFrames", &m_DumpFrames, false);
 }
 
 void SConfig::LoadDSPSettings(IniFile& ini)
diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h
index de7e45b316..8fc8cf8f44 100644
--- a/Source/Core/Core/ConfigManager.h
+++ b/Source/Core/Core/ConfigManager.h
@@ -89,6 +89,7 @@ struct SConfig : NonCopyable
 	bool m_ShowFrameCount;
 	std::string m_strMovieAuthor;
 	unsigned int m_FrameSkip;
+	bool m_DumpFrames;
 
 	// DSP settings
 	bool m_DSPEnableJIT;
diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp
index 4cb00431c7..fd5ca74bea 100644
--- a/Source/Core/DolphinWX/FrameTools.cpp
+++ b/Source/Core/DolphinWX/FrameTools.cpp
@@ -220,7 +220,7 @@ wxMenuBar* CFrame::CreateMenu()
 	movieMenu->Check(IDM_RECORDREADONLY, true);
 	movieMenu->AppendSeparator();
 	movieMenu->AppendCheckItem(IDM_TOGGLE_DUMPFRAMES, _("Dump frames"));
-	movieMenu->Check(IDM_TOGGLE_DUMPFRAMES, g_ActiveConfig.bDumpFrames);
+	movieMenu->Check(IDM_TOGGLE_DUMPFRAMES, SConfig::GetInstance().m_DumpFrames);
 	movieMenu->AppendCheckItem(IDM_TOGGLE_DUMPAUDIO, _("Dump audio"));
 	movieMenu->Check(IDM_TOGGLE_DUMPAUDIO, SConfig::GetInstance().m_DumpAudio);
 	menubar->Append(movieMenu, _("&Movie"));
@@ -729,8 +729,8 @@ void CFrame::OnTogglePauseMovie(wxCommandEvent& WXUNUSED (event))
 
 void CFrame::OnToggleDumpFrames(wxCommandEvent& WXUNUSED(event))
 {
-	g_Config.bDumpFrames = !g_Config.bDumpFrames;
-	g_SWVideoConfig.bDumpFrames = !g_SWVideoConfig.bDumpFrames;
+	SConfig::GetInstance().m_DumpFrames = !SConfig::GetInstance().m_DumpFrames;
+	SConfig::GetInstance().SaveSettings();
 }
 
 void CFrame::OnToggleDumpAudio(wxCommandEvent& WXUNUSED(event))
diff --git a/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp
index ab97113f55..60cea18ac4 100644
--- a/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp
+++ b/Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp
@@ -102,7 +102,6 @@ SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std
 
 	szr_utility->Add(new SettingCheckBox(page_general, _("Dump Textures"), "", vconfig.bDumpTextures));
 	szr_utility->Add(new SettingCheckBox(page_general, _("Dump Objects"), "", vconfig.bDumpObjects));
-	szr_utility->Add(new SettingCheckBox(page_general, _("Dump Frames"), "", vconfig.bDumpFrames));
 
 	// - debug only
 	wxStaticBoxSizer* const group_debug_only_utility = new wxStaticBoxSizer(wxHORIZONTAL, page_general, _("Debug Only"));
diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp
index 645160abda..d1f3e291ac 100644
--- a/Source/Core/VideoBackends/D3D/Render.cpp
+++ b/Source/Core/VideoBackends/D3D/Render.cpp
@@ -713,7 +713,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
 {
 	if (g_bSkipCurrentFrame || (!XFBWrited && !g_ActiveConfig.RealXFBEnabled()) || !fbWidth || !fbHeight)
 	{
-		if (g_ActiveConfig.bDumpFrames && !frame_data.empty())
+		if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
 			AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
 
 		Core::Callback_VideoCopiedToXFB(false);
@@ -724,7 +724,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
 	const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, &xfbCount);
 	if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
 	{
-		if (g_ActiveConfig.bDumpFrames && !frame_data.empty())
+		if (SConfig::GetInstance().m_DumpFrames && !frame_data.empty())
 			AVIDump::AddFrame(&frame_data[0], fbWidth, fbHeight);
 
 		Core::Callback_VideoCopiedToXFB(false);
@@ -833,7 +833,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
 
 	// Dump frames
 	static int w = 0, h = 0;
-	if (g_ActiveConfig.bDumpFrames)
+	if (SConfig::GetInstance().m_DumpFrames)
 	{
 		static int s_recordWidth;
 		static int s_recordHeight;
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp
index 99dd6548be..e8e936b133 100644
--- a/Source/Core/VideoBackends/OGL/Render.cpp
+++ b/Source/Core/VideoBackends/OGL/Render.cpp
@@ -1366,10 +1366,10 @@ void Renderer::SetBlendMode(bool forceUpdate)
 static void DumpFrame(const std::vector<u8>& data, int w, int h)
 {
 #if defined(HAVE_LIBAV) || defined(_WIN32)
-		if (g_ActiveConfig.bDumpFrames && !data.empty())
-		{
-			AVIDump::AddFrame(&data[0], w, h);
-		}
+	if (SConfig::GetInstance().m_DumpFrames && !data.empty())
+	{
+		AVIDump::AddFrame(&data[0], w, h);
+	}
 #endif
 }
 
@@ -1516,7 +1516,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
 	if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL)
 	{
 #if defined _WIN32 || defined HAVE_LIBAV
-		if (g_ActiveConfig.bDumpFrames)
+		if (SConfig::GetInstance().m_DumpFrames)
 		{
 			std::lock_guard<std::mutex> lk(s_criticalScreenshot);
 			if (frame_data.empty() || w != flipped_trc.GetWidth() ||
@@ -1577,7 +1577,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
 			bLastFrameDumped = false;
 		}
 #else
-		if (g_ActiveConfig.bDumpFrames)
+		if (SConfig::GetInstance().m_DumpFrames)
 		{
 			std::lock_guard<std::mutex> lk(s_criticalScreenshot);
 			std::string movie_file_name;
diff --git a/Source/Core/VideoBackends/Software/DebugUtil.cpp b/Source/Core/VideoBackends/Software/DebugUtil.cpp
index f5740d5883..dc198c2e99 100644
--- a/Source/Core/VideoBackends/Software/DebugUtil.cpp
+++ b/Source/Core/VideoBackends/Software/DebugUtil.cpp
@@ -6,6 +6,8 @@
 #include "Common/FileUtil.h"
 #include "Common/StringUtil.h"
 
+#include "Core/ConfigManager.h"
+
 #include "VideoBackends/Software/BPMemLoader.h"
 #include "VideoBackends/Software/DebugUtil.h"
 #include "VideoBackends/Software/EfbInterface.h"
@@ -253,7 +255,7 @@ void OnFrameEnd(u32 width, u32 height)
 {
 	if (!g_bSkipCurrentFrame)
 	{
-		if (g_SWVideoConfig.bDumpFrames)
+		if (SConfig::GetInstance().m_DumpFrames)
 		{
 			DumpColorTexture(StringFromFormat("%sframe%i_color.png",
 					File::GetUserPath(D_DUMPFRAMES_IDX).c_str(), swstats.frameCount), width, height);
diff --git a/Source/Core/VideoBackends/Software/SWVideoConfig.cpp b/Source/Core/VideoBackends/Software/SWVideoConfig.cpp
index 408cef6a2e..d283ccdb95 100644
--- a/Source/Core/VideoBackends/Software/SWVideoConfig.cpp
+++ b/Source/Core/VideoBackends/Software/SWVideoConfig.cpp
@@ -21,7 +21,6 @@ SWVideoConfig::SWVideoConfig()
 
 	bDumpTextures = false;
 	bDumpObjects = false;
-	bDumpFrames = false;
 
 	bZComploc = true;
 	bZFreeze = true;
diff --git a/Source/Core/VideoBackends/Software/SWVideoConfig.h b/Source/Core/VideoBackends/Software/SWVideoConfig.h
index 758f9bb722..6b42adaf10 100644
--- a/Source/Core/VideoBackends/Software/SWVideoConfig.h
+++ b/Source/Core/VideoBackends/Software/SWVideoConfig.h
@@ -31,7 +31,6 @@ struct SWVideoConfig : NonCopyable
 
 	bool bDumpTextures;
 	bool bDumpObjects;
-	bool bDumpFrames;
 
 	// Debug only
 	bool bDumpTevStages;
diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp
index 921073f17a..18b622b513 100644
--- a/Source/Core/VideoCommon/RenderBase.cpp
+++ b/Source/Core/VideoCommon/RenderBase.cpp
@@ -19,6 +19,7 @@
 #include "Common/StringUtil.h"
 #include "Common/Timer.h"
 
+#include "Core/ConfigManager.h"
 #include "Core/Core.h"
 #include "Core/Host.h"
 #include "Core/FifoPlayer/FifoRecorder.h"
@@ -97,7 +98,7 @@ Renderer::~Renderer()
 	efb_scale_numeratorX = efb_scale_numeratorY = efb_scale_denominatorX = efb_scale_denominatorY = 1;
 
 #if defined _WIN32 || defined HAVE_LIBAV
-	if (g_ActiveConfig.bDumpFrames && bLastFrameDumped && bAVIDumping)
+	if (SConfig::GetInstance().m_DumpFrames && bLastFrameDumped && bAVIDumping)
 		AVIDump::Stop();
 #else
 	if (pFrameDump.IsOpen())
diff --git a/Source/Core/VideoCommon/VideoConfig.h b/Source/Core/VideoCommon/VideoConfig.h
index 715eaff89c..07436d1610 100644
--- a/Source/Core/VideoCommon/VideoConfig.h
+++ b/Source/Core/VideoCommon/VideoConfig.h
@@ -94,7 +94,6 @@ struct VideoConfig final
 	bool bDumpTextures;
 	bool bHiresTextures;
 	bool bDumpEFBTarget;
-	bool bDumpFrames;
 	bool bUseFFV1;
 	bool bFreeLook;
 	bool bAnaglyphStereo;