X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fworldmap%2Flevel.cpp;h=fbc6b0bdbe5efda18dcffcea27909283346fc875;hb=d84d73b701cc7fa2bd74f3490b9be1bf8b6f705a;hp=e6c7429a646db6f07ef88ac7fa0246f3838211b9;hpb=ff3f2e3e93b2af69c0f686f8f636ba0d66c67f73;p=supertux.git diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index e6c7429a6..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 @@ -21,16 +21,18 @@ #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_path(true), basedir(basedir), picture_cached(false), picture(0) { lisp->get("x", pos.x); lisp->get("y", pos.y); @@ -50,19 +52,33 @@ Level::Level(const std::string& basedir, const lisp::Lisp* lisp) } } -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; +} + }