X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap%2Flevel.cpp;h=fbc6b0bdbe5efda18dcffcea27909283346fc875;hb=850855bb178f8325762e7c9b1db94118cd48ad5c;hp=51f2a81b3059b3b8f0550e85a718da65a9075058;hpb=cb941f239a04ee0588c99bfcdcd6aff62e1fbc98;p=supertux.git diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index 51f2a81b3..fbc6b0bdb 100644 --- a/src/worldmap/level.cpp +++ b/src/worldmap/level.cpp @@ -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; +} + }