2013-08-24 03:28:21 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2016-03-06 21:16:50 +00:00
|
|
|
#include <deque>
|
2013-08-24 03:28:21 +00:00
|
|
|
#include "input/input_state.h"
|
|
|
|
#include "ui/ui.h"
|
2014-06-08 22:13:26 +00:00
|
|
|
#include "util/text/utf8.h"
|
2013-08-24 03:28:21 +00:00
|
|
|
#include "i18n/i18n.h"
|
|
|
|
|
2016-03-06 21:16:50 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2013-08-24 03:28:21 +00:00
|
|
|
#include "Core/Core.h"
|
2013-09-15 03:28:41 +00:00
|
|
|
#include "Core/Config.h"
|
2016-03-06 21:16:50 +00:00
|
|
|
#include "Core/CwCheat.h"
|
2016-05-01 08:35:37 +00:00
|
|
|
#include "Core/MIPS/JitCommon/JitCommon.h"
|
2013-08-24 03:28:21 +00:00
|
|
|
|
|
|
|
#include "UI/OnScreenDisplay.h"
|
|
|
|
#include "UI/ui_atlas.h"
|
|
|
|
|
|
|
|
#include "UI/MainScreen.h"
|
|
|
|
#include "UI/EmuScreen.h"
|
|
|
|
#include "UI/GameInfoCache.h"
|
|
|
|
#include "UI/MiscScreens.h"
|
|
|
|
#include "UI/CwCheatScreen.h"
|
2013-08-24 13:54:15 +00:00
|
|
|
|
2013-08-30 18:13:59 +00:00
|
|
|
static bool enableAll = false;
|
2013-08-23 02:58:37 +00:00
|
|
|
static std::vector<std::string> cheatList;
|
2013-08-24 03:28:21 +00:00
|
|
|
static CWCheatEngine *cheatEngine2;
|
2013-10-12 01:04:15 +00:00
|
|
|
static std::deque<bool> bEnableCheat;
|
2016-06-19 22:18:35 +00:00
|
|
|
static std::string gamePath_;
|
|
|
|
|
|
|
|
|
|
|
|
CwCheatScreen::CwCheatScreen(std::string gamePath)
|
|
|
|
: UIDialogScreenWithBackground() {
|
|
|
|
gamePath_ = gamePath;
|
|
|
|
}
|
2013-10-23 14:10:11 +00:00
|
|
|
|
2014-05-28 07:04:26 +00:00
|
|
|
void CwCheatScreen::CreateCodeList() {
|
2017-05-18 10:52:03 +00:00
|
|
|
std::shared_ptr<GameInfo> info = g_gameInfoCache->GetInfo(NULL, gamePath_, 0);
|
2016-06-19 22:18:35 +00:00
|
|
|
if (info && info->paramSFOLoaded) {
|
|
|
|
gameTitle = info->paramSFO.GetValueString("DISC_ID");
|
|
|
|
}
|
2017-05-29 01:57:39 +00:00
|
|
|
if ((info->id.empty() || !info->disc_total)
|
|
|
|
&& gamePath_.find("/PSP/GAME/") != std::string::npos) {
|
|
|
|
gameTitle = g_paramSFO.GenerateFakeID(gamePath_);
|
2016-06-20 22:15:29 +00:00
|
|
|
}
|
2017-05-29 01:57:39 +00:00
|
|
|
|
2013-08-24 03:28:21 +00:00
|
|
|
cheatEngine2 = new CWCheatEngine();
|
2016-06-19 22:18:35 +00:00
|
|
|
cheatEngine2->CreateCheatFile();
|
2016-06-21 04:29:26 +00:00
|
|
|
cheatList = cheatEngine2->GetCodesList();
|
2016-06-19 22:18:35 +00:00
|
|
|
|
2013-10-12 01:04:15 +00:00
|
|
|
bEnableCheat.clear();
|
2014-05-28 07:04:26 +00:00
|
|
|
formattedList_.clear();
|
2013-08-24 03:28:21 +00:00
|
|
|
for (size_t i = 0; i < cheatList.size(); i++) {
|
2017-11-30 04:05:52 +00:00
|
|
|
if (cheatList[i][0] == '_' && cheatList[i][1] == 'C') {
|
2013-10-23 14:10:11 +00:00
|
|
|
formattedList_.push_back(cheatList[i].substr(4));
|
2017-11-30 04:05:52 +00:00
|
|
|
if (cheatList[i][2] == '0') {
|
2017-05-31 09:58:24 +00:00
|
|
|
bEnableCheat.push_back(false);
|
|
|
|
} else {
|
|
|
|
bEnableCheat.push_back(true);
|
|
|
|
}
|
2013-08-24 03:28:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-23 02:58:37 +00:00
|
|
|
delete cheatEngine2;
|
2013-08-24 03:28:21 +00:00
|
|
|
}
|
2013-08-30 18:13:59 +00:00
|
|
|
|
2013-08-24 03:28:21 +00:00
|
|
|
void CwCheatScreen::CreateViews() {
|
|
|
|
using namespace UI;
|
2015-07-01 20:40:11 +00:00
|
|
|
I18NCategory *cw = GetI18NCategory("CwCheats");
|
2015-07-01 21:26:55 +00:00
|
|
|
I18NCategory *di = GetI18NCategory("Dialog");
|
2014-05-28 07:04:26 +00:00
|
|
|
CreateCodeList();
|
2013-09-05 22:36:14 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
2013-08-24 03:28:21 +00:00
|
|
|
root_ = new LinearLayout(ORIENT_HORIZONTAL);
|
2013-09-03 15:50:34 +00:00
|
|
|
Margins actionMenuMargins(50, -15, 15, 0);
|
2013-08-24 03:28:21 +00:00
|
|
|
|
2013-08-24 03:07:41 +00:00
|
|
|
LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(400, FILL_PARENT));
|
2015-07-01 20:40:11 +00:00
|
|
|
leftColumn->Add(new ItemHeader(cw->T("Options")));
|
2015-07-01 21:26:55 +00:00
|
|
|
leftColumn->Add(new Choice(di->T("Back")))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
|
2015-07-01 20:40:11 +00:00
|
|
|
//leftColumn->Add(new Choice(cw->T("Add Cheat")))->OnClick.Handle(this, &CwCheatScreen::OnAddCheat);
|
|
|
|
leftColumn->Add(new Choice(cw->T("Import Cheats")))->OnClick.Handle(this, &CwCheatScreen::OnImportCheat);
|
2015-05-26 11:59:00 +00:00
|
|
|
#if !defined(MOBILE_DEVICE)
|
2015-07-01 20:40:11 +00:00
|
|
|
leftColumn->Add(new Choice(cw->T("Edit Cheat File")))->OnClick.Handle(this, &CwCheatScreen::OnEditCheatFile);
|
2014-06-08 22:13:26 +00:00
|
|
|
#endif
|
2015-07-01 20:40:11 +00:00
|
|
|
leftColumn->Add(new Choice(cw->T("Enable/Disable All")))->OnClick.Handle(this, &CwCheatScreen::OnEnableAll);
|
|
|
|
leftColumn->Add(new PopupSliderChoice(&g_Config.iCwCheatRefreshRate, 1, 1000, cw->T("Refresh Rate"), 1, screenManager()));
|
2013-08-24 03:28:21 +00:00
|
|
|
|
2013-08-24 03:07:41 +00:00
|
|
|
ScrollView *rightScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(0.5f));
|
2016-01-23 06:52:13 +00:00
|
|
|
rightScroll->SetTag("CwCheats");
|
2013-08-24 03:28:21 +00:00
|
|
|
rightScroll->SetScrollToTop(false);
|
2013-08-24 03:07:41 +00:00
|
|
|
LinearLayout *rightColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(200, FILL_PARENT, actionMenuMargins));
|
|
|
|
LayoutParams *layout = new LayoutParams(500, 50, LP_PLAIN);
|
2013-08-24 03:28:21 +00:00
|
|
|
rightScroll->Add(rightColumn);
|
2013-10-23 14:10:11 +00:00
|
|
|
|
2013-08-24 03:28:21 +00:00
|
|
|
root_->Add(leftColumn);
|
|
|
|
root_->Add(rightScroll);
|
2015-07-01 20:40:11 +00:00
|
|
|
rightColumn->Add(new ItemHeader(cw->T("Cheats")));
|
2013-10-23 14:10:11 +00:00
|
|
|
for (size_t i = 0; i < formattedList_.size(); i++) {
|
|
|
|
name = formattedList_[i].c_str();
|
2015-07-01 20:40:11 +00:00
|
|
|
rightColumn->Add(new CheatCheckBox(&bEnableCheat[i], cw->T(name), ""))->OnClick.Handle(this, &CwCheatScreen::OnCheckBox);
|
2013-08-30 18:13:59 +00:00
|
|
|
}
|
2013-08-24 03:28:21 +00:00
|
|
|
}
|
2013-08-30 18:13:59 +00:00
|
|
|
|
2013-10-25 11:19:08 +00:00
|
|
|
void CwCheatScreen::onFinish(DialogResult result) {
|
2014-06-05 14:22:43 +00:00
|
|
|
std::fstream fs;
|
2013-11-05 12:38:51 +00:00
|
|
|
if (result != DR_BACK) // This only works for BACK here.
|
|
|
|
return;
|
2014-06-05 14:22:43 +00:00
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::out);
|
2013-08-30 18:13:59 +00:00
|
|
|
for (int j = 0; j < (int)cheatList.size(); j++) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << cheatList[j];
|
2013-09-04 08:51:14 +00:00
|
|
|
if (j < (int)cheatList.size() - 1) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-24 18:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-08-23 02:58:37 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
2013-10-23 14:10:11 +00:00
|
|
|
if (MIPSComp::jit) {
|
2013-10-23 15:23:05 +00:00
|
|
|
MIPSComp::jit->ClearCache();
|
2013-10-23 14:10:11 +00:00
|
|
|
}
|
2013-08-23 02:58:37 +00:00
|
|
|
}
|
2013-08-30 18:13:59 +00:00
|
|
|
|
2013-10-23 14:10:11 +00:00
|
|
|
UI::EventReturn CwCheatScreen::OnEnableAll(UI::EventParams ¶ms) {
|
2014-06-05 14:22:43 +00:00
|
|
|
std::fstream fs;
|
2013-08-24 03:07:41 +00:00
|
|
|
enableAll = !enableAll;
|
2014-06-05 14:22:43 +00:00
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::out);
|
2013-09-04 08:51:14 +00:00
|
|
|
for (int j = 0; j < (int)cheatList.size(); j++) {
|
2017-11-30 04:05:52 +00:00
|
|
|
if (cheatList[j][0] == '_' && cheatList[j][1] == 'C') {
|
|
|
|
if (cheatList[j][2] == '0' && enableAll) {
|
|
|
|
cheatList[j][2] = '1';
|
|
|
|
} else if (cheatList[j][2] != '0' && !enableAll) {
|
|
|
|
cheatList[j][2] = '0';
|
2017-05-31 09:58:24 +00:00
|
|
|
}
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-12 23:49:22 +00:00
|
|
|
for (size_t y = 0; y < bEnableCheat.size(); y++) {
|
2013-10-12 01:04:15 +00:00
|
|
|
bEnableCheat[y] = enableAll;
|
2013-09-04 08:51:14 +00:00
|
|
|
}
|
|
|
|
for (int i = 0; i < (int)cheatList.size(); i++) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << cheatList[i];
|
2013-09-04 08:51:14 +00:00
|
|
|
if (i < (int)cheatList.size() - 1) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-10-23 14:10:11 +00:00
|
|
|
|
2017-11-08 03:51:32 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
2013-08-24 03:07:41 +00:00
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
2013-09-04 08:51:14 +00:00
|
|
|
|
2013-10-23 14:10:11 +00:00
|
|
|
UI::EventReturn CwCheatScreen::OnAddCheat(UI::EventParams ¶ms) {
|
2017-03-20 00:43:03 +00:00
|
|
|
TriggerFinish(DR_OK);
|
2013-08-24 03:07:41 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
2013-09-04 08:51:14 +00:00
|
|
|
|
2014-06-08 22:13:26 +00:00
|
|
|
UI::EventReturn CwCheatScreen::OnEditCheatFile(UI::EventParams ¶ms) {
|
2015-01-28 08:06:00 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
|
|
|
if (MIPSComp::jit) {
|
|
|
|
MIPSComp::jit->ClearCache();
|
|
|
|
}
|
2017-03-20 00:43:03 +00:00
|
|
|
TriggerFinish(DR_OK);
|
2017-02-28 00:47:13 +00:00
|
|
|
#if PPSSPP_PLATFORM(UWP)
|
|
|
|
LaunchBrowser(activeCheatFile.c_str());
|
|
|
|
#else
|
2016-06-22 03:55:45 +00:00
|
|
|
File::openIniFile(activeCheatFile);
|
2017-02-28 00:47:13 +00:00
|
|
|
#endif
|
2014-06-08 22:13:26 +00:00
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
|
|
|
|
2013-10-23 14:10:11 +00:00
|
|
|
UI::EventReturn CwCheatScreen::OnImportCheat(UI::EventParams ¶ms) {
|
2016-06-20 09:32:31 +00:00
|
|
|
if (gameTitle.length() != 9) {
|
|
|
|
WARN_LOG(COMMON, "CWCHEAT: Incorrect ID(%s) - can't import cheats.", gameTitle.c_str());
|
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
2013-08-24 03:07:41 +00:00
|
|
|
std::string line;
|
2013-09-01 02:15:50 +00:00
|
|
|
std::vector<std::string> title;
|
2013-08-24 03:07:41 +00:00
|
|
|
bool finished = false, skip = false;
|
|
|
|
std::vector<std::string> newList;
|
2013-10-15 07:04:12 +00:00
|
|
|
|
2014-06-08 22:13:26 +00:00
|
|
|
std::string cheatFile = GetSysDirectory(DIRECTORY_CHEATS) + "cheat.db";
|
2017-11-30 05:14:36 +00:00
|
|
|
std::string gameID = StringFromFormat("_S %s-%s", gameTitle.substr(0, 4).c_str(), gameTitle.substr(4).c_str());
|
2014-06-05 02:41:42 +00:00
|
|
|
|
2014-06-05 14:22:43 +00:00
|
|
|
std::fstream fs;
|
2014-06-08 22:13:26 +00:00
|
|
|
File::OpenCPPFile(fs, cheatFile, std::ios::in);
|
2013-10-15 07:04:12 +00:00
|
|
|
|
2014-07-08 04:56:20 +00:00
|
|
|
if (!fs.is_open()) {
|
|
|
|
WARN_LOG(COMMON, "Unable to open %s\n", cheatFile.c_str());
|
|
|
|
}
|
|
|
|
|
2014-06-05 14:22:43 +00:00
|
|
|
while (fs.good()) {
|
|
|
|
getline(fs, line); // get line from file
|
2017-11-30 04:05:52 +00:00
|
|
|
if (line == gameID) {
|
2013-09-01 02:15:50 +00:00
|
|
|
title.push_back(line);
|
2014-06-05 14:22:43 +00:00
|
|
|
getline(fs, line);
|
2013-09-01 02:15:50 +00:00
|
|
|
title.push_back(line);
|
2013-08-24 03:07:41 +00:00
|
|
|
do {
|
|
|
|
if (finished == false){
|
2014-06-05 14:22:43 +00:00
|
|
|
getline(fs, line);
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
2017-11-30 04:05:52 +00:00
|
|
|
if (line[0] == '_' && line[1] == 'C') {
|
2013-08-24 03:07:41 +00:00
|
|
|
//Test if cheat already exists in cheatList
|
2013-10-23 14:10:11 +00:00
|
|
|
for (size_t j = 0; j < formattedList_.size(); j++) {
|
|
|
|
if (line.substr(4) == formattedList_[j]) {
|
2013-08-24 03:07:41 +00:00
|
|
|
finished = false;
|
|
|
|
goto loop;
|
|
|
|
}
|
|
|
|
}
|
2013-09-01 02:15:50 +00:00
|
|
|
|
2013-08-24 03:07:41 +00:00
|
|
|
newList.push_back(line);
|
2014-06-05 14:22:43 +00:00
|
|
|
getline(fs, line);
|
2013-08-24 03:07:41 +00:00
|
|
|
do {
|
|
|
|
newList.push_back(line);
|
2014-06-05 14:22:43 +00:00
|
|
|
getline(fs, line);
|
2018-11-03 07:13:22 +00:00
|
|
|
} while ((line[0] == '_' && line[1] == 'L') || line[0] == '/' || line[0] == '#');
|
2013-08-24 03:07:41 +00:00
|
|
|
finished = true;
|
2013-10-23 14:10:11 +00:00
|
|
|
} else {
|
|
|
|
continue;
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
|
|
|
loop:;
|
2018-11-03 07:13:22 +00:00
|
|
|
} while (fs.good() && (line[0] == '_' && line[1] != 'S') || line[0] == '/' || line[0] == '#');
|
2013-08-24 03:07:41 +00:00
|
|
|
finished = true;
|
2013-09-01 02:15:50 +00:00
|
|
|
}
|
2013-08-24 03:07:41 +00:00
|
|
|
if (finished == true)
|
|
|
|
break;
|
2013-09-01 02:15:50 +00:00
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-09-01 02:15:50 +00:00
|
|
|
std::string title2;
|
2014-06-05 14:22:43 +00:00
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::in);
|
|
|
|
getline(fs, title2);
|
|
|
|
fs.close();
|
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::out | std::ios::app);
|
|
|
|
|
2013-09-09 06:26:37 +00:00
|
|
|
auto it = title.begin();
|
2018-11-03 07:13:22 +00:00
|
|
|
if ((title2[0] == '_' && title2[1] != 'S') || title2[0] == '/' || title2[0] == '#' && it != title.end() && (++it) != title.end()) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << title[0] << "\n" << title[1];
|
2013-09-01 02:15:50 +00:00
|
|
|
}
|
2014-07-08 04:56:20 +00:00
|
|
|
|
2014-08-02 21:55:15 +00:00
|
|
|
NOTICE_LOG(COMMON, "Imported %u entries from %s.\n", (int)newList.size(), cheatFile.c_str());
|
2013-10-23 14:10:11 +00:00
|
|
|
if (newList.size() != 0) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
2014-07-08 04:56:20 +00:00
|
|
|
|
2013-08-30 18:13:59 +00:00
|
|
|
for (int i = 0; i < (int)newList.size(); i++) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << newList[i];
|
2013-09-04 08:51:14 +00:00
|
|
|
if (i < (int)newList.size() - 1) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-24 03:07:41 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-08-24 03:07:41 +00:00
|
|
|
g_Config.bReloadCheats = true;
|
|
|
|
//Need a better way to refresh the screen, rather than exiting and having to re-enter.
|
2017-03-20 00:43:03 +00:00
|
|
|
TriggerFinish(DR_OK);
|
2013-08-24 03:07:41 +00:00
|
|
|
return UI::EVENT_DONE;
|
|
|
|
}
|
2013-08-23 02:58:37 +00:00
|
|
|
|
2013-08-30 12:47:28 +00:00
|
|
|
UI::EventReturn CwCheatScreen::OnCheckBox(UI::EventParams ¶ms) {
|
2013-08-24 03:28:21 +00:00
|
|
|
return UI::EVENT_DONE;
|
2013-08-23 00:46:30 +00:00
|
|
|
}
|
2013-08-30 12:47:28 +00:00
|
|
|
|
2013-08-23 00:46:30 +00:00
|
|
|
void CwCheatScreen::processFileOn(std::string activatedCheat) {
|
2014-06-05 14:22:43 +00:00
|
|
|
std::fstream fs;
|
2013-08-30 18:13:59 +00:00
|
|
|
for (size_t i = 0; i < cheatList.size(); i++) {
|
2016-10-24 02:37:49 +00:00
|
|
|
if (cheatList[i].length() >= 4) {
|
|
|
|
if (cheatList[i].substr(4) == activatedCheat) {
|
|
|
|
cheatList[i] = "_C1 " + activatedCheat;
|
|
|
|
}
|
2013-08-23 00:46:30 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-23 14:10:11 +00:00
|
|
|
|
2014-06-05 14:22:43 +00:00
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::out);
|
|
|
|
|
2013-08-30 18:13:59 +00:00
|
|
|
for (size_t j = 0; j < cheatList.size(); j++) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << cheatList[j];
|
2013-08-23 02:58:37 +00:00
|
|
|
if (j < cheatList.size() - 1) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-23 02:58:37 +00:00
|
|
|
}
|
2013-08-23 00:46:30 +00:00
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-08-23 00:46:30 +00:00
|
|
|
}
|
2013-08-30 12:47:28 +00:00
|
|
|
|
2013-08-23 02:58:37 +00:00
|
|
|
void CwCheatScreen::processFileOff(std::string deactivatedCheat) {
|
2014-06-05 14:22:43 +00:00
|
|
|
std::fstream fs;
|
2013-08-30 18:13:59 +00:00
|
|
|
for (size_t i = 0; i < cheatList.size(); i++) {
|
2016-10-24 02:37:49 +00:00
|
|
|
if (cheatList[i].length() >= 4) {
|
|
|
|
if (cheatList[i].substr(4) == deactivatedCheat) {
|
|
|
|
cheatList[i] = "_C0 " + deactivatedCheat;
|
|
|
|
}
|
2013-08-23 02:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
2013-08-23 00:46:30 +00:00
|
|
|
|
2014-06-05 14:22:43 +00:00
|
|
|
File::OpenCPPFile(fs, activeCheatFile, std::ios::out);
|
|
|
|
|
2013-08-30 18:13:59 +00:00
|
|
|
for (size_t j = 0; j < cheatList.size(); j++) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << cheatList[j];
|
2013-08-23 02:58:37 +00:00
|
|
|
if (j < cheatList.size() - 1) {
|
2014-06-05 14:22:43 +00:00
|
|
|
fs << "\n";
|
2013-08-23 02:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
fs.close();
|
2013-08-23 00:46:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CheatCheckBox::Draw(UIContext &dc) {
|
|
|
|
ClickableItem::Draw(dc);
|
2013-08-24 03:07:41 +00:00
|
|
|
int paddingX = 16;
|
|
|
|
int paddingY = 12;
|
2013-08-23 00:46:30 +00:00
|
|
|
|
|
|
|
int image = *toggle_ ? dc.theme->checkOn : dc.theme->checkOff;
|
|
|
|
|
2014-12-22 09:48:17 +00:00
|
|
|
UI::Style style = dc.theme->itemStyle;
|
2013-08-23 00:46:30 +00:00
|
|
|
if (!IsEnabled())
|
|
|
|
style = dc.theme->itemDisabledStyle;
|
|
|
|
|
2013-08-30 12:47:28 +00:00
|
|
|
dc.SetFontStyle(dc.theme->uiFont);
|
|
|
|
dc.DrawText(text_.c_str(), bounds_.x + paddingX, bounds_.centerY(), style.fgColor, ALIGN_VCENTER);
|
2013-08-23 00:46:30 +00:00
|
|
|
dc.Draw()->DrawImage(image, bounds_.x2() - paddingX, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_RIGHT | ALIGN_VCENTER);
|
2013-09-03 08:27:58 +00:00
|
|
|
}
|
2014-06-05 14:22:43 +00:00
|
|
|
|