1 /*
2 Copyright © 2018 Justin Jacobs
3 
4 This file is part of FLARE.
5 
6 FLARE is free software: you can redistribute it and/or modify it under the terms
7 of the GNU General Public License as published by the Free Software Foundation,
8 either version 3 of the License, or (at your option) any later version.
9 
10 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 FLARE.  If not, see http://www.gnu.org/licenses/
16 */
17 
18 /**
19  * class EngineSettings
20  */
21 
22 #ifndef ENGINESETTINGS_H
23 #define ENGINESETTINGS_H
24 
25 #include "CommonIncludes.h"
26 #include "Utils.h"
27 #include "WidgetLabel.h"
28 
29 class EngineSettings {
30 public:
31 	void load();
32 
33 	class Misc {
34 	public:
35 		void load();
36 
37 		enum {
38 			SAVE_ONSTASH_NONE = 0,
39 			SAVE_ONSTASH_PRIVATE = 1,
40 			SAVE_ONSTASH_SHARED = 2,
41 			SAVE_ONSTASH_ALL = 3,
42 		};
43 
44 		bool save_hpmp;
45 		int corpse_timeout;
46 		bool sell_without_vendor;
47 		int aim_assist;
48 		std::string window_title;
49 		std::string save_prefix;
50 		int sound_falloff;
51 		int party_exp_percentage;
52 		bool enable_ally_collision;
53 		bool enable_ally_collision_ai;
54 		ItemID currency_id;
55 		float interact_range;
56 		bool menus_pause;
57 		bool save_onload;
58 		bool save_onexit;
59 		bool save_pos_onexit;
60 		bool save_oncutscene;
61 		int save_onstash;
62 		bool save_anywhere;
63 		float camera_speed;
64 		bool save_buyback;
65 		bool keep_buyback_on_map_change;
66 		std::string sfx_unable_to_cast;
67 		bool combat_aborts_npc_interact;
68 	};
69 
70 	class Resolutions {
71 	public:
72 		void load();
73 
74 		unsigned short frame_w;
75 		unsigned short frame_h;
76 		unsigned short icon_size;
77 		unsigned short min_screen_w;
78 		unsigned short min_screen_h;
79 		std::vector<unsigned short> virtual_heights;
80 		float virtual_dpi;
81 		bool ignore_texture_filter;
82 	};
83 
84 	class Gameplay {
85 	public:
86 		void load();
87 
88 		bool enable_playgame;
89 	};
90 
91 	class Combat {
92 	public:
93 		void load();
94 
95 		int min_absorb;
96 		int max_absorb;
97 		int min_resist;
98 		int max_resist;
99 		int min_block;
100 		int max_block;
101 		int min_avoidance;
102 		int max_avoidance;
103 		int min_miss_damage;
104 		int max_miss_damage;
105 		int min_crit_damage;
106 		int max_crit_damage;
107 		int min_overhit_damage;
108 		int max_overhit_damage;
109 	};
110 
111 	class Elements {
112 	public:
113 		class Element {
114 		public:
115 			std::string id;
116 			std::string name;
117 		};
118 
119 		void load();
120 
121 		std::vector<Element> list;
122 	};
123 
124 	class EquipFlags {
125 	public:
126 		class EquipFlag {
127 		public:
128 			std::string id;
129 			std::string name;
130 		};
131 
132 		void load();
133 
134 		std::vector<EquipFlag> list;
135 	};
136 
137 	class PrimaryStats {
138 	public:
139 		class PrimaryStat {
140 		public:
141 			std::string id;
142 			std::string name;
143 		};
144 
145 		void load();
146 		size_t getIndexByID(const std::string& id);
147 
148 		std::vector<PrimaryStat> list;
149 	};
150 
151 	class HeroClasses {
152 	public:
153 		class HeroClass {
154 		public:
155 			HeroClass();
156 
157 			std::string name;
158 			std::string description;
159 			int currency;
160 			std::string equipment;
161 			std::string carried;
162 			std::vector<int> primary;
163 			std::vector<PowerID> hotkeys;
164 			std::vector<PowerID> powers;
165 			std::vector<std::string> statuses;
166 			std::string power_tree;
167 			int default_power_tab;
168 			std::vector<int> options;
169 		};
170 
171 		void load();
172 		HeroClass* getByName(const std::string& name);
173 
174 		std::vector<HeroClass> list;
175 	};
176 
177 	class DamageTypes {
178 	public:
179 		class DamageType {
180 		public:
181 			std::string id;
182 			std::string name;
183 			std::string name_min;
184 			std::string name_max;
185 			std::string description;
186 			std::string min;
187 			std::string max;
188 		};
189 
190 		void load();
191 
192 		std::vector<DamageType> list;
193 		size_t count; // damage_types.size() * 2, to account for min & max
194 	};
195 
196 	class DeathPenalty {
197 	public:
198 		void load();
199 
200 		bool enabled;
201 		bool permadeath;
202 		int currency;
203 		int xp;
204 		int xp_current;
205 		bool item;
206 	};
207 
208 	class Tooltips {
209 	public:
210 		void load();
211 
212 		int offset;
213 		int width;
214 		int margin;
215 		int margin_npc;
216 		int background_border;
217 	};
218 
219 	class Loot {
220 	public:
221 		void load();
222 
223 		int tooltip_margin;
224 		bool autopickup_currency;
225 		float autopickup_range;
226 		std::string currency;
227 		float vendor_ratio;
228 		float vendor_ratio_buyback;
229 		std::string sfx_loot;
230 		int drop_max;
231 		int drop_radius;
232 		float hide_radius;
233 	};
234 
235 	class Tileset {
236 	public:
237 		void load();
238 
239 		enum {
240 			TILESET_ISOMETRIC = 0,
241 			TILESET_ORTHOGONAL = 1
242 		};
243 
244 		float units_per_pixel_x;
245 		float units_per_pixel_y;
246 		unsigned short tile_w;
247 		unsigned short tile_h;
248 		unsigned short tile_w_half;
249 		unsigned short tile_h_half;
250 		unsigned short orientation;
251 	};
252 
253 	class Widgets {
254 	public:
255 		void load();
256 
257 		Color selection_rect_color;
258 		Point colorblind_highlight_offset;
259 		Point tab_padding;
260 		LabelInfo slot_quantity_label;
261 		Color slot_quantity_color;
262 		Color slot_quantity_bg_color;
263 		LabelInfo slot_hotkey_label;
264 		Color slot_hotkey_color;
265 		Color slot_hotkey_bg_color;
266 		Point listbox_text_margin;
267 		int horizontal_list_text_width;
268 		Color scrollbar_bg_color;
269 	};
270 
271 	class XPTable {
272 	public:
273 		void load();
274 
275 		unsigned long getLevelXP(int level);
276 		int getMaxLevel();
277 		int getLevelFromXP(unsigned long level_xp);
278 
279 	private:
280 		std::vector<unsigned long> xp_table;
281 	};
282 
283 	Misc misc;
284 	Resolutions resolutions;
285 	Gameplay gameplay;
286 	Combat combat;
287 	Elements elements;
288 	EquipFlags equip_flags;
289 	PrimaryStats primary_stats;
290 	HeroClasses hero_classes;
291 	DamageTypes damage_types;
292 	DeathPenalty death_penalty;
293 	Tooltips tooltips;
294 	Loot loot;
295 	Tileset tileset;
296 	Widgets widgets;
297 	XPTable xp;
298 };
299 
300 #endif // ENGINESETTINGS_H
301