4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 #ifndef HEADER_TILE_MANAGER_HXX
22 #define HEADER_TILE_MANAGER_HXX
33 friend bool operator<(const TileGroup& lhs, const TileGroup& rhs)
34 { return lhs.name < rhs.name; };
35 friend bool operator>(const TileGroup& lhs, const TileGroup& rhs)
36 { return lhs.name > rhs.name; };
39 std::vector<int> tiles;
48 typedef std::map<int, Tile*> Tiles;
51 static TileManager* instance_ ;
52 static std::set<TileGroup>* tilegroups_;
53 void load_tileset(std::string filename);
55 std::string current_tileset;
58 static TileManager* instance()
59 { return instance_ ? instance_ : instance_ = new TileManager(); }
60 static void destroy_instance()
61 { delete instance_; instance_ = 0; }
63 void draw_tile(DrawingContext& context, unsigned int id,
64 const Vector& pos, int layer);
66 static std::set<TileGroup>* tilegroups() { if(!instance_) { instance_ = new TileManager(); } return tilegroups_ ? tilegroups_ : tilegroups_ = new std::set<TileGroup>; }
68 unsigned int total_ids()
69 { return tiles.size(); }
71 Tile* get(unsigned int id);