diff --git a/FormMain.Designer.cs b/FormMain.Designer.cs index 3cdfa86..2be37f0 100644 --- a/FormMain.Designer.cs +++ b/FormMain.Designer.cs @@ -131,9 +131,8 @@ this.cbxShowGamepad = new System.Windows.Forms.CheckBox(); this.txFilter = new System.Windows.Forms.TextBox(); this.tcXML = new System.Windows.Forms.TabControl(); - this.tPageOther = new System.Windows.Forms.TabPage(); - this.lbxOther = new System.Windows.Forms.ListBox(); this.tPageDump = new System.Windows.Forms.TabPage(); + this.tPageOther = new System.Windows.Forms.TabPage(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.tsBtReset = new System.Windows.Forms.ToolStripDropDownButton(); this.resetDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -148,6 +147,9 @@ this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.tableLayoutPanel6 = new System.Windows.Forms.TableLayoutPanel(); + this.lbxOther = new System.Windows.Forms.ListBox(); + this.cbxAutoTabXML = new System.Windows.Forms.CheckBox(); this.cmCopyPaste.SuspendLayout(); this.panel2.SuspendLayout(); this.cmMouseEntry.SuspendLayout(); @@ -162,9 +164,10 @@ this.tableLayoutPanel4.SuspendLayout(); this.tableLayoutPanel5.SuspendLayout(); this.tcXML.SuspendLayout(); - this.tPageOther.SuspendLayout(); this.tPageDump.SuspendLayout(); + this.tPageOther.SuspendLayout(); this.statusStrip1.SuspendLayout(); + this.tableLayoutPanel6.SuspendLayout(); this.SuspendLayout(); // // btDumpList @@ -621,7 +624,6 @@ // tdiTxDefActivationMode // this.tdiTxDefActivationMode.BackColor = System.Drawing.Color.PapayaWhip; - this.tdiTxDefActivationMode.Font = new System.Drawing.Font("Segoe UI", 9F); this.tdiTxDefActivationMode.Name = "tdiTxDefActivationMode"; this.tdiTxDefActivationMode.ReadOnly = true; this.tdiTxDefActivationMode.Size = new System.Drawing.Size(160, 23); @@ -1196,28 +1198,6 @@ this.tcXML.Size = new System.Drawing.Size(362, 686); this.tcXML.TabIndex = 30; // - // tPageOther - // - this.tPageOther.Controls.Add(this.lbxOther); - this.tPageOther.Location = new System.Drawing.Point(4, 22); - this.tPageOther.Name = "tPageOther"; - this.tPageOther.Padding = new System.Windows.Forms.Padding(3); - this.tPageOther.Size = new System.Drawing.Size(354, 660); - this.tPageOther.TabIndex = 0; - this.tPageOther.Text = "All Mappings"; - this.tPageOther.UseVisualStyleBackColor = true; - // - // lbxOther - // - this.lbxOther.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbxOther.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lbxOther.FormattingEnabled = true; - this.lbxOther.ItemHeight = 14; - this.lbxOther.Location = new System.Drawing.Point(3, 3); - this.lbxOther.Name = "lbxOther"; - this.lbxOther.Size = new System.Drawing.Size(348, 654); - this.lbxOther.TabIndex = 0; - // // tPageDump // this.tPageDump.Controls.Add(this.rtb); @@ -1229,6 +1209,17 @@ this.tPageDump.Text = "Dumps (XML, Logs etc.)"; this.tPageDump.UseVisualStyleBackColor = true; // + // tPageOther + // + this.tPageOther.Controls.Add(this.tableLayoutPanel6); + this.tPageOther.Location = new System.Drawing.Point(4, 22); + this.tPageOther.Name = "tPageOther"; + this.tPageOther.Padding = new System.Windows.Forms.Padding(3); + this.tPageOther.Size = new System.Drawing.Size(354, 660); + this.tPageOther.TabIndex = 0; + this.tPageOther.Text = "All Mappings"; + this.tPageOther.UseVisualStyleBackColor = true; + // // toolStripStatusLabel2 // this.toolStripStatusLabel2.BackColor = System.Drawing.Color.DarkKhaki; @@ -1370,6 +1361,44 @@ this.statusStrip1.TabIndex = 26; this.statusStrip1.Text = "statusStrip1"; // + // tableLayoutPanel6 + // + this.tableLayoutPanel6.ColumnCount = 1; + this.tableLayoutPanel6.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel6.Controls.Add(this.lbxOther, 0, 1); + this.tableLayoutPanel6.Controls.Add(this.cbxAutoTabXML, 0, 0); + this.tableLayoutPanel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel6.Location = new System.Drawing.Point(3, 3); + this.tableLayoutPanel6.Name = "tableLayoutPanel6"; + this.tableLayoutPanel6.RowCount = 2; + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F)); + this.tableLayoutPanel6.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel6.Size = new System.Drawing.Size(348, 654); + this.tableLayoutPanel6.TabIndex = 0; + // + // lbxOther + // + this.lbxOther.BackColor = System.Drawing.Color.WhiteSmoke; + this.lbxOther.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbxOther.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lbxOther.FormattingEnabled = true; + this.lbxOther.ItemHeight = 14; + this.lbxOther.Location = new System.Drawing.Point(3, 33); + this.lbxOther.Name = "lbxOther"; + this.lbxOther.Size = new System.Drawing.Size(342, 618); + this.lbxOther.TabIndex = 1; + // + // cbxAutoTabXML + // + this.cbxAutoTabXML.AutoSize = true; + this.cbxAutoTabXML.Location = new System.Drawing.Point(3, 3); + this.cbxAutoTabXML.Name = "cbxAutoTabXML"; + this.cbxAutoTabXML.Size = new System.Drawing.Size(233, 17); + this.cbxAutoTabXML.TabIndex = 2; + this.cbxAutoTabXML.Text = "Switch XML/Mapping tab automatically"; + this.cbxAutoTabXML.UseVisualStyleBackColor = true; + this.cbxAutoTabXML.CheckedChanged += new System.EventHandler(this.cbxAutoTabXML_CheckedChanged); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -1405,10 +1434,12 @@ this.tableLayoutPanel5.ResumeLayout(false); this.tableLayoutPanel5.PerformLayout(); this.tcXML.ResumeLayout(false); - this.tPageOther.ResumeLayout(false); this.tPageDump.ResumeLayout(false); + this.tPageOther.ResumeLayout(false); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); + this.tableLayoutPanel6.ResumeLayout(false); + this.tableLayoutPanel6.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -1527,8 +1558,10 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel5; private System.Windows.Forms.TabControl tcXML; private System.Windows.Forms.TabPage tPageOther; - private System.Windows.Forms.ListBox lbxOther; private System.Windows.Forms.TabPage tPageDump; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel6; + private System.Windows.Forms.ListBox lbxOther; + private System.Windows.Forms.CheckBox cbxAutoTabXML; } } diff --git a/FormMain.cs b/FormMain.cs index 9db4c8c..f5185b1 100644 --- a/FormMain.cs +++ b/FormMain.cs @@ -286,6 +286,8 @@ namespace SCJMapper_V2 lblPTU.Visible = m_AppSettings.UsePTU; if ( m_AppSettings.UsePTU ) log.Debug( "Using PTU Folders" ); + // Auto Tab XML + cbxAutoTabXML.Checked = m_AppSettings.AutoTabXML; // poll the XInput log.Debug( "Start XInput polling" ); @@ -776,11 +778,12 @@ namespace SCJMapper_V2 private void btFind_Click( object sender, EventArgs e ) { - m_AT.FindAndSelectCtrl( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ) ); // find the action for a Control (joystick input) + m_AT.FindAndSelectCtrl( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ) , ""); // find the action for a Control (joystick input) } private void btAssign_Click( object sender, EventArgs e ) { + log.Debug( "btAssign_Click" ); if ( m_AT.UpdateSelectedItem( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ), InputMode, true ) ) { if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; UpdateTableSelectedItem( ); @@ -790,6 +793,7 @@ namespace SCJMapper_V2 private void btBlend_Click( object sender, EventArgs e ) { + log.Debug( "btBlend_Click" ); if ( m_AT.CanBlendBinding ) { m_AT.BlendBinding( ); UpdateTableSelectedItem( ); @@ -800,6 +804,7 @@ namespace SCJMapper_V2 private void btClear_Click( object sender, EventArgs e ) { + log.Debug( "btClear_Click" ); if ( m_AT.CanClearBinding || m_AT.CanBlendBinding ) { m_AT.ClearBinding( ); UpdateTableSelectedItem( ); @@ -866,6 +871,10 @@ namespace SCJMapper_V2 m_AT.FilterTree( txFilter.Text ); } + private void cbxAutoTabXML_CheckedChanged( object sender, EventArgs e ) + { + m_AppSettings.AutoTabXML = cbxAutoTabXML.Checked; m_AppSettings.Save( ); + } // Toolstrip Items @@ -1100,6 +1109,7 @@ namespace SCJMapper_V2 private void tsiAddBinding_Click( object sender, EventArgs e ) { // note: the right click selected the node + log.Debug( "tsiAddBinding_Click" ); m_AT.AddBinding( ); if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; } @@ -1107,6 +1117,7 @@ namespace SCJMapper_V2 private void tdiDelBinding_Click( object sender, EventArgs e ) { // note: the right click selected the node + log.Debug( "tdiDelBinding_Click" ); m_AT.DelBinding( ); if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; } diff --git a/FormMain.resx b/FormMain.resx index 44b4ee7..bfb0979 100644 --- a/FormMain.resx +++ b/FormMain.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8 - EAAAAk1TRnQBSQFMAgEBCQEAAZgBEQGYAREBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + EAAAAk1TRnQBSQFMAgEBCQEAAaABEQGgAREBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAATADAAEBAQABCAYAAQwYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/FormSettings.Designer.cs b/FormSettings.Designer.cs index bdd9f0b..fd9f582 100644 --- a/FormSettings.Designer.cs +++ b/FormSettings.Designer.cs @@ -64,11 +64,11 @@ this.btCancel = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); + this.cbxAutoTabXML = new System.Windows.Forms.CheckBox(); this.cbxListModifiers = new System.Windows.Forms.CheckBox(); this.cbxCSVListing = new System.Windows.Forms.CheckBox(); this.cbxPTU = new System.Windows.Forms.CheckBox(); this.cbxDetectGamepad = new System.Windows.Forms.CheckBox(); - this.cbxAutoTabXML = new System.Windows.Forms.CheckBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); @@ -438,6 +438,16 @@ this.groupBox4.TabStop = false; this.groupBox4.Text = "Advanced Options ..."; // + // cbxAutoTabXML + // + this.cbxAutoTabXML.AutoSize = true; + this.cbxAutoTabXML.Location = new System.Drawing.Point(9, 44); + this.cbxAutoTabXML.Name = "cbxAutoTabXML"; + this.cbxAutoTabXML.Size = new System.Drawing.Size(233, 17); + this.cbxAutoTabXML.TabIndex = 10; + this.cbxAutoTabXML.Text = "Switch XML/Mapping tab automatically"; + this.cbxAutoTabXML.UseVisualStyleBackColor = true; + // // cbxListModifiers // this.cbxListModifiers.AutoSize = true; @@ -479,16 +489,6 @@ this.cbxDetectGamepad.Text = "Use Gamepad"; this.cbxDetectGamepad.UseVisualStyleBackColor = true; // - // cbxAutoTabXML - // - this.cbxAutoTabXML.AutoSize = true; - this.cbxAutoTabXML.Location = new System.Drawing.Point(9, 44); - this.cbxAutoTabXML.Name = "cbxAutoTabXML"; - this.cbxAutoTabXML.Size = new System.Drawing.Size(247, 17); - this.cbxAutoTabXML.TabIndex = 10; - this.cbxAutoTabXML.Text = "Switch XML/Assignment tab automatically"; - this.cbxAutoTabXML.UseVisualStyleBackColor = true; - // // FormSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); diff --git a/SC/DProfileReader.cs b/SC/DProfileReader.cs index 2de3e34..174a85e 100644 --- a/SC/DProfileReader.cs +++ b/SC/DProfileReader.cs @@ -15,9 +15,9 @@ namespace SCJMapper_V2.SC { private static readonly log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod( ).DeclaringType ); - public Boolean ValidContent { get; set; } + public bool ValidContent { get; set; } - private Stack m_nodeNameStack = null; // element name stack - keeping track where we are + private Stack m_nodeNameStack = null; // element name stack - keeping track where we are // state for the parser enum EState @@ -30,22 +30,22 @@ namespace SCJMapper_V2.SC // an action map and its actions class ProfileAction { - public String name { get; set; } // the action name - public String devID { get; set; } // the input method K,J,X,P - private String m_defBinding = ""; // NOTE: this is AC1 style in the Profile - need to conver later when dumping out - public String defBinding { get { return m_defBinding; } set { m_defBinding = value; } } // DONT! need to clean this one, found spaces... + public string name { get; set; } // the action name + public string devID { get; set; } // the input method K,J,X,P + private string m_defBinding = ""; // NOTE: this is AC1 style in the Profile - need to conver later when dumping out + public string defBinding { get { return m_defBinding; } set { m_defBinding = value; } } // DONT! need to clean this one, found spaces... private ActivationMode m_defActivationMode = ActivationMode.Default; public ActivationMode defActivationMode { get { return m_defActivationMode; } set { m_defActivationMode = value; } } - public String keyName + public string keyName { get { return devID + name; } } // prep for TreView usage - create a key from input+name } class ActionMap : List // carries the action list { - public String name { get; set; } // the map name + public string name { get; set; } // the map name static int ContainsLoop( List list, string value ) { @@ -76,7 +76,7 @@ namespace SCJMapper_V2.SC base.Add( pact ); } }; - Dictionary m_aMap = null; // key would be the actionmap name + Dictionary m_aMap = null; // key would be the actionmap name ActionMap m_currentMap = null; @@ -96,18 +96,18 @@ namespace SCJMapper_V2.SC /// Returns the collected actionmaps as CSV (same format as MappingVars) /// i.e. one line per actionmap where the first element is the actionmap and following are actions;defaultBinding lead by the input Key in uppercase (JKXP) /// - public String CSVMap + public string CSVMap { get { log.Debug( "DProfileReader.CSVMap - Entry" ); - String buf = ""; + string buf = ""; foreach ( ActionMap am in m_aMap.Values ) { buf += am.name + ";"; foreach ( ProfileAction a in am ) { buf += a.keyName + ";" + a.defBinding + ";" + a.defActivationMode.Name + ";" + a.defActivationMode.MultiTap.ToString( ) + ";"; // add default binding + activation mode to the CSV } - buf += String.Format( "\n" ); + buf += string.Format( "\n" ); } return buf; } @@ -150,7 +150,7 @@ namespace SCJMapper_V2.SC if ( ac.defBinding == " " ) { ac.defBinding = Joystick.JoystickCls.BlendedInput; m_currentMap.Add( ac ); // finally add it to the current map if it was bound - } else if ( !String.IsNullOrEmpty( ac.defBinding ) ) { + } else if ( !string.IsNullOrEmpty( ac.defBinding ) ) { ac.defBinding = "js1_" + ac.defBinding; m_currentMap.Add( ac ); // finally add it to the current map if it was bound } @@ -165,7 +165,7 @@ namespace SCJMapper_V2.SC if ( ac.defBinding == " " ) { ac.defBinding = Keyboard.KeyboardCls.BlendedInput; m_currentMap.Add( ac ); // finally add it to the current map if it was bound - } else if ( !String.IsNullOrEmpty( ac.defBinding ) ) { + } else if ( !string.IsNullOrEmpty( ac.defBinding ) ) { ac.defBinding = "kb1_" + ac.defBinding; m_currentMap.Add( ac ); // finally add it to the current map if it was bound } @@ -180,7 +180,7 @@ namespace SCJMapper_V2.SC if ( ac.defBinding == " " ) { ac.defBinding = Mouse.MouseCls.BlendedInput; m_currentMap.Add( ac ); // finally add it to the current map if it was bound - } else if ( !String.IsNullOrEmpty( ac.defBinding ) ) { + } else if ( !string.IsNullOrEmpty( ac.defBinding ) ) { ac.defBinding = "mo1_" + ac.defBinding; m_currentMap.Add( ac ); // finally add it to the current map if it was bound } @@ -195,7 +195,7 @@ namespace SCJMapper_V2.SC if ( ac.defBinding == " " ) { ac.defBinding = Gamepad.GamepadCls.BlendedInput; m_currentMap.Add( ac ); // finally add it to the current map if it was bound - } else if ( !String.IsNullOrEmpty( ac.defBinding ) ) { + } else if ( !string.IsNullOrEmpty( ac.defBinding ) ) { ac.defBinding = "xi1_" + ac.defBinding; m_currentMap.Add( ac ); // finally add it to the current map if it was bound } @@ -214,10 +214,10 @@ namespace SCJMapper_V2.SC /// /// An XML reader @ StartElement /// True if reading can continue - private Boolean ReadEmptyElement( XmlReader xr ) + private bool ReadEmptyElement( XmlReader xr ) { - Dictionary attr = new Dictionary( ); - String eName = xr.Name; + Dictionary attr = new Dictionary( ); + string eName = xr.Name; switch ( xr.NodeType ) { case XmlNodeType.Element: //Console.Write( "<{0}", xr.Name ); @@ -250,7 +250,7 @@ namespace SCJMapper_V2.SC /// Reads an action sub element /// /// An XML reader @ StartElement - private void ReadActionSub( XmlReader xr, String actionName, String device ) + private void ReadActionSub( XmlReader xr, string actionName, string device ) { /* @@ -281,14 +281,14 @@ namespace SCJMapper_V2.SC */ - Boolean done = false; + bool done = false; do { xr.Read( ); // get next element - Dictionary attr = new Dictionary( ); + Dictionary attr = new Dictionary( ); // add what is not contained in the structure we are about to parse attr.Add( "name", actionName ); // actionName is in the outer element - String eName = xr.Name; // this is either the device or inputdata if there are multiple entries + string eName = xr.Name; // this is either the device or inputdata if there are multiple entries // read attributes if any while ( xr.MoveToNextAttribute( ) ) { @@ -299,10 +299,26 @@ namespace SCJMapper_V2.SC // Have to add the device, otherwise the following does not work.. if ( attr.ContainsKey( "input" ) ) { - if ( !string.IsNullOrEmpty( device ) ) - attr.Add( device, attr["input"] ); // if the device is given, use it - else - attr.Add( eName, attr["input"] ); // else it should be the eName element + if ( !string.IsNullOrEmpty( device ) ) { + // device is given i.e. enclosing the input statements + // 20170512 - some keyboard entries are listed with mouse input ... ?!? + // we substitute and add such mouse entries - don't know what the game does later... + string ip = attr["input"]; + if ( !string.IsNullOrEmpty( ip ) ) { + if ( ip.StartsWith( "mouse" ) ) { + attr.Add( "mouse", attr["input"] ); // override the device given + } + else { + attr.Add( device, attr["input"] ); // if the device is given, use it + } + } + } + else { + string ip = attr["input"]; + if ( !string.IsNullOrEmpty( ip ) ) { + attr.Add( eName, ip ); // else it should be the eName element + } + } } // the element name is a control @@ -331,10 +347,10 @@ namespace SCJMapper_V2.SC /// /// An XML reader @ StartElement /// True if reading can continue - private Boolean ReadElement( XmlReader xr ) + private bool ReadElement( XmlReader xr ) { - Dictionary attr = new Dictionary( ); - String eName = xr.Name; + Dictionary attr = new Dictionary( ); + string eName = xr.Name; switch ( xr.NodeType ) { case XmlNodeType.Element: //Console.Write( "<{0}", xr.Name ); @@ -346,9 +362,9 @@ namespace SCJMapper_V2.SC if ( m_state == EState.idle ) { if ( m_nodeNameStack.Peek( ).ToLower( ) == "actionmap" ) { // check for a valid one - String mapName = attr["name"]; - String item = Array.Find( ActionMapsCls.ActionMaps, delegate ( String sstr ) { return sstr == mapName; } ); - if ( !String.IsNullOrEmpty( item ) ) { + string mapName = attr["name"]; + string item = Array.Find( ActionMapsCls.ActionMaps, delegate ( string sstr ) { return sstr == mapName; } ); + if ( !string.IsNullOrEmpty( item ) ) { // finally.... it is a valid actionmap m_currentMap = new ActionMap( ); m_currentMap.name = mapName; @@ -386,11 +402,11 @@ namespace SCJMapper_V2.SC /// /// /// - private Boolean ReadXML( XmlReader xr ) + private bool ReadXML( XmlReader xr ) { log.Debug( "DProfileReader.ReadXML - Entry" ); - Boolean retVal = true; + bool retVal = true; try { do { @@ -404,7 +420,7 @@ namespace SCJMapper_V2.SC } } else if ( xr.NodeType == XmlNodeType.EndElement ) { //Console.Write( "\n", xr.Name ); - String exitElement = m_nodeNameStack.Pop( ); + string exitElement = m_nodeNameStack.Pop( ); if ( m_state == EState.inActionMap ) if ( exitElement.ToLower( ) == "actionmap" ) m_state = EState.idle; // finished } @@ -424,7 +440,7 @@ namespace SCJMapper_V2.SC } - private Boolean ReadActivationModes( XmlReader xr ) + private bool ReadActivationModes( XmlReader xr ) { log.Debug( "DProfileReader.ReadActivationModes - Entry" ); @@ -436,8 +452,8 @@ namespace SCJMapper_V2.SC xr.Read( ); break; // finished } - String name = xr["name"]; - String mTap = xr["multiTap"]; + string name = xr["name"]; + string mTap = xr["multiTap"]; if ( !string.IsNullOrEmpty( name ) ) ActivationModes.Instance.Add( new ActivationMode( name, int.Parse( mTap ) ) ); } while ( xr.Read( ) ); @@ -455,7 +471,7 @@ namespace SCJMapper_V2.SC /// /// the XML action defaultProfile Content /// True if an action was decoded - public Boolean fromXML( String xml ) + public bool fromXML( string xml ) { log.Debug( "DProfileReader.fromXML - Entry" ); @@ -468,8 +484,8 @@ namespace SCJMapper_V2.SC XmlReader reader = XmlReader.Create( new StringReader( xml ), settings ); - m_nodeNameStack = new Stack( ); - m_aMap = new Dictionary( ); + m_nodeNameStack = new Stack( ); + m_aMap = new Dictionary( ); // init the activation modes singleton ActivationModes.Instance.Clear( ); ActivationModes.Instance.Add( ActivationMode.Default ); diff --git a/actions/ActionMapsCls.cs b/actions/ActionMapsCls.cs index 20d9765..b48121a 100644 --- a/actions/ActionMapsCls.cs +++ b/actions/ActionMapsCls.cs @@ -314,7 +314,9 @@ namespace SCJMapper_V2 r += string.Format( "{0}\n", amc.toXML( ) ); } r += string.Format( "\n" ); - return r; + + // tidy up.. + return r.Replace( string.Format( "\n\n" ), string.Format( "\n" ) ); } diff --git a/actions/ActionTree.cs b/actions/ActionTree.cs index 833af2c..bca5de4 100644 --- a/actions/ActionTree.cs +++ b/actions/ActionTree.cs @@ -34,10 +34,18 @@ namespace SCJMapper_V2 #endregion public event EventHandler NodeSelectedEvent; + // call when the items are known. private void NodeSelected( string action, string ctrl ) { NodeSelectedEvent?.Invoke( this, new ActionTreeEventArgs( action, ctrl ) ); } + // call when a selection is updated (finds the items in the master tree for the currently selected Ctrl) + private void NodeSelected() + { + string action = ""; string ctrl = ""; + SelectedActionCtrl( out action, out ctrl ); + NodeSelected( action, ctrl ); + } public ActionMapsCls ActionMaps { get; set; } // the Action Maps and Actions @@ -71,7 +79,7 @@ namespace SCJMapper_V2 /// private void M_ctrl_AfterSelect( object sender, TreeViewEventArgs e ) { - NodeSelected( this.SelectedAction, this.SelectedCtrl ); + NodeSelected( ); } @@ -161,7 +169,7 @@ namespace SCJMapper_V2 { get { if ( Ctrl.SelectedNode == null ) return false; - else return ( ( Ctrl.SelectedNode.Level == 1 ) && (IsMappedAction || IsDisabledAction)) ; + else return ( ( Ctrl.SelectedNode.Level == 1 ) && ( IsMappedAction || IsDisabledAction ) ); } } @@ -242,7 +250,7 @@ namespace SCJMapper_V2 ActionCommandCls acc = ac.AddCommand( "", matin.Index ); // show stuff FilterTree( ); - FindAndSelectCtrlByName( matn.Name ); + FindAndSelectCtrlByName( matn.Name, (matn.Parent as ActionTreeNode ).Action ); // jump to the latest if a new one was added if ( Ctrl.SelectedNode.LastNode != null ) { Ctrl.SelectedNode = Ctrl.SelectedNode.LastNode; @@ -266,7 +274,7 @@ namespace SCJMapper_V2 Dirty = true; // show stuff FilterTree( ); - FindAndSelectCtrlByName( matn.Name ); + FindAndSelectCtrlByName( matn.Name, ( matn.Parent as ActionTreeNode ).Action ); } @@ -354,7 +362,7 @@ namespace SCJMapper_V2 /// The sought node or null private ActionTreeInputNode FindMasterAction( ActionTreeInputNode atn ) { - log.DebugFormat( "FindMasterAction(ActionTreeInputNode) - Entry {0}", m_MasterTree.GetHashCode().ToString() ); + log.DebugFormat( "FindMasterAction(ActionTreeInputNode) - Entry {0}", m_MasterTree.GetHashCode( ).ToString( ) ); if ( atn.Level != 2 ) return null; // sanity TreeNode[] masterNode = m_MasterTree.Nodes.Find( atn.Name, true ); // find the same node in master @@ -408,7 +416,7 @@ namespace SCJMapper_V2 if ( topNode != null ) Ctrl.TopNode = topNode; // set view to topnode Ctrl.EndUpdate( ); // enable GUI update - NodeSelected( this.SelectedAction, this.SelectedCtrl ); + NodeSelected( ); } @@ -650,7 +658,7 @@ namespace SCJMapper_V2 acc.ActivationMode = ActivationModes.Instance.ActivationModeByName( newActivationModeName ); } atn.UpdateAction( acc ); UpdateMasterNode( atn ); - NodeSelected( this.SelectedAction, this.SelectedCtrl ); // virtual event - as the selection does not change + NodeSelected( ); // virtual event - as the selection does not change Dirty = true; } @@ -670,7 +678,7 @@ namespace SCJMapper_V2 acc.ActivationMode = ActivationModes.Instance.ActivationModeByName( newActivationModeName ); } atn.UpdateAction( acc ); UpdateMasterNode( atn ); - NodeSelected( this.SelectedAction, this.SelectedCtrl ); // virtual event - as the selection does not change + NodeSelected( ); // virtual event - as the selection does not change Dirty = true; } } @@ -700,14 +708,14 @@ namespace SCJMapper_V2 // have it - continue ac.UpdateCommandFromInput( ActionCls.DevInput( input, inKind ), acc.NodeIndex + 1 ); atn.UpdateAction( acc ); UpdateMasterNode( atn ); - NodeSelected( this.SelectedAction, this.SelectedCtrl ); // virtual event - as the selection does not change + NodeSelected( ); // virtual event - as the selection does not change Dirty = true; } else if ( Ctrl.SelectedNode.Level == 2 ) { // this is a child of an action with further commands ActionTreeNode patn = ( Ctrl.SelectedNode.Parent as ActionTreeNode ); // the parent treenode from a level 2 - ActionTreeNode atn = ( Ctrl.SelectedNode as ActionTreeNode ); // the treenode from a level 2 + ActionTreeInputNode atn = ( Ctrl.SelectedNode as ActionTreeInputNode ); // the treenode from a level 2 if ( string.IsNullOrEmpty( input ) ) atn.Action = "UNDEF"; // apply UNDEF else @@ -715,8 +723,8 @@ namespace SCJMapper_V2 ActionCls ac = FindActionObject( patn.Parent.Name, patn.Name ); // the related action in an actionmap if ( ac == null ) return false; // ERROR exit if ( checkKind ) { - if (ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) { - if (( inKind != ActionCls.ActionDevice.AD_Keyboard ) && (inKind != ActionCls.ActionDevice.AD_Mouse)) return false; // ERROR exit + if ( ac.actionDevice == ActionCls.ActionDevice.AD_Keyboard ) { + if ( ( inKind != ActionCls.ActionDevice.AD_Keyboard ) && ( inKind != ActionCls.ActionDevice.AD_Mouse ) ) return false; // ERROR exit } else { if ( ac.actionDevice != inKind ) return false; // ERROR exit @@ -727,7 +735,7 @@ namespace SCJMapper_V2 // have it - continue ac.UpdateCommandFromInput( ActionCls.DevInput( input, inKind ), acc.NodeIndex + 1 ); atn.UpdateAction( acc ); UpdateMasterNode( atn ); - NodeSelected( this.SelectedAction, this.SelectedCtrl ); // virtual event - as the selection does not change + NodeSelected( ); // virtual event - as the selection does not change Dirty = true; } return true; @@ -824,7 +832,7 @@ namespace SCJMapper_V2 /// public void ReloadTreeView() { - log.DebugFormat( "ReloadTreeView - Entry {0}", m_MasterTree.GetHashCode().ToString() ); + log.DebugFormat( "ReloadTreeView - Entry {0}", m_MasterTree.GetHashCode( ).ToString( ) ); foreach ( ActionMapCls acm in ActionMaps ) { if ( IgnoreMaps.Contains( "," + acm.name + "," ) ) break; // next @@ -859,7 +867,7 @@ namespace SCJMapper_V2 Dirty = true; } // foreach } - } catch (Exception e) { + } catch ( Exception e ) { log.DebugFormat( "ReloadTreeView - Exception in loading Treevie\n{0}", e.Message ); // map key not found ?? } } @@ -884,7 +892,7 @@ namespace SCJMapper_V2 foreach ( ActionTreeNode stn in tn.Nodes ) { if ( stn.Name == actionKey ) { if ( nodeIndex < 0 ) { - if ( Ctrl.SelectedNode == stn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); + if ( Ctrl.SelectedNode == stn ) NodeSelected( ); Ctrl.SelectedNode = stn; Ctrl.SelectedNode.EnsureVisible( ); } @@ -893,7 +901,7 @@ namespace SCJMapper_V2 int ni = 0; foreach ( ActionTreeInputNode sstn in stn.Nodes ) { if ( ni++ == nodeIndex ) { - if ( Ctrl.SelectedNode == sstn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); + if ( Ctrl.SelectedNode == sstn ) NodeSelected( ); Ctrl.SelectedNode = sstn; Ctrl.SelectedNode.EnsureVisible( ); return; // exit all loops @@ -912,28 +920,29 @@ namespace SCJMapper_V2 /// Find a control that contains the string and mark it /// this method is applied to the GUI TreeView only /// - /// The string to find - public void FindAndSelectCtrl( string ctrl ) + public void FindAndSelectCtrl( string ctrl, string actionmap ) { log.Debug( "FindAndSelectCtrl - Entry" ); foreach ( ActionTreeNode tn in Ctrl.Nodes ) { // have to search nodes of nodes - foreach ( ActionTreeNode stn in tn.Nodes ) { - if ( stn.Text.Contains( ctrl ) ) { - if ( Ctrl.SelectedNode == stn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); - Ctrl.SelectedNode = stn; - Ctrl.SelectedNode.EnsureVisible( ); - return; // exit all loops - } - // have to search nodes of nodes - foreach ( ActionTreeInputNode sstn in stn.Nodes ) { - if ( sstn.Text.Contains( ctrl ) ) { - if ( Ctrl.SelectedNode == sstn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); - Ctrl.SelectedNode = sstn; + if ( string.IsNullOrEmpty( actionmap ) || ( tn.Action == actionmap ) ) { + foreach ( ActionTreeNode stn in tn.Nodes ) { + if ( stn.Text.Contains( ctrl ) ) { + if ( Ctrl.SelectedNode == stn ) NodeSelected( ); + Ctrl.SelectedNode = stn; Ctrl.SelectedNode.EnsureVisible( ); return; // exit all loops } + // have to search nodes of nodes + foreach ( ActionTreeInputNode sstn in stn.Nodes ) { + if ( sstn.Text.Contains( ctrl ) ) { + if ( Ctrl.SelectedNode == sstn ) NodeSelected( ); + Ctrl.SelectedNode = sstn; + Ctrl.SelectedNode.EnsureVisible( ); + return; // exit all loops + } + } } } } @@ -944,28 +953,29 @@ namespace SCJMapper_V2 /// Find a control that contains the string and mark it /// this method is applied to the GUI TreeView only /// - /// The string to find - public void FindAndSelectCtrlByName( string ctrlName ) + public void FindAndSelectCtrlByName( string ctrlName, string actionmap ) { log.Debug( "FindAndSelectCtrlByName - Entry" ); foreach ( ActionTreeNode tn in Ctrl.Nodes ) { - // have to search nodes of nodes - foreach ( ActionTreeNode stn in tn.Nodes ) { - if ( stn.Name == ctrlName ) { - if ( Ctrl.SelectedNode == stn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); - Ctrl.SelectedNode = stn; - Ctrl.SelectedNode.EnsureVisible( ); - return; // exit all loops - } + if ( string.IsNullOrEmpty( actionmap ) || ( tn.Action == actionmap ) ) { // have to search nodes of nodes - foreach ( ActionTreeInputNode sstn in stn.Nodes ) { - if ( sstn.Name == ctrlName ) { - if ( Ctrl.SelectedNode == sstn ) NodeSelected( this.SelectedAction, this.SelectedCtrl ); - Ctrl.SelectedNode = sstn; + foreach ( ActionTreeNode stn in tn.Nodes ) { + if ( stn.Name == ctrlName ) { + if ( Ctrl.SelectedNode == stn ) NodeSelected( ); + Ctrl.SelectedNode = stn; Ctrl.SelectedNode.EnsureVisible( ); return; // exit all loops } + // have to search nodes of nodes + foreach ( ActionTreeInputNode sstn in stn.Nodes ) { + if ( sstn.Name == ctrlName ) { + if ( Ctrl.SelectedNode == sstn ) NodeSelected( ); + Ctrl.SelectedNode = sstn; + Ctrl.SelectedNode.EnsureVisible( ); + return; // exit all loops + } + } } } } @@ -980,7 +990,7 @@ namespace SCJMapper_V2 { List ret = new List( ); if ( string.IsNullOrEmpty( input ) ) return ret; // nothing to find here... - if ( ActionCls.IsBlendedInput(input) ) return ret; // nothing to find here... + if ( ActionCls.IsBlendedInput( input ) ) return ret; // nothing to find here... ret.Add( "Actions listed for Input: " + input ); ret.Add( "" ); @@ -994,7 +1004,7 @@ namespace SCJMapper_V2 if ( ac.defBinding == input ) { ret.Add( "" ); aMode = string.Format( "{0};{1}", ac.defActivationMode.Name, ac.defActivationMode.MultiTap ); - l = string.Format( "{0} - {1} - {2} - {3}", "profile",ac.name, acm.name, aMode ); + l = string.Format( "{0} - {1} - {2} - {3}", "profile", ac.name, acm.name, aMode ); ret.Add( l ); } foreach ( ActionCommandCls acc in ac.inputList ) { @@ -1043,6 +1053,47 @@ namespace SCJMapper_V2 } + /// + /// Returns Action and Ctrl of the currently selected node + /// + /// The action or empty + /// The control or empty + public void SelectedActionCtrl( out string action, out string ctrl ) + { + action = ""; ctrl = ""; + if ( Ctrl.SelectedNode == null ) return; + + if ( Ctrl.SelectedNode.Level == 1 ) { + ActionTreeNode matn = FindMasterAction( (ActionTreeNode)Ctrl.SelectedNode ); + action = ActionTreeNode.ActionFromNodeText( matn.Text ); + ctrl = ActionTreeNode.CommandFromNodeText( matn.Text ); + } + else if ( Ctrl.SelectedNode.Level == 2 ) { + ActionTreeNode matn = FindMasterAction( (ActionTreeInputNode)Ctrl.SelectedNode ); // the parent treenode + action = ActionTreeNode.ActionFromNodeText( matn.Text ); + ctrl = ActionTreeNode.CommandFromNodeText( matn.Text ); + } + } + + /// + /// Returns the dev control of the selected item + /// + public string SelectedCtrl + { + get { + if ( Ctrl.SelectedNode == null ) return ""; + if ( Ctrl.SelectedNode.Level == 1 ) { + ActionTreeNode matn = FindMasterAction( (ActionTreeNode)Ctrl.SelectedNode ); + return ActionTreeNode.CommandFromNodeText( matn.Text ); + } + else if ( Ctrl.SelectedNode.Level == 2 ) { + ActionTreeNode matn = FindMasterAction( (ActionTreeInputNode)Ctrl.SelectedNode ); // the parent treenode + return ActionTreeNode.CommandFromNodeText( matn.Text ); + } + else return ""; + } + } + /// /// Returns the Action name of the selected item /// @@ -1102,25 +1153,6 @@ namespace SCJMapper_V2 } } - /// - /// Returns the dev control of the selected item - /// - public string SelectedCtrl - { - get { - if ( Ctrl.SelectedNode == null ) return ""; - if ( Ctrl.SelectedNode.Level == 1 ) { - ActionTreeNode matn = FindMasterAction( (ActionTreeNode)Ctrl.SelectedNode ); - return ActionTreeNode.CommandFromNodeText( matn.Text ); - } - else if ( Ctrl.SelectedNode.Level == 2 ) { - ActionTreeNode matn = FindMasterAction( (ActionTreeInputNode)Ctrl.SelectedNode ); // the parent treenode - return ActionTreeNode.CommandFromNodeText( matn.Text ); - } - else return ""; - } - } - /// /// Update from all edits in the dataset DS_ActionMaps /// /// The dataset to update from @@ -1154,7 +1186,7 @@ namespace SCJMapper_V2 if ( countChanges > 0 ) { dsa.AcceptChanges( ); - NodeSelected( this.SelectedAction, this.SelectedCtrl ); + NodeSelected( ); nTree.Dirty = true; return nTree; } @@ -1289,7 +1321,7 @@ namespace SCJMapper_V2 if ( !string.IsNullOrEmpty( acc.Input ) ) { // set modified - note: don't add trailing semicolons as the are applied in the output formatting string aTag = "modified"; //default or modified - string aMode = string.Format( "modified;{0};{1}", acc.ActivationMode.Name, acc.ActivationMode.MultiTap ); + string aMode = string.Format( "modified;{0};{1}", acc.ActivationMode.Name, acc.ActivationMode.MultiTap ); // change if they are default mappings if ( acc.DevInput == ac.defBinding ) aTag = "default"; if ( acc.ActivationMode == ActivationMode.Default ) aMode = string.Format( "default;{0};{1}", ac.defActivationMode.Name, ac.defActivationMode.MultiTap ); diff --git a/actions/ActionTreeNode.cs b/actions/ActionTreeNode.cs index c1ed1a3..d1b2b28 100644 --- a/actions/ActionTreeNode.cs +++ b/actions/ActionTreeNode.cs @@ -148,6 +148,7 @@ namespace SCJMapper_V2 this.BackColor = other.BackColor; this.Command = other.Command; this.Modified = other.Modified; + this.Action = other.Action; //????????????????? } /// diff --git a/doc/ReadMe.txt b/doc/ReadMe.txt index 777d938..b35c12b 100644 --- a/doc/ReadMe.txt +++ b/doc/ReadMe.txt @@ -33,6 +33,8 @@ V 2.30 - BETA Build 64 - add - Tab to show all mappings for the current input (Tabbed with XML other Dump items) - add - Setting (enabled, disabled -> default) to automatically switch the new tabs - either Input or Dump - add - addbind of Mouse input is possible for Keyboard actions - seems to work somehow in the game... +- improvement - mouse mappings in kbd entries in defaultProfile are collected as mouse now and allowed to map +- improvement - removed some unneeded tree scans - to speed things up - fix - issue with user activations modes while dumping the mapping list - fix - issue with loading a map with gamepad mappings and the gamepad is not connected - fixes and refacturing while encountered... diff --git a/doc/SCJMapper_QGuide V2.30beta.pdf b/doc/SCJMapper_QGuide V2.30beta.pdf new file mode 100644 index 0000000..5663375 Binary files /dev/null and b/doc/SCJMapper_QGuide V2.30beta.pdf differ diff --git a/doc/SCJMapper_QGuide V2.x.pub b/doc/SCJMapper_QGuide V2.x.pub index 98e4690..24b8350 100644 Binary files a/doc/SCJMapper_QGuide V2.x.pub and b/doc/SCJMapper_QGuide V2.x.pub differ