public Mapping(string id, string label, MappingProcessor processor, IMappingOutput[] outputs) { Id = id; Label = label; Processor = processor; Outputs = new List<IMappingOutput>(outputs); Feedback = new MappingFeedback(this); Feedback.Mode = (FeedbackMode) processor.GetFeedbackMode(); Feedback.IsBoolean = processor.IsBoolean; Feedback.Effect = processor.Effect; Feedback.Label = processor.Label; Feedback.ShowLabel = processor.LabelFeedback; }
MappingProcessor ReadXmlProcessor(XmlNode xmlProc, MappingProcessor parentProcessor) { string id = AttrAsString(xmlProc, "id", ""); string label = AttrAsString(xmlProc, "label", ""); bool showFeedback = AttrAsBool(xmlProc, "showFeedback", true); bool labelFeedback = AttrAsBool(xmlProc, "labelFeedback", true); string type = xmlProc.Attributes["type"].Value; string filter = AttrAsString(xmlProc, "filter", "none"); string effect = AttrAsString(xmlProc, "effect", "none"); string op = AttrAsString(xmlProc, "operator", "and"); int minValue = int.Parse(AttrAsString(xmlProc, "minValue", "-5555")); int maxValue = int.Parse(AttrAsString(xmlProc, "maxValue", "-5555")); string overflow = AttrAsString(xmlProc, "overflow", "clip"); string action = AttrAsString(xmlProc, "action", "none"); string file = AttrAsString(xmlProc, "file", ""); string setId = AttrAsString(xmlProc, "setId", ""); string inactive = AttrAsString(xmlProc, "inactive", "null"); string parentAxis = parentProcessor != null ? Tokens.axisToken[parentProcessor.Axis] : "x"; string axis = AttrAsString(xmlProc, "axis", parentAxis); var p = new MappingProcessor( id, label, showFeedback, labelFeedback, type, filter, op, overflow, effect, axis, action, inactive); if(minValue != -5555) p.MinValue = minValue; if(maxValue != -5555) p.MaxValue = maxValue; if(p.Action != Tokens.NONE) { p.File = file; p.SetId = setId; } var elems = new List<MappingElement>(); foreach(XmlNode element in xmlProc.SelectNodes("/Element")) elems.Add(ReadXmlElement(element, p)); if(elems.Count > 0) { p.elements = elems; p.SetGroup(false); } var procs = new List<MappingProcessor>(); foreach(XmlNode processor in xmlProc.SelectNodes("/Processor")) procs.Add(ReadXmlProcessor(processor, p)); if(procs.Count > 0) { p.processors = procs; p.SetGroup(true); } return p; }
MappingElement ReadXmlElement(XmlNode xmlElem, MappingProcessor parentProcessor) { return new MappingElement( xmlElem.Attributes["type"].Value, int.Parse(AttrAsString(xmlElem, "userId", "0")), xmlElem.Attributes["target"].Value, AttrAsString(xmlElem, "property", "position"), AttrAsString(xmlElem, "axis", ((parentProcessor != null) ? Tokens.axisToken[parentProcessor.Axis] : "x")), int.Parse(AttrAsString(xmlElem, "value", "0")), new Vector4() { X = int.Parse(AttrAsString(xmlElem, "x", "0")), Y = int.Parse(AttrAsString(xmlElem, "y", "0")), Z = int.Parse(AttrAsString(xmlElem, "z", "0")) } ); }