Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy/src/orxonox/objects/infos/LevelInfo.cc @ 1968

Last change on this file since 1968 was 1968, checked in by landauf, 16 years ago

added MovableEntity with network optimization for constant velocity and rotation

added new Timer feature to destroy a Timer right after it called the function

File size: 3.4 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "LevelInfo.h"
31
32#include <OgreSceneManager.h>
33
34#include "core/CoreIncludes.h"
35#include "core/XMLPort.h"
36#include "core/Core.h"
37
38#include "GraphicsEngine.h"
39
40namespace orxonox
41{
42    CreateFactory(LevelInfo);
43
44    LevelInfo::LevelInfo()
45    {
46        RegisterObject(LevelInfo);
47
48        this->gametypeInstance_ = 0;
49        this->registerVariables();
50
51        COUT(0) << "created LevelInfo" << std::endl;
52    }
53
54    void LevelInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
55    {
56        SUPER(LevelInfo, XMLPort, xmlelement, mode);
57
58        XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
59        XMLPortParam(LevelInfo, "gametype", setGametype, getGametype, xmlelement, mode).defaultValues("Gametype");
60        XMLPortParam(LevelInfo, "skybox", setSkybox, getSkybox, xmlelement, mode);
61        XMLPortParam(LevelInfo, "ambientlight", setAmbientLight, getAmbientLight, xmlelement, mode).defaultValues(ColourValue(0.2, 0.2, 0.2, 1));
62    }
63
64    void LevelInfo::registerVariables()
65    {
66        REGISTERSTRING(name_,         network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::changedName));
67        REGISTERSTRING(description_,  network::direction::toclient);
68        REGISTERSTRING(skybox_,       network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applySkybox));
69        REGISTERDATA(ambientLight_, network::direction::toclient, new network::NetworkCallback<LevelInfo>(this, &LevelInfo::applyAmbientLight));
70    }
71
72    void LevelInfo::setSkybox(const std::string& skybox)
73    {
74        if (Core::showsGraphics())
75            if (GraphicsEngine::getInstance().getLevelSceneManager())
76                GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skybox);
77
78        this->skybox_ = skybox;
79    }
80
81    void LevelInfo::setAmbientLight(const ColourValue& colour)
82    {
83        if (Core::showsGraphics())
84            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour);
85
86        this->ambientLight_ = colour;
87    }
88
89    void LevelInfo::setGametype(const std::string& gametype)
90    {
91        Identifier* identifier = ClassByString(gametype);
92        if (identifier)
93        {
94            this->gametype_ = gametype;
95            this->gametypeIdentifier_ = identifier;
96            this->gametypeInstance_ = this->gametypeIdentifier_.fabricate();
97        }
98    }
99}
Note: See TracBrowser for help on using the repository browser.