Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10128 was 9667, checked in by landauf, 11 years ago

merged core6 back to trunk

  • Property svn:eol-style set to native
File size: 4.0 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 *      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>
33#include <OgreBorderPanelOverlayElement.h>
34
35#include "util/StringUtils.h"
36#include "core/CoreIncludes.h"
37#include "core/config/ConfigValueIncludes.h"
38
39namespace orxonox
40{
41    RegisterClass(Stats);
42
43    /**
44        @brief Constructor: Creates and initializes the Stats panel.
45    */
46    Stats::Stats(Context* context)
47        : OrxonoxOverlay(context)
48        , statsOverlayNoise_(0)
49        , statsOverlayBorder_(0)
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
59        this->statsOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "StatsBorderPanel" + getUniqueNumberString()));
60        //this->statsOverlayBorder_->setMaterialName("StatsCenter");
61        this->statsOverlayBorder_->setBorderSize(0.003f, 16.0f * 0.003f);
62        this->statsOverlayBorder_->setBorderMaterialName("StatsBorder");
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);
71
72        background_->addChild(statsOverlayBorder_);
73
74        // create noise
75        //this->statsOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "StatsNoise" + getUniqueNumberString()));
76        //this->statsOverlayNoise_->setPosition(0,0);
77        //this->statsOverlayNoise_->setMaterialName("StatsNoiseSmall");
78        // comment following line to disable noise
79        //background_->addChild(this->statsOverlayNoise_);
80    }
81
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        }
90    }
91
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
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)
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);
108    }
109
110}
Note: See TracBrowser for help on using the repository browser.