+ // deal with statistics
+ level->statistics.merge(global_stats);
+ calculate_total_stats();
+
+ if (old_level_state != level->solved && level->auto_path)
+ { // Try to detect the next direction to which we should walk
+ // FIXME: Mostly a hack
+ Direction dir = D_NONE;
+
+ const Tile* tile = at(tux->get_tile_pos());
+
+ if (tile->getData() & Tile::WORLDMAP_NORTH
+ && tux->back_direction != D_NORTH)
+ dir = D_NORTH;
+ else if (tile->getData() & Tile::WORLDMAP_SOUTH
+ && tux->back_direction != D_SOUTH)
+ dir = D_SOUTH;
+ else if (tile->getData() & Tile::WORLDMAP_EAST
+ && tux->back_direction != D_EAST)
+ dir = D_EAST;
+ else if (tile->getData() & Tile::WORLDMAP_WEST
+ && tux->back_direction != D_WEST)
+ dir = D_WEST;
+
+ if (dir != D_NONE)
+ {
+ tux->set_direction(dir);
+ //tux->update(delta);
+ }
+ }
+ }
+
+ break;
+ case GameSession::ES_LEVEL_ABORT:
+ level_finished = false;
+ /* In case the player's abort the level, keep it using the old
+ status. But the minimum lives and no bonus. */
+ player_status.coins = old_player_status.coins;
+ player_status.lives = std::min(old_player_status.lives, player_status.lives);
+ player_status.bonus = NO_BONUS;
+
+ break;
+ case GameSession::ES_GAME_OVER:
+ {
+ level_finished = false;
+ /* draw an end screen */
+ /* TODO: in the future, this should make a dialog a la SuperMario, asking
+ if the player wants to restart the world map with no score and from
+ level 1 */
+ char str[80];
+
+ DrawingContext context;
+ context.draw_gradient(Color (200,240,220), Color(200,200,220),
+ LAYER_BACKGROUND0);
+
+ context.draw_text(blue_text, _("GAMEOVER"),
+ Vector(SCREEN_WIDTH/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
+
+ sprintf(str, _("COINS: %d"), player_status.coins);
+ context.draw_text(gold_text, str,
+ Vector(SCREEN_WIDTH/2, SCREEN_WIDTH - 32), CENTER_ALLIGN,
+ LAYER_FOREGROUND1);
+
+ total_stats.draw_message_info(context, _("Total Statistics"));
+
+ context.do_drawing();
+
+ wait_for_event(2.0, 6.0);
+
+ quit = true;
+ player_status.reset();
+ break;
+ }
+ case GameSession::ES_NONE:
+ assert(false);
+ // Should never be reached
+ break;