Example #1
0
 private static void LoadScene(DataElement sceneElement, Scene scene, ShapeTemplatesSet templates)
 {
   scene.Size = Vector2f.Parse(sceneElement.GetAttribValue("size"));
   DataElement shapesEl = sceneElement.GetChild("shapes");
   foreach(DataElement shapeEl in shapesEl.CollectChildren("shape"))
   {
     string name = shapeEl.GetAttribValue("name");
     Shape shape = scene.CreateShape(name);
     LoadShape(shapeEl, shape, templates);
   }
   
   DataElement propertiesContainer = sceneElement.GetChild("properties");
   if(propertiesContainer != null)
   {
     LoadUserProperties(propertiesContainer, scene);
   }
 }
Example #2
0
    private static void LoadShape(DataElement node, Shape shape, ShapeTemplatesSet templates)
    {
      string templateName = node.GetAttribValue("template_name");
      ShapeTemplate template = templates.FindTemplate(templateName);
      shape.Template = template;
      shape.ZOrder = float.Parse(node.GetAttribValue("z_order"));

      string colorStr = node.GetAttribValue("color");
      if(colorStr != null)
      {
        shape.Color = Color.FromArgb(int.Parse(colorStr));
      }

      if(shape.EditableColor)
      {
        node.CreateAttribute("color", shape.Color.ToArgb().ToString());
      }

      DataElement circlesEl = node.GetChild("circles");
      IList<DataElement> circleElList = circlesEl.CollectChildren("circle");
      IList<ShapeCircle> circles = shape.Circles;
      for(int index = 0; index < circleElList.Count; ++index)
      {
        DataElement circleEl = circleElList[index];
        ShapeCircle circle = circles[index];
        LoadShapeCircle(circleEl, circle);
      }
      
      DataElement userPropertiesEl = node.GetChild("user_properties");
      LoadUserProperties(userPropertiesEl, shape);
    }
Example #3
0
    private static void LoadBaseTemplate(DataElement node, ShapeTemplate template)
    {
      string colorStr = node.GetAttribValue("color");
      string backgroudStr = node.GetAttribValue("background");
      template.Color = Color.FromArgb(int.Parse(colorStr));
      template.Backgroud = bool.Parse(backgroudStr);

      string editableColorStr = node.GetAttribValue("editable_color");
      if(editableColorStr != null)
      {
        template.EditableColor = bool.Parse(editableColorStr);
      }
      
      DataElement circlesEl = node.GetChild("circles");
      List<ShapeCircle> allCircles = template.RootCircle.AllCircles;
      int index = 0;
      foreach(DataElement circleEl in circlesEl.CollectChildren("circle"))
      {
        string positionStr = circleEl.GetAttribValue("position");
        string radiusStr = circleEl.GetAttribValue("radius");
        string angleStr = circleEl.GetAttribValue("angle");
        ShapeCircle circle = allCircles[index];
        circle.Position = Vector2f.Parse(positionStr);
        circle.Radius = float.Parse(radiusStr);
        circle.Angle = float.Parse(angleStr);
        ++index;
      }
      
      DataElement circlesSettingsEl = node.GetChild("circles_settings");
      index = 0;
      foreach(DataElement circleSettingsEl in circlesSettingsEl.CollectChildren("settings"))
      {
        ShapeTemplate.ShapeCircleSettings settings = template.PerCircleSettings[index];
        string enableOffsetStr = circleSettingsEl.GetAttribValue("enable_offset");
        string enableRotateStr = circleSettingsEl.GetAttribValue("enable_rotate");
        settings.EnableOffset = bool.Parse(enableOffsetStr);
        settings.EnableRotate = bool.Parse(enableRotateStr);
        ++index;
      }
    }