Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

78 wiersze
1.4 KiB

  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 */