00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <config.h>
00018
00019 #include <physfs.h>
00020 #include <stddef.h>
00021
00022 #include "sprite/sprite.hpp"
00023 #include "sprite/sprite_manager.hpp"
00024 #include "util/file_system.hpp"
00025 #include "util/log.hpp"
00026 #include "util/reader.hpp"
00027 #include "video/drawing_context.hpp"
00028 #include "worldmap/level.hpp"
00029
00030 namespace worldmap {
00031
00032 LevelTile::LevelTile(const std::string& basedir, const Reader& lisp) :
00033 pos(),
00034 title(),
00035 solved(false),
00036 auto_play(false),
00037 sprite(),
00038 statistics(),
00039 extro_script(),
00040 basedir(basedir),
00041 picture_cached(false),
00042 picture(0)
00043 {
00044 lisp.get("name", name);
00045 lisp.get("x", pos.x);
00046 lisp.get("y", pos.y);
00047 lisp.get("auto-play", auto_play);
00048
00049 std::string spritefile = "images/worldmap/common/leveldot.sprite";
00050 lisp.get("sprite", spritefile);
00051 sprite = sprite_manager->create(spritefile);
00052
00053 lisp.get("extro-script", extro_script);
00054
00055 if (!PHYSFS_exists((basedir + name).c_str()))
00056 {
00057 log_warning << "level file '" << name
00058 << "' does not exist and will not be added to the worldmap" << std::endl;
00059 return;
00060 }
00061 }
00062
00063 LevelTile::~LevelTile()
00064 {
00065 delete picture;
00066 }
00067
00068 void
00069 LevelTile::draw(DrawingContext& context)
00070 {
00071 sprite->draw(context, pos*32 + Vector(16, 16), LAYER_OBJECTS - 1);
00072 }
00073
00074 void
00075 LevelTile::update(float )
00076 {
00077 }
00078
00079 }
00080
00081