Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes for state serialisation #85

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions SandWorm/Components/SandWormComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ public override void DrawViewportWires(IGH_PreviewArgs args)

if (_labelSpacing.Value > 0 && ((AnalysisTypes) _analysisType.Value == AnalysisTypes.CutFill || (AnalysisTypes)_analysisType.Value == AnalysisTypes.Elevation))
{
foreach (var text in labels)
args.Display.Draw3dText(text, Color.White);
if (labels != null)
foreach (var text in labels)
args.Display.Draw3dText(text, Color.White);
}
}

Expand Down
3 changes: 2 additions & 1 deletion SandWorm/CustomComponent/MenuCheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public override bool Write(GH_IWriter writer)
public override bool Read(GH_IReader reader)
{
GH_IReader gH_IReader = reader.FindChunk("Checkbox", Index);
_active = gH_IReader.GetBoolean("Active");
if (gH_IReader != null)
_active = gH_IReader.GetBoolean("Active");
return true;
}

Expand Down
15 changes: 10 additions & 5 deletions SandWorm/CustomComponent/MenuSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,18 @@ public override bool Write(GH_IWriter writer)
public override bool Read(GH_IReader reader)
{
GH_IReader gH_IReader = reader.FindChunk("Slider", Index);
minValue = gH_IReader.GetDouble("MinValue");
maxValue = gH_IReader.GetDouble("MaxValue");
currentValue = gH_IReader.GetDouble("CurrentValue");
if (!gH_IReader.TryGetInt32("NumDecimals", ref numDecimals))
if (gH_IReader != null)
{
numDecimals = 2;
minValue = gH_IReader.GetDouble("MinValue");
maxValue = gH_IReader.GetDouble("MaxValue");
currentValue = gH_IReader.GetDouble("CurrentValue");

if (!gH_IReader.TryGetInt32("NumDecimals", ref numDecimals))
{
numDecimals = 2;
}
}

FixValues();
return true;
}
Expand Down