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