private void SetNewHeight(float windowHeight) { var previousWindowHeight = BDArmorySetup.WindowRectVesselSpawner.height; BDArmorySetup.WindowRectVesselSpawner.height = windowHeight; if (BDArmorySettings.STRICT_WINDOW_BOUNDARIES && windowHeight < previousWindowHeight && Mathf.RoundToInt(BDArmorySetup.WindowRectVesselSpawner.y + previousWindowHeight) == Screen.height) // Window shrunk while being at edge of screen. { BDArmorySetup.WindowRectVesselSpawner.y = Screen.height - BDArmorySetup.WindowRectVesselSpawner.height; } BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSpawner); }
private void DrawSettingsWindow(int id) { GUI.Box(new Rect(0, 0, SettingsWidth, SettingsHeight), "BDA Category Settings"); if (BDArmorySettings.SHOW_CATEGORIES != (BDArmorySettings.SHOW_CATEGORIES = BDArmorySettings.SHOW_CATEGORIES = GUI.Toggle( new Rect(SettingsMargin, SettingsLineHeight * 1.25f, SettingsWidth - (2 * SettingsMargin), SettingsLineHeight), BDArmorySettings.SHOW_CATEGORIES, "Subcategories" ))) { PartCategorizer.Instance.editorPartList.Refresh(); } if (BDArmorySettings.AUTOCATEGORIZE_PARTS != (BDArmorySettings.AUTOCATEGORIZE_PARTS = BDArmorySettings.AUTOCATEGORIZE_PARTS = GUI.Toggle( new Rect(SettingsMargin, SettingsLineHeight * 2.25f, SettingsWidth - (2 * SettingsMargin), SettingsLineHeight), BDArmorySettings.AUTOCATEGORIZE_PARTS, "Autocategorize parts" ))) { PartCategorizer.Instance.editorPartList.Refresh(); } BDGUIUtils.RepositionWindow(ref SettingsWindow); BDGUIUtils.UseMouseEventInRect(SettingsWindow); }
void WindowRcs(int windowID) { if (GUI.Button(new Rect(windowRect.width - 18, 2, 16, 16), "X")) { HideToolbarGUI(); } GUI.Label(new Rect(10, 40, 200, 20), "Frontal", BDArmorySetup.BDGuiSkin.box); GUI.Label(new Rect(220, 40, 200, 20), "Lateral", BDArmorySetup.BDGuiSkin.box); GUI.Label(new Rect(430, 40, 200, 20), "Ventral", BDArmorySetup.BDGuiSkin.box); if (takeSnapshot) { takeRadarSnapshot(); } // for each view draw the rendering with the higher cross section (normal or 45°): if (RadarUtils.rcsFrontal > RadarUtils.rcsFrontal45) { GUI.DrawTexture(new Rect(10, 70, 200, 200), RadarUtils.GetTextureFrontal, ScaleMode.StretchToFill); } else { GUI.DrawTexture(new Rect(10, 70, 200, 200), RadarUtils.GetTextureFrontal45, ScaleMode.StretchToFill); } if (RadarUtils.rcsLateral > RadarUtils.rcsLateral45) { GUI.DrawTexture(new Rect(220, 70, 200, 200), RadarUtils.GetTextureLateral, ScaleMode.StretchToFill); } else { GUI.DrawTexture(new Rect(220, 70, 200, 200), RadarUtils.GetTextureLateral45, ScaleMode.StretchToFill); } if (RadarUtils.rcsVentral > RadarUtils.rcsVentral45) { GUI.DrawTexture(new Rect(430, 70, 200, 200), RadarUtils.GetTextureVentral, ScaleMode.StretchToFill); } else { GUI.DrawTexture(new Rect(430, 70, 200, 200), RadarUtils.GetTextureVentral45, ScaleMode.StretchToFill); } GUI.Label(new Rect(10, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsFrontal, RadarUtils.rcsFrontal45)) + " m^2", BDArmorySetup.BDGuiSkin.label); GUI.Label(new Rect(220, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsLateral, RadarUtils.rcsLateral45)) + " m^2", BDArmorySetup.BDGuiSkin.label); GUI.Label(new Rect(430, 275, 200, 20), string.Format("{0:0.00}", Mathf.Max(RadarUtils.rcsVentral, RadarUtils.rcsVentral45)) + " m^2", BDArmorySetup.BDGuiSkin.label); GUIStyle style = BDArmorySetup.BDGuiSkin.label; style.fontStyle = FontStyle.Bold; GUI.Label(new Rect(10, 300, 600, 20), "Base radar cross section for vessel: " + string.Format("{0:0.00} m^2 (without ECM/countermeasures)", RadarUtils.rcsTotal), style); GUI.Label(new Rect(10, 320, 600, 20), "Total radar cross section for vessel: " + string.Format("{0:0.00} m^2 (with RCS reduction/stealth/ground clutter)", RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF), style); style.fontStyle = FontStyle.Normal; GUI.Label(new Rect(10, 380, 600, 20), "** (Range evaluation not accounting for ECM/countermeasures)", style); GUI.Label(new Rect(10, 410, 600, 20), text_detection, style); GUI.Label(new Rect(10, 430, 600, 20), text_locktrack, style); GUI.Label(new Rect(10, 450, 600, 20), text_sonar, style); bool bNewValue = GUI.Toggle(new Rect(490, 348, 150, 20), bLandedSplashed, "Splashed/Landed", BDArmorySetup.BDGuiSkin.toggle); if (radars == null) { FillRadarList(); GUIStyle listStyle = new GUIStyle(BDArmorySetup.BDGuiSkin.button); listStyle.fixedHeight = 18; //make list contents slightly smaller radarBox = new BDGUIComboBox(new Rect(10, 350, 600, 20), new Rect(10, 350, 250, 20), radarBoxText, radarsGUI, 124, listStyle); } int selected_index = radarBox.Show(); if ((selected_index != previous_index) || (bNewValue != bLandedSplashed)) { text_sonar = ""; bLandedSplashed = bNewValue; // selected radar changed - evaluate craft RCS against this radar if (selected_index != -1) { var selected_radar = radars[selected_index]; // ground clutter factor from radar if (bLandedSplashed) { rcsGCF = selected_radar.radarGroundClutterFactor; } else { rcsGCF = 1.0f; } if (selected_radar.canScan) { for (float distance = selected_radar.radarMaxDistanceDetect; distance >= 0; distance--) { text_detection = $"Detection: undetectable by this radar."; if (selected_radar.radarDetectionCurve.Evaluate(distance) <= (RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF)) { text_detection = $"Detection: detected at {distance} km and closer"; break; } } } else { text_detection = "Detection: This radar does not have detection capabilities."; } if (selected_radar.canLock) { text_locktrack = $"Lock/Track: untrackable by this radar."; for (float distance = selected_radar.radarMaxDistanceLockTrack; distance >= 0; distance--) { if (selected_radar.radarLockTrackCurve.Evaluate(distance) <= (RadarUtils.rcsTotal * rcsReductionFactor * rcsGCF)) { text_locktrack = $"Lock/Track: tracked at {distance} km and closer"; break; } } } else { text_locktrack = "Lock/Track: This radar does not have locking/tracking capabilities."; } if (selected_radar.getRWRType(selected_radar.rwrThreatType) == "SONAR") { text_sonar = "SONAR - will only be able to detect/track splashed or submerged vessels!"; } } } previous_index = selected_index; GUI.DragWindow(); BDGUIUtils.RepositionWindow(ref windowRect); }
private void WindowRemoteOrchestration(int id) { GUI.DragWindow(new Rect(0, 0, BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH - _titleHeight / 2 - 2, _titleHeight)); if (GUI.Button(new Rect(BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH - _titleHeight / 2 - 2, 2, _titleHeight / 2, _titleHeight / 2), "X", BDArmorySetup.BDGuiSkin.button)) { showWindow = false; } float offset = _titleHeight + _margin; float width = BDArmorySettings.REMOTE_ORCHESTRATION_WINDOW_WIDTH; float fifth = width / 5.0f; GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Competition: "); GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), competition); offset += _titleHeight; GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Status: "); string statusLine; switch (service.status) { case BDAScoreService.StatusType.Waiting: statusLine = status + " " + (30 + service.retryFindStartedAt - Planetarium.GetUniversalTime()).ToString("0") + "s"; break; default: statusLine = status; break; } GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), statusLine); offset += _titleHeight; GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Stage: "); GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), stage); offset += _titleHeight; GUI.Label(new Rect(_margin, offset, 2 * fifth, _titleHeight), "Heat: "); GUI.Label(new Rect(_margin + 2 * fifth, offset, 3 * fifth, _titleHeight), heat); offset += _titleHeight; string buttonText; bool nextButton = false; switch (BDAScoreService.Instance.status) { case BDAScoreService.StatusType.Waiting: buttonText = "Stop"; nextButton = true; break; case BDAScoreService.StatusType.Stopped: case BDAScoreService.StatusType.Cancelled: buttonText = "Next Heat"; break; default: buttonText = "Cancel"; break; } if (GUI.Button(new Rect(_margin, offset, nextButton ? 2 * width / 3 - _margin : width - 2 * _margin, _titleHeight), buttonText, BDArmorySetup.BDGuiSkin.button)) { switch (BDAScoreService.Instance.status) { case BDAScoreService.StatusType.Stopped: case BDAScoreService.StatusType.Cancelled: service.Configure(service.vesselPath, BDArmorySettings.COMPETITION_HASH); break; default: service.Cancel(); break; } } if (nextButton && GUI.Button(new Rect(2 * width / 3, offset, width / 3 - _margin, _titleHeight), "Next", BDArmorySetup.BDGuiSkin.button)) { BDAScoreService.Instance.retryFindStartedAt = -1; } offset += _titleHeight + _margin; _windowHeight = offset; BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectRemoteOrchestration); // Prevent it from going off the screen edges. }
private void WindowVesselSwitcher(int id) { GUI.DragWindow(new Rect(0, 0, _windowWidth - _buttonHeight - 4, _titleHeight)); if (GUI.Button(new Rect(_windowWidth - _buttonHeight - 4, 4, _buttonHeight, _buttonHeight), "X", BDArmorySetup.BDGuiSkin.button)) { BDArmorySetup.Instance.showVSGUI = false; return; } float height = _titleHeight; float vesselButtonWidth = _windowWidth - 2 * _margin - 3 * _buttonHeight; using (var teamManagers = weaponManagers.GetEnumerator()) while (teamManagers.MoveNext()) { height += _margin; GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), $"{teamManagers.Current.Key}:", BDArmorySetup.BDGuiSkin.label); height += _buttonHeight; using (var wm = teamManagers.Current.Value.GetEnumerator()) while (wm.MoveNext()) { if (wm.Current == null) { continue; } Rect buttonRect = new Rect(_margin, height, vesselButtonWidth, _buttonHeight); GUIStyle vButtonStyle = wm.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; string status = UpdateVesselStatus(wm.Current, vButtonStyle); if (GUI.Button(buttonRect, status + wm.Current.vessel.GetName(), vButtonStyle)) { ForceSwitchVessel(wm.Current.vessel); } //guard toggle GUIStyle guardStyle = wm.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect guardButtonRect = new Rect(_margin + vesselButtonWidth, height, _buttonHeight, _buttonHeight); if (GUI.Button(guardButtonRect, "G", guardStyle)) { wm.Current.ToggleGuardMode(); } //AI toggle if (wm.Current.AI != null) { GUIStyle aiStyle = wm.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect aiButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, height, _buttonHeight, _buttonHeight); if (GUI.Button(aiButtonRect, "P", aiStyle)) { wm.Current.AI.TogglePilot(); } } //team toggle Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight * 2, height, _buttonHeight, _buttonHeight); if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button)) { if (Event.current.button == 1) { BDTeamSelector.Instance.Open(wm.Current, new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)); } else { _wmToSwitchTeam = wm.Current; _teamSwitchDirty = true; } } height += _buttonHeight + _buttonGap; } } height += _margin; _windowHeight = height; BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher); }
private void TeamSelectorWindow(int id) { height = margin; // Team input field newTeamName = GUI.TextField(new Rect(margin, margin, width - buttonGap - 2 * margin - newTeanButtonWidth, buttonHeight), newTeamName, 30); // New team button Rect newTeamButtonRect = new Rect(width - margin - newTeanButtonWidth, height, newTeanButtonWidth, buttonHeight); if (GUI.Button(newTeamButtonRect, Localizer.Format("#LOC_BDArmory_Generic_New"), BDArmorySetup.BDGuiSkin.button))//"New" { if (!string.IsNullOrEmpty(newTeamName.Trim())) { targetWeaponManager.SetTeam(BDTeam.Get(newTeamName.Trim())); open = false; } } height += buttonHeight; // Scrollable list of existing teams scrollable = (BDArmorySetup.Instance.Teams.Count * (buttonHeight + buttonGap) * 2 > Screen.height); if (scrollable) { scrollPosition = GUI.BeginScrollView( new Rect(margin, height, width - margin * 2 + scrollWidth, Screen.height / 2), scrollPosition, new Rect(margin, height, width - margin * 2, BDArmorySetup.Instance.Teams.Count * (buttonHeight + buttonGap)), false, true); } using (var teams = BDArmorySetup.Instance.Teams.Values.GetEnumerator()) while (teams.MoveNext()) { if (teams.Current == null || !teams.Current.Name.ToLowerInvariant().StartsWith(newTeamName.ToLowerInvariant().Trim())) { continue; } height += buttonGap; Rect buttonRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle buttonStyle = (teams.Current == targetWeaponManager.Team) ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(buttonRect, teams.Current.Name, buttonStyle)) { targetWeaponManager.SetTeam(teams.Current); open = false; } height += buttonHeight; } if (scrollable) { GUI.EndScrollView(); } // Buttons if (Event.current.type == EventType.KeyUp) { if ((Event.current.keyCode == KeyCode.Return || Event.current.keyCode == KeyCode.KeypadEnter) && !string.IsNullOrEmpty(newTeamName.Trim())) { targetWeaponManager.SetTeam(BDTeam.Get(newTeamName.Trim())); open = false; } else if (Event.current.keyCode == KeyCode.Escape) { open = false; } } height += margin; BDGUIUtils.RepositionWindow(ref window); BDGUIUtils.UseMouseEventInRect(window); }
private void WindowVesselSwitcher(int id) { GUI.DragWindow(new Rect(0, 0, _windowWidth - 4 * (_buttonHeight) - _margin, _titleHeight)); // enablge guard mode for all pilots if (GUI.Button(new Rect(_windowWidth - 4 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "G", _guardModeEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button)) { // switch everyon onto different teams ToggleGuardModes(); } // enable autopilot for all if (GUI.Button(new Rect(_windowWidth - 3 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "P", _autoPilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button)) { // Toggle autopilots for everyone ToggleAutopilots(); } // toggle between FFA and putting everyone on the same team if (GUI.Button(new Rect(_windowWidth - 2 * (_buttonHeight) - _margin, 4, _buttonHeight, _buttonHeight), "T", _freeForAll ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button)) { // switch everyon onto different teams _teamSwitchDirty = true; _wmToSwitchTeam = null; } // close the window if (GUI.Button(new Rect(_windowWidth - _buttonHeight - _margin, 4, _buttonHeight, _buttonHeight), "X", BDArmorySetup.BDGuiSkin.button)) { BDArmorySetup.Instance.showVSGUI = false; return; } float height = _titleHeight; float vesselButtonWidth = _windowWidth - 2 * _margin - 6 * _buttonHeight; using (var teamManagers = weaponManagers.GetEnumerator()) while (teamManagers.MoveNext()) { height += _margin; using (var wm = teamManagers.Current.Value.GetEnumerator()) while (wm.MoveNext()) { if (wm.Current == null) { continue; } // team at the start of the line GUI.Label(new Rect(_margin, height, _buttonHeight, _buttonHeight), $"{teamManagers.Current.Key}:", BDArmorySetup.BDGuiSkin.label); Rect buttonRect = new Rect(_margin + _buttonHeight, height, vesselButtonWidth, _buttonHeight); GUIStyle vButtonStyle = wm.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; // current target string targetName = ""; Vessel targetVessel = wm.Current.vessel; bool incomingThreat = false; if (wm.Current.incomingThreatVessel != null) { incomingThreat = true; targetName = "<<<" + wm.Current.incomingThreatVessel.GetName(); targetVessel = wm.Current.incomingThreatVessel; } else if (wm.Current.currentTarget) { targetName = ">>>" + wm.Current.currentTarget.Vessel.GetName(); targetVessel = wm.Current.currentTarget.Vessel; } string status = UpdateVesselStatus(wm.Current, vButtonStyle); string vesselName = wm.Current.vessel.GetName(); string postStatus = ""; if (wm.Current.AI != null && wm.Current.AI.currentStatus != null) { postStatus += " " + wm.Current.AI.currentStatus; } float targetDistance = 5000; if (wm.Current.currentTarget != null) { targetDistance = Vector3.Distance(wm.Current.vessel.GetWorldPos3D(), wm.Current.currentTarget.position); } if (targetName != "") { postStatus += " " + targetName; } if (GUI.Button(buttonRect, status + vesselName + postStatus, vButtonStyle)) { ForceSwitchVessel(wm.Current.vessel); } // selects current target if (targetName != "") { Rect targettingButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, height, _buttonHeight, _buttonHeight); GUIStyle targButton = BDArmorySetup.BDGuiSkin.button; if (wm.Current.currentGun != null && wm.Current.currentGun.recentlyFiring) { if (targetDistance < 500) { targButton = redLight; } else if (targetDistance < 1000) { targButton = yellowLight; } else { targButton = blueLight; } } if (GUI.Button(targettingButtonRect, incomingThreat ? "><" : "[]", targButton)) { ForceSwitchVessel(targetVessel); } } //guard toggle GUIStyle guardStyle = wm.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect guardButtonRect = new Rect(_margin + vesselButtonWidth + 2 * _buttonHeight, height, _buttonHeight, _buttonHeight); if (GUI.Button(guardButtonRect, "G", guardStyle)) { wm.Current.ToggleGuardMode(); } //AI toggle if (wm.Current.AI != null) { GUIStyle aiStyle = new GUIStyle(wm.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button); if (wm.Current.underFire) { var distance = Vector3.Distance(wm.Current.vessel.GetWorldPos3D(), wm.Current.incomingThreatPosition); if (distance < 500) { aiStyle.normal.textColor = Color.red; } else if (distance < 1000) { aiStyle.normal.textColor = Color.yellow; } else { aiStyle.normal.textColor = Color.blue; } } Rect aiButtonRect = new Rect(_margin + vesselButtonWidth + 3 * _buttonHeight, height, _buttonHeight, _buttonHeight); if (GUI.Button(aiButtonRect, "P", aiStyle)) { wm.Current.AI.TogglePilot(); } } //team toggle Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + 4 * _buttonHeight, height, _buttonHeight, _buttonHeight); if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button)) { if (Event.current.button == 1) { BDTeamSelector.Instance.Open(wm.Current, new Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y)); } else { _wmToSwitchTeam = wm.Current; _teamSwitchDirty = true; } } // boom Rect killButtonRect = new Rect(_margin + vesselButtonWidth + 5 * _buttonHeight, height, _buttonHeight, _buttonHeight); if (GUI.Button(killButtonRect, "X", BDArmorySetup.BDGuiSkin.button)) { // must use right button if (Event.current.button == 1) { Misc.Misc.ForceDeadVessel(wm.Current.vessel); } } height += _buttonHeight + _buttonGap; } } height += _margin; _windowHeight = height; BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher); }
private void TargetingSelectorWindow(int id) { height = margin; GUIStyle labelStyle = BDArmorySetup.BDGuiSkin.label; GUI.Label(new Rect(margin, height, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Selecttargeting"), labelStyle); if (GUI.Button(new Rect(width - 18, 2, 16, 16), "X")) { open = false; } height += buttonHeight; height += buttonGap; Rect CoMRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle CoMStyle = targetWeaponManager.targetCoM ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(CoMRect, Localizer.Format("#LOC_BDArmory_TargetCOM"), CoMStyle)) { targetWeaponManager.targetCoM = !targetWeaponManager.targetCoM; if (targetWeaponManager.targetCoM) { targetWeaponManager.targetWeapon = false; targetWeaponManager.targetEngine = false; targetWeaponManager.targetCommand = false; targetWeaponManager.targetMass = false; } if (!targetWeaponManager.targetCoM && (!targetWeaponManager.targetWeapon && !targetWeaponManager.targetEngine && !targetWeaponManager.targetCommand && !targetWeaponManager.targetMass)) { targetWeaponManager.targetMass = true; } } height += buttonHeight; height += buttonGap; Rect MassRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle MassStyle = targetWeaponManager.targetMass ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(MassRect, Localizer.Format("#LOC_BDArmory_Mass"), MassStyle)) { targetWeaponManager.targetMass = !targetWeaponManager.targetMass; if (targetWeaponManager.targetMass) { targetWeaponManager.targetCoM = false; } if (!targetWeaponManager.targetCoM && (!targetWeaponManager.targetWeapon && !targetWeaponManager.targetEngine && !targetWeaponManager.targetCommand && !targetWeaponManager.targetMass)) { targetWeaponManager.targetCoM = true; } } height += buttonHeight; height += buttonGap; Rect CommandRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle CommandStyle = targetWeaponManager.targetCommand ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(CommandRect, Localizer.Format("#LOC_BDArmory_Command"), CommandStyle)) { targetWeaponManager.targetCommand = !targetWeaponManager.targetCommand; if (targetWeaponManager.targetCommand) { targetWeaponManager.targetCoM = false; } } height += buttonHeight; height += buttonGap; Rect EngineRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle EngineStyle = targetWeaponManager.targetEngine ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(EngineRect, Localizer.Format("#LOC_BDArmory_Engines"), EngineStyle)) { targetWeaponManager.targetEngine = !targetWeaponManager.targetEngine; if (targetWeaponManager.targetEngine) { targetWeaponManager.targetCoM = false; } } height += buttonHeight; height += buttonGap; Rect weaponRect = new Rect(margin, height, width - 2 * margin, buttonHeight); GUIStyle WepStyle = targetWeaponManager.targetWeapon ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; if (GUI.Button(weaponRect, Localizer.Format("#LOC_BDArmory_Weapons"), WepStyle)) { targetWeaponManager.targetWeapon = !targetWeaponManager.targetWeapon; if (targetWeaponManager.targetWeapon) { targetWeaponManager.targetCoM = false; } } height += buttonHeight; height += margin; targetWeaponManager.targetingString = (targetWeaponManager.targetCoM ? Localizer.Format("#LOC_BDArmory_TargetCOM") + "; " : "") + (targetWeaponManager.targetMass ? Localizer.Format("#LOC_BDArmory_Mass") + "; " : "") + (targetWeaponManager.targetCommand ? Localizer.Format("#LOC_BDArmory_Command") + "; " : "") + (targetWeaponManager.targetEngine ? Localizer.Format("#LOC_BDArmory_Engines") + "; " : "") + (targetWeaponManager.targetWeapon ? Localizer.Format("#LOC_BDArmory_Weapons") + "; " : ""); BDGUIUtils.RepositionWindow(ref window); BDGUIUtils.UseMouseEventInRect(window); }
private void AmmoSelectorWindow(int id) { float line = 0.5f; string labelString = GUIstring.ToString() + countString.ToString(); GUIStyle labelStyle = BDArmorySetup.BDGuiSkin.label; GUI.Label(new Rect(margin, 0.5f * buttonHeight, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Ammo_Setup"), labelStyle); if (GUI.Button(new Rect(width - 18, 2, 16, 16), "X")) { open = false; } line++; GUI.Label(new Rect(margin, line * buttonHeight, width - 2 * margin, buttonHeight), Localizer.Format("#LOC_BDArmory_Ammo_Belt"), labelStyle); line += 1.2f; GUI.Label(new Rect(margin, line * buttonHeight, width - 2 * margin, buttonHeight * labelLines), labelString, labelStyle); line++; labelLines = Mathf.CeilToInt((GUIstring.Length / 50)); float ammolines = 0.1f; for (int i = 0; i < AList.Count; i++) { string ammoname = AList[i]; if (GUI.Button(new Rect(margin * 2, (line + labelLines + ammolines) * buttonHeight, (width - 4 * margin), buttonHeight), ammoname, BDArmorySetup.BDGuiSkin.button)) { beltString += ammoname; beltString += "; "; if (lastGUIstring != ammoname) { GUIstring += countString.ToString(); GUIstring += ammoname; lastGUIstring = ammoname; roundCounter = 1; countString = "; "; } else { roundCounter++; countString = " X" + roundCounter + "; "; } } ammolines++; if (ammoDesc[i] != null) { GUI.Label(new Rect(margin * 4, (line + labelLines + ammolines) * buttonHeight, (width - 8 * margin), buttonHeight), ammoDesc[i], labelStyle); ammolines += 1.1f; } } if (GUI.Button(new Rect(margin * 5, (line + labelLines + ammolines) * buttonHeight, (width - (10 * margin)) / 2, buttonHeight), Localizer.Format("#LOC_BDArmory_reset"))) { beltString = String.Empty; GUIstring = String.Empty; countString = String.Empty; labelLines = 1; } if (GUI.Button(new Rect(((margin * 5) + ((width - (10 * margin)) / 2)), (line + labelLines + ammolines) * buttonHeight, (width - (10 * margin)) / 2, buttonHeight), Localizer.Format("#LOC_BDArmory_save"))) { save = true; open = false; } line += 1.5f; height = Mathf.Lerp(height, (line + labelLines + ammolines) * buttonHeight, 0.15f); windowRect.height = height; GUI.DragWindow(); BDGUIUtils.RepositionWindow(ref windowRect); }
private void WindowVesselSwitcher(int id) { GUI.DragWindow(new Rect(0, 0, _windowWidth - _buttonHeight - 4, _titleHeight)); if (GUI.Button(new Rect(_windowWidth - _buttonHeight - 4, 4, _buttonHeight, _buttonHeight), "X", BDArmorySetup.BDGuiSkin.button)) { BDArmorySetup.Instance.showVSGUI = false; return; } float height = 0; float vesselLineA = 0; float vesselLineB = 0; height += _margin + _titleHeight; GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), "Team A:", BDArmorySetup.BDGuiSkin.label); height += _buttonHeight; float vesselButtonWidth = _windowWidth - 2 * _margin; vesselButtonWidth -= 3 * _buttonHeight; List <MissileFire> .Enumerator wma = _wmgrsA.GetEnumerator(); while (wma.MoveNext()) { if (wma.Current == null) { continue; } float lineY = height + vesselLineA * (_buttonHeight + _buttonGap); Rect buttonRect = new Rect(_margin, lineY, vesselButtonWidth, _buttonHeight); GUIStyle vButtonStyle = wma.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; string status = UpdateVesselStatus(wma.Current, vButtonStyle); if (GUI.Button(buttonRect, status + wma.Current.vessel.GetName(), vButtonStyle)) { ForceSwitchVessel(wma.Current.vessel); } //guard toggle GUIStyle guardStyle = wma.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect guardButtonRect = new Rect(_margin + vesselButtonWidth, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(guardButtonRect, "G", guardStyle)) { wma.Current.ToggleGuardMode(); } //AI toggle if (wma.Current.AI != null) { GUIStyle aiStyle = wma.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect aiButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(aiButtonRect, "P", aiStyle)) { wma.Current.AI.TogglePilot(); } } //team toggle Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight + _buttonHeight, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button)) { _wmToSwitchTeam = wma.Current; _teamSwitchDirty = true; } vesselLineA++; } wma.Dispose(); height += vesselLineA * (_buttonHeight + _buttonGap); height += _margin; GUI.Label(new Rect(_margin, height, _windowWidth - 2 * _margin, _buttonHeight), "Team B:", BDArmorySetup.BDGuiSkin.label); height += _buttonHeight; List <MissileFire> .Enumerator wmb = _wmgrsB.GetEnumerator(); while (wmb.MoveNext()) { if (wmb.Current == null) { continue; } float lineY = height + vesselLineB * (_buttonHeight + _buttonGap); Rect buttonRect = new Rect(_margin, lineY, vesselButtonWidth, _buttonHeight); GUIStyle vButtonStyle = wmb.Current.vessel.isActiveVessel ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; string status = UpdateVesselStatus(wmb.Current, vButtonStyle); if (GUI.Button(buttonRect, status + wmb.Current.vessel.GetName(), vButtonStyle)) { ForceSwitchVessel(wmb.Current.vessel); } //guard toggle GUIStyle guardStyle = wmb.Current.guardMode ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect guardButtonRect = new Rect(_margin + vesselButtonWidth, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(guardButtonRect, "G", guardStyle)) { wmb.Current.ToggleGuardMode(); } //AI toggle if (wmb.Current.AI != null) { GUIStyle aiStyle = wmb.Current.AI.pilotEnabled ? BDArmorySetup.BDGuiSkin.box : BDArmorySetup.BDGuiSkin.button; Rect aiButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(aiButtonRect, "P", aiStyle)) { wmb.Current.AI.TogglePilot(); } } //team toggle Rect teamButtonRect = new Rect(_margin + vesselButtonWidth + _buttonHeight + _buttonHeight, lineY, _buttonHeight, _buttonHeight); if (GUI.Button(teamButtonRect, "T", BDArmorySetup.BDGuiSkin.button)) { _wmToSwitchTeam = wmb.Current; _teamSwitchDirty = true; } vesselLineB++; } height += vesselLineB * (_buttonHeight + _buttonGap); height += _margin; _windowHeight = height; BDGUIUtils.RepositionWindow(ref BDArmorySetup.WindowRectVesselSwitcher); }