// constructor static Profiler() { // create window dialog_items = new DialogGUIVerticalLayout(); scroll_list = new DialogGUIScrollList(new Vector2(), false, true, dialog_items); multi_dialog = new MultiOptionDialog( "TrajectoriesProfilerWindow", "", GetTitle(), HighLogic.UISkin, new Rect(0.5f, 0.5f, width, height), new DialogGUIBase[] { new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.UpperCenter, // create average reset and show zero calls buttons new DialogGUIHorizontalLayout(false, false, new DialogGUIButton(Localizer.Format("#autoLOC_900305"), OnButtonClick_Reset, () => true, 75, 25, false), new DialogGUIToggle(() => { return show_zero; },"Show zero calls", OnButtonClick_ShowZero), new DialogGUILabel(() => { return tot_frames_txt; }, value_width + 50f)), // create header line new DialogGUIHorizontalLayout( new DialogGUILabel("<b> NAME</b>", true), new DialogGUILabel("<b>LAST</b>", value_width), new DialogGUILabel("<b>AVG</b>", value_width), new DialogGUILabel("<b>CALLS</b>", value_width - 15f), new DialogGUILabel("<b>AVG</b>", value_width - 10f))), // create scrollbox for entry data scroll_list }); }
static Watcher() { // create window dialog_items = new DialogGUIVerticalLayout(); scroll_list = new DialogGUIScrollList(new Vector2(), false, true, dialog_items); multi_dialog = new MultiOptionDialog( "TrajectoriesWatcherWindow", "", GetTitle(), HighLogic.UISkin, new Rect(0.5f, 0.5f, WIDTH, HEIGHT), new DialogGUIBase[] { new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.UpperCenter, // create reset button new DialogGUIHorizontalLayout(false, false, new DialogGUIButton(Localizer.Format("#autoLOC_900305"), OnButtonClick_Reset, () => true, 75, 25, false), new DialogGUILabel(() => { return tot_frames_txt; }, VALUE_WIDTH + 50f)), // create header line new DialogGUIHorizontalLayout( new DialogGUILabel("<b> NAME</b>", true), new DialogGUILabel("<b>LAST</b>", VALUE_WIDTH))), // create scrollbox for entry data scroll_list }); }
private DialogGUIBase CreateMissionListDialog() { DialogGUIContentSizer sizer = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); DialogGUIToggleGroup toggle = new DialogGUIToggleGroup(this.CreateMissionListItems()); DialogGUIGridLayout layout = new DialogGUIGridLayout(new RectOffset(0, 4, 4, 4), new Vector2(320f, 64f), new Vector2(0f, 0f), GridLayoutGroup.Corner.UpperLeft, GridLayoutGroup.Axis.Horizontal, TextAnchor.UpperLeft, GridLayoutGroup.Constraint.FixedColumnCount, 1, sizer, toggle); DialogGUIScrollList scrollList = new DialogGUIScrollList(new Vector2(344f, 425f), false, true, layout); DialogGUIButton deleteButton = new DialogGUIButton("Delete", delegate { ShowDeleteMissionConfirmDialog(); }); deleteButton.OptionInteractableCondition = (() => selectedMissionIndex >= 0); DialogGUIButton cancelButton = new DialogGUIButton("Cancel", delegate { DismissDialog(); }); DialogGUIButton loadButton = new DialogGUIButton("Load", delegate { OnMissionSelected(); DismissDialog(); }); loadButton.OptionInteractableCondition = (() => selectedMissionIndex >= 0); DialogGUIVerticalLayout dialogGUIVerticalLayout = new DialogGUIVerticalLayout(true, true); dialogGUIVerticalLayout.AddChild(scrollList); dialogGUIVerticalLayout.AddChild(new DialogGUIHorizontalLayout(deleteButton, cancelButton, loadButton)); return(dialogGUIVerticalLayout); }
/// <summary> /// Gets the dialog GUI for use with the stock popup dialog system. /// </summary> private DialogGUIBase[] GetDialogGUI() { // layout containing the settings gui objects DialogGUIVerticalLayout settingsLayout = new DialogGUIVerticalLayout(0f, 0f, 0f, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, new DialogGUIToggleButton(tempConfig.discardDuplicates, "Automatically Discard Duplicates", value => tempConfig.discardDuplicates = value, h: 30f), new DialogGUIToggleButton(tempConfig.saveExperimentsResultDialogPosition, "Save Experiements Result Dialog Position", value => tempConfig.saveExperimentsResultDialogPosition = value, h: 30f) ); // scroll list for containing the settings layout DialogGUIScrollList settingsScrollList = new DialogGUIScrollList(-Vector2.one, false, true, settingsLayout); // layout containing the bottom gui objects DialogGUIBase bottomLayout = new DialogGUIHorizontalLayout (TextAnchor.MiddleLeft, // version new DialogGUIFlexibleSpace(), new DialogGUILabel($"<color=#eee><i>v{Assembly.GetExecutingAssembly().GetName().Version}</i></color>"), new DialogGUIFlexibleSpace(), // buttons new DialogGUIButton("Apply", Apply, 80f, 30f, false), new DialogGUIButton("Accept", Accept, 80f, 30f, false), new DialogGUIButton("Close", Close, 80f, 30f, false) ); return(new DialogGUIBase[2] { settingsScrollList, bottomLayout }); }
internal static void CreateCrewList() { List <DialogGUIBase> list = new List <DialogGUIBase>(); list.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true)); list.Add(new DialogGUIFlexibleSpace()); //list.Add(new DialogGUIButton("Default", delegate { SetVariant(null);}, 140.0f, 30.0f, true)); //vesselToLaunch.protoVessel.LoadObjects(); //foreach (ProtoCrewMember protoKerbal in HighLogic.CurrentGame.CrewRoster.Crew) //{ // Log.Normal(protoKerbal.name + " : " + protoKerbal.trait); //} foreach (ProtoCrewMember protoKerbal in HighLogic.CurrentGame.CrewRoster.Crew.Where(x => x.rosterStatus == ProtoCrewMember.RosterStatus.Available)) { list.Add(new DialogGUIHorizontalLayout( new DialogGUILabel(delegate { return(protoKerbal.trait); }, KKStyle.whiteLabel), new DialogGUIFlexibleSpace(), new DialogGUILabel(delegate { return(GetCurrentCrewExperience(protoKerbal)); }, KKStyle.goldLabel), new DialogGUIFlexibleSpace(), new DialogGUIButton(delegate { return(protoKerbal.name); }, delegate { SeatKerbal(protoKerbal); }, delegate { return((selectedPart != null) && protoKerbal.rosterStatus == ProtoCrewMember.RosterStatus.Available); }, 140f, 25, false)) ); } list.Add(new DialogGUIFlexibleSpace()); var layout = new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleCenter, list.ToArray()); var scroll = new DialogGUIScrollList(new Vector2(350, 200), new Vector2(330, 23f * list.Count - 2), false, true, layout); availableCrewList = scroll; }
internal static void CreateSeatList() { List <DialogGUIBase> list = new List <DialogGUIBase>(); list.Add(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true)); list.Add(new DialogGUIFlexibleSpace()); //list.Add(new DialogGUIButton("Default", delegate { SetVariant(null);}, 140.0f, 30.0f, true)); if (selectedVessel != null) { foreach (ProtoPartSnapshot protoPart0 in selectedVessel.protoPartSnapshots) { ProtoPartSnapshot protoPart = protoPart0; if (protoPart.partPrefab == null) { continue; } Part myPart = protoPart.partPrefab; int seatCount = myPart.CrewCapacity; if (seatCount > 0) { list.Add(new DialogGUIHorizontalLayout( new DialogGUILabel(myPart.name, KKStyle.defaultLabel), new DialogGUIFlexibleSpace() )); for (int i = 0; i < myPart.CrewCapacity; i++) { int seatNumber = i; list.Add(new DialogGUIHorizontalLayout( new DialogGUIFlexibleSpace(), new DialogGUILabel(delegate { return(GetCurrentCrewTrait(protoPart, seatNumber)); }, KKStyle.whiteLabel), new DialogGUIFlexibleSpace(), new DialogGUILabel(delegate { return(GetCurrentCrewExperience(protoPart, seatNumber)); }, KKStyle.goldLabel), new DialogGUIFlexibleSpace(), new DialogGUIButton(delegate { return(GetCurrentCrewName(protoPart, seatNumber)); }, delegate { SelectSeat(protoPart, seatNumber); }, delegate { return((protoPart != selectedPart) || selectedSeat != seatNumber); }, 140f, 25, false), new DialogGUIButton(" X ", delegate { EmptySeat(protoPart, seatNumber); }, 25, 25, false, KKStyle.DeadButtonRed) )); } } } } list.Add(new DialogGUIFlexibleSpace()); var layout = new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleCenter, list.ToArray()); var scroll = new DialogGUIScrollList(new Vector2(350, 200), new Vector2(330, 23f * list.Count - 2), false, true, layout); seatList = scroll; }
private void ToggleDialog() { if (DismissDialog()) { return; } DialogGUILabel title = new DialogGUILabel("Physics Hold", true); DialogGUILabel subTitle = new DialogGUILabel("Keep physics in check for landed vessels !", true); DialogGUIVerticalLayout titleLayout = new DialogGUIVerticalLayout(true, false); titleLayout.AddChild(title); titleLayout.AddChild(subTitle); DialogGUIButton closeButton = new DialogGUIButton(string.Empty, () => DismissDialog(), 24f, 24f, false); DialogGUIHorizontalLayout headerLayout = new DialogGUIHorizontalLayout(titleLayout, closeButton); List <DialogGuiVesselWidget> widgets = new List <DialogGuiVesselWidget>(); for (int i = 0; i < physicsHoldInstances.Count; i++) { DialogGuiVesselWidget widget = new DialogGuiVesselWidget(physicsHoldInstances[i]); widgets.Add(widget); } Vector3 activeVesselPos = FlightGlobals.ActiveVessel.transform.position; widgets.Sort((x, y) => Vector3.Distance(activeVesselPos, x.instance.Vessel.transform.position) < Vector3.Distance(activeVesselPos, y.instance.Vessel.transform.position) ? -1 : 1); DialogGUIBase[] scrollList = new DialogGUIBase[widgets.Count + 1]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < widgets.Count; i++) { scrollList[i + 1] = widgets[i].widgetBox; } DialogGUIScrollList scrollListItem = new DialogGUIScrollList(Vector2.one, false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList)); List <DialogGUIBase> dialog = new List <DialogGUIBase>(); dialog.Add(headerLayout); dialog.Add(scrollListItem); DialogGUILabel kasInstalledLabel = null; if (isKASInstalled) { kasInstalledLabel = new DialogGUILabel("<color=orange><b>WARNING</b></color> : KAS is installed. \nHaving a KAS connection on a on-hold vessel <b>won't work</b> and will cause it to disappear from the game", true, false); dialog.Add(kasInstalledLabel); } Rect posAndSize = new Rect(lastPopupPos.x, lastPopupPos.y, 320f, isKASInstalled ? 365f : 320f); currentDialog = PopupDialog.SpawnPopupDialog(new Vector2(0f, 1f), new Vector2(0f, 1f), new MultiOptionDialog("PhysicsHoldDialog", "", "", UISkinManager.defaultSkin, posAndSize, dialog.ToArray()), true, UISkinManager.defaultSkin, false); // wteak title text style TextMeshProUGUI titleText = title.uiItem.GetComponent <TextMeshProUGUI>(); titleText.alignment = TextAlignmentOptions.Top; titleText.color = Color.white; titleText.fontSize = 16f; titleText.fontStyle = FontStyles.Bold; TextMeshProUGUI subTitleText = subTitle.uiItem.GetComponent <TextMeshProUGUI>(); subTitleText.alignment = TextAlignmentOptions.Top; // top-left align widgets in the scroll area ScrollRect scrollRect = scrollListItem.uiItem.GetComponentInChildren <ScrollRect>(); scrollRect.content.pivot = new Vector2(0f, 1f); foreach (DialogGuiVesselWidget widget in widgets) { widget.TweakAfterCreation(); } // close button use custom sprite ColorBlock buttonColorTintColors = new ColorBlock() { colorMultiplier = 1f, normalColor = Color.white, selectedColor = Color.white, highlightedColor = new Color(0.75f, 1f, 0.65f, 1f), pressedColor = new Color(0.75f, 1f, 0.65f, 1f), disabledColor = new Color(1f, 1f, 1f, 1f) }; Image imgCpnt = closeButton.uiItem.GetComponent <Image>(); imgCpnt.type = Image.Type.Simple; imgCpnt.preserveAspect = true; imgCpnt.color = Color.white; imgCpnt.sprite = Lib.CloseSprite; Button btnCpnt = closeButton.uiItem.GetComponent <Button>(); btnCpnt.transition = Selectable.Transition.ColorTint; btnCpnt.navigation = new Navigation() { mode = Navigation.Mode.None }; btnCpnt.colors = buttonColorTintColors; btnCpnt.image = imgCpnt; if (kasInstalledLabel != null) { kasInstalledLabel.uiItem.GetComponent <TextMeshProUGUI>().alignment = TextAlignmentOptions.Top; } }