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