mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-16 18:35:45 -04:00
Qt: Implement context menu in game list
This commit is contained in:
@ -77,7 +77,7 @@ void HostInterface::CreateAudioStream()
|
||||
m_audio_stream->Reconfigure(AUDIO_SAMPLE_RATE, AUDIO_CHANNELS, AUDIO_BUFFER_SIZE, 4);
|
||||
}
|
||||
|
||||
bool HostInterface::BootSystemFromFile(const char* filename)
|
||||
bool HostInterface::BootSystem(const SystemBootParameters& parameters)
|
||||
{
|
||||
if (!AcquireHostDisplay())
|
||||
{
|
||||
@ -92,7 +92,7 @@ bool HostInterface::BootSystemFromFile(const char* filename)
|
||||
CreateAudioStream();
|
||||
|
||||
m_system = System::Create(this);
|
||||
if (!m_system->Boot(filename))
|
||||
if (!m_system->Boot(parameters))
|
||||
{
|
||||
ReportFormattedError("System failed to boot. The log may contain more information.");
|
||||
DestroySystem();
|
||||
@ -111,11 +111,6 @@ bool HostInterface::BootSystemFromFile(const char* filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HostInterface::BootSystemFromBIOS()
|
||||
{
|
||||
return BootSystemFromFile(nullptr);
|
||||
}
|
||||
|
||||
void HostInterface::PauseSystem(bool paused)
|
||||
{
|
||||
if (paused == m_paused)
|
||||
@ -439,7 +434,8 @@ bool HostInterface::LoadState(const char* filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BootSystemFromFile(nullptr))
|
||||
SystemBootParameters boot_params;
|
||||
if (!BootSystem(boot_params))
|
||||
{
|
||||
ReportFormattedError("Failed to boot system to load state from '%s'.", filename);
|
||||
return false;
|
||||
@ -512,7 +508,9 @@ bool HostInterface::SaveState(bool global, s32 slot)
|
||||
|
||||
bool HostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure)
|
||||
{
|
||||
if (!BootSystemFromFile(filename))
|
||||
SystemBootParameters boot_params;
|
||||
boot_params.filename = filename;
|
||||
if (!BootSystem(boot_params))
|
||||
return false;
|
||||
|
||||
const bool global = m_system->GetRunningCode().empty();
|
||||
@ -762,6 +760,20 @@ std::vector<HostInterface::SaveStateInfo> HostInterface::GetAvailableSaveStates(
|
||||
return si;
|
||||
}
|
||||
|
||||
void HostInterface::DeleteSaveStates(const char* game_code, bool resume)
|
||||
{
|
||||
const std::vector<SaveStateInfo> states(GetAvailableSaveStates(game_code));
|
||||
for (const SaveStateInfo& si : states)
|
||||
{
|
||||
if (si.global || (!resume && si.slot < 0))
|
||||
continue;
|
||||
|
||||
Log_InfoPrintf("Removing save state at '%s'", si.path.c_str());
|
||||
if (!FileSystem::DeleteFile(si.path.c_str()))
|
||||
Log_ErrorPrintf("Failed to delete save state file '%s'", si.path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::string HostInterface::GetMostRecentResumeSaveStatePath() const
|
||||
{
|
||||
std::vector<FILESYSTEM_FIND_DATA> files;
|
||||
@ -970,7 +982,9 @@ void HostInterface::RecreateSystem()
|
||||
}
|
||||
|
||||
DestroySystem();
|
||||
if (!BootSystemFromFile(nullptr))
|
||||
|
||||
SystemBootParameters boot_params;
|
||||
if (!BootSystem(boot_params))
|
||||
{
|
||||
ReportError("Failed to boot system after recreation.");
|
||||
return;
|
||||
|
@ -18,6 +18,7 @@ class HostDisplay;
|
||||
class GameList;
|
||||
|
||||
class System;
|
||||
struct SystemBootParameters;
|
||||
|
||||
class HostInterface
|
||||
{
|
||||
@ -42,8 +43,7 @@ public:
|
||||
/// Access to emulated system.
|
||||
ALWAYS_INLINE System* GetSystem() const { return m_system.get(); }
|
||||
|
||||
bool BootSystemFromFile(const char* filename);
|
||||
bool BootSystemFromBIOS();
|
||||
bool BootSystem(const SystemBootParameters& parameters);
|
||||
void PauseSystem(bool paused);
|
||||
void ResetSystem();
|
||||
void PowerOffSystem();
|
||||
@ -90,6 +90,9 @@ public:
|
||||
/// such as compiling shaders when starting up.
|
||||
void DisplayLoadingScreen(const char* message, int progress_min = -1, int progress_max = -1, int progress_value = -1);
|
||||
|
||||
/// Deletes save states for the specified game code. If resume is set, the resume state is deleted too.
|
||||
void DeleteSaveStates(const char* game_code, bool resume);
|
||||
|
||||
protected:
|
||||
enum : u32
|
||||
{
|
||||
|
@ -30,6 +30,12 @@ Log_SetChannel(System);
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
SystemBootParameters::SystemBootParameters() = default;
|
||||
|
||||
SystemBootParameters::SystemBootParameters(std::string filename_) : filename(filename_) {}
|
||||
|
||||
SystemBootParameters::~SystemBootParameters() = default;
|
||||
|
||||
System::System(HostInterface* host_interface) : m_host_interface(host_interface)
|
||||
{
|
||||
m_cpu = std::make_unique<CPU::Core>();
|
||||
@ -102,14 +108,14 @@ void System::SetCPUExecutionMode(CPUExecutionMode mode)
|
||||
m_cpu_code_cache->SetUseRecompiler(mode == CPUExecutionMode::Recompiler);
|
||||
}
|
||||
|
||||
bool System::Boot(const char* filename)
|
||||
bool System::Boot(const SystemBootParameters& params)
|
||||
{
|
||||
// Load CD image up and detect region.
|
||||
std::unique_ptr<CDImage> media;
|
||||
bool exe_boot = false;
|
||||
if (filename)
|
||||
if (!params.filename.empty())
|
||||
{
|
||||
exe_boot = GameList::IsExeFileName(filename);
|
||||
exe_boot = GameList::IsExeFileName(params.filename.c_str());
|
||||
if (exe_boot)
|
||||
{
|
||||
if (m_region == ConsoleRegion::Auto)
|
||||
@ -120,11 +126,11 @@ bool System::Boot(const char* filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_InfoPrintf("Loading CD image '%s'...", filename);
|
||||
media = CDImage::Open(filename);
|
||||
Log_InfoPrintf("Loading CD image '%s'...", params.filename.c_str());
|
||||
media = CDImage::Open(params.filename.c_str());
|
||||
if (!media)
|
||||
{
|
||||
m_host_interface->ReportFormattedError("Failed to load CD image '%s'", filename);
|
||||
m_host_interface->ReportFormattedError("Failed to load CD image '%s'", params.filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -134,7 +140,8 @@ bool System::Boot(const char* filename)
|
||||
if (detected_region)
|
||||
{
|
||||
m_region = detected_region.value();
|
||||
Log_InfoPrintf("Auto-detected %s region for '%s'", Settings::GetConsoleRegionName(m_region), filename);
|
||||
Log_InfoPrintf("Auto-detected %s region for '%s'", Settings::GetConsoleRegionName(m_region),
|
||||
params.filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -172,19 +179,22 @@ bool System::Boot(const char* filename)
|
||||
BIOS::PatchBIOSEnableTTY(*bios_image, bios_hash);
|
||||
|
||||
// Load EXE late after BIOS.
|
||||
if (exe_boot && !LoadEXE(filename, *bios_image))
|
||||
if (exe_boot && !LoadEXE(params.filename.c_str(), *bios_image))
|
||||
{
|
||||
m_host_interface->ReportFormattedError("Failed to load EXE file '%s'", filename);
|
||||
m_host_interface->ReportFormattedError("Failed to load EXE file '%s'", params.filename.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Notify change of disc.
|
||||
UpdateRunningGame(filename, media.get());
|
||||
UpdateRunningGame(params.filename.c_str(), media.get());
|
||||
|
||||
// Insert CD, and apply fastboot patch if enabled.
|
||||
m_cdrom->InsertMedia(std::move(media));
|
||||
if (m_cdrom->HasMedia() && GetSettings().bios_patch_fast_boot)
|
||||
if (m_cdrom->HasMedia() &&
|
||||
(params.override_fast_boot.has_value() ? params.override_fast_boot.value() : GetSettings().bios_patch_fast_boot))
|
||||
{
|
||||
BIOS::PatchBIOSFastBoot(*bios_image, bios_hash);
|
||||
}
|
||||
|
||||
// Load the patched BIOS up.
|
||||
m_bus->SetBIOS(*bios_image);
|
||||
|
@ -28,11 +28,21 @@ class SPU;
|
||||
class MDEC;
|
||||
class SIO;
|
||||
|
||||
struct SystemBootParameters
|
||||
{
|
||||
SystemBootParameters();
|
||||
SystemBootParameters(std::string filename_);
|
||||
~SystemBootParameters();
|
||||
|
||||
std::string filename;
|
||||
std::optional<bool> override_fast_boot;
|
||||
};
|
||||
|
||||
class System
|
||||
{
|
||||
public:
|
||||
friend TimingEvent;
|
||||
|
||||
public:
|
||||
~System();
|
||||
|
||||
/// Creates a new System.
|
||||
@ -75,7 +85,7 @@ public:
|
||||
float GetAverageFrameTime() const { return m_average_frame_time; }
|
||||
float GetWorstFrameTime() const { return m_worst_frame_time; }
|
||||
|
||||
bool Boot(const char* filename);
|
||||
bool Boot(const SystemBootParameters& params);
|
||||
void Reset();
|
||||
|
||||
bool LoadState(ByteStream* state);
|
||||
|
Reference in New Issue
Block a user