X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap.cpp;h=36e04441b06f1990eb6a40e693ab88d2240cffae;hb=a15b670f9fb343da5a2398880cfacf2655aefdec;hp=3649bab511e99baa018946732c6a6563ea028af6;hpb=aec32b2eca58fcbe1a2730d79d500a44cf9043f1;p=supertux.git diff --git a/src/worldmap.cpp b/src/worldmap.cpp index 3649bab51..36e04441b 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -26,32 +26,32 @@ #include #include -#include "gettext.h" -#include "video/surface.h" -#include "video/screen.h" -#include "video/drawing_context.h" -#include "sprite/sprite_manager.h" -#include "audio/sound_manager.h" -#include "lisp/parser.h" -#include "lisp/lisp.h" -#include "lisp/list_iterator.h" -#include "lisp/writer.h" -#include "game_session.h" -#include "sector.h" -#include "worldmap.h" -#include "resources.h" -#include "misc.h" -#include "player_status.h" -#include "textscroller.h" -#include "main.h" -#include "spawn_point.h" -#include "file_system.h" -#include "gui/menu.h" -#include "gui/mousecursor.h" -#include "control/joystickkeyboardcontroller.h" -#include "object/background.h" -#include "object/tilemap.h" -#include "scripting/script_interpreter.h" +#include "gettext.hpp" +#include "video/surface.hpp" +#include "video/screen.hpp" +#include "video/drawing_context.hpp" +#include "sprite/sprite_manager.hpp" +#include "audio/sound_manager.hpp" +#include "lisp/parser.hpp" +#include "lisp/lisp.hpp" +#include "lisp/list_iterator.hpp" +#include "lisp/writer.hpp" +#include "game_session.hpp" +#include "sector.hpp" +#include "worldmap.hpp" +#include "resources.hpp" +#include "misc.hpp" +#include "player_status.hpp" +#include "textscroller.hpp" +#include "main.hpp" +#include "spawn_point.hpp" +#include "file_system.hpp" +#include "gui/menu.hpp" +#include "gui/mousecursor.hpp" +#include "control/joystickkeyboardcontroller.hpp" +#include "object/background.hpp" +#include "object/tilemap.hpp" +#include "scripting/script_interpreter.hpp" Menu* worldmap_menu = 0; @@ -352,17 +352,13 @@ WorldMap::WorldMap() tux = new Tux(this); add_object(tux); - leveldot_green - = new Surface(datadir + "/images/tiles/worldmap/leveldot_green.png", true); - leveldot_red - = new Surface(datadir + "/images/tiles/worldmap/leveldot_red.png", true); - messagedot - = new Surface(datadir + "/images/tiles/worldmap/messagedot.png", true); - teleporterdot - = new Surface(datadir + "/images/tiles/worldmap/teleporterdot.png", true); + leveldot_green= new Surface("images/tiles/worldmap/leveldot_green.png", true); + leveldot_red = new Surface("images/tiles/worldmap/leveldot_red.png", true); + messagedot = new Surface("images/tiles/worldmap/messagedot.png", true); + teleporterdot = new Surface("images/tiles/worldmap/teleporterdot.png", true); name = ""; - music = "salcon.mod"; + music = "salcon.ogg"; intro_displayed = false; total_stats.reset(); @@ -415,12 +411,11 @@ WorldMap::load_map() try { lisp::Parser parser; - std::string filename = get_resource_filename(map_filename); - std::auto_ptr root (parser.parse(filename)); + std::auto_ptr root (parser.parse(map_filename)); const lisp::Lisp* lisp = root->get_lisp("supertux-worldmap"); if(!lisp) - throw new std::runtime_error("file isn't a supertux-worldmap file."); + throw std::runtime_error("file isn't a supertux-worldmap file."); clear_objects(); lisp::ListIterator iter(lisp); @@ -548,8 +543,7 @@ WorldMap::get_level_title(Level& level) try { lisp::Parser parser; - std::auto_ptr root ( - parser.parse(get_resource_filename(levels_path + level.name))); + std::auto_ptr root (parser.parse(levels_path + level.name)); const lisp::Lisp* level_lisp = root->get_lisp("supertux-level"); if(!level_lisp) @@ -719,7 +713,7 @@ WorldMap::update(float delta) if (special_tile->teleport_dest != Vector(-1,-1)) { // TODO: an animation, camera scrolling or a fading would be a nice touch - sound_manager->play_sound("warp"); + sound_manager->play("sounds/warp.ogg"); tux->back_direction = D_NONE; tux->set_tile_pos(special_tile->teleport_dest); SDL_Delay(1000); @@ -740,12 +734,13 @@ WorldMap::update(float delta) if (level->pos == tux->get_tile_pos()) { + sound_manager->stop_music(); PlayerStatus old_player_status = player_status; // do a shriking fade to the level shrink_fade(Vector((level->pos.x*32 + 16 + offset.x), (level->pos.y*32 + 16 + offset.y)), 500); - GameSession session(get_resource_filename(levels_path + level->name), + GameSession session(levels_path + level->name, ST_GL_LOAD_LEVEL_FILE, &level->statistics); switch (session.run()) @@ -834,7 +829,7 @@ WorldMap::update(float delta) break; } - sound_manager->play_music(song); + sound_manager->play_music(std::string("music/") + music); Menu::set_current(0); if (!savegame_file.empty()) savegame(savegame_file); @@ -847,8 +842,7 @@ WorldMap::update(float delta) std::auto_ptr interpreter (new ScriptInterpreter(levels_path)); std::istringstream in(level->extro_script); - interpreter->load_script(in, "level-extro-script"); - interpreter->start_script(); + interpreter->run_script(in, "level-extro-script"); add_object(interpreter.release()); } catch(std::exception& e) { std::cerr << "Couldn't run level-extro-script:" << e.what() << "\n"; @@ -977,7 +971,7 @@ WorldMap::draw_status(DrawingContext& context) } } /* Display a passive message in the map, if needed */ - if(passive_message_timer.check()) + if(passive_message_timer.started()) context.draw_text(gold_text, passive_message, Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - white_text->get_height() - 60), CENTER_ALLIGN, LAYER_FOREGROUND1); @@ -992,16 +986,14 @@ WorldMap::display() quit = false; - song = sound_manager->load_music(datadir + "/music/" + music); - sound_manager->play_music(song); + sound_manager->play_music(std::string("music/") + music); if(!intro_displayed && intro_script != "") { try { std::auto_ptr interpreter (new ScriptInterpreter(levels_path)); std::istringstream in(intro_script); - interpreter->load_script(in, "worldmap-intro-script"); - interpreter->start_script(); + interpreter->run_script(in, "worldmap-intro-script"); add_object(interpreter.release()); } catch(std::exception& e) { std::cerr << "Couldn't execute worldmap-intro-script: " @@ -1016,7 +1008,7 @@ WorldMap::display() while(!quit) { Uint32 ticks = SDL_GetTicks(); float elapsed_time = float(ticks - lastticks) / 1000; - global_time += elapsed_time; + game_time += elapsed_time; lastticks = ticks; // 40 fps minimum // TODO use same code as in GameSession here @@ -1043,6 +1035,7 @@ WorldMap::display() context.pop_transform(); get_input(); update(elapsed_time); + sound_manager->update(); if(Menu::current()) { Menu::current()->draw(context); @@ -1058,8 +1051,7 @@ WorldMap::savegame(const std::string& filename) if(filename == "") return; - std::ofstream file(filename.c_str(), std::ios::out); - lisp::Writer writer(file); + lisp::Writer writer(filename); int nb_solved_levels = 0, total_levels = 0; for(Levels::iterator i = levels.begin(); i != levels.end(); ++i) {