Exemplo n.º 1
0
        /// <summary>
        /// Apply an update from the action to the treenode
        /// First apply to the GUI tree where the selection happend then copy it over to master tree
        /// </summary>
        /// <param name="action">The action that carries the update</param>
        public void UpdateAction(ActionCommandCls actionCmd)
        {
            //log.Debug( "UpdateNodeFromAction - Entry" );
            if (actionCmd == null)
            {
                return;
            }

            // input is either "" or a valid mapping or a blended mapping
            if (String.IsNullOrEmpty(actionCmd.Input))
            {
                // new unmapped
                this.Command = ""; this.BackColor = MyColors.UnassignedColor;
                if (this.Level == 2)
                {
                    this.Action = "UNDEF";            // apply UNDEF - 20160525 fix addbind not showing UNDEF if assigned
                }
            }
            // blended mapped ones - can only get a Blend Background
            else if (actionCmd.Input == DeviceCls.BlendedInput)
            {
                this.Command = actionCmd.DevInput; this.BackColor = MyColors.BlendedColor;
            }
            else
            {
                // mapped ( regular ones )
                this.Command = actionCmd.DevInput;
                //if ( this.Level == 2 ) this.Action = ""; // remove UNDEF - 20160525 fix addbind not showing UNDEF if assigned
                // background is along the input
                this.BackColor = ActionCls.DeviceColor(actionCmd.DevInput);
            }
            this.Modified = !actionCmd.DefaultActivationMode; // apply modifier visual
        }
Exemplo n.º 2
0
 // ctor
 public ActionCommandCls(ActionCommandCls other)
 {
     Input          = other.Input;
     DevID          = other.DevID;
     ActivationMode = new ActivationMode(other.ActivationMode);
     NodeIndex      = other.NodeIndex;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Add an ActionCommand with Input at nodeindex
        ///   apply default ActivationMode
        /// </summary>
        /// <param name="devInput"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public ActionCommandCls AddCommand(String devInput, int index)
        {
            ActionCommandCls acc = new ActionCommandCls(devInput, index);

            acc.ActivationMode = new ActivationMode(ActivationMode.Default);
            inputList.Add(acc);
            return(acc);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates and adds the inputCommand list with given input string
        /// AC2 style input is used i.e. with device tag in front
        ///   apply given ActivationMode - can be "~" to indicate DONT APPLY
        /// </summary>
        /// <param name="devInput"></param>
        /// <returns>Returns the ActionCommand created</returns>
        public ActionCommandCls AddCommand(String devInput, ActivationMode activationMode)
        {
            ActionCommandCls acc = new ActionCommandCls(devInput, inputList.Count - 1); // starts from -1 ...

            acc.ActivationMode = new ActivationMode(activationMode);
            inputList.Add(acc);
            return(acc);
        }
Exemplo n.º 5
0
        public ActionCommandCls AddCommand(String input, int index)
        {
            ActionCommandCls acc = new ActionCommandCls( );

            acc.input = input; acc.nodeIndex = index;
            inputList.Add(acc);
            return(acc);
        }
Exemplo n.º 6
0
        public ActionCommandCls AddCommand(String input)
        {
            ActionCommandCls acc = new ActionCommandCls( );

            acc.input = input; acc.nodeIndex = inputList.Count - 1; // starts from -1 ...
            inputList.Add(acc);
            return(acc);
        }
Exemplo n.º 7
0
        }                                           // index of the vis treenode


        /// <summary>
        /// Clone this object
        /// </summary>
        /// <returns>A deep Clone of this object</returns>
        public object Clone( )
        {
            ActionCommandCls ac = (ActionCommandCls)this.MemberwiseClone();

            // more objects to deep copy
            ac.ActivationMode = ( ActivationMode )this.ActivationMode.Clone( );

            return(ac);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Find an ActionCommand with index in an Action
        /// </summary>
        /// <param name="input">The input</param>
        /// <returns>An actionCommand or null if not found</returns>
        public ActionCommandCls FindActionInputObject(int index)
        {
            log.Debug("FindActionInputObject - Entry");
            // Apply the input to the ActionTree
            ActionCommandCls acc = null;

            acc = this.inputList.Find(delegate(ActionCommandCls _ACC) { return(_ACC.NodeIndex == index); });
            if (acc == null)
            {
                log.Error("FindActionInputObject - Action Input not found in Action");
                return(null); // ERROR - Action Input not found in tree
            }
            return(acc);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Copy return the action while reassigning the JsN Tag
        /// </summary>
        /// <param name="newJsList">The JsN reassign list</param>
        /// <returns>The action copy with reassigned input</returns>
        public ActionCommandCls ReassignJsN( JsReassingList newJsList )
        {
            ActionCommandCls newAc = new ActionCommandCls( );
              // full copy from 'this'
              newAc.input = this.input;

              // reassign the jsX part for Joystick commands  (silly but rather fast comparison)
              if ( this.input.Contains( "js1_" ) || this.input.Contains( "js2_" ) || this.input.Contains( "js3_" ) || this.input.Contains( "js4_" ) ) {
            int oldJsN = JoystickCls.JSNum( this.input );
            if ( JoystickCls.IsJSValid( oldJsN ) ) {
              if ( newJsList.ContainsOldJs( oldJsN ) ) newAc.input = JoystickCls.ReassignJSTag( this.input, newJsList.newJsFromOldJs(oldJsN) );
            }
              }

              return newAc;
        }
Exemplo n.º 10
0
        /// <summary>
        /// Copy return the action while reassigning the JsN Tag
        /// </summary>
        /// <param name="newJsList">The JsN reassign list</param>
        /// <returns>The action copy with reassigned input</returns>
        public ActionCommandCls ReassignJsN(JsReassingList newJsList)
        {
            ActionCommandCls newAc = (ActionCommandCls)this.Clone();

            // reassign the jsX part for Joystick commands
            if (this.DevID.StartsWith("js"))
            {
                int oldJsN = JoystickCls.JSNum(this.DevID);
                if (JoystickCls.IsJSValid(oldJsN))
                {
                    if (newJsList.ContainsOldJs(oldJsN))
                    {
                        newAc.DevID = JoystickCls.ReassignJSTag(this.DevID, newJsList.newJsFromOldJs(oldJsN));
                    }
                }
            }

            return(newAc);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Copy return the action while reassigning the JsN Tag
        /// </summary>
        /// <param name="newJsList">The JsN reassign list</param>
        /// <returns>The action copy with reassigned input</returns>
        public ActionCommandCls ReassignJsN(JsReassingList newJsList)
        {
            ActionCommandCls newAc = new ActionCommandCls( );

            // full copy from 'this'
            newAc.input = this.input;

            // reassign the jsX part for Joystick commands  (silly but rather fast comparison)
            if (this.input.Contains("js1_") || this.input.Contains("js2_") || this.input.Contains("js3_") || this.input.Contains("js4_"))
            {
                int oldJsN = JoystickCls.JSNum(this.input);
                if (JoystickCls.IsJSValid(oldJsN))
                {
                    if (newJsList.ContainsOldJs(oldJsN))
                    {
                        newAc.input = JoystickCls.ReassignJSTag(this.input, newJsList.newJsFromOldJs(oldJsN));
                    }
                }
            }

            return(newAc);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Apply an update from the action to the treenode
        /// First apply to the GUI tree where the selection happend then copy it over to master tree
        /// </summary>
        /// <param name="input">The input command</param>
        /// <param name="node">The TreeNode to update</param>
        /// <param name="actionCmd">The actionCommand that carries the update</param>
        /// <param name="inKind">The input device</param>
        private void UpdateInputNodeFromAction( ActionTreeInputNode node, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
        {
            log.Debug( "UpdateInputNodeFromAction - Entry" );
              if ( actionCmd == null ) return;
              if ( node.Level != 2 ) return; // applies only to ActionTreeInputNode

              // input is either "" or a valid mapping or a blended mapping
              if ( String.IsNullOrEmpty( actionCmd.input ) ) {
            // new unmapped
            node.Command = ""; node.BackColor = MyColors.UnassignedColor;
              }

              // blended mapped ones - can only get a Blend Background
              else if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && ( actionCmd.input == JoystickCls.BlendedInput ) ) {
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && ( actionCmd.input == GamepadCls.BlendedInput ) ) {
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else if ( actionCmd.input == DeviceCls.BlendedInput ) {
            // Manually Blended input
            node.Command = actionCmd.input; node.BackColor = MyColors.BlendedColor;
              }
              else {
            // mapped ( regular ones )
            node.Command = actionCmd.input;

            // background is along the input
            if ( inKind == ActionCls.ActionDevice.AD_Joystick ) {
              int jNum = JoystickCls.JSNum( actionCmd.input );
              node.BackColor = JoystickCls.JsNColor( jNum );
            }
            else if ( inKind == ActionCls.ActionDevice.AD_Gamepad ) {
              node.BackColor = GamepadCls.XiColor( );
            }
            else if ( inKind == ActionCls.ActionDevice.AD_Keyboard ) {
              node.BackColor = KeyboardCls.KbdColor( );
            }
            else {
              // ?? what else
              node.BackColor = MyColors.UnassignedColor;
            }
              }
              UpdateMasterNode( node );
        }
Exemplo n.º 13
0
        /// <summary>
        /// Updates an actionCommand with a new input (command)
        /// </summary>
        /// <param name="input">The input command</param>
        /// <param name="action">The action to containing the command</param>
        /// <param name="actionCmd">The actionCommand to update</param>
        private void UpdateActionCommandFromInput( String input, ActionCommandCls actionCmd, ActionCls.ActionDevice inKind )
        {
            //log.Debug( "UpdateActionCommandFromInput - Entry" );
              if ( actionCmd == null ) return;

              // Apply the input to the ActionTree
              if ( String.IsNullOrEmpty( input ) ) {
            // unmapped - handle the blended ones from setting
            if ( ( inKind == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) actionCmd.input = JoystickCls.BlendedInput;
            else if ( ( inKind == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) actionCmd.input = GamepadCls.BlendedInput;
            else actionCmd.input = "";
              }
              else {
            // mapped ones
            actionCmd.input = input;
              }
              Dirty = true;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Load Mappings into the ActionList and create the Master TreeView 
        /// </summary>
        /// <param name="defaultProfileName">The name of the profile to load (w/o extension)</param>
        /// <param name="applyDefaults">True if default mappings should be carried on</param>
        public void LoadProfileTree( String defaultProfileName, Boolean applyDefaults )
        {
            log.Debug( "LoadProfileTree - Entry" );

              ActionTreeNode tn = null;
              ActionTreeNode[] cnl = { };
              ActionTreeNode cn = null;
              ActionTreeNode topNode = null;

              ActionMapCls acm = null;
              ActionCls ac = null;
              ActionCommandCls acc = null;

              ActionMaps = new ActionMapsCls( m_jsList );
              m_MasterTree.Nodes.Clear( );

              // read the action items into the TreeView
              DProfileReader dpReader = new DProfileReader( ); // we may read a profile
              TextReader txReader = null;

              dpReader.fromXML( SCDefaultProfile.DefaultProfile( defaultProfileName + ".xml" ) );
              if ( dpReader.ValidContent ) {
            txReader = new StringReader( dpReader.CSVMap );
              }

              // we assume no addbind items in the profile
              //  so all actions are shown in the ActionTreeNode and no ActionTreeNode childs must be created here
              //  however we create the ActionCommand for each entry that is supported - even if it is not mapped (input= "")
              using ( TextReader sr = txReader ) {
            String buf = sr.ReadLine( );
            while ( !String.IsNullOrEmpty( buf ) ) {
              String[] elem = buf.Split( new char[] { ';', ',' } );
              if ( elem.Length > 1 ) {
            if ( !IgnoreMaps.Contains( "," + elem[0] + "," ) ) {
              // must have 2 elements min
              Array.Resize( ref cnl, 0 );
              acm = new ActionMapCls( ); acm.name = elem[0]; // get actionmap name
              // process items
              for ( int ei=1; ei < elem.Length; ei += 2 ) { // step 2  - action;defaultBinding come in pairs
                if ( !String.IsNullOrEmpty( elem[ei] ) ) {
                  // default assignments
                  String action = elem[ei].Substring( 1 );
                  String defBinding = elem[ei + 1].Substring( 0 );
                  String devID = elem[ei].Substring( 0, 1 );
                  String device = ActionCls.DeviceFromID( devID );

                  // visual item for the action
                  cn = new ActionTreeNode( "UNDEF" ); cn.Name = elem[ei]; cn.Action = action; cn.BackColor = Color.White; // name with the key it to find it..
                  cn.ImageKey = devID; cn.BackColor = Color.White; // some stuff does not work properly...
                  Array.Resize( ref cnl, cnl.Length + 1 ); cnl[cnl.Length - 1] = cn;

                  // derive content tree
                  ac = new ActionCls( ); ac.key = cn.Name; ac.name = action; ac.device = device; ac.actionDevice = ActionCls.ADevice( device ); ac.defBinding = defBinding;
                  acm.Add( ac ); // add to our map
                  cn.ActionDevice = ac.actionDevice; // should be known now
                  // create just an unmapped ActionCommand item
                  acc = new ActionCommandCls( ); acc.input = ""; acc.nodeIndex = -1; // profile items are shown in the ActionTreeNode (not in a child)
                  ac.inputList.Add( acc );// add to our Action

                  // modify defaults and blendings
                  if ( applyDefaults ) {
                    // apply the default mappings
                    if ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) {
                      int jNum = JoystickCls.JSNum( ac.defBinding );
                      if ( JoystickCls.IsJSValid( jNum ) ) {
                        acc.input = ac.defBinding;
                        cn.Command = ac.defBinding; cn.BackColor = JoystickCls.JsNColor( jNum );
                      }
                      else if ( BlendUnmappedJS ) {
                        // jsx_reserved gets here
                        acc.input = JoystickCls.BlendedInput;
                        cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
                      }
                    }
                    else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) {
                      if ( GamepadCls.IsXiValid( ac.defBinding ) ) {
                        acc.input = ac.defBinding;
                        cn.Command = ac.defBinding; cn.BackColor = GamepadCls.XiColor( );
                      }
                      else if ( BlendUnmappedGP ) {
                        // xi_reserved gets here
                        acc.input = GamepadCls.BlendedInput;
                        cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
                      }
                    }
                    else if ( ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) {
                      if ( !String.IsNullOrEmpty( ac.defBinding ) ) {
                        acc.input = ac.defBinding;
                        cn.Command = ac.defBinding; cn.BackColor = KeyboardCls.KbdColor( );
                      }
                    }
                  }
                  // Don't apply defaults - but blend if checked
                  else {
                    if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Joystick ) && BlendUnmappedJS ) {
                      cn.Command = JoystickCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
                      acc.input = JoystickCls.BlendedInput;
                    }
                    else if ( ( ac.actionDevice == ActionCls.ActionDevice.AD_Gamepad ) && BlendUnmappedGP ) {
                      cn.Command = GamepadCls.BlendedInput; cn.BackColor = MyColors.BlendedColor;
                      acc.input = GamepadCls.BlendedInput;
                    }
                  }
                }
              }//for

              tn = new ActionTreeNode( acm.name, cnl ); tn.Name = acm.name;  // name it to find it..
              tn.ImageIndex = 0; tn.NodeFont = new Font( m_MasterTree.Font, FontStyle.Bold );
              m_MasterTree.BackColor = Color.White; // fix for defect TreeView (cut off bold text)
              m_MasterTree.Nodes.Add( tn ); // add to control
              if ( topNode == null ) topNode = tn; // once to keep the start of list
              ActionMaps.Add( acm ); // add to our map
            }//not ignored

              }// if valid line
              buf = sr.ReadLine( );
            }//while
              }
              // fix for defect TreeView (cut off bold text at last element -despite the BackColor fix) add another and delete it
              tn = new ActionTreeNode( "DUMMY" ); tn.Name = "DUMMY";
              tn.ImageIndex = 0; tn.NodeFont = new Font( m_MasterTree.Font, FontStyle.Bold );
              m_MasterTree.BackColor = m_MasterTree.BackColor; // fix for defect TreeView (cut off bold text)
              m_MasterTree.Nodes.Add( tn ); // add to control
              m_MasterTree.Nodes.RemoveByKey( "DUMMY" );
              // fix for defect TreeView (cut off bold text)

              txReader = null;
              Dirty = false;

              // finally apply the filter and make it visible
              FilterTree( );
        }
Exemplo n.º 15
0
 public ActionCommandCls AddCommand( String input, int index )
 {
     ActionCommandCls acc = new ActionCommandCls( );
       acc.input = input; acc.nodeIndex = index;
       inputList.Add( acc );
       return acc;
 }
Exemplo n.º 16
0
 public ActionCommandCls AddCommand( String input )
 {
     ActionCommandCls acc = new ActionCommandCls( );
       acc.input = input; acc.nodeIndex = inputList.Count - 1; // starts from -1 ...
       inputList.Add( acc );
       return acc;
 }