1 // Copyright (c) 2013- PPSSPP Project.
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, version 2.0 or later versions.
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU General Public License 2.0 for more details.
12 // A copy of the GPL 2.0 should have been included with the program.
13 // If not, see http://www.gnu.org/licenses/
15 // Official git repository and contact information can be found at
16 // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
19 #include "Common/FileUtil.h"
21 #include "base/functional.h"
23 #include "ui/ui_screen.h"
24 #include "ui/ui_context.h"
25 #include "../Core/CwCheat.h"
26 #include "UI/MiscScreens.h"
27 #include "UI/GameSettingsScreen.h"
29 extern std::string activeCheatFile
;
30 extern std::string gameTitle
;
32 class CwCheatScreen
: public UIDialogScreenWithBackground
{
35 void CreateCodeList();
36 void processFileOn(std::string activatedCheat
);
37 void processFileOff(std::string deactivatedCheat
);
39 std::string activatedCheat
, deactivatedCheat
;
40 UI::EventReturn
OnBack(UI::EventParams
¶ms
);
41 UI::EventReturn
OnAddCheat(UI::EventParams
¶ms
);
42 UI::EventReturn
OnImportCheat(UI::EventParams
¶ms
);
43 UI::EventReturn
OnEditCheatFile(UI::EventParams
¶ms
);
44 UI::EventReturn
OnEnableAll(UI::EventParams
¶ms
);
46 virtual void onFinish(DialogResult result
);
48 virtual void CreateViews();
51 UI::EventReturn
OnCheckBox(UI::EventParams
¶ms
);
52 std::vector
<std::string
> formattedList_
;
53 bool anythingChanged_
;
56 // TODO: Instead just hook the OnClick event on a regular checkbox.
57 class CheatCheckBox
: public UI::ClickableItem
, public CwCheatScreen
{
59 CheatCheckBox(bool *toggle
, const std::string
&text
, const std::string
&smallText
= "", UI::LayoutParams
*layoutParams
= 0)
60 : UI::ClickableItem(layoutParams
), toggle_(toggle
), text_(text
) {
61 OnClick
.Handle(this, &CheatCheckBox::OnClicked
);
64 virtual void Draw(UIContext
&dc
);
66 UI::EventReturn
OnClicked(UI::EventParams
&e
) {
69 *toggle_
= !(*toggle_
);
73 activatedCheat
= text_
;
74 processFileOn(activatedCheat
);
76 deactivatedCheat
= text_
;
77 processFileOff(deactivatedCheat
);
79 return UI::EVENT_DONE
;
85 std::string smallText_
;