1// SuperTux - Add-on
2// Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
3// 2014 Ingo Ruhnke <grumbel@gmail.com>
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
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 General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18#ifndef HEADER_SUPERTUX_ADDON_ADDON_HPP
19#define HEADER_SUPERTUX_ADDON_ADDON_HPP
20
21#include <memory>
22#include <string>
23
24class ReaderMapping;
25
26class Addon final
27{
28public:
29 static std::unique_ptr<Addon> parse(const ReaderMapping& mapping);
30 static std::unique_ptr<Addon> parse(const std::string& fname);
31
32 enum Type { WORLD, WORLDMAP, LEVELSET, LANGUAGEPACK };
33
34 enum Format {
35 ORIGINAL = 0,
36 WITH_MOUNTPOINT = 1
37 };
38
39private:
40 // fields provided by the addon.zip itself
41 std::string m_id;
42 int m_version;
43 Type m_type;
44 std::string m_title;
45 std::string m_author;
46 std::string m_license;
47 int m_format;
48
49 // additional fields provided for addons from an addon repository
50 std::string m_url;
51 std::string m_md5;
52
53 // fields filled by the AddonManager
54 std::string m_install_filename;
55 bool m_enabled;
56
57private:
58 Addon();
59
60public:
61 std::string get_id() const { return m_id; }
62 int get_version() const { return m_version; }
63 int get_format() const { return m_format; }
64
65 Type get_type() const { return m_type; }
66 std::string get_title() const { return m_title; }
67 std::string get_author() const { return m_author; }
68 std::string get_license() const { return m_license; }
69
70 std::string get_url() const { return m_url; }
71 std::string get_md5() const { return m_md5; }
72
73 std::string get_filename() const;
74 std::string get_install_filename() const;
75
76 bool is_installed() const;
77 bool is_enabled() const;
78
79 void set_install_filename(const std::string& absolute_filename, const std::string& md5);
80 void set_enabled(bool v);
81
82private:
83 Addon(const Addon&) = delete;
84 Addon& operator=(const Addon&) = delete;
85};
86
87#endif
88
89/* EOF */
90