Merge pull request #3368 from makotech222/master

Fix Enable/disable all logic
This commit is contained in:
Henrik Rydgård 2013-08-24 15:41:52 -07:00
commit 69ed2d44af
2 changed files with 14 additions and 9 deletions

View File

@ -39,6 +39,7 @@ bool enableAll = false;
static std::vector<std::string> cheatList;
extern void DrawBackground(float alpha);
static CWCheatEngine *cheatEngine2;
static bool enableCheat [64];
std::vector<std::string> CwCheatScreen::CreateCodeList() {
cheatEngine2 = new CWCheatEngine();
@ -93,6 +94,14 @@ void CwCheatScreen::CreateViews() {
UI::EventReturn CwCheatScreen::OnBack(UI::EventParams &params)
{
screenManager()->finishDialog(this, DR_OK);
os.open(activeCheatFile.c_str());
for (int j = 0; j < cheatList.size(); j++) {
os << cheatList[j];
if (j < cheatList.size() - 1) {
os << "\n";
}
}
os.close();
g_Config.bReloadCheats = true;
return UI::EVENT_DONE;
}
@ -104,19 +113,17 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams &params)
for (int j = 0; j < temp.size(); j++) {
if (enableAll == 1 && temp[j].substr(0, 3) == "_C0"){
temp[j].replace(0,3,"_C1");
for (int x = 0; x < sizeof(enableCheat); x++) {
enableCheat[x] = true;
}
}
else if (enableAll == 0 && temp[j].substr(0, 3) == "_C1") {
temp[j].replace(0, 3, "_C0");
for (int x = 0; x < 64; x++) {
enableCheat[x] = false;
}
}
}
for (int y = 0; y < 64; y++) {
enableCheat[y] = enableAll;
}
for (int i = 0; i < temp.size(); i++) {
os << temp[i];
if (i < temp.size() - 1) {
@ -124,6 +131,7 @@ UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams &params)
}
}
os.close();
return UI::EVENT_DONE;
}
UI::EventReturn CwCheatScreen::OnAddCheat(UI::EventParams &params)

View File

@ -347,12 +347,9 @@ void GameSettingsScreen::CreateViews() {
enableReports_ = g_Config.sReportHost != "default";
#ifndef ANDROID
systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
// Need to move the cheat config dir somewhere where it can be read/written on android
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
systemSettings->Add(new Choice(s->T("Reload Cheats")))->OnClick.Handle(this, &GameSettingsScreen::OnReloadCheats);
#endif
LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
systemSettings->SetSpacing(0);