bsnes/target-tomoko/tools/cheat-database.cpp
Tim Allen c335ee9d80 Update to v094r16 release.
byuu says:

Finished the cheat code system, it'll now load and save cheats.bml to
disk.

Also hooked up overscan masking. But for now you can only configure the
amount it clips via the configuration file, since I don't have a video
settings dialog anymore.

And that's the last of the low-hanging fruit. The remaining items are
all going to be a pain in the ass for one reason or another.

Short-term:
- add input port changing support
- add other input types (mouse-based, etc)

Long-term:
- add slotted cart loader (SGB, BSX, ST)
- add DIP switch selection window (NSS)
- add timing configuration (video/audio sync)

Not planned:
- video color adjustments (will allow emulated color vs raw color; but
  no more sliders)
- pixel shaders
- ananke integration (will need to make a command-line version to get my
  games in)
- fancy audio adjustment controls (resampler, latency, volume)
- input focus settings
- localization support (not enough users)
- window geometry memory
- anything else not in higan v094
2015-04-21 21:58:59 +10:00

54 lines
1.7 KiB
C++

CheatDatabase::CheatDatabase() {
cheatDatabase = this;
layout.setMargin(5);
cheatList.setCheckable();
selectAllButton.setText("Select All").onActivate([&] { cheatList.setChecked(true); });
unselectAllButton.setText("Unselect All").onActivate([&] { cheatList.setChecked(false); });
addCodesButton.setText("Add Codes").onActivate([&] { addCodes(); });
setSize({800, 400});
setPlacement(0.5, 1.0);
}
auto CheatDatabase::findCodes() -> void {
if(!emulator) return;
auto sha256 = emulator->sha256();
auto contents = string::read({localpath(), "tomoko/cheats.bml"});
auto document = Markup::Document(contents);
for(auto& cartridge : document) {
if(cartridge.name != "cartridge") continue;
if(cartridge["sha256"].text() != sha256) continue;
codes.reset();
cheatList.reset();
cheatList.append(ListViewColumn().setWidth(~0));
for(auto& cheat : cartridge) {
if(cheat.name != "cheat") continue;
codes.append(cheat["code"].text());
cheatList.append(ListViewItem().setText(0, cheat["description"].text()));
}
setTitle(cartridge["name"].text());
setVisible();
return;
}
MessageDialog().setParent(*toolsManager).setText("Sorry, no cheats were found for this game.").information();
}
auto CheatDatabase::addCodes() -> void {
for(auto item : cheatList.checked()) {
string code = codes(item->offset(), "");
string description = item->text(0);
if(toolsManager->cheatEditor.addCode(code, description) == false) {
MessageDialog().setParent(*this).setText("Free slots exhausted. Not all codes could be added.").warning();
break;
}
}
setVisible(false);
toolsManager->cheatEditor.doRefresh();
}