- /* Draw the background: */
- draw_demo(frame_ratio);
-
- if (Menu::current() == main_menu)
- context.draw_surface(logo, Vector(screen->w/2 - logo->w/2, 30),
- LAYER_FOREGROUND1+1);
-
- context.draw_text(white_small_text,
- " SuperTux " VERSION "\n"
- "Copyright (c) 2003 SuperTux Devel Team\n"
- "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
- "are welcome to redistribute it under certain conditions; see the file COPYING\n"
- "for details.\n", Vector(0, screen->h - 70), LAYER_FOREGROUND1);
-
- /* Don't draw menu, if quit is true */
- Menu* menu = Menu::current();
- if(menu)
- {
- menu->draw(context);
- menu->action();
-
- if(menu == main_menu)
- {
- switch (main_menu->check())
- {
- case MNID_STARTGAME:
- // Start Game, ie. goto the slots menu
- update_load_save_game_menu(load_game_menu);
- break;
- case MNID_CONTRIB:
- // Contrib Menu
- puts("Entering contrib menu");
- generate_contrib_menu();
- break;
- case MNID_LEVELEDITOR:
- // TODO
- //leveleditor();
- Menu::set_current(main_menu);
- break;
- case MNID_CREDITS:
- display_text_file("CREDITS", bkg_title, SCROLL_SPEED_CREDITS);
- Menu::set_current(main_menu);
- break;
- case MNID_QUITMAINMENU:
- Menu::set_current(0);
- break;
- }
- }
- else if(menu == options_menu)
- {
- process_options_menu();
- }
- else if(menu == load_game_menu)
- {
- if(event.key.keysym.sym == SDLK_DELETE)
- {
- int slot = menu->get_active_item_id();
- char str[1024];
- sprintf(str,"Are you sure you want to delete slot %d?", slot);
-
- if(confirm_dialog(str))
- {
- sprintf(str,"%s/slot%d.stsg", st_save_dir, slot);
- printf("Removing: %s\n",str);
- remove(str);
- }
-
- update_load_save_game_menu(load_game_menu);
- Menu::set_current(main_menu);
- update_time = st_get_ticks();
- }
- else if (process_load_game_menu())
- {
- // FIXME: shouldn't be needed if GameSession doesn't relay on global variables
- titlesession->get_current_sector()->activate();
- titlesession->set_current();
- //titletux.level_begin();
- update_time = st_get_ticks();
- }
- }
- else if(menu == contrib_menu)
- {
- check_contrib_menu();
- }
- else if (menu == contrib_subset_menu)
- {
- check_contrib_subset_menu();
- }
- }
+std::string
+TitleScreen::get_slotinfo(int slot)
+{
+ std::string tmp;
+ std::string title;
+
+ std::string basename = current_world->get_basedir();
+ basename = basename.substr(0, basename.length()-1);
+ std::string worlddirname = FileSystem::basename(basename);
+ std::ostringstream stream;
+ stream << "save/" << worlddirname << "_" << slot << ".stsg";
+ std::string slotfile = stream.str();
+
+ try {
+ lisp::Parser parser;
+ std::auto_ptr<lisp::Lisp> root (parser.parse(slotfile));
+
+ const lisp::Lisp* savegame = root->get_lisp("supertux-savegame");
+ if(!savegame)
+ throw std::runtime_error("file is not a supertux-savegame.");
+
+ savegame->get("title", title);
+ } catch(std::exception& e) {
+ std::ostringstream slottitle;
+ slottitle << _("Slot") << " " << slot << " - " << _("Free");
+ return slottitle.str();
+ }
+
+ std::ostringstream slottitle;
+ slottitle << _("Slot") << " " << slot << " - " << title;
+ return slottitle.str();
+}