diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index b96d256b1..4083bd828 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -462,7 +462,7 @@ void HostInterface::SetUserDirectory() } } -std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...) +std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...) const { std::va_list ap; va_start(ap, format); @@ -480,6 +480,11 @@ std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...) } } +std::string HostInterface::GetSettingsFileName() const +{ + return GetUserDirectoryRelativePath("settings.ini"); +} + void HostInterface::RunFrame() { m_frame_timer.Reset(); diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 3f12d1115..f300e5cb8 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -65,7 +65,7 @@ public: const std::string& GetUserDirectory() const { return m_user_directory; } /// Returns a path relative to the user directory. - std::string GetUserDirectoryRelativePath(const char* format, ...); + std::string GetUserDirectoryRelativePath(const char* format, ...) const; protected: using ThrottleClock = std::chrono::steady_clock; @@ -90,6 +90,9 @@ protected: void SetUserDirectory(); + /// Returns the path of the settings file. + std::string GetSettingsFileName() const; + void RunFrame(); /// Throttles the system, i.e. sleeps until it's time to execute the next frame. diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 4d96af4a7..225fc3c14 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -22,7 +22,7 @@ Log_SetChannel(QtHostInterface); #endif QtHostInterface::QtHostInterface(QObject* parent) - : QObject(parent), m_qsettings("duckstation-qt.ini", QSettings::IniFormat) + : QObject(parent), HostInterface(), m_qsettings(QString::fromStdString(GetSettingsFileName()), QSettings::IniFormat) { checkSettings(); createGameList(); diff --git a/src/duckstation/sdl_host_interface.cpp b/src/duckstation/sdl_host_interface.cpp index 6ea64789f..7674ba552 100644 --- a/src/duckstation/sdl_host_interface.cpp +++ b/src/duckstation/sdl_host_interface.cpp @@ -25,7 +25,7 @@ Log_SetChannel(SDLHostInterface); #include #endif -SDLHostInterface::SDLHostInterface() : m_settings_filename("settings.ini") +SDLHostInterface::SDLHostInterface() { // Increase timer/sleep resolution since we use it for throttling. #ifdef WIN32 @@ -152,7 +152,7 @@ void SDLHostInterface::CreateAudioStream() void SDLHostInterface::SaveSettings() { - SDLSettingsInterface si(m_settings_filename.c_str()); + SDLSettingsInterface si(GetSettingsFileName().c_str()); m_settings.Save(si); } @@ -238,7 +238,7 @@ std::unique_ptr SDLHostInterface::Create(const char* filename std::unique_ptr intf = std::make_unique(); // Settings need to be loaded prior to creating the window for OpenGL bits. - SDLSettingsInterface si(intf->m_settings_filename.c_str()); + SDLSettingsInterface si(intf->GetSettingsFileName().c_str()); intf->m_settings.Load(si); if (!intf->CreateSDLWindow()) diff --git a/src/duckstation/sdl_host_interface.h b/src/duckstation/sdl_host_interface.h index b66c3f3e9..592d27f0b 100644 --- a/src/duckstation/sdl_host_interface.h +++ b/src/duckstation/sdl_host_interface.h @@ -128,8 +128,6 @@ private: SDL_Window* m_window = nullptr; std::unique_ptr m_app_icon_texture; - std::string m_settings_filename; - KeyboardControllerActionMap m_keyboard_button_mapping; std::map m_sdl_controllers;