diff options
| author | a1xd <[email protected]> | 2021-04-13 23:59:21 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2021-04-13 23:59:21 -0400 |
| commit | a6926be0e911b7b7637861866f41c3bca31a87a3 (patch) | |
| tree | a8d7cd5afb4c093e6f97e8d772b139dd5d749988 /grapher/Models | |
| parent | additional fixes (diff) | |
| download | rawaccel-a6926be0e911b7b7637861866f41c3bca31a87a3.tar.xz rawaccel-a6926be0e911b7b7637861866f41c3bca31a87a3.zip | |
move arbitrary input into settings
separate arbitrary mode from spaced modes, arbitrary now deserializes from default settings file
Diffstat (limited to 'grapher/Models')
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 23 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 9 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 121 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 57 |
4 files changed, 92 insertions, 118 deletions
diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index ec570d3..324dcb1 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -114,20 +114,19 @@ namespace grapher public void UpdateActiveSettingsFromFields() { - var settings = new DriverSettings + var settings = new DriverSettings(); + + settings.rotation = ApplyOptions.Rotation.Field.Data; + settings.sensitivity = new Vec2<double> { - rotation = ApplyOptions.Rotation.Field.Data, - sensitivity = new Vec2<double> - { - x = ApplyOptions.Sensitivity.Fields.X, - y = ApplyOptions.Sensitivity.Fields.Y - }, - combineMagnitudes = ApplyOptions.IsWhole, - args = ApplyOptions.GetArgs(), - domainArgs = ApplyOptions.Directionality.GetDomainArgs(), - rangeXY = ApplyOptions.Directionality.GetRangeXY(), - deviceID = DeviceIDManager.ID, + x = ApplyOptions.Sensitivity.Fields.X, + y = ApplyOptions.Sensitivity.Fields.Y }; + settings.combineMagnitudes = ApplyOptions.IsWhole; + ApplyOptions.SetArgs(ref settings.args); + settings.domainArgs = ApplyOptions.Directionality.GetDomainArgs(); + settings.rangeXY = ApplyOptions.Directionality.GetRangeXY(); + settings.deviceID = DeviceIDManager.ID; Settings.SetHiddenOptions(settings); diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs index f4c08a1..8b957f1 100644 --- a/grapher/Models/Options/AccelOptionSet.cs +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -103,16 +103,11 @@ namespace grapher.Models.Options Options.SetArgs(ref args); } - public AccelArgs GenerateArgs() - { - return Options.GenerateArgs(); - } - - public void SetActiveValues(AccelArgs args) + public void SetActiveValues(ref AccelArgs args) { if (!Hidden) { - Options.SetActiveValues(args); + Options.SetActiveValues(ref args); } } diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index b12ad8a..62a923d 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -12,19 +12,15 @@ namespace grapher { #region Fields - public static readonly Dictionary<string, LayoutBase> AccelerationTypes = new List<LayoutBase> - { - new LinearLayout(), - new ClassicLayout(), - new NaturalLayout(), - new JumpLayout(), - new PowerLayout(), - new MotivityLayout(), - new LUTLayout(), - new OffLayout(), - }.ToDictionary(k => k.Name); - - public static readonly AccelArgs DefaultArgs = new DriverSettings().args.x; + public static readonly LayoutBase Linear = new LinearLayout(); + public static readonly LayoutBase Classic = new ClassicLayout(); + public static readonly LayoutBase Jump = new JumpLayout(); + public static readonly LayoutBase Natural = new NaturalLayout(); + public static readonly LayoutBase Motivity = new MotivityLayout(); + public static readonly LayoutBase Power = new PowerLayout(); + public static readonly LayoutBase LUT = new LUTLayout(); + public static readonly LayoutBase Off = new OffLayout(); + public static readonly LayoutBase Unsupported = new UnsupportedLayout(); #endregion Fields @@ -47,7 +43,19 @@ namespace grapher { AccelDropdown = accelDropdown; AccelDropdown.Items.Clear(); - AccelDropdown.Items.AddRange(AccelerationTypes.Keys.ToArray()); + AccelDropdown.Items.AddRange( + new LayoutBase[] + { + Linear, + Classic, + Jump, + Natural, + Motivity, + Power, + LUT, + Off + }); + AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged); GainSwitch = gainSwitch; @@ -67,7 +75,8 @@ namespace grapher AccelTypeActiveValue.Height = AccelDropdown.Height; GainSwitch.Left = Acceleration.Field.Left; - Layout("Off"); + AccelerationType = Off; + Layout(); ShowingDefault = true; } @@ -80,16 +89,6 @@ namespace grapher public ComboBox AccelDropdown { get; } - public int AccelerationIndex - { - get - { - return AccelerationType.Index; - } - } - - public LayoutBase AccelerationType { get; private set; } - public ActiveValueLabel AccelTypeActiveValue { get; } public Option Acceleration { get; } @@ -112,6 +111,18 @@ namespace grapher public CheckBoxOption GainSwitch { get; } + public LayoutBase AccelerationType + { + get + { + return AccelDropdown.SelectedItem as LayoutBase; + } + private set + { + AccelDropdown.SelectedItem = value; + } + } + public override int Top { get @@ -201,18 +212,15 @@ namespace grapher Show(); } - public void SetActiveValues(AccelArgs args) + public void SetActiveValues(ref AccelArgs args) { - AccelerationType = AccelTypeFromSettings(args); + AccelerationType = AccelTypeFromSettings(ref args); AccelTypeActiveValue.SetValue(AccelerationType.Name); - // Add one to include linear, which is not represented separately in the config - AccelDropdown.SelectedIndex = AccelerationType.Index + 1; - GainSwitch.SetActiveValue(args.legacy); Weight.SetActiveValue(args.weight); Cap.SetActiveValue(args.cap); Offset.SetActiveValue(args.offset); - Acceleration.SetActiveValue(AccelerationParameterFromArgs(args)); + Acceleration.SetActiveValue(AccelerationParameterFromArgs(ref args)); Scale.SetActiveValue(args.scale); Limit.SetActiveValue(args.limit); Exponent.SetActiveValue(args.exponent); @@ -243,7 +251,10 @@ namespace grapher public void SetArgs(ref AccelArgs args) { - args.mode = (AccelMode)AccelerationType.Index; + if (AccelerationType == Unsupported) throw new NotImplementedException(); + + args.mode = AccelerationType.Mode; + if (Acceleration.Visible) { if (args.mode == AccelMode.natural) @@ -273,13 +284,6 @@ namespace grapher if (Weight.Visible) args.weight = Weight.Field.Data; } - public AccelArgs GenerateArgs() - { - AccelArgs args = new DriverSettings().args.x; - SetArgs(ref args); - return args; - } - public override void AlignActiveValues() { AccelTypeActiveValue.Align(); @@ -296,17 +300,10 @@ namespace grapher private void OnIndexChanged(object sender, EventArgs e) { - var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); - Layout(accelerationTypeString, Beneath); + Layout(Beneath); ShowingDefault = false; } - private void Layout(string type, int top = -1) - { - AccelerationType = AccelerationTypes[type]; - Layout(top); - } - private void Layout(int top = -1) { if (top < 0) @@ -328,23 +325,31 @@ namespace grapher top); } - private LayoutBase AccelTypeFromSettings(AccelArgs args) - { - LayoutBase type; - if (args.mode == AccelMode.classic && args.exponent == 2) + private LayoutBase AccelTypeFromSettings(ref AccelArgs args) + { + if (args.spacedTableArgs.mode != SpacedTableMode.off) { - type = AccelerationTypes.Values.Where(t => string.Equals(t.Name, LinearLayout.LinearName)).FirstOrDefault(); + if (!AccelDropdown.Items.Contains(Unsupported)) + { + AccelDropdown.Items.Add(Unsupported); + } + + return Unsupported; } - else + + switch (args.mode) { - int index = (int)args.mode; - type = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value; + case AccelMode.classic: return (args.power == 2) ? Linear : Classic; + case AccelMode.jump: return Jump; + case AccelMode.natural: return Natural; + case AccelMode.motivity: return Motivity; + case AccelMode.power: return Power; + case AccelMode.lut: return LUT; + default: return Off; } - - return type; } - private double AccelerationParameterFromArgs(AccelArgs args) + private double AccelerationParameterFromArgs(ref AccelArgs args) { if (args.mode == AccelMode.motivity) { diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 43a2da8..06854b8 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -81,55 +81,30 @@ namespace grapher.Models.Options #region Methods - public Vec2<AccelMode> GetModes() + public void SetArgs(ref Vec2<AccelArgs> args) { - var xMode = (AccelMode)OptionSetX.Options.AccelerationIndex; + OptionSetX.SetArgs(ref args.x); - return new Vec2<AccelMode> + if (ByComponentVectorXYLock.Checked) { - x = xMode, - y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.Options.AccelerationIndex - }; - } - - public Vec2<AccelArgs> GetArgs() - { - var xArgs = OptionSetX.GenerateArgs(); - - return new Vec2<AccelArgs> + OptionSetX.SetArgs(ref args.y); + } + else { - x = xArgs, - y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs() - }; - - } - - public void SetActiveValues( - double xSens, - double ySens, - double rotation, - AccelArgs xArgs, - AccelArgs yArgs, - bool isWhole) - { - Sensitivity.SetActiveValues(xSens, ySens); - Rotation.SetActiveValue(rotation); - OptionSetX.SetActiveValues(xArgs); - WholeVectorCheckBox.Checked = isWhole; - ByComponentVectorCheckBox.Checked = !isWhole; - ByComponentVectorXYLock.Checked = xArgs.Equals(yArgs); - OptionSetY.SetActiveValues(yArgs); + OptionSetY.SetArgs(ref args.y); + } } public void SetActiveValues(DriverSettings settings) { - SetActiveValues( - settings.sensitivity.x, - settings.sensitivity.y, - settings.rotation, - settings.args.x, - settings.args.y, - settings.combineMagnitudes); + Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y); + Rotation.SetActiveValue(settings.rotation); + + WholeVectorCheckBox.Checked = settings.combineMagnitudes; + ByComponentVectorCheckBox.Checked = !settings.combineMagnitudes; + ByComponentVectorXYLock.Checked = settings.args.x.Equals(settings.args.y); + OptionSetX.SetActiveValues(ref settings.args.x); + OptionSetY.SetActiveValues(ref settings.args.y); Directionality.SetActiveValues(settings); |