Skip to content

Commit

Permalink
Merge pull request #132 from DMagic1/dev
Browse files Browse the repository at this point in the history
Version 11rc5
  • Loading branch information
DMagic1 committed Apr 22, 2015
2 parents 6c70c69 + 07c3508 commit 99cc72d
Show file tree
Hide file tree
Showing 20 changed files with 431 additions and 176 deletions.
Binary file added SCANassets/Icons/SCAN_TargetIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added SCANassets/Icons/SCAN_TargetYellowIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion SCANassets/SCANsat.version
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"MAJOR":1,
"MINOR":1,
"PATCH":1,
"BUILD":4
"BUILD":5
},
"KSP_VERSION":{
"MAJOR":0,
Expand Down
6 changes: 3 additions & 3 deletions SCANmechjeb/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.4.0")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion ("v11rc4")]
[assembly: AssemblyVersion("1.1.5.0")]
[assembly: AssemblyFileVersion("1.1.5.0")]
[assembly: AssemblyInformationalVersion ("v11rc5")]

[assembly: KSPAssembly ("SCANmechjeb", 0, 1)]
[assembly: KSPAssemblyDependency ("SCANsat", 1, 1)]
Expand Down
30 changes: 18 additions & 12 deletions SCANmechjeb/SCANmechjeb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ protected override void LateUpdate()
return;
}

if (!SCANcontroller.controller.mechJebTargetSelection)
{
way = null;
return;
}

v = FlightGlobals.ActiveVessel;

if (v == null)
Expand All @@ -49,8 +55,8 @@ protected override void LateUpdate()
return;
}

if (v.mainBody != SCANcontroller.controller.MechJebTargetBody)
SCANcontroller.controller.MechJebTargetBody = v.mainBody;
if (v.mainBody != SCANcontroller.controller.LandingTargetBody)
SCANcontroller.controller.LandingTargetBody = v.mainBody;

data = SCANUtil.getData(v.mainBody);

Expand Down Expand Up @@ -116,20 +122,20 @@ protected override void LateUpdate()
RenderingManager.AddToPostDrawQueue(1, drawTarget);
}

if (SCANcontroller.controller.MechJebTarget != null)
if (SCANcontroller.controller.LandingTarget != null)
{
way = SCANcontroller.controller.MechJebTarget;
way = SCANcontroller.controller.LandingTarget;
}

if (SCANcontroller.controller.MechJebSelecting)
if (SCANcontroller.controller.TargetSelecting)
{
way = null;
selectingTarget = true;
if (SCANcontroller.controller.MechJebSelectingActive)
if (SCANcontroller.controller.TargetSelectingActive)
selectingInMap = true;
else
selectingInMap = false;
coords = SCANcontroller.controller.MechJebTargetCoords;
coords = SCANcontroller.controller.LandingTargetCoords;
return;
}
else if (selectingTarget)
Expand All @@ -138,9 +144,9 @@ protected override void LateUpdate()
if (selectingInMap)
{
selectingInMap = false;
coords = SCANcontroller.controller.MechJebTargetCoords;
coords = SCANcontroller.controller.LandingTargetCoords;
way = new SCANwaypoint(coords.y, coords.x, siteName);
target.SetPositionTarget(SCANcontroller.controller.MechJebTargetBody, way.Latitude, way.Longitude);
target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, way.Latitude, way.Longitude);
}
}

Expand Down Expand Up @@ -173,14 +179,14 @@ protected override void LateUpdate()
if (!SCANUtil.ApproxEq(coords.x, way.Longitude) || !SCANUtil.ApproxEq(coords.y, way.Latitude))
{
way = new SCANwaypoint(coords.y, coords.x, siteName);
SCANcontroller.controller.MechJebTarget = way;
SCANcontroller.controller.LandingTarget = way;
data.addToWaypoints();
}
}
else
{
way = new SCANwaypoint(coords.y, coords.x, siteName);
SCANcontroller.controller.MechJebTarget = way;
SCANcontroller.controller.LandingTarget = way;
data.addToWaypoints();
}
}
Expand All @@ -198,7 +204,7 @@ private void drawTarget()
if (!v.isActiveVessel || v.GetMasterMechJeb() != core)
return;

GLUtils.DrawMapViewGroundMarker(SCANcontroller.controller.MechJebTargetBody, coords.y, coords.x, palette.mechjebYellow);
GLUtils.DrawMapViewGroundMarker(SCANcontroller.controller.LandingTargetBody, coords.y, coords.x, palette.mechjebYellow);
}
}
}
25 changes: 17 additions & 8 deletions SCANmechjeb/SCANmechjebMainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,16 @@ namespace SCANmechjeb
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
public class SCANmechjebMainMenu : MonoBehaviour
{
private const string SCANsat = "SCANsat";
private const string SCANsatName = "SCANsat";
private const string MechJeb = "MechJeb2";
private const string SCANsatVersion = "v11rc3";
private readonly Version MechJebVersion = new Version(2, 4, 2, 0);
private static bool loaded = false;

private void Awake()
{
loaded = checkLoaded();

if (loaded)
print("[SCANsatMechJeb] SCANsat and MechJeb Assemblies Detected");
else
print("[SCANsatMechJeb] SCANsat or MechJeb Assembly Not Detected; Shutting Down...");
print(loaded ? "[SCANsatMechJeb] SCANsat and MechJeb Assemblies Detected" : "[SCANsatMechJeb] SCANsat or MechJeb Assembly Not Detected; Shutting Down...");
}

public static bool Loaded
Expand All @@ -34,7 +30,7 @@ public static bool Loaded

private bool checkLoaded()
{
var SCANassembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == SCANsat);
var SCANassembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == SCANsatName);

if (SCANassembly == null)
return false;
Expand All @@ -44,7 +40,17 @@ private bool checkLoaded()
if (infoV == null)
return false;

if (infoV.InformationalVersion != SCANsatVersion)
var SCANmechjebAssembly = Assembly.GetExecutingAssembly();

if (SCANmechjebAssembly == null)
return false;

var SMinfoV = Attribute.GetCustomAttribute(SCANmechjebAssembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;

if (SMinfoV == null)
return false;

if (infoV.InformationalVersion != SMinfoV.InformationalVersion)
return false;

var MechJebAssembly = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.assembly.GetName().Name == MechJeb);
Expand All @@ -58,7 +64,10 @@ private bool checkLoaded()
return false;

if (fileV.Version == MechJebVersion.ToString())
{
SCANsat.SCANmainMenuLoader.MechJebLoaded = true;
return true;
}

return false;
}
Expand Down
37 changes: 29 additions & 8 deletions SCANsat/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
Version 11.5 - 2015-4-22
------------------------

- Fix MechJeb integration

- Add MechJeb-independent targeting system
- Target selection controlled through zoom map
- Toggle MechJeb integration through settings menu if available
- Landing target overlayed on the planet in map view
- Green, four-arrow target used to differentiate between SCANsat and MechJeb targets

- Landing target waypoints made persistent
- Each planet can have one saved landing target waypoint
- Clear existing targets by initiating target selection from the zoom map and clicking outside of the actual map texture
- Saved targets won't automatically update MechJeb Landing Guidance module

- Orbit shown in Tracking Station when targeting a vessel

- Possibly? Support for custom waypoints generated by nightingale's Waypoint Manager
- New custom waypoints won't be added to the map until after scene change/reload

Version 11.4 - 2015-4-18
------------------------

Expand All @@ -9,16 +30,16 @@ Version 11.3 - 2015-4-18
------------------------

- Color management options for slope maps
- Two sets of colors are used to define the slope maps, one for low slope levels, another for high levels
- Default slope colors tweaked
- Minor color management UI tweaks
- Two sets of colors are used to define the slope maps, one for low slope levels, another for high levels
- Default slope colors tweaked
- Minor color management UI tweaks

- MechJeb landing guidance interface
- Landing targets selected through MechJeb will show as special waypoint icons on SCANsat maps of the current planet
- Landing targets can be selected through the SCANsat zoom map using the landing target icon
- Interface only loads if both SCANsat and MechJeb are present
- Landing targets also show on IVA maps through Raster Prop Monitor
- Landing targets selected through MechJeb will show as special waypoint icons on SCANsat maps of the current planet
- Landing targets can be selected through the SCANsat zoom map using the landing target icon
- Interface only loads if both SCANsat and MechJeb are present
- Landing targets also show on IVA maps through Raster Prop Monitor

- Fixes bug with waypoints loading when the map is open during scene changes
- Includes a fixed Active Texture Management config file to prevent SCANsat icons from being altered
- Window positions made persistent
Expand Down
6 changes: 3 additions & 3 deletions SCANsat/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.1.4.0")]
[assembly: AssemblyFileVersion ("1.1.4.0")]
[assembly: AssemblyInformationalVersion ("v11rc4")]
[assembly: AssemblyVersion ("1.1.5.0")]
[assembly: AssemblyFileVersion ("1.1.5.0")]
[assembly: AssemblyInformationalVersion ("v11rc5")]

[assembly: KSPAssembly ("SCANsat", 1, 1)]

Expand Down
41 changes: 25 additions & 16 deletions SCANsat/SCAN_Data/SCANdata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,39 @@ public SCANanomaly[] Anomalies
#region Waypoints

private List<SCANwaypoint> waypoints;
private bool waypointsLoaded;

public void addToWaypoints()
{
if (SCANcontroller.controller == null)
return;

addToWaypoints(SCANcontroller.controller.LandingTarget);
}

public void addToWaypoints(SCANwaypoint w)
{
if (waypoints == null)
{
waypoints = new List<SCANwaypoint>() { SCANcontroller.controller.MechJebTarget };
waypoints = new List<SCANwaypoint>() { w };
return;
}

if (waypoints.Any(a => a.Mechjeb))
waypoints.RemoveAll(a => a.Mechjeb);
if (waypoints.Any(a => a.LandingTarget))
waypoints.RemoveAll(a => a.LandingTarget);

waypoints.Add(SCANcontroller.controller.MechJebTarget);
waypoints.Add(w);
}

public void removeTargetWaypoint()
{
if (waypoints == null)
return;

SCANwaypoint w = waypoints.FirstOrDefault(a => a.Mechjeb);

SCANcontroller.controller.MechJebTarget = null;
if (waypoints.Any(a => a.LandingTarget))
waypoints.RemoveAll(a => a.LandingTarget);

if (w != null)
waypoints.Remove(w);
SCANcontroller.controller.LandingTarget = null;
}

public List<SCANwaypoint> Waypoints
Expand All @@ -174,9 +178,11 @@ public List<SCANwaypoint> Waypoints

if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && !SCANcontroller.controller.ContractsLoaded)
return new List<SCANwaypoint>();
else if (waypoints == null)
else if (!waypointsLoaded)
{
List<SCANwaypoint> bodyWaypoints = new List<SCANwaypoint>();
waypointsLoaded = true;
if (waypoints == null)
waypoints = new List<SCANwaypoint>();
if (ContractSystem.Instance != null)
{
var surveys = ContractSystem.Instance.GetCurrentActiveContracts<SurveyContract>();
Expand All @@ -193,7 +199,7 @@ public List<SCANwaypoint> Waypoints
{
SCANwaypoint p = new SCANwaypoint(s);
if (p.Way != null)
bodyWaypoints.Add(p);
waypoints.Add(p);
}
}
}
Expand All @@ -218,7 +224,7 @@ public List<SCANwaypoint> Waypoints
{
SCANwaypoint p = new SCANwaypoint(s);
if (p.Way != null)
bodyWaypoints.Add(p);
waypoints.Add(p);
}
}
}
Expand All @@ -240,17 +246,20 @@ public List<SCANwaypoint> Waypoints
{
if (p.contractReference.ContractState == Contract.State.Active)
{
if (!bodyWaypoints.Any(a => a.Way == p))
if (!waypoints.Any(a => a.Way == p))
{
bodyWaypoints.Add(new SCANwaypoint(p));
waypoints.Add(new SCANwaypoint(p));
}
}
}
else if (!waypoints.Any(a => a.Way == p))
{
waypoints.Add(new SCANwaypoint(p));
}
}
}
}
}
waypoints = bodyWaypoints;
}

return waypoints;
Expand Down
14 changes: 7 additions & 7 deletions SCANsat/SCAN_Data/SCANwaypoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal SCANwaypoint(SurveyWaypointParameter p)
name = way.name;
longitude = SCANUtil.fixLonShift(way.longitude);
latitude = SCANUtil.fixLatShift(way.latitude);
mechjeb = false;
landingTarget = false;
}
}

Expand All @@ -34,7 +34,7 @@ internal SCANwaypoint(StationaryPointParameter p)
name = way.name;
longitude = SCANUtil.fixLonShift(way.longitude);
latitude = SCANUtil.fixLatShift(way.latitude);
mechjeb = false;
landingTarget = false;
}
}

Expand All @@ -47,7 +47,7 @@ internal SCANwaypoint(Waypoint p)
name = way.name;
longitude = SCANUtil.fixLonShift(way.longitude);
latitude = SCANUtil.fixLatShift(way.latitude);
mechjeb = false;
landingTarget = false;
}

public SCANwaypoint(double lat, double lon, string n)
Expand All @@ -59,7 +59,7 @@ public SCANwaypoint(double lat, double lon, string n)
name = n;
longitude = SCANUtil.fixLonShift(lon);
latitude = SCANUtil.fixLatShift(lat);
mechjeb = true;
landingTarget = true;
}

private Waypoint way;
Expand All @@ -69,7 +69,7 @@ public SCANwaypoint(double lat, double lon, string n)
private FlightBand band;
private Contract root;
private ContractParameter param;
private bool mechjeb;
private bool landingTarget;

public Waypoint Way
{
Expand Down Expand Up @@ -106,9 +106,9 @@ public FlightBand Band
get { return band; }
}

public bool Mechjeb
public bool LandingTarget
{
get { return mechjeb; }
get { return landingTarget; }
}

private Waypoint reflectWaypoint(SurveyWaypointParameter p)
Expand Down
Loading

0 comments on commit 99cc72d

Please sign in to comment.