Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/releasetodo/src/orxonox/LevelInfo.cc @ 7614

Last change on this file since 7614 was 7614, checked in by dafrick, 14 years ago

Trying out some stuff.

File size: 2.5 KB
RevLine 
[7614]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 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "LevelInfo.h"
30
31#include <sstream>
32#include <vector>
33
34#include "util/SubString.h"
35#include "core/CoreIncludes.h"
36#include "core/XMLPort.h"
37
38#include "LevelManager.h"
39
40namespace orxonox
41{
42    CreateFactory(LevelInfo);
43
44    LevelInfo::LevelInfo(BaseObject* creator) : BaseObject(creator)
45    {
46        RegisterObject(LevelInfo);
47
48    }
49
50    LevelInfo::~LevelInfo()
51    {
52       
53    }
54
55    void LevelInfo::XMLPort(Element& xmlelement, XMLPort::Mode mode)
56    {
57        SUPER(LevelInfo, XMLPort, xmlelement, mode);
58
59        XMLPortParam(LevelInfo, "description", setDescription, getDescription, xmlelement, mode);
60        XMLPortParam(LevelInfo, "tags", setTags, getTags, xmlelement, mode).defaultValues("");
61    }
62   
63    void LevelInfo::setTags(const std::string& tags)
64    {
65        const std::vector<std::string>& strings = SubString(tags, ",", " ").getAllStrings();
66        for(std::vector<std::string>::const_iterator it = strings.begin(); it != strings.end(); it++)
67            this->addTag(*it);
68           
69        this->tagsUpdated();
70    }
71   
72    void LevelInfo::tagsUpdated(void)
73    {
74        std::stringstream stream;
75        std::set<std::string>::const_iterator temp;
76        for(std::set<std::string>::const_iterator it = this->tags_.begin(); it != this->tags_.end(); )
77        {
78            temp = it;
79            if(++it == this->tags_.end()) // If this is the last tag.
80                stream << *temp;
81            else
82                stream << *temp << ", ";
83        }
84           
85        this->tagsString_ = stream.str();
86    }
87   
88}
89   
Note: See TracBrowser for help on using the repository browser.