| 197 | } |
| 198 | |
| 199 | void SkinExportSerializer::fillStateData(DataPtr _data, pugi::xml_node _node) |
| 200 | { |
| 201 | using MapPoint = std::map<std::string, MyGUI::IntPoint, std::less<>>; |
| 202 | MapPoint values; |
| 203 | |
| 204 | pugi::xpath_node_set states = _node.select_nodes("BasisSkin/State"); |
| 205 | for (auto state : states) |
| 206 | { |
| 207 | MyGUI::IntCoord coord((std::numeric_limits<int>::max)(), (std::numeric_limits<int>::max)(), 0, 0); |
| 208 | |
| 209 | pugi::xml_attribute attribute = state.node().attribute("offset"); |
| 210 | if (!attribute.empty()) |
| 211 | coord = MyGUI::IntCoord::parse(attribute.value()); |
| 212 | |
| 213 | std::string_view name = state.node().attribute("name").value(); |
| 214 | MapPoint::iterator valuesIterator = values.find(name); |
| 215 | if (valuesIterator != values.end()) |
| 216 | { |
| 217 | (*valuesIterator).second = MyGUI::IntPoint( |
| 218 | (std::min)((*valuesIterator).second.left, coord.left), |
| 219 | (std::min)((*valuesIterator).second.top, coord.top)); |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | values.emplace(name, coord.point()); |
| 224 | } |
| 225 | |
| 226 | // create, if there is no data |
| 227 | name = convertExportToEditorStateName(name); |
| 228 | DataPtr childData = getChildData(_data, "State", name); |
| 229 | if (childData == nullptr) |
| 230 | { |
| 231 | childData = Data::CreateInstance(); |
| 232 | childData->setType(DataTypeManager::getInstance().getType("State")); |
| 233 | childData->setPropertyValue("Name", name); |
| 234 | _data->addChild(childData); |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | for (const auto& child : _data->getChilds()) |
| 239 | { |
| 240 | if (child->getType()->getName() != "State") |
| 241 | continue; |
| 242 | |
| 243 | MapPoint::iterator result = values.find(convertEditorToExportStateName(child->getPropertyValue("Name"))); |
| 244 | if (result != values.end()) |
| 245 | { |
| 246 | child->setPropertyValue("Visible", "True"); |
| 247 | if ((*result).second.left != (std::numeric_limits<int>::max)() && |
| 248 | (*result).second.top != (std::numeric_limits<int>::max)()) |
| 249 | child->setPropertyValue("Point", (*result).second); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | states = _node.select_nodes("BasisSkin/State[@colour]"); |
| 254 | for (auto state : states) |
| 255 | { |
| 256 | std::string_view name = state.node().attribute("name").value(); |
nothing calls this directly
no test coverage detected