diff --git a/Utilities/config_context.cpp b/Utilities/config_context.cpp index 685328f79a..921de6b6c7 100644 --- a/Utilities/config_context.cpp +++ b/Utilities/config_context.cpp @@ -1,6 +1,5 @@ #include "stdafx.h" #include "config_context.h" -#include "convert.h" #include "StrFmt.h" #include #include diff --git a/Utilities/config_context.h b/Utilities/config_context.h index ebc0eaca7f..fcbcfb17d7 100644 --- a/Utilities/config_context.h +++ b/Utilities/config_context.h @@ -1,6 +1,7 @@ #pragma once #include #include +#include "convert.h" class config_context_t { diff --git a/rpcs3/CMakeLists.txt b/rpcs3/CMakeLists.txt index 30a99ecb0e..804cf49588 100644 --- a/rpcs3/CMakeLists.txt +++ b/rpcs3/CMakeLists.txt @@ -139,6 +139,7 @@ file( GLOB_RECURSE RPCS3_SRC "${RPCS3_SRC_DIR}/rpcs3.cpp" +"${RPCS3_SRC_DIR}/config.cpp" "${RPCS3_SRC_DIR}/Ini.cpp" "${RPCS3_SRC_DIR}/../Utilities/GNU.cpp" "${RPCS3_SRC_DIR}/Emu/*" diff --git a/rpcs3/config.cpp b/rpcs3/config.cpp index 5d4960f6c9..cd38ad0e60 100644 --- a/rpcs3/config.cpp +++ b/rpcs3/config.cpp @@ -32,13 +32,21 @@ namespace rpcs3 void config_t::load() { if (!m_path.empty()) - deserialize(std::ifstream{ m_path }); + { + std::ifstream stream{ m_path }; + if (stream) + deserialize(stream); + } } void config_t::save() const { if (!m_path.empty()) - serialize(std::ofstream{ m_path }); + { + std::ofstream stream{ m_path }; + if (stream) + serialize(stream); + } } config_t config{ "rpcs3.new.ini" }; diff --git a/rpcs3/config.h b/rpcs3/config.h index c6c95e4be8..9f14b95ac7 100644 --- a/rpcs3/config.h +++ b/rpcs3/config.h @@ -9,39 +9,42 @@ enum class audio_output_type XAudio2 }; -template<> -struct convert::to_impl_t +namespace convert { - static std::string func(audio_output_type value) + template<> + struct to_impl_t { - switch (value) + static std::string func(audio_output_type value) { - case audio_output_type::Null: return "Null"; - case audio_output_type::OpenAL: return "OpenAL"; - case audio_output_type::XAudio2: return "XAudio2"; + switch (value) + { + case audio_output_type::Null: return "Null"; + case audio_output_type::OpenAL: return "OpenAL"; + case audio_output_type::XAudio2: return "XAudio2"; + } + + return "Unknown"; } + }; - return "Unknown"; - } -}; - -template<> -struct convert::to_impl_t -{ - static audio_output_type func(const std::string &value) + template<> + struct to_impl_t { - if (value == "Null") + static audio_output_type func(const std::string &value) + { + if (value == "Null") + return audio_output_type::Null; + + if (value == "OpenAL") + return audio_output_type::OpenAL; + + if (value == "XAudio2") + return audio_output_type::XAudio2; + return audio_output_type::Null; - - if (value == "OpenAL") - return audio_output_type::OpenAL; - - if (value == "XAudio2") - return audio_output_type::XAudio2; - - return audio_output_type::Null; - } -}; + } + }; +} enum class rsx_renderer_type { @@ -50,39 +53,42 @@ enum class rsx_renderer_type DX12 }; -template<> -struct convert::to_impl_t +namespace convert { - static std::string func(rsx_renderer_type value) + template<> + struct to_impl_t { - switch (value) + static std::string func(rsx_renderer_type value) { - case rsx_renderer_type::Null: return "Null"; - case rsx_renderer_type::OpenGL: return "OpenGL"; - case rsx_renderer_type::DX12: return "DX12"; + switch (value) + { + case rsx_renderer_type::Null: return "Null"; + case rsx_renderer_type::OpenGL: return "OpenGL"; + case rsx_renderer_type::DX12: return "DX12"; + } + + return "Unknown"; } + }; - return "Unknown"; - } -}; - -template<> -struct convert::to_impl_t -{ - static rsx_renderer_type func(const std::string &value) + template<> + struct to_impl_t { - if (value == "Null") + static rsx_renderer_type func(const std::string &value) + { + if (value == "Null") + return rsx_renderer_type::Null; + + if (value == "OpenGL") + return rsx_renderer_type::OpenGL; + + if (value == "DX12") + return rsx_renderer_type::DX12; + return rsx_renderer_type::Null; - - if (value == "OpenGL") - return rsx_renderer_type::OpenGL; - - if (value == "DX12") - return rsx_renderer_type::DX12; - - return rsx_renderer_type::Null; - } -}; + } + }; +} enum class ppu_decoder_type { @@ -91,39 +97,42 @@ enum class ppu_decoder_type recompiler_llvm }; -template<> -struct convert::to_impl_t +namespace convert { - static std::string func(ppu_decoder_type value) + template<> + struct to_impl_t { - switch (value) + static std::string func(ppu_decoder_type value) { - case ppu_decoder_type::interpreter: return "interpreter"; - case ppu_decoder_type::interpreter2: return "interpreter2"; - case ppu_decoder_type::recompiler_llvm: return "recompiler_llvm"; + switch (value) + { + case ppu_decoder_type::interpreter: return "interpreter"; + case ppu_decoder_type::interpreter2: return "interpreter2"; + case ppu_decoder_type::recompiler_llvm: return "recompiler_llvm"; + } + + return "Unknown"; } + }; - return "Unknown"; - } -}; - -template<> -struct convert::to_impl_t -{ - static ppu_decoder_type func(const std::string &value) + template<> + struct to_impl_t { - if (value == "interpreter") + static ppu_decoder_type func(const std::string &value) + { + if (value == "interpreter") + return ppu_decoder_type::interpreter; + + if (value == "interpreter2") + return ppu_decoder_type::interpreter2; + + if (value == "DX12") + return ppu_decoder_type::recompiler_llvm; + return ppu_decoder_type::interpreter; - - if (value == "interpreter2") - return ppu_decoder_type::interpreter2; - - if (value == "DX12") - return ppu_decoder_type::recompiler_llvm; - - return ppu_decoder_type::interpreter; - } -}; + } + }; +} enum class spu_decoder_type @@ -133,39 +142,42 @@ enum class spu_decoder_type recompiler_asmjit }; -template<> -struct convert::to_impl_t +namespace convert { - static std::string func(spu_decoder_type value) + template<> + struct to_impl_t { - switch (value) + static std::string func(spu_decoder_type value) { - case spu_decoder_type::interpreter_precise: return "interpreter_precise"; - case spu_decoder_type::interpreter_fast: return "interpreter_fast"; - case spu_decoder_type::recompiler_asmjit: return "recompiler_asmjit"; + switch (value) + { + case spu_decoder_type::interpreter_precise: return "interpreter_precise"; + case spu_decoder_type::interpreter_fast: return "interpreter_fast"; + case spu_decoder_type::recompiler_asmjit: return "recompiler_asmjit"; + } + + return "Unknown"; } + }; - return "Unknown"; - } -}; - -template<> -struct convert::to_impl_t -{ - static spu_decoder_type func(const std::string &value) + template<> + struct to_impl_t { - if (value == "interpreter_precise") + static spu_decoder_type func(const std::string &value) + { + if (value == "interpreter_precise") + return spu_decoder_type::interpreter_precise; + + if (value == "interpreter_fast") + return spu_decoder_type::interpreter_fast; + + if (value == "recompiler_asmjit") + return spu_decoder_type::recompiler_asmjit; + return spu_decoder_type::interpreter_precise; - - if (value == "interpreter_fast") - return spu_decoder_type::interpreter_fast; - - if (value == "recompiler_asmjit") - return spu_decoder_type::recompiler_asmjit; - - return spu_decoder_type::interpreter_precise; - } -}; + } + }; +} namespace rpcs3 {