1 /*
2 Copyright © 2011-2012 Clint Bellanger
3 Copyright © 2012 Igor Paliychuk
4 Copyright © 2013 Kurt Rinnert
5 Copyright © 2012-2016 Justin Jacobs
6 
7 This file is part of FLARE.
8 
9 FLARE is free software: you can redistribute it and/or modify it under the terms
10 of the GNU General Public License as published by the Free Software Foundation,
11 either version 3 of the License, or (at your option) any later version.
12 
13 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE.  See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 FLARE.  If not, see http://www.gnu.org/licenses/
19 */
20 
21 /**
22  * class ActionBar
23  *
24  * Handles the config, display, and usage of the 0-9 hotkeys, mouse buttons, and menu calls
25  */
26 
27 #ifndef MENU_ACTION_BAR_H
28 #define MENU_ACTION_BAR_H
29 
30 #include "CommonIncludes.h"
31 #include "Menu.h"
32 #include "Utils.h"
33 
34 class ActionData;
35 class Power;
36 class StatBlock;
37 class WidgetLabel;
38 class WidgetSlot;
39 
40 class MenuActionBar : public Menu {
41 private:
42 	static const bool IS_EQUIPPED = true;
43 
44 	FPoint setTarget(bool have_aim, const Power& pow);
45 	void addSlot(unsigned index, int x, int y, bool is_locked);
46 	void setItemCount(unsigned index, int count, bool is_equipped);
47 
48 	Sprite *sprite_emptyslot;
49 	Sprite *sprite_disabled;
50 	Sprite *sprite_attention;
51 
52 	Rect src;
53 
54 	std::vector<std::string> labels;
55 	std::vector<std::string> menu_labels;
56 
57 	Point last_mouse;
58 
59 	std::vector<int> slot_fail_cooldown;
60 
61 	SoundID sfx_unable_to_cast;
62 
63 	int tooltip_length;
64 
65 public:
66 	enum {
67 		MENU_CHARACTER = 0,
68 		MENU_INVENTORY = 1,
69 		MENU_POWERS = 2,
70 		MENU_LOG = 3,
71 	};
72 	static const unsigned MENU_COUNT = 4;
73 
74 	static const int SLOT_MAIN1 = 10;
75 	static const int SLOT_MAIN2 = 11;
76 	static const int SLOT_MAX = 12; // maximum number of slots in MenuActionBar
77 
78 	static const int USE_EMPTY_SLOT = 0;
79 
80 	static const bool REORDER = true;
81 	static const bool CLEAR_SKIP_ITEMS = true;
82 	static const bool SET_SKIP_EMPTY = true;
83 
84 	MenuActionBar();
85 	~MenuActionBar();
86 	void align();
87 	void loadGraphics();
88 	void logic();
89 	void render();
90 	void checkAction(std::vector<ActionData> &action_queue);
91 	PowerID checkDrag(const Point& mouse);
92 	void checkMenu(bool &menu_c, bool &menu_i, bool &menu_p, bool &menu_l);
93 	void drop(const Point& mouse, PowerID power_index, bool rearranging);
94 	void actionReturn(PowerID power_index);
95 	void remove(const Point& mouse);
96 	void set(std::vector<PowerID> power_id, bool skip_empty);
97 	void clear(bool skip_items);
98 	void resetSlots();
99 	Point getSlotPos(int slot);
100 	PowerID getSlotPower(int slot);
101 
102 	void renderTooltips(const Point& position);
103 	bool isWithinSlots(const Point& mouse);
104 	bool isWithinMenus(const Point& mouse);
105 	void addPower(const PowerID id, const PowerID target_id);
106 
107 	unsigned slots_count;
108 	std::vector<PowerID> hotkeys; // refer to power_index in PowerManager
109 	std::vector<PowerID> hotkeys_temp; // temp for shapeshifting
110 	std::vector<PowerID> hotkeys_mod; // hotkeys can be changed by items
111 	std::vector<bool> locked; // if slot is locked, you cannot drop it
112 	std::vector<bool> prevent_changing;
113 	std::vector<WidgetSlot *> slots; // hotkey slots
114 	WidgetSlot *menus[MENU_COUNT]; // menu buttons
115 	std::string menu_titles[MENU_COUNT];
116 	std::vector<int> slot_item_count; // -1 means this power isn't item based.  0 means out of items.  1+ means sufficient items.
117 	std::vector<bool> slot_enabled;
118 	bool requires_attention[MENU_COUNT];
119 	std::vector<bool> slot_activated;
120 	std::vector<int> slot_cooldown_size;
121 
122 	int drag_prev_slot;
123 	bool updated;
124 	int twostep_slot;
125 };
126 
127 #endif
128