- Uint32 lastticks = SDL_GetTicks();
-
- Menu::set_current(main_menu);
- DrawingContext& context = *titlesession->context;
- while (Menu::current())
- {
- // Calculate the movement-factor
- Uint32 ticks = SDL_GetTicks();
- float elapsed_time = float(ticks - lastticks) / 1000.;
- global_time += elapsed_time;
- lastticks = ticks;
- // 40fps is minimum
- if(elapsed_time > .04)
- elapsed_time = .04;
-
- /* Lower the speed so that Tux doesn't jump too hectically throught
- the demo. */
- elapsed_time /= 2;
-
- SDL_Event event;
- while (SDL_PollEvent(&event))
- {
- if (Menu::current())
- {
- Menu::current()->event(event);
- }
- // FIXME: QUIT signal should be handled more generic, not locally
- if (event.type == SDL_QUIT)
- Menu::set_current(0);
- }
-
- /* Draw the background: */
- draw_demo(elapsed_time);
-
-
- 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 " PACKAGE_VERSION "\n",
- Vector(0, screen->h - 70), LEFT_ALLIGN, LAYER_FOREGROUND1);
- context.draw_text(white_small_text,
- _(
-"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 + white_small_text->get_height()),
- LEFT_ALLIGN, 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_LEVELS_CONTRIB:
- // Contrib Menu
- puts("Entering contrib menu");
- generate_contrib_menu();
- break;
- case MNID_LEVELEDITOR:
- leveleditor = new LevelEditor();
- leveleditor->run();
- delete leveleditor;
- Menu::set_current(main_menu);
- resume_demo();
- break;
- case MNID_CREDITS:
- fadeout(500);
- titlesession->get_current_sector()->play_music(CREDITS_MUSIC);
- display_text_file("credits.txt", SCROLL_SPEED_CREDITS, white_big_text , white_text, white_small_text, blue_text );
- fadeout(500);
- //titlesession->get_current_sector()->play_music(LEVEL_MUSIC); //not needed
- 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();
- std::stringstream stream;
- stream << slot;
- std::string str = _("Are you sure you want to delete slot") + stream.str() + "?";
-
- if(confirm_dialog(bkg_title, str.c_str()))
- {
- str = st_save_dir + "/slot" + stream.str() + ".stsg";
- printf("Removing: %s\n",str.c_str());
- remove(str.c_str());
- }
-
- update_load_save_game_menu(load_game_menu);
- Menu::set_current(main_menu);
- resume_demo();
- }
- else if (process_load_game_menu())
- {
- resume_demo();
- }
- }
- else if(menu == contrib_menu)
- {
- check_levels_contrib_menu();
- }
- else if (menu == contrib_subset_menu)
- {
- check_contrib_subset_menu();
- }
+void
+TitleScreen::update(float elapsed_time)
+{
+ main_loop->set_speed(0.6f);
+ Sector* sector = titlesession->get_current_sector();
+ sector->update(elapsed_time);
+
+ make_tux_jump();
+
+ Menu* menu = Menu::current();
+ if(menu) {
+ menu->update();
+
+ if(menu == main_menu.get()) {
+ switch (main_menu->check()) {
+ case MNID_STARTGAME:
+ // Start Game, ie. goto the slots menu
+ if(main_world.get() == NULL) {
+ main_world.reset(new World());
+ main_world->load("levels/world1/info");
+ }
+ current_world = main_world.get();
+ update_load_game_menu();
+ Menu::push_current(load_game_menu.get());
+ break;
+ case MNID_LEVELS_CONTRIB:
+ // Contrib Menu
+ generate_contrib_menu();
+ Menu::push_current(contrib_menu.get());
+ break;
+ case MNID_ADDONS:
+ // Add-ons Menu
+ generate_addons_menu();
+ Menu::push_current(addons_menu.get());
+ break;
+ case MNID_CREDITS:
+ main_loop->push_screen(new TextScroller("credits.txt"),
+ new FadeOut(0.5));
+ break;
+ case MNID_QUITMAINMENU:
+ main_loop->quit(new FadeOut(0.25));
+ sound_manager->stop_music(0.25);
+ break;
+ }
+ } else if(menu == load_game_menu.get()) {
+ /*
+ if(event.key.keysym.sym == SDLK_DELETE) {
+ int slot = menu->get_active_item_id();
+ std::stringstream stream;
+ stream << slot;
+ std::string str = _("Are you sure you want to delete slot") + stream.str() + "?";
+
+ if(confirm_dialog(bkg_title, str.c_str())) {
+ str = "save/slot" + stream.str() + ".stsg";
+ log_debug << "Removing: " << str << std::endl;
+ PHYSFS_delete(str.c_str());