From 761186ec4cb7beaffcaa339af877eee57073e418 Mon Sep 17 00:00:00 2001 From: Steven Cherry Date: Fri, 23 Aug 2013 22:28:21 -0500 Subject: [PATCH] Rebase --- UI/CwCheatScreen.cpp | 103 ++++++++++++++++++++++++++++++++++++++ UI/CwCheatScreen.h | 35 +++++++++++++ UI/Header.h | 0 UI/MainScreen.cpp | 6 +++ UI/MainScreen.h | 1 + UI/UI.vcxproj | 3 +- Windows/WndMainWindow.cpp | 6 ++- lang | 2 +- native | 2 +- 9 files changed, 154 insertions(+), 4 deletions(-) create mode 100644 UI/CwCheatScreen.cpp create mode 100644 UI/CwCheatScreen.h delete mode 100644 UI/Header.h diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp new file mode 100644 index 000000000..26d208e71 --- /dev/null +++ b/UI/CwCheatScreen.cpp @@ -0,0 +1,103 @@ +// 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/. + +#include "android/app-android.h" +#include "base/logging.h" + +#include "gfx_es2/glsl_program.h" +#include "gfx_es2/gl_state.h" +#include "gfx_es2/fbo.h" + +#include "input/input_state.h" +#include "ui/ui.h" +#include "i18n/i18n.h" + +#include "Common/KeyMap.h" + +#include "Core/Config.h" +#include "Core/CoreTiming.h" +#include "Core/CoreParameter.h" +#include "Core/Core.h" +#include "Core/Host.h" +#include "Core/System.h" +#include "GPU/GPUState.h" +#include "GPU/GPUInterface.h" +#include "Core/HLE/sceCtrl.h" +#include "Core/HLE/sceDisplay.h" +#include "Core/Debugger/SymbolMap.h" + +#include "UI/OnScreenDisplay.h" +#include "UI/ui_atlas.h" +#include "UI/GamepadEmu.h" +#include "UI/UIShader.h" + +#include "UI/MainScreen.h" +#include "UI/EmuScreen.h" +#include "UI/GameInfoCache.h" +#include "UI/MiscScreens.h" +#include "UI/CwCheatScreen.h" + + +extern void DrawBackground(float alpha); +static CWCheatEngine *cheatEngine2; + +std::vector CwCheatScreen::CreateCodeList() { + std::vector cheatList, formattedList; + cheatEngine2 = new CWCheatEngine(); + cheatList = cheatEngine2->GetCodesList(); + + for (size_t i = 0; i < cheatList.size(); i++) { + if (cheatList[i].substr(0, 3) == "_C1") { + formattedList.push_back(cheatList[i].substr(3)); + enableCheat[i] = true; + } + if (cheatList[i].substr(0, 3) == "_C0") { + formattedList.push_back(cheatList[i].substr(3)); + enableCheat[i] = false; + } + + } + + return formattedList; +} +void CwCheatScreen::CreateViews() { + using namespace UI; + std::vector formattedList; + I18NCategory *k = GetI18NCategory("CwCheats"); + formattedList = CreateCodeList(); + root_ = new LinearLayout(ORIENT_HORIZONTAL); + + LinearLayout *leftColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(200, FILL_PARENT)); + leftColumn->Add(new Choice(k->T("Back")))->OnClick.Handle(this, &UIScreen::OnBack); + + + ScrollView *rightScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)); + rightScroll->SetScrollToTop(false); + LinearLayout *rightColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)); + rightScroll->Add(rightColumn); + + root_->Add(leftColumn); + root_->Add(rightScroll); + rightColumn->Add(new ItemHeader(k->T("Cheats"))); + for (size_t i = 0; i < formattedList.size(); i++) { + const char * name = formattedList[i].c_str(); + rightColumn->Add(new CheckBox(&enableCheat[i], k->T(name)))->OnClick.Handle(this, &CwCheatScreen::OnCheckBox);; + } +} +UI::EventReturn CwCheatScreen::OnCheckBox(UI::EventParams ¶ms) { + return UI::EVENT_DONE; +} \ No newline at end of file diff --git a/UI/CwCheatScreen.h b/UI/CwCheatScreen.h new file mode 100644 index 000000000..625154180 --- /dev/null +++ b/UI/CwCheatScreen.h @@ -0,0 +1,35 @@ +// Copyright (c) 2013- 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/. + +#include "base/functional.h" +#include "ui/view.h" +#include "ui/ui_screen.h" +#include "../Core/CwCheat.h" +#include "UI/MiscScreens.h" + +class CwCheatScreen : public UIDialogScreenWithBackground { +public: + CwCheatScreen() {} + std::vector CreateCodeList(); +protected: + virtual void CreateViews(); + +private: + UI::EventReturn OnCheckBox(UI::EventParams ¶ms); + bool enableCheat [64]; + +}; diff --git a/UI/Header.h b/UI/Header.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 183d67082..05821d088 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -32,6 +32,7 @@ #include "UI/GameScreen.h" #include "UI/GameInfoCache.h" #include "UI/GameSettingsScreen.h" +#include "UI/CwCheatScreen.h" #include "UI/MiscScreens.h" #include "UI/ui_atlas.h" #include "Core/Config.h" @@ -685,6 +686,7 @@ void GamePauseScreen::CreateViews() { rightColumnItems->Add(new Choice(i->T("Continue")))->OnClick.Handle(this, &GamePauseScreen::OnContinue); rightColumnItems->Add(new Choice(i->T("Game Settings")))->OnClick.Handle(this, &GamePauseScreen::OnGameSettings); + rightColumnItems->Add(new Choice(i->T("Cheats")))->OnClick.Handle(this, &GamePauseScreen::OnCwCheat); rightColumnItems->Add(new Choice(i->T("Exit to menu")))->OnClick.Handle(this, &GamePauseScreen::OnExitToMenu); UI::EventParams e; @@ -727,3 +729,7 @@ UI::EventReturn GamePauseScreen::OnSaveState(UI::EventParams &e) { screenManager()->finishDialog(this, DR_CANCEL); return UI::EVENT_DONE; } +UI::EventReturn GamePauseScreen::OnCwCheat(UI::EventParams &e) { + screenManager()->push(new CwCheatScreen()); + return UI::EVENT_DONE; +} diff --git a/UI/MainScreen.h b/UI/MainScreen.h index f2bf69447..c5b4a57e2 100644 --- a/UI/MainScreen.h +++ b/UI/MainScreen.h @@ -69,6 +69,7 @@ private: UI::EventReturn OnLoadState(UI::EventParams &e); UI::EventReturn OnStateSelected(UI::EventParams &e); + UI::EventReturn OnCwCheat(UI::EventParams &e); std::string gamePath_; diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index d5528d6de..9dcd2aaa7 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -20,6 +20,7 @@ + @@ -40,7 +41,7 @@ - + diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 87fdcf06f..c26955af1 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -720,7 +720,9 @@ namespace MainWindow case ID_EMULATION_RESET: NativeMessageReceived("reset", ""); break; - + case ID_CHEAT: + NativeMessageReceived("reset", ""); + break; case ID_EMULATION_SPEEDLIMIT: g_Config.bSpeedLimit = !g_Config.bSpeedLimit; break; @@ -1408,12 +1410,14 @@ namespace MainWindow EnableMenuItem(menu, ID_TOGGLE_PAUSE, ingameEnable); EnableMenuItem(menu, ID_EMULATION_STOP, ingameEnable); EnableMenuItem(menu, ID_EMULATION_RESET, ingameEnable); + EnableMenuItem(menu, ID_CHEAT, ingameEnable); UINT menuEnable = globalUIState == UISTATE_MENU ? MF_ENABLED : MF_GRAYED; EnableMenuItem(menu, ID_FILE_SAVESTATEFILE, !menuEnable); EnableMenuItem(menu, ID_FILE_LOADSTATEFILE, !menuEnable); EnableMenuItem(menu, ID_FILE_QUICKSAVESTATE, !menuEnable); EnableMenuItem(menu, ID_FILE_QUICKLOADSTATE, !menuEnable); + EnableMenuItem(menu, ID_CHEAT, !menuEnable); EnableMenuItem(menu, ID_CPU_DYNAREC, menuEnable); EnableMenuItem(menu, ID_CPU_INTERPRETER, menuEnable); EnableMenuItem(menu, ID_CPU_MULTITHREADED, menuEnable); diff --git a/lang b/lang index 25865bf06..e03a5a7fe 160000 --- a/lang +++ b/lang @@ -1 +1 @@ -Subproject commit 25865bf06478f8937c02d5de54b9a9384063a971 +Subproject commit e03a5a7fee7661d8d1949398c302770517d997ad diff --git a/native b/native index 2bf829cdc..e2301a5a7 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 2bf829cdc18148388ed9ce73a8dc0f88736ddb16 +Subproject commit e2301a5a75943059771320c364d77e135330d341