Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/usability/src/orxonox/controllers/NewHumanController.cc @ 12076

Last change on this file since 12076 was 7859, checked in by landauf, 14 years ago

implemented feature to reset the mouse cursor to the center
used in NewHumanController to set cursor to the center of the screen every time the ControllableEntity is changed
avoids turning of the spaceship right after spawn, if the player looked around in spectator mode

needs testing with derived mouse input (joysticks should be unchanged).
input system experts may have a look at this. ;)

  • Property svn:eol-style set to native
File size: 23.9 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Michael Wirth
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "NewHumanController.h"
30
31#include <cmath>
32#include <OgreRay.h>
33#include <OgreSceneQuery.h>
34#include <OgreCamera.h>
35#include <OgreSceneManager.h>
36#include <bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h>
37
38#include "core/CoreIncludes.h"
39#include "core/command/ConsoleCommand.h"
40#include "core/input/KeyBinder.h"
41#include "core/input/KeyBinderManager.h"
42#include "worldentities/ControllableEntity.h"
43#include "worldentities/pawns/Pawn.h"
44#include "infos/PlayerInfo.h"
45#include "overlays/OrxonoxOverlay.h"
46#include "graphics/Camera.h"
47#include "sound/SoundManager.h"
48#include "tools/BulletConversions.h"
49#include "Scene.h"
50
51namespace orxonox
52{
53    SetConsoleCommand("NewHumanController", "changeMode", &NewHumanController::changeMode).keybindMode(KeybindMode::OnPress);
54    SetConsoleCommand("NewHumanController", "accelerate", &NewHumanController::accelerate).keybindMode(KeybindMode::OnPress);
55    SetConsoleCommand("NewHumanController", "decelerate", &NewHumanController::decelerate).keybindMode(KeybindMode::OnPress);
56    SetConsoleCommand("NewHumanController", "unfire",     &NewHumanController::unfire    ).keybindMode(KeybindMode::OnRelease).addShortcut();
57
58    CreateUnloadableFactory(NewHumanController);
59
60    NewHumanController* NewHumanController::localController_s = 0;
61
62    NewHumanController::NewHumanController(BaseObject* creator)
63        : HumanController(creator)
64        , crossHairOverlay_(NULL)
65        , centerOverlay_(NULL)
66        , damageOverlayTop_(NULL)
67        , damageOverlayRight_(NULL)
68        , damageOverlayBottom_(NULL)
69        , damageOverlayLeft_(NULL)
70        , damageOverlayTT_(0)
71        , arrowsOverlay1_(NULL)
72        , arrowsOverlay2_(NULL)
73        , arrowsOverlay3_(NULL)
74        , arrowsOverlay4_(NULL)
75    {
76        RegisterObject(NewHumanController);
77
78        overlaySize_ = 0.08f;
79        arrowsSize_ = 0.4f;
80
81        damageOverlayTime_ = 0.6f;
82
83        controlMode_ = 0;
84        acceleration_ = 0;
85        accelerating_ = false;
86        firemode_ = -1;
87
88        showArrows_ = true;
89        showOverlays_ = false;
90        showDamageOverlay_ = true;
91
92        //currentPitch_ = 1;
93        //currentYaw_ = 1;
94
95        if (GameMode::showsGraphics())
96        {
97            crossHairOverlay_ = new OrxonoxOverlay(this);
98            crossHairOverlay_->setBackgroundMaterial("Orxonox/Crosshair3");
99            crossHairOverlay_->setSize(Vector2(overlaySize_, overlaySize_));
100            crossHairOverlay_->hide();
101            //crossHairOverlay_->setAspectCorrection(true); not working
102
103            centerOverlay_ = new OrxonoxOverlay(this);
104            centerOverlay_->setBackgroundMaterial("Orxonox/CenterOverlay");
105            centerOverlay_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
106            centerOverlay_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
107            centerOverlay_->hide();
108
109            if (showDamageOverlay_)
110            {
111                damageOverlayTop_ = new OrxonoxOverlay(this);
112                damageOverlayTop_->setBackgroundMaterial("Orxonox/DamageOverlayTop");
113                damageOverlayTop_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
114                damageOverlayTop_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
115                damageOverlayTop_->hide();
116
117                damageOverlayRight_ = new OrxonoxOverlay(this);
118                damageOverlayRight_->setBackgroundMaterial("Orxonox/DamageOverlayRight");
119                damageOverlayRight_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
120                damageOverlayRight_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
121                damageOverlayRight_->hide();
122
123                damageOverlayBottom_ = new OrxonoxOverlay(this);
124                damageOverlayBottom_->setBackgroundMaterial("Orxonox/DamageOverlayBottom");
125                damageOverlayBottom_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
126                damageOverlayBottom_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
127                damageOverlayBottom_->hide();
128
129                damageOverlayLeft_ = new OrxonoxOverlay(this);
130                damageOverlayLeft_->setBackgroundMaterial("Orxonox/DamageOverlayLeft");
131                damageOverlayLeft_->setSize(Vector2(overlaySize_ * 2.5f, overlaySize_ * 2.5f));
132                damageOverlayLeft_->setPosition(Vector2(0.5f - overlaySize_*2.5f/2.0f, 0.5f - overlaySize_*2.5f/2.0f));
133                damageOverlayLeft_->hide();
134            }
135
136            if (showArrows_)
137            {
138                arrowsOverlay1_ = new OrxonoxOverlay(this);
139                arrowsOverlay1_->setBackgroundMaterial("Orxonox/DirectionArrows1");
140                arrowsOverlay1_->setSize(Vector2(0.02727f, 0.36f * arrowsSize_));
141                arrowsOverlay1_->setPickPoint(Vector2(0.5f, 0.5f));
142                arrowsOverlay1_->setPosition(Vector2(0.5f, 0.5f));
143                arrowsOverlay1_->hide();
144
145                arrowsOverlay2_ = new OrxonoxOverlay(this);
146                arrowsOverlay2_->setBackgroundMaterial("Orxonox/DirectionArrows2");
147                arrowsOverlay2_->setSize(Vector2(0.02727f, 0.59f * arrowsSize_));
148                arrowsOverlay2_->setPickPoint(Vector2(0.5f, 0.5f));
149                arrowsOverlay2_->setPosition(Vector2(0.5f, 0.5f));
150                arrowsOverlay2_->hide();
151
152                arrowsOverlay3_ = new OrxonoxOverlay(this);
153                arrowsOverlay3_->setBackgroundMaterial("Orxonox/DirectionArrows3");
154                arrowsOverlay3_->setSize(Vector2(0.02727f, 0.77f * arrowsSize_));
155                arrowsOverlay3_->setPickPoint(Vector2(0.5f, 0.5f));
156                arrowsOverlay3_->setPosition(Vector2(0.5f, 0.5f));
157                arrowsOverlay3_->hide();
158
159                arrowsOverlay4_ = new OrxonoxOverlay(this);
160                arrowsOverlay4_->setBackgroundMaterial("Orxonox/DirectionArrows4");
161                arrowsOverlay4_->setSize(Vector2(0.02727f, arrowsSize_));
162                arrowsOverlay4_->setPickPoint(Vector2(0.5f, 0.5f));
163                arrowsOverlay4_->setPosition(Vector2(0.5f, 0.5f));
164                arrowsOverlay4_->hide();
165            }
166        }
167
168        // HACK: Define which objects are targetable when considering the creator of an orxonox::Model
169        this->targetMask_.exclude(ClassByString("BaseObject"));
170        this->targetMask_.include(ClassByString("WorldEntity"));
171        this->targetMask_.exclude(ClassByString("Projectile"));
172
173        NewHumanController::localController_s = this;
174
175        controlPaused_ = false;
176
177        //HumanController::localController_s->getControllableEntity()->getCamera()->setDrag(true);
178    }
179
180    NewHumanController::~NewHumanController()
181    {
182        if (this->isInitialized())
183        {
184            if (this->crossHairOverlay_)
185                this->crossHairOverlay_->destroy();
186            if (this->centerOverlay_)
187                this->centerOverlay_->destroy();
188
189            if (this->arrowsOverlay1_)
190                this->arrowsOverlay1_->destroy();
191            if (this->arrowsOverlay2_)
192                this->arrowsOverlay2_->destroy();
193            if (this->arrowsOverlay3_)
194                this->arrowsOverlay3_->destroy();
195            if (this->arrowsOverlay4_)
196                this->arrowsOverlay4_->destroy();
197            if (this->damageOverlayTop_)
198                this->damageOverlayTop_->destroy();
199            if (this->damageOverlayLeft_)
200                this->damageOverlayLeft_->destroy();
201            if (this->damageOverlayRight_)
202                this->damageOverlayRight_->destroy();
203            if (this->damageOverlayBottom_)
204                this->damageOverlayBottom_->destroy();
205        }
206    }
207
208    void NewHumanController::tick(float dt)
209    {
210        if (GameMode::showsGraphics())
211        {
212
213            if (this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
214            {
215                this->updateTarget();
216
217                if (!controlPaused_ )
218                {
219                    if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
220                        this->showOverlays();
221                    else if (this->getControllableEntity() &&  this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
222                    {
223                        this->showOverlays();
224                        this->hideArrows();
225                    }
226
227                    this->crossHairOverlay_->setPosition(Vector2(static_cast<float>(this->currentYaw_)/2*-1+.5f-overlaySize_/2, static_cast<float>(this->currentPitch_)/2*-1+.5f-overlaySize_/2));
228
229                    if (this->controlMode_ == 0 || (this->controlMode_ == 1 && this->firemode_ == 1))
230                    {
231                        if (this->showOverlays_ && this->showArrows_)
232                            alignArrows();
233                    }
234                    else
235                        hideArrows();
236
237                    if (this->showDamageOverlay_ && (this->damageOverlayTT_ > 0 || this->damageOverlayTR_ > 0 || this->damageOverlayTB_ > 0 || this->damageOverlayTL_ > 0))
238                    {
239                        this->damageOverlayTT_ -= dt;
240                        this->damageOverlayTR_ -= dt;
241                        this->damageOverlayTB_ -= dt;
242                        this->damageOverlayTL_ -= dt;
243                        if (this->damageOverlayTT_ <= 0)
244                            this->damageOverlayTop_->hide();
245                        if (this->damageOverlayTR_ <= 0)
246                            this->damageOverlayRight_->hide();
247                        if (this->damageOverlayTB_ <= 0)
248                            this->damageOverlayBottom_->hide();
249                        if (this->damageOverlayTL_ <= 0)
250                            this->damageOverlayLeft_->hide();
251                    }
252                }
253            }
254            else
255                this->hideOverlays();
256
257            if (this->acceleration_ > 0)
258            {
259                if (this->accelerating_)
260                    HumanController::moveFrontBack(Vector2(1, 0));
261                else
262                    HumanController::moveFrontBack(Vector2(this->acceleration_, 0));
263                this->accelerating_ = false;
264                //HumanController::moveFrontBack(Vector2(clamp(this->acceleration_ + this->currentAcceleration_, 0.0f, 1.0f), 0));
265            }
266        }
267
268        // Reset pitch and yaw rates
269        // TODO: Reactivate this to fix the game pad problem with 0 input
270        //this->currentPitch_ = 0;
271        //this->currentYaw_ = 0;
272
273        HumanController::tick(dt);
274    }
275
276    void NewHumanController::doFire(unsigned int firemode)
277    {
278        if (!this->controllableEntity_)
279            return;
280
281        this->firemode_ = firemode;
282
283        if (firemode == 1 && this->controlMode_ == 1)
284        {
285            //unlocked steering, steer on right mouse click
286            HumanController::yaw(Vector2(this->currentYaw_, 0));
287            HumanController::pitch(Vector2(this->currentPitch_, 0));
288        }
289        else
290            HumanController::localController_s->getControllableEntity()->fire(firemode);
291
292    }
293
294    void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
295    {
296        if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook())
297        {
298            Vector3 posA;
299            if (originator)
300                posA = originator->getWorldPosition();
301            else
302                posA = multi_cast<Vector3>(contactpoint.getPositionWorldOnA());
303            //Vector3 posB = multi_cast<Vector3>(contactpoint.getPositionWorldOnB());
304            //posA and posB are almost identical
305
306            Vector3 relativeHit = this->getControllableEntity()->getWorldOrientation().UnitInverse() * (this->getControllableEntity()->getWorldPosition() - posA);
307
308            //back is z positive
309            //x is left positive
310            //y is down positive
311            relativeHit.normalise();
312
313            float threshold = 0.3f;
314            if (relativeHit.x > threshold) // Left
315            {
316                this->damageOverlayLeft_->show();
317                this->damageOverlayTL_ = this->damageOverlayTime_;
318                //this->damageOverlayLeft_->setBackgroundAlpha(0.3);
319            }
320            if (relativeHit.x < -threshold) //Right
321            {
322                this->damageOverlayRight_->show();
323                this->damageOverlayTR_ = this->damageOverlayTime_;
324                //this->damageOverlayRight_->setBackgroundAlpha(0.3);
325            }
326            if (relativeHit.y > threshold) //Top
327            {
328                this->damageOverlayBottom_->show();
329                this->damageOverlayTB_ = this->damageOverlayTime_;
330                //this->damageOverlayTop_->setBackgroundAlpha(0.3);
331            }
332            if (relativeHit.y < -threshold) //Bottom
333            {
334                this->damageOverlayTop_->show();
335                this->damageOverlayTT_ = this->damageOverlayTime_;
336                //this->damageOverlayBottom_->setBackgroundAlpha(0.3);
337            }
338        }
339    }
340
341    void NewHumanController::unfire()
342    {
343        if (NewHumanController::localController_s)
344            NewHumanController::localController_s->doUnfire();
345    }
346
347    void NewHumanController::doUnfire()
348    {
349        this->firemode_ = -1;
350        hideArrows();
351    }
352
353    void NewHumanController::centerCursor()
354    {
355        this->currentYaw_ = 0;
356        this->currentPitch_ = 0;
357
358        KeyBinderManager::getInstance().getCurrent()->resetMouseAxes();
359    }
360
361    void NewHumanController::updateTarget()
362    {
363        Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
364
365        Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f);
366
367        rsq->setRay(mouseRay);
368        rsq->setSortByDistance(true);
369
370        /*
371        Distance of objects:
372        ignore everything under 200 maybe even take 1000 as min distance to shoot at
373
374        shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
375        they vanish only after a distance of 10'000
376        */
377
378
379        Ogre::RaySceneQueryResult& result = rsq->execute();
380        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
381        WorldEntity* myWe = static_cast<WorldEntity*>(this->getControllableEntity());
382
383        Ogre::RaySceneQueryResult::iterator itr;
384        for (itr = result.begin(); itr != result.end(); ++itr)
385        {
386//             CCOUT(0) << "testing object as target" << endl;
387            if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 200)
388            {
389                // Try to cast the user pointer
390                WorldEntity* wePtr;
391                try
392                {
393                    wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
394                }
395                catch (...)
396                {
397                    continue;
398                }
399
400                // make sure we don't shoot ourselves
401                if( wePtr==myWe )
402                    continue;
403
404                if (wePtr)
405                {
406                    // go through all parents of object and look whether they are sightable or not
407                    bool isSightable = false;
408                    WorldEntity* parent = wePtr->getParent();
409                    while (parent)
410                    {
411                        if (this->targetMask_.isExcluded(parent->getIdentifier()) || parent==myWe)
412                        {
413                            parent = parent->getParent();
414                            continue;
415                        }
416                        else
417                        {
418                            isSightable = true;
419                            break;
420                        }
421                    }
422                    if (!isSightable)
423                        continue;
424                }
425
426                if (this->getControllableEntity() && this->getControllableEntity()->getTarget() != wePtr)
427                    this->getControllableEntity()->setTarget(wePtr);
428
429                if (pawn)
430                    pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance );
431
432                //itr->movable->getParentSceneNode()->showBoundingBox(true);
433                //return mouseRay.getOrigin() + mouseRay.getDirection() * itr->distance; //or itr->movable->getParentSceneNode()->_getDerivedPosition()
434                return;
435            }
436        }
437
438        if (pawn)
439            pawn->setAimPosition( mouseRay.getOrigin() + mouseRay.getDirection() * 1200 );
440
441        if( this->getControllableEntity() && this->getControllableEntity()->getTarget() != 0 )
442            this->getControllableEntity()->setTarget( 0 );
443
444        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getWorldOrientation() * Vector3::NEGATIVE_UNIT_Z * 2000);
445        //return this->controllableEntity_->getWorldPosition() + (this->controllableEntity_->getCamera()->getOgreCamera()->getOrientation() * Vector3::NEGATIVE_UNIT_Z);
446    }
447
448    void NewHumanController::frontback(const Vector2& value)
449    {
450        this->accelerating_ = true;
451
452        //if (this->acceleration_ == 0)
453        HumanController::frontback(value);
454    }
455
456    void NewHumanController::yaw(const Vector2& value)
457    {
458        //SUPER(NewHumanController, yaw, value);
459        if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
460            HumanController::yaw(value);
461
462        if (this->getControllableEntity() && !this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
463            this->currentYaw_ = value.x;
464    }
465
466    void NewHumanController::pitch(const Vector2& value)
467    {
468        //SUPER(NewHumanController, pitch, value);
469        if (this->controlMode_ == 0 || (this->controllableEntity_ && this->controllableEntity_->isInMouseLook()))
470            HumanController::pitch(value);
471
472        if (this->getControllableEntity() && !this->getControllableEntity()->isExactlyA(ClassByString("FpsPlayer")))
473            this->currentPitch_ = value.x;
474    }
475
476    void NewHumanController::changeMode()
477    {
478        if (NewHumanController::localController_s)
479        {
480            if (NewHumanController::localController_s->controlMode_ == 0)
481            {
482                NewHumanController::localController_s->controlMode_ = 1;
483                NewHumanController::localController_s->hideArrows();
484            }
485            else
486                NewHumanController::localController_s->controlMode_ = 0;
487        }
488    }
489
490    void NewHumanController::changedControllableEntity()
491    {
492        this->controlMode_ = 0;
493        this->centerCursor();
494        if (this->getControllableEntity() && (this->getControllableEntity()->isExactlyA(ClassByString("SpaceShip")) || this->getControllableEntity()->isExactlyA(ClassByString("Rocket"))))
495        {
496            this->showOverlays_ = true;
497            if (!this->controlPaused_)
498            {
499                this->showOverlays();
500                this->alignArrows();
501            }
502        }
503        else
504        {
505            this->showOverlays_ = false;
506            this->hideOverlays();
507        }
508    }
509
510    void NewHumanController::accelerate()
511    {
512        if (NewHumanController::localController_s)
513            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ + 0.2f, 0.00f, 1.0f);
514    }
515
516    void NewHumanController::decelerate()
517    {
518        if (NewHumanController::localController_s)
519            NewHumanController::localController_s->acceleration_ = clamp(NewHumanController::localController_s->acceleration_ - 0.1f, 0.0f, 1.0f);
520    }
521
522    void NewHumanController::doResumeControl()
523    {
524        this->controlPaused_ = false;
525        if (this->showOverlays_)
526            this->showOverlays();
527    }
528
529    void NewHumanController::doPauseControl()
530    {
531        this->controlPaused_ = true;
532        this->hideOverlays();
533    }
534
535    void NewHumanController::alignArrows()
536    {
537        if (showArrows_)
538        {
539            hideArrows();
540
541            float distance = sqrt(pow(static_cast<float>(this->currentYaw_)/2*-1,2) + pow(static_cast<float>(this->currentPitch_)/2*-1,2));
542
543            if (distance > 0.04f && distance <= 0.59f * arrowsSize_ / 2.0f )
544            {
545                this->arrowsOverlay1_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
546                this->arrowsOverlay1_->show();
547            }
548            else if (distance > 0.59f * arrowsSize_ / 2.0f && distance <= 0.77f * arrowsSize_ / 2.0f )
549            {
550                this->arrowsOverlay2_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
551                this->arrowsOverlay2_->show();
552            }
553            else if (distance > 0.77f * arrowsSize_ / 2.0f && distance <= arrowsSize_ / 2.0f)
554            {
555                this->arrowsOverlay3_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
556                this->arrowsOverlay3_->show();
557            }
558            else if (distance > arrowsSize_ / 2.0f)
559            {
560                this->arrowsOverlay4_->setRotation(Degree(-90 + -1.0f * atan2(static_cast<float>(this->currentPitch_)/2*-1, static_cast<float>(this->currentYaw_)/2*-1) / (2.0f * math::pi) * 360.0f));
561                this->arrowsOverlay4_->show();
562            }
563        }
564    }
565
566    void NewHumanController::showOverlays()
567    {
568        if (!GameMode::showsGraphics())
569            return;
570        this->crossHairOverlay_->show();
571        this->centerOverlay_->show();
572
573        if (showArrows_)
574        {
575            this->arrowsOverlay1_->show();
576            this->arrowsOverlay2_->show();
577            this->arrowsOverlay3_->show();
578            this->arrowsOverlay4_->show();
579        }
580    }
581
582    void NewHumanController::hideOverlays()
583    {
584        if (!GameMode::showsGraphics())
585            return;
586        this->crossHairOverlay_->hide();
587        this->centerOverlay_->hide();
588
589        if (showDamageOverlay_)
590        {
591            this->damageOverlayTop_->hide();
592            this->damageOverlayRight_->hide();
593            this->damageOverlayBottom_->hide();
594            this->damageOverlayLeft_->hide();
595        }
596
597        this->hideArrows();
598    }
599
600    void NewHumanController::hideArrows()
601    {
602        if(!GameMode::showsGraphics())
603            return;
604        if (showArrows_)
605        {
606            this->arrowsOverlay1_->hide();
607            this->arrowsOverlay2_->hide();
608            this->arrowsOverlay3_->hide();
609            this->arrowsOverlay4_->hide();
610        }
611    }
612
613
614
615
616
617}
Note: See TracBrowser for help on using the repository browser.