summaryrefslogtreecommitdiff
path: root/grapher/Models/Serialized
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-10-25 23:57:44 -0400
committerGitHub <[email protected]>2020-10-25 23:57:44 -0400
commit1601eaffd7c83888fd804c00eae0b0e8633232ee (patch)
tree72beb1b8b32b82ebfd853c04fe85c1f67e1d4afe /grapher/Models/Serialized
parentMerge pull request #37 from JacobPalecki/GUI (diff)
parentupdate signed (diff)
downloadrawaccel-1.2.0-w7.tar.xz
rawaccel-1.2.0-w7.zip
Merge pull request #38 from a1xd/1.2v1.2.0-w7v1.2.0
1.2.0
Diffstat (limited to 'grapher/Models/Serialized')
-rw-r--r--grapher/Models/Serialized/GUISettings.cs10
-rw-r--r--grapher/Models/Serialized/RawAccelSettings.cs17
-rw-r--r--grapher/Models/Serialized/SettingsManager.cs25
3 files changed, 34 insertions, 18 deletions
diff --git a/grapher/Models/Serialized/GUISettings.cs b/grapher/Models/Serialized/GUISettings.cs
index c8f87ae..bb35055 100644
--- a/grapher/Models/Serialized/GUISettings.cs
+++ b/grapher/Models/Serialized/GUISettings.cs
@@ -4,6 +4,7 @@ using System;
namespace grapher.Models.Serialized
{
[Serializable]
+ [JsonObject(ItemRequired = Required.Always)]
public class GUISettings
{
#region Constructors
@@ -27,6 +28,9 @@ namespace grapher.Models.Serialized
[JsonProperty(Order = 4)]
public bool ShowVelocityAndGain { get; set; }
+ [JsonProperty(Order = 5)]
+ public bool AutoWriteToDriverOnStartup { get; set; }
+
#endregion Properties
#region Methods
@@ -48,7 +52,8 @@ namespace grapher.Models.Serialized
return DPI == other.DPI &&
PollRate == other.PollRate &&
ShowLastMouseMove == other.ShowLastMouseMove &&
- ShowVelocityAndGain == other.ShowVelocityAndGain;
+ ShowVelocityAndGain == other.ShowVelocityAndGain &&
+ AutoWriteToDriverOnStartup == other.AutoWriteToDriverOnStartup;
}
public override int GetHashCode()
@@ -56,7 +61,8 @@ namespace grapher.Models.Serialized
return DPI.GetHashCode() ^
PollRate.GetHashCode() ^
ShowLastMouseMove.GetHashCode() ^
- ShowVelocityAndGain.GetHashCode();
+ ShowVelocityAndGain.GetHashCode() ^
+ AutoWriteToDriverOnStartup.GetHashCode();
}
#endregion Methods
diff --git a/grapher/Models/Serialized/RawAccelSettings.cs b/grapher/Models/Serialized/RawAccelSettings.cs
index 818bfb6..af87a65 100644
--- a/grapher/Models/Serialized/RawAccelSettings.cs
+++ b/grapher/Models/Serialized/RawAccelSettings.cs
@@ -117,13 +117,18 @@ namespace grapher.Models.Serialized
public bool IsDefaultEquivalent()
{
- bool wholeOrNoY = AccelerationSettings.combineMagnitudes ||
- AccelerationSettings.modes.y == AccelMode.noaccel;
+ return IsDefaultEquivalent(AccelerationSettings);
+ }
+
+ public static bool IsDefaultEquivalent(DriverSettings accelSettings)
+ {
+ bool wholeOrNoY = accelSettings.combineMagnitudes ||
+ accelSettings.modes.y == AccelMode.noaccel;
- return AccelerationSettings.sensitivity.x == 1 &&
- AccelerationSettings.sensitivity.y == 1 &&
- AccelerationSettings.rotation == 0 &&
- AccelerationSettings.modes.x == AccelMode.noaccel &&
+ return accelSettings.sensitivity.x == 1 &&
+ accelSettings.sensitivity.y == 1 &&
+ accelSettings.rotation == 0 &&
+ accelSettings.modes.x == AccelMode.noaccel &&
wholeOrNoY;
}
diff --git a/grapher/Models/Serialized/SettingsManager.cs b/grapher/Models/Serialized/SettingsManager.cs
index 8712c87..f13ba81 100644
--- a/grapher/Models/Serialized/SettingsManager.cs
+++ b/grapher/Models/Serialized/SettingsManager.cs
@@ -14,12 +14,14 @@ namespace grapher.Models.Serialized
ManagedAccel activeAccel,
Field dpiField,
Field pollRateField,
+ ToolStripMenuItem autoWrite,
ToolStripMenuItem showLastMouseMove,
ToolStripMenuItem showVelocityAndGain)
{
ActiveAccel = activeAccel;
DpiField = dpiField;
PollRateField = pollRateField;
+ AutoWriteMenuItem = autoWrite;
ShowLastMouseMoveMenuItem = showLastMouseMove;
ShowVelocityAndGainMoveMenuItem = showVelocityAndGain;
}
@@ -36,6 +38,8 @@ namespace grapher.Models.Serialized
private Field PollRateField { get; set; }
+ private ToolStripMenuItem AutoWriteMenuItem { get; set; }
+
private ToolStripMenuItem ShowLastMouseMoveMenuItem { get; set; }
private ToolStripMenuItem ShowVelocityAndGainMoveMenuItem { get; set; }
@@ -92,12 +96,7 @@ namespace grapher.Models.Serialized
PollRateField.SetToEntered(RawAccelSettings.GUISettings.PollRate);
ShowLastMouseMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowLastMouseMove;
ShowVelocityAndGainMoveMenuItem.Checked = RawAccelSettings.GUISettings.ShowVelocityAndGain;
- }
-
- public void UpdateActiveAccelFromFileSettings(DriverSettings settings)
- {
- TryUpdateAccel(settings);
- UpdateFieldsFromGUISettings();
+ AutoWriteMenuItem.Checked = RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
}
public SettingsErrors TryUpdateAccel(DriverSettings settings)
@@ -126,11 +125,13 @@ namespace grapher.Models.Serialized
DPI = (int)DpiField.Data,
PollRate = (int)PollRateField.Data,
ShowLastMouseMove = ShowLastMouseMoveMenuItem.Checked,
- ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked
+ ShowVelocityAndGain = ShowVelocityAndGainMoveMenuItem.Checked,
+ AutoWriteToDriverOnStartup = AutoWriteMenuItem.Checked
};
}
- public void Startup()
+ // Returns true when file settings are active
+ public bool Startup()
{
if (RawAccelSettings.Exists())
{
@@ -138,8 +139,11 @@ namespace grapher.Models.Serialized
{
RawAccelSettings = RawAccelSettings.Load(() => MakeGUISettingsFromFields());
UpdateFieldsFromGUISettings();
- UpdateActiveAccelFromFileSettings(RawAccelSettings.AccelerationSettings);
- return;
+ if (RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup)
+ {
+ TryUpdateAccel(RawAccelSettings.AccelerationSettings);
+ }
+ return RawAccelSettings.GUISettings.AutoWriteToDriverOnStartup;
}
catch (JsonException e)
{
@@ -151,6 +155,7 @@ namespace grapher.Models.Serialized
DriverInterop.GetActiveSettings(),
MakeGUISettingsFromFields());
RawAccelSettings.Save();
+ return true;
}
#endregion Methods