source: trunk/src/tiler.cpp @ 790

Last change on this file since 790 was 790, checked in by sam, 9 years ago

tileset: replace the Tiler ID system with real TileSet objects. The only
thing that is still broken is the Layer <--> Map interface.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16
17namespace lol
18{
19
20/*
21 * Tiler implementation class
22 */
23
24static class TilerData
25{
26    friend class Tiler;
27
28public:
29    TilerData()
30    { }
31
32private:
33    Dict tilesets;
34}
35tilerdata;
36
37static TilerData * const data = &tilerdata;
38
39/*
40 * Public Tiler class
41 */
42
43TileSet *Tiler::Register(char const *path, vec2i size, vec2i count,
44                         float dilate)
45{
46    int id = data->tilesets.MakeSlot(path);
47    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
48
49    if (!tileset)
50    {
51        tileset = new TileSet(path, size, count, dilate);
52        data->tilesets.SetEntity(id, tileset);
53    }
54
55    return tileset;
56}
57
58void Tiler::Deregister(TileSet *tileset)
59{
60    data->tilesets.RemoveSlot(tileset);
61}
62
63} /* namespace lol */
64
Note: See TracBrowser for help on using the repository browser.