diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 29b7bb5403..e267c8a662 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -19,6 +19,7 @@ #include "CommonPaths.h" #include "FileUtil.h" #include "StringUtil.h" +#include "ConfigManager.h" #ifdef _WIN32 #include @@ -669,7 +670,7 @@ std::string GetSysDirectory() // Returns a string with a Dolphin data dir or file in the user's home // directory. To be used in "multi-user" mode (that is, installed). -std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) +const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath) { static std::string paths[NUM_PATH_INDICES]; @@ -742,6 +743,20 @@ std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath) return paths[DirIDX]; } +std::string GetThemeDir() +{ + std::string theme = SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/"; + std::string dir = File::GetUserPath(D_THEMES_IDX) + theme; + +#if !defined(_WIN32) + // If theme does not exist in user's dir load from shared directory + if (!File::Exists(dir)) + dir = SHARED_USER_DIR THEMES_DIR "/" + theme; +#endif + + return dir; +} + bool WriteStringToFile(bool text_file, const std::string &str, const char *filename) { return File::IOFile(filename, text_file ? "w" : "wb").WriteBytes(str.data(), str.size()); diff --git a/Source/Core/Common/Src/FileUtil.h b/Source/Core/Common/Src/FileUtil.h index 2747c50cf4..9376f272c8 100644 --- a/Source/Core/Common/Src/FileUtil.h +++ b/Source/Core/Common/Src/FileUtil.h @@ -132,7 +132,10 @@ bool SetCurrentDir(const std::string &directory); // Returns a pointer to a string with a Dolphin data dir in the user's home // directory. To be used in "multi-user" mode (that is, installed). -std::string &GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); +const std::string& GetUserPath(const unsigned int DirIDX, const std::string &newPath=""); + +// probably doesn't belong here +std::string GetThemeDir(); // Returns the path to where the sys file are std::string GetSysDirectory(); diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index 4272d9ef90..3240070c14 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -617,16 +617,17 @@ void CConfigMain::CreateGUIControls() SplitPath(filename, NULL, &name, &ext); name += ext; - if (-1 == theme_selection->FindString(name)) - theme_selection->Append(name); + auto const wxname = StrToWxStr(name); + if (-1 == theme_selection->FindString(wxname)) + theme_selection->Append(wxname); }); - theme_selection->SetStringSelection(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name); + theme_selection->SetStringSelection(StrToWxStr(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name)); // std::function = avoid error on msvc theme_selection->Bind(wxEVT_COMMAND_CHOICE_SELECTED, std::function([theme_selection](wxEvent&) { - SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name = theme_selection->GetStringSelection(); + SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name = WxStrToStr(theme_selection->GetStringSelection()); main_frame->InitBitmaps(); main_frame->UpdateGameList(); })); diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 8462a82490..8c33575fc4 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -509,14 +509,7 @@ void CFrame::RecreateToolbar() void CFrame::InitBitmaps() { - std::string theme(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/"); - std::string dir(File::GetUserPath(D_THEMES_IDX) + theme); - -#if !defined(_WIN32) - // If theme does not exist in user's dir load from shared directory - if (!File::Exists(dir)) - dir = SHARED_USER_DIR THEMES_DIR "/" + theme; -#endif + auto const dir = StrToWxStr(File::GetThemeDir()); m_Bitmaps[Toolbar_FileOpen].LoadFile(dir + "open.png", wxBITMAP_TYPE_PNG); m_Bitmaps[Toolbar_Refresh].LoadFile(dir + "refresh.png", wxBITMAP_TYPE_PNG); diff --git a/Source/Core/DolphinWX/Src/ISOFile.cpp b/Source/Core/DolphinWX/Src/ISOFile.cpp index f28a6bca03..584e35d0d9 100644 --- a/Source/Core/DolphinWX/Src/ISOFile.cpp +++ b/Source/Core/DolphinWX/Src/ISOFile.cpp @@ -137,16 +137,8 @@ GameListItem::GameListItem(const std::string& _rFileName) } else { - std::string theme = SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name + "/"; - std::string dir = File::GetUserPath(D_THEMES_IDX) + theme; - -#if !defined(_WIN32) - // If theme does not exist in user's dir load from shared directory - if (!File::Exists(dir)) - dir = SHARED_USER_DIR THEMES_DIR "/" + theme; -#endif // default banner - m_Image = wxImage(dir + "nobanner.png", wxBITMAP_TYPE_PNG); + m_Image = wxImage(StrToWxStr(File::GetThemeDir()) + "nobanner.png", wxBITMAP_TYPE_PNG); } }