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); }
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; }
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); }
protected override void DrawWindowPre(int id) { WindowCaption = SCANuiUtil.toDMS(spotmap.CenteredLat, spotmap.CenteredLong); if (IsResizing && !inRepaint()) { if (Input.GetMouseButtonUp(0)) { double scale = spotmap.MapScale; IsResizing = false; if (resizeW < WindowSize_Min.x) { resizeW = WindowSize_Min.x; } else if (resizeW > WindowSize_Max.x) { resizeW = WindowSize_Max.x; } if (resizeH < WindowSize_Min.y) { resizeH = WindowSize_Min.y; } else if (resizeH > WindowSize_Max.y) { resizeH = WindowSize_Max.y; } spotmap.setSize((int)resizeW, (int)resizeH); spotmap.MapScale = scale; spotmap.centerAround(spotmap.CenteredLong, spotmap.CenteredLat); spotmap.resetMap(spotmap.MType, false); } else { float yy = Input.mousePosition.y; float xx = Input.mousePosition.x; if (Input.mousePosition.y < 0) { yy = 0; } if (Input.mousePosition.x < 0) { xx = 0; } resizeH += dragStart.y - yy; dragStart.y = yy; resizeW += xx - dragStart.x; dragStart.x = xx; } if (Event.current.isMouse) { Event.current.Use(); } } //Lock space center click through if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { 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) { InputLockManager.RemoveControlLock(lockID); controlLock = false; } } //Lock tracking scene click through if (HighLogic.LoadedScene == GameScenes.TRACKSTATION) { 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) { InputLockManager.RemoveControlLock(lockID); controlLock = false; } } }