Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11904 was 11071, checked in by landauf, 9 years ago

merged branch cpp11_v3 back to trunk

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