3 Copyright (C) 2018 rubenwardy <rw@rubenwardy.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include "content/content.h"
22 #include "content/subgames.h"
23 #include "content/mods.h"
36 ContentType getContentType(const ContentSpec &spec)
38 std::ifstream modpack_is((spec.path + DIR_DELIM + "modpack.txt").c_str());
39 if (modpack_is.good()) {
44 std::ifstream init_is((spec.path + DIR_DELIM + "init.lua").c_str());
50 std::ifstream game_is((spec.path + DIR_DELIM + "game.conf").c_str());
56 std::ifstream txp_is((spec.path + DIR_DELIM + "texture_pack.conf").c_str());
65 void parseContentInfo(ContentSpec &spec)
67 std::string conf_path;
69 switch (getContentType(spec)) {
72 conf_path = spec.path + DIR_DELIM + "mod.conf";
75 spec.type = "modpack";
76 conf_path = spec.path + DIR_DELIM + "mod.conf";
80 conf_path = spec.path + DIR_DELIM + "game.conf";
84 conf_path = spec.path + DIR_DELIM + "texture_pack.conf";
87 spec.type = "unknown";
92 if (!conf_path.empty() && conf.readConfigFile(conf_path.c_str())) {
93 if (conf.exists("name"))
94 spec.name = conf.get("name");
96 if (conf.exists("description"))
97 spec.desc = conf.get("description");
99 if (conf.exists("author"))
100 spec.author = conf.get("author");
103 if (spec.desc.empty()) {
104 std::ifstream is((spec.path + DIR_DELIM + "description.txt").c_str());
105 spec.desc = std::string((std::istreambuf_iterator<char>(is)),
106 std::istreambuf_iterator<char>());