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_game_hudH 21 #define ui_graphical_game_hudH 22 23 #include "ui/graphical/widget.h" 24 #include "maxrconfig.h" 25 #include "utility/signal/signal.h" 26 #include "utility/signal/signalconnectionmanager.h" 27 28 class cPushButton; 29 class cCheckBox; 30 class cSlider; 31 class cLabel; 32 class cTurnTimeClockWidget; 33 class cUnitVideoWidget; 34 class cUnitDetailsHud; 35 class cUnitRenameWidget; 36 class cUnit; 37 class cAnimationTimer; 38 class cPlayer; 39 class cTurnClock; 40 class cTurnTimeClock; 41 class cGameSettings; 42 43 class cHud : public cWidget 44 { 45 public: 46 static const int panelLeftWidth = 180; 47 static const int panelRightWidth = 12; 48 static const int panelTotalWidth = panelLeftWidth + panelRightWidth; 49 static const int panelTopHeight = 18; 50 static const int panelBottomHeight = 14; 51 static const int panelTotalHeight = panelTopHeight + panelBottomHeight; 52 53 cHud (std::shared_ptr<cAnimationTimer> animationTimer); 54 55 void setPlayer (std::shared_ptr<const cPlayer> player); 56 void setTurnClock (std::shared_ptr<const cTurnClock> turnClock); 57 void setTurnTimeClock (std::shared_ptr<const cTurnTimeClock> turnTimeClock); 58 void setGameSettings (std::shared_ptr<const cGameSettings> gameSettings); 59 60 static AutoSurface generateSurface(); 61 62 void setMinimalZoomFactor (float zoomFactor); 63 void setZoomFactor (float zoomFactor); 64 float getZoomFactor() const; 65 void increaseZoomFactor (double percent); 66 void decreaseZoomFactor (double percent); 67 68 void lockEndButton(); 69 void unlockEndButton(); 70 71 void setSurveyActive (bool value); 72 bool getSurveyActive() const; 73 74 void setHitsActive (bool value); 75 bool getHitsActive() const; 76 77 void setScanActive (bool value); 78 bool getScanActive() const; 79 80 void setStatusActive (bool value); 81 bool getStatusActive() const; 82 83 void setAmmoActive (bool value); 84 bool getAmmoActive() const; 85 86 void setGridActive (bool value); 87 bool getGridActive() const; 88 89 void setColorActive (bool value); 90 bool getColorActive() const; 91 92 void setRangeActive (bool value); 93 bool getRangeActive() const; 94 95 void setFogActive (bool value); 96 bool getFogActive() const; 97 98 void setLockActive (bool value); 99 bool getLockActive() const; 100 101 void setChatActive (bool value); 102 bool getChatActive() const; 103 104 void setMiniMapZoomFactorActive (bool value); 105 bool getMiniMapZoomFactorActive() const; 106 107 void setMiniMapAttackUnitsOnly (bool value); 108 bool getMiniMapAttackUnitsOnly() const; 109 110 void setCoordinatesText (const std::string& text); 111 void setUnitNameText (const std::string& text); 112 113 void startUnitVideo(); 114 void stopUnitVideo(); 115 bool isUnitVideoPlaying(); 116 117 void resizeToResolution(); 118 119 void activateShortcuts(); 120 void deactivateShortcuts(); 121 122 mutable cSignal<void ()> zoomChanged; 123 124 mutable cSignal<void ()> surveyToggled; 125 mutable cSignal<void ()> hitsToggled; 126 mutable cSignal<void ()> scanToggled; 127 mutable cSignal<void ()> statusToggled; 128 mutable cSignal<void ()> ammoToggled; 129 mutable cSignal<void ()> gridToggled; 130 mutable cSignal<void ()> colorToggled; 131 mutable cSignal<void ()> rangeToggled; 132 mutable cSignal<void ()> fogToggled; 133 mutable cSignal<void ()> lockToggled; 134 mutable cSignal<void ()> chatToggled; 135 136 mutable cSignal<void ()> centerClicked; 137 mutable cSignal<void ()> helpClicked; 138 139 mutable cSignal<void ()> reportsClicked; 140 141 mutable cSignal<void ()> miniMapZoomFactorToggled; 142 mutable cSignal<void ()> miniMapAttackUnitsOnlyToggled; 143 144 mutable cSignal<void ()> endClicked; 145 146 mutable cSignal<void ()> filesClicked; 147 mutable cSignal<void ()> preferencesClicked; 148 149 mutable cSignal<void ()> nextClicked; 150 mutable cSignal<void ()> prevClicked; 151 mutable cSignal<void ()> doneClicked; 152 153 mutable cSignal<void (const cUnit&, const std::string&)> triggeredRenameUnit; 154 155 void setActiveUnit (const cUnit* unit); 156 157 virtual bool isAt (const cPosition& position) const MAXR_OVERRIDE_FUNCTION; 158 159 virtual void draw (SDL_Surface& destination, const cBox<cPosition>& clipRect) MAXR_OVERRIDE_FUNCTION; 160 protected: 161 162 private: 163 AutoSurface surface; 164 165 std::shared_ptr<const cPlayer> player; 166 std::shared_ptr<const cTurnClock> turnClock; 167 168 cSignalConnectionManager signalConnectionManager; 169 cSignalConnectionManager turnClockSignalConnectionManager; 170 171 cPushButton* endButton; 172 173 cSlider* zoomSlider; 174 175 cCheckBox* surveyButton; 176 cCheckBox* hitsButton; 177 cCheckBox* scanButton; 178 cCheckBox* statusButton; 179 cCheckBox* ammoButton; 180 cCheckBox* gridButton; 181 cCheckBox* colorButton; 182 cCheckBox* rangeButton; 183 cCheckBox* fogButton; 184 cCheckBox* lockButton; 185 cCheckBox* chatButton; 186 187 cShortcut* surveyShortcut; 188 cShortcut* hitsShortcut; 189 cShortcut* scanShortcut; 190 cShortcut* statusShortcut; 191 cShortcut* ammoShortcut; 192 cShortcut* gridShortcut; 193 cShortcut* colorShortcut; 194 cShortcut* rangeShortcut; 195 cShortcut* fogShortcut; 196 197 cCheckBox* miniMapZoomFactorButton; 198 cCheckBox* miniMapAttackUnitsOnlyButton; 199 200 cLabel* coordsLabel; 201 cLabel* unitNameLabel; 202 cLabel* turnLabel; 203 cTurnTimeClockWidget* turnTimeClockWidget; 204 205 cUnitRenameWidget* unitRenameWidget; 206 207 cUnitVideoWidget* unitVideo; 208 209 cUnitDetailsHud* unitDetails; 210 211 void handleZoomPlusClicked(); 212 void handleZoomMinusClicked(); 213 214 void handlePreferencesClicked(); 215 }; 216 217 218 #endif // ui_graphical_game_hudH 219