source: trunk/src/tiler.cpp @ 2370

Last change on this file since 2370 was 2216, checked in by touky, 7 years ago

New year copyright update.

  • Property svn:keywords set to Id
File size: 1.1 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 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://www.wtfpl.net/ 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, ivec2 size, ivec2 count)
44{
45    int id = data->tilesets.MakeSlot(path);
46    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
47
48    if (!tileset)
49    {
50        tileset = new TileSet(path, size, count);
51        data->tilesets.SetEntity(id, tileset);
52    }
53
54    return tileset;
55}
56
57void Tiler::Deregister(TileSet *tileset)
58{
59    data->tilesets.RemoveSlot(tileset);
60}
61
62} /* namespace lol */
63
Note: See TracBrowser for help on using the repository browser.