//Draw the active scanner display private void scannerInfo(int id) { bool repainting = Event.current.type == EventType.Repaint; if (!repainting) { infoText = SCANuiUtil.InfoText(v, data, notMappingToday); } if (infoText != null) { SCANuiUtil.readableLabel(infoText, false); } }
//Method to handle vessel info private bool vesselInfo(Vessel scanV, Rect r, int i, bool b) { if (scanV == null) { return(false); } if (scanV.mainBody == v.mainBody) { if (!showVesselInfo) { SCANuiUtil.drawVesselLabel(r, null, -1, scanV); return(true); } float lon = (float)SCANUtil.fixLonShift(scanV.longitude); float lat = (float)SCANUtil.fixLatShift(scanV.latitude); float alt = scanV.heightFromTerrain; if (alt < 0) { alt = (float)scanV.altitude; } string text = string.Format("[{0}] {1} ({2:F1}°,{3:F1}°; {4:N1}m)", i, scanV.vesselName, lat, lon, alt); if (SCANuiUtil.readableLabel(text, b)) { if (Event.current.clickCount > 1) { Event.current.Use(); FlightGlobals.SetActiveVessel(scanV); ScreenMessages.PostScreenMessage(scanV.vesselName, 5, ScreenMessageStyle.UPPER_CENTER); } } SCANuiUtil.drawVesselLabel(r, null, i, scanV); fillS(-10); return(true); } return(false); }
private void mouseOver(int id) { float mx = Event.current.mousePosition.x - TextureRect.x; float my = Event.current.mousePosition.y - TextureRect.y; bool in_map = false; double mlon = 0, mlat = 0; //Draw the re-size label in the corner Rect resizer = new Rect(WindowRect.width - 24, WindowRect.height - 26, 24, 24); GUI.Label(resizer, SCANskins.SCAN_ResizeIcon); //Handles mouse positioning and converting to lat/long coordinates if (mx >= 0 && my >= 0 && mx <= TextureRect.width && my <= TextureRect.height /*mx >= 0 && my >= 0 && mx < MapTexture.width && my < MapTexture.height*/) { double mlo = spotmap.Lon_Offset + (mx / spotmap.MapScale) - 180; double mla = spotmap.Lat_Offset + ((TextureRect.height - my) / spotmap.MapScale) - 90; mlon = spotmap.unprojectLongitude(mlo, mla); mlat = spotmap.unprojectLatitude(mlo, mla); if (mlon >= -180 && mlon <= 180 && mlat >= -90 && mlat <= 90) { in_map = true; if (SCANcontroller.controller.TargetSelecting) { SCANcontroller.controller.TargetSelectingActive = true; mjTarget.x = mlon; mjTarget.y = mlat; SCANcontroller.controller.LandingTargetCoords = mjTarget; Rect r = new Rect(mx + TextureRect.x - 11, my + TextureRect.y - 13, 24, 24); SCANuiUtil.drawMapIcon(r, SCANcontroller.controller.mechJebTargetSelection ? SCANskins.SCAN_MechJebIcon : SCANskins.SCAN_TargetIcon, true, palette.yellow, true); } } else if (SCANcontroller.controller.TargetSelecting) { SCANcontroller.controller.TargetSelectingActive = false; } if (mlat > 90) { mlon = (mlon + 360) % 360 - 180; mlat = 180 - mlat; } else if (mlat < -90) { mlon = (mlon + 360) % 360 - 180; mlat = -180 - mlat; } } else if (SCANcontroller.controller.TargetSelecting) { SCANcontroller.controller.TargetSelectingActive = false; } //Handles mouse click while inside map if (Event.current.isMouse) { if (Event.current.type == EventType.MouseUp) { //Generate waypoint for MechJeb target if (SCANcontroller.controller.TargetSelecting && SCANcontroller.controller.TargetSelectingActive && Event.current.button == 0 && in_map) { string s = SCANcontroller.controller.mechJebTargetSelection ? "MechJeb Landing Target" : "Landing Target Site"; SCANwaypoint w = new SCANwaypoint(mlat, mlon, s); SCANcontroller.controller.LandingTarget = w; data.addToWaypoints(); SCANcontroller.controller.TargetSelecting = false; SCANcontroller.controller.TargetSelectingActive = false; } //Middle click re-center else if (Event.current.button == 2 || (Event.current.button == 1 && GameSettings.MODIFIER_KEY.GetKey())) { if (in_map) { spotmap.centerAround(mlon, mlat); resetMap(); } } //Right click zoom in else if (Event.current.button == 1) { if (in_map) { spotmap.MapScale = spotmap.MapScale * 1.25f; spotmap.centerAround(mlon, mlat); resetMap(); } } //Left click zoom out else if (Event.current.button == 0) { if (in_map) { spotmap.MapScale = spotmap.MapScale / 1.25f; if (spotmap.MapScale < 2) { spotmap.MapScale = 2; } spotmap.centerAround(mlon, mlat); resetMap(); } } Event.current.Use(); } //Handle clicking inside the re-size button else if (Event.current.isMouse && Event.current.type == EventType.MouseDown && Event.current.button == 0 && resizer.Contains(Event.current.mousePosition)) { IsResizing = true; dragStart.x = Input.mousePosition.x; dragStart.y = Input.mousePosition.y; resizeW = TextureRect.width; resizeH = TextureRect.height; Event.current.Use(); } } //Draw the actual mouse over info label below the map if (SCANcontroller.controller.TargetSelecting) { SCANuiUtil.readableLabel(SCANcontroller.controller.mechJebTargetSelection ? "MechJeb Landing Guidance Targeting..." : "Landing Site Targeting...", false); fillS(-10); SCANuiUtil.mouseOverInfoSimple(mlon, mlat, spotmap, data, spotmap.Body, in_map); } else if (showInfo) { SCANuiUtil.mouseOverInfoSimple(mlon, mlat, spotmap, data, spotmap.Body, in_map); } else { fillS(10); } }