Skip to content

Commit

Permalink
Prerelease for 1.1. Some bugs. Some Parts Don't Hide
Browse files Browse the repository at this point in the history
  • Loading branch information
bigorangemachine committed Apr 3, 2016
1 parent f74b84d commit ea4c257
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
Binary file modified GameData.zip
Binary file not shown.
16 changes: 8 additions & 8 deletions src/KRSEditorAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void Awake()
print("awake");
}

void OnPostRender()
void OnPostRender(Camera cameraArg)
{
if (!this.evo.CoMmarker.gameObject.activeInHierarchy) return;

Expand All @@ -45,12 +45,12 @@ void OnPostRender()
var t = this.evo.CoMmarker.posMarkerObject.transform;
Vector3 dirInterval;
int dirAxis;
dirAxis = -Math.Sign(Vector3.Dot(this.camera.transform.forward, t.forward));
dirAxis = -Math.Sign(Vector3.Dot(cameraArg.transform.forward, t.forward));

GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.forward)) - 0.707f) * 5f)));
GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.forward)) - 0.707f) * 5f)));
GL.Vertex(t.position - t.forward * 10f);
GL.Vertex(t.position + t.forward * 10f);
dirInterval = (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.right)) < 0.7071 ? t.right : t.up) * 0.5f;
dirInterval = (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.right)) < 0.7071 ? t.right : t.up) * 0.5f;
for (var i = 0; i < 10; ++i)
{
GL.Vertex(t.position - t.forward * i - dirInterval);
Expand All @@ -59,10 +59,10 @@ void OnPostRender()
GL.Vertex(t.position + t.forward * i + dirInterval);
}

GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.right)) - 0.707f) * 5f)));
GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.right)) - 0.707f) * 5f)));
GL.Vertex(t.position - t.right * 10f);
GL.Vertex(t.position + t.right * 10f);
dirInterval = (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.forward)) < 0.7071 ? t.forward : t.up) * 0.5f;
dirInterval = (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.forward)) < 0.7071 ? t.forward : t.up) * 0.5f;
for (var i = 0; i < 10; ++i)
{
GL.Vertex(t.position - t.right * i - dirInterval);
Expand All @@ -71,10 +71,10 @@ void OnPostRender()
GL.Vertex(t.position + t.right * i + dirInterval);
}

GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.up)) - 0.707f) * 5f)));
GL.Color(Color.yellow * new Color(1f, 1f, 1f, Mathf.Lerp(1f, 0f, (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.up)) - 0.707f) * 5f)));
GL.Vertex(t.position - t.up * 10f);
GL.Vertex(t.position + t.up * 10f);
dirInterval = (Math.Abs(Vector3.Dot(this.camera.transform.forward, t.forward)) < 0.7071 ? t.forward : t.right) * 0.5f;
dirInterval = (Math.Abs(Vector3.Dot(cameraArg.transform.forward, t.forward)) < 0.7071 ? t.forward : t.right) * 0.5f;
for (var i = 0; i < 10; ++i)
{
GL.Vertex(t.position - t.up * i - dirInterval);
Expand Down
47 changes: 27 additions & 20 deletions src/KRSVesselShotUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using UnityEngine;
using KSP.UI.Screens;

namespace KronalUtils
{
Expand All @@ -19,7 +20,7 @@ class KRSVesselShotUI : MonoBehaviour
private string[] shaderTabsNames;
private Rect orthoViewRect;
private GUIStyle guiStyleButtonAlert;
private ApplicationLauncherButton KVVButton;
private KSP.UI.Screens.ApplicationLauncherButton KVVButton;
private bool visible;
private KRSEditorAxis axis;
private bool IsOnEditor()
Expand Down Expand Up @@ -62,25 +63,25 @@ private void ConfigReverted()
private void ButtonMode(bool isOn){
if (isOn)
{
EditorLogic.fetch.partPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.actionPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.crewPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.saveBtn.controlIsEnabled = true;
EditorLogic.fetch.launchBtn.controlIsEnabled = true;
EditorLogic.fetch.exitBtn.controlIsEnabled = true;
EditorLogic.fetch.loadBtn.controlIsEnabled = true;
EditorLogic.fetch.newBtn.controlIsEnabled = true;
EditorLogic.fetch.partPanelBtn.enabled = true;
EditorLogic.fetch.actionPanelBtn.enabled = true;
EditorLogic.fetch.crewPanelBtn.enabled = true;
EditorLogic.fetch.saveBtn.enabled = true;
EditorLogic.fetch.launchBtn.enabled = true;
EditorLogic.fetch.exitBtn.enabled = true;
EditorLogic.fetch.loadBtn.enabled = true;
EditorLogic.fetch.newBtn.enabled = true;
}
else
{
EditorLogic.fetch.partPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.actionPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.crewPanelBtn.controlIsEnabled = true;
EditorLogic.fetch.saveBtn.controlIsEnabled = false;
EditorLogic.fetch.launchBtn.controlIsEnabled = false;
EditorLogic.fetch.exitBtn.controlIsEnabled = false;
EditorLogic.fetch.loadBtn.controlIsEnabled = true;
EditorLogic.fetch.newBtn.controlIsEnabled = true;
EditorLogic.fetch.partPanelBtn.enabled = true;
EditorLogic.fetch.actionPanelBtn.enabled = true;
EditorLogic.fetch.crewPanelBtn.enabled = true;
EditorLogic.fetch.saveBtn.enabled = false;
EditorLogic.fetch.launchBtn.enabled = false;
EditorLogic.fetch.exitBtn.enabled = false;
EditorLogic.fetch.loadBtn.enabled = true;
EditorLogic.fetch.newBtn.enabled = true;

}

Expand Down Expand Up @@ -445,7 +446,10 @@ private void GUITabConfig()

void OnGUIAppLauncherReady()
{
if (ApplicationLauncher.Ready)
#if DEBUG
Debug.Log(string.Format("KVV: OnGUIAppLauncherReady {0}", KSP.UI.Screens.ApplicationLauncher.Ready.ToString()));
#endif
if (KSP.UI.Screens.ApplicationLauncher.Ready)
{
KVVButton = ApplicationLauncher.Instance.AddModApplication(
onAppLaunchToggleOn,
Expand All @@ -454,7 +458,7 @@ void OnGUIAppLauncherReady()
DummyVoid,
DummyVoid,
DummyVoid,
ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.VAB,
KSP.UI.Screens.ApplicationLauncher.AppScenes.SPH | KSP.UI.Screens.ApplicationLauncher.AppScenes.VAB,
(Texture)GameDatabase.Instance.GetTexture("KronalUtils/Textures/icon_button", false));
control.setFacility();

Expand All @@ -478,12 +482,15 @@ void DummyVoid() { }

void OnDestroy()
{
#if DEBUG
Debug.Log(string.Format("KVV: OnDestroy"));
#endif
GameEvents.onGUIApplicationLauncherReady.Remove(OnGUIAppLauncherReady);
if (this.axis != null)
EditorLogic.DestroyObject(this.axis);

if (KVVButton != null)
ApplicationLauncher.Instance.RemoveModApplication(KVVButton);
KSP.UI.Screens.ApplicationLauncher.Instance.RemoveModApplication(KVVButton);

Resources.UnloadUnusedAssets();//fix memory leak?
}
Expand Down
1 change: 0 additions & 1 deletion src/VesselViewConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public VesselViewConfig()
//updated for simpflication
private void StateToggle(bool toggleOn)
{
//var p = EditorLogic.startPod;
var p = EditorLogic.RootPart;
if (toggleOn)
{
Expand Down

0 comments on commit ea4c257

Please sign in to comment.