1 /*
2  * This file is part of EasyRPG Player.
3  *
4  * EasyRPG Player 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 3 of the License, or
7  * (at your option) any later version.
8  *
9  * EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef EP_WINDOW_BASE_H
19 #define EP_WINDOW_BASE_H
20 
21 // Headers
22 #include <array>
23 #include <string>
24 #include "window.h"
25 #include "game_actor.h"
26 #include "main_data.h"
27 #include "async_handler.h"
28 #include <map>
29 
30 /**
31  * Window Base class.
32  */
33 class Window_Base : public Window {
34 public:
35 	/**
36 	 * Constructor.
37 	 *
38 	 * @param x window x position.
39 	 * @param y window y position.
40 	 * @param width window width.
41 	 * @param height window height.
42 	 * @param flags flags to pass to drawable base class
43 	 */
44 	Window_Base(int x, int y, int width, int height, Drawable::Flags flags = Drawable::Flags::Default);
45 
46 	/**
47 	 * Updates the window.
48 	 */
49 	virtual void Update();
50 
51 	/**
52 	 * Draw helpers.
53 	 */
54 	/** @{ */
55 	void DrawFace(StringView face_name, int face_index, int cx, int cy, bool flip = false);
56 	void DrawActorFace(const Game_Actor& actor, int cx, int cy);
57 	void DrawActorName(const Game_Battler& actor, int cx, int cy) const;
58 	void DrawActorTitle(const Game_Actor& actor, int cx, int cy) const;
59 	void DrawActorClass(const Game_Actor& actor, int cx, int cy) const;
60 	void DrawActorLevel(const Game_Actor& actor, int cx, int cy) const;
61 	void DrawActorState(const Game_Battler& actor, int cx, int cy) const;
62 	void DrawActorExp(const Game_Actor& actor, int cx, int cy) const;
63 	void DrawActorHp(const Game_Battler& actor, int cx, int cy, int digits, bool draw_max = true) const;
64 	void DrawActorSp(const Game_Battler& actor, int cx, int cy, int digits, bool draw_max = true) const;
65 	void DrawActorParameter(const Game_Battler& actor, int cx, int cy, int type) const;
66 	void DrawEquipmentType(const Game_Actor& actor, int cx, int cy, int type) const;
67 	void DrawItemName(const lcf::rpg::Item& item, int cx, int cy, bool enabled = true) const;
68 	void DrawSkillName(const lcf::rpg::Skill& skill, int cx, int cy, bool enabled = true) const;
69 	void DrawCurrencyValue(int money, int cx, int cy) const;
70 	void DrawGauge(const Game_Battler& actor, int cx, int cy, int alpha = 255) const;
71 	void DrawActorHpValue(const Game_Battler& actor, int cx, int cy) const;
72 	void DrawActorSpValue(const Game_Battler& actor, int cx, int cy) const;
73 	int GetValueFontColor(int have, int max, bool can_knockout) const;
74 	/** @} */
75 
76 	/**
77 	 * Cancels async loading of faces.
78 	 * Used to prevent rendering faces that are loaded too slow on the wrong page.
79 	 */
80 	void CancelFace();
81 
82 	bool InitMovement(int old_x, int old_y, int new_x, int new_y, int duration);
83 	bool IsMovementActive();
84 	void UpdateMovement();
85 
86 protected:
87 	void OnFaceReady(FileRequestResult* result, int face_index, int cx, int cy, bool flip);
88 
89 	std::vector<FileRequestBinding> face_request_ids;
90 
91 	int current_frame = 0;
92 	int total_frames = 0;
93 	std::array<int, 2> old_position;
94 	std::array<int, 2> new_position;
95 
96 };
97 
98 #endif
99