5ed50722d766ca50878c95144ab4e7bfc01fdf3d
[supertux.git] / src / supertux / menu / profile_menu.cpp
1 //  SuperTux
2 //  Copyright (C) 2008 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/profile_menu.hpp"
18
19 #include <sstream>
20
21 #include "gui/menu_manager.hpp"
22 #include "gui/menu_item.hpp"
23 #include "supertux/gameconfig.hpp"
24 #include "util/gettext.hpp"
25
26 ProfileMenu::ProfileMenu() 
27 {
28   add_label(_("Select Profile"));
29   add_hl();
30   for(int i = 0; i < 5; ++i)
31   {
32     std::ostringstream out;
33     out << "Profile " << i+1;
34     add_entry(i+1, out.str());
35   }
36
37   add_hl();
38   add_back(_("Back"));
39 }
40
41 void
42 ProfileMenu::menu_action(MenuItem* item) 
43 {
44   g_config->profile = item->id;
45   MenuManager::set_current(0);
46 }
47
48 /*
49   std::string
50   TitleScreen::get_slotinfo(int slot)
51   {
52   std::string tmp;
53   std::string title;
54
55   std::string basename = current_world->get_basedir();
56   basename = basename.substr(0, basename.length()-1);
57   std::string worlddirname = FileSystem::basename(basename);
58   std::ostringstream stream;
59   stream << "profile" << config->profile << "/" << worlddirname << "_" << slot << ".stsg";
60   std::string slotfile = stream.str();
61
62   try {
63   lisp::Parser parser;
64   const lisp::Lisp* root = parser.parse(slotfile);
65
66   const lisp::Lisp* savegame = root->get_lisp("supertux-savegame");
67   if(!savegame)
68   throw std::runtime_error("file is not a supertux-savegame.");
69
70   savegame->get("title", title);
71   } catch(std::exception& ) {
72   std::ostringstream slottitle;
73   slottitle << _("Slot") << " " << slot << " - " << _("Free");
74   return slottitle.str();
75   }
76
77   std::ostringstream slottitle;
78   slottitle << _("Slot") << " " << slot << " - " << title;
79   return slottitle.str();
80   }
81 */
82
83 /* EOF */