1 /*
2  *  Copyright (C) 2000-2013  The Exult Team
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #ifndef CHEAT_SCREEN_H
20 #define CHEAT_SCREEN_H
21 
22 #include "palette.h"
23 
24 class Game_window;
25 class Image_buffer8;
26 class Font;
27 class Game_clock;
28 class Actor;
29 
30 class CheatScreen {
31 	Actor           *grabbed = nullptr;
32 	static const char   *schedules[33];
33 	static const char   *flag_names[64];
34 	static const char   *alignments[4];
35 
36 public:
37 	void    show_screen();
SetGrabbedActor(Actor * g)38 	void    SetGrabbedActor(Actor *g) {
39 		grabbed = g;
40 	}
ClearThisGrabbedActor(Actor * g)41 	void    ClearThisGrabbedActor(Actor *g) const {
42 		if (g == grabbed) g = nullptr;
43 	}
44 private:
45 	enum Cheat_Prompt {
46 	    CP_Command = 0,
47 
48 	    CP_HitKey = 1,
49 	    CP_NotAvail = 2,
50 	    CP_InvalidNPC = 3,
51 	    CP_InvalidCom = 4,
52 	    CP_Canceled = 5,
53 	    CP_ClockSet = 6,
54 	    CP_InvalidTime = 7,
55 	    CP_InvalidShape = 8,
56 	    CP_InvalidValue = 9,
57 	    CP_Created = 10,
58 	    CP_ShapeSet = 11,
59 	    CP_ValueSet = 12,
60 	    CP_NameSet = 13,
61 	    CP_WrongShapeFile = 14,
62 
63 	    CP_ChooseNPC = 16,
64 	    CP_EnterValue = 17,
65 	    CP_Minute = 18,
66 	    CP_Hour = 19,
67 	    CP_Day = 20,
68 	    CP_Shape = 21,
69 	    CP_Activity = 22,
70 	    CP_XCoord = 23,
71 	    CP_YCoord = 24,
72 	    CP_Lift = 25,
73 	    CP_GFlagNum = 26,
74 	    CP_NFlagNum = 27,
75 	    CP_TempNum = 28,
76 	    CP_NLatitude = 29,
77 	    CP_SLatitude = 30,
78 	    CP_WLongitude = 31,
79 	    CP_ELongitude = 32,
80 
81 	    CP_Name = 33,
82 	    CP_NorthSouth = 34,
83 	    CP_WestEast = 35,
84 
85 	    CP_HexXCoord = 37,
86 	    CP_HexYCoord = 38,
87 	    CP_EnterValueNoCancel = 39
88 	};
89 	Game_window *gwin = nullptr;
90 	Image_buffer8 *ibuf = nullptr;
91 	Font *font = nullptr;
92 	Game_clock *clock = nullptr;
93 	int maxx = 0, maxy = 0;
94 	int centerx = 0, centery = 0;
95 	Palette pal;
96 
97 	void SharedPrompt(char *input, const Cheat_Prompt &mode);
98 	bool SharedInput(char *input, int len, int &command, Cheat_Prompt &mode, bool &activate);
99 
100 	void NormalLoop();
101 	void NormalDisplay();
102 	void NormalMenu();
103 	void NormalActivate(char *input, int &command, Cheat_Prompt &mode);
104 	bool NormalCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate);
105 
106 	void ActivityDisplay();
107 
108 	Cheat_Prompt GlobalFlagLoop(int num);
109 
110 	Cheat_Prompt TimeSetLoop();
111 
112 	Cheat_Prompt NPCLoop(int num);
113 	void NPCDisplay(Actor *actor, int &num);
114 	void NPCMenu(Actor *actor, int &num);
115 	void NPCActivate(char *input, int &command, Cheat_Prompt &mode, Actor *actor, int &num);
116 	bool NPCCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor, int &num);
117 
118 	void FlagLoop(Actor *actor);
119 	void FlagMenu(Actor *actor);
120 	void FlagActivate(char *input, int &command, Cheat_Prompt &mode, Actor *actor);
121 	bool FlagCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor);
122 	Cheat_Prompt AdvancedFlagLoop(int flagnum, Actor *actor);
123 
124 	void BusinessLoop(Actor *actor);
125 	void BusinessDisplay(Actor *actor);
126 	void BusinessMenu(Actor *actor);
127 	void BusinessActivate(char *input, int &command, Cheat_Prompt &mode, Actor *actor, int &time, int &prev);
128 	bool BusinessCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor, int &time);
129 
130 	void StatLoop(Actor *actor);
131 	void StatMenu(Actor *actor);
132 	void StatActivate(char *input, int &command, Cheat_Prompt &mode, Actor *actor);
133 	bool StatCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate, Actor *actor);
134 
135 	void TeleportLoop();
136 	void TeleportDisplay();
137 	void TeleportMenu();
138 	void TeleportActivate(char *input, int &command, Cheat_Prompt &mode, int &prev);
139 	bool TeleportCheck(char *input, int &command, Cheat_Prompt &mode, bool &activate);
140 };
141 
142 #endif
143