Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 27, 2009, 7:28:09 PM (15 years ago)
Author:
rgrieder
Message:

Moved Radar Management from GSLevel to Scene.

Location:
code/branches/core5/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/modules/gamestates/GSLevel.cc

    r5806 r5813  
    4848
    4949#include "tools/interfaces/Tickable.h"
    50 #include "Radar.h"
    5150#include "CameraManager.h"
    5251#include "LevelManager.h"
     
    6766        , guiMouseOnlyInputState_(0)
    6867        , guiKeysOnlyInputState_(0)
    69         , radar_(0)
    7068        , cameraManager_(0)
    7169    {
     
    104102            // create the global CameraManager
    105103            this->cameraManager_ = new CameraManager(GraphicsManager::getInstance().getViewport());
    106 
    107             // Start the Radar
    108             this->radar_ = new Radar();
    109104        }
    110105
     
    186181        if (GameMode::isMaster())
    187182            this->unloadLevel();
    188 
    189         if (this->radar_)
    190         {
    191             this->radar_->destroy();
    192             this->radar_ = 0;
    193         }
    194183
    195184        if (this->cameraManager_)
  • code/branches/core5/src/modules/gamestates/GSLevel.h

    r5738 r5813  
    6767        InputState*              guiMouseOnlyInputState_;  //!< input state if we only need the mouse to use the GUI
    6868        InputState*              guiKeysOnlyInputState_;   //!< input state if we only need the keys to use the GUI
    69         Radar*                   radar_;                   //!< represents the Radar (not the HUD part)
    7069        CameraManager*           cameraManager_;           //!< camera manager for this level
    7170        PlayerManager*           playerManager_;           //!< player manager for this level
  • code/branches/core5/src/modules/overlays/hud/HUDNavigation.cc

    r5738 r5813  
    3939#include "core/CoreIncludes.h"
    4040#include "core/XMLPort.h"
     41#include "Scene.h"
    4142#include "Radar.h"
    4243
     
    130131        SUPER(HUDNavigation, tick, dt);
    131132
    132         if (!Radar::getInstance().getFocus())
     133        // Get radar
     134        Radar* radar = this->getOwner()->getScene()->getRadar();
     135
     136        if (!radar->getFocus())
    133137        {
    134138            this->overlay_->hide();
     
    150154*/
    151155        // transform to screen coordinates
    152         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
     156        Vector3 pos = /*transformationMatrix * */radar->getFocus()->getRVWorldPosition();
    153157
    154158        bool outOfView;
  • code/branches/core5/src/orxonox/Radar.cc

    r5785 r5813  
    4343namespace orxonox
    4444{
    45     SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
    46     SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
    47 
    48     Radar* Radar::instance_s = 0;
    4945
    5046    Radar::Radar()
     
    5248        , objectTypeCounter_(0)
    5349    {
    54         assert(instance_s == 0);
    55         instance_s = this;
    56 
    5750        // TODO: make this mapping configurable. Maybe there's a possibility with self configured
    5851        //       configValues..
     
    7972    Radar::~Radar()
    8073    {
    81         instance_s = 0;
    8274    }
    8375
     
    194186        }
    195187    }
    196 
    197 
    198     /*static*/ Radar& Radar::getInstance()
    199     {
    200         assert(instance_s);
    201         return *instance_s;
    202     }
    203 
    204     /*static*/ void Radar::cycleNavigationFocus()
    205     {
    206         // avoid using getInstance because of the assert().
    207         // User might call this fuction even if HUDNavigation doesn't exist.
    208         if (instance_s)
    209             instance_s->cycleFocus();
    210     }
    211 
    212     /*static*/ void Radar::releaseNavigationFocus()
    213     {
    214         // avoid using getInstance because of the assert().
    215         // User might call this fuction even if HUDNavigation doesn't exist.
    216         if (instance_s)
    217             instance_s->releaseFocus();
    218     }
    219188}
  • code/branches/core5/src/orxonox/Radar.h

    r5738 r5813  
    4646namespace orxonox
    4747{
    48     /**
    49     @brief This class merely ensures that no one can inherit from Radar.
    50     */
    51     class _OrxonoxExport RadarBase
    52     {
    53     private:
    54         friend class Radar;
    55         RadarBase() { }
    56     };
    57 
    58     class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
     48    class _OrxonoxExport Radar : public Tickable
    5949    {
    6050    public:
    6151        Radar();
    62         ~Radar();
     52        virtual ~Radar();
    6353
    6454        virtual void tick(float dt);
     
    6959        void listObjects() const;
    7060
    71         static Radar& getInstance();
    72         static Radar* getInstancePtr() { return instance_s; }
    73 
    74         static void cycleNavigationFocus();
    75         static void releaseNavigationFocus();
     61        void releaseFocus();
     62        void cycleFocus();
    7663
    7764    private:
    7865        Radar(Radar& instance);
    7966
    80         void releaseFocus();
    8167        void updateFocus();
    82         void cycleFocus();
    8368
    8469        ObjectListIterator<RadarViewable> itFocus_;
     
    8671        std::map<std::string, RadarViewable::Shape> objectTypes_;
    8772        int objectTypeCounter_;
    88 
    89         static Radar* instance_s;
    9073    };
    9174}
  • code/branches/core5/src/orxonox/Scene.cc

    r5805 r5813  
    4444#include "core/XMLPort.h"
    4545#include "tools/BulletConversions.h"
     46#include "Radar.h"
    4647#include "worldentities/WorldEntity.h"
    4748
     
    6263            this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
    6364            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     65
     66            this->radar_ = new Radar();
    6467        }
    6568        else
     
    6871            this->sceneManager_ = new Ogre::DefaultSceneManager("");
    6972            this->rootSceneNode_ = this->sceneManager_->getRootSceneNode();
     73
     74            this->radar_ = 0;
    7075        }
    7176
     
    9297            else
    9398                delete this->sceneManager_;
     99
     100            if (this->radar_)
     101                this->radar_->destroy();
    94102
    95103            this->setPhysicalWorld(false);
  • code/branches/core5/src/orxonox/Scene.h

    r5738 r5813  
    7171                { return this->bShadows_; }
    7272
     73            inline Radar* getRadar()
     74                { return this->radar_; }
     75
    7376            virtual void tick(float dt);
    7477
     
    9194            std::list<BaseObject*>   objects_;
    9295            bool                     bShadows_;
     96            Radar*                   radar_;
    9397
    9498
  • code/branches/core5/src/orxonox/controllers/HumanController.cc

    r5738 r5813  
    3636#include "infos/PlayerInfo.h"
    3737#include "overlays/Map.h"
     38#include "Radar.h"
     39#include "Scene.h"
    3840
    3941namespace orxonox
     
    5658    SetConsoleCommand(HumanController, dropItems,     true);
    5759    SetConsoleCommand(HumanController, useItem,       true);
     60    SetConsoleCommand(HumanController, cycleNavigationFocus,   true);
     61    SetConsoleCommand(HumanController, releaseNavigationFocus, true);
    5862
    5963    CreateUnloadableFactory(HumanController);
     
    200204            return NULL;
    201205    }
     206
     207    void HumanController::cycleNavigationFocus()
     208    {
     209        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     210            HumanController::localController_s->controllableEntity_->getScene()->getRadar()->cycleFocus();
     211    }
     212
     213    void HumanController::releaseNavigationFocus()
     214    {
     215        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     216            HumanController::localController_s->controllableEntity_->getScene()->getRadar()->releaseFocus();
     217    }
    202218}
  • code/branches/core5/src/orxonox/controllers/HumanController.h

    r5738 r5813  
    5858            static void dropItems();
    5959            static void useItem();
     60            static void cycleNavigationFocus();
     61            static void releaseNavigationFocus();
    6062
    6163            static void suicide();
  • code/branches/core5/src/orxonox/interfaces/RadarViewable.cc

    r5738 r5813  
    3838#include "worldentities/WorldEntity.h"
    3939#include "Radar.h"
     40#include "Scene.h"
    4041#include "overlays/Map.h"
    4142
     
    135136    void RadarViewable::setRadarObjectDescription(const std::string& str)
    136137    {
    137         Radar* radar = Radar::getInstancePtr();
     138        Radar* radar = this->getWorldEntity()->getScene()->getRadar();
    138139        if (radar)
    139140            this->radarObjectShape_ = radar->addObjectDescription(str);
Note: See TracChangeset for help on using the changeset viewer.