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.

forge.cpp 976 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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://www.wtfpl.net/ for more details.
  9. //
  10. #include <lol/engine-internal.h>
  11. namespace lol
  12. {
  13. /*
  14. * Forge implementation class
  15. */
  16. static class ForgeData
  17. {
  18. friend class Forge;
  19. public:
  20. Dict fonts;
  21. }
  22. forgedata;
  23. static ForgeData * const data = &forgedata;
  24. /*
  25. * Public Forge class
  26. */
  27. int Forge::Register(char const *path)
  28. {
  29. int id = data->fonts.MakeSlot(path);
  30. if (!data->fonts.GetEntity(id))
  31. {
  32. Font *font = new Font(path);
  33. data->fonts.SetEntity(id, font);
  34. }
  35. return id;
  36. }
  37. void Forge::Deregister(int id)
  38. {
  39. data->fonts.RemoveSlot(id);
  40. }
  41. Font *Forge::GetFont(int id)
  42. {
  43. return (Font *)data->fonts.GetEntity(id);
  44. }
  45. } /* namespace lol */