CheatList: Add merge list function for importing
This commit is contained in:
parent
370494b50c
commit
d3f33212ec
|
@ -529,6 +529,37 @@ void CheatList::ApplyCode(u32 index)
|
|||
m_codes[index].Apply();
|
||||
}
|
||||
|
||||
const CheatCode* CheatList::FindCode(const char* name) const
|
||||
{
|
||||
for (const CheatCode& cc : m_codes)
|
||||
{
|
||||
if (cc.description == name)
|
||||
return &cc;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const CheatCode* CheatList::FindCode(const char* group, const char* name) const
|
||||
{
|
||||
for (const CheatCode& cc : m_codes)
|
||||
{
|
||||
if (cc.group == group && cc.description == name)
|
||||
return &cc;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CheatList::MergeList(const CheatList& cl)
|
||||
{
|
||||
for (const CheatCode& cc : cl.m_codes)
|
||||
{
|
||||
if (!FindCode(cc.group.c_str(), cc.description.c_str()))
|
||||
AddCode(cc);
|
||||
}
|
||||
}
|
||||
|
||||
std::string CheatCode::GetInstructionsAsString() const
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
|
|
@ -102,6 +102,9 @@ public:
|
|||
ALWAYS_INLINE u32 GetCodeCount() const { return static_cast<u32>(m_codes.size()); }
|
||||
ALWAYS_INLINE bool IsCodeEnabled(u32 index) const { return m_codes[index].enabled; }
|
||||
|
||||
const CheatCode* FindCode(const char* name) const;
|
||||
const CheatCode* FindCode(const char* group, const char* name) const;
|
||||
|
||||
void AddCode(CheatCode cc);
|
||||
void SetCode(u32 index, CheatCode cc);
|
||||
void RemoveCode(u32 i);
|
||||
|
@ -125,6 +128,8 @@ public:
|
|||
|
||||
void ApplyCode(u32 index);
|
||||
|
||||
void MergeList(const CheatList& cl);
|
||||
|
||||
private:
|
||||
std::vector<CheatCode> m_codes;
|
||||
};
|
||||
|
|
|
@ -558,10 +558,7 @@ void CheatManagerDialog::importClicked()
|
|||
QtHostInterface::GetInstance()->executeOnEmulationThread(
|
||||
[&new_cheats]() {
|
||||
DebugAssert(System::HasCheatList());
|
||||
CheatList* list = System::GetCheatList();
|
||||
for (u32 i = 0; i < new_cheats.GetCodeCount(); i++)
|
||||
list->AddCode(new_cheats.GetCode(i));
|
||||
|
||||
System::GetCheatList()->MergeList(new_cheats);
|
||||
QtHostInterface::GetInstance()->SaveCheatList();
|
||||
},
|
||||
true);
|
||||
|
|
Loading…
Reference in New Issue