Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Removed a ton of msvc warnings revealed with OGRE v1.7 (they removed the warning suppressors in OgrePrerequisites.h).
All of them are conversions from one type to another that might be lossy (mostly double to float, please always use "3.7f" instead of "3.7" as constants when using floats).

  • 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#include <OgreOverlayManager.h>
[3196]33#include <OgreBorderPanelOverlayElement.h>
[2120]34
[3280]35#include "util/StringUtils.h"
[2120]36#include "core/CoreIncludes.h"
37#include "core/ConfigValueIncludes.h"
38
39namespace orxonox
40{
[2140]41    CreateFactory(Stats);
[2120]42
43    /**
44        @brief Constructor: Creates and initializes the Stats panel.
45    */
46    Stats::Stats(BaseObject* creator)
47        : OrxonoxOverlay(creator)
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
[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
100    /**
101        @brief Initializes the Stats panel.
102    */
103    void Stats::XMLPort(Element& xmlElement, XMLPort::Mode mode)
104    {
105        OrxonoxOverlay::XMLPort(xmlElement, mode);
106    }
107
[2120]108    void Stats::tick(float dt)
109    {
110        // SUPER(Stats, tick, dt);
111
112            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
[2495]113            //float uRand = (rand() & 1023) / 1023.0f * 0.2f;
114            //float vRand = (rand() & 1023) / 1023.0f * 0.2f;
115            //this->statsOverlayNoise_->setUV(uRand, vRand, 7.5f + uRand, 7.5f + vRand);
[2120]116    }
117
118}
Note: See TracBrowser for help on using the repository browser.