diff --git a/Form1.Designer.cs b/Form1.Designer.cs index c055433..5f5f1b1 100644 --- a/Form1.Designer.cs +++ b/Form1.Designer.cs @@ -70,22 +70,24 @@ this.btAssign = new System.Windows.Forms.Button(); this.treeView1 = new System.Windows.Forms.TreeView(); this.cmAddDel = new System.Windows.Forms.ContextMenuStrip(this.components); + this.tdiCollapseAll = new System.Windows.Forms.ToolStripMenuItem(); + this.tdiExpandAll = new System.Windows.Forms.ToolStripMenuItem(); + this.tdiSGroup1 = new System.Windows.Forms.ToolStripSeparator(); this.tdiAssignBinding = new System.Windows.Forms.ToolStripMenuItem(); this.tdiBlendBinding = new System.Windows.Forms.ToolStripMenuItem(); this.tdiClearBinding = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.tdiSGroup2 = new System.Windows.Forms.ToolStripSeparator(); this.tdiAddBinding = new System.Windows.Forms.ToolStripMenuItem(); this.tdiDelBinding = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.tdiSGroup3 = new System.Windows.Forms.ToolStripSeparator(); this.tdiTxDefActivationMode = new System.Windows.Forms.ToolStripTextBox(); this.tdiCbxActivation = new System.Windows.Forms.ToolStripComboBox(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); + this.tdiSGroup4 = new System.Windows.Forms.ToolStripSeparator(); this.tdiAddMod1 = new System.Windows.Forms.ToolStripMenuItem(); this.tdiAddMod2 = new System.Windows.Forms.ToolStripMenuItem(); this.tdiAddMod3 = new System.Windows.Forms.ToolStripMenuItem(); this.tc1 = new System.Windows.Forms.TabControl(); this.tabJS1 = new System.Windows.Forms.TabPage(); - this.UC_JoyPanel = new SCJMapper_V2.Joystick.UC_JoyPanel(); this.panel1 = new System.Windows.Forms.Panel(); this.btClip = new System.Windows.Forms.Button(); this.txRebind = new System.Windows.Forms.TextBox(); @@ -147,6 +149,7 @@ this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); + this.UC_JoyPanel = new SCJMapper_V2.Joystick.UC_JoyPanel(); this.cmCopyPaste.SuspendLayout(); this.panel2.SuspendLayout(); this.cmMouseEntry.SuspendLayout(); @@ -508,24 +511,48 @@ // cmAddDel // this.cmAddDel.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tdiCollapseAll, + this.tdiExpandAll, + this.tdiSGroup1, this.tdiAssignBinding, this.tdiBlendBinding, this.tdiClearBinding, - this.toolStripSeparator2, + this.tdiSGroup2, this.tdiAddBinding, this.tdiDelBinding, - this.toolStripSeparator5, + this.tdiSGroup3, this.tdiTxDefActivationMode, this.tdiCbxActivation, - this.toolStripSeparator6, + this.tdiSGroup4, this.tdiAddMod1, this.tdiAddMod2, this.tdiAddMod3}); this.cmAddDel.Name = "cmAddDel"; - this.cmAddDel.Size = new System.Drawing.Size(221, 407); + this.cmAddDel.Size = new System.Drawing.Size(221, 479); this.cmAddDel.Closed += new System.Windows.Forms.ToolStripDropDownClosedEventHandler(this.cmAddDel_Closed); this.cmAddDel.Opening += new System.ComponentModel.CancelEventHandler(this.cmAddDel_Opening); // + // tdiCollapseAll + // + this.tdiCollapseAll.ForeColor = System.Drawing.Color.MediumBlue; + this.tdiCollapseAll.Name = "tdiCollapseAll"; + this.tdiCollapseAll.Size = new System.Drawing.Size(220, 22); + this.tdiCollapseAll.Text = "Collapse to selected"; + this.tdiCollapseAll.Click += new System.EventHandler(this.tdiCollapseAll_Click); + // + // tdiExpandAll + // + this.tdiExpandAll.ForeColor = System.Drawing.Color.MediumBlue; + this.tdiExpandAll.Name = "tdiExpandAll"; + this.tdiExpandAll.Size = new System.Drawing.Size(220, 22); + this.tdiExpandAll.Text = "Expand all Mappings"; + this.tdiExpandAll.Click += new System.EventHandler(this.tdiExpandAll_Click); + // + // tdiSGroup1 + // + this.tdiSGroup1.Name = "tdiSGroup1"; + this.tdiSGroup1.Size = new System.Drawing.Size(217, 6); + // // tdiAssignBinding // this.tdiAssignBinding.Name = "tdiAssignBinding"; @@ -547,10 +574,10 @@ this.tdiClearBinding.Text = "Clear Mapping"; this.tdiClearBinding.Click += new System.EventHandler(this.tdiClearBinding_Click); // - // toolStripSeparator2 + // tdiSGroup2 // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(217, 6); + this.tdiSGroup2.Name = "tdiSGroup2"; + this.tdiSGroup2.Size = new System.Drawing.Size(217, 6); // // tdiAddBinding // @@ -566,10 +593,10 @@ this.tdiDelBinding.Text = "Delete Mapping"; this.tdiDelBinding.Click += new System.EventHandler(this.tdiDelBinding_Click); // - // toolStripSeparator5 + // tdiSGroup3 // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(217, 6); + this.tdiSGroup3.Name = "tdiSGroup3"; + this.tdiSGroup3.Size = new System.Drawing.Size(217, 6); // // tdiTxDefActivationMode // @@ -593,10 +620,10 @@ this.tdiCbxActivation.Size = new System.Drawing.Size(160, 180); this.tdiCbxActivation.Click += new System.EventHandler(this.tdiCbxActivation_Click); // - // toolStripSeparator6 + // tdiSGroup4 // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(217, 6); + this.tdiSGroup4.Name = "tdiSGroup4"; + this.tdiSGroup4.Size = new System.Drawing.Size(217, 6); // // tdiAddMod1 // @@ -652,15 +679,6 @@ this.tabJS1.TabIndex = 0; this.tabJS1.Text = "Joystick 1"; // - // UC_JoyPanel - // - this.UC_JoyPanel.Dock = System.Windows.Forms.DockStyle.Fill; - this.UC_JoyPanel.JsAssignment = 0; - this.UC_JoyPanel.Location = new System.Drawing.Point(3, 3); - this.UC_JoyPanel.Name = "UC_JoyPanel"; - this.UC_JoyPanel.Size = new System.Drawing.Size(274, 336); - this.UC_JoyPanel.TabIndex = 0; - // // panel1 // this.tlpanel.SetColumnSpan(this.panel1, 3); @@ -1349,6 +1367,15 @@ this.statusStrip1.TabIndex = 26; this.statusStrip1.Text = "statusStrip1"; // + // UC_JoyPanel + // + this.UC_JoyPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.UC_JoyPanel.JsAssignment = 0; + this.UC_JoyPanel.Location = new System.Drawing.Point(3, 3); + this.UC_JoyPanel.Name = "UC_JoyPanel"; + this.UC_JoyPanel.Size = new System.Drawing.Size(274, 336); + this.UC_JoyPanel.TabIndex = 0; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1478,7 +1505,7 @@ private System.Windows.Forms.CheckBox cbxInvStrafeLon; private System.Windows.Forms.CheckBox cbxInvThrottle; private System.Windows.Forms.Button btDumpLog; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripSeparator tdiSGroup2; private System.Windows.Forms.ToolStripMenuItem tdiBlendBinding; private System.Windows.Forms.ToolStripMenuItem tdiClearBinding; private System.Windows.Forms.ToolStripMenuItem tdiAssignBinding; @@ -1490,14 +1517,14 @@ private System.Windows.Forms.ToolStripMenuItem tmeWUp; private System.Windows.Forms.ToolStripMenuItem tmeWDown; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripSeparator tdiSGroup3; private System.Windows.Forms.ToolStripMenuItem tdiAddMod1; private System.Windows.Forms.ToolStripMenuItem tdiAddMod2; private System.Windows.Forms.ToolStripMenuItem tdiAddMod3; private System.Windows.Forms.Button btMakeMod; private System.Windows.Forms.Label lblPTU; private System.Windows.Forms.ToolStripComboBox tdiCbxActivation; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; + private System.Windows.Forms.ToolStripSeparator tdiSGroup4; private System.Windows.Forms.ToolStripTextBox tdiTxDefActivationMode; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label lblProfileUsed; @@ -1506,6 +1533,9 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel4; private System.Windows.Forms.Button btDumpProfile; private System.Windows.Forms.Button btTable; + private System.Windows.Forms.ToolStripMenuItem tdiCollapseAll; + private System.Windows.Forms.ToolStripMenuItem tdiExpandAll; + private System.Windows.Forms.ToolStripSeparator tdiSGroup1; } } diff --git a/Form1.cs b/Form1.cs index be3fcfa..44a7d21 100644 --- a/Form1.cs +++ b/Form1.cs @@ -66,6 +66,7 @@ namespace SCJMapper_V2 /// private ActionTree m_AT = null; + private OGL.FormJSCalCurve JSCAL = null; private FormTable FTAB = null; @@ -93,8 +94,7 @@ namespace SCJMapper_V2 // catch if the Tag is not an int... try { return ( ( int )page.Tag == ID_GAMEPAD_TAB ); - } - catch { + } catch { return false; } } @@ -104,20 +104,16 @@ namespace SCJMapper_V2 /// private ActionCls.ActionDevice InputMode { - get - { + get { // take care of the sequence.. mouse overrides key but both override joy and game if ( m_mouseIn ) { // 20151220BM: add mouse device (from AC 2.0 defaultProfile usage) return ActionCls.ActionDevice.AD_Mouse; - } - else if ( m_keyIn ) { + } else if ( m_keyIn ) { return ActionCls.ActionDevice.AD_Keyboard; - } - else { + } else { if ( IsGamepadTab( tc1.SelectedTab ) ) { return ActionCls.ActionDevice.AD_Gamepad; - } - else { + } else { return ActionCls.ActionDevice.AD_Joystick; } } @@ -148,8 +144,7 @@ namespace SCJMapper_V2 // Load the icon from our resources System.Resources.ResourceManager resources = new System.Resources.ResourceManager( this.GetType( ) ); this.Icon = ( ( System.Drawing.Icon )( resources.GetObject( "$this.Icon" ) ) ); - } - catch { + } catch { ; // well... } @@ -160,7 +155,7 @@ namespace SCJMapper_V2 private void MainForm_Deactivate( object sender, EventArgs e ) { timer1.Enabled = false; - if ( m_Joystick!=null) m_Joystick.Deactivate( ); + if ( m_Joystick != null ) m_Joystick.Deactivate( ); if ( m_Keyboard != null ) m_Keyboard.Deactivate( ); } @@ -223,9 +218,6 @@ namespace SCJMapper_V2 rtb.DragDrop += new DragEventHandler( rtb_DragDrop ); rtb.AllowDrop = true; // add Drop to rtb - // load profiles - log.Debug( "Loading Profiles" ); - // load mappings log.Debug( "Loading Mappings" ); LoadMappingDD( ); @@ -259,8 +251,7 @@ namespace SCJMapper_V2 Grab( ); m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist txMappingName.BackColor = MyColors.SuccessColor; - } - else { + } else { log.WarnFormat( "Last used mapping not available ({0})", txMappingName.Text ); txMappingName.BackColor = MyColors.ErrorColor; } @@ -349,8 +340,7 @@ namespace SCJMapper_V2 } tabRegion.Exclude( TabItemRect ); e.Graphics.FillRegion( backBrush, tabRegion ); - } - else { + } else { f = e.Font; foreBrush = new SolidBrush( e.ForeColor ); } @@ -371,13 +361,11 @@ namespace SCJMapper_V2 if ( e.Index == this.tc1.SelectedIndex ) { f.Dispose( ); backBrush.Dispose( ); - } - else { + } else { backBrush.Dispose( ); foreBrush.Dispose( ); } - } - catch ( Exception Ex ) { + } catch ( Exception Ex ) { log.Error( "Ex DrawItem", Ex ); MessageBox.Show( Ex.Message.ToString( ), "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Information ); } @@ -427,8 +415,7 @@ namespace SCJMapper_V2 // valid Device Tab if ( IsGamepadTab( tc1.TabPages[deviceTabIndex] ) ) { ; // ignore gamepads - } - else if ( m_Joystick.Count > joyStickIndex ) { + } else if ( m_Joystick.Count > joyStickIndex ) { // there is a joystick device left.. m_Joystick[joyStickIndex].JSAssignment = joyStickIndex + 1; // assign number 1.. m_AT.ActionMaps.jsN[deviceTabIndex] = m_Joystick[joyStickIndex].DevName; @@ -464,8 +451,7 @@ namespace SCJMapper_V2 log.Debug( "Get Mouse device" ); m_Mouse = new MouseCls( new SharpDX.DirectInput.Mouse( directInput ), this ); - } - catch ( Exception ex ) { + } catch ( Exception ex ) { log.Debug( "InitDirectInput phase 1 failed unexpectedly", ex ); return false; } @@ -492,8 +478,7 @@ namespace SCJMapper_V2 break; } } - } - else { + } else { jsDevice = new SharpDX.DirectInput.Joystick( directInput, instance.InstanceGuid ); log.DebugFormat( "Create the device interface for: {0}", jsDevice.Information.ProductName ); } @@ -512,8 +497,7 @@ namespace SCJMapper_V2 gs.SetDeviceName( instance.ProductName ); tc1.TabPages[tabs].ToolTipText = String.Format( "{0}\n{1}", gs.DevName, " " ); toolTip1.SetToolTip( tc1.TabPages[tabs], tc1.TabPages[tabs].ToolTipText ); - } - else { + } else { log.Debug( "Add first Joystick panel" ); log.Debug( "Create Joystick instance" ); tc1.TabPages[tabs].Text = String.Format( "Joystick {0}", nJs++ ); @@ -521,8 +505,7 @@ namespace SCJMapper_V2 tc1.TabPages[tabs].ToolTipText = String.Format( "{0}\n{1}", js.DevName, js.DevInstanceGUID ); toolTip1.SetToolTip( tc1.TabPages[tabs], tc1.TabPages[tabs].ToolTipText ); } - } - else { + } else { if ( gpDevice != null ) { log.Debug( "Add next Gamepad panel" ); tc1.TabPages.Add( "Gamepad " ); @@ -533,8 +516,7 @@ namespace SCJMapper_V2 gs.SetDeviceName( instance.ProductName ); tc1.TabPages[tabs].ToolTipText = String.Format( "{0}\n{1}", gs.DevName, " " ); toolTip1.SetToolTip( tc1.TabPages[tabs], tc1.TabPages[tabs].ToolTipText ); - } - else { + } else { log.Debug( "Add next Joystick panel" ); // setup the further tab contents along the reference one in TabPage[0] (the control named UC_JoyPanel) tc1.TabPages.Add( String.Format( "Joystick {0}", nJs++ ) ); @@ -551,8 +533,7 @@ namespace SCJMapper_V2 m_Gamepad = gs; SetGamepadTab( tc1.TabPages[tabs] ); // indicates the gamepad tab (murks..) MyColors.GamepadColor = MyColors.TabColor[tabs]; // save it for future use - } - else if ( js != null ) { + } else if ( js != null ) { m_Joystick.Add( js ); // add to joystick list tc1.TabPages[tabs].Tag = ( m_Joystick.Count - 1 ); // used to find the tab for polling } @@ -563,8 +544,7 @@ namespace SCJMapper_V2 if ( tabs >= JoystickCls.JSnum_MAX ) break; // cannot load more JSticks than predefined Tabs } log.DebugFormat( "Added {0} GameControl devices", tabs ); - } - catch ( Exception ex ) { + } catch ( Exception ex ) { log.Debug( "InitDirectInput phase 2 failed unexpectedly", ex ); return false; } @@ -641,8 +621,7 @@ namespace SCJMapper_V2 if ( j != null ) { m_AT.ActionMaps.jsNGUID[i] = j.DevInstanceGUID; // subst for missing one (version up etc.) j.JSAssignment = i + 1; // i is 0 based ; jsN is 1 based - } - else { + } else { // a valid but unknown GUID m_AT.ActionMaps.Clear_jsEntry( i ); @@ -667,8 +646,7 @@ namespace SCJMapper_V2 // get the text into the view try { rtb.ScrollToCaret( ); - } - catch { + } catch { ; // just ignore } UpdateTable( ); @@ -738,16 +716,14 @@ namespace SCJMapper_V2 ctrl = m_Gamepad.GetLastChange( ); timer1.Interval = 750; // allow more time to release buttons [msec] } - } - else { + } else { // poll active Joystick m_curJoystick.GetData( ); // poll the device // add keyboard modifier - if there are .. if ( m_Keyboard == null ) { // no keyboard => no modifier ctrl = JSStr( ) + m_curJoystick.GetLastChange( ); // show last handled JS control - } - else { + } else { UpdateModifiers( ); // get the last keyboard modifer to compose the command, also handles the modifier lifetime ctrl = JSStr( ) + m_persistentMods + m_curJoystick.GetLastChange( ); // show last handled JS control } @@ -759,8 +735,7 @@ namespace SCJMapper_V2 // Handle Throttle checkbox if ( JoystickCls.CanThrottle( ctrl ) ) { cbxThrottle.Enabled = true; - } - else { + } else { cbxThrottle.Checked = false; cbxThrottle.Enabled = false; } // Update joystick modifiers - not currently used @@ -817,8 +792,7 @@ namespace SCJMapper_V2 if ( m_AT.UpdateSelectedItem( JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ), InputMode, true ) ) { if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; UpdateTableSelectedItem( ); - } - else MySounds.PlayNotfound( ); + } else MySounds.PlayNotfound( ); } private void btBlend_Click( object sender, EventArgs e ) @@ -827,8 +801,7 @@ namespace SCJMapper_V2 m_AT.BlendBinding( ); UpdateTableSelectedItem( ); if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; - } - else MySounds.PlayCannot( ); + } else MySounds.PlayCannot( ); } private void btClear_Click( object sender, EventArgs e ) @@ -837,8 +810,7 @@ namespace SCJMapper_V2 m_AT.ClearBinding( ); UpdateTableSelectedItem( ); if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; - } - else MySounds.PlayCannot( ); + } else MySounds.PlayCannot( ); } private void btMakeMod_Click( object sender, EventArgs e ) @@ -859,14 +831,12 @@ namespace SCJMapper_V2 tdiAddMod1.Visible = true; m_curJoystick.UpdateModifier( lblLastJ.Text, true ); m_AT.Dirty = true; if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; - } - else if ( string.IsNullOrEmpty( tdiAddMod2.Text ) ) { + } else if ( string.IsNullOrEmpty( tdiAddMod2.Text ) ) { tdiAddMod2.Text = string.Format( "MOD: {0}", lblLastJ.Text ); tdiAddMod2.Visible = true; m_curJoystick.UpdateModifier( lblLastJ.Text, true ); m_AT.Dirty = true; if ( m_AT.Dirty ) btDump.BackColor = MyColors.DirtyColor; - } - else if ( string.IsNullOrEmpty( tdiAddMod3.Text ) ) { + } else if ( string.IsNullOrEmpty( tdiAddMod3.Text ) ) { tdiAddMod3.Text = string.Format( "MOD: {0}", lblLastJ.Text ); tdiAddMod3.Visible = true; m_curJoystick.UpdateModifier( lblLastJ.Text, true ); @@ -1070,25 +1040,27 @@ namespace SCJMapper_V2 // Node Menu private ActivationMode m_prevActivationMode = new ActivationMode( ActivationMode.Default ); + private void cmAddDel_Opening( object sender, CancelEventArgs e ) { // note: the right click selected the node ContextMenuStrip cts = ( sender as ContextMenuStrip ); - Boolean any=false; // above separator - Boolean any2 = false; // below separator + Boolean any2 = false; // Group 2 + Boolean any3 = false; // Group 3 + Boolean any4 = false; // Group 4 + m_prevActivationMode = ActivationMode.Default; // switch Closing handling OFF in case we don't show anything if ( m_AT.CanAssignBinding ) { - cts.Items[0].Text = "Assign: " + JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ); + tdiAssignBinding.Text = "Assign: " + JoystickCls.MakeThrottle( lblLastJ.Text, cbxThrottle.Checked ); } - cts.Items[0].Visible = m_AT.CanAssignBinding; any = any || m_AT.CanAssignBinding; // Assign - cts.Items[1].Visible = m_AT.CanBlendBinding; any = any || m_AT.CanBlendBinding; // Blend - cts.Items[2].Visible = m_AT.CanClearBinding; any = any || m_AT.CanClearBinding; // Clear + tdiAssignBinding.Visible = m_AT.CanAssignBinding; any2 = any2 || m_AT.CanAssignBinding; // Assign + tdiBlendBinding.Visible = m_AT.CanBlendBinding; any2 = any2 || m_AT.CanBlendBinding; // Blend + tdiClearBinding.Visible = m_AT.CanClearBinding; any2 = any2 || m_AT.CanClearBinding; // Clear - cts.Items[4].Visible = m_AT.CanAddBinding; any2 = any2 || m_AT.CanAddBinding; // Add - cts.Items[5].Visible = m_AT.CanDelBinding; any2 = any2 || m_AT.CanDelBinding; // Del + tdiAddBinding.Visible = m_AT.CanAddBinding; any3 = any3 || m_AT.CanAddBinding; // Add + tdiDelBinding.Visible = m_AT.CanDelBinding; any3 = any3 || m_AT.CanDelBinding; // Del - cts.Items[3].Visible = any2; // separator // handle activation modes - there is a default one and the list of choosable ones // there is no further decision on can or cannot - any(2) is enough to know @@ -1100,13 +1072,19 @@ namespace SCJMapper_V2 else tdiTxDefActivationMode.Text = string.Format( "Profile: {0}", am[0].Name ); // show the default element - if ( any && m_AT.IsMappedAction ) { + if ( any2 && m_AT.IsMappedAction ) { m_prevActivationMode = am[1]; // this is the selected one tdiCbxActivation.Visible = true; + any4 = true; tdiCbxActivation.Text = m_prevActivationMode.Name; } - e.Cancel = !( any || any2 ); + tdiSGroup1.Visible = any2; // separator + tdiSGroup2.Visible = any3; // separator + tdiSGroup3.Visible = any4; // separator + tdiTxDefActivationMode.Visible = any4; + + e.Cancel = false; // !( any2 || any3 ); } // after user entry of the context menu - see if one has changed the ActivationMode @@ -1114,6 +1092,28 @@ namespace SCJMapper_V2 { } + // Collapses all but the selected node or the part where it is in + private void tdiCollapseAll_Click( object sender, EventArgs e ) + { + TreeNode selNodeActionMap = treeView1.SelectedNode; + TreeNode selNodeParent = selNodeActionMap; + // see if we have a parent.. + if ( selNodeActionMap.Level > 1 ) + selNodeParent = selNodeActionMap.Parent; + + treeView1.CollapseAll( ); + selNodeParent.Expand( ); + treeView1.SelectedNode = selNodeActionMap; + treeView1.SelectedNode.EnsureVisible( ); + } + + private void tdiExpandAll_Click( object sender, EventArgs e ) + { + treeView1.ExpandAll( ); + treeView1.SelectedNode.EnsureVisible( ); + } + + private void tdiCbxActivation_Click( object sender, EventArgs e ) { cmAddDel.Close( ToolStripDropDownCloseReason.ItemClicked ); @@ -1179,15 +1179,13 @@ namespace SCJMapper_V2 break; } } - } - else { + } else { dropEnabled = false; } if ( dropEnabled ) { e.Effect = DragDropEffects.Copy; - } - else { + } else { e.Effect = DragDropEffects.None; } } @@ -1208,8 +1206,7 @@ namespace SCJMapper_V2 Grab( ); m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist txMappingName.BackColor = MyColors.SuccessColor; - } - else { + } else { txMappingName.BackColor = MyColors.ErrorColor; } } @@ -1233,8 +1230,7 @@ namespace SCJMapper_V2 m_AppSettings.MyMappingName = txMappingName.Text; m_AppSettings.Save( );// last used - persist txMappingName.BackColor = MyColors.SuccessColor; } - } - else { + } else { txMappingName.BackColor = MyColors.ErrorColor; } } @@ -1243,8 +1239,7 @@ namespace SCJMapper_V2 { if ( SCMappings.IsValidMappingName( txMappingName.Text ) ) { txMappingName.BackColor = MyColors.ValidColor; - } - else { + } else { txMappingName.BackColor = MyColors.InvalidColor; } } @@ -1302,8 +1297,7 @@ namespace SCJMapper_V2 j = m_Joystick.Find_jsN( i + 1 ); if ( j != null ) { newTree.ActionMaps.jsN[i] = j.DevName; newTree.ActionMaps.jsNGUID[i] = j.DevInstanceGUID; - } - else { + } else { newTree.ActionMaps.jsN[i] = ""; newTree.ActionMaps.jsNGUID[i] = ""; } } @@ -1344,8 +1338,7 @@ namespace SCJMapper_V2 nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command") if ( !String.IsNullOrWhiteSpace( nodeText ) ) { dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) ); - } - else { + } else { find = ActionTreeNode.ComposeNodeText( "v_yaw", "xi" ); nodeText = m_AT.FindText( "spaceship_movement", find ); if ( !String.IsNullOrWhiteSpace( nodeText ) ) { @@ -1361,21 +1354,19 @@ namespace SCJMapper_V2 m_AT.ActionMaps.TuningY.Action = nodeText; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX; JSCAL.YawTuning = m_AT.ActionMaps.TuningY; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.Action = nodeText; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneY; JSCAL.YawTuning = m_AT.ActionMaps.TuningY; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.Action = nodeText; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneZ; JSCAL.YawTuning = m_AT.ActionMaps.TuningY; } - // GP commands that are supported - X - else if ( nodeText.ToLowerInvariant( ).Contains( "_thumblx" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbrx" ) ) { + // GP commands that are supported - X + else if ( nodeText.ToLowerInvariant( ).Contains( "_thumblx" ) || nodeText.ToLowerInvariant( ).Contains( "_thumbrx" ) ) { m_AT.ActionMaps.TuningY.GameDevice = dev; m_AT.ActionMaps.TuningY.Action = nodeText; m_AT.ActionMaps.TuningY.Deadzone = m_AT.ActionMaps.DeadzoneX; @@ -1389,8 +1380,7 @@ namespace SCJMapper_V2 nodeText = m_AT.FindText( "spaceship_movement", find ); // returns "" or a complete text ("action - command") if ( !String.IsNullOrWhiteSpace( nodeText ) ) { dev = m_Joystick.Find_jsN( JoystickCls.JSNum( ActionTreeNode.CommandFromNodeText( nodeText ) ) ); - } - else { + } else { find = ActionTreeNode.ComposeNodeText( "v_pitch", "xi" ); nodeText = m_AT.FindText( "spaceship_movement", find ); if ( !String.IsNullOrWhiteSpace( nodeText ) ) { @@ -1406,14 +1396,12 @@ namespace SCJMapper_V2 m_AT.ActionMaps.TuningP.Action = nodeText; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneX; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.Action = nodeText; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneY; JSCAL.PitchTuning = m_AT.ActionMaps.TuningP; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { m_AT.ActionMaps.TuningP.GameDevice = dev; m_AT.ActionMaps.TuningP.Action = nodeText; m_AT.ActionMaps.TuningP.Deadzone = m_AT.ActionMaps.DeadzoneZ; @@ -1444,14 +1432,12 @@ namespace SCJMapper_V2 m_AT.ActionMaps.TuningR.Action = nodeText; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneX; JSCAL.RollTuning = m_AT.ActionMaps.TuningR; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_y" ) || nodeText.ToLowerInvariant( ).EndsWith( "_roty" ) ) { m_AT.ActionMaps.TuningR.GameDevice = dev; m_AT.ActionMaps.TuningR.Action = nodeText; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneY; JSCAL.RollTuning = m_AT.ActionMaps.TuningR; - } - else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { + } else if ( nodeText.ToLowerInvariant( ).EndsWith( "_z" ) || nodeText.ToLowerInvariant( ).EndsWith( "_rotz" ) ) { m_AT.ActionMaps.TuningR.GameDevice = dev; m_AT.ActionMaps.TuningR.Action = nodeText; m_AT.ActionMaps.TuningR.Deadzone = m_AT.ActionMaps.DeadzoneZ; @@ -1493,8 +1479,7 @@ namespace SCJMapper_V2 lblLastJ.Focus( ); m_Keyboard.Activate( ); m_Keyboard.GetData( ); // poll to aquire once - } - else { + } else { m_mouseIn = false; // not longer lblLastJ.BackColor = MyColors.ValidColor; btJsKbd.ImageKey = "J"; @@ -1513,8 +1498,7 @@ namespace SCJMapper_V2 // don't override modifiers when we are in mouse mode and the mod is the same and there is no kbd entry.... if ( m_mouseIn && ( keyModS == modS ) && ( m_persistentMods == ( modS + "+" ) ) ) { ; // nothing here - - } - else { + } else { lblLastJ.Text = m_Keyboard.GetLastChange( true ); m_mouseIn = false; // clear on kbd input } @@ -1539,13 +1523,11 @@ namespace SCJMapper_V2 if ( modS.Contains( KeyboardCls.ClearMods ) ) { // allow to cancel modifiers m_persistentMods = ""; // kill persistent ones - } - else { + } else { m_persistentMods = modS + "+"; m_modifierTimeout = c_modifierTime; // restart show interval } - } - else { + } else { if ( m_modifierTimeout <= 0 ) { m_persistentMods = ""; // modifier timed out m_mouseIn = false; @@ -1574,8 +1556,7 @@ namespace SCJMapper_V2 if ( int.TryParse( ( string )ts.Tag, out btNum ) ) { // got a button (most likely..) item = "mouse" + btNum.ToString( ); - } - else if ( ( string )ts.Tag == "X" ) + } else if ( ( string )ts.Tag == "X" ) item = "maxis_x"; else if ( ( string )ts.Tag == "Y" ) item = "maxis_y"; @@ -1594,14 +1575,12 @@ namespace SCJMapper_V2 if ( m_Keyboard == null ) { // no keyboard = no modifier ctrl = MouseCls.MakeCtrl( item, "" ); // show last handled JS control - } - else { + } else { UpdateModifiers( ); ctrl = MouseCls.MakeCtrl( item, m_persistentMods ); // show last handled JS control } m_mouseIn = true; // for this one only - } - else if ( KeyboardCls.IsDeviceClass( device ) ) { + } else if ( KeyboardCls.IsDeviceClass( device ) ) { UpdateModifiers( ); ctrl = KeyboardCls.MakeCtrl( item, m_persistentMods ); // show last handled JS control } @@ -1618,7 +1597,7 @@ namespace SCJMapper_V2 // only if needed if ( ( FTAB != null ) && FTAB.Visible ) { FTAB.SuspendDGV( ); - m_AT.ActionMaps.toDataSet( FTAB.DS_AMaps); + m_AT.ActionMaps.toDataSet( FTAB.DS_AMaps ); FTAB.ResumeDGV( ); FTAB.Populate( ); } @@ -1639,7 +1618,7 @@ namespace SCJMapper_V2 private void btTable_Click( object sender, EventArgs e ) { bool created = false; - if (FTAB == null ) { + if ( FTAB == null ) { FTAB = new FormTable( ); FTAB.EditActionEvent += FTAB_EditActionEvent; FTAB.UpdateEditEvent += FTAB_UpdateEditEvent; @@ -1655,7 +1634,7 @@ namespace SCJMapper_V2 } else { FTAB.Show( ); - if (created) { + if ( created ) { FTAB.Size = m_AppSettings.FormTableSize; FTAB.Location = m_AppSettings.FormTableLocation; FTAB.LastColSize = m_AppSettings.FormTableColumnWidth; @@ -1681,13 +1660,12 @@ namespace SCJMapper_V2 } - + // called when the user if the TAB form wants to edit a row private void FTAB_EditActionEvent( object sender, EditRowEventArgs e ) { m_AT.FindAndSelectActionKey( e.Actionmap, e.Actionkey, e.Nodeindex ); } - } } diff --git a/Form1.resx b/Form1.resx index 87c7bab..9b408f9 100644 --- a/Form1.resx +++ b/Form1.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA6 - EAAAAk1TRnQBSQFMAgEBCQEAAWABEAFgAhABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + EAAAAk1TRnQBSQFMAgEBCQEAAcABEAHAAhABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AUADAAEwAwABAQEAAQgGAAEMGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm @@ -470,15 +470,6 @@ x1//2Q== - - 133, 17 - - - 209, 17 - - - 421, 17 - iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABGdBTUEAALGOfPtRkwAAACBjSFJNAACH @@ -551,6 +542,15 @@ Tesk88046SuRb2gfwdMB6S/DHs/UzS4d0QAAAABJRU5ErkJggg== + + 133, 17 + + + 209, 17 + + + 421, 17 + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 diff --git a/FormSettings.cs b/FormSettings.cs index 7872fc1..d71c883 100644 --- a/FormSettings.cs +++ b/FormSettings.cs @@ -64,6 +64,8 @@ namespace SCJMapper_V2 for ( int i = 0; i < chkLbActionMaps.Items.Count; i++ ) { if ( m_owner.IgnoreActionmaps.Contains( "," + chkLbActionMaps.Items[i].ToString( ) + "," ) ) { chkLbActionMaps.SetItemChecked( i, true ); + } else { + chkLbActionMaps.SetItemChecked( i, false ); // 20161223: fix checked items and Canceled } } @@ -104,7 +106,7 @@ namespace SCJMapper_V2 // Ignore actionmaps String ignore = ","; for ( int i = 0; i < chkLbActionMaps.Items.Count; i++ ) { - if ( chkLbActionMaps.GetItemChecked( i ) ) { + if ( chkLbActionMaps.GetItemCheckState( i ) == CheckState.Checked ) { ignore += chkLbActionMaps.Items[i].ToString( ) + ","; } } @@ -190,6 +192,6 @@ namespace SCJMapper_V2 } } - + } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8732573..14e4962 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion( "2.26.0.60" )] -[assembly: AssemblyFileVersion( "2.26.0.60" )] +[assembly: AssemblyVersion( "2.27.0.61" )] +[assembly: AssemblyFileVersion( "2.27.0.61" )] diff --git a/SC/DProfileReader.cs b/SC/DProfileReader.cs index a899b37..e8f5bc2 100644 --- a/SC/DProfileReader.cs +++ b/SC/DProfileReader.cs @@ -399,8 +399,6 @@ namespace SCJMapper_V2.SC Boolean retVal = true; - if ( ActionMapsCls.ActionMaps.Length == 0 ) ActionMapsCls.LoadSupportedActionMaps( ); // make sure we have them loaded ( refactoring to get a singleton or so...) - try { do { if ( xr.IsStartElement( ) ) { @@ -472,12 +470,15 @@ namespace SCJMapper_V2.SC { log.Debug( "DProfileReader.fromXML - Entry" ); + if ( ActionMapsCls.ActionMaps.Length == 0 ) ActionMapsCls.LoadSupportedActionMaps( ActionMapList( xml ) ); // make sure we have them loaded ( refactoring to get a singleton or so...) + XmlReaderSettings settings = new XmlReaderSettings( ); settings.ConformanceLevel = ConformanceLevel.Fragment; settings.IgnoreWhitespace = true; settings.IgnoreComments = true; XmlReader reader = XmlReader.Create( new StringReader( xml ), settings ); + m_nodeNameStack = new Stack( ); m_aMap = new Dictionary( ); // init the activation modes singleton @@ -489,13 +490,39 @@ namespace SCJMapper_V2.SC ValidContent &= ReadActivationModes( reader ); m_nodeNameStack.Push( "profile" ); // we are already in the XML now + ValidContent &= ReadXML( reader ); return ValidContent; } + /// + /// Returns the acionmals contained in the profile xml string + /// + /// A default profile XML string + /// A filled SCActionMapList object + public SCActionMapList ActionMapList(string xml ) + { + SCActionMapList aml = new SCActionMapList(); + log.Debug( "DProfileReader.ActionMapList - Entry" ); + XmlReaderSettings settings = new XmlReaderSettings( ); + settings.ConformanceLevel = ConformanceLevel.Fragment; + settings.IgnoreWhitespace = true; + settings.IgnoreComments = true; + XmlReader reader = XmlReader.Create( new StringReader( xml ), settings ); + + reader.Read( ); + if ( !reader.ReadToFollowing( "actionmap" ) ) return aml; // ERROR empty one.. + do { + string attr = reader["name"]; + if ( !string.IsNullOrEmpty( attr ) ) + aml.AddActionMap( attr ); + } while ( reader.ReadToFollowing( "actionmap" ) ); + + return aml; + } } } diff --git a/SC/SCActionMapList.cs b/SC/SCActionMapList.cs new file mode 100644 index 0000000..6612ec9 --- /dev/null +++ b/SC/SCActionMapList.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SCJMapper_V2.SC +{ + class SCActionMapList : SortedList + { + private int NextID + { + get { + return this.Count; + } + } + + public void AddActionMap( string amName ) + { + if ( !this.ContainsValue( amName ) ) + this.Add( NextID, amName ); + } + + public string[] ActionMaps { get { return this.Values.ToArray( ); } } + + + } +} diff --git a/SCJMapper-V2.csproj b/SCJMapper-V2.csproj index 7f220f3..0f33297 100644 --- a/SCJMapper-V2.csproj +++ b/SCJMapper-V2.csproj @@ -26,8 +26,8 @@ false false true - 60 - 2.26.0.%2a + 61 + 2.27.0.%2a false true @@ -126,6 +126,7 @@ + DS_ActionMaps.xsd diff --git a/actions/ActionMapsCls.cs b/actions/ActionMapsCls.cs index fcbfda0..a59f32f 100644 --- a/actions/ActionMapsCls.cs +++ b/actions/ActionMapsCls.cs @@ -41,11 +41,11 @@ namespace SCJMapper_V2 // actionmap names to gather (do we need them to be cofigurable ??) public static String[] ActionMaps = { }; - public static void LoadSupportedActionMaps( ) + + public static void LoadSupportedActionMaps( SCActionMapList aml ) { // load actionmaps - String acm = AppConfiguration.AppConfig.scActionmaps; - ActionMaps = acm.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ); + ActionMaps = aml.ActionMaps; } #endregion Static Part of ActionMaps @@ -181,7 +181,7 @@ namespace SCJMapper_V2 CreateNewOptions( ); - LoadSupportedActionMaps( ); // get them from config + //LoadSupportedActionMaps( ); // get them from config @@@@@@@@@ } diff --git a/app.config b/app.config index 102dadc..ffb722c 100644 --- a/app.config +++ b/app.config @@ -11,10 +11,7 @@ - + diff --git a/appConfiguration.cs b/appConfiguration.cs index 7bf3124..9665fa1 100644 --- a/appConfiguration.cs +++ b/appConfiguration.cs @@ -25,13 +25,6 @@ namespace SCJMapper_V2 private static readonly ConfigurationProperty _msSenseLimit = new ConfigurationProperty( "msSenseLimit", typeof( int ), ( int )150, ConfigurationPropertyOptions.None ); - // The scActionmaps property. - private static String _defaultActionmaps = "default,multiplayer,singleplayer,invite,player,player_choice,prone,flycam,vehicle_general,vehicle_driver,vehicle_gunner" - + ",spaceship_general,spaceship_view,spaceship_movement,spaceship_targeting,spaceship_turret,spaceship_weapons,spaceship_missiles" - + ",spaceship_defensive,spaceship_auto_weapons,spaceship_power,spaceship_radar,spaceship_hud,zero_gravity_general,zero_gravity_eva,IFCS_controls"; - private static readonly ConfigurationProperty _scActionmaps = - new ConfigurationProperty( "scActionmaps", typeof( String ), (String)_defaultActionmaps, ConfigurationPropertyOptions.None ); - // ctor public AppConfiguration( ) { @@ -40,7 +33,6 @@ namespace SCJMapper_V2 _Properties.Add( _jsSenseLimit ); _Properties.Add( _gpSenseLimit ); _Properties.Add( _msSenseLimit ); - _Properties.Add( _scActionmaps ); } @@ -168,22 +160,6 @@ namespace SCJMapper_V2 } } - /// - /// The actionmaps supported - /// - static public String scActionmaps - { - get - { - AppConfiguration s = GetAppSection( ); - if ( s != null ) { - // get rid of blanks and CR,LFs from the config file - String t = s.scActionmaps.Replace( " ", "" ).Replace( String.Format( "\n" ), "" ).Replace( String.Format( "\r" ), "" ); - return t; - } - else return _defaultActionmaps; // default if things go wrong... - } - } }