1// SuperTux
2// Copyright (C) 2015 Hume2 <teratux.mail@gmail.com>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17#include "editor/object_group.hpp"
18
19#include "util/reader_mapping.hpp"
20
21ObjectGroup::ObjectGroup() :
22 m_name(),
23 m_icons(),
24 m_for_worldmap(false)
25{
26 m_icons.clear();
27}
28
29ObjectGroup::ObjectGroup(const ReaderMapping& reader) :
30 m_name(),
31 m_icons(),
32 m_for_worldmap(false)
33{
34 m_icons.clear();
35
36 reader.get("name", m_name);
37 reader.get("worldmap", m_for_worldmap);
38
39 auto iter = reader.get_iter();
40 while (iter.next()) {
41 const std::string& token = iter.get_key();
42 if (token == "object") {
43 m_icons.push_back( ObjectIcon( iter.as_mapping() ) );
44 }
45 }
46}
47
48void
49ObjectGroup::add_icon(const std::string& object, const std::string& icon_path) {
50 ObjectIcon new_icon(object, icon_path);
51 m_icons.push_back(new_icon);
52}
53
54/* EOF */
55