/// <summary> /// Dump the ActionMaps as partial XML nicely formatted /// </summary> /// <returns>the action as XML fragment</returns> public String toXML( ) { log.Debug("toXML - Entry"); AppSettings appSettings = new AppSettings( ); // handle the versioning of the actionmaps String r = "<ActionMaps "; if (!String.IsNullOrEmpty(ignoreversion)) { r += String.Format("ignoreVersion=\"{0}\" \n", ignoreversion); } else if (appSettings.ForceIgnoreversion) { ignoreversion = "1"; // preset if missing r += String.Format("ignoreVersion=\"{0}\" \n", ignoreversion); } else if (!String.IsNullOrEmpty(version)) { r += String.Format("version=\"{0}\" \n", version); } else { version = ACM_VERSION; // preset if missing r += String.Format("version=\"{0}\" \n", version); } // now the devices (our addition) for (int i = 0; i < JoystickCls.JSnum_MAX; i++) { if (!String.IsNullOrEmpty(jsN[i])) { r += String.Format("\tjs{0}=\"{1}\" ", i + 1, jsN[i]); } if (!String.IsNullOrEmpty(jsNGUID[i])) { r += String.Format("js{0}G=\"{1}\" \n", i + 1, jsNGUID[i]); } } // close the tag r += String.Format(">\n"); // and dump the option contents if (m_uiCustHeader.Count > 0) { r += m_uiCustHeader.toXML( ) + String.Format("\n"); } if (m_options.Count > 0) { r += m_options.toXML( ) + String.Format("\n"); } if (m_deviceOptions.Count > 0) { r += m_deviceOptions.toXML( ) + String.Format("\n"); } // finally the action maps foreach (ActionMapCls amc in this) { r += String.Format("{0}\n", amc.toXML( )); } r += String.Format("</ActionMaps>\n"); return(r); }
/// <summary> /// Dump the ActionMaps as partial XML nicely formatted /// </summary> /// <returns>the action as XML fragment</returns> public string toXML(string fileName) { log.Debug("ActionMapsCls.toXML - Entry"); AppSettings appSettings = new AppSettings( ); // *** HEADER // handle the versioning of the actionmaps // AC2 do not longer support ignoreversion... enter the new fixed header string r = "<ActionMaps " + ACM_VERSION; r += string.Format(" profileName=\"{0}\" \n", fileName.Replace(SCMappings.c_MapStartsWith, "")); //AC2 add profilename // now the devices (our addition) for (int i = 0; i < JoystickCls.JSnum_MAX; i++) { if (!string.IsNullOrEmpty(jsN[i])) { r += string.Format("\tjs{0}=\"{1}\" ", i + 1, jsN[i]); } if (!string.IsNullOrEmpty(jsNGUID[i])) { r += string.Format("js{0}G=\"{1}\" \n", i + 1, jsNGUID[i]); } } // close the tag r += string.Format(">\n"); // *** CustomisationUIHeader // and dump the option contents - prepare with new data m_uiCustHeader.ClearInstances( ); UICustHeader.DevRec dr = new UICustHeader.DevRec( ); dr.devType = KeyboardCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances(dr); dr.devType = MouseCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances(dr); // do we use Gamepad ?? if (GamepadCls.RegisteredDevices > 0) { dr.devType = GamepadCls.DeviceClass; dr.instNo = 1; m_uiCustHeader.AddInstances(dr); } // all Joysticks for (int i = 0; i < JoystickCls.JSnum_MAX; i++) { if (!string.IsNullOrEmpty(jsN[i])) { dr.devType = JoystickCls.DeviceClass; dr.instNo = i + 1; m_uiCustHeader.AddInstances(dr); } } m_uiCustHeader.Label = fileName.Replace(SCMappings.c_MapStartsWith, ""); // remove redundant part r += m_uiCustHeader.toXML( ) + string.Format("\n"); // *** OPTIONS foreach (KeyValuePair <string, OptionTree> kv in m_tuningOptions) { if (kv.Value.Count > 0) { r += kv.Value.toXML( ) + string.Format("\n"); } } // *** DEVICE OPTIONS if (m_deviceOptions.Count > 0) { r += m_deviceOptions.toXML( ) + string.Format("\n"); } // *** ACTION MAPS foreach (ActionMapCls amc in this) { r += string.Format("{0}\n", amc.toXML( )); } r += string.Format("</ActionMaps>\n"); // tidy up.. return(r.Replace(string.Format("\n\n"), string.Format("\n"))); }