private void drawSetting() { Settings.ChangeVesselType = GUILayout.Toggle(Settings.ChangeVesselType, "change vessel type", buttonStyle, GUILayout.Width(200), GUILayout.Height(20)); // volume GUILayout.Label(String.Format("Volume: {0}%", Math.Round(Settings.Volume * 100.0f))); Settings.Volume = (float)Math.Round(GUILayout.HorizontalSlider(Settings.Volume, 0.0f, 1.0f), 2); // Use Captions Settings.UseCaption = GUILayout.Toggle(Settings.UseCaption, "Screen Captions", toggleStyle); switch (Gpws.ActiveVesselType) { case SimpleTypes.VesselType.PLANE: drawPlaneSetting(); break; case SimpleTypes.VesselType.LANDER: drawLanderSetting(); break; default: break; } // save if (GUILayout.Button("Save", buttonStyle, GUILayout.Width(200), GUILayout.Height(30))) { float newFloat; if (float.TryParse(tooLowGearAltitudeString, out newFloat)) { planeConfig.TooLowGearAltitude = newFloat; } if (float.TryParse(touchDownSpeedString, out newFloat)) { landerConfig.TouchDownSpeed = newFloat; } if (float.TryParse(horizontalSpeedCheckAltitudeString, out newFloat)) { landerConfig.HorizontalSpeedCheckAltitude = newFloat; } // save Settings.SaveSettings(); Settings.SaveCurrentVesselConfig(FlightGlobals.ActiveVessel); } }
private void drawLanderSetting() { landerConfig.EnableSystem = GUILayout.Toggle(landerConfig.EnableSystem, "System Enable", toggleStyle); // descent rate landerConfig.EnableDescentRate = GUILayout.Toggle(landerConfig.EnableDescentRate, "Descent Rate", toggleStyle); GUILayout.Label(String.Format("Safety Factor: {0}", landerConfig.DescentRateSafetyFactor)); landerConfig.DescentRateSafetyFactor = (float)Math.Round(GUILayout.HorizontalSlider(landerConfig.DescentRateSafetyFactor, 1.0f, 4.0f), 1); GUILayout.BeginHorizontal(); { GUILayout.Label("Final Speed"); GUILayout.FlexibleSpace(); touchDownSpeedString = GUILayout.TextField(touchDownSpeedString, GUILayout.Height(30), GUILayout.Width(80)); GUILayout.Label(Util.GetShortString(landerConfig.UnitOfAltitude) + "/s"); } GUILayout.EndHorizontal(); // horizontal speed landerConfig.EnableHorizontalSpeed = GUILayout.Toggle(landerConfig.EnableHorizontalSpeed, "Horizontal Speed", toggleStyle); GUILayout.BeginHorizontal(); { GUILayout.Label("vh Check Alt"); GUILayout.FlexibleSpace(); horizontalSpeedCheckAltitudeString = GUILayout.TextField(horizontalSpeedCheckAltitudeString, GUILayout.Height(30), GUILayout.Width(80)); GUILayout.Label(Util.GetShortString(landerConfig.UnitOfAltitude)); } GUILayout.EndHorizontal(); GUILayout.Label(String.Format("Horizontal Speed Factor: {0}", landerConfig.HorizontalSpeedFactor)); landerConfig.HorizontalSpeedFactor = (float)Math.Round(GUILayout.HorizontalSlider(landerConfig.HorizontalSpeedFactor, 0.01f, 1.0f), 2); // altitude landerConfig.EnableAltitudeCallouts = GUILayout.Toggle(landerConfig.EnableAltitudeCallouts, "Altitude Callouts", toggleStyle); // retard landerConfig.EnableRetard = GUILayout.Toggle(landerConfig.EnableRetard, "Retard", toggleStyle); }
public void MotionDetectorWindow(int id) { if (GUI.Button(new Rect(windowRect.size.x - 22, 2, 20, 20), "X")) { CloseGUI(); } GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(5f); if (GUILayout.Button("ON")) { SetMotionDetectorEnabled(true); ToggleMeshRenderer(true); Events ["SetMotionDetector"].guiName = "Motion Detector : ON"; } GUILayout.Space(15f); if (GUILayout.Button("OFF")) { SetMotionDetectorEnabled(false); ToggleMeshRenderer(false); Events ["SetMotionDetector"].guiName = "Motion Detector : OFF"; } GUILayout.Space(5f); GUILayout.EndHorizontal(); GUILayout.Label("Range : " + rangeNew.ToString("n0") + "m"); rangeNew = GUILayout.HorizontalSlider(rangeNew, 1f, 25f); GUILayout.Label("Timer : " + timerNew.ToString("n0") + "s"); timerNew = GUILayout.HorizontalSlider(timerNew, 1f, 60f); applyToSymPartNew = GUILayout.Toggle(applyToSymPartNew, "Symmetry"); GUILayout.EndVertical(); }
/* * 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()
private void drawPlaneSetting() { planeConfig.EnableSystem = GUILayout.Toggle(planeConfig.EnableSystem, "System Enable", toggleStyle); // descent rate config planeConfig.EnableDescentRate = GUILayout.Toggle(planeConfig.EnableDescentRate, "Descent Rate", toggleStyle); planeConfig.EnableClosureToTerrain = GUILayout.Toggle(planeConfig.EnableClosureToTerrain, "Closure to Terrain", toggleStyle); GUILayout.Label(String.Format("Descent Rate Factor: {0}", planeConfig.DescentRateFactor)); descentRateFactorExp = GUILayout.HorizontalSlider(descentRateFactorExp, -1.0f, 1.0f); planeConfig.DescentRateFactor = (float)Math.Round(Math.Pow(10, descentRateFactorExp), 1); // altitude loss planeConfig.EnableAltitudeLoss = GUILayout.Toggle(planeConfig.EnableAltitudeLoss, "Altitude Loss After Takeoff", toggleStyle); // terrain clearance planeConfig.EnableTerrainClearance = GUILayout.Toggle(planeConfig.EnableTerrainClearance, "Terrain Clearance", toggleStyle); GUILayout.BeginHorizontal(); { GUILayout.Label("Gear Alt"); GUILayout.FlexibleSpace(); tooLowGearAltitudeString = GUILayout.TextField(tooLowGearAltitudeString, GUILayout.Height(30), GUILayout.Width(80)); GUILayout.Label(Util.GetShortString(planeConfig.UnitOfAltitude)); } GUILayout.EndHorizontal(); // altitude planeConfig.EnableAltitudeCallouts = GUILayout.Toggle(planeConfig.EnableAltitudeCallouts, "Altitude Callouts", toggleStyle); // retard planeConfig.EnableRetard = GUILayout.Toggle(planeConfig.EnableRetard, "Retard", toggleStyle); // bank angle planeConfig.EnableTraffic = GUILayout.Toggle(planeConfig.EnableTraffic, "Traffic", toggleStyle); // traffic planeConfig.EnableBankAngle = GUILayout.Toggle(planeConfig.EnableBankAngle, "Bank Angle", toggleStyle); // v1 planeConfig.EnableV1 = GUILayout.Toggle(planeConfig.EnableV1, "V1", toggleStyle); // rotate planeConfig.EnableRotate = GUILayout.Toggle(planeConfig.EnableRotate, "Rotate", toggleStyle); // gear up planeConfig.EnableGearUp = GUILayout.Toggle(planeConfig.EnableGearUp, "Gear Up", toggleStyle); // stall GUILayout.BeginHorizontal(); { planeConfig.EnableStall = GUILayout.Toggle(planeConfig.EnableStall, "Stall", toggleStyle); GUILayout.Space(50); planeConfig.EnableStallShake = GUILayout.Toggle(planeConfig.EnableStallShake, "Shake", toggleStyle); } GUILayout.EndHorizontal(); GUILayout.Label(String.Format("Max AOA: {0} deg", planeConfig.StallAoa)); planeConfig.StallAoa = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.StallAoa, 0.0f, 180.0f), 0); // take off speed GUILayout.Label(String.Format("V1 Speed: {0} m/s", planeConfig.V1Speed)); planeConfig.V1Speed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.V1Speed, 10.0f, 200.0f), 0); GUILayout.Label(String.Format("Take Off Speed: {0} m/s", planeConfig.TakeOffSpeed)); planeConfig.TakeOffSpeed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.TakeOffSpeed, 10.0f, 200.0f), 0); // landing speed GUILayout.Label(String.Format("Landing Speed: {0} m/s", planeConfig.LandingSpeed)); planeConfig.LandingSpeed = (float)Math.Round(GUILayout.HorizontalSlider(planeConfig.LandingSpeed, 10.0f, 200.0f), 0); }
// 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)); }
void OnWindowGUI(int id) { GUI.skin = HighLogic.Skin; Historian historian = Historian.Instance; // column one using (GUILayout.AreaScope columnOne = new GUILayout.AreaScope(new Rect(15, 20, 380, 550))) { using (GUILayout.VerticalScope col = new GUILayout.VerticalScope()) { GUILayout.Space(20); historian.Suppressed = GUILayout.Toggle(historian.Suppressed, Localizer.GetStringByTag("#Historian_Suppressed")); historian.AlwaysActive = GUILayout.Toggle(historian.AlwaysActive, Localizer.GetStringByTag("#Historian_AlwaysActive")); historian.AutoHideUI = GUILayout.Toggle(historian.AutoHideUI, Localizer.GetStringByTag("#Historian_AutoHideUI")); Configuration.Instance.AutoHideUI = historian.AutoHideUI; Configuration.Instance.PersistentConfigurationWindow = GUILayout.Toggle(Configuration.Instance.PersistentConfigurationWindow, Localizer.GetStringByTag("#Historian_AlwaysShowConfigWindow")); Configuration.Instance.EnableLauncherButton = GUILayout.Toggle(Configuration.Instance.EnableLauncherButton, Localizer.GetStringByTag("#Historian_UseAppLauncher")); Configuration.Instance.EnableToolbarButton = GUILayout.Toggle(Configuration.Instance.EnableToolbarButton, Localizer.GetStringByTag("#Historian_UseToolbar")); GUILayout.Space(10); using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope()) { int rightClickOptionsCount = 4; //GUILayout.Space(40); GUILayout.Label(Localizer.GetStringByTag("#Historian_RightClickAction")); GUILayout.Space(10); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction - 1, 0, rightClickOptionsCount - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { Configuration.Instance.RightClickAction = (RightClickAction)Mathf.Clamp((int)Configuration.Instance.RightClickAction + 1, 0, rightClickOptionsCount - 1); } GUILayout.Space(5); GUILayout.Label(Configuration.Instance.RightClickAction.ToString(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } ManageButtons(); GUILayout.Space(10); using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_Layout")); GUILayout.Space(10); string[] layouts = historian.GetLayoutNames(); if (GUILayout.Button(previousButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex - 1, 0, layouts.Length - 1); } else if (GUILayout.Button(nextButtonTexture, GUILayout.Width(20), GUILayout.Height(GUI.skin.label.lineHeight))) { historian.CurrentLayoutIndex = Mathf.Clamp(historian.CurrentLayoutIndex + 1, 0, layouts.Length - 1); } GUILayout.Space(5); GUILayout.Label(historian.GetCurrentLayoutName(), GUI.skin.textArea, GUILayout.ExpandWidth(true)); } GUILayout.Space(10); using (GUILayout.HorizontalScope customHead = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_CustomText")); GUILayout.FlexibleSpace(); Configuration.Instance.PersistentCustomText = GUILayout.Toggle(Configuration.Instance.PersistentCustomText, Localizer.GetStringByTag("#Historian_Persistent"), GUILayout.Width(120)); } Configuration.Instance.CustomText = GUILayout.TextArea(Configuration.Instance.CustomText, GUI.skin.textArea, GUILayout.Height(60)); GUILayout.Space(10); using (GUILayout.HorizontalScope spaceCentre = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultSpaceCenterLabel")); GUILayout.FlexibleSpace(); Configuration.Instance.DefaultSpaceCenterName = GUILayout.TextField(Configuration.Instance.DefaultSpaceCenterName, GUI.skin.textArea, GUILayout.Width(150)); } GUILayout.Space(10); GUILayout.Label($"{Localizer.GetStringByTag("#Historian_LastActionTime")}: {Configuration.Instance.TimeToRememberLastAction} ms"); Configuration.Instance.TimeToRememberLastAction = (int)GUILayout.HorizontalSlider(Configuration.Instance.TimeToRememberLastAction, 250, 10000, GUILayout.ExpandWidth(true)); } } // column two using (GUILayout.AreaScope columnTwo = new GUILayout.AreaScope(new Rect(410, 20, 220, 500))) { using (GUILayout.VerticalScope col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label(Localizer.GetStringByTag("#Historian_DayNames")); for (int i = 0; i < Configuration.Instance.KerbinDayNames.Length; i++) { using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); Configuration.Instance.KerbinDayNames[i] = GUILayout.TextField(Configuration.Instance.KerbinDayNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } GUILayout.Space(50); GUILayout.Label(Localizer.GetStringByTag("#Historian_DefaultEmptyCrewSlot")); GUILayout.Space(10); using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_CrewedLabel")); GUILayout.FlexibleSpace(); Configuration.Instance.DefaultNoCrewLabel = GUILayout.TextField(Configuration.Instance.DefaultNoCrewLabel, GUI.skin.textArea, GUILayout.Width(120)); } using (GUILayout.HorizontalScope noCrewLabel = new GUILayout.HorizontalScope()) { GUILayout.Label(Localizer.GetStringByTag("#Historian_UncrewedLabel")); GUILayout.FlexibleSpace(); Configuration.Instance.DefaultUnmannedLabel = GUILayout.TextField(Configuration.Instance.DefaultUnmannedLabel, GUI.skin.textArea, GUILayout.Width(120)); } } } // column three using (GUILayout.AreaScope columnThree = new GUILayout.AreaScope(new Rect(660, 20, 220, 480))) { using (GUILayout.VerticalScope col = new GUILayout.VerticalScope()) { GUILayout.Space(20); GUILayout.Label(Localizer.GetStringByTag("#Historian_MonthNames")); for (int i = 0; i < Configuration.Instance.KerbinMonthNames.Length; i++) { using (GUILayout.HorizontalScope item = new GUILayout.HorizontalScope()) { GUILayout.Label($"{i + 1}:"); GUILayout.FlexibleSpace(); Configuration.Instance.KerbinMonthNames[i] = GUILayout.TextField(Configuration.Instance.KerbinMonthNames[i], GUI.skin.textArea, GUILayout.Width(190f)); } } } } // bottom bar using (GUILayout.AreaScope buttonBar = new GUILayout.AreaScope(new Rect(5, 525, 890, 30))) { using (GUILayout.HorizontalScope layout = new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_900539"), GUILayout.Width(100.0f))) // #autoLOC_900539 = Load { historian.Reload(); } if (GUILayout.Button(Localizer.GetStringByTag("#autoLOC_174778"), GUILayout.Width(100.0f))) // #autoLOC_174778 = Save { Configuration.Instance.Layout = historian.GetCurrentLayoutName(); historian.SetConfiguration(Configuration.Instance); if (!Configuration.Instance.PersistentConfigurationWindow) { Toggle(); } if (!String.IsNullOrEmpty(Configuration.Instance.CustomText)) { Configuration.Instance.TokenizedCustomText = Parser.GetTokens(Configuration.Instance.CustomText); } } GUILayout.Space(20); // GUILayout.FlexibleSpace(); } } GUI.DragWindow(); }
public override void WindowElements() { GUILayout.BeginVertical(); GUILayout.Label("WARNING: You can click through this window!", HighLogic.Skin.label); //Red GUILayout.BeginHorizontal(); GUILayout.Label("Red:", HighLogic.Skin.label, GUILayout.Width(50)); if (float.TryParse(GUILayout.TextField(color.r.ToString(), HighLogic.Skin.textField), out f)) { color.r = Mathf.Clamp01(f); } GUILayout.EndHorizontal(); color.r = GUILayout.HorizontalSlider(color.r, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb); //Green GUILayout.BeginHorizontal(); GUILayout.Label("Green:", HighLogic.Skin.label, GUILayout.Width(50)); if (float.TryParse(GUILayout.TextField(color.g.ToString(), HighLogic.Skin.textField), out f)) { color.g = Mathf.Clamp01(f); } GUILayout.EndHorizontal(); color.g = GUILayout.HorizontalSlider(color.g, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb); //Blue GUILayout.BeginHorizontal(); GUILayout.Label("Blue:", HighLogic.Skin.label, GUILayout.Width(50)); if (float.TryParse(GUILayout.TextField(color.b.ToString(), HighLogic.Skin.textField), out f)) { color.b = Mathf.Clamp01(f); } GUILayout.EndHorizontal(); color.b = GUILayout.HorizontalSlider(color.b, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb); //alpha if (showAlpha) { GUILayout.BeginHorizontal(); GUILayout.Label("Alpha:", HighLogic.Skin.label, GUILayout.Width(50)); if (float.TryParse(GUILayout.TextField(color.a.ToString(), HighLogic.Skin.textField), out f)) { color.a = Mathf.Clamp01(f); } GUILayout.EndHorizontal(); color.a = GUILayout.HorizontalSlider(color.a, 0, 1, HighLogic.Skin.horizontalSlider, HighLogic.Skin.horizontalSliderThumb); } //preset list if (presets.Count > 0) { selectedIndex = -1; for (int j = 0; j < presets.Count; j++) { if (float.Parse(presets[j].GetValue("r")) == color.r && float.Parse(presets[j].GetValue("g")) == color.g && float.Parse(presets[j].GetValue("b")) == color.b && float.Parse(presets[j].GetValue("a")) == color.a) { selectedIndex = j; break; } } GUILayout.Label("Select preset:", HighLogic.Skin.label); scrollPosition = GUILayout.BeginScrollView(scrollPosition, HighLogic.Skin.horizontalSlider, HighLogic.Skin.label, GUILayout.Height(48)); i = GUILayout.Toolbar(selectedIndex, (from n in presets select n.GetValue("name")).ToArray(), HighLogic.Skin.button); GUILayout.EndScrollView(); if (i >= 0) { color = new Color(float.Parse(presets[i].GetValue("r")), float.Parse(presets[i].GetValue("g")), float.Parse(presets[i].GetValue("b")), showAlpha ? float.Parse(presets[i].GetValue("a")) : 1); } } else { selectedIndex = -1; } //add preset newPresetName = GUILayout.TextField(newPresetName, HighLogic.Skin.textField); GUILayout.BeginHorizontal(); if (selectedIndex == -1 && GUILayout.Button("Add preset", HighLogic.Skin.button)) { ConfigNode n = new ConfigNode("PRESET"); n.AddValue("r", color.r); n.AddValue("g", color.g); n.AddValue("b", color.b); n.AddValue("a", color.a); n.AddValue("name", newPresetName); presets.Add(n); SavePresets(); newPresetName = ""; } //rename preset if (selectedIndex >= 0 && GUILayout.Button("Rename preset", HighLogic.Skin.button)) { presets[selectedIndex].SetValue("name", newPresetName); newPresetName = ""; SavePresets(); } //delete preset if (selectedIndex >= 0 && GUILayout.Button("Delete preset", HighLogic.Skin.button)) { presets.RemoveAt(selectedIndex); SavePresets(); } GUILayout.EndHorizontal(); //End GUILayout.EndVertical(); }