X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap%2Flevel.cpp;h=2b61124c67cb42c211da36365caecb985c85a6dd;hb=6b0c80bde84af0bf9323320d99f2fccd7c9eeedd;hp=c4fc95113590b484d8efad36dce3bcdf3f8b4499;hpb=112f01454123c94f5627200c6819b219026f0af0;p=supertux.git diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index c4fc95113..2b61124c6 100644 --- a/src/worldmap/level.cpp +++ b/src/worldmap/level.cpp @@ -1,4 +1,4 @@ -// $Id: worldmap.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ +// $Id$ // // SuperTux // Copyright (C) 2004 Ingo Ruhnke @@ -19,49 +19,68 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include +#include #include -#include "level.hpp" +#include "worldmap/level.hpp" #include "sprite/sprite_manager.hpp" #include "sprite/sprite.hpp" #include "video/drawing_context.hpp" +#include "log.hpp" +#include "file_system.hpp" namespace WorldMapNS { -Level::Level(const std::string& basedir, const lisp::Lisp* lisp) - : solved(false), auto_path(true) +LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) + : solved(false), auto_play(false), basedir(basedir), picture_cached(false), + picture(0) { + lisp->get("name", name); lisp->get("x", pos.x); lisp->get("y", pos.y); - + lisp->get("auto-play", auto_play); + std::string spritefile = "images/worldmap/common/leveldot.sprite"; lisp->get("sprite", spritefile); sprite.reset(sprite_manager->create(spritefile)); lisp->get("extro-script", extro_script); - lisp->get("name", name); - + if (!PHYSFS_exists((basedir + name).c_str())) { - log_warning << "level file '" << name + log_warning << "level file '" << name << "' does not exist and will not be added to the worldmap" << std::endl; return; } } -Level::~Level() +LevelTile::~LevelTile() { + delete picture; } void -Level::draw(DrawingContext& context) +LevelTile::draw(DrawingContext& context) { sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1); } void -Level::update(float ) +LevelTile::update(float ) { } +const Surface* +LevelTile::get_picture() +{ + if (picture_cached) return picture; + picture_cached = true; + std::string fname = FileSystem::strip_extension(basedir + name)+".jpg"; + if (!PHYSFS_exists(fname.c_str())) { + return 0; + } + picture = new Surface(fname); + return picture; +} + }