parent
d5432da082
commit
3a661a1c3d
|
@ -107,11 +107,17 @@ public:
|
|||
|
||||
ALWAYS_INLINE bool IsOpen() const { return static_cast<bool>(m_zip); }
|
||||
|
||||
bool Open(const char* name)
|
||||
bool Open(bool cheats)
|
||||
{
|
||||
if (m_zip)
|
||||
return true;
|
||||
|
||||
#ifndef __ANDROID__
|
||||
const char* name = cheats ? "cheats.zip" : "patches.zip";
|
||||
#else
|
||||
const char* name = cheats ? "patchcodes.zip" : "patches.zip";
|
||||
#endif
|
||||
|
||||
Error error;
|
||||
std::optional<DynamicHeapArray<u8>> data = Host::ReadResourceFile(name, false, &error);
|
||||
if (!data.has_value())
|
||||
|
@ -398,10 +404,7 @@ void Cheats::EnumerateChtFiles(const std::string_view serial, std::optional<Game
|
|||
const std::unique_lock lock(s_zip_mutex);
|
||||
CheatArchive& archive = cheats ? s_cheats_zip : s_patches_zip;
|
||||
if (!archive.IsOpen())
|
||||
{
|
||||
const char* archive_name = cheats ? "cheats.zip" : "patches.zip";
|
||||
archive.Open(archive_name);
|
||||
}
|
||||
archive.Open(cheats);
|
||||
|
||||
if (archive.IsOpen())
|
||||
{
|
||||
|
@ -701,6 +704,36 @@ bool Cheats::SaveCodesToFile(const char* path, const CodeInfoList& codes, Error*
|
|||
return true;
|
||||
}
|
||||
|
||||
void Cheats::RemoveAllCodes(const std::string_view serial, const std::string_view title, std::optional<GameHash> hash)
|
||||
{
|
||||
Error error;
|
||||
std::string path = GetChtFilename(serial, hash, true);
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
|
||||
// check for a non-hashed path and remove that too
|
||||
path = GetChtFilename(serial, std::nullopt, true);
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
|
||||
// and a legacy cht file with the game title
|
||||
if (!title.empty())
|
||||
{
|
||||
path = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.cht", EmuFolders::Cheats, Path::SanitizeFileName(title));
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string Cheats::GetChtFilename(const std::string_view serial, std::optional<GameHash> hash, bool cheats)
|
||||
{
|
||||
return Path::Combine(cheats ? EmuFolders::Cheats : EmuFolders::Patches, GetChtTemplate(serial, hash, false));
|
||||
|
|
|
@ -117,6 +117,9 @@ extern bool UpdateCodeInFile(const char* path, const std::string_view name, cons
|
|||
/// Updates or adds multiple codes to the file, rewriting it.
|
||||
extern bool SaveCodesToFile(const char* path, const CodeInfoList& codes, Error* error);
|
||||
|
||||
/// Removes any .cht files for the specified game.
|
||||
extern void RemoveAllCodes(const std::string_view serial, const std::string_view title, std::optional<GameHash> hash);
|
||||
|
||||
/// Returns the path to a new cheat/patch cht for the specified serial and hash.
|
||||
extern std::string GetChtFilename(const std::string_view serial, std::optional<GameHash> hash, bool cheats);
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ struct Settings
|
|||
bool display_stretch_vertically : 1 = false;
|
||||
bool display_auto_resize_window : 1 = false;
|
||||
float display_pre_frame_sleep_buffer = DEFAULT_DISPLAY_PRE_FRAME_SLEEP_BUFFER;
|
||||
float display_osd_scale = 100.0f;
|
||||
float display_osd_scale = DEFAULT_OSD_SCALE;
|
||||
float display_osd_margin = 0.0f;
|
||||
float gpu_pgxp_tolerance = -1.0f;
|
||||
float gpu_pgxp_depth_clear_threshold = DEFAULT_GPU_PGXP_DEPTH_THRESHOLD / GPU_PGXP_DEPTH_THRESHOLD_SCALE;
|
||||
|
|
|
@ -626,34 +626,7 @@ void GameCheatSettingsWidget::onClearClicked()
|
|||
}
|
||||
|
||||
disableAllCheats();
|
||||
|
||||
Error error;
|
||||
std::string path = Cheats::GetChtFilename(m_dialog->getGameSerial(), m_dialog->getGameHash(), true);
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
|
||||
// check for a non-hashed path and remove that too
|
||||
path = Cheats::GetChtFilename(m_dialog->getGameSerial(), std::nullopt, true);
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
|
||||
// and a legacy cht file with the game title
|
||||
if (const std::string& title = m_dialog->getGameTitle(); !title.empty())
|
||||
{
|
||||
path = fmt::format("{}" FS_OSPATH_SEPARATOR_STR "{}.cht", EmuFolders::Cheats, Path::SanitizeFileName(title));
|
||||
if (FileSystem::FileExists(path.c_str()))
|
||||
{
|
||||
if (!FileSystem::DeleteFile(path.c_str(), &error))
|
||||
ERROR_LOG("Failed to remove cht file '{}': {}", Path::GetFileName(path), error.GetDescription());
|
||||
}
|
||||
}
|
||||
|
||||
Cheats::RemoveAllCodes(m_dialog->getGameSerial(), m_dialog->getGameTitle(), m_dialog->getGameHash());
|
||||
reloadList();
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,11 @@ namespace ImGuiManager {
|
|||
using WCharType = u32;
|
||||
|
||||
/// Default size for screen margins.
|
||||
#ifndef __ANDROID__
|
||||
static constexpr float DEFAULT_SCREEN_MARGIN = 10.0f;
|
||||
#else
|
||||
static constexpr float DEFAULT_SCREEN_MARGIN = 16.0f;
|
||||
#endif
|
||||
|
||||
/// Sets the path to the font to use. Empty string means to use the default.
|
||||
void SetFontPathAndRange(std::string path, std::vector<WCharType> range);
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#if defined(_WIN32)
|
||||
#include "common/windows_headers.h"
|
||||
#elif defined(__linux__)
|
||||
#elif defined(__linux__) && !defined(__ANDROID__)
|
||||
#include <signal.h>
|
||||
#include <ucontext.h>
|
||||
#include <unistd.h>
|
||||
|
@ -136,7 +136,7 @@ bool PageFaultHandler::Install(Error* error)
|
|||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
#elif !defined(__ANDROID__)
|
||||
|
||||
namespace PageFaultHandler {
|
||||
static void SignalHandler(int sig, siginfo_t* info, void* ctx);
|
||||
|
|
Loading…
Reference in New Issue