Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.cc

    r2907 r2908  
    3939#include <OgreOverlayManager.h>
    4040#include <OgrePanelOverlayElement.h>
    41 #include <OgreRenderWindow.h>
    42 
    4341#include "util/Convert.h"
    4442#include "util/Exception.h"
    4543#include "util/String.h"
    46 #include "core/GameMode.h"
     44#include "core/Core.h"
    4745#include "core/CoreIncludes.h"
    4846#include "core/XMLPort.h"
    4947#include "core/ConsoleCommand.h"
    50 #include "GraphicsManager.h"
    5148
    5249namespace orxonox
     
    6764        this->group_ = 0;
    6865
    69         if (!GameMode::showsGraphics())
     66        if (!Core::showsGraphics())
    7067            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    7168
     
    8077        this->overlay_->add2D(this->background_);
    8178
    82         // Get aspect ratio from the render window. Later on, we get informed automatically
    83         Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
    84         this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
     79        // We'll have to set the aspect ratio to a default value first.
     80        // GSGraphics gets informed about our construction here and can update us in the next tick.
     81        this->windowAspectRatio_ = 1.0;
    8582        this->sizeCorrectionChanged();
    8683
     
    178175    /**
    179176    @brief
    180         Called by the GraphicsManager whenever the window size changes.
     177        Called by the GraphicsEngine whenever the window size changes.
    181178        Calculates the aspect ratio only.
    182179    */
    183     void OrxonoxOverlay::windowResized(unsigned int newWidth, unsigned int newHeight)
     180    void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
    184181    {
    185182        this->windowAspectRatio_ = newWidth/(float)newHeight;
  • code/branches/questsystem5/src/orxonox/overlays/OrxonoxOverlay.h

    r2907 r2908  
    154154        virtual void changedVisibility();
    155155
    156         inline void setOwner(BaseObject* owner)
     156        inline void setOwner(ControllableEntity* owner)
    157157        {
    158158            if (this->owner_ != owner)
     
    162162            }
    163163        }
    164         inline BaseObject* getOwner() const
     164        inline ControllableEntity* getOwner() const
    165165            { return this->owner_; }
    166166        virtual void changedOwner() {}
     
    200200
    201201    private:
    202         void windowResized(unsigned int newWidth, unsigned int newHeight);
     202        void windowResized(int newWidth, int newHeight);
    203203
    204204        static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
     
    206206            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
    207207        static std::map<std::string, OrxonoxOverlay*> overlays_s;
    208         BaseObject* owner_;
     208        ControllableEntity* owner_;
    209209        OverlayGroup* group_;
    210210  };
  • code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.cc

    r2907 r2908  
    6363    OverlayGroup::~OverlayGroup()
    6464    {
    65         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    66             delete (*it);
     65        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     66            delete it->second;
    6767    }
    6868
     
    8383    }
    8484
    85     //! Scales every element in the set.
     85    //! Scales every element in the map.
    8686    void OverlayGroup::setScale(const Vector2& scale)
    8787    {
    88         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    89             (*it)->scale(scale / this->scale_);
     88        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     89            (*it).second->scale(scale / this->scale_);
    9090        this->scale_ = scale;
    9191    }
    9292
    93     //! Scrolls every element in the set.
     93    //! Scrolls every element in the map.
    9494    void OverlayGroup::setScroll(const Vector2& scroll)
    9595    {
    96         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    97             (*it)->scroll(scroll - this->scroll_);
     96        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     97            (*it).second->scroll(scroll - this->scroll_);
    9898        this->scroll_ = scroll;
    9999    }
     
    101101    /**
    102102    @brief
    103         Adds an element to the set (used when loading with XMLPort).
     103        Adds an element to the map (used when loading with XMLPort).
    104104    @remarks
    105105        The names of the OrxonoxOverlays have to be unique!
     
    107107    void OverlayGroup::addElement(OrxonoxOverlay* element)
    108108    {
    109         hudElements_.insert(element);
    110         element->setVisible(this->isVisible());
    111         if (this->owner_)
    112             element->setOwner(this->owner_);
    113     }
    114 
    115     /**
     109        this->insertElement(element, element->getName());
     110    }
     111
     112        /**
     113    @brief
     114        Adds an element to the map.
     115    @param element
     116        The element to be added.
     117    @param name
     118        The name of the element.
     119    @remarks
     120        The names of the OrxonoxOverlays have to be unique!
     121    */
     122    void OverlayGroup::insertElement(OrxonoxOverlay* element, const std::string & name)
     123    {
     124        element->setName(name);
     125        if (hudElements_.find(name) != hudElements_.end())
     126        {
     127            COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
     128        }
     129        else
     130        {
     131            hudElements_[name] = element;
     132            element->setVisible(this->isVisible());
     133                        if (this->owner_)
     134                element->setOwner(this->owner_);
     135        }
     136    }
     137
     138        /**
    116139    @brief
    117140        Removes an element from the map.
    118     @param element
    119         The element that is to be removed.
     141    @param name
     142        The name of the element that is removed.
    120143    @return
    121144        Returns true if there was such an element to remove, false if not.
    122145    */
    123     bool OverlayGroup::removeElement(OrxonoxOverlay* element)
    124     {
    125         if(this->hudElements_.erase(element) == 0)
     146    bool OverlayGroup::removeElement(const std::string & name)
     147    {
     148        if(this->hudElements_.erase(name) == 0)
    126149            return false;
    127150        return true;
     
    133156        if (index < this->hudElements_.size())
    134157        {
    135             std::set<OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
     158            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
    136159            for (unsigned int i = 0; i != index; ++it, ++i)
    137160                ;
    138             return (*it);
     161            return (*it).second;
    139162        }
    140163        else
     
    145168    void OverlayGroup::changedVisibility()
    146169    {
    147         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    148             (*it)->setVisible(this->isVisible());
    149     }
    150 
    151     void OverlayGroup::setOwner(BaseObject* owner)
     170        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     171            (*it).second->setVisible(this->isVisible());
     172    }
     173
     174    void OverlayGroup::setOwner(ControllableEntity* owner)
    152175    {
    153176        this->owner_ = owner;
    154177
    155         for (std::set<OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
    156             (*it)->setOwner(owner);
     178        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     179            (*it).second->setOwner(owner);
    157180    }
    158181
  • code/branches/questsystem5/src/orxonox/overlays/OverlayGroup.h

    r2907 r2908  
    3737#include "OrxonoxPrereqs.h"
    3838
    39 #include <set>
    40 #include <string>
     39#include <map>
    4140#include <OgrePrerequisites.h>
    4241#include "core/BaseObject.h"
     
    6564        static void scrollGroup(const std::string& name, const Vector2& scroll);
    6665
    67         inline const std::set<OrxonoxOverlay*>& getOverlays() const
     66        inline const std::map<std::string, OrxonoxOverlay*>& getOverlays() const
    6867            { return this->hudElements_; }
    6968
    7069        void changedVisibility();
    7170
    72         void setOwner(BaseObject* owner);
    73         inline BaseObject* getOwner() const
     71        void setOwner(ControllableEntity* owner);
     72        inline ControllableEntity* getOwner() const
    7473            { return this->owner_; }
    7574
     
    8786
    8887        void addElement(OrxonoxOverlay* element);
    89         bool removeElement(OrxonoxOverlay* element);
     88                void insertElement(OrxonoxOverlay* element, const std::string & name);
     89        bool removeElement(const std::string & name);
    9090        OrxonoxOverlay* getElement(unsigned int index);
    9191
    9292    private:
    93         std::set<OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
    94         Vector2 scale_;                            //!< Current scale (independent of the elements).
    95         Vector2 scroll_;                           //!< Current scrolling offset.
    96         BaseObject* owner_;                        //!< The owner of this OverlayGroup
     93        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
     94        Vector2 scale_;                                         //!< Current scale (independent of the elements).
     95        Vector2 scroll_;                                        //!< Current scrolling offset.
     96        ControllableEntity* owner_;                             //!< The owner of this OverlayGroup
    9797    };
    9898}
  • code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.cc

    r2907 r2908  
    4242#include "util/Convert.h"
    4343#include "util/Debug.h"
    44 #include "core/Clock.h"
    4544#include "core/CoreIncludes.h"
    4645#include "core/ConfigValueIncludes.h"
     
    173172    {
    174173        // create the corresponding input state
    175         inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", false, false, InputStatePriority::Console);
     174        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("console", 40);
    176175        inputState_->setKeyHandler(Shell::getInstance().getInputBuffer());
    177176        bHidesAllInputChanged();
     
    348347        @brief Used to control the actual scrolling and the cursor.
    349348    */
    350     void InGameConsole::update(const Clock& time)
     349    void InGameConsole::tick(float dt)
    351350    {
    352351        if (this->scroll_ != 0)
     
    359358                // enlarge oldTop a little bit so that this exponential function
    360359                // reaches 0 before infinite time has passed...
    361                 float deltaScroll = (oldTop - 0.01) * time.getDeltaTime() * this->scrollSpeed_;
     360                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
    362361                if (oldTop - deltaScroll >= 0)
    363362                {
     
    374373                // scrolling up
    375374                // note: +0.01 for the same reason as when scrolling down
    376                 float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * time.getDeltaTime() * this->scrollSpeed_;
     375                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
    377376                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
    378377                {
     
    389388        if (this->bActive_)
    390389        {
    391             this->cursor_ += time.getDeltaTime();
     390            this->cursor_ += dt;
    392391            if (this->cursor_ >= this->blinkTime)
    393392            {
     
    410409        @brief Resizes the console elements. Call if window size changes.
    411410    */
    412     void InGameConsole::windowResized(unsigned int newWidth, unsigned int newHeight)
     411    void InGameConsole::windowResized(int newWidth, int newHeight)
    413412    {
    414413        this->windowW_ = newWidth;
  • code/branches/questsystem5/src/orxonox/overlays/console/InGameConsole.h

    r2907 r2908  
    5353        void setConfigValues();
    5454
    55         void update(const Clock& time);
     55        virtual void tick(float dt);
    5656
    5757        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     
    8181        void print(const std::string& text, int index, bool alwaysShift = false);
    8282
    83         void windowResized(unsigned int newWidth, unsigned int newHeight);
     83        void windowResized(int newWidth, int newHeight);
    8484
    8585        // config value related
  • code/branches/questsystem5/src/orxonox/overlays/debug/DebugFPSText.cc

    r2907 r2908  
    3030#include "DebugFPSText.h"
    3131#include <OgreTextAreaOverlayElement.h>
     32#include "core/CoreIncludes.h"
     33#include "GraphicsEngine.h"
    3234#include "util/Convert.h"
    33 #include "core/CoreIncludes.h"
    34 #include "core/Game.h"
    3535
    3636namespace orxonox
     
    5151        SUPER(DebugFPSText, tick, dt);
    5252
    53         float fps = Game::getInstance().getAvgFPS();
     53        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5454        this->setCaption(convertToString(fps));
    5555    }
  • code/branches/questsystem5/src/orxonox/overlays/debug/DebugRTRText.cc

    r2907 r2908  
    3232#include "core/CoreIncludes.h"
    3333#include "util/Convert.h"
    34 #include "core/Game.h"
     34#include "GraphicsEngine.h"
    3535
    3636namespace orxonox
     
    5151        SUPER(DebugRTRText, tick, dt);
    5252
    53         float rtr = Game::getInstance().getAvgTickTime();
     53        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5454        this->setCaption(convertToString(rtr));
    5555    }
  • code/branches/questsystem5/src/orxonox/overlays/hud/CMakeLists.txt

    r2907 r2908  
    77  ChatOverlay.cc
    88  GametypeStatus.cc
    9   PongScore.cc
    109)
  • code/branches/questsystem5/src/orxonox/overlays/hud/HUDRadar.cc

    r2907 r2908  
    9494    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9595    {
    96         if (object == static_cast<RadarViewable*>(this->owner_))
     96        if (object == (RadarViewable*)this->owner_)
    9797            return;
    9898
  • code/branches/questsystem5/src/orxonox/overlays/notifications/NotificationQueue.cc

    r2907 r2908  
    410410        this->containers_.insert(container);
    411411        this->overlays_[notification] = container;
    412         this->addElement(container->overlay);
     412        this->insertElement(container->overlay, container->name);
    413413        this->size_= this->size_+1;
    414414
     
    429429            return false;
    430430       
    431         this->removeElement(container->overlay);
     431        this->removeElement(container->name);
    432432        this->containers_.erase(container);
    433433        this->overlays_.erase(container->notification);
Note: See TracChangeset for help on using the changeset viewer.