Skip to content

Commit

Permalink
Fix UI issue of missing signal delay and flight computer button and u…
Browse files Browse the repository at this point in the history
…pdate to hide this UI if EVA construction panel is opened (KSP 1.11)
  • Loading branch information
KSP-TaxiService committed Dec 19, 2020
1 parent 5521c76 commit 067a053
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/RemoteTech/UI/TimeWarpDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using RemoteTech.SimpleTypes;
using UnityEngine;
using KSP.UI;
using KSP.UI.Screens.Flight;
using KSP.Localization;

namespace RemoteTech.UI
Expand All @@ -17,7 +16,7 @@ public class TimeWarpDecorator
/// <summary>
/// Image for position access
/// </summary>
private UnityEngine.UI.Image mTimewarpImage;
private UnityEngine.RectTransform mTimewarpTransform;
/// <summary>
/// Delay-Text style
/// </summary>
Expand Down Expand Up @@ -115,11 +114,11 @@ public TimeWarpDecorator()
GameObject go = GameObject.Find("TimeQuadrant");
if (go)
{
mTimewarpImage = go.GetComponent<UnityEngine.UI.Image>();
mTimewarpTransform = go.GetComponent<UnityEngine.RectTransform>();
}

// objects on this scene?
if (mTimewarpImage == null || TimeWarp.fetch == null)
if (mTimewarpTransform == null || TimeWarp.fetch == null)
{
return;
}
Expand All @@ -138,17 +137,21 @@ public TimeWarpDecorator()
public void Draw()
{
// no drawing without timewarp object
if (mTimewarpImage == null)
if (mTimewarpTransform == null)
return;

// no drawing with in-flight action group panel is opened
// no drawing if in-flight action group panel is opened
if(ActionGroupsFlightController.Instance != null && ActionGroupsFlightController.Instance.IsOpen)
return;

Vector2 timeWarpImageScreenCoord = UIMainCamera.Camera.WorldToScreenPoint(mTimewarpImage.rectTransform.position);
// no drawing if in-flight construction panel is opened
if (EVAConstructionModeController.Instance != null && EVAConstructionModeController.Instance.IsOpen)
return;

Vector2 timeWarpImageScreenCoord = UIMainCamera.Camera.WorldToScreenPoint(mTimewarpTransform.position);

float scale = GameSettings.UI_SCALE_TIME * GameSettings.UI_SCALE;
float topLeftTotimeQuadrant = Screen.height - (timeWarpImageScreenCoord.y - (mTimewarpImage.preferredHeight * scale));
float topLeftTotimeQuadrant = Screen.height - (timeWarpImageScreenCoord.y - (mTimewarpTransform.rect.height * scale));
float texBackgroundHeight = (mTexBackground.height * 0.7f) * scale;
float texBackgroundWidth = (mTexBackground.width * 0.8111f) * scale;

Expand Down

1 comment on commit 067a053

@KSP-TaxiService
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to issue #821

Please sign in to comment.