Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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
            if (m_options.Count > 0)
            {
                r += m_options.toXML( ) + String.Format("\n");
            }

            // *** DEVICE OPTIONS
            if (m_deviceOptions.Count > 0)
            {
                r += m_deviceOptions.toXML( ) + String.Format("\n");
            }

            // *** MODIFIERS
            if (m_modifiers.Count > 0)
            {
                r += m_modifiers.toXML( ) + String.Format("\n");
            }

            // *** ACTION MAPS

            foreach (ActionMapCls amc in this)
            {
                r += String.Format("{0}\n", amc.toXML( ));
            }
            r += String.Format("</ActionMaps>\n");
            return(r);
        }