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); }
// private MultiOptionDialog CreateDialog() { //Create Fields List<DialogGUIBase> dialogBase = new List<DialogGUIBase>(); DialogGUIBase[] scrollList = new DialogGUIBase[bodylist.Count]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); TechLevel tLev = new TechLevel();
/// <summary> /// Get layout of the list of vessels /// </summary> /// <returns></returns> internal DialogGUIVerticalLayout GetVesselListLayout() { // Count disabled controllers int disabledControllersCount = 0; int controllersCount = BonVoyage.Instance.BVControllers.Count(); foreach (BVController controller in BonVoyage.Instance.BVControllers.Values) { if (controller.Shutdown) { disabledControllersCount++; } } int listLength = 1; if (activeControllersChecked) { listLength += controllersCount - disabledControllersCount; } if (disabledControllersChecked) { listLength += disabledControllersCount; } DialogGUIBase[] list = new DialogGUIBase[listLength]; list[0] = new DialogGUIContentSizer(UnityEngine.UI.ContentSizeFitter.FitMode.Unconstrained, UnityEngine.UI.ContentSizeFitter.FitMode.PreferredSize, true); if (listLength > 1) // anything is checked { int counter = 1; foreach (BVController controller in BonVoyage.Instance.BVControllers.Values) { DialogGUIHorizontalLayout row = CreateListLayoutRow(controller); if (row != null) { list[counter] = row; counter++; if (counter >= listLength) // break if we are at the end of list { break; } } } } vesselListLayout = new DialogGUIVerticalLayout( CommonWindowProperties.mainListMinWidth, CommonWindowProperties.mainListMinHeight, CommonWindowProperties.mainWindowSpacing, CommonWindowProperties.mainListPadding, TextAnchor.UpperLeft, list ); return(vesselListLayout); }
public static DialogGUIContentSizer GUIContentSizer(ContentSizeFitter.FitMode widthMode, ContentSizeFitter.FitMode heightMode, Boolean useParentSize = false, Modifier <DialogGUIContentSizer> modifier = null) { DialogGUIContentSizer element = new DialogGUIContentSizer(widthMode, heightMode, useParentSize); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); DialogGUILabel nameLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_Generic_nameLabel") + "</b>", 30, 12);//Name nameInput = new DialogGUITextInput(this.hostStation.stationName, false, CNCSettings.MaxLengthName, setNameInput, 145, 25); DialogGUIButton defaultButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Resetbutton"), defaultNameClick, 40, 25, false);//"Reset" DialogGUIHorizontalLayout nameGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nameLabel, nameInput, new DialogGUIFlexibleSpace(), defaultButton }); listComponments.Add(nameGroup); DialogGUILabel freqLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationEdit_freqLabel") + "</b>", 85, 12);//New frequency frequencyInput = new DialogGUITextInput("", false, CNCSettings.MaxDigits, setFreqInput, 60, 25); DialogGUIButton addButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Addbutton"), addClick, 40, 25, false);//"Add" stationColorImage = new DialogGUIImage(new Vector2(16f, 16f), Vector2.zero, this.hostStation.Color, CNCCommNetHome.getGroundStationTexture(this.hostStation.TechLevel)); DialogGUIHorizontalLayout imageBtnLayout = new DialogGUIHorizontalLayout(true, true, 0f, new RectOffset(5, 5, 5, 5), TextAnchor.MiddleCenter, new DialogGUIBase[] { stationColorImage }); DialogGUIButton colorButton = new DialogGUIButton("", colorEditClick, 26, 26, false, new DialogGUIBase[] { imageBtnLayout }); DialogGUIHorizontalLayout freqGRoup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { freqLabel, frequencyInput, addButton, new DialogGUISpace(50), colorButton }); listComponments.Add(freqGRoup); //Prepare a list container for the GUILayout rows DialogGUIBase[] rows = new DialogGUIBase[this.hostStation.getFrequencyList().Count + 1]; rows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < this.freqListShown.Count; i++) { rows[i + 1] = createConstellationRow(this.freqListShown[i]); } frequencyRowLayout = new DialogGUIVerticalLayout(10, 100, 0, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, rows); listComponments.Add(new CustomDialogGUIScrollList(new Vector2(240, 100), false, true, frequencyRowLayout)); DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), updateAction, false); //"Update" DialogGUIButton cancelButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_CancelButton"), delegate { this.dismiss(); }, false); //"Cancel" DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), updateButton, cancelButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
private void showLabWindow() { // This is a list of content items to add to the dialog List <DialogGUIBase> dialog = new List <DialogGUIBase>(); dialog.Add(new DialogGUILabel("#ne_Chooose_Lab")); // Build a button list of all available experiments with their descriptions int numLabs = availableLabs.Count; DialogGUIBase[] scrollList = new DialogGUIBase[numLabs + 1]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int idx = 0; idx < numLabs; idx++) { var lab = availableLabs[idx]; var button = new DialogGUIButton <Lab>(lab.abbreviation, installExperimentInLab, lab, true); button.size = new Vector2(60, 30); var label = new DialogGUILabel(lab.GetInfo(), true, true); var h = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.UpperLeft, new DialogGUIBase[] { button, label }); scrollList[idx + 1] = h; } #if true dialog.Add(new DialogGUIScrollList(new Vector2(200, 300), false, true, //Vector2.one, false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList) )); #else dialog.Add(new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleLeft, scrollList)); #endif // Add a centered "Cancel" button dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[] { new DialogGUIFlexibleSpace(), new DialogGUIButton("#ne_Cancel", null, true), new DialogGUIFlexibleSpace(), })); // Actually create and show the dialog PopupDialog.SpawnPopupDialog( new MultiOptionDialog("", "", "#ne_Install_Experiment", HighLogic.UISkin, dialog.ToArray()), false, HighLogic.UISkin); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); CNCCommNetVessel cncVessel = (CNCCommNetVessel)this.hostVessel.Connection; List <short> vesselFrequencyList = cncVessel.getFrequencyList(); vesselFrequencyList.Sort(); listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.UpperCenter, new DialogGUIBase[] { new DialogGUILabel(this.description + "\n\n", false, false) })); //frequency list listComponments.Add(new DialogGUILabel("<b>Active frequencies</b>", false, false)); DialogGUIBase[] frequencyRows; if (vesselFrequencyList.Count == 0) { frequencyRows = new DialogGUIBase[2]; frequencyRows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); frequencyRows[1] = new DialogGUILabel(nofreqMessage, nofreqMessageStyle, true, false); } else { frequencyRows = new DialogGUIBase[vesselFrequencyList.Count + 1]; frequencyRows[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < vesselFrequencyList.Count; i++) { frequencyRows[i + 1] = createFrequencyRow(vesselFrequencyList[i]); } } frequencyRowLayout = new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, frequencyRows); scrollArea = new CustomDialogGUIScrollList(new Vector2(450, 100), false, true, frequencyRowLayout); listComponments.Add(scrollArea); //tools listComponments.AddRange(this.toolMgt.getLayoutContents()); return(listComponments); }
private PopupDialog spawnDialog(ExperimentResultDialogPage page) { List <DialogGUIBase> dialog = new List <DialogGUIBase>(); dialog.Add(new DialogGUILabel(Localizer.Format("#autoLOC_ScienceRelay_Transmit", page.pageData.title), false, false)); transferAll = false; if (resultsDialog.pages.Count > 1) { dialog.Add(new DialogGUIToggle(false, Localizer.Format("#autoLOC_ScienceRelay_TransmitAll"), delegate(bool b) { transferAll = !transferAll; }) ); } List <DialogGUIHorizontalLayout> vessels = new List <DialogGUIHorizontalLayout>(); for (int i = connectedVessels.Count - 1; i >= 0; i--) { KeyValuePair <Vessel, double> pair = connectedVessels[i]; Vessel v = pair.Key; float boost = signalBoost((float)pair.Value, v, page.pageData, page.xmitDataScalar); DialogGUILabel label = null; if (settings.transmissionBoost) { string transmit = string.Format("Xmit: {0:P0}", page.xmitDataScalar * (1 + boost)); if (boost > 0) { transmit += string.Format("(+{0:P0})", boost); } label = new DialogGUILabel(transmit, 130, 25); } DialogGUIBase button = null; if (settings.showTransmitWarning && page.showTransmitWarning) { button = new DialogGUIButton( v.vesselName, delegate { spawnWarningDialog( new ScienceRelayData() { _data = page.pageData, _host = page.host, _boost = boost, _source = FlightGlobals.ActiveVessel, _target = v, }, page.transmitWarningMessage); }, 160, 30, true, null); } else { button = new DialogGUIButton <ScienceRelayData>( v.vesselName, transferToVessel, new ScienceRelayData() { _data = page.pageData, _host = page.host, _boost = boost, _source = FlightGlobals.ActiveVessel, _target = v, }, true); button.size = new Vector2(160, 30); } DialogGUIHorizontalLayout h = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { button }); if (label != null) { h.AddChild(label); } vessels.Add(h); } DialogGUIBase[] scrollList = new DialogGUIBase[vessels.Count + 1]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < vessels.Count; i++) { scrollList[i + 1] = vessels[i]; } dialog.Add(new DialogGUIScrollList(new Vector2(270, 200), false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.MiddleLeft, scrollList) )); dialog.Add(new DialogGUISpace(4)); dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[] { new DialogGUIFlexibleSpace(), new DialogGUIButton(Localizer.Format("#autoLOC_190768"), popupDismiss), new DialogGUIFlexibleSpace(), new DialogGUILabel(version, false, false) })); RectTransform resultRect = resultsDialog.GetComponent <RectTransform>(); Rect pos = new Rect(0.5f, 0.5f, 300, 300); if (resultRect != null) { Vector2 resultPos = resultRect.position; float scale = GameSettings.UI_SCALE; int width = Screen.width; int height = Screen.height; float xpos = (resultPos.x / scale) + width / 2; float ypos = (resultPos.y / scale) + height / 2; float yNorm = ypos / height; pos.y = yNorm; pos.x = xpos > (width - (550 * scale)) ? (xpos - 360) / width : (xpos + 360) / width; } return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog( "ScienceRelayDialog", "", Localizer.Format("#autoLOC_ScienceRelay_Title"), UISkinManager.defaultSkin, pos, dialog.ToArray()), false, UISkinManager.defaultSkin)); }
/* +---------------------------------------------------+ * | Storage Manifest | * +---------------------------------------------------+ * | OMS ESC 4/1 |^|| * | Material Exposure Experiment 1 | || * | Needs: MEP-825 and MPL-600 or MSL-1000 | || * | State: Finished | || * | | || * | OMS ESC 4/2 | || * | empty | || * | | || * | OMS ESC 4/3 | || * | 3D Printer Demonstration Test |v|| * | [Close] | * +---------------------------------------------------+ */ private void showManifestWindow() { // This is a list of content items to add to the dialog List <DialogGUIBase> dialog = new List <DialogGUIBase>(); // TODO? Add description of part for which we're displaying the manifest //dialog.Add(new DialogGUILabel("Chooose lab")); //dialog.Add(new DialogGUISpace(4)); // Build a button list of all available experiments with their descriptions int numSlots = storageSlots.Count; DialogGUIBase[] scrollList = new DialogGUIBase[numSlots + 1]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); StringBuilder sb = new StringBuilder(); for (int i = 0; i < numSlots; i++) { var e = storageSlots[i]; sb.Append("<b>").Append(e.identifier).Append("</b>\n"); if (e.isEmpty()) { sb.Append("\t ").Append(Localizer.Format("#ne_empty")).AppendLine(); } else { ExperimentData exp = e.getStoredExperimentData(); sb.Append(exp.getDescription("\t ")).AppendLine(); sb.Append("\t ").Append(Localizer.Format("#ne_Status")).Append(": ").Append(exp.displayStateString()).AppendLine(); } var label = new DialogGUILabel(sb.ToString(), true, true); var h = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, label); scrollList[i + 1] = h; sb.Length = 0; } // NB: Specify a minimum size; the scroll-list will automatically expand to fill available space in the parent form. dialog.Add( new DialogGUIScrollList(new Vector2(300, 300), false, true, //new DialogGUIScrollList(Vector2.one, false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList) )); dialog.Add(new DialogGUISpace(4)); // Add a centered "Close" button dialog.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[] { new DialogGUIFlexibleSpace(), new DialogGUIButton(Localizer.Format("#ne_Close"), null, true), new DialogGUIFlexibleSpace(), })); // Calculate size of dialog window Rect pos = new Rect(0.5f, 0.5f, width, fixedHeight + numSlots * slotHeight); if (pos.height > maxHeight) { pos.height = maxHeight; } // Actually create and show the dialog PopupDialog.SpawnPopupDialog( new MultiOptionDialog("", "", Localizer.Format("#ne_Storage_Manifest"), HighLogic.UISkin, pos, dialog.ToArray()), false, HighLogic.UISkin); }
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; } }
/// <summary> /// Generates and spawns the Upgrade Editor UI. /// </summary> public PopupDialog GenerateUpgradeEditorUI() { upgrade_editor.Clear(); upgrade_line.Clear(); upgrade_editor.Add(new DialogGUIHorizontalLayout(new DialogGUISpace(50), new DialogGUILabel("Upgrade"), new DialogGUISpace(150), new DialogGUILabel("Changes"), new DialogGUISpace(250), new DialogGUILabel("Description"))); upgrade_editor.Add(new DialogGUISpace(4)); // create one line with toggle upgrade button, all modules affected and description for every upgrade in the selected part for (int cns = 0; cns < allupgrades.Count; cns++) { var affected_modules = new List <string>(); foreach (PartModule yapm in part.Modules) { if (yapm.HasUpgrades()) { foreach (ConfigNode ymup in yapm.upgrades) { if (ymup.GetValue("name__") == allupgrades[cns].GetValue("name__")) { affected_modules.Add(yapm.GetModuleDisplayName() + " => " + ymup.GetValue("description__")); } } } } // Using PartUpgradeManager.Handler to access the Upgrade as located in the Tech Tree referred // in the PartModules and find out its in-game name and description. var nameforcurrentupgrade = allupgrades[cns].GetValue("name__"); var currentupgrade = PartUpgradeManager.Handler.GetUpgrade(nameforcurrentupgrade); if (affected_modules[0] == " => ") { affected_modules[0] = "See general description for details"; } var single_upgrade_button = new DialogGUIToggleButton(() => !ListOfTemporarilyDisabledUpgrades.Contains(currentupgrade.name), currentupgrade.title, OnButtonClick_Upgrade(currentupgrade), button_width, button_height); //PartUpgradeManager.Handler.IsEnabled(currentupgrade.name) var single_modules_button = new DialogGUIBox(string.Join("\n", affected_modules.ToArray()), 250, button_height); var single_desc_button = new DialogGUIBox(currentupgrade.description, 340, button_height); var h = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { single_upgrade_button, single_modules_button, single_desc_button }); upgrade_line.Add(h); } scrollList = null; scrollList = new DialogGUIBase[upgrade_line.Count + 1]; scrollList[0] = new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true); for (int i = 0; i < upgrade_line.Count; i++) { scrollList[i + 1] = upgrade_line[i]; } upgrade_editor.Add(new DialogGUIScrollList(new Vector2(270, 200), false, true, new DialogGUIVerticalLayout(10, 100, 4, new RectOffset(6, 24, 10, 10), TextAnchor.UpperLeft, scrollList) )); upgrade_editor.Add(new DialogGUISpace(4)); upgrade_editor.Add(new DialogGUIHorizontalLayout(new DialogGUIBase[] { new DialogGUIFlexibleSpace(), new DialogGUIButton("Reset & Close", ResetUnlockedUpgrades), new DialogGUIFlexibleSpace(), new DialogGUIToggleButton(() => EnableAllUpgrades, "Toggle All", OnButtonClick_EnableAllUpgrades, -1, 30), new DialogGUIFlexibleSpace(), new DialogGUIToggleButton(() => PartUpgradeHandler.AllEnabled, "Always Enable", OnButtonClick_ToggleAllUpgrades, -1, 30), new DialogGUIFlexibleSpace(), new DialogGUIButton("Close", Dismiss) })); return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog( "Upgrade Editor", "", "Upgrade Editor", HighLogic.UISkin, // window origin is center of rect, position is offset from lower left corner of screen and normalized i.e (0.5, 0.5 is screen center) new Rect(0.5f, 0.5f, width, height), upgrade_editor.ToArray()), false, HighLogic.UISkin)); }