diff --git a/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg b/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg index d72b32c32..6e5691742 100644 --- a/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg +++ b/SCANassets/MM_Parts/SCANsat_Resource_Scanner.cfg @@ -40,7 +40,11 @@ max_alt = 500000 best_alt = 150000 scanName = Ore Scan - power = 0.4 + RESOURCE + { + name = ElectricCharge + rate = 0.4 + } } MODULE @@ -72,7 +76,11 @@ max_alt = 1000000 best_alt = 150000 scanName = Resource Scan - power = 0.5 + RESOURCE + { + name = ElectricCharge + rate = 0.5 + } } } @@ -87,7 +95,11 @@ max_alt = 71000 best_alt = 65000 scanName = Metal Ore Scan - power = 0.4 + RESOURCE + { + name = ElectricCharge + rate = 0.4 + } } MODULE @@ -109,7 +121,11 @@ max_alt = 500000 best_alt = 200000 scanName = Metal Ore Scan - power = 0.8 + RESOURCE + { + name = ElectricCharge + rate = 0.8 + } } MODULE @@ -131,7 +147,11 @@ max_alt = 500000 best_alt = 150000 scanName = Resource Scan - power = 0.4 + RESOURCE + { + name = ElectricCharge + rate = 0.4 + } } MODULE @@ -290,7 +310,11 @@ max_alt = 500000 best_alt = 150000 scanName = Karbonite Scan - power = 0.4 + RESOURCE + { + name = ElectricCharge + rate = 0.4 + } } MODULE diff --git a/SCANassets/Parts/BTDT/BTDT.cfg b/SCANassets/Parts/BTDT/BTDT.cfg index 200f36321..fece1ffee 100644 --- a/SCANassets/Parts/BTDT/BTDT.cfg +++ b/SCANassets/Parts/BTDT/BTDT.cfg @@ -41,7 +41,11 @@ MODULE min_alt = 0 max_alt = 2000 best_alt = 0 - power = 0.1 scanName = BTDT Scan + RESOURCE + { + name = ElectricCharge + rate = 0.1 + } } } diff --git a/SCANassets/Parts/MULTI/MULTI.cfg b/SCANassets/Parts/MULTI/MULTI.cfg index 1f47f9cc8..bf0401e06 100644 --- a/SCANassets/Parts/MULTI/MULTI.cfg +++ b/SCANassets/Parts/MULTI/MULTI.cfg @@ -40,8 +40,12 @@ MODULE min_alt = 5000 max_alt = 500000 best_alt = 250000 - power = 1 scanName = Multispectral Scan animationName = Multi_Antenna + RESOURCE + { + name = ElectricCharge + rate = 1 + } } } diff --git a/SCANassets/Parts/MapTraq/MapTraq.cfg b/SCANassets/Parts/MapTraq/MapTraq.cfg index 136c60886..7fcee788d 100644 --- a/SCANassets/Parts/MapTraq/MapTraq.cfg +++ b/SCANassets/Parts/MapTraq/MapTraq.cfg @@ -45,7 +45,11 @@ MODULE min_alt = 0 max_alt = 0 best_alt = 0 - power = 0.05 scanName = Eyeball Scan + RESOURCE + { + name = ElectricCharge + rate = 0.05 + } } } diff --git a/SCANassets/Parts/RADAR/RADAR.cfg b/SCANassets/Parts/RADAR/RADAR.cfg index a0196baea..8fcc3f5ed 100644 --- a/SCANassets/Parts/RADAR/RADAR.cfg +++ b/SCANassets/Parts/RADAR/RADAR.cfg @@ -43,7 +43,11 @@ MODULE max_alt = 500000 best_alt = 5000 scanName = RADAR Scan - power = 0.1 animationName = Collapse_Antenna + RESOURCE + { + name = ElectricCharge + rate = 0.1 + } } } diff --git a/SCANassets/Parts/SAR/SAR.cfg b/SCANassets/Parts/SAR/SAR.cfg index aeb940a1d..eee07e3a7 100644 --- a/SCANassets/Parts/SAR/SAR.cfg +++ b/SCANassets/Parts/SAR/SAR.cfg @@ -40,8 +40,12 @@ MODULE min_alt = 5000 max_alt = 800000 best_alt = 750000 - power = 1.5 scanName = SAR Scan animationName = Antenna + RESOURCE + { + name = ElectricCharge + rate = 1.5 + } } } diff --git a/SCANassets/Resources/Contracts/Biome.cfg b/SCANassets/Resources/Contracts/Biome.cfg index cac977cd0..26c554aea 100644 --- a/SCANassets/Resources/Contracts/Biome.cfg +++ b/SCANassets/Resources/Contracts/Biome.cfg @@ -2,6 +2,7 @@ CONTRACT_TYPE { name = SCAN_Biome title = Do a Biome Scan of @/targetBody2 + genericTitle = Do a Biome Scan of a body. group = ScanSatOfficial agent = SCAN: Scientific Committee on Advanced Navigation topic = Science @@ -32,7 +33,8 @@ CONTRACT_TYPE type = CelestialBody requiredValue = true uniquenessCheck = CONTRACT_ALL - targetBody2 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.Random() : @ScanSatOfficial:p2Bodies.Random() + targetBody2 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.SelectUnique() : @ScanSatOfficial:p2Bodies.SelectUnique() + title = Must have orbited the target body. } DATA @@ -60,6 +62,7 @@ CONTRACT_TYPE minCoverage = 0.0 maxCoverage = @/minScan2 scanType = Biome + title = Must have scanned less than @/minScan2% of the target body. } REQUIREMENT { diff --git a/SCANassets/Resources/Contracts/ContractPackScanSatOfficial.cfg b/SCANassets/Resources/Contracts/ContractPackScanSatOfficial.cfg index 6a26f6343..70aab7ff0 100644 --- a/SCANassets/Resources/Contracts/ContractPackScanSatOfficial.cfg +++ b/SCANassets/Resources/Contracts/ContractPackScanSatOfficial.cfg @@ -2,8 +2,9 @@ CONTRACT_GROUP { // Name of the contract group name = ScanSatOfficial - - minVersion = 1.9.1 + displayName = ScanSat Official + agent = SCAN: Scientific Committee on Advanced Navigation + minVersion = 1.15.0 maxSimultaneous = 3 diff --git a/SCANassets/Resources/Contracts/HiRes.cfg b/SCANassets/Resources/Contracts/HiRes.cfg index 3416a80f2..3cfe9fd21 100644 --- a/SCANassets/Resources/Contracts/HiRes.cfg +++ b/SCANassets/Resources/Contracts/HiRes.cfg @@ -2,6 +2,7 @@ CONTRACT_TYPE { name = SCAN_HiRes title = Do a High Resolution Scan of @/targetBody3 + genericTitle = Do a High Resolution Scan of a body. group = ScanSatOfficial agent = SCAN: Scientific Committee on Advanced Navigation topic = Science @@ -33,7 +34,8 @@ CONTRACT_TYPE type = CelestialBody requiredValue = true uniquenessCheck = CONTRACT_ALL - targetBody3 = Prestige() == Significant ? @ScanSatOfficial:p2Bodies.Random() : @ScanSatOfficial:p3Bodies.Random() + targetBody3 = Prestige() == Significant ? @ScanSatOfficial:p2Bodies.SelectUnique() : @ScanSatOfficial:p3Bodies.SelectUnique() + title = Must have orbited the target body. } DATA @@ -61,6 +63,7 @@ CONTRACT_TYPE minCoverage = 0.0 maxCoverage = @/minScan3 scanType = AltimetryHiRes + title = Must have scanned less than @/minScan3% of the target body. } REQUIREMENT { diff --git a/SCANassets/Resources/Contracts/LoRes.cfg b/SCANassets/Resources/Contracts/LoRes.cfg index efc64a0dc..e52ab14db 100644 --- a/SCANassets/Resources/Contracts/LoRes.cfg +++ b/SCANassets/Resources/Contracts/LoRes.cfg @@ -2,6 +2,7 @@ CONTRACT_TYPE { name = SCAN_LoRes title = Do a Low Resolution Scan of @/targetBody1 + genericTitle = Do a Low Resolution Scan of a body. group = ScanSatOfficial topic = Science subject = Kerbal @@ -33,7 +34,8 @@ CONTRACT_TYPE type = CelestialBody requiredValue = true uniquenessCheck = CONTRACT_ALL - targetBody1 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.Random() : @ScanSatOfficial:p2Bodies.Random() + targetBody1 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.SelectUnique() : @ScanSatOfficial:p2Bodies.SelectUnique() + title = Must have orbited the target body. } DATA @@ -61,6 +63,7 @@ CONTRACT_TYPE minCoverage = 0.0 maxCoverage = @/minScan1 scanType = AltimetryLoRes + title = Must have scanned less than @/minScan1% of the target body. } REQUIREMENT { diff --git a/SCANassets/Resources/Contracts/M700.cfg b/SCANassets/Resources/Contracts/M700.cfg index 4c323f832..fbe753fcc 100644 --- a/SCANassets/Resources/Contracts/M700.cfg +++ b/SCANassets/Resources/Contracts/M700.cfg @@ -2,6 +2,7 @@ CONTRACT_TYPE { name = SCAN_M700 title = Scan @/targetBody4 for resources + genericTitle = Scan a body for resouces. group = ScanSatOfficial topic = Science subject = Kerbal @@ -32,7 +33,8 @@ CONTRACT_TYPE type = CelestialBody requiredValue = true uniquenessCheck = CONTRACT_ALL - targetBody4 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.Random() : @ScanSatOfficial:p2Bodies.Random() + targetBody4 = Prestige() == Trivial ? @ScanSatOfficial:p1Bodies.SelectUnique() : @ScanSatOfficial:p2Bodies.SelectUnique() + title = Must have orbited the target body. } DATA @@ -60,6 +62,7 @@ CONTRACT_TYPE minCoverage = 0.0 maxCoverage = @/minScan4 scanType = FuzzyResources + title = Must have scanned less than @/minScan4% of the target body. } REQUIREMENT { diff --git a/SCANassets/Resources/Contracts/NarrowBand.cfg b/SCANassets/Resources/Contracts/NarrowBand.cfg index f8bf663a1..a02f91c02 100644 --- a/SCANassets/Resources/Contracts/NarrowBand.cfg +++ b/SCANassets/Resources/Contracts/NarrowBand.cfg @@ -2,6 +2,7 @@ CONTRACT_TYPE { name = SCAN_NarrowBand title = Scan @/targetBody5 for Ore + genericTitle = Scan a body for Ore. group = ScanSatOfficial topic = Science subject = Kerbal @@ -33,7 +34,8 @@ CONTRACT_TYPE type = CelestialBody requiredValue = true uniquenessCheck = CONTRACT_ALL - targetBody5 = Prestige() == Significant ? @ScanSatOfficial:p2Bodies.Random() : @ScanSatOfficial:p3Bodies.Random() + targetBody5 = Prestige() == Significant ? @ScanSatOfficial:p2Bodies.SelectUnique() : @ScanSatOfficial:p3Bodies.SelectUnique() + title = Must have orbited the target body. } DATA @@ -61,6 +63,7 @@ CONTRACT_TYPE minCoverage = 0.0 maxCoverage = @/minScan5 scanType = Ore + title = Must have scanned less than @/minScan5% of the target body. } REQUIREMENT { diff --git a/SCANassets/SCANsat.version b/SCANassets/SCANsat.version index 45d390c75..52f376381 100644 --- a/SCANassets/SCANsat.version +++ b/SCANassets/SCANsat.version @@ -11,7 +11,7 @@ "MAJOR":1, "MINOR":1, "PATCH":6, - "BUILD":3 + "BUILD":4 }, "KSP_VERSION":{ "MAJOR":1, diff --git a/SCANmechjeb/Properties/AssemblyInfo.cs b/SCANmechjeb/Properties/AssemblyInfo.cs index bf479cd6a..48c203b49 100644 --- a/SCANmechjeb/Properties/AssemblyInfo.cs +++ b/SCANmechjeb/Properties/AssemblyInfo.cs @@ -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.6.0.3")] -[assembly: AssemblyFileVersion("1.6.0.3")] -[assembly: AssemblyInformationalVersion ("v16.3")] +[assembly: AssemblyVersion("1.6.0.4")] +[assembly: AssemblyFileVersion("1.6.0.4")] +[assembly: AssemblyInformationalVersion ("v16.4")] [assembly: KSPAssembly ("SCANmechjeb", 0, 4)] [assembly: KSPAssemblyDependency ("SCANsat", 1, 6)] diff --git a/SCANsat/CHANGELOG.txt b/SCANsat/CHANGELOG.txt index bc820c88a..3d7348a1f 100644 --- a/SCANsat/CHANGELOG.txt +++ b/SCANsat/CHANGELOG.txt @@ -1,3 +1,13 @@ +Version 16.4 - 2016-8-9 +------------------------ + +- Update contracts for Contract Configurator 1.15+ (severedsolo) +- Switch to using ModuleResource and RESOURCE nodes for all power consumption (NathanKell) +- Calculate the local min and max terrain for RPM maps +- Hidden map fill cheat option + - Add "cheatMapFill = True" to the SCANcolors.cfg file +- Fix potential Toolbar related errors (bssthu) + Version 16.3 - 2016-6-27 ------------------------ diff --git a/SCANsat/Properties/AssemblyInfo.cs b/SCANsat/Properties/AssemblyInfo.cs index f304e0d3c..66210f797 100644 --- a/SCANsat/Properties/AssemblyInfo.cs +++ b/SCANsat/Properties/AssemblyInfo.cs @@ -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.6.0.3")] -[assembly: AssemblyFileVersion ("1.6.0.3")] -[assembly: AssemblyInformationalVersion ("v16.3")] +[assembly: AssemblyVersion ("1.6.0.4")] +[assembly: AssemblyFileVersion ("1.6.0.4")] +[assembly: AssemblyInformationalVersion ("v16.4")] [assembly: KSPAssembly ("SCANsat", 1, 6)] diff --git a/SCANsat/SCAN_Color_Config.cs b/SCANsat/SCAN_Color_Config.cs index 5c13da6e4..7d7130568 100644 --- a/SCANsat/SCAN_Color_Config.cs +++ b/SCANsat/SCAN_Color_Config.cs @@ -58,6 +58,8 @@ public class SCAN_Color_Config : SCAN_ConfigNodeStorage [Persistent] private float windowScale = 1f; [Persistent] + private bool cheatMapFill = false; + [Persistent] private List SCANsat_Altimetry = new List(); [Persistent] private List SCANsat_Resources = new List(); @@ -150,6 +152,11 @@ public bool BiomeBorder get { return biomeBorder; } } + public bool CheatMapFill + { + get { return cheatMapFill; } + } + public float SlopeCutoff { get { return slopeCutoff; } diff --git a/SCANsat/SCAN_PartModules/SCANsat.cs b/SCANsat/SCAN_PartModules/SCANsat.cs index d46e7fd0c..a99a5fca5 100644 --- a/SCANsat/SCAN_PartModules/SCANsat.cs +++ b/SCANsat/SCAN_PartModules/SCANsat.cs @@ -30,6 +30,7 @@ public class SCANsat : PartModule, IScienceDataContainer private Animation anim = null; private List storedData = new List(); private ExperimentsResultDialog expDialog = null; + public List resourceInputs = new List(); /* SAT: KSP entry points */ public override void OnStart(StartState state) @@ -103,7 +104,7 @@ public override void OnStart(StartState state) if (scanning) animate(1, 1); powerIsProblem = false; - print("[SCANsat] sensorType: " + sensorType.ToString() + " fov: " + fov.ToString() + " min_alt: " + min_alt.ToString() + " max_alt: " + max_alt.ToString() + " best_alt: " + best_alt.ToString() + " power: " + power.ToString()); + print("[SCANsat] sensorType: " + sensorType.ToString() + " fov: " + fov.ToString() + " min_alt: " + min_alt.ToString() + " max_alt: " + max_alt.ToString() + " best_alt: " + best_alt.ToString()); } protected virtual void Update() @@ -162,17 +163,22 @@ protected virtual void FixedUpdate() { if (TimeWarp.CurrentRate < 15000) { - float p = power * TimeWarp.fixedDeltaTime; - float e = part.RequestResource("ElectricCharge", p); - if (e < p) - { - unregisterScanner(); - powerIsProblem = true; - powerTimer = 0; - } - else + int l = resourceInputs.Count; + + for (int i = 0; i < l; i++) { - powerIsProblem = false; + ModuleResource resource = resourceInputs[i]; + resource.currentRequest = resource.rate * TimeWarp.fixedDeltaTime; + resource.currentAmount = part.RequestResource(resource.id, resource.currentRequest); + if (resource.currentAmount < resource.currentRequest) + { + unregisterScanner(); + powerIsProblem = true; + powerTimer = 0; + break; + } + else + powerIsProblem = false; } } else if (powerIsProblem) @@ -196,6 +202,23 @@ public override void OnLoad(ConfigNode node) storedData.Add(data); } } + + if (node.HasNode("RESOURCE")) + resourceInputs = new List(); + else + return; + + ConfigNode[] resources = node.GetNodes("RESOURCE"); + + int l = resources.Length; + + for (int i = 0; i < l; i++) + { + ConfigNode resource = resources[i]; + ModuleResource mod = new ModuleResource(); + mod.Load(resource); + resourceInputs.Add(mod); + } } public override void OnSave(ConfigNode node) @@ -215,22 +238,15 @@ public override string GetInfo() string str = base.GetInfo(); if (min_alt != 0) - { str += "Altitude ( min): " + (min_alt / 1000).ToString("F0") + " km\n"; - } if (best_alt != min_alt) - { str += "Altitude (best): " + (best_alt / 1000).ToString("F0") + " km\n"; - } if (max_alt != 0) - { str += "Altitude ( max): " + (max_alt / 1000).ToString("F0") + " km\n"; - } if (fov != 0) - { str += "FOV: " + fov.ToString("F0") + " °\n"; - } - str += "Power usage: " + power.ToString("F1") + " charge/s\n"; + if (resourceInputs.Count > 0) + str += PartModuleUtil.PrintResourceRequirements("Requires:", resourceInputs.ToArray()); return str; } @@ -246,8 +262,6 @@ public override string GetInfo() [KSPField] public float best_alt; [KSPField] - public float power; - [KSPField] public string scanName; [KSPField] public string animationName; diff --git a/SCANsat/SCAN_Toolbar/SCANtoolbarwrapper.cs b/SCANsat/SCAN_Toolbar/SCANtoolbarwrapper.cs index 14c656ade..cde52a181 100644 --- a/SCANsat/SCAN_Toolbar/SCANtoolbarwrapper.cs +++ b/SCANsat/SCAN_Toolbar/SCANtoolbarwrapper.cs @@ -728,9 +728,21 @@ internal ToolbarTypes() { } internal static Type getType(string name) { - return AssemblyLoader.loadedAssemblies - .SelectMany(a => a.assembly.GetExportedTypes()) - .SingleOrDefault(t => t.FullName == name); + foreach (AssemblyLoader.LoadedAssembly assembly in AssemblyLoader.loadedAssemblies) + { + try + { + var type = assembly.assembly.GetExportedTypes().SingleOrDefault(t => t.FullName == name); + if (type != null) + { + return type; + } + } + catch (InvalidOperationException) + { + } + } + return null; } internal static PropertyInfo getProperty(Type type, string name) { diff --git a/SCANsat/SCAN_UI/SCANsatRPM.cs b/SCANsat/SCAN_UI/SCANsatRPM.cs index 385d52aa5..c387c7299 100644 --- a/SCANsat/SCAN_UI/SCANsatRPM.cs +++ b/SCANsat/SCAN_UI/SCANsatRPM.cs @@ -705,6 +705,7 @@ private void RedrawMap() map.Resource = loadedResources[currentResource]; map.Resource.CurrentBodyConfig(orbitingBody.name); } + calcTerrainLimits(orbitingBody); map.resetMap((mapType)mapMode, false, SCANconfigLoader.GlobalResource && resourceOverlay); // Compute and store the map scale factors in mapSizeScale. We @@ -728,6 +729,46 @@ private void RedrawMap() pixelsPerKm = pixelsPerDegree / kmPerDegreeLon; } + private void calcTerrainLimits(CelestialBody b) + { + if (map.MType == mapType.Slope) + return; + + int w = map.MapWidth / 4; + int h = map.MapHeight / 4; + + float max = -200000; + float min = 100000; + float terrain = 0; + + for (int i = 0; i < map.MapHeight; i += 4) + { + for (int j = 0; j < map.MapWidth; j += 4) + { + double lat = (i * 1.0f / map.MapScale) - 90f + map.Lat_Offset; + double lon = (j * 1.0f / map.MapScale) - 180f + map.Lon_Offset; + double la = lat, lo = lon; + lat = map.unprojectLatitude(lo, la); + lon = map.unprojectLongitude(lo, la); + + terrain = (float)SCANUtil.getElevation(b, lon, lat); + + if (terrain < min) + min = terrain; + if (terrain > max) + max = terrain; + } + } + + if (min > max) + min = max - 1f; + + if (min == max) + min = max - 1f; + + map.setCustomRange(min, max); + } + private bool UpdateCheck() { if (map == null) diff --git a/SCANsat/SCAN_UI/SCANsettingsUI.cs b/SCANsat/SCAN_UI/SCANsettingsUI.cs index 7707e9d7a..7874e900d 100644 --- a/SCANsat/SCAN_UI/SCANsettingsUI.cs +++ b/SCANsat/SCAN_UI/SCANsettingsUI.cs @@ -177,9 +177,8 @@ protected override void DrawWindow(int id) gui_settings_window_resets_tooltips(id);/* reset windows and positions and toggle tooltips*/ gui_settings_export_options(id); gui_settings_data_resets(id); /* reset data and/or reset resources */ - # if DEBUG + if (SCANconfigLoader.SCANNode.CheatMapFill) gui_settings_window_mapFill(id); /* debug option to fill in maps */ - #endif stopS(); warningBox(id); /* Warning box for deleting map data */