1 /* 2 Copyright © 2011-2012 Clint Bellanger 3 Copyright © 2012 Igor Paliychuk 4 Copyright © 2012 Stefan Beller 5 Copyright © 2014 Henrik Andersson 6 Copyright © 2012-2016 Justin Jacobs 7 8 This file is part of FLARE. 9 10 FLARE is free software: you can redistribute it and/or modify it under the terms 11 of the GNU General Public License as published by the Free Software Foundation, 12 either version 3 of the License, or (at your option) any later version. 13 14 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 16 PARTICULAR PURPOSE. See the GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License along with 19 FLARE. If not, see http://www.gnu.org/licenses/ 20 */ 21 22 /** 23 * class MenuPowers 24 */ 25 26 #ifndef MENU_POWERS_H 27 #define MENU_POWERS_H 28 29 #include "CommonIncludes.h" 30 #include "Menu.h" 31 #include "Utils.h" 32 33 class MenuActionBar; 34 class StatBlock; 35 class TooltipData; 36 class WidgetButton; 37 class WidgetLabel; 38 class WidgetSlot; 39 class WidgetTabControl; 40 41 class MenuPowersTab { 42 public: 43 std::string title; 44 std::string background; 45 MenuPowersTab()46 MenuPowersTab() 47 : title("") 48 , background("") { 49 } 50 }; 51 52 class MenuPowersCell { 53 public: 54 MenuPowersCell(); 55 56 PowerID id; 57 bool requires_point; 58 59 int requires_level; 60 std::vector<int> requires_primary; 61 std::vector<PowerID> requires_power; 62 std::vector<StatusID> requires_status; 63 std::vector<StatusID> requires_not_status; 64 65 bool visible; 66 bool visible_check_locked; 67 bool visible_check_status; 68 69 int upgrade_level; 70 bool passive_on; 71 bool is_unlocked; 72 73 size_t group; 74 MenuPowersCell* next; // TODO should we also have "parent"? 75 }; 76 77 class MenuPowersCellGroup { 78 public: 79 MenuPowersCellGroup(); 80 MenuPowersCell* getCurrent(); 81 MenuPowersCell* getBonusCurrent(MenuPowersCell* pcell); 82 int getBonusLevels(); 83 84 int tab; 85 Point pos; 86 87 size_t current_cell; 88 std::vector<MenuPowersCell> cells; 89 90 WidgetButton* upgrade_button; 91 92 std::vector< std::pair<size_t, int> > bonus_levels; 93 }; 94 95 class MenuPowers : public Menu { 96 private: 97 static const bool UPGRADE_POWER_ALL_TABS = true; 98 99 void loadGraphics(); 100 void loadTab(FileParser &infile); 101 void loadPower(FileParser &infile); 102 void loadUpgrade(FileParser &infile, std::vector<MenuPowersCell>& power_cell_upgrade); 103 104 bool checkRequirements(MenuPowersCell* pcell); 105 bool checkRequirementStatus(MenuPowersCell* pcell); 106 bool checkUnlocked(MenuPowersCell* pcell); 107 bool checkUnlock(MenuPowersCell* pcell); 108 bool checkUpgrade(MenuPowersCell* pcell); 109 void lockCell(MenuPowersCell* pcell); 110 bool isBonusCell(MenuPowersCell* pcell); 111 bool isCellVisible(MenuPowersCell* pcell); 112 113 MenuPowersCell* getCellByPowerIndex(PowerID power_index); 114 115 void upgradePower(MenuPowersCell* pcell, bool ignore_tab); 116 117 int getPointsUsed(); 118 119 void createTooltip(TooltipData* tip_data, MenuPowersCell* pcell, PowerID power_index, bool show_unlock_prompt, int tooltip_length); 120 void renderPowers(int tab_num); 121 122 std::vector<MenuPowersCellGroup> power_cell; 123 bool skip_section; 124 125 Sprite *powers_unlock; 126 Sprite *overlay_disabled; 127 std::vector<Sprite *> tree_surf; 128 WidgetButton *closeButton; 129 130 Point close_pos; 131 Rect tab_area; 132 133 int points_left; 134 std::vector<MenuPowersTab> tabs; 135 std::string default_background; 136 137 WidgetLabel *label_powers; 138 WidgetLabel *label_unspent; 139 WidgetTabControl *tab_control; 140 141 bool tree_loaded; 142 143 int default_power_tab; 144 145 public: 146 enum { 147 TOOLTIP_SHORT = 0, 148 TOOLTIP_LONG_MENU = 1, 149 TOOLTIP_LONG_ALL = 2 150 }; 151 152 MenuPowers(); 153 ~MenuPowers(); 154 void align(); 155 156 void loadPowerTree(const std::string &filename); 157 158 void logic(); 159 void render(); 160 161 void renderTooltips(const Point& position); 162 PowerID click(const Point& mouse); 163 void upgradeBySlotIndex(int slot_index); 164 165 void setUnlockedPowers(); 166 void resetToBasePowers(); 167 168 bool meetsUsageStats(PowerID power_index); 169 170 void clearActionBarBonusLevels(); 171 void clearBonusLevels(); 172 void addBonusLevels(PowerID power_index, int bonus_levels); 173 std::string getItemBonusPowerReqString(PowerID power_index); 174 175 void createTooltipFromActionBar(TooltipData* tip_data, unsigned slot, int tooltip_length); 176 177 std::vector<WidgetSlot*> slots; // power slot Widgets 178 179 bool newPowerNotification; 180 181 182 std::vector<TabList> tablist_pow; 183 184 bool isTabListSelected(); 185 int getSelectedCellIndex(); 186 void setNextTabList(TabList *tl); 187 TabList* getCurrentTabList(); 188 void defocusTabLists(); 189 }; 190 #endif 191