CommonHostInterface: Add save state selector UI

This commit is contained in:
Connor McLaughlin
2020-04-21 02:50:57 +10:00
parent 7c2244f20f
commit 2a710798cc
7 changed files with 365 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include "core/game_list.h"
#include "core/gpu.h"
#include "core/system.h"
#include "save_state_selector_ui.h"
#include "scmversion/scmversion.h"
#ifdef WITH_SDL2
#include "sdl_audio_stream.h"
@ -32,6 +33,8 @@ bool CommonHostInterface::Initialize()
if (!FileSystem::SetWorkingDirectory(m_user_directory.c_str()))
Log_ErrorPrintf("Failed to set working directory to '%s'", m_user_directory.c_str());
m_save_state_selector_ui = std::make_unique<FrontendCommon::SaveStateSelectorUI>(this);
RegisterGeneralHotkeys();
RegisterGraphicsHotkeys();
RegisterSaveStateHotkeys();
@ -360,6 +363,14 @@ void CommonHostInterface::OnControllerTypeChanged(u32 slot)
UpdateInputMap();
}
void CommonHostInterface::DrawImGuiWindows()
{
HostInterface::DrawImGuiWindows();
if (m_save_state_selector_ui->IsOpen())
m_save_state_selector_ui->Draw();
}
void CommonHostInterface::SetDefaultSettings(SettingsInterface& si)
{
HostInterface::SetDefaultSettings(si);
@ -773,6 +784,27 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
void CommonHostInterface::RegisterSaveStateHotkeys()
{
RegisterHotkey(StaticString("Save States"), StaticString("LoadSelectedSaveState"),
StaticString("Load From Selected Slot"), [this](bool pressed) {
if (!pressed)
m_save_state_selector_ui->LoadCurrentSlot();
});
RegisterHotkey(StaticString("Save States"), StaticString("SaveSelectedSaveState"),
StaticString("Save To Selected Slot"), [this](bool pressed) {
if (!pressed)
m_save_state_selector_ui->SaveCurrentSlot();
});
RegisterHotkey(StaticString("Save States"), StaticString("SelectPreviousSaveStateSlot"),
StaticString("Select Previous Save Slot"), [this](bool pressed) {
if (!pressed)
m_save_state_selector_ui->SelectPreviousSlot();
});
RegisterHotkey(StaticString("Save States"), StaticString("SelectNextSaveStateSlot"),
StaticString("Select Next Save Slot"), [this](bool pressed) {
if (!pressed)
m_save_state_selector_ui->SelectNextSlot();
});
for (u32 global_i = 0; global_i < 2; global_i++)
{
const bool global = ConvertToBoolUnchecked(global_i);