BsGUISkin.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "BsGUISkin.h"
  2. #include "BsGUIElementStyle.h"
  3. #include "BsDebug.h"
  4. #include "BsResources.h"
  5. #include "BsGUISkinRTTI.h"
  6. namespace BansheeEngine
  7. {
  8. GUIElementStyle GUISkin::DefaultStyle;
  9. GUISkin::GUISkin()
  10. :Resource(false)
  11. { }
  12. GUISkin::GUISkin(const GUISkin& skin)
  13. :Resource(false)
  14. { }
  15. const GUIElementStyle* GUISkin::getStyle(const String& guiElemType) const
  16. {
  17. auto iterFind = mStyles.find(guiElemType);
  18. if(iterFind != mStyles.end())
  19. return &iterFind->second;
  20. LOGWRN("Cannot find GUI style with name: " + guiElemType + ". Returning default style.");
  21. return &DefaultStyle;
  22. }
  23. void GUISkin::setStyle(const String& guiElemType, const GUIElementStyle& style)
  24. {
  25. mStyles[guiElemType] = style;
  26. }
  27. HGUISkin GUISkin::create()
  28. {
  29. GUISkinPtr newSkin = _createPtr();
  30. return static_resource_cast<GUISkin>(gResources()._createResourceHandle(newSkin));
  31. }
  32. GUISkinPtr GUISkin::_createPtr()
  33. {
  34. GUISkinPtr newSkin = bs_core_ptr<GUISkin, PoolAlloc>(new (bs_alloc<GUISkin, PoolAlloc>()) GUISkin());
  35. newSkin->_setThisPtr(newSkin);
  36. newSkin->initialize();
  37. return newSkin;
  38. }
  39. RTTITypeBase* GUISkin::getRTTIStatic()
  40. {
  41. return GUISkinRTTI::instance();
  42. }
  43. RTTITypeBase* GUISkin::getRTTI() const
  44. {
  45. return GUISkin::getRTTIStatic();
  46. }
  47. }