Beispiel #1
0
        /// <summary>
        /// Reads an action sub element
        /// </summary>
        /// <param name="xr">An XML reader @ StartElement</param>
        private void ReadActionSub(XmlReader xr, String actionName)
        {
            //<action name="v_brake" onPress="1" onHold="1" onRelease="1" keyboard="space" xboxpad="xi_shoulderl+xi_shoulderr">
            //	<joystick input="js2_button7" />
            //	<joystick input="js2_button8" />
            //</action>
            //or
            //<action name="v_hud_confirm" onPress="1" onRelease="1" xboxpad="xi_triggerL_btn+xi_a" joystick="js1_button19">
            //	<keyboard>
            //		<inputdata input="enter"/>
            //	</keyboard>
            //</action>
            Boolean done = false;

            do
            {
                xr.Read( ); // get next element
                Dictionary <String, String> attr = new Dictionary <string, string>( );
                String eName = xr.Name;
                while (xr.MoveToNextAttribute( ))
                {
                    attr.Add(xr.Name, xr.Value); // save the attributes
                    //Console.Write( " {0}='{1}'", xr.Name, xr.Value );
                }
                xr.MoveToElement( ); // backup
                Action ac = new Action( );
                ac.name = actionName;
                // the element name is a control
                if (xr.NodeType == XmlNodeType.EndElement)
                {
                    done = (xr.Name == "action");
                }
                else if (xr.IsEmptyElement)
                {
                    // an attribute only element
                    ac.input      = ActionCls.DevID(eName);
                    ac.defBinding = attr["input"];
                    if (!String.IsNullOrEmpty(ac.defBinding))
                    {
                        m_currentMap.Add(ac);                                    // finally add it to the current map if it was bound
                    }
                }
                else
                {
                    // one with subelements again
                    xr.Read( );
                    ac.input      = ActionCls.DevID(eName);
                    ac.defBinding = xr["input"];
                    if (!String.IsNullOrEmpty(ac.defBinding))
                    {
                        m_currentMap.Add(ac);                                    // finally add it to the current map if it was bound
                    }
                }
            } while (!done);
            m_nodeNameStack.Pop( ); // action is finished
        }