2021-12-31 11:00:35 +08:00
|
|
|
|
#include "SkinData.h"
|
2020-10-18 00:27:23 +08:00
|
|
|
|
#include "DisplayData.h"
|
|
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
void SkinData::_onClear()
|
|
|
|
|
{
|
|
|
|
|
for (const auto& pair : displays)
|
|
|
|
|
{
|
|
|
|
|
for (const auto display : pair.second)
|
|
|
|
|
{
|
|
|
|
|
if (display != nullptr)
|
|
|
|
|
{
|
|
|
|
|
display->returnToPool();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = "";
|
|
|
|
|
displays.clear();
|
|
|
|
|
parent = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 11:00:35 +08:00
|
|
|
|
void SkinData::addDisplay(const std::string& slotName, DisplayData* value)
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
if (value != nullptr)
|
|
|
|
|
{
|
|
|
|
|
value->parent = this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
|
displays[slotName].push_back(value); // TODO clear prev
|
2020-10-18 00:27:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-31 11:00:35 +08:00
|
|
|
|
DisplayData* SkinData::getDisplay(const std::string& slotName, const std::string& displayName)
|
2020-10-18 00:27:23 +08:00
|
|
|
|
{
|
|
|
|
|
const auto slotDisplays = getDisplays(slotName);
|
|
|
|
|
if (slotDisplays != nullptr)
|
|
|
|
|
{
|
|
|
|
|
for (const auto display : *slotDisplays)
|
|
|
|
|
{
|
|
|
|
|
if (display != nullptr && display->name == displayName)
|
|
|
|
|
{
|
|
|
|
|
return display;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_END
|