Skip to content

Commit

Permalink
Fixed resetting the control point when using the Alt (on Windows) whe…
Browse files Browse the repository at this point in the history
…n cycling past the last camera
  • Loading branch information
linuxgurugamer committed Dec 2, 2018
1 parent 63c6edb commit 1f33aeb
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 31 deletions.
5 changes: 4 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,7 @@
0.1.9.11
Reverted change to line 317 in MuMechModuleHullCamera, caused issues with cameras
Fixed cameras for the inline docking ports to match the navball when the docking port is the active control point
New feature, holding down Alt (on Windows) when hitting + or - will change the control point to the docking port with the camera, only works on docking ports and the original controlling part
New feature, holding down Alt (on Windows) when hitting + or - will change the control point to the docking port with the camera, only works on docking ports and the original controlling part

0.1.9.12
Fixed resetting the control point when using the Alt (on Windows) when cycling past the last camera
2 changes: 1 addition & 1 deletion GameData/HullCameraVDS/HullcamVDSContinued.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MAJOR": 0,
"MINOR": 1,
"PATCH": 9,
"BUILD": 11
"BUILD": 12
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down
2 changes: 1 addition & 1 deletion GameData/HullCameraVDS/Plugins/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ HullCameraVDSConfig
DebugOutput = true
DisplayCameraNameWhenSwitching = true
DisplayVesselNameWhenSwitching = true
MessageDuration = 9
MessageDuration = 3

CAMERA_NEXT
{
Expand Down
32 changes: 32 additions & 0 deletions GameData/HullCameraVDS/Plugins/settings.cfg.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
HullCameraVDSConfig
{
AllowMainCamera = true
CycleMainCamera = true
CycleOnlyActiveVessel = false
DebugOutput = true
DisplayCameraNameWhenSwitching = true
DisplayVesselNameWhenSwitching = true
MessageDuration = 9

CAMERA_NEXT
{
primary = Minus
secondary = None
group = 0
switchState = Any
}
CAMERA_PREV
{
primary = Equals
secondary = None
group = 0
switchState = Any
}
CAMERA_RESET
{
primary = Backspace
secondary = None
group = 0
switchState = Any
}
}
2 changes: 1 addition & 1 deletion HullCamera/AssemblyVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

using System.Reflection;

[assembly: AssemblyVersion("0.1.9.11")]
[assembly: AssemblyVersion("0.1.9.12")]
55 changes: 29 additions & 26 deletions HullCamera/MuMechModuleHullCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected struct ActionFlags

protected static void DebugOutput(object o)
{
// if (sDebugOutput)
if (sDebugOutput)
{
Debug.Log("HullCam: " + o.ToString());
}
Expand All @@ -164,7 +164,6 @@ protected static void DebugOutput(object o)

protected static void StaticInit()
{
Debug.Log("StaticInit");
// Commented out so that we can reload the config by reloading a save file rather than restarting KSP.
/*
if (sInit)
Expand Down Expand Up @@ -248,6 +247,11 @@ protected static void SaveMainCamera()
sOrigFov = Camera.main.fieldOfView;
sOrigPosition = sCam.transform.localPosition;
sOrigRotation = sCam.transform.localRotation;
if (sOrigVesselTransformPart == null)
{
sOrigVesselTransformPart = FlightGlobals.ActiveVessel.GetReferenceTransformPart();
ScreenMessages.PostScreenMessage("Original Control Point: " + sOrigVesselTransformPart.partInfo.title);
}
}

protected static void RestoreMainCamera()
Expand Down Expand Up @@ -284,12 +288,20 @@ protected static void RestoreMainCamera()
{
if (GameSettings.MODIFIER_KEY.GetKey(false))
{
#if false
ModuleDockingNode mdn = sOrigVesselTransformPart.FindModuleImplementing<ModuleDockingNode>();
if (mdn != null)
{
sOrigVesselTransformPart.SetReferenceTransform(mdn.controlTransform);
FlightGlobals.ActiveVessel.SetReferenceTransform(sOrigVesselTransformPart, true);
ScreenMessages.PostScreenMessage("Control Point changed to " + sOrigVesselTransformPart.partInfo.title);
} else
#endif
{
// sOrigVesselTransformPart.SetReferenceTransform(sOrigVesselTransformPart.GetReferenceTransform());
}

FlightGlobals.ActiveVessel.SetReferenceTransform(sOrigVesselTransformPart, true);
ScreenMessages.PostScreenMessage("Control Point restored to " + sOrigVesselTransformPart.partInfo.title);
sOrigVesselTransformPart = null;
}
}
/////////////////////////////////////
Expand Down Expand Up @@ -374,13 +386,20 @@ protected static void CycleCamera(int direction)
newCam = sCameras[nextCam];

#if true

if (newCam.vessel == FlightGlobals.ActiveVessel)
{
if (GameSettings.MODIFIER_KEY.GetKey(false))
{
ModuleDockingNode mdn = newCam.part.FindModuleImplementing<ModuleDockingNode>();
if (mdn != null)
{
if (sOrigVesselTransformPart == null)
{
sOrigVesselTransformPart = FlightGlobals.ActiveVessel.GetReferenceTransformPart();
ScreenMessages.PostScreenMessage("Original Control Point: " + sOrigVesselTransformPart.partInfo.title);
}

newCam.part.SetReferenceTransform(mdn.controlTransform);
FlightGlobals.ActiveVessel.SetReferenceTransform(newCam.part, true);

Expand Down Expand Up @@ -471,16 +490,7 @@ protected void Activate()
}
return;
}
else
{

/////////////////////////////////////

sOrigVesselTransformPart = FlightGlobals.ActiveVessel.GetReferenceTransformPart();
Debug.Log("OrigVesselTransformPart: " + sOrigVesselTransformPart.partInfo.title);

/////////////////////////////////////
}
sCurrentCamera = this;
camActive = true;
changeCameraMode();
Expand All @@ -495,7 +505,7 @@ protected void DirtyWindow()
}
}

#region Events
#region Events

// Note: Events show in the part menu in flight.

Expand All @@ -519,9 +529,9 @@ public void EnableCamera()
DirtyWindow();
}

#endregion
#endregion

#region Actions
#region Actions

// Note: Actions are available to action groups.

Expand Down Expand Up @@ -555,9 +565,9 @@ public void PreviousCameraAction(KSPActionParam ap)
sActionFlags.prevCamera = true;
}

#endregion
#endregion

#region Callbacks
#region Callbacks

void DebugList()
{
Expand Down Expand Up @@ -780,13 +790,6 @@ public void FixedUpdate()
{
return;
}

/////////////////////////////////////

sOrigVesselTransformPart = FlightGlobals.ActiveVessel.GetReferenceTransformPart();
Debug.Log("OrigVesselTransformPart: " + sOrigVesselTransformPart.partInfo.title);

/////////////////////////////////////
}

// Either we haven't set sOriginParent, or we've nulled it when restoring the main camera, so we save it again here.
Expand Down Expand Up @@ -923,7 +926,7 @@ private void Remove()



#endregion
#endregion
}

}
2 changes: 1 addition & 1 deletion HullcamVDSContinued.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MAJOR": 0,
"MINOR": 1,
"PATCH": 9,
"BUILD": 11
"BUILD": 12
},
"KSP_VERSION": {
"MAJOR": 1,
Expand Down

0 comments on commit 1f33aeb

Please sign in to comment.