void OnGUI() { if (HighLogic.LoadedSceneIsFlight && !MapView.MapIsEnabled && BDArmorySettings.GAME_UI_ENABLED && !delayedEnabling) { if (cameraEnabled && vessel.isActiveVessel && FlightGlobals.ready) { //window if (activeCam == this && TargetingCamera.ReadyForUse) { camWindowRect = GUI.Window(125452, camWindowRect, CamWindow, string.Empty, HighLogic.Skin.window); BDGUIUtils.UseMouseEventInRect(camWindowRect); } //locked target icon if (groundStabilized) { BDGUIUtils.DrawTextureOnWorldPos(groundTargetPosition, BDArmorySettings.Instance.greenPointCircleTexture, new Vector3(20, 20), 0); } else { BDGUIUtils.DrawTextureOnWorldPos(targetPointPosition, BDArmorySettings.Instance.greenCircleTexture, new Vector3(18, 18), 0); } } if (BDArmorySettings.DRAW_DEBUG_LABELS) { GUI.Label(new Rect(500, 500, 500, 500), "Slew rate: " + finalSlewSpeed); } } }
void OnGUI() { if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ready && BDArmorySettings.GAME_UI_ENABLED && vessel.isActiveVessel && rwrEnabled) { windowRect = GUI.Window(94353, windowRect, RWRWindow, "Radar Warning Receiver", HighLogic.Skin.window); BDGUIUtils.UseMouseEventInRect(windowRect); } }
void OnGUI() { if (HighLogic.LoadedSceneIsFlight && vessel && vessel.isActiveVessel && !vessel.packed) { if (BDArmorySettings.GAME_UI_ENABLED) { if (showGUI) { if (!rectInit) { guiWindowRect = new Rect(45, 75, 240, 800); buttonWidth = guiWindowRect.width - (2 * margin); buttonEndY = buttonStartY; wingmanButtonStyle = new GUIStyle(HighLogic.Skin.button); wingmanButtonStyle.alignment = TextAnchor.MiddleLeft; wingmanButtonStyle.wordWrap = false; wingmanButtonStyle.fontSize = 11; wingmanButtonSelectedStyle = new GUIStyle(HighLogic.Skin.box); wingmanButtonSelectedStyle.alignment = TextAnchor.MiddleLeft; wingmanButtonSelectedStyle.wordWrap = false; wingmanButtonSelectedStyle.fontSize = 11; rectInit = true; } guiWindowRect = GUI.Window(1293293, guiWindowRect, WingmenWindow, "WingCommander", HighLogic.Skin.window); if (showAGWindow) { AGWindow(); } } //command position diamonds float diamondSize = 24; foreach (var comPos in commandedPositions) { BDGUIUtils.DrawTextureOnWorldPos(comPos.worldPos, BDArmorySettings.Instance.greenDiamondTexture, new Vector2(diamondSize, diamondSize), 0); Vector2 labelPos; if (BDGUIUtils.WorldToGUIPos(comPos.worldPos, out labelPos)) { labelPos.x += diamondSize / 2; labelPos.y -= 10; GUI.Label(new Rect(labelPos.x, labelPos.y, 300, 20), comPos.name); } } if (drawMouseDiamond) { Vector2 mouseDiamondPos = Input.mousePosition; Rect mouseDiamondRect = new Rect(mouseDiamondPos.x - (diamondSize / 2), Screen.height - mouseDiamondPos.y - (diamondSize / 2), diamondSize, diamondSize); GUI.DrawTexture(mouseDiamondRect, BDArmorySettings.Instance.greenDiamondTexture, ScaleMode.StretchToFill, true); } } } }
void OnGUI() { if (setupComplete) { for (int i = 0; i < localAnchors.Length; i++) { BDGUIUtils.DrawTextureOnWorldPos(parentTransform.TransformPoint(localAnchors[i]), BDArmorySettings.Instance.greenDotTexture, new Vector2(6, 6), 0); } } }
void OnGUI() { if (drawGUI) { if (boresightScan) { BDGUIUtils.DrawTextureOnWorldPos(transform.position + (3500 * transform.up), BDArmorySettings.Instance.dottedLargeGreenCircle, new Vector2(156, 156), 0); } } }
void DrawAlignmentIndicator() { if(fireTransforms == null || fireTransforms[0] == null) return; Transform refTransform = EditorLogic.RootPart.GetReferenceTransform(); Vector3 fwdPos = fireTransforms[0].position + (5 * fireTransforms[0].forward); BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, fwdPos, 4, Color.green); Vector3 referenceDirection = refTransform.up; Vector3 refUp = -refTransform.forward; Vector3 refRight = refTransform.right; Vector3 refFwdPos = fireTransforms[0].position + (5 * referenceDirection); BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, refFwdPos, 2, Color.white); BDGUIUtils.DrawLineBetweenWorldPositions(fwdPos, refFwdPos, 2, XKCDColors.Orange); Vector2 guiPos; if(BDGUIUtils.WorldToGUIPos(fwdPos, out guiPos)) { Rect angleRect = new Rect(guiPos.x, guiPos.y, 100, 200); Vector3 pitchVector = (5 *Vector3.ProjectOnPlane(fireTransforms[0].forward, refRight)); Vector3 yawVector = (5 * Vector3.ProjectOnPlane(fireTransforms[0].forward, refUp)); BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position + pitchVector, fwdPos, 3, Color.white); BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position + yawVector, fwdPos, 3, Color.white); float pitch = Vector3.Angle(pitchVector, referenceDirection); float yaw = Vector3.Angle(yawVector, referenceDirection); string convergeDistance; Vector3 projAxis = Vector3.Project(refTransform.position - fireTransforms[0].transform.position, refRight); float xDist = projAxis.magnitude; float convergeAngle = 90 - Vector3.Angle(yawVector, refTransform.up); if(Vector3.Dot(fireTransforms[0].forward, projAxis) > 0) { convergeDistance = "Converge: "+Mathf.Round((xDist * Mathf.Tan(convergeAngle*Mathf.Deg2Rad))).ToString()+"m"; } else { convergeDistance = "Diverging"; } string xAngle = "X: " + Vector3.Angle(fireTransforms[0].forward, pitchVector).ToString("0.00"); string yAngle = "Y: " + Vector3.Angle(fireTransforms[0].forward, yawVector).ToString("0.00"); GUI.Label(angleRect, xAngle+"\n"+ yAngle + "\n"+convergeDistance); } }
void OnGUI() { if (pilotEnabled && vessel.isActiveVessel) { if (BDArmorySettings.DRAW_DEBUG_LABELS) { GUI.Label(new Rect(200, 800, 400, 400), debugString); } if (BDArmorySettings.DRAW_DEBUG_LINES) { if (command == PilotCommands.Follow) { BDGUIUtils.DrawLineBetweenWorldPositions(vesselTransform.position, commandPosition, 2, Color.red); } } } }
void CamWindow(int windowID) { if (!TargetingCamera.Instance) { return; } windowIsOpen = true; GUI.DragWindow(new Rect(0, 0, camImageSize + 16, camImageSize + 8)); Rect imageRect = new Rect(8, 20, camImageSize, camImageSize); GUI.DrawTexture(imageRect, TargetingCamera.Instance.targetCamRenderTexture, ScaleMode.StretchToFill, false); GUI.DrawTexture(imageRect, TargetingCamera.Instance.ReticleTexture, ScaleMode.StretchToFill, true); float controlsStartY = 24 + camImageSize + 4; //slew buttons float slewStartX = 8; float slewSize = (controlPanelHeight / 3) - 8; Rect slewUpRect = new Rect(slewStartX + slewSize, controlsStartY, slewSize, slewSize); Rect slewDownRect = new Rect(slewStartX + slewSize, controlsStartY + (2 * slewSize), slewSize, slewSize); Rect slewLeftRect = new Rect(slewStartX, controlsStartY + slewSize, slewSize, slewSize); Rect slewRightRect = new Rect(slewStartX + (2 * slewSize), controlsStartY + slewSize, slewSize, slewSize); if (GUI.RepeatButton(slewUpRect, "^", HighLogic.Skin.button)) { //SlewCamera(Vector3.up); slewInput.y = 1; } if (GUI.RepeatButton(slewDownRect, "v", HighLogic.Skin.button)) { //SlewCamera(Vector3.down); slewInput.y = -1; } if (GUI.RepeatButton(slewLeftRect, "<", HighLogic.Skin.button)) { //SlewCamera(Vector3.left); slewInput.x = -1; } if (GUI.RepeatButton(slewRightRect, ">", HighLogic.Skin.button)) { //SlewCamera(Vector3.right); slewInput.x = 1; } //zoom buttons float zoomStartX = 8 + (3 * slewSize) + 4; Rect zoomInRect = new Rect(zoomStartX, controlsStartY, 3 * slewSize, slewSize); Rect zoomOutRect = new Rect(zoomStartX, controlsStartY + (2 * slewSize), 3 * slewSize, slewSize); GUIStyle disabledStyle = new GUIStyle(); disabledStyle.alignment = TextAnchor.MiddleCenter; disabledStyle.normal.textColor = Color.white; if (currentFovIndex < zoomFovs.Length - 1) { if (GUI.Button(zoomInRect, "In", HighLogic.Skin.button)) { ZoomIn(); } } else { GUI.Label(zoomInRect, "(In)", disabledStyle); } if (currentFovIndex > 0) { if (GUI.Button(zoomOutRect, "Out", HighLogic.Skin.button)) { ZoomOut(); } } else { GUI.Label(zoomOutRect, "(Out)", disabledStyle); } Rect zoomInfoRect = new Rect(zoomStartX, controlsStartY + slewSize, 3 * slewSize, slewSize); GUIStyle zoomInfoStyle = new GUIStyle(HighLogic.Skin.box); zoomInfoStyle.fontSize = 12; zoomInfoStyle.wordWrap = false; GUI.Label(zoomInfoRect, "Zoom " + (currentFovIndex + 1).ToString(), zoomInfoStyle); GUIStyle dataStyle = new GUIStyle(); dataStyle.alignment = TextAnchor.MiddleCenter; dataStyle.normal.textColor = Color.white; //groundStablize button float stabilStartX = zoomStartX + zoomInRect.width + 4; Rect stabilizeRect = new Rect(stabilStartX, controlsStartY, 3 * slewSize, 3 * slewSize); if (!groundStabilized) { if (GUI.Button(stabilizeRect, "Lock\nTarget", HighLogic.Skin.button)) { GroundStabilize(); } } else { if (GUI.Button(new Rect(stabilizeRect.x, stabilizeRect.y, stabilizeRect.width, stabilizeRect.height / 2), "Unlock", HighLogic.Skin.button)) { ClearTarget(); } if (weaponManager) { GUIStyle gpsStyle = new GUIStyle(HighLogic.Skin.button); gpsStyle.fontSize = 10; if (GUI.Button(new Rect(stabilizeRect.x, stabilizeRect.y + (stabilizeRect.height / 2), stabilizeRect.width, stabilizeRect.height / 2), "Send GPS", gpsStyle)) { SendGPS(); } } if (!gimbalLimitReached) { //open square float oSqrSize = (24f / 512f) * camImageSize; Rect oSqrRect = new Rect(imageRect.x + (camImageSize / 2) - (oSqrSize / 2), imageRect.y + (camImageSize / 2) - (oSqrSize / 2), oSqrSize, oSqrSize); GUI.DrawTexture(oSqrRect, BDArmorySettings.Instance.openWhiteSquareTexture, ScaleMode.StretchToFill, true); } //geo data Rect geoRect = new Rect(imageRect.x, (camImageSize * 0.94f), camImageSize, 14); string geoLabel = Misc.FormattedGeoPos(bodyRelativeGTP, false); GUI.Label(geoRect, geoLabel, dataStyle); //target data dataStyle.fontSize = 16; float dataStartX = stabilStartX + stabilizeRect.width + 8; Rect targetRangeRect = new Rect(imageRect.x, (camImageSize * 0.94f) - 18, camImageSize, 18); float targetRange = Vector3.Distance(groundTargetPosition, transform.position); string rangeString = "Range: " + targetRange.ToString("0.0") + "m"; GUI.Label(targetRangeRect, rangeString, dataStyle); //laser ranging indicator dataStyle.fontSize = 18; string lrLabel = surfaceDetected ? "LR" : "NO LR"; Rect lrRect = new Rect(imageRect.x, imageRect.y + (camImageSize * 0.65f), camImageSize, 20); GUI.Label(lrRect, lrLabel, dataStyle); //azimuth and elevation indicator //UNFINISHED /* * Vector2 azielPos = TargetAzimuthElevationScreenPos(imageRect, groundTargetPosition, 4); * Rect azielRect = new Rect(azielPos.x, azielPos.y, 4, 4); * GUI.DrawTexture(azielRect, BDArmorySettings.Instance.whiteSquareTexture, ScaleMode.StretchToFill, true); */ //DLZ if (weaponManager && weaponManager.selectedWeapon != null) { if (weaponManager.selectedWeapon.GetWeaponClass() == WeaponClasses.Missile) { MissileLauncher currMissile = weaponManager.currentMissile; if (currMissile.targetingMode == MissileLauncher.TargetingModes.GPS || currMissile.targetingMode == MissileLauncher.TargetingModes.Laser) { MissileLaunchParams dlz = MissileLaunchParams.GetDynamicLaunchParams(currMissile, Vector3.zero, groundTargetPosition); float dlzWidth = 12 * (imageRect.width / 360); float lineWidth = 2; Rect dlzRect = new Rect(imageRect.x + imageRect.width - (3 * dlzWidth) - lineWidth, imageRect.y + (imageRect.height / 4), dlzWidth, imageRect.height / 2); float scaleDistance = Mathf.Max(Mathf.Max(8000f, currMissile.maxStaticLaunchRange * 2), targetRange); float rangeToPixels = (1f / scaleDistance) * dlzRect.height; GUI.BeginGroup(dlzRect); float dlzX = 0; BDGUIUtils.DrawRectangle(new Rect(0, 0, dlzWidth, dlzRect.height), Color.black); Rect maxRangeVertLineRect = new Rect(dlzRect.width - lineWidth, Mathf.Clamp(dlzRect.height - (dlz.maxLaunchRange * rangeToPixels), 0, dlzRect.height), lineWidth, Mathf.Clamp(dlz.maxLaunchRange * rangeToPixels, 0, dlzRect.height)); BDGUIUtils.DrawRectangle(maxRangeVertLineRect, Color.white); Rect maxRangeTickRect = new Rect(dlzX, maxRangeVertLineRect.y, dlzWidth, lineWidth); BDGUIUtils.DrawRectangle(maxRangeTickRect, Color.white); Rect minRangeTickRect = new Rect(dlzX, Mathf.Clamp(dlzRect.height - (dlz.minLaunchRange * rangeToPixels), 0, dlzRect.height), dlzWidth, lineWidth); BDGUIUtils.DrawRectangle(minRangeTickRect, Color.white); Rect rTrTickRect = new Rect(dlzX, Mathf.Clamp(dlzRect.height - (dlz.rangeTr * rangeToPixels), 0, dlzRect.height), dlzWidth, lineWidth); BDGUIUtils.DrawRectangle(rTrTickRect, Color.white); Rect noEscapeLineRect = new Rect(dlzX, rTrTickRect.y, lineWidth, minRangeTickRect.y - rTrTickRect.y); BDGUIUtils.DrawRectangle(noEscapeLineRect, Color.white); GUI.EndGroup(); float targetDistIconSize = 6; float targetDistY = dlzRect.y + dlzRect.height - (targetRange * rangeToPixels); Rect targetDistanceRect = new Rect(dlzRect.x - (targetDistIconSize / 2), targetDistY, (targetDistIconSize / 2) + dlzRect.width, targetDistIconSize); BDGUIUtils.DrawRectangle(targetDistanceRect, Color.white); } } } } //gimbal limit dataStyle.fontSize = 24; if (gimbalLimitReached) { Rect gLimRect = new Rect(imageRect.x, imageRect.y + (camImageSize * 0.15f), camImageSize, 28); GUI.Label(gLimRect, "GIMBAL LIMIT", dataStyle); } //reset button float resetStartX = stabilStartX + stabilizeRect.width + 4; Rect resetRect = new Rect(resetStartX, controlsStartY + (2 * slewSize), 3 * slewSize, slewSize - 1); if (GUI.Button(resetRect, "Reset", HighLogic.Skin.button)) { ResetCameraButton(); } //CoM lock Rect comLockRect = new Rect(resetRect.x, controlsStartY, 3 * slewSize, slewSize - 1); GUIStyle comStyle = new GUIStyle(CoMLock ? HighLogic.Skin.box : HighLogic.Skin.button); comStyle.fontSize = 10; comStyle.wordWrap = false; if (GUI.Button(comLockRect, "CoM Track", comStyle)) { CoMLock = !CoMLock; } //radar slave Rect radarSlaveRect = new Rect(comLockRect.x + comLockRect.width + 4, comLockRect.y, 3 * slewSize, slewSize - 1); GUIStyle radarSlaveStyle = radarLock ? HighLogic.Skin.box : HighLogic.Skin.button; if (GUI.Button(radarSlaveRect, "Radar", radarSlaveStyle)) { radarLock = !radarLock; } //slave turrets button Rect slaveRect = new Rect(resetStartX, controlsStartY + slewSize, (3 * slewSize), slewSize - 1); if (!slaveTurrets) { if (GUI.Button(slaveRect, "Turrets", HighLogic.Skin.button)) { SlaveTurrets(); } } else { if (GUI.Button(slaveRect, "Turrets", HighLogic.Skin.box)) { UnslaveTurrets(); } } //point to gps button Rect toGpsRect = new Rect(resetRect.x + slaveRect.width + 4, slaveRect.y, 3 * slewSize, slewSize - 1); if (GUI.Button(toGpsRect, "To GPS", HighLogic.Skin.button)) { PointToGPSTarget(); } //nv button float nvStartX = resetStartX + resetRect.width + 4; Rect nvRect = new Rect(nvStartX, resetRect.y, 3 * slewSize, slewSize - 1); string nvLabel = nvMode ? "NV Off" : "NV On"; GUIStyle nvStyle = nvMode ? HighLogic.Skin.box : HighLogic.Skin.button; if (GUI.Button(nvRect, nvLabel, nvStyle)) { ToggleNV(); } //off button float offStartX = nvStartX + nvRect.width + 4; Rect offRect = new Rect(offStartX, controlsStartY, slewSize * 1.5f, 3 * slewSize); if (GUI.Button(offRect, "O\nF\nF", HighLogic.Skin.button)) { DisableCamera(); } float indicatorSize = Mathf.Clamp(64 * (camImageSize / 360), 64, 128); float indicatorBorder = imageRect.width * 0.056f; Vector3 vesForward = vessel.ReferenceTransform.up; Vector3 upDirection = (transform.position - FlightGlobals.currentMainBody.transform.position).normalized; //horizon indicator float horizY = imageRect.y + imageRect.height - indicatorSize - indicatorBorder; Vector3 hForward = Vector3.ProjectOnPlane(vesForward, upDirection); float hAngle = -Misc.SignedAngle(hForward, vesForward, upDirection); horizY -= (hAngle / 90) * (indicatorSize / 2); Rect horizonRect = new Rect(indicatorBorder + imageRect.x, horizY, indicatorSize, indicatorSize); GUI.DrawTexture(horizonRect, BDArmorySettings.Instance.horizonIndicatorTexture, ScaleMode.StretchToFill, true); //roll indicator Rect rollRect = new Rect(indicatorBorder + imageRect.x, imageRect.y + imageRect.height - indicatorSize - indicatorBorder, indicatorSize, indicatorSize); GUI.DrawTexture(rollRect, rollReferenceTexture, ScaleMode.StretchToFill, true); Vector3 localUp = vessel.ReferenceTransform.InverseTransformDirection(upDirection); localUp = Vector3.ProjectOnPlane(localUp, Vector3.up).normalized; float rollAngle = -Misc.SignedAngle(-Vector3.forward, localUp, Vector3.right); GUIUtility.RotateAroundPivot(rollAngle, rollRect.center); GUI.DrawTexture(rollRect, rollIndicatorTexture, ScaleMode.StretchToFill, true); GUI.matrix = Matrix4x4.identity; //target direction indicator float angleToTarget = Misc.SignedAngle(hForward, Vector3.ProjectOnPlane(targetPointPosition - transform.position, upDirection), Vector3.Cross(upDirection, hForward)); GUIUtility.RotateAroundPivot(angleToTarget, rollRect.center); GUI.DrawTexture(rollRect, BDArmorySettings.Instance.targetDirectionTexture, ScaleMode.StretchToFill, true); GUI.matrix = Matrix4x4.identity; //resizing Rect resizeRect = new Rect(camWindowRect.width - 20, camWindowRect.height - 20, 20, 20); if (GUI.RepeatButton(resizeRect, "//")) { resizing = true; } if (resizing) { camImageSize += Mouse.delta.x / 4; camImageSize += Mouse.delta.y / 4; camImageSize = Mathf.Clamp(camImageSize, 360, 800); RefreshWindowSize(); } if (Input.GetMouseButtonUp(0)) { resizing = false; } }
void OnGUI() { if(weaponState == WeaponStates.Enabled && vessel && !vessel.packed && vessel.isActiveVessel && BDArmorySettings.DRAW_AIMERS && !aiControlled & !MapView.MapIsEnabled) { float size = 30; Vector3 reticlePosition; if(BDArmorySettings.AIM_ASSIST && vessel.srf_velocity.sqrMagnitude < Mathf.Pow(750,2)) { if(targetAcquired && (slaved || yawRange < 1 || maxPitch-minPitch < 1)) { reticlePosition = pointingAtPosition+fixedLeadOffset; if(!slaved) { BDGUIUtils.DrawLineBetweenWorldPositions(pointingAtPosition, reticlePosition, 2, new Color(0, 1, 0, 0.6f)); } BDGUIUtils.DrawTextureOnWorldPos(pointingAtPosition, BDArmorySettings.Instance.greenDotTexture, new Vector2(6, 6), 0); if(atprAcquired) { BDGUIUtils.DrawTextureOnWorldPos(targetPosition, BDArmorySettings.Instance.openGreenSquare, new Vector2(20, 20), 0); } } else { reticlePosition = bulletPrediction; } } else { reticlePosition = pointingAtPosition; } Texture2D texture; if(Vector3.Angle(pointingAtPosition-transform.position, finalAimTarget-transform.position) < 1f) { texture = BDArmorySettings.Instance.greenSpikedPointCircleTexture; } else { texture = BDArmorySettings.Instance.greenPointCircleTexture; } BDGUIUtils.DrawTextureOnWorldPos (reticlePosition, texture, new Vector2 (size, size), 0); if(BDArmorySettings.DRAW_DEBUG_LINES) { if(targetAcquired) { BDGUIUtils.DrawLineBetweenWorldPositions(fireTransforms[0].position, targetPosition, 2, Color.blue); } } } if(HighLogic.LoadedSceneIsEditor && BDArmorySettings.showWeaponAlignment) { DrawAlignmentIndicator(); } }