25 SkinManager::SkinManager() :
26 mSingletonHolder(this),
27 mXmlSkinTagName(
"Skin"),
28 mXmlDefaultSkinValue(
"Default")
32 void SkinManager::initialise()
34 MYGUI_ASSERT(!mIsInitialise, getClassTypeName() <<
" initialised twice");
35 MYGUI_LOG(Info,
"* Initialise: " << getClassTypeName());
37 ResourceManager::getInstance().registerLoadXmlDelegate(mXmlSkinTagName) =
38 newDelegate(
this, &SkinManager::_load);
40 const std::string& resourceCategory = ResourceManager::getInstance().getCategoryName();
41 FactoryManager::getInstance().registerFactory<ResourceSkin>(resourceCategory);
43 mDefaultName =
"skin_Default";
44 createDefault(mDefaultName);
46 MYGUI_LOG(Info, getClassTypeName() <<
" successfully initialized");
50 void SkinManager::shutdown()
52 MYGUI_ASSERT(mIsInitialise, getClassTypeName() <<
" is not initialised");
53 MYGUI_LOG(Info,
"* Shutdown: " << getClassTypeName());
55 ResourceManager::getInstance().unregisterLoadXmlDelegate(mXmlSkinTagName);
57 const std::string& resourceCategory = ResourceManager::getInstance().getCategoryName();
58 FactoryManager::getInstance().unregisterFactory<ResourceSkin>(resourceCategory);
60 MYGUI_LOG(Info, getClassTypeName() <<
" successfully shutdown");
61 mIsInitialise =
false;
64 void SkinManager::_load(xml::ElementPtr _node, std::string_view _file, Version _version)
66#ifndef MYGUI_DONT_USE_OBSOLETE
67 loadOldSkinFormat(_node, _file, _version, mXmlSkinTagName);
71 void SkinManager::createDefault(std::string_view _value)
73 const std::string& resourceCategory = ResourceManager::getInstance().getCategoryName();
74 ResourceSkin* skin = FactoryManager::getInstance().createObject<ResourceSkin>(resourceCategory);
76 skin->setResourceName(_value);
77 ResourceManager::getInstance().addResource(skin);
80 ResourceSkin* SkinManager::getByName(std::string_view _name)
const
82 std::string_view skinName = BackwardCompatibility::getSkinRename(_name);
83 IResource* result =
nullptr;
84 if (!skinName.empty() && skinName != mXmlDefaultSkinValue)
85 result = ResourceManager::getInstance().getByName(skinName,
false);
87 if (result ==
nullptr)
89 result = ResourceManager::getInstance().getByName(mDefaultName,
false);
90 if (!skinName.empty() && skinName != mXmlDefaultSkinValue)
94 "Skin '" << skinName <<
"' not found. Replaced with default skin."
95 <<
" [" << LayoutManager::getInstance().getCurrentLayout() <<
"]");
99 return result ? result->castType<ResourceSkin>(
false) : nullptr;
102 bool SkinManager::isExist(std::string_view _name)
const
104 std::string_view skinName = BackwardCompatibility::getSkinRename(_name);
105 IResource* result = ResourceManager::getInstance().getByName(skinName,
false);
106 return (result !=
nullptr) && (result->isType<ResourceSkin>());
109 void SkinManager::setDefaultSkin(std::string_view _value)
111 mDefaultName = _value;
114 const std::string& SkinManager::getDefaultSkin()
const
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_LOG(level, text)
MYGUI_SINGLETON_DEFINITION(ClipboardManager)