Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/overlays/stats/Stats.cc @ 3110

Last change on this file since 3110 was 3110, checked in by rgrieder, 15 years ago

Removed old msvc specific support for precompiled header files.

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