summaryrefslogtreecommitdiff
path: root/grapher/Models
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 /grapher/Models
parentRefactor for nice gain offset (diff)
downloadrawaccel-2fbc4b3d504962c2462d7aec98f5f389e5333164.tar.xz
rawaccel-2fbc4b3d504962c2462d7aec98f5f389e5333164.zip
Add offset options to GUI, make gain options default
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/AccelGUI.cs11
-rw-r--r--grapher/Models/Options/CapOptions.cs22
-rw-r--r--grapher/Models/Options/OffsetOptions.cs124
3 files changed, 141 insertions, 16 deletions
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;
+ }
+ }
+}