1 /*
2 Copyright © 2011-2012 Clint Bellanger
3 Copyright © 2012-2016 Justin Jacobs
4 
5 This file is part of FLARE.
6 
7 FLARE is free software: you can redistribute it and/or modify it under the terms
8 of the GNU General Public License as published by the Free Software Foundation,
9 either version 3 of the License, or (at your option) any later version.
10 
11 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License along with
16 FLARE.  If not, see http://www.gnu.org/licenses/
17 */
18 
19 /**
20  * class MenuCharacter
21  */
22 
23 #ifndef MENU_CHARACTER_H
24 #define MENU_CHARACTER_H
25 
26 #include "CommonIncludes.h"
27 #include "TooltipData.h"
28 #include "WidgetLabel.h"
29 
30 class StatBlock;
31 class WidgetButton;
32 class WidgetLabel;
33 class WidgetListBox;
34 
35 class MenuCharacter : public Menu {
36 private:
37 	class CharStat {
38 	public:
39 		WidgetLabel *label;
40 		WidgetLabel *value;
41 		Rect hover;
42 		TooltipData tip;
43 		Rect value_pos;
44 
setHover(int x,int y)45 		void setHover(int x, int y) {
46 			hover.x = x + value_pos.x;
47 			hover.y = y + value_pos.y;
48 			hover.w = value_pos.w;
49 			hover.h = value_pos.h;
50 		}
51 	};
52 
53 	enum {
54 		CSTAT_NAME = 0,
55 		CSTAT_LEVEL = 1
56 	};
57 
58 	WidgetButton *closeButton;
59 	WidgetLabel *labelCharacter;
60 	WidgetLabel *labelUnspent;
61 	WidgetListBox *statList;
62 	std::vector<WidgetButton*> upgradeButton;
63 
64 	void loadGraphics();
65 	Color bonusColor(int stat);
66 	std::string statTooltip(int stat);
67 	std::string damageTooltip(size_t dmg_type);
68 	bool checkSkillPoints();
69 	int skill_points;
70 	std::vector<bool> primary_up;
71 
72 	// label and widget positions
73 	Point statlist_pos;
74 	int statlist_rows;
75 	int statlist_scrollbar_offset;
76 	std::vector<bool> show_stat;
77 	bool show_resists;
78 
79 	std::vector<CharStat> cstat;
80 
81 	std::vector<int*> base_stats;
82 	std::vector<int*> base_stats_add;
83 	std::vector< std::vector<int>* > base_bonus;
84 
85 	int name_max_width;
86 
87 public:
88 	explicit MenuCharacter();
89 	~MenuCharacter();
90 	void align();
91 
92 	void logic();
93 	void render();
94 	void refreshStats();
95 	void renderTooltips(const Point& position);
96 	bool checkUpgrade();
getUnspent()97 	int getUnspent() {
98 		return skill_points;
99 	}
100 };
101 
102 #endif
103