X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap%2Flevel.cpp;h=fbc6b0bdbe5efda18dcffcea27909283346fc875;hb=d84d73b701cc7fa2bd74f3490b9be1bf8b6f705a;hp=67a1ba91a3780e47385fd79d5d719592924409c4;hpb=52de79ad8301a395a5a2999ecbdf31731c0b65f8;p=supertux.git diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index 67a1ba91a..fbc6b0bdb 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 @@ -25,12 +25,14 @@ #include "sprite/sprite_manager.hpp" #include "sprite/sprite.hpp" #include "video/drawing_context.hpp" +#include "log.hpp" +#include "file_system.hpp" namespace WorldMapNS { LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) - : solved(false), auto_path(true) + : solved(false), auto_path(true), basedir(basedir), picture_cached(false), picture(0) { lisp->get("x", pos.x); lisp->get("y", pos.y); @@ -52,6 +54,7 @@ LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) LevelTile::~LevelTile() { + delete picture; } void @@ -65,4 +68,17 @@ 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; +} + }