2 // Copyright (C) 2008 Ingo Ruhnke <grumbel@gmx.de>
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.
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.
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/>.
17 #include "gui/menu.hpp"
18 #include "gui/menu_item.hpp"
19 #include "supertux/gameconfig.hpp"
20 #include "util/gettext.hpp"
26 class ProfileMenu : public Menu
30 add_label(_("Select Profile"));
32 for(int i = 0; i < 5; ++i)
34 std::ostringstream out;
35 out << "Profile " << i+1;
36 add_entry(i+1, out.str());
43 void menu_action(MenuItem* item) {
44 g_config->profile = item->id;
49 Menu* profile_menu = 0;
51 Menu* get_profile_menu()
53 //static ProfileMenu menu;
54 profile_menu = new ProfileMenu();
58 void free_profile_menu()
66 TitleScreen::get_slotinfo(int slot)
71 std::string basename = current_world->get_basedir();
72 basename = basename.substr(0, basename.length()-1);
73 std::string worlddirname = FileSystem::basename(basename);
74 std::ostringstream stream;
75 stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
76 std::string slotfile = stream.str();
80 const lisp::Lisp* root = parser.parse(slotfile);
82 const lisp::Lisp* savegame = root->get_lisp("supertux-savegame");
84 throw std::runtime_error("file is not a supertux-savegame.");
86 savegame->get("title", title);
87 } catch(std::exception& ) {
88 std::ostringstream slottitle;
89 slottitle << _("Slot") << " " << slot << " - " << _("Free");
90 return slottitle.str();
93 std::ostringstream slottitle;
94 slottitle << _("Slot") << " " << slot << " - " << title;
95 return slottitle.str();