Add support for newer format .cht files and OptionBrowser text scrolling (#1038)

* Add support for BML-format .cht files, and OptionBrowser text scrolling

* Move BML handling out of cheatmgr.cpp
This commit is contained in:
InfiniteBlueGX 2022-11-07 15:26:28 -06:00 committed by GitHub
parent 9b3eccf8a2
commit 67af82ad0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#include "snes9xgx.h"
#include "fileop.h"
#include "filebrowser.h"
#include "bml.h"
#define MAX_CHEATS 150
@ -91,7 +92,25 @@ WiiSetupCheats()
// load cheat file if present
if(offset > 0)
LoadCheatFile (offset);
{
bml_node bml;
if (!bml.parse_file(filepath))
{
LoadCheatFile (offset);
}
bml_node *n = bml.find_subnode("cheat");
if (n)
{
S9xLoadCheatsFromBMLNode (&bml);
}
if (!n)
{
LoadCheatFile (offset);
}
}
FreeSaveBuffer ();
}

View File

@ -79,6 +79,7 @@ GuiOptionBrowser::GuiOptionBrowser(int w, int h, OptionList * l)
optionTxt[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
optionTxt[i]->SetPosition(8,0);
optionTxt[i]->SetMaxWidth(235);
optionVal[i] = new GuiText(NULL, 20, (GXColor){0, 0, 0, 0xff});
optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
@ -312,6 +313,11 @@ void GuiOptionBrowser::Update(GuiTrigger * t)
if(optionBtn[i]->GetState() == STATE_SELECTED)
selectedItem = i;
if(selectedItem == i)
optionTxt[i]->SetScroll(SCROLL_HORIZONTAL);
else
optionTxt[i]->SetScroll(SCROLL_NONE);
}
// pad/joystick navigation

View File

@ -8,6 +8,7 @@
#define _CHEATS_H_
#include "port.h"
#include "bml.h"
#include <vector>
struct SCheat
@ -95,6 +96,7 @@ void S9xSearchForChange (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize,
void S9xSearchForValue (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8, bool8);
void S9xSearchForAddress (SCheatData *, S9xCheatComparisonType, S9xCheatDataSize, uint32, bool8);
void S9xOutputCheatSearchResults (SCheatData *);
void S9xLoadCheatsFromBMLNode (bml_node *);
const char * S9xGameGenieToRaw (const char *, uint32 &, uint8 &);
const char * S9xProActionReplayToRaw (const char *, uint32 &, uint8 &);

View File

@ -558,7 +558,7 @@ static int S9xCheatIsDuplicate (const char *name, const char *code)
return FALSE;
}
static void S9xLoadCheatsFromBMLNode (bml_node *n)
void S9xLoadCheatsFromBMLNode (bml_node *n)
{
unsigned int i;