Beispiel #1
0
 protected override void Start()
 {
     Visible = SCANcontroller.controller.kscMapVisible;
     if (b == null)
     {
         b = Planetarium.fetch.Home;
     }
     if (bigmap == null)
     {
         bigmap = new SCANmap(b, true);
         bigmap.setProjection((MapProjection)SCANcontroller.controller.projection);
         bigmap.setWidth(720);
     }
     currentColor  = SCANcontroller.controller.colours == 0;
     lastColor     = currentColor;
     lastResource  = SCANcontroller.controller.map_ResourceOverlay;
     WindowCaption = string.Format("Map of {0}", b.theName);
     data          = SCANUtil.getData(b);
     if (data == null)
     {
         data = new SCANdata(b);
         SCANcontroller.controller.addToBodyData(b, data);
     }
     bigmap.setBody(b);
     if (SCANconfigLoader.GlobalResource)
     {
         loadedResources = SCANcontroller.setLoadedResourceList();
     }
     TooltipsEnabled = SCANcontroller.controller.toolTips;
 }
Beispiel #2
0
		private void Startup()
		{
			//Initialize the map object
			Visible = false;
			if (HighLogic.LoadedSceneIsFlight)
			{
				v = SCANcontroller.controller.BigMap.V;
				b = SCANcontroller.controller.BigMap.Body;
				data = SCANcontroller.controller.BigMap.Data;
			}
			else if (HighLogic.LoadedSceneHasPlanetarium)
			{
				v = null;
				b = SCANcontroller.controller.kscMap.Body;
				data = SCANcontroller.controller.kscMap.Data;
			}
			if (spotmap == null)
			{
				spotmap = new SCANmap();
				spotmap.setSize(320, 240);
			}

			showOrbit = SCANcontroller.controller.map_orbit;
			showAnomaly = SCANcontroller.controller.map_markers;

			if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
				showWaypoints = false;
			else
				showWaypoints = SCANcontroller.controller.map_waypoints;

			TooltipsEnabled = SCANcontroller.controller.toolTips;

			spotmap.setBody(b);
		}
Beispiel #3
0
		protected override void Start()
		{
			Visible = SCANcontroller.controller.kscMapVisible;
			if (b == null)
				b = Planetarium.fetch.Home;
			if (bigmap == null)
			{
				bigmap = new SCANmap(b, true);
				bigmap.setProjection((MapProjection)SCANcontroller.controller.projection);
				bigmap.setWidth(720);
			}
			currentColor = SCANcontroller.controller.colours == 0;
			lastColor = currentColor;
			lastResource = SCANcontroller.controller.map_ResourceOverlay;
			WindowCaption = string.Format("Map of {0}", b.theName);
			data = SCANUtil.getData(b);
			if (data == null)
			{
				data = new SCANdata(b);
				SCANcontroller.controller.addToBodyData(b, data);
			}
			bigmap.setBody(b);
			if (SCANconfigLoader.GlobalResource)
			{
				loadedResources = SCANcontroller.setLoadedResourceList();
			}
			TooltipsEnabled = SCANcontroller.controller.toolTips;
		}
Beispiel #4
0
        //Pulls data out of the Kethane database to update the SCANsat resource coverage map - intentionally slow
        private void rebuildResourceArray()
        {
            SCANdata data = SCANUtil.getData(body);

            if (!rebuildingArray)
            {
                print("[SCAN Kethane] Rebuilding SCANsat Kethane Array");
                rebuildingArray = true;
            }
            for (int ilon = 0; ilon < 360; ilon++)              //Run 360 points per frame; 3 seconds at 60FPS
            {
                cell = getKethaneCell(ilon - 180, rebuildStep - 90);
                if (KethaneData.Current[resource.name][body].IsCellScanned(cell))
                {
                    updateResourceArray(ilon, rebuildStep, resource.type, data);
                    double?depositValue = KethaneData.Current[resource.name][body].Resources.GetQuantity(cell);
                    if (depositValue != null)
                    {
                        updateResourceValue(ilon, rebuildStep, depositValue, data);
                    }
                    else
                    {
                        updateResourceValue(ilon, rebuildStep, -1d, data);                         //Give empty cells -1 resources, account for this later on
                    }
                }
            }
            rebuildStep++;
            if (rebuildStep >= 180)
            {
                SCANcontroller.controller.kethaneBusy = false;
                rebuildingArray = false;
                print("[SCAN Kethane] SCANsat Kethane Array Rebuilt");
            }
        }
 private void soiChange(GameEvents.HostedFromToAction <Vessel, CelestialBody> VC)
 {
     data = SCANUtil.getData(VC.to);
     if (data == null)
     {
         data = new SCANdata(VC.to);
         SCANcontroller.controller.addToBodyData(VC.to, data);
     }
     planetConstants(VC.to);
 }
Beispiel #6
0
		protected override void Start()
		{
			GameEvents.onVesselSOIChanged.Add(soiChange);
			data = SCANUtil.getData(FlightGlobals.currentMainBody);
			if (data == null)
			{
				data = new SCANdata(FlightGlobals.currentMainBody);
				SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
			}
			planetConstants(FlightGlobals.currentMainBody);
		}
 protected override void Start()
 {
     GameEvents.onVesselSOIChanged.Add(soiChange);
     data = SCANUtil.getData(FlightGlobals.currentMainBody);
     if (data == null)
     {
         data = new SCANdata(FlightGlobals.currentMainBody);
         SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
     }
     planetConstants(FlightGlobals.currentMainBody);
 }
Beispiel #8
0
 protected override void Start()
 {
     Visible = SCANcontroller.controller.mainMapVisible;
     v       = FlightGlobals.ActiveVessel;
     data    = SCANUtil.getData(v.mainBody);
     if (data == null)
     {
         data = new SCANdata(v.mainBody);
         SCANcontroller.controller.addToBodyData(v.mainBody, data);
     }
     TooltipsEnabled = SCANcontroller.controller.toolTips;
 }
Beispiel #9
0
 protected override void DrawWindowPre(int id)
 {
     //Keep the map updated with the current vessel location and status
     v    = FlightGlobals.ActiveVessel;
     data = SCANUtil.getData(v.mainBody);
     if (data == null)
     {
         data = new SCANdata(v.mainBody);
         SCANcontroller.controller.addToBodyData(v.mainBody, data);
     }
     sensors = SCANcontroller.controller.activeSensorsOnVessel(v.id);
     data.updateImages(sensors);
 }
Beispiel #10
0
        internal Texture2D getLegend(int scheme, SCANdata data)
        {
            Texture2D t = new Texture2D(256, 1, TextureFormat.RGB24, false);

            Color[] pix = t.GetPixels();
            for (int x = 0; x < 256; ++x)
            {
                float val = (x * (data.TerrainConfig.MaxTerrain - data.TerrainConfig.MinTerrain)) / 256f + data.TerrainConfig.MinTerrain;
                pix[x] = palette.heightToColor(val, scheme, data);
            }
            t.SetPixels(pix);
            t.Apply();
            return(t);
        }
Beispiel #11
0
        private void setResource(string s)           //Watcher to check for the user switching to different Kethane resources
        {
            if (s == resource.name)
            {
                return;
            }
            resource = SCANcontroller.ResourcesList[SCANcontroller.controller.gridSelection];
            reset    = SCANcontroller.controller.kethaneReset;
            SCANcontroller.controller.map_ResourceOverlay = false;             //Force the overlay off to allow array to rebuild
            SCANdata data = SCANUtil.getData(body);

            data.kethaneValueMap = new float[360, 180];
            rebuildStep          = 0;
            SCANcontroller.controller.kethaneBusy = true;
        }
Beispiel #12
0
 public static Color heightToColor(float val, int scheme, SCANdata data)
 {
     Color32[] c = data.TerrainConfig.ColorPal.colors;
     if (data.TerrainConfig.PalRev)
     {
         c = data.TerrainConfig.ColorPal.colorsReverse;
     }
     if (scheme == 0)
     {
         return(heightToColor(val, data.TerrainConfig.MaxTerrain, data.TerrainConfig.MinTerrain, data.TerrainConfig.ClampTerrain, data.TerrainConfig.PalDis, c));
     }
     else
     {
         return(heightToColor(val, data.TerrainConfig.MaxTerrain, data.TerrainConfig.MinTerrain, data.TerrainConfig.PalDis));
     }
 }
        public void setMapCenter(double lat, double lon, SCANmap big)
        {
            Visible = true;
            bigmap  = big;

            SCANcontroller.controller.TargetSelecting       = false;
            SCANcontroller.controller.TargetSelectingActive = false;

            if (bigmap.Projection == MapProjection.Polar)
            {
                spotmap.setProjection(MapProjection.Polar);
            }
            else
            {
                spotmap.setProjection(MapProjection.Rectangular);
            }

            if (bigmap.Body != b)
            {
                SCANdata dat = SCANUtil.getData(bigmap.Body);
                if (dat == null)
                {
                    dat = new SCANdata(bigmap.Body);
                }

                data = dat;
                b    = data.Body;

                spotmap.setBody(b);
            }

            if (SCANconfigLoader.GlobalResource && narrowBand)
            {
                spotmap.Resource = bigmap.Resource;
                spotmap.Resource.CurrentBodyConfig(b.name);
            }

            spotmap.MapScale = 10;

            spotmap.centerAround(lon, lat);
            if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay)
            {
                checkForScanners();
            }
            spotmap.resetMap(bigmap.MType, false, narrowBand);
        }
Beispiel #14
0
 private void setBody(CelestialBody b)           //Watcher to check for Celestial Body changes
 {
     if (body == b)
     {
         return;
     }
     if (b != null)
     {
         body     = b;
         resource = SCANcontroller.ResourcesList[SCANcontroller.controller.gridSelection];
         reset    = SCANcontroller.controller.kethaneReset;
         SCANcontroller.controller.map_ResourceOverlay = false;                 //Force the overlay off to allow array to rebuild
         SCANdata data = SCANUtil.getData(body);
         data.kethaneValueMap = new float[360, 180];
         rebuildStep          = 0;
         SCANcontroller.controller.kethaneBusy = true;
     }
 }
Beispiel #15
0
        /* Calculates the terrain elevation based on scanning coverage; fetches data from elevation cache if possible */
        private float terrainElevation(double Lon, double Lat, SCANdata Data, out int Scheme)
        {
            float elevation = 0f;

            Scheme = SCANcontroller.controller.colours;
            if (SCANUtil.isCovered(Lon, Lat, Data, SCANtype.AltimetryHiRes))
            {
                if (cache)
                {
                    double lon = fixUnscale(unScaleLongitude(Lon), mapwidth);
                    double lat = fixUnscale(unScaleLatitude(Lat), mapheight);
                    elevation = big_heightmap[Mathf.RoundToInt((float)lon), Mathf.RoundToInt((float)lat)];
                    if (elevation == 0f)
                    {
                        elevation = (float)SCANUtil.getElevation(body, Lon, Lat);
                    }
                }
                else
                {
                    elevation = (float)SCANUtil.getElevation(body, Lon, Lat);
                }
            }
            else
            {
                if (cache)
                {
                    double lon = fixUnscale(unScaleLongitude(Lon), mapwidth);
                    double lat = fixUnscale(unScaleLatitude(Lat), mapheight);
                    elevation = big_heightmap[((int)(lon * 5)) / 5, ((int)(lat * 5)) / 5];
                    if (elevation == 0f)
                    {
                        elevation = (float)SCANUtil.getElevation(body, ((int)(Lon * 5)) / 5, ((int)(Lat * 5)) / 5);
                    }
                }
                else
                {
                    elevation = (float)SCANUtil.getElevation(body, ((int)(Lon * 5)) / 5, ((int)(Lat * 5)) / 5);
                }
                Scheme = 1;
            }

            return(elevation);
        }
Beispiel #16
0
 internal Texture2D getLegend(float min, float max, int scheme, SCANdata data)
 {
     if (legend != null && legendMin == min && legendMax == max && legendScheme == scheme && data.TerrainConfig.ColorPal.hash == dataPalette.hash)
     {
         return(legend);
     }
     legend       = new Texture2D(256, 1, TextureFormat.RGB24, false);
     legendMin    = min;
     legendMax    = max;
     legendScheme = scheme;
     dataPalette  = data.TerrainConfig.ColorPal;
     Color[] pix = legend.GetPixels();
     for (int x = 0; x < 256; ++x)
     {
         float val = (x * (max - min)) / 256f + min;
         pix[x] = palette.heightToColor(val, scheme, data);
     }
     legend.SetPixels(pix);
     legend.Apply();
     return(legend);
 }
Beispiel #17
0
        private void RedrawMap()
        {
            map = new SCANmap();
            map.setProjection(MapProjection.Rectangular);
            orbitingBody = vessel.mainBody;
            map.setBody(vessel.mainBody);
            map.setSize(screenWidth, screenHeight);
            map.MapScale *= (zoomLevel * zoomLevel + zoomModifier);
            mapCenterLong = vessel.longitude;
            mapCenterLat  = vessel.latitude;
            // That's really just sweeping the problem under the carpet instead of fixing it, but meh.
            if (zoomLevel == 0)
            {
                mapCenterLat = 0;
            }
            map.centerAround(mapCenterLong, mapCenterLat);
            map.resetMap((mapType)mapMode, false);

            // Compute and store the map scale factors in mapSizeScale.  We
            // use these values for every segment when drawing trails, so it
            // makes sense to compute it only when it changes.
            mapSizeScale    = new Vector2d(360.0 * map.MapScale / map.MapWidth, 180.0 * map.MapScale / map.MapHeight);
            redrawDeviation = redrawEdge * 180 / (zoomLevel * zoomLevel + zoomModifier);
            try {
                SCANdata data = SCANUtil.getData(vessel.mainBody);
                if (data != null)
                {
                    localAnomalies = data.Anomalies;
                    localWaypoints = data.Waypoints;
                }
            } catch {
                Debug.Log("JSISCANsatRPM: Could not get a list of anomalies, what happened?");
            }
            // MATH!
            double kmPerDegreeLon  = (2 * Math.PI * (orbitingBody.Radius / 1000d)) / 360d;
            double pixelsPerDegree = Math.Abs(longitudeToPixels(mapCenterLong + (((mapCenterLong + 1) > 360) ? -1 : 1), mapCenterLat) - longitudeToPixels(mapCenterLong, mapCenterLat));

            pixelsPerKm = pixelsPerDegree / kmPerDegreeLon;
        }
        private void Startup()
        {
            //Initialize the map object
            Visible = false;
            if (HighLogic.LoadedSceneIsFlight)
            {
                v    = SCANcontroller.controller.BigMap.V;
                b    = SCANcontroller.controller.BigMap.Body;
                data = SCANcontroller.controller.BigMap.Data;
            }
            else if (HighLogic.LoadedSceneHasPlanetarium)
            {
                v    = null;
                b    = SCANcontroller.controller.kscMap.Body;
                data = SCANcontroller.controller.kscMap.Data;
            }
            if (spotmap == null)
            {
                spotmap = new SCANmap();
                spotmap.setSize(320, 240);
            }

            showOrbit   = SCANcontroller.controller.map_orbit;
            showAnomaly = SCANcontroller.controller.map_markers;

            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                showWaypoints = false;
            }
            else
            {
                showWaypoints = SCANcontroller.controller.map_waypoints;
            }

            TooltipsEnabled = SCANcontroller.controller.toolTips;

            spotmap.setBody(b);
        }
Beispiel #19
0
        //Reset the resource value array - quicker than rebuildKethaneData (), called on map resets
        private void rebuildResourceValue(SCANdata.SCANtype type)
        {
            if (!rebuildingValue)
            {
                print("[SCAN Kethane] Rebuilding Value Array");
                rebuildingValue = true;
            }
            SCANdata data = SCANUtil.getData(body);

            for (int ilat = 4 * rebuildValueStep; ilat < 4 * (rebuildValueStep + 1); ilat++)
            {
                for (int ilon = 0; ilon < 360; ilon++)
                {
                    if (SCANUtil.isCovered(ilon, ilat, body, (int)type))
                    {
                        if (data.kethaneValueMap[ilon, ilat] == 0)                           //Only check unassigned values
                        {
                            cell = getKethaneCell(ilon - 180, ilat - 90);
                            double?depositValue = KethaneData.Current[resource.name][body].Resources.GetQuantity(cell);
                            if (depositValue != null)
                            {
                                updateResourceValue(ilon, ilat, depositValue, data);
                            }
                            else
                            {
                                updateResourceValue(ilon, ilat, -1d, data);                                  //Give empty cells -1 resources, account for this later on
                            }
                        }
                    }
                }
            }
            rebuildValueStep++;
            if (rebuildValueStep >= 45)
            {
                print("[SCAN Kethane] Value Array Rebuilt");
                rebuildingValue = false;
            }
        }
Beispiel #20
0
 protected override void Start()
 {
     //Initialize the map object
     Visible = SCANcontroller.controller.bigMapVisible;
     if (v == null)
     {
         v = FlightGlobals.ActiveVessel;
     }
     if (b == null)
     {
         b = v.mainBody;
     }
     if (bigmap == null)
     {
         bigmap = new SCANmap(b, true);
         bigmap.setProjection((MapProjection)SCANcontroller.controller.projection);
         bigmap.setWidth(SCANcontroller.controller.map_width);
     }
     WindowRect.x  = SCANcontroller.controller.map_x;
     WindowRect.y  = SCANcontroller.controller.map_y;
     currentColor  = SCANcontroller.controller.colours == 0;
     lastColor     = currentColor;
     lastResource  = SCANcontroller.controller.map_ResourceOverlay;
     WindowCaption = string.Format("Map of {0}", b.theName);
     data          = SCANUtil.getData(b);
     if (data == null)
     {
         data = new SCANdata(b);
         SCANcontroller.controller.addToBodyData(b, data);
     }
     bigmap.setBody(b);
     if (SCANconfigLoader.GlobalResource)
     {
         loadedResources = SCANcontroller.setLoadedResourceList();
     }
     TooltipsEnabled = SCANcontroller.controller.toolTips;
 }
Beispiel #21
0
		private void Update()
		{
			if (scan_background && loaded)
			{
				scanFromAllVessels();
			}

			if (unDocked || docked)
			{
				if (timer < 30)
					timer++;
				else
				{
					if (unDocked)
					{
						if (NewVessel != null)
						{
							removeVessel(NewVessel);
							addVessel(NewVessel);
							NewVessel = null;
						}

						if (OldVessel != null)
						{
							removeVessel(OldVessel);
							addVessel(OldVessel);
							OldVessel = null;
						}
					}

					if (docked)
					{
						if (PartFromVessel != null)
						{
							removeVessel(PartFromVessel);
							PartFromVessel = null;
						}

						if (PartToVessel != null)
						{
							removeVessel(PartToVessel);
							PartToVessel = null;
						}

						addVessel(FlightGlobals.ActiveVessel);
					}

					unDocked = false;
					docked = false;
					timer = 0;
				}
			}

			if (!HighLogic.LoadedSceneIsFlight && HighLogic.LoadedScene != GameScenes.TRACKSTATION)
				return;

			if (!easyModeScanning)
				return;

			if (body == null)
			{
				if (HighLogic.LoadedSceneIsFlight)
				{
					body = FlightGlobals.ActiveVessel.mainBody;
					bodyScanned = false;
					bodyCoverage = false;
				}
				else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
				{
					MapObject target = PlanetariumCamera.fetch.target;

					if (target.type != MapObject.MapObjectType.CELESTIALBODY)
					{
						body = null;
						return;
					}

					body = target.celestialBody;
					bodyScanned = false;
					bodyCoverage = false;
				}
			}

			if (bodyScanned)
				return;

			if (!bodyCoverage)
			{
				if (SCANUtil.GetCoverage((int)SCANtype.AllResources, body) >= 100)
				{
					bodyScanned = true;
					return;
				}
				bodyCoverage = true;
			}

			if (ResourceMap.Instance.IsPlanetScanned(body.flightGlobalsIndex))
			{
				SCANdata data = SCANUtil.getData(body);
				if (data == null)
				{
					data = new SCANdata(body);
					addToBodyData(body, data);
				}
				data.fillResourceMap();
				bodyScanned = true;
			}
		}
Beispiel #22
0
        protected override void Start()
        {
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                kscMapObj = (SCANkscMap)SCANcontroller.controller.kscMap;
                if (SCANkscMap.BigMap != null)
                {
                    bigMap = SCANkscMap.BigMap;
                }
                if (kscMapObj.Data != null)
                {
                    data = kscMapObj.Data;
                }
            }
            else if (HighLogic.LoadedSceneIsFlight)
            {
                bigMapObj = (SCANBigMap)SCANcontroller.controller.BigMap;
                if (SCANBigMap.BigMap != null)
                {
                    bigMap = SCANBigMap.BigMap;
                }
                if (bigMapObj.Data != null)
                {
                    data = bigMapObj.Data;
                }
            }

            if (data == null)
            {
                data = SCANUtil.getData(Planetarium.fetch.Home);
                if (data == null)
                {
                    data = new SCANdata(Planetarium.fetch.Home);
                    SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                }
            }

            currentTerrain = new SCANterrainConfig(data.TerrainConfig);

            stockBiomes = SCANcontroller.controller.useStockBiomes;

            minTerrainSlider   = new SCANuiSlider(data.TerrainConfig.DefaultMinHeight - SCANconfigLoader.SCANNode.RangeBelowMinHeight, data.TerrainConfig.MaxTerrain - 100, data.TerrainConfig.MinTerrain, "Min: ", "m", -2);
            maxTerrainSlider   = new SCANuiSlider(data.TerrainConfig.MinTerrain + 100, data.TerrainConfig.DefaultMaxHeight + SCANconfigLoader.SCANNode.RangeAboveMaxHeight, data.TerrainConfig.MaxTerrain, "Max: ", "m", -2);
            clampTerrainSlider = new SCANuiSlider(data.TerrainConfig.MinTerrain + 10, data.TerrainConfig.MaxTerrain - 10, data.TerrainConfig.ClampTerrain ?? data.TerrainConfig.MinTerrain + 10, "Clamp: ", "m", -1);
            paletteSizeSlider  = new SCANuiSlider(3, 12, data.TerrainConfig.PalSize, "Palette Size: ", "", 0);

            slopeColorPickerLow  = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorOne, SCANcontroller.controller.highSlopeColorOne, true);
            slopeColorPickerHigh = new SCANuiColorPicker(SCANcontroller.controller.lowSlopeColorTwo, SCANcontroller.controller.highSlopeColorTwo, true);

            slopeColorPickerLow.updateOldSwatches();
            slopeColorPickerHigh.updateOldSwatches();

            bTrans           = SCANcontroller.controller.biomeTransparency;
            biomeTransSlider = new SCANuiSlider(0, 80, bTrans, "Ter. Trans: ", "%", 0);

            biomeColorPicker = new SCANuiColorPicker(SCANcontroller.controller.lowBiomeColor, SCANcontroller.controller.highBiomeColor, true);

            biomeColorPicker.updateOldSwatches();

            if (SCANconfigLoader.GlobalResource)
            {
                loadedResources = SCANcontroller.setLoadedResourceList();
                currentResource = new SCANresourceGlobal(loadedResources[0]);
                currentResource.CurrentBodyConfig(data.Body.name);

                if (currentResource != null)
                {
                    resourceMinSlider   = new SCANuiSlider(0, currentResource.CurrentBody.MinValue - 0.1f, currentResource.CurrentBody.MinValue, "Min: ", "%", 1);
                    resourceMaxSlider   = new SCANuiSlider(currentResource.CurrentBody.MinValue + 0.1f, 100, currentResource.CurrentBody.MaxValue, "Max: ", "%", 1);
                    resourceTransSlider = new SCANuiSlider(0, 80, currentResource.Transparency, "Trans: ", "%", 0);

                    resourceColorPicker = new SCANuiColorPicker(currentResource.MinColor, currentResource.MaxColor, true);
                }
            }

            bodyIndex = data.Body.flightGlobalsIndex;

            if (windowMode > 3 || (windowMode > 2 && !SCANconfigLoader.GlobalResource))
            {
                windowMode = 0;
            }

            setSizeSlider(currentTerrain.ColorPal.kind);
        }
Beispiel #23
0
        /* MAP: build: map to Texture2D */
        internal Texture2D getPartialMap()
        {
            SCANdata data = SCANUtil.getData(body);

            if (data == null)
            {
                return(new Texture2D(1, 1));
            }
            Color[] pix;

            /* init cache if necessary */
            if (cache)
            {
                if (body != big_heightmap_body)
                {
                    for (int x = 0; x < mapwidth; x++)
                    {
                        for (int y = 0; y < mapwidth / 2; y++)
                        {
                            big_heightmap[x, y] = 0f;
                        }
                    }
                    big_heightmap_body = body;
                }
            }

            if (map == null)
            {
                map = new Texture2D(mapwidth, mapheight, TextureFormat.ARGB32, false);
                pix = map.GetPixels();
                for (int i = 0; i < pix.Length; ++i)
                {
                    pix[i] = palette.clear;
                }
                map.SetPixels(pix);
            }
            else if (mapstep >= map.height)
            {
                return(map);
            }

            if (palette.redline == null || palette.redline.Length != map.width)
            {
                palette.redline = new Color[map.width];
                for (int i = 0; i < palette.redline.Length; ++i)
                {
                    palette.redline[i] = palette.red;
                }
            }

            if (mapstep < map.height - 1)
            {
                map.SetPixels(0, mapstep + 1, map.width, 1, palette.redline);
            }

            if (mapstep <= 0)
            {
                mapstep = 0;
                mapline = new double[map.width];
            }

            pix = map.GetPixels(0, mapstep, map.width, 1);

            for (int i = 0; i < map.width; i++)
            {
                Color baseColor = palette.grey;
                pix[i] = baseColor;
                int    scheme = SCANcontroller.controller.colours;
                float  projVal = 0f;
                double lat = (mapstep * 1.0f / mapscale) - 90f + lat_offset;
                double lon = (i * 1.0f / mapscale) - 180f + lon_offset;
                double la = lat, lo = lon;
                lat = unprojectLatitude(lo, la);
                lon = unprojectLongitude(lo, la);

                /* Introduce altimetry check here; Use unprojected lat/long coordinates
                 * All cached altimetry data stored in a single 2D array in rectangular format
                 * Pull altimetry data from cache after unprojection
                 */

                if (body.pqsController != null && cache)
                {
                    if (big_heightmap[i, mapstep] == 0f)
                    {
                        if (SCANUtil.isCovered(lo, la, data, SCANtype.Altimetry))
                        {
                            terrainHeightToArray(lo, la, i, mapstep);
                        }
                    }
                }

                if (double.IsNaN(lat) || double.IsNaN(lon) || lat < -90 || lat > 90 || lon < -180 || lon > 180)
                {
                    pix[i] = palette.clear;
                    continue;
                }

                /* Altimetry Map */
                if (mType == mapType.Altimetry)
                {
                    if (body.pqsController == null)
                    {
                        baseColor = palette.lerp(palette.black, palette.white, UnityEngine.Random.value);
                    }
                    else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Altimetry))
                    {
                        projVal   = terrainElevation(lon, lat, data, out scheme);
                        baseColor = palette.heightToColor(projVal, scheme, data);
                    }
                    mapline[i] = projVal;

                    if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null)
                    {
                        pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource);
                    }
                    else
                    {
                        pix[i] = baseColor;
                    }

                    /* draw height lines - works, but mostly useless...
                     * int step = (int)(val / 1000);
                     * int step_h = step, step_v = step;
                     * if(i > 0) step_h = (int)(bigline[i - 1] / 1000);
                     * if(bigstep > 0) step_v = (int)(bigline[i] / 1000);
                     * if(step != step_h || step != step_v) {
                     * pix[i] = palette.white;
                     * }
                     */
                    //mapline [i] = val;
                }

                /* Slope Map */
                else if (mType == mapType.Slope)
                {
                    if (body.pqsController == null)
                    {
                        baseColor = palette.lerp(palette.black, palette.white, UnityEngine.Random.value);
                    }
                    else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Altimetry))
                    {
                        projVal = terrainElevation(lon, lat, data, out scheme);
                        if (mapstep == 0)
                        {
                            baseColor = palette.grey;
                        }
                        else
                        {
                            // This doesn't actually calculate the slope per se, but it's faster
                            // than asking for yet more elevation data. Please don't use this
                            // code to operate nuclear power plants or rockets.
                            double v1 = mapline[i];
                            if (i > 0)
                            {
                                v1 = Math.Max(v1, mapline[i - 1]);
                            }
                            if (i < mapline.Length - 1)
                            {
                                v1 = Math.Max(v1, mapline[i + 1]);
                            }
                            float v = Mathf.Clamp((float)Math.Abs(projVal - v1) / 1000f, 0, 2f);
                            if (SCANcontroller.controller.colours == 1)
                            {
                                baseColor = palette.lerp(palette.black, palette.white, v / 2f);
                            }
                            else
                            {
                                if (v < 1)
                                {
                                    baseColor = palette.lerp(SCANcontroller.controller.lowSlopeColorOne, SCANcontroller.controller.highSlopeColorOne, v);
                                }
                                else
                                {
                                    baseColor = palette.lerp(SCANcontroller.controller.lowSlopeColorTwo, SCANcontroller.controller.highSlopeColorTwo, v - 1);
                                }
                            }
                        }
                        mapline[i] = projVal;
                    }
                    if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null)
                    {
                        pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource);
                    }
                    else
                    {
                        pix[i] = baseColor;
                    }
                }

                /* Biome Map */
                else if (mType == mapType.Biome)
                {
                    if (body.BiomeMap == null)
                    {
                        baseColor = palette.lerp(palette.black, palette.white, UnityEngine.Random.value);
                    }

                    /* // this just basically stretches the actual biome map to fit... it looks horrible
                     * float u = ((lon + 360 + 180 + 90)) % 360;
                     * float v = ((lat + 180 + 90)) % 180;
                     * if(u < 0 || v < 0 || u >= 360 || v >= 180) continue;
                     * u /= 360f; v /= 180f;
                     * pix[i] = body.BiomeMap.Map.GetPixelBilinear(u, v);
                     */
                    else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Biome))
                    {
                        double bio   = SCANUtil.getBiomeIndexFraction(body, lon, lat);
                        Color  biome = palette.grey;
                        if (SCANcontroller.controller.colours == 1)
                        {
                            if ((i > 0 && mapline[i - 1] != bio) || (mapstep > 0 && mapline[i] != bio))
                            {
                                biome = palette.white;
                            }
                            else
                            {
                                biome = palette.lerp(palette.black, palette.white, (float)bio);
                            }
                        }
                        else
                        {
                            Color elevation = palette.grey;
                            if (SCANcontroller.controller.biomeTransparency > 0)
                            {
                                if (body.pqsController == null)
                                {
                                    elevation = palette.grey;
                                }
                                else if (SCANUtil.isCovered(lon, lat, data, SCANtype.Altimetry))
                                {
                                    projVal   = terrainElevation(lon, lat, data, out scheme);
                                    elevation = palette.lerp(palette.black, palette.white, Mathf.Clamp(projVal + 1500f, 0, 9000) / 9000f);
                                }
                            }

                            if ((i > 0 && mapline[i - 1] != bio) || (mapstep > 0 && mapline[i] != bio))
                            {
                                biome = palette.white;
                            }
                            else if (SCANcontroller.controller.useStockBiomes)
                            {
                                Color c = SCANUtil.getBiome(body, lon, lat).mapColor;
                                biome = palette.lerp(c, elevation, SCANcontroller.controller.biomeTransparency / 100f);
                            }
                            else
                            {
                                biome = palette.lerp(palette.lerp(SCANcontroller.controller.lowBiomeColor, SCANcontroller.controller.highBiomeColor, (float)bio), elevation, SCANcontroller.controller.biomeTransparency / 100f);
                            }
                        }

                        baseColor  = biome;
                        mapline[i] = bio;
                    }
                    if (SCANcontroller.controller.map_ResourceOverlay && SCANconfigLoader.GlobalResource && resource != null)
                    {
                        pix[i] = SCANuiUtil.resourceToColor(lon, lat, data, baseColor, resource);
                    }
                    else
                    {
                        pix[i] = baseColor;
                    }
                }
            }
            map.SetPixels(0, mapstep, map.width, 1, pix);
            mapstep++;
            if (mapstep % 10 == 0 || mapstep >= map.height)
            {
                map.Apply();
            }
            return(map);
        }
Beispiel #24
0
        protected override void DrawWindowPre(int id)
        {
            //Some clumsy logic is used here to ensure that the color selection fields always remain in sync with the current map in each scene
            if (HighLogic.LoadedSceneIsFlight)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(FlightGlobals.currentMainBody);
                    if (data == null)
                    {
                        data = new SCANdata(FlightGlobals.currentMainBody);
                        SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
                    }
                }

                if (bigMapObj.Visible && SCANBigMap.BigMap != null)
                {
                    data   = bigMapObj.Data;
                    bigMap = SCANBigMap.BigMap;
                }
                else if (data.Body != FlightGlobals.currentMainBody)
                {
                    data = SCANUtil.getData(FlightGlobals.currentMainBody);
                    if (data == null)
                    {
                        data = new SCANdata(FlightGlobals.currentMainBody);
                        SCANcontroller.controller.addToBodyData(FlightGlobals.currentMainBody, data);
                    }
                }

                if (bigMap == null)
                {
                    if (SCANBigMap.BigMap != null)
                    {
                        bigMap = SCANBigMap.BigMap;
                    }
                }
            }

            //Lock space center click through - Sync SCANdata
            else if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (kscMapObj.Visible)
                {
                    data   = kscMapObj.Data;
                    bigMap = SCANkscMap.BigMap;
                }
                else if (data.Body != Planetarium.fetch.Home)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (bigMap == null)
                {
                    if (SCANkscMap.BigMap != null)
                    {
                        bigMap = SCANkscMap.BigMap;
                    }
                }
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.CAMERACONTROLS | ControlTypes.KSC_ALL, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //Lock tracking scene click through - Sync SCANdata
            else if (HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                if (data == null)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (kscMapObj.Visible)
                {
                    data   = kscMapObj.Data;
                    bigMap = SCANkscMap.BigMap;
                }
                else if (data.Body != Planetarium.fetch.Home)
                {
                    data = SCANUtil.getData(Planetarium.fetch.Home);
                    if (data == null)
                    {
                        data = new SCANdata(Planetarium.fetch.Home);
                        SCANcontroller.controller.addToBodyData(Planetarium.fetch.Home, data);
                    }
                }
                if (bigMap == null)
                {
                    if (SCANkscMap.BigMap != null)
                    {
                        bigMap = SCANkscMap.BigMap;
                    }
                }
                Vector2 mousePos = Input.mousePosition;
                mousePos.y = Screen.height - mousePos.y;
                if (WindowRect.Contains(mousePos) && !controlLock)
                {
                    InputLockManager.SetControlLock(ControlTypes.TRACKINGSTATION_UI, lockID);
                    controlLock = true;
                }
                else if (!WindowRect.Contains(mousePos) && controlLock)
                {
                    removeControlLocks();
                }
            }

            //This updates all of the fields whenever the palette selection is changed
            if (windowMode == 0 && (currentLegend == null || bodyIndex != data.Body.flightGlobalsIndex))
            {
                currentTerrain = new SCANterrainConfig(data.TerrainConfig);

                SCANUtil.SCANdebugLog("Trigger Body Change");
                bodyIndex = data.Body.flightGlobalsIndex;

                currentTerrain = new SCANterrainConfig(data.TerrainConfig);

                updateUI();
            }

            if (windowMode == 0 && previewLegend == null)
            {
                drawPreviewLegend();
            }

            if (!dropDown)
            {
                paletteBox  = false;
                resourceBox = false;
                saveWarning = false;
            }
        }
Beispiel #25
0
        //Draw the drop down menus if any have been opened
        private void dropDown(int id)
        {
            if (projection_drop_down)
            {
                ddRect = new Rect(110, 45, 100, 70);
                GUI.Box(ddRect, "");
                for (int i = 0; i < SCANmapProjection.projectionNames.Length; ++i)
                {
                    Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20);
                    if (GUI.Button(r, SCANmapProjection.projectionNames[i], SCANskins.SCAN_dropDownButton))
                    {
                        bigmap.setProjection((MapProjection)i);
                        bigmap.resetMap();
                        SCANcontroller.controller.projection = i;
                        drawGrid       = true;
                        drop_down_open = false;
                    }
                }
            }

            else if (mapType_drop_down)
            {
                ddRect = new Rect(270, 45, 70, 70);
                GUI.Box(ddRect, "");
                for (int i = 0; i < SCANmapType.mapTypeNames.Length; i++)
                {
                    Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20);
                    if (GUI.Button(r, SCANmapType.mapTypeNames[i], SCANskins.SCAN_dropDownButton))
                    {
                        bigmap.resetMap((mapType)i, true);
                        drop_down_open = false;
                    }
                }
            }

            else if (resources_drop_down)
            {
                ddRect = new Rect(WindowRect.width - 290, 45, 120, 160);
                GUI.Box(ddRect, "");
                for (int i = 0; i < loadedResources.Count; i++)
                {
                    scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * loadedResources.Count));
                    Rect r = new Rect(2, 20 * i, 96, 20);
                    if (GUI.Button(r, loadedResources[i].Name, SCANskins.SCAN_dropDownButton))
                    {
                        bigmap.Resource = loadedResources[i];
                        bigmap.Resource.CurrentBodyConfig(bigmap.Body.name);

                        SCANcontroller.controller.resourceSelection = bigmap.Resource.Name;

                        if (SCANcontroller.controller.map_ResourceOverlay)
                        {
                            bigmap.resetMap();
                        }

                        drop_down_open = false;
                    }
                    GUI.EndScrollView();
                }
            }

            else if (planetoid_drop_down)
            {
                int j = 0;
                ddRect = new Rect(WindowRect.width - 130, 45, 100, 160);
                GUI.Box(ddRect, "");
                for (int i = 0; i < SCANcontroller.controller.GetDataCount; i++)
                {
                    scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.controller.GetDataCount) + 1));

                    SCANdata dropDownData = SCANcontroller.controller.getData(i);
                    if (dropDownData != null)
                    {
                        Rect r = new Rect(2, 20 * j, 76, 20);
                        if (GUI.Button(r, dropDownData.Body.name, SCANskins.SCAN_dropDownButton))
                        {
                            data = dropDownData;
                            b    = data.Body;
                            bigmap.setBody(data.Body);
                            bigmap.resetMap();
                            drop_down_open = false;
                        }
                        j++;
                    }
                    GUI.EndScrollView();
                }
            }

            else
            {
                drop_down_open = false;
            }
        }
Beispiel #26
0
		private void soiChange (GameEvents.HostedFromToAction<Vessel, CelestialBody> VC)
		{
			data = SCANUtil.getData(VC.to);
			if (data == null)
			{
				data = new SCANdata(VC.to);
				SCANcontroller.controller.addToBodyData(VC.to, data);
			}
			planetConstants(VC.to);
		}
Beispiel #27
0
		internal static bool isCovered(double lon, double lat, SCANdata data, SCANtype type)
		{
			int ilon = icLON(lon);
			int ilat = icLAT(lat);
			if (badLonLat(ilon, ilat)) return false;
			return (data.Coverage[ilon, ilat] & (Int32)type) != 0;
		}
Beispiel #28
0
        protected override void LateUpdate()
        {
            if (shutdown)
            {
                return;
            }

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

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

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

            v = FlightGlobals.ActiveVessel;

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

            if (v.mainBody != SCANcontroller.controller.LandingTargetBody)
            {
                SCANcontroller.controller.LandingTargetBody = 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.LandingTarget != null)
            {
                way = SCANcontroller.controller.LandingTarget;
            }

            if (SCANcontroller.controller.TargetSelecting)
            {
                way             = null;
                selectingTarget = true;
                if (SCANcontroller.controller.TargetSelectingActive)
                {
                    selectingInMap = true;
                }
                else
                {
                    selectingInMap = false;
                }
                coords = SCANcontroller.controller.LandingTargetCoords;
                return;
            }
            else if (selectingTarget)
            {
                selectingTarget = false;
                if (selectingInMap)
                {
                    selectingInMap = false;
                    coords         = SCANcontroller.controller.LandingTargetCoords;
                    way            = new SCANwaypoint(coords.y, coords.x, siteName);
                    target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, 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.LandingTarget = way;
                    data.addToWaypoints();
                }
            }
            else
            {
                way = new SCANwaypoint(coords.y, coords.x, siteName);
                SCANcontroller.controller.LandingTarget = way;
                data.addToWaypoints();
            }
        }
Beispiel #29
0
		//Draw the drop down menus if any have been opened
		private void dropDown(int id)
		{
			if (projection_drop_down)
			{
				ddRect = new Rect(110, 45, 100, 70);
				GUI.Box(ddRect, "");
				for (int i = 0; i < SCANmapProjection.projectionNames.Length; ++i)
				{
					Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20);
					if (GUI.Button(r, SCANmapProjection.projectionNames[i], SCANskins.SCAN_dropDownButton))
					{
						bigmap.setProjection((MapProjection)i);
						bigmap.resetMap();
						SCANcontroller.controller.projection = i;
						drawGrid = true;
						drop_down_open = false;
					}
				}
			}

			else if (mapType_drop_down)
			{
				ddRect = new Rect(270, 45, 70, 70);
				GUI.Box(ddRect, "");
				for (int i = 0; i < SCANmapType.mapTypeNames.Length; i++)
				{
					Rect r = new Rect(ddRect.x + 2, ddRect.y + (24 * i), ddRect.width - 4, 20);
					if (GUI.Button(r, SCANmapType.mapTypeNames[i], SCANskins.SCAN_dropDownButton))
					{
						bigmap.resetMap((mapType)i, true);
						drop_down_open = false;
					}
				}
			}

			else if (resources_drop_down)
			{
				ddRect = new Rect(WindowRect.width - 290, 45, 120, 160);
				GUI.Box(ddRect, "");
				for (int i = 0; i < loadedResources.Count; i++)
				{
					scrollR = GUI.BeginScrollView(ddRect, scrollR, new Rect(0, 0, 100, 20 * loadedResources.Count));
					Rect r = new Rect(2, 20 * i, 96, 20);
					if (GUI.Button(r, loadedResources[i].Name, SCANskins.SCAN_dropDownButton))
					{
						bigmap.Resource = loadedResources[i];
						bigmap.Resource.CurrentBodyConfig(bigmap.Body.name);

						SCANcontroller.controller.resourceSelection = bigmap.Resource.Name;

						if (SCANcontroller.controller.map_ResourceOverlay)
						{
							bigmap.resetMap();
						}

						drop_down_open = false;
					}
					GUI.EndScrollView();
				}
			}

			else if (planetoid_drop_down)
			{
				int j = 0;
				ddRect = new Rect(WindowRect.width - 130, 45, 100, 160);
				GUI.Box(ddRect, "");
				for (int i = 0; i < SCANcontroller.controller.GetDataCount; i++)
				{
					scrollP = GUI.BeginScrollView(ddRect, scrollP, new Rect(0, 0, 80, (20 * SCANcontroller.controller.GetDataCount) + 1));

					SCANdata dropDownData = SCANcontroller.controller.getData(i);
					if (dropDownData != null)
					{
						Rect r = new Rect(2, 20 * j, 76, 20);
						if (GUI.Button(r, dropDownData.Body.name, SCANskins.SCAN_dropDownButton))
						{
							data = dropDownData;
							b = data.Body;
							bigmap.setBody(data.Body);
							bigmap.resetMap();
							drop_down_open = false;
						}
						j++;
					}
					GUI.EndScrollView();
				}
			}
			else
				drop_down_open = false;
		}
Beispiel #30
0
		internal static bool isCoveredByAll (int lon, int lat, SCANdata data, SCANtype type)
		{
			if (badLonLat(lon,lat)) return false;
			return (data.Coverage[lon, lat] & (Int32)type) == (Int32)type;
		}
Beispiel #31
0
		public void setMapCenter(double lat, double lon, SCANmap big)
		{
			Visible = true;
			bigmap = big;

			SCANcontroller.controller.TargetSelecting = false;
			SCANcontroller.controller.TargetSelectingActive = false;

			if (bigmap.Projection == MapProjection.Polar)
				spotmap.setProjection(MapProjection.Polar);
			else
				spotmap.setProjection(MapProjection.Rectangular);

			if (bigmap.Body != b)
			{
				SCANdata dat = SCANUtil.getData(bigmap.Body);
				if (dat == null)
					dat = new SCANdata(bigmap.Body);

				data = dat;
				b = data.Body;

				spotmap.setBody(b);
			}

			if (SCANconfigLoader.GlobalResource && narrowBand)
			{
				spotmap.Resource = bigmap.Resource;
				spotmap.Resource.CurrentBodyConfig(b.name);
			}

			spotmap.MapScale = 10;

			spotmap.centerAround(lon, lat);
			if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay)
				checkForScanners();
			spotmap.resetMap(bigmap.MType, false, narrowBand);
		}
Beispiel #32
0
		protected override void LateUpdate()
		{
			if (shutdown)
				return;

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

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

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

			v = FlightGlobals.ActiveVessel;

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

			if (v.mainBody != SCANcontroller.controller.LandingTargetBody)
				SCANcontroller.controller.LandingTargetBody = 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.LandingTarget != null)
			{
				way = SCANcontroller.controller.LandingTarget;
			}

			if (SCANcontroller.controller.TargetSelecting)
			{
				way = null;
				selectingTarget = true;
				if (SCANcontroller.controller.TargetSelectingActive)
					selectingInMap = true;
				else
					selectingInMap = false;
				coords = SCANcontroller.controller.LandingTargetCoords;
				return;
			}
			else if (selectingTarget)
			{
				selectingTarget = false;
				if (selectingInMap)
				{
					selectingInMap = false;
					coords = SCANcontroller.controller.LandingTargetCoords;
					way = new SCANwaypoint(coords.y, coords.x, siteName);
					target.SetPositionTarget(SCANcontroller.controller.LandingTargetBody, 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.LandingTarget = way;
					data.addToWaypoints();
				}
			}
			else
			{
				way = new SCANwaypoint(coords.y, coords.x, siteName);
				SCANcontroller.controller.LandingTarget = way;
				data.addToWaypoints();
			}
		}
Beispiel #33
0
		internal static void registerPass ( double lon, double lat, SCANdata data, SCANtype type ) {
			int ilon = SCANUtil.icLON(lon);
			int ilat = SCANUtil.icLAT(lat);
			if (SCANUtil.badLonLat(ilon, ilat)) return;
			data.Coverage[ilon, ilat] |= (Int32)type;
		}
Beispiel #34
0
 private void updateResourceArray(int lon, int lat, SCANdata.SCANtype type, SCANdata data)
 {
     data.coverage[lon, lat] |= (Int32)type;
 }
Beispiel #35
0
		internal static double getCoveragePercentage(SCANdata data, SCANtype type )
		{
			if (data == null)
				return 0;
			double cov = 0d;
			if (type == SCANtype.Nothing)
				type = SCANtype.AltimetryLoRes | SCANtype.AltimetryHiRes | SCANtype.Biome | SCANtype.Anomaly;          
			cov = data.getCoverage (type);
			if (cov <= 0)
				cov = 100;
			else
				cov = Math.Min (99.9d , 100 - cov * 100d / (360d * 180d * countBits((int)type)));
			return cov;
		}
Beispiel #36
0
 private void updateResourceValue(int lon, int lat, double?value, SCANdata data)
 {
     data.kethaneValueMap[lon, lat] = (float)value;
 }
        private void topBar(int id)
        {
            growE();
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
            {
                GUILayout.Label("", GUILayout.Width(70));
            }
            else
            {
                if (v != null)
                {
                    showOrbit = GUILayout.Toggle(showOrbit, textWithTT("", "Toggle Orbit"));

                    Rect d = GUILayoutUtility.GetLastRect();
                    d.x     += 30;
                    d.y     += 2;
                    d.width  = 40;
                    d.height = 20;

                    if (GUI.Button(d, iconWithTT(SCANskins.SCAN_OrbitIcon, "Toggle Orbit"), SCANskins.SCAN_buttonBorderless))
                    {
                        showOrbit = !showOrbit;
                    }
                }
                else
                {
                    GUILayout.Label("", GUILayout.Width(10));
                }

                if (SCANcontroller.controller.mechJebTargetSelection)
                {
                    if (SCANcontroller.controller.MechJebLoaded && SCANcontroller.controller.LandingTargetBody == b)
                    {
                        fillS(50);
                        if (GUILayout.Button(textWithTT("", "Set MechJeb Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24)))
                        {
                            SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting;
                        }
                        Rect  r   = GUILayoutUtility.GetLastRect();
                        Color old = GUI.color;
                        GUI.color = palette.red;
                        GUI.DrawTexture(r, SCANskins.SCAN_MechJebIcon);
                        GUI.color = old;
                    }
                    else
                    {
                        GUILayout.Label("", GUILayout.Width(70));
                    }
                }
                else
                {
                    fillS(50);
                    if (GUILayout.Button(textWithTT("", "Set Landing Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24)))
                    {
                        SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting;
                    }
                    Rect  r   = GUILayoutUtility.GetLastRect();
                    Color old = GUI.color;
                    GUI.color = palette.xkcd_PukeGreen;
                    GUI.DrawTexture(r, SCANskins.SCAN_TargetIcon);
                    GUI.color = old;
                }
            }

            fillS();

            if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomOutIcon, "Zoom Out"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26)))
            {
                spotmap.MapScale = spotmap.MapScale / 1.25f;
                if (spotmap.MapScale < 2)
                {
                    spotmap.MapScale = 2;
                }
                resetMap();
            }

            if (GUILayout.Button(textWithTT(spotmap.MapScale.ToString("N1") + " X", "Sync To Big Map"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(50), GUILayout.Height(24)))
            {
                SCANcontroller.controller.TargetSelecting       = false;
                SCANcontroller.controller.TargetSelectingActive = false;

                if (bigmap.Projection == MapProjection.Polar)
                {
                    spotmap.setProjection(MapProjection.Polar);
                }
                else
                {
                    spotmap.setProjection(MapProjection.Rectangular);
                }

                if (bigmap.Body != b)
                {
                    SCANdata dat = SCANUtil.getData(bigmap.Body);
                    if (dat == null)
                    {
                        dat = new SCANdata(bigmap.Body);
                    }

                    data = dat;
                    b    = data.Body;

                    spotmap.setBody(b);
                }

                if (SCANconfigLoader.GlobalResource && narrowBand)
                {
                    spotmap.Resource = bigmap.Resource;
                    spotmap.Resource.CurrentBodyConfig(b.name);
                }

                spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat);
                if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay)
                {
                    checkForScanners();
                }
                spotmap.resetMap(bigmap.MType, false, narrowBand);
            }

            if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomInIcon, "Zoom In"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26)))
            {
                spotmap.MapScale = spotmap.MapScale * 1.25f;
                resetMap();
            }

            fillS();

            if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
            {
                showWaypoints = GUILayout.Toggle(showWaypoints, textWithTT("", "Toggle Waypoints"));

                Rect w = GUILayoutUtility.GetLastRect();
                w.x     += 28;
                w.y     += 2;
                w.width  = 20;
                w.height = 20;

                if (GUI.Button(w, iconWithTT(SCANskins.SCAN_WaypointIcon, "Toggle Waypoints"), SCANskins.SCAN_buttonBorderless))
                {
                    showWaypoints = !showWaypoints;
                }

                fillS(16);
            }
            else
            {
                GUILayout.Label("", GUILayout.Width(40));
            }

            showAnomaly = GUILayout.Toggle(showAnomaly, textWithTT("", "Toggle Anomalies"));

            Rect a = GUILayoutUtility.GetLastRect();

            a.x     += 26;
            a.y     += 2;
            a.width  = 20;
            a.height = 20;

            if (GUI.Button(a, textWithTT(SCANcontroller.controller.anomalyMarker, "Toggle Anomalies"), SCANskins.SCAN_buttonBorderless))
            {
                showAnomaly = !showAnomaly;
            }

            fillS(16);

            stopE();
        }
Beispiel #38
0
		private void topBar(int id)
		{
			growE();
			if (HighLogic.LoadedScene == GameScenes.SPACECENTER)
			{
				GUILayout.Label("", GUILayout.Width(70));
			}
			else
			{
				if (v != null)
				{
					showOrbit = GUILayout.Toggle(showOrbit, textWithTT("", "Toggle Orbit"));

					Rect d = GUILayoutUtility.GetLastRect();
					d.x += 30;
					d.y += 2;
					d.width = 40;
					d.height = 20;

					if (GUI.Button(d, iconWithTT(SCANskins.SCAN_OrbitIcon, "Toggle Orbit"), SCANskins.SCAN_buttonBorderless))
					{
						showOrbit = !showOrbit;
					}
				}
				else
					GUILayout.Label("", GUILayout.Width(10));

				if (SCANcontroller.controller.mechJebTargetSelection)
				{
					if (SCANcontroller.controller.MechJebLoaded && SCANcontroller.controller.LandingTargetBody == b)
					{
						fillS(50);
						if (GUILayout.Button(textWithTT("", "Set MechJeb Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24)))
						{
							SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting;
						}
						Rect r = GUILayoutUtility.GetLastRect();
						Color old = GUI.color;
						GUI.color = palette.red;
						GUI.DrawTexture(r, SCANskins.SCAN_MechJebIcon);
						GUI.color = old;
					}
					else
						GUILayout.Label("", GUILayout.Width(70));
				}
				else
				{
					fillS(50);
					if (GUILayout.Button(textWithTT("", "Set Landing Target"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(24), GUILayout.Height(24)))
					{
						SCANcontroller.controller.TargetSelecting = !SCANcontroller.controller.TargetSelecting;
					}
					Rect r = GUILayoutUtility.GetLastRect();
					Color old = GUI.color;
					GUI.color = palette.xkcd_PukeGreen;
					GUI.DrawTexture(r, SCANskins.SCAN_TargetIcon);
					GUI.color = old;
				}
			}

			fillS();

			if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomOutIcon, "Zoom Out"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26)))
			{
				spotmap.MapScale = spotmap.MapScale / 1.25f;
				if (spotmap.MapScale < 2)
					spotmap.MapScale = 2;
				resetMap();
			}

			if (GUILayout.Button(textWithTT(spotmap.MapScale.ToString("N1") + " X", "Sync To Big Map"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(50), GUILayout.Height(24)))
			{
				SCANcontroller.controller.TargetSelecting = false;
				SCANcontroller.controller.TargetSelectingActive = false;

				if (bigmap.Projection == MapProjection.Polar)
					spotmap.setProjection(MapProjection.Polar);
				else
					spotmap.setProjection(MapProjection.Rectangular);

				if (bigmap.Body != b)
				{
					SCANdata dat = SCANUtil.getData(bigmap.Body);
					if (dat == null)
						dat = new SCANdata(bigmap.Body);

					data = dat;
					b = data.Body;

					spotmap.setBody(b);
				}

				if (SCANconfigLoader.GlobalResource && narrowBand)
				{
					spotmap.Resource = bigmap.Resource;
					spotmap.Resource.CurrentBodyConfig(b.name);
				}

				spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat);
				if (SCANcontroller.controller.needsNarrowBand && SCANcontroller.controller.map_ResourceOverlay)
					checkForScanners();
				spotmap.resetMap(bigmap.MType, false, narrowBand);
			}

			if (GUILayout.Button(iconWithTT(SCANskins.SCAN_ZoomInIcon, "Zoom In"), SCANskins.SCAN_buttonBorderless, GUILayout.Width(26), GUILayout.Height(26)))
			{
				spotmap.MapScale = spotmap.MapScale * 1.25f;
				resetMap();
			}

			fillS();

			if (HighLogic.LoadedScene != GameScenes.SPACECENTER)
			{
				showWaypoints = GUILayout.Toggle(showWaypoints, textWithTT("", "Toggle Waypoints"));

				Rect w = GUILayoutUtility.GetLastRect();
				w.x += 28;
				w.y += 2;
				w.width = 20;
				w.height = 20;

				if (GUI.Button(w, iconWithTT(SCANskins.SCAN_WaypointIcon, "Toggle Waypoints"), SCANskins.SCAN_buttonBorderless))
				{
					showWaypoints = !showWaypoints;
				}

				fillS(16);
			}
			else
				GUILayout.Label("", GUILayout.Width(40));

			showAnomaly = GUILayout.Toggle(showAnomaly, textWithTT("", "Toggle Anomalies"));

			Rect a = GUILayoutUtility.GetLastRect();
			a.x += 26;
			a.y += 2;
			a.width = 20;
			a.height = 20;

			if (GUI.Button(a, textWithTT(SCANcontroller.controller.anomalyMarker, "Toggle Anomalies"), SCANskins.SCAN_buttonBorderless))
			{
				showAnomaly = !showAnomaly;
			}

			fillS(16);

			stopE();
		}
Beispiel #39
0
		public override void OnLoad(ConfigNode node)
		{
			try
			{
				lowBiomeColor = ConfigNode.ParseColor(node.GetValue("lowBiomeColor"));
				highBiomeColor = ConfigNode.ParseColor(node.GetValue("highBiomeColor"));
				lowSlopeColorOne = ConfigNode.ParseColor(node.GetValue("lowSlopeColorOne"));
				highSlopeColorOne = ConfigNode.ParseColor(node.GetValue("highSlopeColorOne"));
				lowSlopeColorTwo = ConfigNode.ParseColor(node.GetValue("lowSlopeColorTwo"));
				highSlopeColorTwo = ConfigNode.ParseColor(node.GetValue("highSlopeColorTwo"));
			}
			catch (Exception e)
			{
				SCANUtil.SCANlog("Error While Loading SCANsat Colors: {0}", e);
			}


			ConfigNode node_vessels = node.GetNode("Scanners");
			if (node_vessels != null)
			{
				SCANUtil.SCANlog("SCANsat Controller: Loading {0} known vessels", node_vessels.CountNodes);
				foreach (ConfigNode node_vessel in node_vessels.GetNodes("Vessel"))
				{
					Guid id;
					try
					{
						id = new Guid(node_vessel.GetValue("guid"));
					}
					catch (Exception e)
					{
						SCANUtil.SCANlog("Something Went Wrong Loading This SCAN Vessel; Moving On To The Next: {0}", e);
						continue;
					}
					foreach (ConfigNode node_sensor in node_vessel.GetNodes("Sensor"))
					{
						int sensor;
						double fov, min_alt, max_alt, best_alt;
						if (!int.TryParse(node_sensor.GetValue("type"), out sensor))
							sensor = 0;
						if (!double.TryParse(node_sensor.GetValue("fov"), out fov))
							fov = 3;
						if (!double.TryParse(node_sensor.GetValue("min_alt"), out min_alt))
							min_alt = minScanAlt;
						if (!double.TryParse(node_sensor.GetValue("max_alt"), out max_alt))
							max_alt = maxScanAlt;
						if (!double.TryParse(node_sensor.GetValue("best_alt"), out best_alt))
							best_alt = bestScanAlt;
						registerSensor(id, (SCANtype)sensor, fov, min_alt, max_alt, best_alt);
					}
				}
			}

			ConfigNode node_progress = node.GetNode("Progress");
			if (node_progress != null)
			{
				foreach (ConfigNode node_body in node_progress.GetNodes("Body"))
				{
					float min, max, clamp;
					float? clampState = null;
					Palette dataPalette;
					SCANwaypoint target = null;
					string paletteName = "";
					int pSize;
					bool pRev, pDis, disabled;
					string body_name = node_body.GetValue("Name");
					SCANUtil.SCANlog("SCANsat Controller: Loading map for {0}", body_name);
					CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(b => b.name == body_name);
					if (body != null)
					{
						SCANdata data = getData(body.name);
						if (data == null)
							data = new SCANdata(body);
						if (!body_data.ContainsKey(body_name))
							body_data.Add(body_name, data);
						else
							body_data[body_name] = data;
						try
						{
							string mapdata = node_body.GetValue("Map");
							if (dataRebuild)
							{ //On the first load deserialize the "Map" value to both coverage arrays
								data.integerDeserialize(mapdata, true);
							}
							else
							{
								data.integerDeserialize(mapdata, false);
							}
						}
						catch (Exception e)
						{
							SCANUtil.SCANlog("Something Went Wrong Loading Scanning Data; Resetting Coverage: {0}", e);
							data.reset();
							// fail somewhat gracefully; don't make the save unloadable 
						}
						try // Make doubly sure that nothing here can interupt the Scenario Module loading process
						{
							//Verify that saved data types can be converted, revert to default values otherwise
							if (node_body.HasValue("LandingTarget"))
								target = loadWaypoint(node_body.GetValue("LandingTarget"));
							if (bool.TryParse(node_body.GetValue("Disabled"), out disabled))
								data.Disabled = disabled;
							if (!float.TryParse(node_body.GetValue("MinHeightRange"), out min))
								min = data.TerrainConfig.DefaultMinHeight;
							if (!float.TryParse(node_body.GetValue("MaxHeightRange"), out max))
								max = data.TerrainConfig.DefaultMaxHeight;
							if (node_body.HasValue("ClampHeight"))
							{
								if (float.TryParse(node_body.GetValue("ClampHeight"), out clamp))
									clampState = clamp;
							}
							if (!int.TryParse(node_body.GetValue("PaletteSize"), out pSize))
								pSize = data.TerrainConfig.DefaultPaletteSize;
							if (!bool.TryParse(node_body.GetValue("PaletteReverse"), out pRev))
								pRev = data.TerrainConfig.DefaultReverse;
							if (!bool.TryParse(node_body.GetValue("PaletteDiscrete"), out pDis))
								pDis = data.TerrainConfig.DefaultDiscrete;
							if (node_body.HasValue("PaletteName"))
								paletteName = node_body.GetValue("PaletteName");
							dataPalette = SCANUtil.paletteLoader(paletteName, pSize);
							if (dataPalette.hash == PaletteLoader.defaultPalette.hash)
							{
								paletteName = "Default";
								pSize = 7;
							}

							SCANterrainConfig dataTerrainConfig = getTerrainNode(body.name);

							if (dataTerrainConfig == null)
								dataTerrainConfig = new SCANterrainConfig(min, max, clampState, dataPalette, pSize, pRev, pDis, body);
							else
								setNewTerrainConfigValues(dataTerrainConfig, min, max, clampState, dataPalette, pSize, pRev, pDis);

							data.TerrainConfig = dataTerrainConfig;

							if (target != null)
								data.addToWaypoints(target);
						}
						catch (Exception e)
						{
							SCANUtil.SCANlog("Error Loading SCANdata; Reverting To Default Settings: {0}", e);
						}
					}
				}
			}
			dataRebuild = false; //Used for the one-time update to the new integer array

			if (SCANconfigLoader.GlobalResource)
			{
				if (string.IsNullOrEmpty(resourceSelection))
					resourceSelection = masterResourceNodes.ElementAt(0).Key;
				else if (!masterResourceNodes.ContainsKey(resourceSelection))
					resourceSelection = masterResourceNodes.ElementAt(0).Key;
			}
			ConfigNode node_resources = node.GetNode("SCANResources");
			if (node_resources != null)
			{
				foreach(ConfigNode node_resource_type in node_resources.GetNodes("ResourceType"))
				{
					if (node_resource_type != null)
					{
						string name = node_resource_type.GetValue("Resource");
						string lowColor = node_resource_type.GetValue("MinColor");
						string highColor = node_resource_type.GetValue("MaxColor");
						string transparent = node_resource_type.GetValue("Transparency");
						string minMaxValues = node_resource_type.GetValue("MinMaxValues");
						loadCustomResourceValues(minMaxValues, name, lowColor, highColor, transparent);
					}
				}
			}
			loaded = true;
		}
Beispiel #40
0
		protected override void Start()
		{
			//Initialize the map object
			Visible = SCANcontroller.controller.bigMapVisible;
			if (v == null)
				v = FlightGlobals.ActiveVessel;
			if (b == null)
				b = v.mainBody;
			if (bigmap == null)
			{
				bigmap = new SCANmap(b, true);
				bigmap.setProjection((MapProjection)SCANcontroller.controller.projection);
				bigmap.setWidth(SCANcontroller.controller.map_width);
			}
			WindowRect.x = SCANcontroller.controller.map_x;
			WindowRect.y = SCANcontroller.controller.map_y;
			currentColor = SCANcontroller.controller.colours == 0;
			lastColor = currentColor;
			lastResource = SCANcontroller.controller.map_ResourceOverlay;
			WindowCaption = string.Format("Map of {0}", b.theName);
			data = SCANUtil.getData(b);
			if (data == null)
			{
				data = new SCANdata(b);
				SCANcontroller.controller.addToBodyData(b, data);
			}
			bigmap.setBody(b);
			if (SCANconfigLoader.GlobalResource)
			{
				loadedResources = SCANcontroller.setLoadedResourceList();
			}
			TooltipsEnabled = SCANcontroller.controller.toolTips;
		}
Beispiel #41
0
		/* Use this method to protect against duplicate dictionary keys */
		public void addToBodyData (CelestialBody b, SCANdata data)
		{
			if (!body_data.ContainsKey(b.name))
				body_data.Add(b.name, data);
			else
				Debug.LogError("[SCANsat] Warning: SCANdata Dictionary Already Contains Key of This Type");
		}