/* * Main window */ private void HandleMainWindow(int windowID) { GUIStyle _settingsToggleGroupStyle = new GUIStyle(GUI.skin.toggle); _settingsToggleGroupStyle.margin.left += 40; //save Window Position _config.MainWindowXPosition = (int)_editorMainWindow.xMin; _config.MainWindowYPosition = (int)_editorMainWindow.yMin; GUILayout.BeginVertical(); GUILayout.EndVertical(); GUILayout.BeginVertical(); if (GUILayout.Button(Constants.guiSettingsGUIContent, GUILayout.MaxWidth(160))) { _mainWindowsSettingsMode = !_mainWindowsSettingsMode; } //Settings if (_mainWindowsSettingsMode) { _editorMainWindow.height = Constants.guiMainWindowHSettingsExpanded; _settingsScrollPosition = GUILayout.BeginScrollView(_settingsScrollPosition); _config.includeAllNodes = GUILayout.Toggle(_config.includeAllNodes, Constants.guiAllNodesGUIContent); Welder.includeAllNodes = _config.includeAllNodes; _config.dontProcessMasslessParts = GUILayout.Toggle(_config.dontProcessMasslessParts, Constants.guiDontProcessMasslessPartsGUIContent); Welder.dontProcessMasslessParts = _config.dontProcessMasslessParts; _config.dataBaseAutoReload = GUILayout.Toggle(_config.dataBaseAutoReload, Constants.guiDbAutoReloadGUIContent); _config.useNamedCfgFile = GUILayout.Toggle(_config.useNamedCfgFile, Constants.guiUseNamedCfgFileGUIContent); _config.advancedDebug = GUILayout.Toggle(_config.advancedDebug, Constants.guiAdvancedDebugGUIContent); _config.clearEditor = GUILayout.Toggle(_config.clearEditor, Constants.guiClearEditorGUIContent); _config.fileSimplification = GUILayout.Toggle(_config.fileSimplification, Constants.guiFileSimplificationGUIContent); Welder.fileSimplification = _config.fileSimplification; GUILayout.Space(10.0f); GUILayout.Label(" Vector Precision: " + _config.precisionDigits); _config.precisionDigits = (int)GUILayout.HorizontalSlider(_config.precisionDigits, 1, 6); Welder.precisionDigits = _config.precisionDigits; GUILayout.Space(10.0f); GUILayout.Label("Strength params calculation method"); // _config.StrengthCalcMethod = (StrengthParamsCalcMethod)GUILayout.SelectionGrid((int)_config.StrengthCalcMethod, Constants.StrengthParamsCalcMethodsGUIContent, 1, GUILayout.MaxWidth(140)); foreach (StrengthParamsCalcMethod method in Enum.GetValues(typeof(StrengthParamsCalcMethod))) { if (GUILayout.Toggle((_config.StrengthCalcMethod == method), Constants.StrengthParamsCalcMethodsGUIContent[(int)method], _settingsToggleGroupStyle)) { _config.StrengthCalcMethod = method; Welder.StrengthCalcMethod = method; } } GUILayout.Space(10.0f); GUILayout.Label("MaxTemp calculation method"); // _config.MaxTempCalcMethod = (MaxTempCalcMethod)GUILayout.SelectionGrid((int)_config.MaxTempCalcMethod, Constants.MaxTempCalcMethodsGUIContent, 1, GUILayout.MaxWidth(140)); foreach (MaxTempCalcMethod method in Enum.GetValues(typeof(MaxTempCalcMethod))) { if (GUILayout.Toggle((_config.MaxTempCalcMethod == method), Constants.MaxTempCalcMethodsGUIContent[(int)method], _settingsToggleGroupStyle)) { _config.MaxTempCalcMethod = method; Welder.MaxTempCalcMethod = method; } } GUILayout.EndScrollView(); // GUILayout.Space(10.0f); if (GUILayout.Button(Constants.guiSaveSettingsButtonGUIContent, GUILayout.MaxWidth(160))) { FileManager.saveConfig(_config); _config = FileManager.loadConfig(); } } else { _editorMainWindow.height = Constants.guiMainWindowH; GUILayout.Space(20.0f); } //SelectPArtbranch button if (GUILayout.RepeatButton(Constants.guiSelectPartGUIContent, GUILayout.MaxWidth(160))) { this.state = DisplayState.partSelection; } //Weld button if (GUILayout.Button(Constants.guiWeldItButtonGUIContent, GUILayout.MaxWidth(160))) { FileManager.saveConfig(_config); if (EditorLockManager.isEditorLocked()) { if (_selectedPartbranch == null) { _selectedPartbranch = EditorLogic.RootPart; } repositionPreWeldment(_selectedPartbranch); weldPart(_selectedPartbranch); } } if (GUILayout.Button(Constants.guiCloseGUIContent, GUILayout.MaxWidth(160))) { closeMainwindow(); } //Hints area GUILayout.TextArea(GUI.tooltip, GUILayout.ExpandHeight(true), GUILayout.MaxHeight(100)); GUIStyle VersionLabelGUIStyle = new GUIStyle(GUI.skin.label); VersionLabelGUIStyle.fontSize = 12; GUILayout.Label(Constants.logVersion, VersionLabelGUIStyle); GUILayout.EndVertical(); GUI.DragWindow(); } //private void OnMainWindow()
// GUI private void WindowGUI(int windowID) { if (null == this.CurrentVessel) { return; } #region General GUI // General GUI window information GUIStyle mySty = new GUIStyle(GUI.skin.button); mySty.normal.textColor = mySty.focused.textColor = Color.white; mySty.hover.textColor = mySty.active.textColor = Color.yellow; mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green; mySty.padding = new RectOffset(2, 2, 2, 2); // Buoyancy -, current %, and + buttons GUILayout.BeginHorizontal(); if (GUILayout.RepeatButton("-", mySty)) { TargetBuoyantVessel -= 0.002f; ToggleAltitudeControl = false; } TargetBuoyantVessel = Mathf.Clamp01(TargetBuoyantVessel); GUILayout.Label(" " + Mathf.RoundToInt(TargetBuoyantVessel * 100) + "%"); if (GUILayout.RepeatButton("+", mySty)) { TargetBuoyantVessel += 0.002f; ToggleAltitudeControl = false; } GUILayout.EndHorizontal(); // Slider control. Also is set by the other controls. GUILayout.BeginHorizontal(); { float temp = TargetBuoyantVessel; TargetBuoyantVessel = GUILayout.HorizontalSlider(TargetBuoyantVessel, 0f, 1f); if (temp != TargetBuoyantVessel) { ToggleAltitudeControl = false; } } GUILayout.EndHorizontal(); TargetBuoyantVessel = Mathf.Clamp01(TargetBuoyantVessel); #endregion #region Toggle Altitude // Altitude control. Should be deactivated when pressing any other unrelated control. GUILayout.BeginHorizontal(); { string toggleAltitudeControlString = "Altitude Control Off"; if (ToggleAltitudeControl) { toggleAltitudeControlString = "Altitude Control On"; } ToggleAltitudeControl = GUILayout.Toggle(ToggleAltitudeControl, toggleAltitudeControlString); } GUILayout.EndHorizontal(); #endregion if (ToggleAltitudeControl) { #region Altitude Control willReset1 = true; // Vertical Velocity -, target velocity, and + buttons GUILayout.BeginHorizontal(); GUILayout.Label("Target Vertical Velocity"); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.RepeatButton("--", mySty)) { TargetVerticalVelocity -= 0.1f; } if (GUILayout.Button("-", mySty)) { TargetVerticalVelocity -= 0.1f; } if (GUILayout.Button(TargetVerticalVelocity.ToString("00.0") + " m/s", mySty)) { TargetVerticalVelocity = 0; } if (GUILayout.Button("+", mySty)) { TargetVerticalVelocity += 0.1f; } if (GUILayout.RepeatButton("++", mySty)) { TargetVerticalVelocity += 0.1f; } GUILayout.EndHorizontal(); #endregion } else { TargetVerticalVelocity = 0; if (willReset1) { resetGUIsize = true; willReset1 = false; } } if (Envelopes.Count > 1) { GUILayout.BeginHorizontal(); string toggleAutoPitchString = "Auto Pitch Off"; if (ToggleAutoPitch) { toggleAutoPitchString = "Auto Pitch On"; } ToggleAutoPitch = GUILayout.Toggle(ToggleAutoPitch, toggleAutoPitchString); GUILayout.EndHorizontal(); } if (ToggleAutoPitch) { willReset4 = true; } else { if (willReset4) { resetGUIsize = true; willReset4 = false; } } if (ToggleAutoPitch) { willReset2 = true; #if DEBUG DisplayHologram = GUILayout.Toggle(DisplayHologram, "Display Hologram at " + LineOffsetMultiplier.ToString("F1")); if (DisplayHologram) { LineOffsetMultiplier = GUILayout.HorizontalSlider(LineOffsetMultiplier, -20f, 20f); } #endif } else { DisplayHologram = false; if (willReset2) { resetGUIsize = true; willReset2 = false; } } if (AnchorPresent) { GUILayout.BeginHorizontal(); string toggleAnchor = "Anchor Inactive"; if (AnchorOn) { toggleAnchor = "Anchor Active"; } AnchorOn = GUILayout.Toggle(AnchorOn, toggleAnchor); string toggleAutoAnchor = "Auto Anchor Off"; if (AutoAnchor) { toggleAutoAnchor = "Auto Anchor On"; } AutoAnchor = GUILayout.Toggle(AutoAnchor, toggleAutoAnchor); GUILayout.EndHorizontal(); } if (resetGUIsize) { // Reset window size windowPos.Set(windowPos.x, windowPos.y, 10, 10); resetGUIsize = false; } #region Debug // Debug info GUILayout.BeginHorizontal(); GUILayout.Label("Buoyancy - Weight: " + (TotalBuoyancy - (CurrentVessel.GetTotalMass() * FlightGlobals.getGeeForceAtPosition(CurrentVessel.GetWorldPos3D()).magnitude)).ToString("0.00")); GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Angle from Up: " + (ContAngle(heading, up, up)).ToString("0.0")); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Front Torque: " + (totalTorqueP).ToString("0.0")); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Rear Torque: " + (totalTorqueN).ToString("0.0")); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Front B: " + (targetBuoyancyP).ToString("0.00")); //GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Rear B: " + (targetBuoyancyN).ToString("0.00")); //GUILayout.EndHorizontal(); #if DEBUG int x = 0; foreach (HLEnvelopePartModule envelope in Envelopes) { GUILayout.BeginHorizontal(); GUILayout.Label("Env" + x + " Location: " + (envelope.eDistanceFromCoM).ToString("0.00")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Env" + x + " Buoyancy: " + (envelope.buoyantForce.magnitude).ToString("0.00")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Env" + x + " Specific Volume: " + (envelope.specificVolumeFractionEnvelope).ToString("0.00")); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Env" + x + " targetPitchBuoyancy: " + (envelope.targetPitchBuoyancy).ToString("0.00")); GUILayout.EndHorizontal(); //GUILayout.BeginHorizontal(); //GUILayout.Label("Env" + x + " targetBoyantForceFractionCompressor: " + (envelope.targetBoyantForceFractionCompressor).ToString("0.00")); //GUILayout.EndHorizontal(); x += 1; } #endif #endregion GUI.DragWindow(new Rect(0, 0, 500, 20)); }