Add cheats in per game configuration (#6379)
This commit is contained in:
parent
ea649263b7
commit
7327c334ca
13 changed files with 86 additions and 122 deletions
|
@ -19,9 +19,12 @@ namespace Cheats {
|
|||
// we use the same value
|
||||
constexpr u64 run_interval_ticks = 50'000'000;
|
||||
|
||||
CheatEngine::CheatEngine(Core::System& system_) : system(system_) {
|
||||
CheatEngine::CheatEngine(u64 title_id_, Core::System& system_)
|
||||
: system(system_), title_id{title_id_} {
|
||||
LoadCheatFile();
|
||||
Connect();
|
||||
if (system.IsPoweredOn()) {
|
||||
Connect();
|
||||
}
|
||||
}
|
||||
|
||||
void CheatEngine::Connect() {
|
||||
|
@ -32,7 +35,9 @@ void CheatEngine::Connect() {
|
|||
}
|
||||
|
||||
CheatEngine::~CheatEngine() {
|
||||
system.CoreTiming().UnscheduleEvent(event, 0);
|
||||
if (system.IsPoweredOn()) {
|
||||
system.CoreTiming().UnscheduleEvent(event, 0);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<CheatBase>> CheatEngine::GetCheats() const {
|
||||
|
@ -65,8 +70,7 @@ void CheatEngine::UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase
|
|||
|
||||
void CheatEngine::SaveCheatFile() const {
|
||||
const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir);
|
||||
const std::string filepath = fmt::format(
|
||||
"{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id);
|
||||
const std::string filepath = fmt::format("{}{:016X}.txt", cheat_dir, title_id);
|
||||
|
||||
if (!FileUtil::IsDirectory(cheat_dir)) {
|
||||
FileUtil::CreateDir(cheat_dir);
|
||||
|
@ -81,8 +85,7 @@ void CheatEngine::SaveCheatFile() const {
|
|||
|
||||
void CheatEngine::LoadCheatFile() {
|
||||
const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir);
|
||||
const std::string filepath = fmt::format(
|
||||
"{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id);
|
||||
const std::string filepath = fmt::format("{}{:016X}.txt", cheat_dir, title_id);
|
||||
|
||||
if (!FileUtil::IsDirectory(cheat_dir)) {
|
||||
FileUtil::CreateDir(cheat_dir);
|
||||
|
|
|
@ -24,7 +24,7 @@ class CheatBase;
|
|||
|
||||
class CheatEngine {
|
||||
public:
|
||||
explicit CheatEngine(Core::System& system);
|
||||
explicit CheatEngine(u64 title_id_, Core::System& system);
|
||||
~CheatEngine();
|
||||
void Connect();
|
||||
std::vector<std::shared_ptr<CheatBase>> GetCheats() const;
|
||||
|
@ -40,5 +40,6 @@ private:
|
|||
mutable std::shared_mutex cheats_list_mutex;
|
||||
Core::TimingEventType* event;
|
||||
Core::System& system;
|
||||
u64 title_id;
|
||||
};
|
||||
} // namespace Cheats
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue