Skip to content

Commit

Permalink
It's now possible to save custom cheats
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor251093 committed Jun 18, 2024
1 parent d56bfa0 commit 090bf70
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/ARCodeFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ARCodeFile

ARCodeCatList Categories;

private:
protected:
std::string Filename;
};

Expand Down
15 changes: 9 additions & 6 deletions src/frontend/qt_sdl/KHDays_ARCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ namespace melonDS
{
using namespace Platform;

KHDaysARCodes::KHDaysARCodes()
KHDaysARCodes::KHDaysARCodes(const std::string& filename)
{
Filename = filename;

Error = false;

float aspectTop = (Config::WindowWidth * 1.f) / Config::WindowHeight;
Expand Down Expand Up @@ -73,6 +75,12 @@ ARCode KHDaysARCodes::ChangeAspectRatio(std::string codeName, u32 address)

bool KHDaysARCodes::Load()
{
FileHandle* f = OpenFile(Filename, FileMode::ReadText);
if (f) {
CloseFile(f);
return ARCodeFile::Load();
}

// References
// https://uk.codejunkies.com/support_downloads/Trainer-Toolkit-for-Nintendo-DS-User-Manual.pdf

Expand All @@ -96,9 +104,4 @@ bool KHDaysARCodes::Load()
return true;
}

bool KHDaysARCodes::Save()
{
return false;
}

}
3 changes: 1 addition & 2 deletions src/frontend/qt_sdl/KHDays_ARCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ namespace melonDS
class KHDaysARCodes: public ARCodeFile
{
public:
KHDaysARCodes();
KHDaysARCodes(const std::string& filename);

bool Load() override;
bool Save() override;


private:
Expand Down
15 changes: 9 additions & 6 deletions src/frontend/qt_sdl/KHReCoded_ARCodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ namespace melonDS
{
using namespace Platform;

KHReCodedARCodes::KHReCodedARCodes()
KHReCodedARCodes::KHReCodedARCodes(const std::string& filename)
{
Filename = filename;

Error = false;

float aspectTop = (Config::WindowWidth * 1.f) / Config::WindowHeight;
Expand Down Expand Up @@ -94,6 +96,12 @@ ARCode KHReCodedARCodes::AlwaysEnableXAndDPadToControlCommandMenu(std::string co

bool KHReCodedARCodes::Load()
{
FileHandle* f = OpenFile(Filename, FileMode::ReadText);
if (f) {
CloseFile(f);
return ARCodeFile::Load();
}

// References
// https://uk.codejunkies.com/support_downloads/Trainer-Toolkit-for-Nintendo-DS-User-Manual.pdf

Expand All @@ -120,9 +128,4 @@ bool KHReCodedARCodes::Load()
return true;
}

bool KHReCodedARCodes::Save()
{
return false;
}

}
3 changes: 1 addition & 2 deletions src/frontend/qt_sdl/KHReCoded_ARCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ namespace melonDS
class KHReCodedARCodes: public ARCodeFile
{
public:
KHReCodedARCodes();
KHReCodedARCodes(const std::string& filename);

bool Load() override;
bool Save() override;


private:
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/qt_sdl/ROMManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,10 @@ void LoadCheats(NDS& nds)
if (CheatFile->Categories.empty())
{
if (CartValidator::isDays()) {
CheatFile = new KHDaysARCodes();
CheatFile = new KHDaysARCodes(filename);
}
if (CartValidator::isRecoded()) {
CheatFile = new KHReCodedARCodes();
CheatFile = new KHReCodedARCodes(filename);
}
}

Expand Down

0 comments on commit 090bf70

Please sign in to comment.