/// <summary>
 /// Initializes a new instance of the <see cref="InputItemViewModel"/> class.
 /// </summary>
 public InputItemViewModel()
 {
     InputItem = new InputItemModel();
     WaitFrames = 1;
     SendInputs = true;
     PlaySound = false;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Static definition for deserializing a string into a set of inputs.
        /// </summary>
        /// <param name="value">The <see cref="string"/> value to deserialize.</param>
        ///<returns><see cref="InputItemModel"/> containing the inputs from the string.</returns>
        public static InputItemModel Deserialize(string value)
        {
            /**
             * Creates a timeline object from a string serialization and assumes the following
             * formats (specified by the respective Serialize methods)
             *
             * InputItemModel:     ItemType#PlaySound#NumFrames#NumInputs[#Input1,#Input2...]
             *
             */
            String[] tokens = value.ToUpper().Split('#');

            // Big change: this is the new default to help transform old file type.
            int  n;
            bool isNumeric = int.TryParse(tokens[0].ToString(), out n);

            if (isNumeric)
            {
                InputItemModel item = new InputItemModel();
                item.PlaySound = int.Parse(tokens[0].ToString()) == 0 ? false : true;
                item.Frames    = int.Parse(tokens[1].ToString());

                char[] inputs = tokens[2].ToString().ToCharArray();


                item.InputCommandState.DirectionState = (InputCommandModel.DirectionStateEnum) int.Parse(inputs[0].ToString());
                item.InputCommandState.LightPunch     = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[1].ToString());
                item.InputCommandState.MediumPunch    = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[2].ToString());
                item.InputCommandState.HardPunch      = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[3].ToString());
                item.InputCommandState.LightKick      = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[4].ToString());
                item.InputCommandState.MediumKick     = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[5].ToString());
                item.InputCommandState.HardKick       = (InputCommandModel.ButtonStateEnum) int.Parse(inputs[6].ToString());
                return(item);
            }

            throw new FormatException("Failed to deserialize TimelineItem, wrong string format: " + value);
        }
Exemplo n.º 3
0
        /// <summary>         
        /// Static definition for deserializing a string into a set of inputs.
        /// </summary>
        /// <param name="value">The <see cref="string"/> value to deserialize.</param>
        ///<returns><see cref="InputItemModel"/> containing the inputs from the string.</returns>
        public static InputItemModel Deserialize(string value)
        {
            /**
             * Creates a timeline object from a string serialization and assumes the following
             * formats (specified by the respective Serialize methods)
             *
             * InputItemModel:     ItemType#PlaySound#NumFrames#NumInputs[#Input1,#Input2...]
             *
             */
            String[] tokens = value.ToUpper().Split('#');

            // Big change: this is the new default to help transform old file type.
            int n;
            bool isNumeric = int.TryParse(tokens[0].ToString(), out n);
            if (isNumeric)
            {
                InputItemModel item = new InputItemModel();
                item.PlaySound = int.Parse(tokens[0].ToString()) == 0 ? false : true;
                item.Frames = int.Parse(tokens[1].ToString());

                char[] inputs = tokens[2].ToString().ToCharArray();

                item.InputCommandState.DirectionState = (InputCommandModel.DirectionStateEnum)int.Parse(inputs[0].ToString());
                item.InputCommandState.LightPunch = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[1].ToString());
                item.InputCommandState.MediumPunch = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[2].ToString());
                item.InputCommandState.HardPunch = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[3].ToString());
                item.InputCommandState.LightKick = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[4].ToString());
                item.InputCommandState.MediumKick = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[5].ToString());
                item.InputCommandState.HardKick = (InputCommandModel.ButtonStateEnum)int.Parse(inputs[6].ToString());
                return item;

            }

            throw new FormatException("Failed to deserialize TimelineItem, wrong string format: " + value);
        }