Пример #1
0
        private AxisConfiguration ReadAxisConfiguration(XmlReader reader)
        {
            AxisConfiguration axisConfig = new AxisConfiguration();

            axisConfig.name = reader["name"];

            bool endOfAxis = false;

            while (reader.Read() && reader.IsStartElement() && !endOfAxis)
            {
                switch (reader.LocalName)
                {
                case "description":
                    axisConfig.description = reader.IsEmptyElement ? string.Empty : reader.ReadElementContentAsString();
                    break;

                case "positive":
                    axisConfig.positive = AxisConfiguration.StringToKey(reader.ReadElementContentAsString());
                    break;

                case "altPositive":
                    axisConfig.altPositive = AxisConfiguration.StringToKey(reader.ReadElementContentAsString());
                    break;

                case "negative":
                    axisConfig.negative = AxisConfiguration.StringToKey(reader.ReadElementContentAsString());
                    break;

                case "altNegative":
                    axisConfig.altNegative = AxisConfiguration.StringToKey(reader.ReadElementContentAsString());
                    break;

                case "deadZone":
                    axisConfig.deadZone = reader.ReadElementContentAsFloat();
                    break;

                case "gravity":
                    axisConfig.gravity = reader.ReadElementContentAsFloat();
                    break;

                case "sensitivity":
                    axisConfig.sensitivity = reader.ReadElementContentAsFloat();
                    break;

                case "snap":
                    axisConfig.snap = reader.ReadElementContentAsBoolean();
                    break;

                case "invert":
                    axisConfig.invert = reader.ReadElementContentAsBoolean();
                    break;

                case "type":
                    axisConfig.type = AxisConfiguration.StringToInputType(reader.ReadElementContentAsString());
                    break;

                case "axis":
                    axisConfig.axis = reader.ReadElementContentAsInt();
                    break;

                case "joystick":
                    axisConfig.joystick = reader.ReadElementContentAsInt();
                    break;

                default:
                    endOfAxis = true;
                    break;
                }
            }

            return(axisConfig);
        }
Пример #2
0
        private AxisConfiguration ReadAxisConfiguration(XmlNode node)
        {
            AxisConfiguration axisConfig = new AxisConfiguration();

            axisConfig.name = ReadAttribute(node, "name", "Unnamed Axis");

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.LocalName)
                {
                case "description":
                    axisConfig.description = child.InnerText;
                    break;

                case "positive":
                    axisConfig.positive = AxisConfiguration.StringToKey(child.InnerText);
                    break;

                case "altPositive":
                    axisConfig.altPositive = AxisConfiguration.StringToKey(child.InnerText);
                    break;

                case "negative":
                    axisConfig.negative = AxisConfiguration.StringToKey(child.InnerText);
                    break;

                case "altNegative":
                    axisConfig.altNegative = AxisConfiguration.StringToKey(child.InnerText);
                    break;

                case "deadZone":
                    axisConfig.deadZone = ReadAsFloat(child);
                    break;

                case "gravity":
                    axisConfig.gravity = ReadAsFloat(child, 1.0f);
                    break;

                case "sensitivity":
                    axisConfig.sensitivity = ReadAsFloat(child, 1.0f);
                    break;

                case "snap":
                    axisConfig.snap = ReadAsBool(child);
                    break;

                case "invert":
                    axisConfig.invert = ReadAsBool(child);
                    break;

                case "type":
                    axisConfig.type = AxisConfiguration.StringToInputType(child.InnerText);
                    break;

                case "axis":
                    axisConfig.axis = ReadAsInt(child);
                    break;

                case "joystick":
                    axisConfig.joystick = ReadAsInt(child);
                    break;
                }
            }

            return(axisConfig);
        }