X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fworldmap%2Flevel.cpp;h=85e987f2140989237aa3659b3ac48454ae210b5c;hb=7be55d4d3cfdeea2c68405c4b2a1999b8e246331;hp=67a1ba91a3780e47385fd79d5d719592924409c4;hpb=52de79ad8301a395a5a2999ecbdf31731c0b65f8;p=supertux.git diff --git a/src/worldmap/level.cpp b/src/worldmap/level.cpp index 67a1ba91a..85e987f21 100644 --- a/src/worldmap/level.cpp +++ b/src/worldmap/level.cpp @@ -1,13 +1,11 @@ -// $Id: worldmap.hpp 3327 2006-04-13 15:02:40Z ravu_al_hemio $ -// // SuperTux -// Copyright (C) 2004 Ingo Ruhnke +// Copyright (C) 2004 Ingo Ruhnke // Copyright (C) 2006 Christoph Sommer // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,43 +13,58 @@ // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// along with this program. If not, see . #include -#include #include -#include "worldmap/level.hpp" -#include "sprite/sprite_manager.hpp" +#include + #include "sprite/sprite.hpp" +#include "sprite/sprite_manager.hpp" +#include "util/file_system.hpp" +#include "util/log.hpp" +#include "util/reader.hpp" #include "video/drawing_context.hpp" +#include "worldmap/level.hpp" -namespace WorldMapNS -{ +namespace worldmap { -LevelTile::LevelTile(const std::string& basedir, const lisp::Lisp* lisp) - : solved(false), auto_path(true) +LevelTile::LevelTile(const std::string& basedir_, const Reader& lisp) : + pos(), + title(), + solved(false), + perfect(false), + auto_play(false), + sprite(), + statistics(), + target_time(), + extro_script(), + basedir(basedir_), + picture_cached(false), + picture(0) { - lisp->get("x", pos.x); - lisp->get("y", pos.y); - + 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("sprite", spritefile); + sprite = SpriteManager::current()->create(spritefile); - lisp->get("extro-script", extro_script); - lisp->get("name", name); - - if (!PHYSFS_exists((basedir + name).c_str())) + lisp.get("extro-script", extro_script); + + if (!PHYSFS_exists((basedir_ + name).c_str())) { - log_warning << "level file '" << name - << "' does not exist and will not be added to the worldmap" << std::endl; + log_warning << "level file '" << name + << "' does not exist and will not be added to the worldmap" << std::endl; return; } } LevelTile::~LevelTile() { + delete picture; } void @@ -65,4 +78,37 @@ LevelTile::update(float ) { } +void +LevelTile::update_sprite_action() +{ + if (perfect) + { + sprite->set_action("perfect"); + } + else if (solved) + { + sprite->set_action("perfect"); + } + else + { + sprite->set_action("default"); + } +} + +void +LevelTile::set_solved(bool v) +{ + solved = v; + update_sprite_action(); } + +void +LevelTile::set_perfect(bool v) +{ + perfect = v; + update_sprite_action(); +} + +} // namespace worldmap + +/* EOF */