X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftile_manager.hpp;h=bcdb920016e7b1608c0b30aba5829b336a4fe4b9;hb=198f758764fff064a47630b5d0f1e3d6aabe95a8;hp=aaf8a81394ae33aecb2749b9a22d5b6ccaf5f607;hpb=7c579d3ef0a6667c18b53dad84c63c05d2760a84;p=supertux.git diff --git a/src/tile_manager.hpp b/src/tile_manager.hpp index aaf8a8139..bcdb92001 100644 --- a/src/tile_manager.hpp +++ b/src/tile_manager.hpp @@ -1,8 +1,7 @@ // $Id$ // // SuperTux -// Copyright (C) 2004 Tobias Glaesser -// Copyright (C) 2006 Matthias Braun +// 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 @@ -18,85 +17,40 @@ // 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 #include "log.hpp" -#include "tile.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) { - log_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; - } - - uint32_t get_max_tileid() const - { - return tiles.size(); - } - - int get_default_width() const - { - return 32; - } + TileSet* get_tileset(const std::string &filename); - int get_default_height() const - { - return 32; - } + TileSet* parse_tileset_definition(const lisp::Lisp& reader); }; -extern TileManager* tile_manager; +extern TileManager *tile_manager; +/** this is only set while loading a map */ +extern TileSet *current_tileset; #endif