Skip to content

Commit

Permalink
Merge pull request #129 from DMagic1/dev
Browse files Browse the repository at this point in the history
Version 11rc3
  • Loading branch information
DMagic1 committed Apr 18, 2015
2 parents d585c72 + 7e2824a commit dcde2ce
Show file tree
Hide file tree
Showing 35 changed files with 1,585 additions and 567 deletions.
215 changes: 124 additions & 91 deletions README.md

Large diffs are not rendered by default.

Binary file added SCANassets/Icons/SCAN_MechJebIcon.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_MechJebYellowIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions SCANassets/Resources/SCANatm.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ACTIVE_TEXTURE_MANAGER_CONFIG
{
folder = SCANsat
enabled = true
OVERRIDES
{
SCANsat/Icons/.*
{
compress = true
mipmaps = false
scale = 1
max_size = 0
make_not_readable = false
}
}
}
18 changes: 10 additions & 8 deletions SCANassets/Resources/SCANcolors.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ SCAN_Color_Config
highBiomeColor = 0.7,0.2388235,0,1
biomeTransparency = 30
stockBiomeMap = False
lowSlopeColor = 0.6039216,0.682353,0.02745098,1
highSlopeColor = 1,1,0.07843138,1
bottomLowSlopeColor = 0.004705883,0.6,0.3788235,1
bottemHighSlopeColor = 0.9764706,1,0.4627451,1
topLowSlopeColor = 0.9764706,1,0.4627451,1
topHighSlopeColor = 0.94,0.2727843,0.007372549,1
SCANsat_Altimetry
{
Item
Expand Down Expand Up @@ -227,7 +229,7 @@ SCAN_Color_Config
highResourceColor = 0.75,0.3823529,0,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down Expand Up @@ -375,7 +377,7 @@ SCAN_Color_Config
highResourceColor = 0,0.576471,0.07451,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down Expand Up @@ -523,7 +525,7 @@ SCAN_Color_Config
highResourceColor = 1,0.023529,0.180392,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down Expand Up @@ -671,7 +673,7 @@ SCAN_Color_Config
highResourceColor = 0.7428235,0.82,0,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down Expand Up @@ -819,7 +821,7 @@ SCAN_Color_Config
highResourceColor = 1,0.2352941,0.03137255,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down Expand Up @@ -967,7 +969,7 @@ SCAN_Color_Config
highResourceColor = 0,0.5687844,0.98,1
resourceTransparency = 20
defaultMinValue = 0.1
defaultMaxValue = 10
defaultMaxValue = 7
Resource_Planetary_Config
{
Item
Expand Down
4 changes: 2 additions & 2 deletions 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":2
"BUILD":3
},
"KSP_VERSION":{
"MAJOR":0,
Expand All @@ -28,4 +28,4 @@
"MINOR":90,
"PATCH":0
}
}
}
41 changes: 41 additions & 0 deletions SCANmechjeb/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SCANmechjeb")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SCANmechjeb")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a96b8661-cfef-40ab-8798-f701b97808c4")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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.3.0")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion ("v11rc3")]

[assembly: KSPAssembly ("SCANmechjeb", 0, 1)]
[assembly: KSPAssemblyDependency ("SCANsat", 1, 1)]
[assembly: KSPAssemblyDependency("MechJeb2", 2, 4)]
21 changes: 21 additions & 0 deletions SCANmechjeb/SCANmechStarter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


using UnityEngine;

namespace SCANmechjeb
{
[KSPAddon(KSPAddon.Startup.Flight, false)]
class SCANmechStarter : MonoBehaviour
{
private MonoBehaviour SCANmechjebInt;

private void Start()
{
if (SCANmechjebMainMenu.Loaded)
{
print("[SCANsatMechJeb] Starting SCANsat - MechJeb Interface...");
SCANmechjebInt = gameObject.AddComponent<SCANmechjeb>();
}
}
}
}
204 changes: 204 additions & 0 deletions SCANmechjeb/SCANmechjeb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@


using System;
using System.Collections.Generic;
using System.Linq;
using SCANsat;
using SCANsat.SCAN_Data;
using SCANsat.SCAN_Platform;
using log = SCANsat.SCAN_Platform.Logging.ConsoleLogger;
using palette = SCANsat.SCAN_UI.UI_Framework.SCANpalette;
using MuMech;

using UnityEngine;

namespace SCANmechjeb
{
class SCANmechjeb : SCAN_MBE
{
private const string siteName = "MechJeb Landing Target";
private Vessel v;
private MechJebCore core;
private MechJebModuleTargetController target;
private DisplayModule guidanceModule;
private SCANwaypoint way;
private SCANdata data;
private Vector2d coords = new Vector2d();
private bool selectingTarget, selectingInMap, shutdown;

protected override void LateUpdate()
{
if (shutdown)
return;

if (!HighLogic.LoadedSceneIsFlight || !FlightGlobals.ready)
return;

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

v = FlightGlobals.ActiveVessel;

if (v == null)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

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

data = SCANUtil.getData(v.mainBody);

if (data == null)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

if (v.FindPartModulesImplementing<MechJebCore>().Count <= 0)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

core = v.GetMasterMechJeb();

if (core == null)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
{
if (guidanceModule == null)
guidanceModule = (DisplayModule)core.GetComputerModule("MechJebModuleLandingGuidance");

if (guidanceModule == null)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

if (!guidanceModule.unlockChecked)
return;

if (guidanceModule.hidden)
{
SCANcontroller.controller.MechJebLoaded = false;
shutdown = true;
way = null;
return;
}
}

target = core.target;

if (target == null)
{
SCANcontroller.controller.MechJebLoaded = false;
way = null;
return;
}

if (!SCANcontroller.controller.MechJebLoaded)
{
SCANcontroller.controller.MechJebLoaded = true;
RenderingManager.AddToPostDrawQueue(1, drawTarget);
}

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

if (SCANcontroller.controller.MechJebSelecting)
{
way = null;
selectingTarget = true;
if (SCANcontroller.controller.MechJebSelectingActive)
selectingInMap = true;
else
selectingInMap = false;
coords = SCANcontroller.controller.MechJebTargetCoords;
return;
}
else if (selectingTarget)
{
selectingTarget = false;
if (selectingInMap)
{
selectingInMap = false;
coords = SCANcontroller.controller.MechJebTargetCoords;
way = new SCANwaypoint(coords.y, coords.x, siteName);
target.SetPositionTarget(SCANcontroller.controller.MechJebTargetBody, way.Latitude, way.Longitude);
}
}

selectingInMap = false;
selectingTarget = false;

if (target.Target == null)
{
way = null;
return;
}

if (target.targetBody != v.mainBody)
{
way = null;
return;
}

if (!(target.Target is PositionTarget))
{
way = null;
return;
}

coords.x = target.targetLongitude;
coords.y = target.targetLatitude;

if (way != null)
{
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;
data.addToWaypoints();
}
}
else
{
way = new SCANwaypoint(coords.y, coords.x, siteName);
SCANcontroller.controller.MechJebTarget = way;
data.addToWaypoints();
}
}

//Draw the mapview MechJeb target arrows
private void drawTarget()
{
if (!selectingInMap)
return;

target.pickingPositionTarget = false;

if (!MapView.MapIsEnabled)
return;
if (!v.isActiveVessel || v.GetMasterMechJeb() != core)
return;

GLUtils.DrawMapViewGroundMarker(SCANcontroller.controller.MechJebTargetBody, coords.y, coords.x, palette.mechjebYellow);
}
}
}
Loading

0 comments on commit dcde2ce

Please sign in to comment.