You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 12 година
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include "core.h"
  14. namespace lol
  15. {
  16. /*
  17. * Tiler implementation class
  18. */
  19. static class TilerData
  20. {
  21. friend class Tiler;
  22. public:
  23. TilerData()
  24. { }
  25. private:
  26. Dict tilesets;
  27. }
  28. tilerdata;
  29. static TilerData * const data = &tilerdata;
  30. /*
  31. * Public Tiler class
  32. */
  33. TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count)
  34. {
  35. int id = data->tilesets.MakeSlot(path);
  36. TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
  37. if (!tileset)
  38. {
  39. tileset = new TileSet(path, size, count);
  40. data->tilesets.SetEntity(id, tileset);
  41. }
  42. return tileset;
  43. }
  44. TileSet *Tiler::Register(char const *path)
  45. {
  46. int id = data->tilesets.MakeSlot(path);
  47. TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id);
  48. if (!tileset)
  49. {
  50. tileset = new TileSet(path);
  51. data->tilesets.SetEntity(id, tileset);
  52. }
  53. return tileset;
  54. }
  55. void Tiler::Deregister(TileSet *tileset)
  56. {
  57. data->tilesets.RemoveSlot(tileset);
  58. }
  59. } /* namespace lol */