HostInterface: Make SetUserDirectory() overridable by frontends

This commit is contained in:
Connor McLaughlin
2020-04-05 22:59:06 +10:00
parent 11e8a91e30
commit e7640d5367
13 changed files with 188 additions and 108 deletions

View File

@ -1,6 +1,7 @@
#include "common_host_interface.h"
#include "common/assert.h"
#include "common/audio_stream.h"
#include "common/file_system.h"
#include "common/log.h"
#include "common/string_util.h"
#include "controller_interface.h"
@ -21,6 +22,13 @@ CommonHostInterface::~CommonHostInterface() = default;
bool CommonHostInterface::Initialize()
{
if (!HostInterface::Initialize())
return false;
// Change to the user directory so that all default/relative paths in the config are after this.
if (!FileSystem::SetWorkingDirectory(m_user_directory.c_str()))
Log_ErrorPrintf("Failed to set working directory to '%s'", m_user_directory.c_str());
RegisterGeneralHotkeys();
RegisterGraphicsHotkeys();
RegisterSaveStateHotkeys();
@ -41,8 +49,12 @@ bool CommonHostInterface::Initialize()
void CommonHostInterface::Shutdown()
{
HostInterface::Shutdown();
m_system.reset();
m_audio_stream.reset();
if (m_display)
ReleaseHostDisplay();
if (m_controller_interface)
{

View File

@ -33,8 +33,8 @@ public:
using HotkeyInfoList = std::vector<HotkeyInfo>;
virtual bool Initialize();
virtual void Shutdown();
virtual bool Initialize() override;
virtual void Shutdown() override;
/// Returns a list of all available hotkeys.
ALWAYS_INLINE const HotkeyInfoList& GetHotkeyInfoList() const { return m_hotkeys; }