X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftile_manager.hpp;h=bcdb920016e7b1608c0b30aba5829b336a4fe4b9;hb=f50304d44b36b39dc50a6de31de62d46198e88ad;hp=5cd6fc2dc98011d6d7fe51c22bc2e8c2e8b5965d;hpb=67690e081c28b818e94796be284206326bc8a6b9;p=supertux.git diff --git a/src/tile_manager.hpp b/src/tile_manager.hpp index 5cd6fc2dc..bcdb92001 100644 --- a/src/tile_manager.hpp +++ b/src/tile_manager.hpp @@ -1,7 +1,7 @@ // $Id$ -// +// // SuperTux -// Copyright (C) 2004 Tobias Glaesser +// Copyright (C) 2008 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,88 +12,45 @@ // 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 // 02111-1307, USA. +#ifndef HEADER_TILE_MANAGER_HPP +#define HEADER_TILE_MANAGER_HPP -#ifndef HEADER_TILE_MANAGER_HXX -#define HEADER_TILE_MANAGER_HXX - -#include #include #include #include #include #include #include -#include "msg.hpp" -#include "tile.hpp" +#include "log.hpp" -struct TileGroup -{ - friend bool operator<(const TileGroup& lhs, const TileGroup& rhs) - { return lhs.name < rhs.name; }; - friend bool operator>(const TileGroup& lhs, const TileGroup& rhs) - { return lhs.name > rhs.name; }; +namespace lisp { +class Lisp; +} - std::string name; - std::vector tiles; -}; +class TileSet; class TileManager { private: - typedef std::vector Tiles; - Tiles tiles; - - static TileManager* instance_ ; - std::set tilegroups; - - std::string tiles_path; - - void load_tileset(std::string filename); + typedef std::map TileSets; + TileSets tilesets; public: - TileManager(const std::string& filename); + TileManager(); ~TileManager(); - const std::set& get_tilegroups() const - { - return tilegroups; - } - - const Tile* get(uint32_t id) const - { - //FIXME: Commenting out tiles in sprites.strf makes tiles.size() fail - it's being set to the first tile commented out. - assert(id < tiles.size()); - Tile* tile = tiles[id]; - if(!tile) { - msg_warning << "Invalid tile: " << id << std::endl; - return tiles[0]; - } - - if(tile->images.size() == 0 && tile->imagespecs.size() != 0) - tile->load_images(tiles_path); - - return tile; - } + TileSet* get_tileset(const std::string &filename); - uint32_t get_max_tileid() const - { - return tiles.size(); - } - - int get_default_width() const - { - return 32; - } - - int get_default_height() const - { - return 32; - } + TileSet* parse_tileset_definition(const lisp::Lisp& reader); }; +extern TileManager *tile_manager; +/** this is only set while loading a map */ +extern TileSet *current_tileset; + #endif