Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/overlays/stats/Stats.cc @ 12209

Last change on this file since 12209 was 11795, checked in by landauf, 7 years ago

merged ogre1.9 (including cegui0.8) into new branch

  • Property svn:eol-style set to native
File size: 4.2 KB
RevLine 
[2120]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 *      Felix Schulthess
24 *   Co-authors:
25 *      Fabian 'x3n' Landau, Benjamin Hildebrandt
26 *
27 */
28
29#include "Stats.h"
30
31#include <string>
32
[11795]33#if OGRE_VERSION >= 0x010900
34#   include <Overlay/OgreOverlayManager.h>
35#   include <Overlay/OgreBorderPanelOverlayElement.h>
36#else
37#   include <OgreOverlayManager.h>
38#   include <OgreBorderPanelOverlayElement.h>
39#endif
40
[3280]41#include "util/StringUtils.h"
[2120]42#include "core/CoreIncludes.h"
[9667]43#include "core/config/ConfigValueIncludes.h"
[2120]44
45namespace orxonox
46{
[9667]47    RegisterClass(Stats);
[2120]48
49    /**
50        @brief Constructor: Creates and initializes the Stats panel.
51    */
[9667]52    Stats::Stats(Context* context)
53        : OrxonoxOverlay(context)
[11071]54        , statsOverlayNoise_(nullptr)
55        , statsOverlayBorder_(nullptr)
[2120]56    {
57        RegisterObject(Stats);
58
59        this->setConfigValues();
60
61        // create overlay and elements
62        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
63
64        // create BorderPanel
[2495]65        this->statsOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "StatsBorderPanel" + getUniqueNumberString()));
66        //this->statsOverlayBorder_->setMaterialName("StatsCenter");
[6502]67        this->statsOverlayBorder_->setBorderSize(0.003f, 16.0f * 0.003f);
[2120]68        this->statsOverlayBorder_->setBorderMaterialName("StatsBorder");
[6502]69        this->statsOverlayBorder_->setTopBorderUV(0.49f, 0.0f, 0.51f, 0.5f);
70        this->statsOverlayBorder_->setTopLeftBorderUV(0.0f, 0.0f, 0.5f, 0.5f);
71        this->statsOverlayBorder_->setTopRightBorderUV(0.5f, 0.0f, 1.0f, 0.5f);
72        this->statsOverlayBorder_->setLeftBorderUV(0.0f, 0.49f, 0.5f, 0.51f);
73        this->statsOverlayBorder_->setRightBorderUV(0.5f, 0.49f, 1.0f, 0.5f);
74        this->statsOverlayBorder_->setBottomBorderUV(0.49f, 0.5f, 0.51f, 1.0f);
75        this->statsOverlayBorder_->setBottomLeftBorderUV(0.0f, 0.5f, 0.5f, 1.0f);
76        this->statsOverlayBorder_->setBottomRightBorderUV(0.5f, 0.5f, 1.0f, 1.0f);
[2120]77
78        background_->addChild(statsOverlayBorder_);
79
80        // create noise
[2495]81        //this->statsOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "StatsNoise" + getUniqueNumberString()));
82        //this->statsOverlayNoise_->setPosition(0,0);
83        //this->statsOverlayNoise_->setMaterialName("StatsNoiseSmall");
[2120]84        // comment following line to disable noise
[2495]85        //background_->addChild(this->statsOverlayNoise_);
86    }
[2120]87
[2495]88    Stats::~Stats()
89    {
90        if (this->isInitialized())
91        {
92            Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
93            ovMan->destroyOverlayElement(this->statsOverlayBorder_);
94            //ovMan->destroyOverlayElement(this->statsOverlayNoise_);
95        }
[2120]96    }
97
[2495]98    /**
99        @brief Sets the config values, describing the size of the Stats panel.
100    */
101    void Stats::setConfigValues()
102    {
103        SetConfigValue(noiseSize_, 1.0f);
104    }
105
[2120]106    void Stats::tick(float dt)
107    {
108        // SUPER(Stats, tick, dt);
109
110            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
[2495]111            //float uRand = (rand() & 1023) / 1023.0f * 0.2f;
112            //float vRand = (rand() & 1023) / 1023.0f * 0.2f;
113            //this->statsOverlayNoise_->setUV(uRand, vRand, 7.5f + uRand, 7.5f + vRand);
[2120]114    }
115
116}
Note: See TracBrowser for help on using the repository browser.