1 /*************************************************************************** 2 * Mechanized Assault and Exploration Reloaded Projectfile * 3 * * 4 * This program 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 2 of the License, or * 7 * (at your option) any later version. * 8 * * 9 * This program 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 this program; if not, write to the * 16 * Free Software Foundation, Inc., * 17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 18 ***************************************************************************/ 19 20 #ifndef ui_graphical_menu_windows_windowupgrades_windowupgradesH 21 #define ui_graphical_menu_windows_windowupgrades_windowupgradesH 22 23 #include <map> 24 #include <array> 25 26 #include "ui/graphical/menu/windows/windowhangar/windowhangar.h" 27 28 class cLabel; 29 class cPushButton; 30 class cResourceBar; 31 class cCheckBox; 32 class cPlayer; 33 class cTurnTimeClock; 34 35 class cWindowUpgradesFilterState 36 { 37 public: cWindowUpgradesFilterState()38 cWindowUpgradesFilterState(): 39 TankChecked(true), 40 PlaneChecked(true), 41 ShipChecked(true), 42 BuildingChecked(true), 43 TNTChecked(false) 44 {}; 45 bool TankChecked; 46 bool PlaneChecked; 47 bool ShipChecked; 48 bool BuildingChecked; 49 bool TNTChecked; 50 }; 51 52 class cWindowUpgrades : public cWindowHangar 53 { 54 // TODO: remove code duplication with @ref cWindowLandingUnitSelection 55 public: 56 explicit cWindowUpgrades (const cPlayer& player, std::shared_ptr<const cTurnTimeClock> turnTimeClock, std::shared_ptr<cWindowUpgradesFilterState> filterState); 57 58 std::vector<std::pair<sID, cUnitUpgrade>> getUnitUpgrades() const; 59 60 protected: 61 virtual void setActiveUnit (const sID& unitId) MAXR_OVERRIDE_FUNCTION; 62 63 private: 64 cSignalConnectionManager signalConnectionManager; 65 66 cCheckBox* tankCheckBox; 67 cCheckBox* planeCheckBox; 68 cCheckBox* shipCheckBox; 69 cCheckBox* buildingCheckBox; 70 cCheckBox* tntCheckBox; 71 std::shared_ptr<cWindowUpgradesFilterState> filterState; 72 73 cResourceBar* goldBar; 74 cLabel* goldBarAmountLabel; 75 76 static const size_t maxUpgradeButtons = 8; 77 78 std::array<cPushButton*, maxUpgradeButtons> upgradeDecreaseButton; 79 std::array<cPushButton*, maxUpgradeButtons> upgradeIncreaseButton; 80 std::array<cLabel*, maxUpgradeButtons> upgradeCostLabel; 81 82 std::map<sID, cUnitUpgrade> unitUpgrades; 83 84 void generateSelectionList (bool select); 85 86 void goldChanged(); 87 88 void upgradeIncreaseClicked (size_t index); 89 void upgradeDecreaseClicked (size_t index); 90 91 void updateUpgradeButtons(); 92 }; 93 94 #endif // ui_graphical_menu_windows_windowupgrades_windowupgradesH 95