private void RedrawMap() { map = new SCANmap(); map.setProjection(SCANmap.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(mapMode); // 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 { localAnomalies = SCANcontroller.controller.getData(vessel.mainBody).getAnomalies(); } 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; }
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); }
protected override void DrawWindowPost(int id) { //Close the drop down menu if the window is clicked anywhere else if (drop_down_open && Event.current.type == EventType.mouseDown && !ddRect.Contains(Event.current.mousePosition)) { drop_down_open = false; } //Update black and white/color statuse if (lastColor != currentColor) { lastColor = currentColor; if (SCANcontroller.controller.colours == 0) { SCANcontroller.controller.colours = 1; } else { SCANcontroller.controller.colours = 0; } data.resetImages(); bigmap.resetMap(); } //Update grid overlay status if (currentGrid != SCANcontroller.controller.map_grid) { currentGrid = SCANcontroller.controller.map_grid; drawGrid = true; } //Update selected resource status if (lastResource != SCANcontroller.controller.map_ResourceOverlay) { lastResource = SCANcontroller.controller.map_ResourceOverlay; bigmap.resetMap(); } SCANcontroller.controller.map_x = (int)WindowRect.x; SCANcontroller.controller.map_y = (int)WindowRect.y; }
//Buttons to apply the new palette or cancel and return to the original private void paletteConfirmation(int id) { growS(); fillS(6); growE(); if (!dropDown) { if (GUILayout.Button("Apply Values", GUILayout.Width(110))) { SCANcontroller.updateTerrainConfig(currentTerrain); updateUI(); if (bigMap != null) { if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0) { bigMap.resetMap(); } } } fillS(6); if (GUILayout.Button("Default Values", GUILayout.Width(110))) { currentTerrain.MinTerrain = data.TerrainConfig.DefaultMinHeight; currentTerrain.MaxTerrain = data.TerrainConfig.DefaultMaxHeight; currentTerrain.ClampTerrain = data.TerrainConfig.DefaultClampHeight; currentTerrain.ColorPal = data.TerrainConfig.DefaultPalette; currentTerrain.PalRev = data.TerrainConfig.DefaultReverse; currentTerrain.PalDis = data.TerrainConfig.DefaultDiscrete; currentTerrain.PalSize = data.TerrainConfig.DefaultPaletteSize; updateUI(); if (bigMap != null) { if (bigMap.MType == mapType.Altimetry && SCANcontroller.controller.colours == 0) { bigMap.resetMap(); } } } } else { GUILayout.Label("Apply Values", SCANskins.SCAN_button, GUILayout.Width(110)); fillS(6); GUILayout.Label("Default Values", SCANskins.SCAN_button, GUILayout.Width(110)); } stopE(); fillS(8); if (!dropDown) { if (GUILayout.Button("Save Values To Config", GUILayout.Width(180))) { dropDown = true; saveWarning = true; } } else { GUILayout.Label("Save Values To Config", SCANskins.SCAN_button, GUILayout.Width(180)); } stopS(); }