Skip to content

Commit

Permalink
Merge pull request #664 from MOARdV/master
Browse files Browse the repository at this point in the history
v0.30.1
  • Loading branch information
MOARdV committed May 11, 2018
2 parents 5e642f1 + 435daca commit 02216a5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 12 deletions.
Expand Up @@ -178,21 +178,21 @@ INTERNAL
{
name = Hatch_Plane
position = 0,0,0.14375
rotation = 0,0,0,0
rotation = -0.7071068,0,0,0.7071068
scale = 1,1,1
}
PROP
{
name = Hatch_Plane_Curve90
position = 0.5327566,-0.1737644,-0.1524241
rotation =0,0,0,0
rotation = -0.415627,0.5720614,0.4156268,0.5720614
scale = 1,1,1.000001
}
PROP
{
name = MonitorDockingMode
position = 0,0.0829,-0.8935
rotation = -2.126542E-08,0.9914449,-0.1305262,-1.615269E-07
rotation = 0.6087615,0,1.360013E-07,0.7933533
scale = 0.75,0.75,0.75
}
PROP
Expand Down
2 changes: 1 addition & 1 deletion GameData/JSI/RasterPropMonitor/RasterPropMonitor.version
Expand Up @@ -5,7 +5,7 @@
"VERSION": {
"MAJOR": 0,
"MINOR": 30,
"PATCH": 0
"PATCH": 1
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion RasterPropMonitor.sln
Expand Up @@ -195,6 +195,6 @@ Global
$36.inheritsSet = Mono
$36.inheritsScope = text/plain
$36.scope = text/plain
version = 0.30.0
version = 0.30.1
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions RasterPropMonitor/Core/RasterPropMonitor.cs
Expand Up @@ -179,6 +179,13 @@ public void Start()
foreach (string layerID in textureLayerID.Split())
{
screenMat.SetTexture(layerID.Trim(), screenTexture);
// This code was written for a much older flavor of Unity, and the Unity 2017.1 update broke
// some assumptions about who managed the y-inversion issue between OpenGL and DX9.
if (JUtil.manuallyInvertY)
{
screenMat.SetTextureScale(layerID.Trim(), new Vector2(1.0f, -1.0f));
screenMat.SetTextureOffset(layerID.Trim(), new Vector2(0.0f, 1.0f));
}
}

if (GameDatabase.Instance.ExistsTexture(noSignalTextureURL.EnforceSlashes()))
Expand Down
29 changes: 24 additions & 5 deletions RasterPropMonitor/Core/TextRenderer.cs
Expand Up @@ -161,6 +161,13 @@ public TextRenderer(List<Texture2D> fontTexture, Vector2 fontLetterSize, string

screenXOffset = (float)screenPixelWidth * -0.5f;
screenYOffset = (float)screenPixelHeight * 0.5f - fontLetterSize.y;
if (JUtil.manuallyInvertY)
{
// This code was written for a much older flavor of Unity, and the Unity 2017.1 update broke
// some assumptions about who managed the y-inversion issue between OpenGL and DX9.
screenYOffset = -screenYOffset;
screenYOffset -= fontLetterSize.y;
}

float fontLettersX = Mathf.Floor(fontTexture[0].width / fontLetterSize.x);
float fontLettersY = Mathf.Floor(fontTexture[0].height / fontLetterSize.y);
Expand Down Expand Up @@ -400,7 +407,19 @@ private bool DrawChar(FontRenderer fr, char letter, float xPos, float yPos, Colo
{
if (fontCharacters.ContainsKey(letter))
{
Rect pos = new Rect(screenXOffset + xPos, screenYOffset - ((scriptType == Script.Superscript) ? yPos - fontLetterHalfHeight : yPos),
// This code was written for a much older flavor of Unity, and the Unity 2017.1 update broke
// some assumptions about who managed the y-inversion issue between OpenGL and DX9.
float yPosition;
if (JUtil.manuallyInvertY)
{
yPosition = screenYOffset + ((scriptType == Script.Superscript) ? yPos + fontLetterHalfHeight : yPos);
}
else
{
yPosition = screenYOffset - ((scriptType == Script.Superscript) ? yPos - fontLetterHalfHeight : yPos);
}
Rect pos = new Rect(screenXOffset + xPos,
yPosition,
(fontWidth == Width.Normal ? fontLetterWidth : (fontWidth == Width.Half ? fontLetterHalfWidth : fontLetterDoubleWidth)),
(scriptType != Script.Normal) ? fontLetterHalfHeight : fontLetterHeight);
fr.vertices.Add(new Vector3(pos.xMin, pos.yMin, 0.0f));
Expand All @@ -409,10 +428,10 @@ private bool DrawChar(FontRenderer fr, char letter, float xPos, float yPos, Colo
fr.vertices.Add(new Vector3(pos.xMax, pos.yMax, 0.0f));

Rect uv = fontCharacters[letter];
fr.uvs.Add(new Vector2(uv.xMin, uv.yMin));
fr.uvs.Add(new Vector2(uv.xMax, uv.yMin));
fr.uvs.Add(new Vector2(uv.xMin, uv.yMax));
fr.uvs.Add(new Vector2(uv.xMax, uv.yMax));
fr.uvs.Add(new Vector2(uv.xMin, (JUtil.manuallyInvertY) ? uv.yMax : uv.yMin));
fr.uvs.Add(new Vector2(uv.xMax, (JUtil.manuallyInvertY) ? uv.yMax : uv.yMin));
fr.uvs.Add(new Vector2(uv.xMin, (JUtil.manuallyInvertY) ? uv.yMin : uv.yMax));
fr.uvs.Add(new Vector2(uv.xMax, (JUtil.manuallyInvertY) ? uv.yMin : uv.yMax));

fr.colors32.Add(letterColor);
}
Expand Down
9 changes: 8 additions & 1 deletion RasterPropMonitor/Core/UtilityFunctions.cs
Expand Up @@ -237,6 +237,8 @@ public static class JUtil
internal static Dictionary<string, Font> loadedFonts = new Dictionary<string, Font>();
internal static Dictionary<string, Color32> globalColors = new Dictionary<string, Color32>();

internal static bool manuallyInvertY = false;

internal static GameObject CreateSimplePlane(string name, float vectorSize, int drawingLayer)
{
return CreateSimplePlane(name, new Vector2(vectorSize, vectorSize), new Rect(0.0f, 0.0f, 1.0f, 1.0f), drawingLayer);
Expand Down Expand Up @@ -1857,6 +1859,11 @@ private void Awake()
}
}

if (SystemInfo.graphicsDeviceVersion.StartsWith("Direct3D 9"))
{
JUtil.manuallyInvertY = true;
}

LoadAssets();

StartCoroutine("LoadRasterPropMonitorValues");
Expand Down Expand Up @@ -2010,7 +2017,7 @@ private IEnumerator LoadRasterPropMonitorValues()
}
JUtil.LogMessage(this, "I know {0} = {1}", name, color);
}
catch(Exception e)
catch (Exception e)
{
JUtil.LogErrorMessage(this, "Error parsing color {0}: {1}", colorConfig[defIdx].GetValue("name").Trim(), e);
}
Expand Down
2 changes: 1 addition & 1 deletion SharedAssemblyInfo.cs
Expand Up @@ -12,7 +12,7 @@
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
// Revision number is altered automatically.
[assembly: AssemblyVersion("0.30.0.*")]
[assembly: AssemblyVersion("0.30.1.*")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
Expand Down

0 comments on commit 02216a5

Please sign in to comment.