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_H
20 #define CHEAT_H
21 
22 #include <memory>
23 #include <vector>
24 #include "singles.h"
25 
26 class Game_window;
27 class ShapeBrowser;
28 class SoundTester;
29 class CheatScreen;
30 class Actor;
31 class Game_object;
32 class Tile_coord;
33 class Effects_manager;
34 class Map_chunk;
35 
36 using Game_object_shared = std::shared_ptr<Game_object>;
37 
38 class Cheat : public Game_singletons {
39 public:
40 	Cheat();
41 	~Cheat();
42 
43 	void init();
44 	void finish_init();
45 	enum Map_editor_mode {
46 	    move = 0,           // Normal dragging.
47 	    paint = 1,          // Left-mouse dragging paints shapes.
48 	    paint_chunks = 2,       // Left-dragging paints whole chunks.
49 	    combo_pick = 3,         // Left-click adds item to combo.
50 	    select_chunks = 4       // Select whole chunks.
51 	};
52 private:
53 	ShapeBrowser *browser;
54 	SoundTester *tester;
55 	CheatScreen *cscreen;
56 
57 	bool god_mode;
58 	bool wizard_mode;
59 	bool map_editor;
60 	bool tile_grid;
61 	Map_editor_mode edit_mode;
62 	int  edit_lift;
63 	int  edit_shape, edit_frame;      // What to 'paint' with.
64 	int  edit_chunknum;           // For painting with chunks.
65 	std::vector<Game_object_shared> selected;   // Selected objects (map-editing).
66 	std::vector<Game_object_shared> clipboard;  // Cut/copy/paste objects.
67 	bool infravision;
68 	bool pickpocket;
69 	bool grab_actor;
70 	bool npc_numbers;
71 	bool hack_mover;
72 
73 	bool enabled;
74 	// Rectangle containing selected chunks:
75 	int chunksel_left, chunksel_right, chunksel_top, chunksel_bottom;
76 
77 	void send_select_status();
78 public:
operator()79 	bool operator()() const {
80 		return enabled;
81 	}
82 	void set_enabled(bool en);
83 
in_god_mode()84 	bool in_god_mode() const {
85 		return god_mode;
86 	}
in_wizard_mode()87 	bool in_wizard_mode() const {
88 		return wizard_mode;
89 	}
in_map_editor()90 	bool in_map_editor() const {
91 		return map_editor;
92 	}
show_tile_grid()93 	bool show_tile_grid() const {
94 		return map_editor && tile_grid;
95 	}
get_edit_mode()96 	Map_editor_mode get_edit_mode() const {
97 		return edit_mode;
98 	}
get_edit_lift()99 	int  get_edit_lift() const {
100 		return edit_lift;
101 	}
get_edit_shape()102 	int  get_edit_shape() const {
103 		return edit_shape;
104 	}
get_edit_frame()105 	int  get_edit_frame() const {
106 		return edit_frame;
107 	}
get_edit_chunknum()108 	int  get_edit_chunknum() const {
109 		return edit_chunknum;
110 	}
in_infravision()111 	bool in_infravision() const {
112 		return infravision;
113 	}
in_pickpocket()114 	bool in_pickpocket() const {
115 		return pickpocket;
116 	}
in_hack_mover()117 	bool in_hack_mover() const {
118 		return hack_mover || map_editor;
119 	}
120 
121 	void toggle_god();
set_god(bool god)122 	void set_god(bool god) {
123 		god_mode = god;
124 	}
125 	void toggle_wizard();
set_wizard(bool wizard)126 	void set_wizard(bool wizard) {
127 		wizard_mode = wizard;
128 	}
129 	void toggle_map_editor();
130 	void toggle_tile_grid();
131 	void set_edit_mode(Map_editor_mode md);
132 	void clear_chunksel();
133 	void add_chunksel(Map_chunk *chunk, bool extend = false);
134 	void move_chunk(Map_chunk *chunk, int dx, int dy);
135 	void move_selected_chunks(int dx, int dy);
136 	void set_edit_lift(int lift);
137 	void set_edit_shape(int sh, int fr);
set_edit_chunknum(int chnum)138 	void set_edit_chunknum(int chnum) {
139 		edit_chunknum = chnum;
140 	}
set_map_editor(bool map)141 	void set_map_editor(bool map) {
142 		if (map_editor != map)
143 			toggle_map_editor();
144 	}
145 	void toggle_infravision();
set_infravision(bool infra)146 	void set_infravision(bool infra) {
147 		infravision = infra;
148 	}
149 	void toggle_pickpocket();
set_pickpocket(bool pick)150 	void set_pickpocket(bool pick) {
151 		pickpocket = pick;
152 	}
153 	void toggle_hack_mover();
set_hack_mover(bool hm)154 	void set_hack_mover(bool hm) {
155 		hack_mover = hm;
156 	}
157 
158 	void toggle_eggs() const;
159 	void change_gender() const;
160 
161 	void toggle_Petra() const;
162 	void toggle_naked() const;
163 	void change_skin() const;
164 
165 	void levelup_party() const;
166 	void heal_party() const;
167 
168 	void fake_time_period() const;
169 	void dec_skip_lift() const;
170 	void set_skip_lift(int skip) const;
171 
172 	void append_selected(Game_object *obj);
173 	void toggle_selected(Game_object *obj);
174 	void clear_selected();
175 	void delete_selected();
176 	void move_selected_objs(int dx, int dy, int dz);
177 	void move_selected(int dx, int dy, int dz);
get_selected()178 	const std::vector<Game_object_shared> &get_selected() const {
179 		return selected;
180 	}
181 	bool is_selected(Game_object *o);
182 
183 	void cut(bool copy = false);
184 	void paste(int mx, int my);
185 	void paste();
get_clipboard()186 	const std::vector<Game_object_shared> &get_clipboard() const {
187 		return clipboard;
188 	}
189 
190 	void map_teleport() const;
191 	void cursor_teleport() const;
192 	void next_map_teleport() const;
193 
194 	void create_coins() const;
195 	void create_last_shape() const;
196 	void delete_object();
197 	void shape_browser() const;
198 	bool get_browser_shape(int &shape, int &frame) const;
199 	void sound_tester() const;
200 
201 	void cheat_screen() const;
202 
grabbing_actor()203 	bool grabbing_actor() const {
204 		return grab_actor;
205 	}
206 	void toggle_grab_actor();
set_grab_actor(bool grab)207 	void set_grab_actor(bool grab) {
208 		grab_actor = grab;
209 	}
210 	void set_grabbed_actor(Actor *actor) const;
211 	void clear_this_grabbed_actor(Actor *actor) const;
212 
number_npcs()213 	bool number_npcs() const {
214 		return npc_numbers;
215 	}
216 	void toggle_number_npcs();
set_number_npcs(bool num)217 	void set_number_npcs(bool num) {
218 		npc_numbers = num;
219 	}
220 };
221 
222 extern Cheat cheat;
223 
224 #endif
225