source: trunk/src/tiler.cpp @ 153

Last change on this file since 153 was 153, checked in by sam, 10 years ago

Factor Forge and Tiler using the new Dict class.

  • Property svn:keywords set to Id
File size: 1.0 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include "core.h"
11
12#if defined WIN32
13#   define strcasecmp _stricmp
14#endif
15
16/*
17 * Tiler implementation class
18 */
19
20static class TilerData
21{
22    friend class Tiler;
23
24public:
25    Dict tilesets;
26}
27tilerdata;
28
29static TilerData * const data = &tilerdata;
30
31/*
32 * Public Tiler class
33 */
34
35int Tiler::Register(char const *path)
36{
37    int id = data->tilesets.MakeSlot(path);
38
39    if (!data->tilesets.GetEntity(id))
40    {
41        TileSet *tileset = new TileSet(path);
42        data->tilesets.SetEntity(id, tileset);
43    }
44
45    return id + 1; /* ID 0 is for the empty tileset */
46}
47
48void Tiler::Deregister(int id)
49{
50    data->tilesets.RemoveSlot(id - 1); /* ID 0 is for the empty tileset */
51}
52
53void Tiler::BlitTile(uint32_t code, int x, int y, int z, int o)
54{
55    int id = (code >> 16) - 1; /* ID 0 is for the empty tileset */
56
57    TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
58    tileset->BlitTile(code & 0xffff, x, y, z, o);
59}
60
Note: See TracBrowser for help on using the repository browser.