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_info.hpp" |
18 | #include "util/reader_mapping.hpp" |
19 | #include "util/reader_document.hpp" |
20 | |
21 | ObjectInfo::ObjectInfo() : |
22 | m_groups() |
23 | { |
24 | auto doc = ReaderDocument::from_file("images/engine/editor/objects.stoi" ); |
25 | auto root = doc.get_root(); |
26 | |
27 | if (root.get_name() != "supertux-objectinfo" ) { |
28 | throw std::runtime_error("file images/engine/editor/objects.stoi is not a supertux-objectinfo file." ); |
29 | } // Bombenfest und Idioten sicher :DDDDD |
30 | |
31 | auto reader = root.get_mapping(); |
32 | |
33 | /*const lisp::Lisp* info = root->get_lisp("supertux-objectinfo"); |
34 | if (!info) { |
35 | throw std::runtime_error("file images/engine/editor/objects.stoi is not a supertux-objectinfo file."); |
36 | }*/ // Bombenfest und Idioten sicher :DDDDD |
37 | |
38 | auto iter = reader.get_iter(); |
39 | while (iter.next()) { |
40 | const std::string& token = iter.get_key(); |
41 | if (token == "objectgroup" ) { |
42 | m_groups.push_back( ObjectGroup( iter.as_mapping() ) ); |
43 | } |
44 | } |
45 | |
46 | } |
47 | |
48 | /* EOF */ |
49 | |