Skip to content

Commit

Permalink
Merge pull request #155 from viniciuslrangel/develop
Browse files Browse the repository at this point in the history
Updated Deprecated methods and Null Pointer verification
  • Loading branch information
ZiwKerman authored Mar 26, 2018
2 parents 5f54289 + d910ec5 commit 68a0d6e
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 47 deletions.
47 changes: 30 additions & 17 deletions InfernalRobotics/InfernalRobotics/Gui/IRBuildAid/BasicInterval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,19 @@ protected override void Awake ()
defaultPosMarker = lineRenderers [4];

}

mainLine.SetVertexCount (2);
endPoint1.SetVertexCount(2);
endPoint2.SetVertexCount(2);

currentPosMarker.SetVertexCount(2);
defaultPosMarker.SetVertexCount(2);
mainLine.positionCount = 2;
endPoint1.positionCount = 2;
endPoint2.positionCount = 2;

currentPosMarker.positionCount = 2;
defaultPosMarker.positionCount = 2;
}

public void SetMainLineColors(Color startColor, Color endColor)
{
mainLine.SetColors(startColor, endColor);
mainLine.startColor = startColor;
mainLine.endColor = endColor;
}

public void SetPresetPositions(List<float> newList)
Expand All @@ -121,8 +122,12 @@ public void SetPresetPositions(List<float> newList)
var posRenderer = CreateNewRenderer();
posRenderer.material = material;
presetsPosMarkers.Add(posRenderer);
posRenderer.SetVertexCount(2);
posRenderer.SetColors(presetPositionsColor, presetPositionsColor);
posRenderer.positionCount = 2;
//posRenderer.positionCount = 2;
posRenderer.startColor = presetPositionsColor;
posRenderer.endColor = presetPositionsColor;
//posRenderer.startColor = presetPositionsColor;
//posRenderer.endColor = presetPositionsColor;
posRenderer.gameObject.layer = gameObject.layer;
}
}
Expand Down Expand Up @@ -152,36 +157,44 @@ protected override void LateUpdate ()
endPoint1.SetPosition (0, mainStartPoint + cross * width * 2);
endPoint1.SetPosition (1, mainStartPoint - cross * width * 2);

endPoint1.SetColors(endPoint1Color, endPoint1Color);
endPoint1.startColor = endPoint1Color;
endPoint1.endColor = endPoint1Color;

endPoint2.SetPosition (0, mainEndPoint + cross * width * 2);
endPoint2.SetPosition (1, mainEndPoint - cross * width * 2);

endPoint2.SetColors(endPoint2Color, endPoint2Color);
endPoint2.startColor = endPoint2Color;
endPoint2.endColor = endPoint2Color;

currentPosMarker.SetWidth (width*2, 0.01f);
currentPosMarker.startWidth = width*2;
currentPosMarker.endWidth = 0.01f;

currentPosMarker.SetColors(currentPositionColor, currentPositionColor);
currentPosMarker.startColor = currentPositionColor;
currentPosMarker.endColor = currentPositionColor;

currentPosMarker.SetPosition (0, currentPosPoint - cross * width * 2);
currentPosMarker.SetPosition (1, currentPosPoint);

defaultPosMarker.SetWidth (width*2, 0.01f);
defaultPosMarker.startWidth = width*2;
defaultPosMarker.endWidth = 0.01f;

defaultPosMarker.SetPosition (0, defaultPosPoint + cross * width * 2);
defaultPosMarker.SetPosition (1, defaultPosPoint);

defaultPosMarker.SetColors(endPoint1Color, endPoint1Color);
defaultPosMarker.startColor = endPoint1Color;
defaultPosMarker.endColor = endPoint1Color;

for (int i = 0; i < presetsPosMarkers.Count; i++)
{
var pos = presetPositions[i];
var posMarker = presetsPosMarkers[i];
var posPoint = transform.position + norm * pos;
posMarker.SetWidth(width * 0.5f, width * 0.5f);
posMarker.startWidth = width * 0.5f;
posMarker.endWidth = width * 0.5f;
posMarker.SetPosition(0, posPoint - cross * width * 2.5f);
posMarker.SetPosition(1, posPoint);
posMarker.SetColors(presetPositionsColor, presetPositionsColor);
posMarker.startColor = presetPositionsColor;
posMarker.endColor = presetPositionsColor;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,38 @@ protected override void Start ()
{
base.Start ();

mainLine.SetVertexCount(vertexCount);
mainLine.positionCount = vertexCount;
mainLine.useWorldSpace = false;
mainLine.SetColors(lineColor, lineColor);
mainLine.startColor = lineColor;
mainLine.endColor = lineColor;

endPoint1.SetVertexCount(2);
endPoint1.positionCount = 2;
endPoint1.useWorldSpace = false;
endPoint1.SetColors(lineColor, lineColor);
endPoint1.startColor = lineColor;
endPoint1.endColor = lineColor;

endPoint2.SetVertexCount(2);
endPoint2.positionCount = 2;
endPoint2.useWorldSpace = false;
endPoint2.SetColors(lineColor, lineColor);
endPoint2.startColor = lineColor;
endPoint2.endColor = lineColor;

currentPosMarker.SetVertexCount(2);
currentPosMarker.positionCount = 2;
currentPosMarker.useWorldSpace = false;
currentPosMarker.SetColors(lineColor, lineColor);
currentPosMarker.startColor = lineColor;
currentPosMarker.endColor = lineColor;

defaultPosMarker.SetVertexCount(2);
defaultPosMarker.positionCount = 2;
defaultPosMarker.useWorldSpace = false;
defaultPosMarker.SetColors(lineColor, lineColor);
defaultPosMarker.startColor = lineColor;
defaultPosMarker.endColor = lineColor;

for (int i = 0; i < presetsPosMarkers.Count; i++)
{
var posRenderer = presetsPosMarkers[i];
posRenderer.useWorldSpace = false;
posRenderer.SetVertexCount(2);
posRenderer.SetColors(presetPositionsColor, presetPositionsColor);
posRenderer.positionCount = 2;
posRenderer.startColor = presetPositionsColor;
posRenderer.endColor = presetPositionsColor;
posRenderer.gameObject.layer = gameObject.layer;
}

Expand Down Expand Up @@ -86,11 +92,15 @@ protected override void LateUpdate ()
if (arcAngle < 360)
{

endPoint1.SetWidth (width, width);
endPoint2.SetWidth (width, width);
endPoint1.startWidth = width;
endPoint1.endWidth = width;
endPoint2.startWidth = width;
endPoint2.endWidth = width;

endPoint1.SetColors(endPoint1Color, endPoint1Color);
endPoint2.SetColors(endPoint2Color, endPoint2Color);
endPoint1.startColor = endPoint1Color;
endPoint1.endColor = endPoint1Color;
endPoint2.startColor = endPoint2Color;
endPoint2.endColor = endPoint2Color;

a = Mathf.Deg2Rad * (offsetAngle);
x = Mathf.Sin (a) * (circleRadius - width*2);
Expand All @@ -117,8 +127,10 @@ protected override void LateUpdate ()

//now draw the currentPosition marker

currentPosMarker.SetColors (currentPositionColor, currentPositionColor);
currentPosMarker.SetWidth (width*2, 0.01f);
currentPosMarker.startColor = currentPositionColor;
currentPosMarker.endColor = currentPositionColor;
currentPosMarker.startWidth = width*2;
currentPosMarker.endWidth = 0.01f;

a = Mathf.Deg2Rad * currentPosition;
x = Mathf.Sin (a) * (circleRadius - width*2);
Expand All @@ -131,8 +143,10 @@ protected override void LateUpdate ()
v = new Vector3(x, y, z);
currentPosMarker.SetPosition(1, v);

defaultPosMarker.SetWidth (width*2, 0.01f);
defaultPosMarker.SetColors(endPoint1Color, endPoint1Color);
defaultPosMarker.startWidth = width*2;
defaultPosMarker.endWidth = 0.01f;
defaultPosMarker.startColor = endPoint1Color;
defaultPosMarker.endColor = endPoint1Color;

a = Mathf.Deg2Rad * defaultPosition;
x = Mathf.Sin (a) * (circleRadius + width*2);
Expand All @@ -151,8 +165,10 @@ protected override void LateUpdate ()
posMarker.useWorldSpace = false;
var pos = presetPositions[i];

posMarker.SetColors(presetPositionsColor, presetPositionsColor);
posMarker.SetWidth(width * 0.5f, width * 0.5f);
posMarker.startColor = presetPositionsColor;
posMarker.endColor = presetPositionsColor;
posMarker.startWidth = width * 0.5f;
posMarker.endWidth = width * 0.5f;

a = Mathf.Deg2Rad * pos;
x = Mathf.Sin(a) * (circleRadius + width * 2.5f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ public virtual void UpdateColor (Color newColor)
lineColor = newColor;
foreach(var lr in lineRenderers)
{
lr.SetColors (newColor, newColor);
lr.startColor = newColor;
lr.endColor = newColor;
}
}

public virtual void UpdateWidth(float v1, float v2)
{
foreach(var lr in lineRenderers)
{
lr.SetWidth (v1, v2);
lr.startWidth = v1;
lr.endWidth = v2;
}
}

Expand Down
2 changes: 1 addition & 1 deletion InfernalRobotics/InfernalRobotics/Gui/UIAssetsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void Start()
Logger.Log("Loading bundles from BundlePath: " + bundlePath, Logger.Level.Debug);

//need to clean cache
Caching.CleanCache();
Caching.ClearCache();

StartCoroutine(LoadBundle(bundlePath + "ir_ui_objects.bundle"));

Expand Down
7 changes: 4 additions & 3 deletions InfernalRobotics/InfernalRobotics/Gui/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1621,11 +1621,12 @@ public void ShowIRWindow()

if(HighLogic.LoadedSceneIsEditor || guiFlightEditorWindowOpen)
{
_editorWindowFader.FadeTo(_UIAlphaValue, 0.1f, () => { GUIEnabled = true; appLauncherButton.SetTrue(false); });
if(_editorWindowFader != null)
_editorWindowFader.FadeTo(_UIAlphaValue, 0.1f, () => { GUIEnabled = true; appLauncherButton.SetTrue(false); });
}
else
else if(_controlWindowFader != null)
{
_controlWindowFader.FadeTo(_UIAlphaValue, 0.1f, () => { GUIEnabled = true; appLauncherButton.SetTrue(false); });
_controlWindowFader.FadeTo(_UIAlphaValue, 0.1f, () => { GUIEnabled = true; appLauncherButton.SetTrue(false); });
}

}
Expand Down
4 changes: 2 additions & 2 deletions InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,8 @@ protected virtual void BuildAttachments()
/// </summary>
protected void FindTransforms()
{
ModelTransform = part.transform.FindChild("model");
RotateModelTransform = ModelTransform.FindChild(rotateModel);
ModelTransform = part.transform.Find("model");
RotateModelTransform = ModelTransform.Find(rotateModel);

FixedMeshTransform = KSPUtil.FindInPartModel(transform, fixedMesh);
}
Expand Down

0 comments on commit 68a0d6e

Please sign in to comment.