/// <summary> /// Create table row for displayed result /// </summary> /// <param name="result"></param> /// <returns>DialogGUIHorizontalLayout row</returns> private DialogGUIHorizontalLayout CreateListLayoutRow(DisplayedSystemCheckResult result) { DialogGUIHorizontalLayout row = null; if (result.Tooltip.Length > 0) { row = new DialogGUIHorizontalLayout( new DialogGUILabel(result.Label + ":", 100f), new DialogGUILabel(result.Text), new DialogGUISpace(1f), // Add a button with transparent background and label style just to display a tooltip when hovering over it // Transparent sprite is needed to hide button borders TooltipExtension.DeferTooltip(new DialogGUIButton(CommonWindowProperties.transparent, "(?)", () => { }, 17f, 18f, false) { tooltipText = result.Tooltip, guiStyle = CommonWindowProperties.Style_Button_Label }) ); } else { row = new DialogGUIHorizontalLayout( new DialogGUILabel(result.Label + ":", 100f), new DialogGUILabel(result.Text) ); } return(row); }
/// <summary> /// Constructor /// </summary> internal ControlWindowView(ControlWindowModel m, UnityAction close) : base( CommonWindowProperties.controlMinWidth, // min width CommonWindowProperties.controlMinHeight, // min height CommonWindowProperties.controlWindowSpacing, // spacing CommonWindowProperties.controlElementPadding, // padding TextAnchor.UpperLeft // text anchor ) { model = m; closeCallback = close; AddChild(model.GetStatsListLayout()); // Set a target section DialogGUITextInput latField = new DialogGUITextInput("", false, 20, (string s) => { model.Latitude = s; return(s); }, model.GetLatitude, TMPro.TMP_InputField.ContentType.DecimalNumber, CommonWindowProperties.buttonHeight); model.AddLockControlToTextField(latField); DialogGUITextInput lonField = new DialogGUITextInput("", false, 20, (string s) => { model.Longitude = s; return(s); }, model.GetLongitude, TMPro.TMP_InputField.ContentType.DecimalNumber, CommonWindowProperties.buttonHeight); model.AddLockControlToTextField(lonField); AddChild(new DialogGUILabel(Localizer.Format("#LOC_BV_Control_SetTarget") + ":")); AddChild(new DialogGUIHorizontalLayout(TextAnchor.MiddleLeft, new DialogGUILabel(Localizer.Format("#LOC_BV_Control_Lat") + ":"), latField, new DialogGUISpace(2f), new DialogGUILabel(Localizer.Format("#LOC_BV_Control_Lon") + ":"), lonField, new DialogGUIButton(Localizer.Format("#LOC_BV_Control_Set"), model.SetButtonClicked, model.EnableButtons, 40f, CommonWindowProperties.buttonHeight - 4, false) )); AddChild(new DialogGUIHorizontalLayout( new DialogGUIButton(Localizer.Format("#LOC_BV_Control_PickOnMap"), model.PickOnMapButtonClicked, model.EnableButtons, 90f, CommonWindowProperties.buttonHeight - 4, false), new DialogGUIButton(Localizer.Format("#LOC_BV_Control_CurrenTarget"), model.CurrentTargetButtonClicked, model.EnableButtons, 104f, CommonWindowProperties.buttonHeight - 4, false) )); AddChild(new DialogGUIHorizontalLayout( new DialogGUIButton(Localizer.Format("#LOC_BV_Control_CurrentWaypoint"), model.CurrentWaypointButtonClicked, model.EnableButtons, 124f, CommonWindowProperties.buttonHeight - 4, false) )); AddChild(new DialogGUISpace(3f)); AddChild(new DialogGUIHorizontalLayout( new DialogGUIFlexibleSpace(), TooltipExtension.DeferTooltip(new DialogGUIButton(Localizer.Format("#LOC_BV_Control_Check"), model.SystemCheckButtonClicked, model.EnableButtons, 120f, CommonWindowProperties.buttonHeight, false) { tooltipText = Localizer.Format("#LOC_BV_Control_Check_Tooltip") }), new DialogGUIFlexibleSpace() )); AddChild(new DialogGUISpace(5f)); AddChild(new DialogGUIHorizontalLayout( new DialogGUIFlexibleSpace(), new DialogGUIButton(model.GetGoButtonText, model.GoButtonClicked, null, 120f, CommonWindowProperties.buttonHeight + 4, false, CommonWindowProperties.Style_Button_Bold_Yellow), new DialogGUIFlexibleSpace() )); }
/// <summary> /// Constructor /// </summary> internal SettingsWindowView(SettingsWindowModel m, Vector3 mwp, UnityAction close) : base( CommonWindowProperties.settingsMinWidth, // min width CommonWindowProperties.settingsMinHeight, // min height CommonWindowProperties.settingsWindowSpacing, // spacing CommonWindowProperties.settingsElementPadding, // padding TextAnchor.UpperLeft // text anchor ) { model = m; mainWindowPosition = mwp; closeCallback = close; AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetDewarpToggleState(), Localizer.Format("#LOC_BV_AutomaticDewarp"), model.DewarpChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_AutomaticDewarp_Tooltip") })); AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GeDisableRotationToggleState(), Localizer.Format("#LOC_BV_DisableRotation"), model.DisableRotationChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_DisableRotation_Tooltip") })); AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GeShowBiomeToggleState(), Localizer.Format("#LOC_BV_ShowBiome"), model.ShowBiomeChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_ShowBiome_Tooltip") })); AddChild(new DialogGUIBox("", 140f, 80f, null, new DialogGUIVerticalLayout(140f, 80f, CommonWindowProperties.settingsWindowSpacing, CommonWindowProperties.boxPadding, TextAnchor.UpperLeft, new DialogGUILabel(Localizer.Format("#LOC_BV_Style"), 135f), new DialogGUISpace(10f), new DialogGUIToggleGroup( new DialogGUIToggle(model.GetKSPSkinToggleState(), Localizer.Format("#LOC_BV_Style_KSP"), model.KSPSkinChecked, 135f), new DialogGUIToggle(model.GetUnitySkinToggleState(), Localizer.Format("#LOC_BV_Style_Unity"), model.UnitySkinChecked, 135f) ) ) )); AddChild(new DialogGUISpace(4f)); AddChild(new DialogGUIBox("", 140f, 80f, null, new DialogGUIVerticalLayout(140f, 80f, CommonWindowProperties.settingsWindowSpacing, CommonWindowProperties.boxPadding, TextAnchor.UpperLeft, new DialogGUILabel(Localizer.Format("#LOC_BV_Toolbar"), 135f), new DialogGUISpace(10f), TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetKSPToolbarToggleState(), Localizer.Format("#LOC_BV_Toolbar_KSP"), model.KSPToolbarChecked, 135f) { tooltipText = Localizer.Format("#LOC_BV_Toolbar_KSP_Tooltip") }), TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetTCToggleState(), Localizer.Format("#LOC_BV_Toolbar_TC"), model.TCChecked, 135f) { tooltipText = Localizer.Format("#LOC_BV_Toolbar_TC_Tooltip") }) ) )); }
/// <summary> /// Create table row for displayed result /// </summary> /// <param name="result"></param> /// <returns>DialogGUIHorizontalLayout row</returns> private DialogGUIHorizontalLayout CreateListLayoutRow(DisplayedSystemCheckResult[] result) { DialogGUIHorizontalLayout row = new DialogGUIHorizontalLayout(); for (int i = 0; i < result.Length; i++) { if (result[i].Toggle) { row.AddChild( (result[i].Tooltip.Length > 0) ? TooltipExtension.DeferTooltip(new DialogGUIToggle(result[i].GetToggleValue, result[i].Text, result[i].ToggleSelectedCallback) { tooltipText = result[i].Tooltip }) : new DialogGUIToggle(result[i].GetToggleValue, result[i].Text, result[i].ToggleSelectedCallback) ); } else { row.AddChild(new DialogGUILabel(result[i].Label + ":", 100f)); if (result[i].Text.Length > 0) { row.AddChild(new DialogGUILabel(result[i].Text)); } if (result[i].Tooltip.Length > 0) { if (result[i].Text.Length > 0) { row.AddChild(new DialogGUISpace(1f)); } // Add a button with transparent background and label style just to display a tooltip when hovering over it // Transparent sprite is needed to hide button borders row.AddChild(TooltipExtension.DeferTooltip(new DialogGUIButton(CommonWindowProperties.transparent, "(?)", () => { }, 17f, 18f, false) { tooltipText = result[i].Tooltip, guiStyle = CommonWindowProperties.Style_Button_Label })); } } } return(row); }
/// <summary> /// Create table row for controller /// </summary> /// <param name="controller"></param> /// <returns>DialogGUIHorizontalLayout row or null if controller state don't equals to selected filter</returns> private DialogGUIHorizontalLayout CreateListLayoutRow(BVController controller) { DialogGUIHorizontalLayout row = null; if ((activeControllersChecked && !controller.Shutdown) || (disabledControllersChecked && controller.Shutdown)) { UIStyle statusStyle; switch (controller.GetVesselState()) { case VesselState.Current: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_White; break; case VesselState.Idle: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_Grey; break; case VesselState.ControllerDisabled: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_Red; break; case VesselState.AwaitingSunlight: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_Yellow; break; case VesselState.Moving: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_Green; break; default: statusStyle = CommonWindowProperties.Style_Label_Normal_Center_Grey; break; } row = new DialogGUIHorizontalLayout( new DialogGUILabel(controller.vessel.GetDisplayName(), 150f), new DialogGUISpace(10f), new DialogGUILabel(controller.GetVesselStateText(), 70f) { guiStyle = statusStyle }, new DialogGUISpace(10f), new DialogGUILabel(controller.vessel.mainBody.bodyDisplayName.Replace("^N", ""), 60f) { guiStyle = CommonWindowProperties.Style_Label_Normal_Center }, new DialogGUISpace(10f), new DialogGUILabel(delegate { return(GetSpeed(controller)); }, 60f) { guiStyle = CommonWindowProperties.Style_Label_Normal_Center }, new DialogGUISpace(10f), new DialogGUILabel(delegate { return(GetDistanceToTarget(controller)); }, 90f) { guiStyle = CommonWindowProperties.Style_Label_Normal_Center }, new DialogGUISpace(10f), ( !controller.vessel.isActiveVessel ? TooltipExtension.DeferTooltip(new DialogGUIButton("->", delegate { SwitchToVessel(controller.vessel.id); }, 22f, 16f, false) { tooltipText = (Localizer.Format("#LOC_BV_SwitchTo") + " " + controller.vessel.GetDisplayName()) }) : new DialogGUISpace(10f) ) ); row.SetOptionText(controller.vessel.id.ToString()); // ID of the row (vessel ID) controller.OnStateChanged += OnControllerStateChanged; // Register state changed event } return(row); }
/// <summary> /// Constructor /// </summary> internal SettingsWindowView(SettingsWindowModel m, Vector3 mwp, UnityAction close) : base( CommonWindowProperties.settingsMinWidth, // min width CommonWindowProperties.settingsMinHeight, // min height CommonWindowProperties.settingsWindowSpacing, // spacing CommonWindowProperties.settingsElementPadding, // padding TextAnchor.UpperLeft // text anchor ) { model = m; mainWindowPosition = mwp; closeCallback = close; AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetDewarpToggleState(), Localizer.Format("#LOC_BV_AutomaticDewarp"), model.DewarpChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_AutomaticDewarp_Tooltip") })); AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GeDisableRotationToggleState(), Localizer.Format("#LOC_BV_DisableRotation"), model.DisableRotationChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_DisableRotation_Tooltip") })); AddChild(TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GeShowBiomeToggleState(), Localizer.Format("#LOC_BV_ShowBiome"), model.ShowBiomeChecked, 130f) { tooltipText = Localizer.Format("#LOC_BV_ShowBiome_Tooltip") })); AddChild(new DialogGUIBox("", 140f, 80f, null, new DialogGUIVerticalLayout(140f, 80f, CommonWindowProperties.settingsWindowSpacing, CommonWindowProperties.boxPadding, TextAnchor.UpperLeft, new DialogGUILabel(Localizer.Format("#LOC_BV_Style"), 135f), new DialogGUISpace(10f), new DialogGUIToggleGroup( new DialogGUIToggle(model.GetKSPSkinToggleState(), Localizer.Format("#LOC_BV_Style_KSP"), model.KSPSkinChecked, 135f), new DialogGUIToggle(model.GetUnitySkinToggleState(), Localizer.Format("#LOC_BV_Style_Unity"), model.UnitySkinChecked, 135f) ) ) )); AddChild(new DialogGUISpace(4f)); AddChild(new DialogGUIBox("", 140f, 80f, null, new DialogGUIVerticalLayout(140f, 80f, CommonWindowProperties.settingsWindowSpacing, CommonWindowProperties.boxPadding, TextAnchor.UpperLeft, new DialogGUILabel(Localizer.Format("#LOC_BV_Toolbar"), 135f), new DialogGUISpace(10f), TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetKSPToolbarToggleState(), Localizer.Format("#LOC_BV_Toolbar_KSP"), model.KSPToolbarChecked, 135f) { tooltipText = Localizer.Format("#LOC_BV_Toolbar_KSP_Tooltip") }), TooltipExtension.DeferTooltip(new DialogGUIToggle(model.GetTCToggleState(), Localizer.Format("#LOC_BV_Toolbar_TC"), model.TCChecked, 135f) { tooltipText = Localizer.Format("#LOC_BV_Toolbar_TC_Tooltip") }) ) )); AddChild(new DialogGUISpace(4f)); DialogGUITextInput heightOffsetField = new DialogGUITextInput("", false, 20, (string s) => { model.HeightOffset = s; return(s); }, model.GetHeightOffset, TMPro.TMP_InputField.ContentType.DecimalNumber, CommonWindowProperties.buttonHeight); model.AddLockControlToTextField(heightOffsetField); AddChild(new DialogGUIVerticalLayout( new DialogGUILabel(Localizer.Format("#LOC_BV_HeightOffset")), new DialogGUIHorizontalLayout(TextAnchor.MiddleLeft, heightOffsetField, new DialogGUILabel(Localizer.Format("m"))) )); }