Guest User

Untitled

a guest
Oct 10th, 2015
110
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Writes the trigger data.
  2. for (auto trigger : writerData->m_LayerManager->m_LevelEditorTriggers)
  3. {
  4.     rapidxml::xml_node<>* triggerElement = levelDocument->allocate_node(rapidxml::node_element, "Trigger");
  5.     levelElement->append_node(triggerElement);
  6.  
  7.     // Saves the name of the trigger.
  8.     PXMLUtil::AddAttribute(triggerElement, levelDocument, "name", trigger->GetTriggerName());
  9.     // Saves the dimensions of the rect of the trigger.
  10.     PXMLUtil::AddAttribute(triggerElement, levelDocument, "x", TString((int)trigger->GetTriggerRect().X));
  11.     PXMLUtil::AddAttribute(triggerElement, levelDocument, "y", TString((int)trigger->GetTriggerRect().Y));
  12.     PXMLUtil::AddAttribute(triggerElement, levelDocument, "w", TString((int)trigger->GetTriggerRect().W));
  13.     PXMLUtil::AddAttribute(triggerElement, levelDocument, "h", TString((int)trigger->GetTriggerRect().H));
  14.  
  15.     // Saves the actions and their properties.
  16.     for (auto triggerAction : trigger->GetTriggerActions())
  17.     {
  18.         rapidxml::xml_node<>* actionElement = levelDocument->allocate_node(rapidxml::node_element, "Action");
  19.         triggerElement->append_node(actionElement);
  20.  
  21.         // Saves the type of the action.
  22.         PXMLUtil::AddAttribute(actionElement, levelDocument, "type", g_LevelTriggerActionTypeNames[(int)triggerAction->m_ActionType]);
  23.         // Then saves the properties.
  24.         for (auto property : triggerAction->m_ActionData->GetActionProperties())
  25.         {
  26.             // Creates the property element.
  27.             rapidxml::xml_node<>* propertyElement = levelDocument->allocate_node(rapidxml::node_element, "Property");
  28.             actionElement->append_node(propertyElement);
  29.  
  30.             // Saves the name of the property.
  31.             PXMLUtil::AddAttribute(propertyElement, levelDocument, "name", property->m_PropertyName);
  32.             // Then saves the value of the property.
  33.             PXMLUtil::AddAttribute(propertyElement, levelDocument, "value", property->PropertyValueToString());
  34.         }
  35.     }
  36. }
RAW Paste Data