summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-03 20:10:43 -0700
committerJacob Palecki <[email protected]>2020-09-03 20:10:43 -0700
commit2fbc4b3d504962c2462d7aec98f5f389e5333164 (patch)
tree2230e353985551a21a25b09bfacb89467b52d165
parentRefactor for nice gain offset (diff)
downloadrawaccel-2fbc4b3d504962c2462d7aec98f5f389e5333164.tar.xz
rawaccel-2fbc4b3d504962c2462d7aec98f5f389e5333164.zip
Add offset options to GUI, make gain options default
-rw-r--r--grapher/Form1.Designer.cs64
-rw-r--r--grapher/Form1.cs11
-rw-r--r--grapher/Models/AccelGUI.cs11
-rw-r--r--grapher/Models/Options/CapOptions.cs22
-rw-r--r--grapher/Models/Options/OffsetOptions.cs124
-rw-r--r--grapher/grapher.csproj1
6 files changed, 196 insertions, 37 deletions
diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs
index 70455ce..a7a3e16 100644
--- a/grapher/Form1.Designer.cs
+++ b/grapher/Form1.Designer.cs
@@ -93,8 +93,8 @@ namespace grapher
this.ScaleMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.capStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.sensitivityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.velocityGainToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.gainCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.legacyCapToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.startupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AutoWriteMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AccelerationChartY = new System.Windows.Forms.DataVisualization.Charting.Chart();
@@ -114,6 +114,9 @@ namespace grapher
this.OffsetActiveLabel = new System.Windows.Forms.Label();
this.LimitExpActiveLabel = new System.Windows.Forms.Label();
this.MidpointActiveLabel = new System.Windows.Forms.Label();
+ this.offsetStyleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.gainOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.legacyOffsetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.AccelerationChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.VelocityChart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.GainChart)).BeginInit();
@@ -491,7 +494,8 @@ namespace grapher
// advancedToolStripMenuItem
//
this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.capStyleToolStripMenuItem});
+ this.capStyleToolStripMenuItem,
+ this.offsetStyleToolStripMenuItem});
this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem";
this.advancedToolStripMenuItem.Size = new System.Drawing.Size(72, 20);
this.advancedToolStripMenuItem.Text = "Advanced";
@@ -499,25 +503,25 @@ namespace grapher
// capStyleToolStripMenuItem
//
this.capStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.sensitivityToolStripMenuItem,
- this.velocityGainToolStripMenuItem});
+ this.gainCapToolStripMenuItem,
+ this.legacyCapToolStripMenuItem});
this.capStyleToolStripMenuItem.Name = "capStyleToolStripMenuItem";
- this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(123, 22);
+ this.capStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.capStyleToolStripMenuItem.Text = "Cap Style";
//
- // sensitivityToolStripMenuItem
+ // gainCapToolStripMenuItem
//
- this.sensitivityToolStripMenuItem.Checked = true;
- this.sensitivityToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
- this.sensitivityToolStripMenuItem.Name = "sensitivityToolStripMenuItem";
- this.sensitivityToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
- this.sensitivityToolStripMenuItem.Text = "Sensitivity";
+ this.gainCapToolStripMenuItem.Checked = true;
+ this.gainCapToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked;
+ this.gainCapToolStripMenuItem.Name = "gainCapToolStripMenuItem";
+ this.gainCapToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.gainCapToolStripMenuItem.Text = "Gain (Default)";
//
- // velocityGainToolStripMenuItem
+ // legacyCapToolStripMenuItem
//
- this.velocityGainToolStripMenuItem.Name = "velocityGainToolStripMenuItem";
- this.velocityGainToolStripMenuItem.Size = new System.Drawing.Size(142, 22);
- this.velocityGainToolStripMenuItem.Text = "Velocity Gain";
+ this.legacyCapToolStripMenuItem.Name = "legacyCapToolStripMenuItem";
+ this.legacyCapToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.legacyCapToolStripMenuItem.Text = "Legacy";
//
// startupToolStripMenuItem
//
@@ -737,6 +741,27 @@ namespace grapher
this.MidpointActiveLabel.TabIndex = 47;
this.MidpointActiveLabel.Text = "0";
//
+ // offsetStyleToolStripMenuItem
+ //
+ this.offsetStyleToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.gainOffsetToolStripMenuItem,
+ this.legacyOffsetToolStripMenuItem});
+ this.offsetStyleToolStripMenuItem.Name = "offsetStyleToolStripMenuItem";
+ this.offsetStyleToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.offsetStyleToolStripMenuItem.Text = "Offset Style";
+ //
+ // gainOffsetToolStripMenuItem
+ //
+ this.gainOffsetToolStripMenuItem.Name = "gainOffsetToolStripMenuItem";
+ this.gainOffsetToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.gainOffsetToolStripMenuItem.Text = "Gain (Default)";
+ //
+ // legacyOffsetToolStripMenuItem
+ //
+ this.legacyOffsetToolStripMenuItem.Name = "legacyOffsetToolStripMenuItem";
+ this.legacyOffsetToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.legacyOffsetToolStripMenuItem.Text = "Legacy";
+ //
// RawAcceleration
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -840,8 +865,8 @@ namespace grapher
private System.Windows.Forms.ToolStripMenuItem showVelocityGainToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem advancedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem capStyleToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem sensitivityToolStripMenuItem;
- private System.Windows.Forms.ToolStripMenuItem velocityGainToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem gainCapToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem legacyCapToolStripMenuItem;
private System.Windows.Forms.DataVisualization.Charting.Chart AccelerationChartY;
private System.Windows.Forms.DataVisualization.Charting.Chart VelocityChartY;
private System.Windows.Forms.DataVisualization.Charting.Chart GainChartY;
@@ -867,6 +892,9 @@ namespace grapher
private System.Windows.Forms.Label MidpointActiveLabel;
private System.Windows.Forms.ToolStripMenuItem startupToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem AutoWriteMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem offsetStyleToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem gainOffsetToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem legacyOffsetToolStripMenuItem;
}
}
diff --git a/grapher/Form1.cs b/grapher/Form1.cs
index 37f67f8..ba0730c 100644
--- a/grapher/Form1.cs
+++ b/grapher/Form1.cs
@@ -104,6 +104,11 @@ namespace grapher
new ActiveValueLabel(OffsetActiveLabel, ActiveValueTitle),
"Offset");
+ var offsetOptions = new OffsetOptions(
+ gainOffsetToolStripMenuItem,
+ legacyOffsetToolStripMenuItem,
+ offset);
+
// The name and layout of these options is handled by AccelerationOptions object.
var acceleration = new Option(
new Field(accelerationBox, this, 0),
@@ -138,8 +143,8 @@ namespace grapher
new ActiveValueLabel(AccelTypeActiveLabel, ActiveValueTitle));
var capOptions = new CapOptions(
- sensitivityToolStripMenuItem,
- velocityGainToolStripMenuItem,
+ gainCapToolStripMenuItem,
+ legacyCapToolStripMenuItem,
cap,
weight);
@@ -163,7 +168,7 @@ namespace grapher
rotation,
weight,
capOptions,
- offset,
+ offsetOptions,
acceleration,
limitOrExponent,
midpoint,
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs
index 1657074..a7d5d49 100644
--- a/grapher/Models/AccelGUI.cs
+++ b/grapher/Models/AccelGUI.cs
@@ -1,5 +1,6 @@
using grapher.Models.Calculations;
using grapher.Models.Mouse;
+using grapher.Models.Options;
using grapher.Models.Serialized;
using System;
using System.CodeDom;
@@ -28,7 +29,7 @@ namespace grapher
Option rotation,
OptionXY weight,
CapOptions cap,
- Option offset,
+ OffsetOptions offset,
Option acceleration,
Option limtOrExp,
Option midpoint,
@@ -82,7 +83,7 @@ namespace grapher
public CapOptions Cap { get; }
- public Option Offset { get; }
+ public OffsetOptions Offset { get; }
public Option Acceleration { get; }
@@ -119,8 +120,8 @@ namespace grapher
{
x = new AccelArgs
{
- offset = Offset.Field.Data,
- legacy_offset = 0,
+ offset = Offset.Offset,
+ legacy_offset = Offset.LegacyOffset,
weight = Weight.Fields.X,
gainCap = Cap.VelocityGainCap,
scaleCap = Cap.SensitivityCapX,
@@ -163,7 +164,7 @@ namespace grapher
Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y);
Rotation.SetActiveValue(settings.rotation);
AccelerationOptions.SetActiveValue((int)settings.modes.x);
- Offset.SetActiveValue(settings.args.x.offset);
+ Offset.SetActiveValue(settings.args.x.offset, settings.args.y.offset);
Weight.SetActiveValues(settings.args.x.weight, settings.args.x.weight);
Acceleration.SetActiveValue(settings.args.x.accel); // rate, powerscale
LimitOrExponent.SetActiveValue(settings.args.x.limit); //exp, powerexp
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
index 493561a..87bac88 100644
--- a/grapher/Models/Options/CapOptions.cs
+++ b/grapher/Models/Options/CapOptions.cs
@@ -14,27 +14,27 @@ namespace grapher
public const string GainCapFormatString = "0.##";
public CapOptions(
- ToolStripMenuItem sensitivityCapCheck,
ToolStripMenuItem velocityGainCapCheck,
+ ToolStripMenuItem legacyCapCheck,
OptionXY capOption,
OptionXY weightOption)
{
- SensitivityCapCheck = sensitivityCapCheck;
VelocityGainCapCheck = velocityGainCapCheck;
+ LegacyCapCheck = legacyCapCheck;
CapOption = capOption;
WeightOption = weightOption;
- SensitivityCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
+ LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick);
- SensitivityCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
+ LegacyCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange);
- EnableSensitivityCap();
+ EnableVelocityGainCap();
}
- public ToolStripMenuItem SensitivityCapCheck { get; }
+ public ToolStripMenuItem LegacyCapCheck { get; }
public ToolStripMenuItem VelocityGainCapCheck { get; }
@@ -104,10 +104,10 @@ namespace grapher
void OnSensitivityCapCheckClick(object sender, EventArgs e)
{
- if (!SensitivityCapCheck.Checked)
+ if (!LegacyCapCheck.Checked)
{
VelocityGainCapCheck.Checked = false;
- SensitivityCapCheck.Checked = true;
+ LegacyCapCheck.Checked = true;
}
}
@@ -116,13 +116,13 @@ namespace grapher
if (!VelocityGainCapCheck.Checked)
{
VelocityGainCapCheck.Checked = true;
- SensitivityCapCheck.Checked = false;
+ LegacyCapCheck.Checked = false;
}
}
void OnSensitivityCapCheckedChange(object sender, EventArgs e)
{
- if (SensitivityCapCheck.Checked == true)
+ if (LegacyCapCheck.Checked == true)
{
EnableSensitivityCap();
}
@@ -130,7 +130,7 @@ namespace grapher
void OnVelocityGainCapCheckedChange(object sender, EventArgs e)
{
- if (SensitivityCapCheck.Checked == true)
+ if (LegacyCapCheck.Checked == true)
{
EnableVelocityGainCap();
}
diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs
new file mode 100644
index 0000000..0b01ab9
--- /dev/null
+++ b/grapher/Models/Options/OffsetOptions.cs
@@ -0,0 +1,124 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options
+{
+ public class OffsetOptions
+ {
+ public OffsetOptions(
+ ToolStripMenuItem velocityGainOffsetCheck,
+ ToolStripMenuItem legacyOffsetCheck,
+ Option offsetOption)
+ {
+ VelocityGainOffsetCheck = velocityGainOffsetCheck;
+ LegacyOffsetCheck = legacyOffsetCheck;
+ OffsetOption = offsetOption;
+
+ VelocityGainOffsetCheck.Click += new System.EventHandler(OnVelocityGainOffsetClick);
+ LegacyOffsetCheck.Click += new System.EventHandler(OnLegacyOffsetClick);
+
+ VelocityGainOffsetCheck.CheckedChanged += new System.EventHandler(OnVelocityGainOffsetCheckedChange);
+ LegacyOffsetCheck.CheckedChanged += new System.EventHandler(OnLegacyOffsetCheckedChange);
+
+ VelocityGainOffsetCheck.Checked = true;
+ }
+
+ public ToolStripMenuItem VelocityGainOffsetCheck { get; }
+
+ public ToolStripMenuItem LegacyOffsetCheck { get; }
+
+ public Option OffsetOption { get; }
+
+ public bool IsLegacy { get; private set; }
+
+ public double LegacyOffset
+ {
+ get
+ {
+ if (IsLegacy)
+ {
+ return OffsetOption.Field.Data;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+
+ public double Offset
+ {
+ get
+ {
+ if (IsLegacy)
+ {
+ return 0;
+ }
+ else
+ {
+ return OffsetOption.Field.Data;
+ }
+ }
+ }
+
+ public void SetActiveValue(double offset, double legacyOffset)
+ {
+ if (offset > 0)
+ {
+ OffsetOption.SetActiveValue(offset);
+ }
+ else
+ {
+ OffsetOption.SetActiveValue(legacyOffset);
+ }
+ }
+
+ public void OnVelocityGainOffsetClick(object sender, EventArgs e)
+ {
+ if (!VelocityGainOffsetCheck.Checked)
+ {
+ VelocityGainOffsetCheck.Checked = true;
+ LegacyOffsetCheck.Checked = false;
+ }
+ }
+
+ public void OnLegacyOffsetClick(object sender, EventArgs e)
+ {
+ if (!LegacyOffsetCheck.Checked)
+ {
+ LegacyOffsetCheck.Checked = true;
+ VelocityGainOffsetCheck.Checked = false;
+ }
+ }
+
+ public void OnVelocityGainOffsetCheckedChange(object sender, EventArgs e)
+ {
+ if (VelocityGainOffsetCheck.Checked)
+ {
+ EnableVelocityGainOffset();
+ }
+ }
+
+ public void OnLegacyOffsetCheckedChange(object sender, EventArgs e)
+ {
+ if (LegacyOffsetCheck.Checked)
+ {
+ EnableLegacyOffset();
+ }
+ }
+
+ public void EnableVelocityGainOffset()
+ {
+ IsLegacy = false;
+ }
+
+ public void EnableLegacyOffset()
+ {
+ IsLegacy = true;
+ }
+ }
+}
diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj
index d34e678..28322bb 100644
--- a/grapher/grapher.csproj
+++ b/grapher/grapher.csproj
@@ -85,6 +85,7 @@
<Compile Include="Layouts\OffLayout.cs" />
<Compile Include="Layouts\PowerLayout.cs" />
<Compile Include="Layouts\SigmoidLayout.cs" />
+ <Compile Include="Models\Options\OffsetOptions.cs" />
<Compile Include="Models\Options\Option.cs" />
<Compile Include="Models\Options\OptionXY.cs" />
<Compile Include="Models\Serialized\GUISettings.cs" />