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 #include "ui/graphical/game/hud.h"
21
22 #include "ui/graphical/game/widgets/unitvideowidget.h"
23 #include "ui/graphical/game/widgets/unitdetailshud.h"
24 #include "ui/graphical/game/widgets/unitrenamewidget.h"
25 #include "ui/graphical/game/widgets/turntimeclockwidget.h"
26
27 #include "ui/graphical/menu/widgets/pushbutton.h"
28 #include "ui/graphical/menu/widgets/checkbox.h"
29 #include "ui/graphical/menu/widgets/label.h"
30 #include "ui/graphical/menu/widgets/lineedit.h"
31 #include "ui/graphical/menu/widgets/slider.h"
32
33 #include "defines.h"
34 #include "settings.h"
35 #include "video.h"
36 #include "pcx.h"
37 #include "main.h"
38 #include "game/data/units/unit.h"
39 #include "keys.h"
40 #include "game/logic/turnclock.h"
41 #include "game/logic/turntimeclock.h"
42
43 //------------------------------------------------------------------------------
cHud(std::shared_ptr<cAnimationTimer> animationTimer)44 cHud::cHud (std::shared_ptr<cAnimationTimer> animationTimer) :
45 player (nullptr)
46 {
47 surface = generateSurface();
48 resize (cPosition (surface->w, surface->h));
49
50 endButton = addChild (std::make_unique<cPushButton> (cPosition (391, 4), ePushButtonType::HudEnd, lngPack.i18n ("Text~Others~End"), FONT_LATIN_NORMAL));
51 endButton->addClickShortcut (KeysList.keyEndTurn);
52 signalConnectionManager.connect (endButton->clicked, [&]() { endClicked(); });
53
54 auto preferencesButton = addChild (std::make_unique<cPushButton> (cPosition (86, 4), ePushButtonType::HudPreferences, lngPack.i18n ("Text~Others~Settings"), FONT_LATIN_SMALL_WHITE));
55 signalConnectionManager.connect (preferencesButton->clicked, [&]() { preferencesClicked(); });
56 auto filesButton = addChild (std::make_unique<cPushButton> (cPosition (17, 3), ePushButtonType::HudFiles, lngPack.i18n ("Text~Others~Files"), FONT_LATIN_SMALL_WHITE));
57 signalConnectionManager.connect (filesButton->clicked, [&]() { filesClicked(); });
58
59 surveyButton = addChild (std::make_unique<cCheckBox> (cPosition (2, 296), lngPack.i18n ("Text~Others~Survey"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_00, false, &SoundData.SNDHudSwitch));
60 surveyShortcut = &surveyButton->addClickShortcut (KeysList.keySurvey);
61 signalConnectionManager.connect (surveyButton->toggled, [&]() { surveyToggled(); });
62
63 hitsButton = addChild (std::make_unique<cCheckBox> (cPosition (57, 296), lngPack.i18n ("Text~Others~Hitpoints_7"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_01, false, &SoundData.SNDHudSwitch));
64 hitsShortcut = &hitsButton->addClickShortcut (KeysList.keyHitpoints);
65 signalConnectionManager.connect (hitsButton->toggled, [&]() { hitsToggled(); });
66
67 scanButton = addChild (std::make_unique<cCheckBox> (cPosition (112, 296), lngPack.i18n ("Text~Others~Scan"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_02, false, &SoundData.SNDHudSwitch));
68 scanShortcut = &scanButton->addClickShortcut (KeysList.keyScan);
69 signalConnectionManager.connect (scanButton->toggled, [&]() { scanToggled(); });
70
71 statusButton = addChild (std::make_unique<cCheckBox> (cPosition (2, 296 + 18), lngPack.i18n ("Text~Others~Status"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_10, false, &SoundData.SNDHudSwitch));
72 statusShortcut = &statusButton->addClickShortcut (KeysList.keyStatus);
73 signalConnectionManager.connect (statusButton->toggled, [&]() { statusToggled(); });
74
75 ammoButton = addChild (std::make_unique<cCheckBox> (cPosition (57, 296 + 18), lngPack.i18n ("Text~Others~Ammo"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_11, false, &SoundData.SNDHudSwitch));
76 ammoShortcut = &ammoButton->addClickShortcut (KeysList.keyAmmo);
77 signalConnectionManager.connect (ammoButton->toggled, [&]() { ammoToggled(); });
78
79 gridButton = addChild (std::make_unique<cCheckBox> (cPosition (112, 296 + 18), lngPack.i18n ("Text~Others~Grid"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_12, false, &SoundData.SNDHudSwitch));
80 gridShortcut = &gridButton->addClickShortcut (KeysList.keyGrid);
81 signalConnectionManager.connect (gridButton->toggled, [&]() { gridToggled(); });
82
83 colorButton = addChild (std::make_unique<cCheckBox> (cPosition (2, 296 + 18 + 16), lngPack.i18n ("Text~Others~Color"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_20, false, &SoundData.SNDHudSwitch));
84 colorShortcut = &colorButton->addClickShortcut (KeysList.keyColors);
85 signalConnectionManager.connect (colorButton->toggled, [&]() { colorToggled(); });
86
87 rangeButton = addChild (std::make_unique<cCheckBox> (cPosition (57, 296 + 18 + 16), lngPack.i18n ("Text~Others~Range"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_21, false, &SoundData.SNDHudSwitch));
88 rangeShortcut = &rangeButton->addClickShortcut (KeysList.keyRange);
89 signalConnectionManager.connect (rangeButton->toggled, [&]() { rangeToggled(); });
90
91 fogButton = addChild (std::make_unique<cCheckBox> (cPosition (112, 296 + 18 + 16), lngPack.i18n ("Text~Others~Fog"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudIndex_21, false, &SoundData.SNDHudSwitch));
92 fogShortcut = &fogButton->addClickShortcut (KeysList.keyFog);
93 signalConnectionManager.connect (fogButton->toggled, [&]() { fogToggled(); });
94
95 lockButton = addChild (std::make_unique<cCheckBox> (cPosition (32, 227), eCheckBoxType::HudLock, false, &SoundData.SNDHudSwitch));
96 signalConnectionManager.connect (lockButton->toggled, [&]() { lockToggled(); });
97
98 miniMapAttackUnitsOnlyButton = addChild (std::make_unique<cCheckBox> (cPosition (136, 413), eCheckBoxType::HudTnt, false, &SoundData.SNDHudSwitch));
99 signalConnectionManager.connect (miniMapAttackUnitsOnlyButton->toggled, [&]() { miniMapAttackUnitsOnlyToggled(); });
100 miniMapZoomFactorButton = addChild (std::make_unique<cCheckBox> (cPosition (136, 387), eCheckBoxType::Hud2x, false, &SoundData.SNDHudSwitch));
101 signalConnectionManager.connect (miniMapZoomFactorButton->toggled, [&]() { miniMapZoomFactorToggled(); });
102
103 auto helpButton = addChild (std::make_unique<cPushButton> (cPosition (20, 250), ePushButtonType::HudHelp));
104 signalConnectionManager.connect (helpButton->clicked, [&]() { helpClicked(); });
105 auto centerButton = addChild (std::make_unique<cPushButton> (cPosition (4, 227), ePushButtonType::HudCenter));
106 signalConnectionManager.connect (centerButton->clicked, [&]() { centerClicked(); });
107
108 auto reportsButton = addChild (std::make_unique<cPushButton> (cPosition (101, 252), ePushButtonType::HudReport, lngPack.i18n ("Text~Others~Log")));
109 signalConnectionManager.connect (reportsButton->clicked, [&]() { reportsClicked(); });
110 chatButton = addChild (std::make_unique<cCheckBox> (cPosition (51, 252), lngPack.i18n ("Text~Others~Chat"), FONT_LATIN_SMALL_WHITE, eCheckBoxTextAnchor::Left, eCheckBoxType::HudChat));
111 signalConnectionManager.connect (chatButton->toggled, [&]() { chatToggled(); });
112
113 auto nextButton = addChild (std::make_unique<cPushButton> (cPosition (124, 227), ePushButtonType::HudNext, ">>"));
114 nextButton->addClickShortcut (KeysList.keyUnitNext);
115 signalConnectionManager.connect (nextButton->clicked, [&]() { nextClicked(); });
116 auto prevButton = addChild (std::make_unique<cPushButton> (cPosition (60, 227), ePushButtonType::HudPrev, "<<"));
117 prevButton->addClickShortcut (KeysList.keyUnitPrev);
118 signalConnectionManager.connect (prevButton->clicked, [&]() { prevClicked(); });
119 auto doneButton = addChild (std::make_unique<cPushButton> (cPosition (99, 227), ePushButtonType::HudDone, lngPack.i18n ("Text~Others~Proceed_4")));
120 doneButton->addClickShortcut (KeysList.keyUnitDone);
121 signalConnectionManager.connect (doneButton->clicked, [&]() { doneClicked(); });
122
123 coordsLabel = addChild (std::make_unique<cLabel> (cBox<cPosition> (cPosition (265, getEndPosition().y() - 18), cPosition (265 + 64, getEndPosition().y() - 18 + 10)), "", FONT_LATIN_NORMAL, eAlignmentType::CenterHorizontal));
124 unitNameLabel = addChild (std::make_unique<cLabel> (cBox<cPosition> (cPosition (343, getEndPosition().y() - 18), cPosition (343 + 212, getEndPosition().y() - 18 + 10)), "", FONT_LATIN_NORMAL, eAlignmentType::CenterHorizontal));
125 turnLabel = addChild (std::make_unique<cLabel> (cBox<cPosition> (cPosition (471, 7), cPosition (471 + 55, 7 + 10)), "", FONT_LATIN_NORMAL, eAlignmentType::CenterHorizontal));
126 turnTimeClockWidget = addChild (std::make_unique<cTurnTimeClockWidget> (cBox<cPosition> (cPosition (537, 7), cPosition (537 + 55, 7 + 10))));
127
128 zoomSlider = addChild (std::make_unique<cSlider> (cBox<cPosition> (cPosition (22, 275), cPosition (22 + 126, 275 + 15)), 0, 100, eOrientationType::Horizontal, eSliderHandleType::HudZoom, eSliderType::Invisible));
129 signalConnectionManager.connect (zoomSlider->valueChanged, [&]() { zoomChanged(); });
130 auto zoomPlusButton = addChild (std::make_unique<cPushButton> (cBox<cPosition> (cPosition (2, 275), cPosition (2 + 15, 275 + 15))));
131 signalConnectionManager.connect (zoomPlusButton->clicked, std::bind (&cHud::handleZoomPlusClicked, this));
132 auto zoomMinusButton = addChild (std::make_unique<cPushButton> (cBox<cPosition> (cPosition (152, 275), cPosition (152 + 15, 275 + 15))));
133 signalConnectionManager.connect (zoomMinusButton->clicked, std::bind (&cHud::handleZoomMinusClicked, this));
134
135 unitVideo = addChild (std::make_unique<cUnitVideoWidget> (cBox<cPosition> (cPosition (10, 29), cPosition (10 + 125, 29 + 125)), animationTimer));
136 signalConnectionManager.connect (unitVideo->clicked, [this]()
137 {
138 if (unitVideo->hasAnimation ())
139 {
140 unitVideo->toggle ();
141 }
142 });
143 auto playButton = addChild (std::make_unique<cPushButton> (cPosition (146, 123), ePushButtonType::HudPlay));
144 signalConnectionManager.connect (playButton->clicked, std::bind (&cUnitVideoWidget::start, unitVideo));
145 auto stopButton = addChild (std::make_unique<cPushButton> (cPosition (146, 143), ePushButtonType::HudStop));
146 signalConnectionManager.connect (stopButton->clicked, std::bind (&cUnitVideoWidget::stop, unitVideo));
147
148 unitDetails = addChild (std::make_unique<cUnitDetailsHud> (cBox<cPosition> (cPosition (8, 171), cPosition (8 + 155, 171 + 48))));
149
150 unitRenameWidget = addChild (std::make_unique<cUnitRenameWidget> (cPosition (12, 30), 123));
151 signalConnectionManager.connect (unitRenameWidget->unitRenameTriggered, [&]()
152 {
153 if (unitRenameWidget->getUnit())
154 {
155 triggeredRenameUnit (*unitRenameWidget->getUnit(), unitRenameWidget->getUnitName());
156 }
157 });
158 }
159
160 //------------------------------------------------------------------------------
setPlayer(std::shared_ptr<const cPlayer> player_)161 void cHud::setPlayer (std::shared_ptr<const cPlayer> player_)
162 {
163 player = std::move (player_);
164 unitRenameWidget->setPlayer (player.get());
165 unitDetails->setPlayer (player.get());
166 }
167
168 //------------------------------------------------------------------------------
setTurnClock(std::shared_ptr<const cTurnClock> turnClock_)169 void cHud::setTurnClock (std::shared_ptr<const cTurnClock> turnClock_)
170 {
171 turnClock = std::move (turnClock_);
172
173 turnClockSignalConnectionManager.disconnectAll();
174 if (turnClock != nullptr)
175 {
176 turnLabel->setText (iToStr (turnClock->getTurn()));
177 turnClockSignalConnectionManager.connect (turnClock->turnChanged, [&]()
178 {
179 turnLabel->setText (iToStr (turnClock->getTurn()));
180 });
181 }
182 }
183
184 //------------------------------------------------------------------------------
setTurnTimeClock(std::shared_ptr<const cTurnTimeClock> turnTimeClock)185 void cHud::setTurnTimeClock (std::shared_ptr<const cTurnTimeClock> turnTimeClock)
186 {
187 turnTimeClockWidget->setTurnTimeClock (std::move (turnTimeClock));
188 }
189
190 //------------------------------------------------------------------------------
setGameSettings(std::shared_ptr<const cGameSettings> gameSettings)191 void cHud::setGameSettings (std::shared_ptr<const cGameSettings> gameSettings)
192 {
193 unitDetails->setGameSettings (std::move (gameSettings));
194 }
195
196 //------------------------------------------------------------------------------
isAt(const cPosition & position) const197 bool cHud::isAt (const cPosition& position) const
198 {
199 cBox<cPosition> hole (cPosition (panelLeftWidth, panelTopHeight), getEndPosition() - cPosition (panelRightWidth, panelBottomHeight));
200
201 if (hole.withinOrTouches (position))
202 {
203 // end button reaches into the hole
204 return endButton->isAt (position);
205 }
206 return true;
207 }
208
209 //------------------------------------------------------------------------------
draw(SDL_Surface & destination,const cBox<cPosition> & clipRect)210 void cHud::draw (SDL_Surface& destination, const cBox<cPosition>& clipRect)
211 {
212 if (surface != nullptr)
213 {
214 auto position = getArea().toSdlRect();
215 //SDL_Rect rect = {0, getEndPosition ().y () - panelBottomHeight * 2, getSize ().x (), panelBottomHeight * 2};
216 SDL_BlitSurface (surface.get(), nullptr, &destination, &position);
217 }
218
219 cWidget::draw (destination, clipRect);
220 }
221
222 //------------------------------------------------------------------------------
generateSurface()223 AutoSurface cHud::generateSurface()
224 {
225 AutoSurface surface (SDL_CreateRGBSurface (0, Video.getResolutionX(), Video.getResolutionY(), Video.getColDepth(), 0, 0, 0, 0));
226
227 SDL_FillRect (surface.get(), nullptr, 0x00FF00FF);
228 SDL_SetColorKey (surface.get(), SDL_TRUE, 0x00FF00FF);
229
230 const std::string gfxPath = cSettings::getInstance().getGfxPath() + PATH_DELIMITER;
231 {
232 AutoSurface tmpSurface (LoadPCX (gfxPath + "hud_left.pcx"));
233 if (tmpSurface != nullptr)
234 {
235 SDL_BlitSurface (tmpSurface.get(), nullptr, surface.get(), nullptr);
236 }
237 }
238
239 SDL_Rect dest;
240 {
241 AutoSurface tmpSurface (LoadPCX (gfxPath + "hud_top.pcx"));
242 if (tmpSurface != nullptr)
243 {
244 SDL_Rect src = {0, 0, Uint16 (tmpSurface->w), Uint16 (tmpSurface->h)};
245 dest.x = panelLeftWidth;
246 dest.y = 0;
247 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
248 src.x = 1275;
249 src.w = 18;
250 src.h = panelTopHeight;
251 dest.x = surface->w - panelTopHeight;
252 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
253 }
254 }
255
256 {
257 AutoSurface tmpSurface (LoadPCX (gfxPath + "hud_right.pcx"));
258 if (tmpSurface != nullptr)
259 {
260 SDL_Rect src = {0, 0, Uint16 (tmpSurface->w), Uint16 (tmpSurface->h)};
261 dest.x = surface->w - panelRightWidth;
262 dest.y = panelTopHeight;
263 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
264 }
265 }
266
267 {
268 AutoSurface tmpSurface (LoadPCX (gfxPath + "hud_bottom.pcx"));
269 if (tmpSurface != nullptr)
270 {
271 SDL_Rect src = {0, 0, Uint16 (tmpSurface->w), Uint16 (tmpSurface->h)};
272 dest.x = panelLeftWidth;
273 dest.y = surface->h - 24;
274 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
275 src.x = 1275;
276 src.w = 23;
277 src.h = 24;
278 dest.x = surface->w - 23;
279 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
280 src.x = 1299;
281 src.w = 16;
282 src.h = 22;
283 dest.x = panelLeftWidth - 16;
284 dest.y = surface->h - 22;
285 SDL_BlitSurface (tmpSurface.get(), &src, surface.get(), &dest);
286 }
287 }
288
289 if (Video.getResolutionY() > 480)
290 {
291 AutoSurface tmpSurface (LoadPCX (gfxPath + "logo.pcx"));
292 if (tmpSurface != nullptr)
293 {
294 dest.x = 9;
295 dest.y = Video.getResolutionY() - panelTotalHeight - 15;
296 SDL_BlitSurface (tmpSurface.get(), nullptr, surface.get(), &dest);
297 }
298 }
299 return surface;
300 }
301
302 //------------------------------------------------------------------------------
setMinimalZoomFactor(float zoomFactor)303 void cHud::setMinimalZoomFactor (float zoomFactor)
304 {
305 zoomSlider->setMaxValue ((int)std::ceil (100. - 100. * zoomFactor));
306 }
307
308 //------------------------------------------------------------------------------
setZoomFactor(float zoomFactor)309 void cHud::setZoomFactor (float zoomFactor)
310 {
311 zoomSlider->setValue (static_cast<int> (100. - zoomFactor * 100));
312 }
313
314 //------------------------------------------------------------------------------
getZoomFactor() const315 float cHud::getZoomFactor() const
316 {
317 return 1.f - (float)zoomSlider->getValue() / 100;
318 }
319
320 //------------------------------------------------------------------------------
increaseZoomFactor(double percent)321 void cHud::increaseZoomFactor (double percent)
322 {
323 zoomSlider->increase ((int) ((zoomSlider->getMaxValue() - zoomSlider->getMinValue()) * percent));
324 }
325
326 //------------------------------------------------------------------------------
decreaseZoomFactor(double percent)327 void cHud::decreaseZoomFactor (double percent)
328 {
329 zoomSlider->decrease ((int) ((zoomSlider->getMaxValue() - zoomSlider->getMinValue()) * percent));
330 }
331
332 //------------------------------------------------------------------------------
lockEndButton()333 void cHud::lockEndButton()
334 {
335 endButton->lock();
336 }
337
338 //------------------------------------------------------------------------------
unlockEndButton()339 void cHud::unlockEndButton()
340 {
341 endButton->unlock();
342 }
343
344 //------------------------------------------------------------------------------
setSurveyActive(bool value)345 void cHud::setSurveyActive (bool value)
346 {
347 surveyButton->setChecked (value);
348 }
349
350 //------------------------------------------------------------------------------
getSurveyActive() const351 bool cHud::getSurveyActive() const
352 {
353 return surveyButton->isChecked();
354 }
355
356 //------------------------------------------------------------------------------
setHitsActive(bool value)357 void cHud::setHitsActive (bool value)
358 {
359 hitsButton->setChecked (value);
360 }
361
362 //------------------------------------------------------------------------------
getHitsActive() const363 bool cHud::getHitsActive() const
364 {
365 return hitsButton->isChecked();
366 }
367
368 //------------------------------------------------------------------------------
setScanActive(bool value)369 void cHud::setScanActive (bool value)
370 {
371 scanButton->setChecked (value);
372 }
373
374 //------------------------------------------------------------------------------
getScanActive() const375 bool cHud::getScanActive() const
376 {
377 return scanButton->isChecked();
378 }
379
380 //------------------------------------------------------------------------------
setStatusActive(bool value)381 void cHud::setStatusActive (bool value)
382 {
383 statusButton->setChecked (value);
384 }
385
386 //------------------------------------------------------------------------------
getStatusActive() const387 bool cHud::getStatusActive() const
388 {
389 return statusButton->isChecked();
390 }
391
392 //------------------------------------------------------------------------------
setAmmoActive(bool value)393 void cHud::setAmmoActive (bool value)
394 {
395 ammoButton->setChecked (value);
396 }
397
398 //------------------------------------------------------------------------------
getAmmoActive() const399 bool cHud::getAmmoActive() const
400 {
401 return ammoButton->isChecked();
402 }
403
404 //------------------------------------------------------------------------------
setGridActive(bool value)405 void cHud::setGridActive (bool value)
406 {
407 gridButton->setChecked (value);
408 }
409
410 //------------------------------------------------------------------------------
getGridActive() const411 bool cHud::getGridActive() const
412 {
413 return gridButton->isChecked();
414 }
415
416 //------------------------------------------------------------------------------
setColorActive(bool value)417 void cHud::setColorActive (bool value)
418 {
419 colorButton->setChecked (value);
420 }
421
422 //------------------------------------------------------------------------------
getColorActive() const423 bool cHud::getColorActive() const
424 {
425 return colorButton->isChecked();
426 }
427
428 //------------------------------------------------------------------------------
setRangeActive(bool value)429 void cHud::setRangeActive (bool value)
430 {
431 rangeButton->setChecked (value);
432 }
433
434 //------------------------------------------------------------------------------
getRangeActive() const435 bool cHud::getRangeActive() const
436 {
437 return rangeButton->isChecked();
438 }
439
440 //------------------------------------------------------------------------------
setFogActive(bool value)441 void cHud::setFogActive (bool value)
442 {
443 fogButton->setChecked (value);
444 }
445
446 //------------------------------------------------------------------------------
getFogActive() const447 bool cHud::getFogActive() const
448 {
449 return fogButton->isChecked();
450 }
451
452 //------------------------------------------------------------------------------
setLockActive(bool value)453 void cHud::setLockActive (bool value)
454 {
455 lockButton->setChecked (value);
456 }
457
458 //------------------------------------------------------------------------------
getLockActive() const459 bool cHud::getLockActive() const
460 {
461 return lockButton->isChecked();
462 }
463
464 //------------------------------------------------------------------------------
setChatActive(bool value)465 void cHud::setChatActive (bool value)
466 {
467 chatButton->setChecked (value);
468 }
469
470 //------------------------------------------------------------------------------
getChatActive() const471 bool cHud::getChatActive() const
472 {
473 return chatButton->isChecked();
474 }
475
476 //------------------------------------------------------------------------------
setMiniMapZoomFactorActive(bool value)477 void cHud::setMiniMapZoomFactorActive (bool value)
478 {
479 miniMapZoomFactorButton->setChecked (value);
480 }
481
482 //------------------------------------------------------------------------------
getMiniMapZoomFactorActive() const483 bool cHud::getMiniMapZoomFactorActive() const
484 {
485 return miniMapZoomFactorButton->isChecked();
486 }
487
488 //------------------------------------------------------------------------------
setMiniMapAttackUnitsOnly(bool value)489 void cHud::setMiniMapAttackUnitsOnly (bool value)
490 {
491 miniMapAttackUnitsOnlyButton->setChecked (value);
492 }
493
494 //------------------------------------------------------------------------------
getMiniMapAttackUnitsOnly() const495 bool cHud::getMiniMapAttackUnitsOnly() const
496 {
497 return miniMapAttackUnitsOnlyButton->isChecked();
498 }
499
500 //------------------------------------------------------------------------------
setCoordinatesText(const std::string & text)501 void cHud::setCoordinatesText (const std::string& text)
502 {
503 coordsLabel->setText (text);
504 }
505
506 //------------------------------------------------------------------------------
setUnitNameText(const std::string & text)507 void cHud::setUnitNameText (const std::string& text)
508 {
509 unitNameLabel->setText (text);
510 }
511
512 //------------------------------------------------------------------------------
startUnitVideo()513 void cHud::startUnitVideo()
514 {
515 unitVideo->start();
516 }
517
518 //------------------------------------------------------------------------------
stopUnitVideo()519 void cHud::stopUnitVideo()
520 {
521 unitVideo->stop();
522 }
523
524 //------------------------------------------------------------------------------
isUnitVideoPlaying()525 bool cHud::isUnitVideoPlaying()
526 {
527 return unitVideo->isPlaying();
528 }
529
530 //------------------------------------------------------------------------------
resizeToResolution()531 void cHud::resizeToResolution()
532 {
533 surface = generateSurface();
534 resize (cPosition (surface->w, surface->h));
535
536 coordsLabel->moveTo (cPosition (265, getEndPosition().y() - 18));
537 unitNameLabel->moveTo (cPosition (343, getEndPosition().y() - 18));
538 }
539
540 //------------------------------------------------------------------------------
activateShortcuts()541 void cHud::activateShortcuts()
542 {
543 surveyShortcut->activate();
544 hitsShortcut->activate();
545 scanShortcut->activate();
546 statusShortcut->activate();
547 ammoShortcut->activate();
548 gridShortcut->activate();
549 colorShortcut->activate();
550 rangeShortcut->activate();
551 fogShortcut->activate();
552 }
553
554 //------------------------------------------------------------------------------
deactivateShortcuts()555 void cHud::deactivateShortcuts()
556 {
557 surveyShortcut->deactivate();
558 hitsShortcut->deactivate();
559 scanShortcut->deactivate();
560 statusShortcut->deactivate();
561 ammoShortcut->deactivate();
562 gridShortcut->deactivate();
563 colorShortcut->deactivate();
564 rangeShortcut->deactivate();
565 fogShortcut->deactivate();
566 }
567
568 //------------------------------------------------------------------------------
handleZoomPlusClicked()569 void cHud::handleZoomPlusClicked()
570 {
571 zoomSlider->decrease ((zoomSlider->getMaxValue() - zoomSlider->getMinValue()) / 6);
572 }
573
574 //------------------------------------------------------------------------------
handleZoomMinusClicked()575 void cHud::handleZoomMinusClicked()
576 {
577 zoomSlider->increase ((zoomSlider->getMaxValue() - zoomSlider->getMinValue()) / 6);
578 }
579
580 //------------------------------------------------------------------------------
setActiveUnit(const cUnit * unit)581 void cHud::setActiveUnit (const cUnit* unit)
582 {
583 unitRenameWidget->setUnit (unit);
584 unitVideo->setUnit (unit);
585 unitDetails->setUnit (unit);
586 }
587