X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Flevel.cpp;h=dccfbd8702fdd4018516e97edef351f8740069a0;hb=f17ff6d7a4ebb176f264e037b12ab8adfbeb3846;hp=d6cd3c75331220ebf4d5c50ab468ce78e8279423;hpb=7ae3aef67ad305cb9c6ed584cdac6117da9eba88;p=supertux.git diff --git a/src/level.cpp b/src/level.cpp index d6cd3c753..dccfbd870 100644 --- a/src/level.cpp +++ b/src/level.cpp @@ -1,7 +1,7 @@ // $Id$ -// +// // SuperTux -// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -12,7 +12,7 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 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 @@ -29,24 +29,21 @@ #include #include -#include "video/screen.h" -#include "lisp/parser.h" -#include "lisp/lisp.h" -#include "lisp/list_iterator.h" -#include "lisp/writer.h" -#include "level.h" -#include "physic.h" -#include "sector.h" -#include "tile.h" -#include "resources.h" -#include "file_system.h" -#include "object/gameobjs.h" -#include "object/camera.h" -#include "object/tilemap.h" -#include "object/coin.h" - -// test -#include "flip_level_transformer.h" +#include "log.hpp" +#include "lisp/parser.hpp" +#include "lisp/lisp.hpp" +#include "lisp/list_iterator.hpp" +#include "lisp/writer.hpp" +#include "level.hpp" +#include "physic.hpp" +#include "sector.hpp" +#include "tile.hpp" +#include "resources.hpp" +#include "file_system.hpp" +#include "object/gameobjs.hpp" +#include "object/camera.hpp" +#include "object/tilemap.hpp" +#include "object/coin.hpp" using namespace std; @@ -79,18 +76,20 @@ Level::load(const std::string& filepath) if(token == "version") { iter.value()->get(version); if(version > 2) { - std::cerr << "Warning: level format newer than application.\n"; + log_warning << "level format newer than application" << std::endl; } } else if(token == "name") { iter.value()->get(name); } else if(token == "author") { iter.value()->get(author); + } else if(token == "on-menukey-script") { + iter.value()->get(on_menukey_script); } else if(token == "sector") { - Sector* sector = new Sector; + Sector* sector = new Sector(this); sector->parse(*(iter.lisp())); add_sector(sector); } else { - std::cerr << "Unknown token '" << token << "' in level file.\n"; + log_warning << "Unknown token '" << token << "' in level file" << std::endl; continue; } } @@ -108,7 +107,7 @@ Level::load_old_format(const lisp::Lisp& reader) reader.get("name", name); reader.get("author", author); - Sector* sector = new Sector; + Sector* sector = new Sector(this); sector->parse_old_format(reader); add_sector(sector); } @@ -127,6 +126,8 @@ Level::save(const std::string& filename) writer->write_string("name", name, true); writer->write_string("author", author); + if(on_menukey_script != "") + writer->write_string("on-menukey-script", on_menukey_script); for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) { Sector* sector = *i; @@ -181,15 +182,6 @@ Level::get_sector(size_t num) } int -Level::get_total_badguys() -{ - int total_badguys = 0; - for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) - total_badguys += (*i)->get_total_badguys(); - return total_badguys; -} - -int Level::get_total_coins() { // FIXME not really correct as coins can also be inside blocks... @@ -206,3 +198,11 @@ Level::get_total_coins() return total_coins; } +int +Level::get_total_badguys() +{ + int total_badguys = 0; + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + total_badguys += (*i)->get_total_badguys(); + return total_badguys; +}