Move all Menus into separate classes
[supertux.git] / src / supertux / menu / addon_menu.cpp
1 //  SuperTux
2 //  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
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 "supertux/menu/addon_menu.hpp"
18
19 #include <config.h>
20
21 #include "addon/addon.hpp"
22 #include "util/gettext.hpp"
23
24 AddonMenu::AddonMenu(const std::vector<Addon*>& addons)
25 {
26   add_label(_("Add-ons"));
27   add_hl();
28
29   // FIXME: don't use macro, use AddonManager::online_available() or so
30 #ifdef HAVE_LIBCURL
31   add_entry(0, std::string(_("Check Online")));
32 #else
33   add_inactive(0, std::string(_("Check Online (disabled)")));
34 #endif
35
36   //add_hl();
37
38   for (unsigned int i = 0; i < addons.size(); i++) 
39   {
40     const Addon& addon = *addons[i];
41     std::string text = "";
42     
43     if (!addon.kind.empty())
44     {
45       text += addon.kind + " ";
46     }
47     text += std::string("\"") + addon.title + "\"";
48
49     if (!addon.author.empty())
50     {
51       text += " by \"" + addon.author + "\"";
52     }
53     add_toggle(ADDON_LIST_START_ID + i, text, addon.loaded);
54   }
55
56   add_hl();
57   add_back(_("Back"));
58 }
59
60 /* EOF */