From 4cbf85bd033490aef24b10f343a6131a0a82bd50 Mon Sep 17 00:00:00 2001 From: dexyfex Date: Tue, 2 Jan 2018 11:07:24 +1100 Subject: [PATCH] Added invert mouse option. --- App.config | 3 +++ Forms/ModelForm.cs | 6 ++++++ Properties/Settings.Designer.cs | 12 ++++++++++++ Properties/Settings.settings | 3 +++ SettingsForm.Designer.cs | 18 ++++++++++++++++-- SettingsForm.cs | 13 ++++++++++++- WorldForm.cs | 10 ++++++++++ 7 files changed, 62 insertions(+), 3 deletions(-) diff --git a/App.config b/App.config index 8853df5..e08b7b2 100644 --- a/App.config +++ b/App.config @@ -190,6 +190,9 @@ 15 + + False + \ No newline at end of file diff --git a/Forms/ModelForm.cs b/Forms/ModelForm.cs index 0a3b15d..e5f2e1b 100644 --- a/Forms/ModelForm.cs +++ b/Forms/ModelForm.cs @@ -44,6 +44,7 @@ namespace CodeWalker.Forms int MouseY; System.Drawing.Point MouseDownPoint; System.Drawing.Point MouseLastPoint; + bool MouseInvert = Settings.Default.MouseInvert; @@ -1051,6 +1052,11 @@ namespace CodeWalker.Forms int dx = e.X - MouseX; int dy = e.Y - MouseY; + if (MouseInvert) + { + dy = -dy; + } + if (MouseLButtonDown) { camera.MouseRotate(dx, dy); diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 6defcf3..a9e64f2 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -686,5 +686,17 @@ namespace CodeWalker.Properties { this["XInputMoveSpeed"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool MouseInvert { + get { + return ((bool)(this["MouseInvert"])); + } + set { + this["MouseInvert"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 2281d1f..903cc47 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -180,5 +180,8 @@ 15 + + False + \ No newline at end of file diff --git a/SettingsForm.Designer.cs b/SettingsForm.Designer.cs index 3191d62..a5abb2e 100644 --- a/SettingsForm.Designer.cs +++ b/SettingsForm.Designer.cs @@ -80,6 +80,7 @@ this.SaveButton = new System.Windows.Forms.Button(); this.ResetButton = new System.Windows.Forms.Button(); this.FolderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog(); + this.MouseInvertCheckBox = new System.Windows.Forms.CheckBox(); this.MainTabControl.SuspendLayout(); this.ControlsTabPage.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -126,6 +127,7 @@ // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox2.Controls.Add(this.MouseInvertCheckBox); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); @@ -141,7 +143,7 @@ // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(242, 30); + this.label4.Location = new System.Drawing.Point(237, 17); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(181, 26); this.label4.TabIndex = 8; @@ -317,7 +319,7 @@ this.AdvancedTabPage.Location = new System.Drawing.Point(4, 22); this.AdvancedTabPage.Name = "AdvancedTabPage"; this.AdvancedTabPage.Padding = new System.Windows.Forms.Padding(3); - this.AdvancedTabPage.Size = new System.Drawing.Size(452, 404); + this.AdvancedTabPage.Size = new System.Drawing.Size(452, 425); this.AdvancedTabPage.TabIndex = 1; this.AdvancedTabPage.Text = "Advanced"; this.AdvancedTabPage.UseVisualStyleBackColor = true; @@ -783,6 +785,17 @@ this.ResetButton.UseVisualStyleBackColor = true; this.ResetButton.Click += new System.EventHandler(this.ResetButton_Click); // + // MouseInvertCheckBox + // + this.MouseInvertCheckBox.AutoSize = true; + this.MouseInvertCheckBox.Location = new System.Drawing.Point(240, 55); + this.MouseInvertCheckBox.Name = "MouseInvertCheckBox"; + this.MouseInvertCheckBox.Size = new System.Drawing.Size(118, 17); + this.MouseInvertCheckBox.TabIndex = 9; + this.MouseInvertCheckBox.Text = "Invert mouse Y axis"; + this.MouseInvertCheckBox.UseVisualStyleBackColor = true; + this.MouseInvertCheckBox.CheckedChanged += new System.EventHandler(this.MouseInvertCheckBox_CheckedChanged); + // // SettingsForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -871,5 +884,6 @@ private System.Windows.Forms.Label label20; private System.Windows.Forms.NumericUpDown TextureCacheSizeUpDown; private System.Windows.Forms.Label label21; + private System.Windows.Forms.CheckBox MouseInvertCheckBox; } } \ No newline at end of file diff --git a/SettingsForm.cs b/SettingsForm.cs index 1095ef9..65f52d1 100644 --- a/SettingsForm.cs +++ b/SettingsForm.cs @@ -21,7 +21,7 @@ namespace CodeWalker private float camSensitivity = Settings.Default.CameraSensitivity; private float camSmoothing = Settings.Default.CameraSmoothing; - + private bool mouseinvert = Settings.Default.MouseInvert; public SettingsForm(WorldForm owner) @@ -67,6 +67,7 @@ namespace CodeWalker { CameraSensitivityUpDown.Value = (decimal)camSensitivity * 1000; CameraSmoothingUpDown.Value = (decimal)camSmoothing; + MouseInvertCheckBox.Checked = mouseinvert; } private void LoadAdvancedSettings() { @@ -203,6 +204,16 @@ namespace CodeWalker } } + private void MouseInvertCheckBox_CheckedChanged(object sender, EventArgs e) + { + mouseinvert = MouseInvertCheckBox.Checked; + Settings.Default.MouseInvert = mouseinvert; + if (worldForm != null) + { + worldForm.SetMouseInverted(mouseinvert); + } + } + private void SaveButton_Click(object sender, EventArgs e) { //apply and save the settings. diff --git a/WorldForm.cs b/WorldForm.cs index a0baf19..81c0bd0 100644 --- a/WorldForm.cs +++ b/WorldForm.cs @@ -71,6 +71,7 @@ namespace CodeWalker int MouseControlWheel = 0; MouseButtons MouseControlButtons = MouseButtons.None; MouseButtons MouseControlButtonsPrev = MouseButtons.None; + bool MouseInvert = Settings.Default.MouseInvert; bool ControlFireToggle = false; @@ -1709,6 +1710,10 @@ namespace CodeWalker camera.Sensitivity = sensitivity; camera.Smoothness = smoothing; } + public void SetMouseInverted(bool invert) + { + MouseInvert = invert; + } public void SetKeyBindings(KeyBindings kb) { @@ -5540,6 +5545,11 @@ namespace CodeWalker int dx = e.X - MouseX; int dy = e.Y - MouseY; + if (MouseInvert) + { + dy = -dy; + } + if (ControlMode == WorldControlMode.Free) { if (MouseLButtonDown)