| 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 | |
|---|
| 40 | namespace 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 | std::cout << "0: " << gametype << std::endl; |
|---|
| 92 | Identifier* identifier = ClassByString(gametype); |
|---|
| 93 | if (identifier) |
|---|
| 94 | { |
|---|
| 95 | std::cout << "1: " << identifier->getName() << std::endl; |
|---|
| 96 | this->gametype_ = gametype; |
|---|
| 97 | this->gametypeIdentifier_ = identifier; |
|---|
| 98 | this->gametypeInstance_ = this->gametypeIdentifier_.fabricate(); |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | } |
|---|