Merge pull request #11365 from iwubcode/cheat_manager_freeze_value

DolphinQt: add ability to lock / freeze values in the watches window
This commit is contained in:
Admiral H. Curtiss
2023-01-09 18:41:28 +01:00
committed by GitHub
17 changed files with 309 additions and 40 deletions

View File

@ -38,6 +38,23 @@ void MemoryPatches::SetPatch(u32 address, std::vector<u8> value)
Patch(index);
}
void MemoryPatches::SetFramePatch(u32 address, u32 value)
{
const std::size_t index = m_patches.size();
m_patches.emplace_back(address, value);
m_patches.back().type = MemoryPatch::ApplyType::EachFrame;
Patch(index);
}
void MemoryPatches::SetFramePatch(u32 address, std::vector<u8> value)
{
UnsetPatch(address);
const std::size_t index = m_patches.size();
m_patches.emplace_back(address, std::move(value));
m_patches.back().type = MemoryPatch::ApplyType::EachFrame;
Patch(index);
}
const std::vector<MemoryPatch>& MemoryPatches::GetPatches() const
{
return m_patches;
@ -81,6 +98,7 @@ bool MemoryPatches::HasEnabledPatch(u32 address) const
void MemoryPatches::RemovePatch(std::size_t index)
{
DisablePatch(index);
UnPatch(index);
m_patches.erase(m_patches.begin() + index);
}
@ -88,7 +106,10 @@ void MemoryPatches::ClearPatches()
{
const std::size_t size = m_patches.size();
for (std::size_t index = 0; index < size; ++index)
{
DisablePatch(index);
UnPatch(index);
}
m_patches.clear();
}
} // namespace Common::Debug

View File

@ -19,12 +19,19 @@ struct MemoryPatch
Disabled
};
enum class ApplyType
{
Once,
EachFrame
};
MemoryPatch(u32 address_, std::vector<u8> value_);
MemoryPatch(u32 address_, u32 value_);
u32 address;
std::vector<u8> value;
State is_enabled = State::Enabled;
ApplyType type = ApplyType::Once;
};
class MemoryPatches
@ -35,6 +42,8 @@ public:
void SetPatch(u32 address, u32 value);
void SetPatch(u32 address, std::vector<u8> value);
void SetFramePatch(u32 address, u32 value);
void SetFramePatch(u32 address, std::vector<u8> value);
const std::vector<MemoryPatch>& GetPatches() const;
void UnsetPatch(u32 address);
void EnablePatch(std::size_t index);
@ -42,9 +51,11 @@ public:
bool HasEnabledPatch(u32 address) const;
void RemovePatch(std::size_t index);
void ClearPatches();
virtual void ApplyExistingPatch(std::size_t index) = 0;
protected:
virtual void Patch(std::size_t index) = 0;
virtual void UnPatch(std::size_t index) = 0;
std::vector<MemoryPatch> m_patches;
};

View File

@ -62,6 +62,11 @@ void Watches::UpdateWatchName(std::size_t index, std::string name)
m_watches[index].name = std::move(name);
}
void Watches::UpdateWatchLockedState(std::size_t index, bool locked)
{
m_watches[index].locked = locked;
}
void Watches::EnableWatch(std::size_t index)
{
m_watches[index].is_enabled = Watch::State::Enabled;

View File

@ -22,6 +22,7 @@ struct Watch
u32 address;
std::string name;
State is_enabled;
bool locked = false;
Watch(u32 address, std::string name, State is_enabled);
};
@ -36,6 +37,7 @@ public:
void UpdateWatch(std::size_t index, u32 address, std::string name);
void UpdateWatchAddress(std::size_t index, u32 address);
void UpdateWatchName(std::size_t index, std::string name);
void UpdateWatchLockedState(std::size_t index, bool locked);
void EnableWatch(std::size_t index);
void DisableWatch(std::size_t index);
bool HasEnabledWatch(u32 address) const;

View File

@ -32,6 +32,7 @@ public:
virtual void UpdateWatch(std::size_t index, u32 address, std::string name) = 0;
virtual void UpdateWatchAddress(std::size_t index, u32 address) = 0;
virtual void UpdateWatchName(std::size_t index, std::string name) = 0;
virtual void UpdateWatchLockedState(std::size_t index, bool locked) = 0;
virtual void EnableWatch(std::size_t index) = 0;
virtual void DisableWatch(std::size_t index) = 0;
virtual bool HasEnabledWatch(u32 address) const = 0;
@ -43,6 +44,8 @@ public:
// Memory Patches
virtual void SetPatch(u32 address, u32 value) = 0;
virtual void SetPatch(u32 address, std::vector<u8> value) = 0;
virtual void SetFramePatch(u32 address, u32 value) = 0;
virtual void SetFramePatch(u32 address, std::vector<u8> value) = 0;
virtual const std::vector<Debug::MemoryPatch>& GetPatches() const = 0;
virtual void UnsetPatch(u32 address) = 0;
virtual void EnablePatch(std::size_t index) = 0;
@ -50,6 +53,7 @@ public:
virtual bool HasEnabledPatch(u32 address) const = 0;
virtual void RemovePatch(std::size_t index) = 0;
virtual void ClearPatches() = 0;
virtual void ApplyExistingPatch(std::size_t index) = 0;
// Threads
virtual Debug::Threads GetThreads() const = 0;