// constructor public Profiler() { // enable global access instance = this; // create window dialog_items = new DialogGUIVerticalLayout(); multi_dialog = new MultiOptionDialog( "TrajectoriesProfilerWindow", "", GetTitle(), HighLogic.UISkin, new Rect(0.5f, 0.5f, width, height), new DialogGUIBase[] { // 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 - 15)), // create scrollbox for entry data new DialogGUIScrollList(new Vector2(), false, true, dialog_items) }); }
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 }); }
protected override List <DialogGUIBase> drawContentComponents() { List <DialogGUIBase> listComponments = new List <DialogGUIBase>(); listComponments.Add(new DialogGUILabel(Localizer.Format("#CNC_ConstellationControl_listComponments"), false, false));//"Manage communication networks of ground, air and space vessels." float btnWidth = (600 - 50) / 3; float btnHeight = 32; DialogGUIButton constellationBtn = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_ConstellationBtn"), delegate { displayContentLayout(ContentType.CONSTELLATIONS); }, btnWidth, btnHeight, false); //"Constellations" DialogGUIButton groundstationBtn = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_GroundstationBtn"), delegate { displayContentLayout(ContentType.GROUNDSTATIONS); }, btnWidth, btnHeight, false); //"Ground Stations" DialogGUIButton vesselBtn = new DialogGUIButton(Localizer.Format("#CNC_ConstellationControl_VesselBtn"), delegate { displayContentLayout(ContentType.VESSELS); }, btnWidth, btnHeight, false); //"CommNet Vessels" listComponments.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { constellationBtn, groundstationBtn, vesselBtn })); contentLayout = new DialogGUIVerticalLayout(true, false, 4, new RectOffset(5, 25, 5, 5), TextAnchor.UpperLeft, new DialogGUIBase[] { new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true) }); contentLayout.AddChildren(getVesselContentLayout().ToArray()); this.currentContentType = ContentType.VESSELS; scrollArea = new CustomDialogGUIScrollList(new Vector2(550, 250), false, true, contentLayout); listComponments.Add(scrollArea); sortVesselBtnLayout = new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, getVesselSortLayout()); listComponments.Add(sortVesselBtnLayout); return(listComponments); }
private DialogGUIToggleButton[] CreateMissionListItems() { List <DialogGUIToggleButton> list = new List <DialogGUIToggleButton>(); DialogGUIVerticalLayout dialogGUIVerticalLayout; DialogGUIToggleButton dialogGUIToggleButton; List <QuickLaunchMission> missions = quickLaunchVessel.GetMissions(); for (int i = 0; i < missions.Count; i++) { int missionIndex = i; QuickLaunchMission mission = missions[missionIndex]; dialogGUIToggleButton = new DialogGUIToggleButton(false, string.Empty, delegate { SelectItem(missionIndex); }, -1f, 1f); dialogGUIVerticalLayout = new DialogGUIVerticalLayout(true, false, 0f, new RectOffset(4, 4, 4, 4), TextAnchor.UpperLeft); dialogGUIVerticalLayout.AddChild(new DialogGUILabel(mission.missionName, skin.customStyles[0], true, false)); DialogGUIVerticalLayout dialogGUIVerticalLayout2 = dialogGUIVerticalLayout; Orbit orbit = mission.protoVessel.orbitSnapShot.Load(); CelestialBody body = orbit.referenceBody; string orbitBody = string.Format("<color=#ffffff>Orbiting {0}</color>", body.name); dialogGUIVerticalLayout2.AddChild(new DialogGUILabel(orbitBody, skin.customStyles[0], true, false)); string orbitInfo = string.Format("<color=#ffffff>Ap: {0}, Pe: {1}, Inc: {2}</color>", Utils.FormatAltitude(orbit.ApA), Utils.FormatAltitude(orbit.PeA), Math.Round(orbit.inclination, 3)); dialogGUIVerticalLayout.AddChild(new DialogGUILabel(orbitInfo, skin.customStyles[0], true, false)); dialogGUIToggleButton.AddChild(dialogGUIVerticalLayout); dialogGUIToggleButton.OptionInteractableCondition = (() => true); list.Add(dialogGUIToggleButton); } return(list.ToArray()); }
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 void OnTrue() { if (!FlightGlobals.ready || FlightGlobals.ActiveVessel == null) { return; } DialogGUIBase guiBase = new DialogGUIVerticalLayout(); bool Filter(VesselType t) => VesselType.Lander == t || VesselType.Probe == t || VesselType.Rover == t || VesselType.Ship == t || VesselType.Station == t; foreach (var vessel in FlightGlobals.Vessels.Where(v => v.id != FlightGlobals.ActiveVessel.id && Filter(v.vesselType))) { bool IsSelected() => FlightGlobals.ActiveVessel.targetObject != null; guiBase .WithHorizontal() .WithLabel(vessel.DiscoveryInfo.displayName.Value) .WithFlexible() .WithButton <ITargetable>("Set Target", target => FlightGlobals.fetch.SetVesselTarget(target, true), vessel, () => !IsSelected()) .WithButton <ITargetable>("Clear Target", target => FlightGlobals.fetch.SetVesselTarget(target, true), null, IsSelected); } var optionDialog = new MultiOptionDialog("Target Selector", string.Empty, "Select target", HighLogic.UISkin, guiBase); _dialog = PopupDialog.SpawnPopupDialog(Vector2.one * .5f, Vector2.one * .5f, optionDialog, false, UISkinManager.GetSkin("MainMenuSkin"), false); }
/// <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 }); }
// 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 }); }
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; }
public void AddEquipment() { Core.Log("AddEquipment"); double freeVolume = AvailableVolume; DialogGUIVerticalLayout partSelector = new DialogGUIVerticalLayout(); partSelector.AddChild(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.MinSize)); partSelector.AddChildren(PartLoader.LoadedPartsList .Where(ap => ap.IsEquipmentItem() && !ap.TechHidden && ResearchAndDevelopment.PartTechAvailable(ap) && ap.partPrefab != null) .OrderBy(ap => ap.category) .Select(ap => { double v = ap.GetPartVolume(); return(new DialogGUIButton(ap.title + " (" + v.ToString("N0") + " l)", () => EquipPart(ap), () => v <= freeVolume, 240, 30, true)); }).ToArray()); PopupDialog.SpawnPopupDialog( new MultiOptionDialog( "PartEquipmentAddPart", "", "Select Part to Add", HighLogic.UISkin, new DialogGUIScrollList(new Vector2(200, 400), false, true, partSelector), new DialogGUIButton("Cancel", null, 200, 30, true)), false, HighLogic.UISkin); }
/// <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); }
/// <summary> /// Clear layout of the list of vessels /// </summary> internal void ClearVesselListLayout() { // Clear events foreach (BVController controller in BonVoyage.Instance.BVControllers.Values) { controller.OnStateChanged -= OnControllerStateChanged; } vesselListLayout = null; }
public static DialogGUIVerticalLayout GUIVerticalLayout(Action optionBuilder, Modifier <DialogGUIVerticalLayout> modifier = null) { DialogGUIVerticalLayout element = new DialogGUIVerticalLayout(Declare(optionBuilder)); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
public static DialogGUIVerticalLayout GUIVerticalLayout(Single minWidth, Single minHeight, Single sp, RectOffset pad, TextAnchor achr, Action optionBuilder, Modifier <DialogGUIVerticalLayout> modifier = null) { DialogGUIVerticalLayout element = new DialogGUIVerticalLayout(minWidth, minHeight, sp, pad, achr, Declare(optionBuilder)); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
public static DialogGUIVerticalLayout GUIVerticalLayout(Boolean sw = false, Boolean sh = false, Modifier <DialogGUIVerticalLayout> modifier = null) { DialogGUIVerticalLayout element = new DialogGUIVerticalLayout(sw, sh); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
public static DialogGUIVerticalLayout GUIVerticalLayout(Single minWidth, Single minHeight, Action optionBuilder, Modifier <DialogGUIVerticalLayout> modifier = null) { DialogGUIVerticalLayout element = new DialogGUIVerticalLayout(minWidth, minHeight, Declare(optionBuilder)); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
/// <summary> /// Clear layout of the list of vessels /// </summary> internal void ClearVesselListLayout() { // Clear events int controllersCount = BonVoyage.Instance.BVControllers.Count; for (int i = 0; i < controllersCount; i++) { BonVoyage.Instance.BVControllers[i].OnStateChanged -= OnControllerStateChanged; } vesselListLayout = null; }
private PopupDialog DrawMainUi() { padding = 0; List <DialogGUIBase> dialogElements = new List <DialogGUIBase>(); List <DialogGUIBase> innerElements = new List <DialogGUIBase>(); if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { innerElements.Add(new DialogGUILabel("Bureaucracy is only available in Career Games")); } else { innerElements.Add(new DialogGUISpace(10)); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Next Budget: " + Utilities.Instance.ConvertUtToKspTimeStamp(BudgetManager.Instance.NextBudget.CompletionTime), false))); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Gross Budget: $" + Utilities.Instance.GetGrossBudget(), false))); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Wage Costs: $" + Costs.Instance.GetWageCosts(), false))); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Facility Maintenance Costs: $" + Costs.Instance.GetFacilityMaintenanceCosts(), false))); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Launch Costs: $" + Costs.Instance.GetLaunchCosts(), false))); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Mission Bonuses: $" + GetBonusesToPay(), false))); for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++) { Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i); if (m.Name == "Budget") { continue; } double departmentFunding = Math.Round(Utilities.Instance.GetNetBudget(m.Name), 0); if (departmentFunding < 0.0f) { continue; } innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(m.Name + " Department Funding: $" + departmentFunding, false))); } innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel("Net Budget: $" + Utilities.Instance.GetNetBudget("Budget"), false))); DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray()); vertical.AddChild(new DialogGUIContentSizer(widthMode: ContentSizeFitter.FitMode.Unconstrained, heightMode: ContentSizeFitter.FitMode.MinSize)); dialogElements.Add(new DialogGUIScrollList(new Vector2(300, 300), false, true, vertical)); DialogGUIBase[] horizontal = new DialogGUIBase[6]; horizontal[0] = new DialogGUILabel("Allocations: "); horizontal[1] = new DialogGUILabel("Funds: " + fundingAllocation + "%"); horizontal[2] = new DialogGUILabel("|"); horizontal[3] = new DialogGUILabel("Construction: " + constructionAllocation + "%"); horizontal[4] = new DialogGUILabel("|"); horizontal[5] = new DialogGUILabel("Research: " + researchAllocation + "%"); dialogElements.Add(new DialogGUIHorizontalLayout(horizontal)); dialogElements.Add(GetBoxes("main")); } return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("BureaucracyMain", "", "Bureaucracy: Budget", UISkinManager.GetSkin("MainMenuSkin"), GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false)); }
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 PopupDialog DrawBudgetAllocationUi() { padding = 0; List <DialogGUIBase> dialogElements = new List <DialogGUIBase>(); List <DialogGUIBase> innerElements = new List <DialogGUIBase>(); DialogGUIBase[] horizontalArray = new DialogGUIBase[4]; horizontalArray[0] = new DialogGUISpace(10); horizontalArray[1] = new DialogGUILabel("Budget", MessageStyle(true)); horizontalArray[2] = new DialogGUISpace(70); horizontalArray[3] = new DialogGUITextInput(fundingAllocation.ToString(), false, 3, s => SetAllocation("Budget", s), 40.0f, 30.0f); innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray)); horizontalArray = new DialogGUIBase[4]; horizontalArray[0] = new DialogGUISpace(10); horizontalArray[1] = new DialogGUILabel("Construction", MessageStyle(true)); horizontalArray[2] = new DialogGUISpace(10); horizontalArray[3] = new DialogGUITextInput(constructionAllocation.ToString(), false, 3, s => SetAllocation("Construction", s), 40.0f, 30.0f); innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray)); horizontalArray = new DialogGUIBase[4]; horizontalArray[0] = new DialogGUISpace(10); horizontalArray[1] = new DialogGUILabel("Research", MessageStyle(true)); horizontalArray[2] = new DialogGUISpace(45); horizontalArray[3] = new DialogGUITextInput(researchAllocation.ToString(), false, 3, s => SetAllocation("Research", s), 40.0f, 30.0f); innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray)); for (int i = 0; i < Bureaucracy.Instance.registeredManagers.Count; i++) { Manager m = Bureaucracy.Instance.registeredManagers.ElementAt(i); // ReSharper disable once CompareOfFloatsByEqualityOperator if (Utilities.Instance.GetNetBudget(m.Name) == -1.0f) { continue; } horizontalArray = new DialogGUIBase[3]; horizontalArray[0] = new DialogGUISpace(10); horizontalArray[1] = new DialogGUILabel(m.Name + ": "); horizontalArray[2] = new DialogGUILabel(() => ShowFunding(m)); innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray)); } horizontalArray = new DialogGUIBase[2]; horizontalArray[0] = new DialogGUISpace(10); horizontalArray[1] = new DialogGUIButton("Load Settings", () => SettingsClass.Instance.InGameLoad(), false); innerElements.Add(new DialogGUIHorizontalLayout(horizontalArray)); DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray()); dialogElements.Add(new DialogGUIScrollList(-Vector2.one, false, false, vertical)); dialogElements.Add(GetBoxes("allocation")); return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("Bureaucracy", "", "Bureaucracy: Budget Allocation", UISkinManager.GetSkin("MainMenuSkin"), GetRect(dialogElements), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin"), false)); }
// Kittopia Additions public static DialogGUIVerticalLayout GUIVerticalLayout(Boolean sw, Boolean sh, Action optionBuilder, Modifier <DialogGUIVerticalLayout> modifier = null) { DialogGUIVerticalLayout element = new DialogGUIVerticalLayout(Declare(optionBuilder)) { stretchWidth = sw, stretchHeight = sh }; if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
// TODO: Complete implementation private void showAddWindow() { // This is a list of content items to add to the dialog List <DialogGUIBase> dialog = new List <DialogGUIBase>(); var noPad = new RectOffset(); DialogGUIButton b; DialogGUILabel l; DialogGUIHorizontalLayout hl; DialogGUIVerticalLayout vl; // Window Contents - scroll list of all available experiments with their descriptions vl = new DialogGUIVerticalLayout(true, false); vl.padding = new RectOffset(6, 24, 6, 6); // Padding between border and contents - ensure we don't overlay content over scrollbar vl.spacing = 4; // Spacing between elements vl.AddChild(new DialogGUIContentSizer(ContentSizeFitter.FitMode.Unconstrained, ContentSizeFitter.FitMode.PreferredSize, true)); int numExperiments = availableExperiments.Count; for (int idx = 0; idx < numExperiments; idx++) { var e = availableExperiments[idx]; b = new DialogGUIButton <ExperimentData>(e.getAbbreviation(), onAddExperiment, e, true); b.size = new Vector2(60, 30); l = new DialogGUILabel(e.getDescription(), true, false); hl = new DialogGUIHorizontalLayout(false, false, 4, new RectOffset(), TextAnchor.MiddleCenter, b, l); vl.AddChild(hl); } hl = new DialogGUIHorizontalLayout(true, true, new DialogGUIScrollList(Vector2.one, false, true, vl)); dialog.Add(hl); // 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 Rect pos = new Rect(0.5f, 0.5f, 400, 400); PopupDialog.SpawnPopupDialog( new MultiOptionDialog("", "", "#ne_Add_Experiment", HighLogic.UISkin, pos, dialog.ToArray()), false, HighLogic.UISkin); }
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) })); //Current group DialogGUILabel currentLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_currentLevelLabel") + "</b>");//Current tech level currentTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture(this.hostStation.TechLevel)); DialogGUILabel currentPower = new DialogGUILabel(currentPowerFunc); DialogGUIVerticalLayout currentLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { currentLevelLabel, currentTexture, currentPower }); //Upgrade arrow DialogGUIImage arrowTexture = new DialogGUIImage(new Vector2(40, 40), Vector2.zero, Color.white, upgradeArrowTexture); //Next group DialogGUILabel nextLevelLabel = new DialogGUILabel("<b>" + Localizer.Format("#CNC_GroundStationBuild_nextLevelLabel") + "</b>");//Next tech level nextTexture = new DialogGUIImage(new Vector2(100, 100), Vector2.zero, Color.white, getLevelTexture((short)(this.hostStation.TechLevel + 1))); DialogGUILabel nextPower = new DialogGUILabel(nextPowerFunc); DialogGUIVerticalLayout nextLevelGroup = new DialogGUIVerticalLayout(100, 100, 4, new RectOffset(), TextAnchor.MiddleCenter, new DialogGUIBase[] { nextLevelLabel, nextTexture, nextPower }); listComponments.Add(new CustomDialogGUIScrollList(new Vector2(300 - 10, 150), false, false, new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { currentLevelGroup, arrowTexture, nextLevelGroup }))); //Requirements if (Funding.Instance != null) //only available in Career mode { DialogGUILabel costLabel = new DialogGUILabel(costFunc); DialogGUILabel availableLabel = new DialogGUILabel(availableFunc); listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { costLabel })); listComponments.Add(new DialogGUIHorizontalLayout(TextAnchor.MiddleCenter, new DialogGUIBase[] { availableLabel })); } listComponments.Add(new DialogGUISpace(10)); DialogGUIButton upgradeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Upgradebutton"), onClickUpgrade, false);//Upgrade upgradeButton.OptionInteractableCondition = () => this.hostStation.TechLevel < 3 ? true : false; DialogGUIButton closeButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_Close"), delegate { this.dismiss(); }, false);//Close DialogGUIHorizontalLayout actionGroup = new DialogGUIHorizontalLayout(true, false, 4, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIFlexibleSpace(), upgradeButton, closeButton, new DialogGUIFlexibleSpace() }); listComponments.Add(actionGroup); return(listComponments); }
/// <summary> /// This function gets called when the user clicks the "New Game" button in the main menu /// </summary> void OnNewGameBtnTap() { FieldInfo createGameDialog = typeof(MainMenu).GetFields(BindingFlags.NonPublic | BindingFlags.Instance).FirstOrDefault(f => f.FieldType == typeof(PopupDialog)); if (createGameDialog == null) { return; } PopupDialog dialog = createGameDialog.GetValue(menu) as PopupDialog; if (dialog == null) { return; } if (dialog.dialogToDisplay == null) { return; } DialogGUIHorizontalLayout d1 = dialog.dialogToDisplay.Options[0] as DialogGUIHorizontalLayout; if (d1 == null) { return; } DialogGUIVerticalLayout d2 = d1.children[0] as DialogGUIVerticalLayout; if (d2 == null) { return; } // Create the new layout DialogGUIHorizontalLayout layout = new DialogGUIHorizontalLayout(new DialogGUIBase[] { new DialogGUILabel(Localizer.Format("#LOC_PlanetaryDiversity_SeedParams_Seed"), true, false), new DialogGUIFlexibleSpace(), new DialogGUITextInput(Seed ?? "", Localizer.Format("#LOC_PlanetaryDiversity_SeedParams_Placeholder"), false, 32, (s) => Seed = s, 200f, 30f) }); d2.children.Insert(1, layout); d1.children[0] = d2; dialog.dialogToDisplay.Options[0] = d1; PopupDialog newDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), dialog.dialogToDisplay, false, menu.guiSkinDef.SkinDef, true, ""); dialog.Dismiss(); createGameDialog.SetValue(menu, newDialog); }
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); }
public void OnEventFire() { List <DialogGUIBase> dialogElements = new List <DialogGUIBase>(); List <DialogGUIBase> innerElements = new List <DialogGUIBase>(); innerElements.Add(new DialogGUISpace(10)); innerElements.Add(new DialogGUIHorizontalLayout(PaddedLabel(Body))); DialogGUIVerticalLayout vertical = new DialogGUIVerticalLayout(innerElements.ToArray()); dialogElements.Add(new DialogGUIScrollList(-Vector2.one, false, false, vertical)); dialogElements.Add(new DialogGUIButton(AcceptString, OnEventAccepted)); if (CanBeDeclined) { dialogElements.Add(new DialogGUIButton(declineString, OnEventDeclined)); } eventDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("EventDialog", "", Title, UISkinManager.GetSkin("MainMenuSkin"), new Rect(0.5f, 0.5f, 300, 200), dialogElements.ToArray()), false, UISkinManager.GetSkin("MainMenuSkin")); }
private void Show(Action <PartSetupDialog> onSet) { this.CalculateTierLabels(false); var tierSelector = new DialogGUIVerticalLayout(this.tierToggles); DialogGUIBase mainForm; if (this.Product.ResearchCategory.Type == ProductionRestriction.Space) { mainForm = tierSelector; } else { var bodySelector = new DialogGUIVerticalLayout( ColonizationResearchScenario.Instance.UnlockedBodies .Select(b => new DialogGUIToggle(() => b == this.Body, b, isSelected => { if (isSelected) { this.SetBody(b); } })).ToArray()); mainForm = new DialogGUIHorizontalLayout( tierSelector, new DialogGUISpace(50), bodySelector); } PopupDialog.SpawnPopupDialog( new MultiOptionDialog( "Whatsthisdoeven", "", // This actually shows up on the screen as a sort of a wierd-looking subtitle "Tiered Part Configuration", HighLogic.UISkin, new DialogGUIVerticalLayout( mainForm, new DialogGUIHorizontalLayout( new DialogGUIButton("Setup This Part", () => { this.Applicability = DecisionImpact.ThisPart; onSet(this); }, dismissOnSelect: true), new DialogGUIFlexibleSpace(), new DialogGUIButton("Setup All Parts", () => { this.Applicability = DecisionImpact.AllParts; onSet(this); }, dismissOnSelect: true), new DialogGUIFlexibleSpace(), new DialogGUIButton("Cancel", () => { }, dismissOnSelect: true)))), persistAcrossScenes: false, skin: HighLogic.UISkin, isModal: true, titleExtra: "TITLE EXTRA!"); }
private PopupDialog GenerateDialog() { List <DialogGUIBase> guiItems = new List <DialogGUIBase>(); if (EditorLogic.fetch == null || EditorLogic.fetch.ship == null) { guiItems.Add(new DialogGUILabel("No Vessel Detected")); } else { guiItems.Add(new DialogGUILabel(_utilities.SystemNotes, _utilities.CreateNoteStyle())); guiItems.Add(new DialogGUILabel(_utilities.Warnings, _utilities.CreateNoteStyle())); DialogGUIBase[] vertical = new DialogGUIBase[_utilities.Planets.Count]; DialogGUIBase[] horizontal = new DialogGUIBase[2]; horizontal[0] = new DialogGUIToggle(() => _returnTrip, "Return Trip?", delegate { SetReturnTrip(); }); horizontal[1] = new DialogGUIToggle(() => payloadOnly, "Payload Only", delegate { SetPayoadOnly(); }); guiItems.Add(new DialogGUIHorizontalLayout(horizontal)); for (int i = 0; i < _utilities.Planets.Count; i++) { PlanetDeltaV p = _utilities.Planets.ElementAt(i); horizontal = new DialogGUIBase[4]; horizontal[0] = new DialogGUILabel(p.GetName(), _utilities.GenerateStyle(-1, false)); horizontal[1] = GetDeltaVString(p, "Flyby: "); horizontal[2] = GetDeltaVString(p, "Orbiting: "); if (p.IsHomeWorld && p.SynchronousDv != -1) { horizontal[3] = GetDeltaVString(p, "Synchronous Orbit: "); } else { horizontal[3] = GetDeltaVString(p, "Landing: "); } vertical[i] = new DialogGUIHorizontalLayout(horizontal); } DialogGUIVerticalLayout layout = new DialogGUIVerticalLayout(vertical); guiItems.Add(new DialogGUIScrollList(-Vector2.one, false, true, layout)); } guiItems.Add(new DialogGUILabel("*Assuming craft has enough chutes")); guiItems.Add(new DialogGUIButton("Close", () => _utilities.CloseDialog(_uiDialog), false)); return(PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("WhereCanIGoDialog", "", "Where Can I Go", UISkinManager.defaultSkin, _geometry, guiItems.ToArray()), false, UISkinManager.defaultSkin)); }
public override List <DialogGUIBase> getContentComponents() { List <DialogGUIBase> layout = new List <DialogGUIBase>(); DialogGUILabel msgLbl = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_msgLabel2"), 100, 16);//"Change the frequency of each antenna." layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl })); freqInputArray = new DialogGUITextInput[antennas.Count]; DialogGUIVerticalLayout nameColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIVerticalLayout useColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIVerticalLayout freqColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIVerticalLayout freqInputColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIVerticalLayout updateColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); for (int i = 0; i < antennas.Count; i++) { int index = i;//convert to solid-reference variable for delegate block CNCAntennaPartInfo antennaInfo = antennas[i]; DialogGUILabel nameLabel = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_nameLabel", antennaInfo.name), style); nameLabel.size = new Vector2(200, 32); //string.Format("Name: {0}",) DialogGUILabel usageLabel = new DialogGUILabel(Localizer.Format("#CNC_getContentCompon_usageLabel") + ": " + (antennaInfo.inUse ? "<color=green>" + Localizer.Format("#CNC_Generic_Yes") + "</color>" : "<color=red>" + Localizer.Format("#CNC_Generic_No") + "</color>"), style); usageLabel.size = new Vector2(75, 32); //In UseYesNo DialogGUILabel freqLabel = new DialogGUILabel(Localizer.Format("#CNC_Generic_FrequencyLabel"), style); freqLabel.size = new Vector2(65, 32); //"Frequency" freqInputArray[i] = new DialogGUITextInput(antennaInfo.frequency.ToString(), false, CNCSettings.MaxDigits, setAntennaFreq, 65, 25); DialogGUIButton updateButton = new DialogGUIButton(Localizer.Format("#CNC_Generic_UpdateButton"), delegate { updateAntennaFreq(antennaInfo, freqInputArray[index].uiItem.GetComponent <TMP_InputField>().text); }, 70, 25, false); //"Update" nameColumn.AddChild(nameLabel); useColumn.AddChild(usageLabel); freqColumn.AddChild(freqLabel); freqInputColumn.AddChild(new DialogGUISpace(3)); freqInputColumn.AddChild(freqInputArray[index]); freqInputColumn.AddChild(new DialogGUISpace(4)); updateColumn.AddChild(new DialogGUISpace(3)); updateColumn.AddChild(updateButton); updateColumn.AddChild(new DialogGUISpace(4)); } layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { nameColumn, useColumn, freqColumn, freqInputColumn, updateColumn })); return(layout); }
void LoadPresetPopup() { // Need to prevent keyboard and mouse clicks from passing thru popup. if (!File.Exists(KSPUtil.ApplicationRootPath + "GameData/AGpanel/PluginsData/Presets.txt")) { ScreenMessages.PostScreenMessage("Preset File Not Found!\nYou need to Save a preset first"); return; } ConfigNode rootNode = ConfigNode.Load(KSPUtil.ApplicationRootPath + "GameData/AGpanel/PluginsData/Presets.txt"); List <DialogGUIBase> guiBaseList = new List <DialogGUIBase>(); guiBaseList.Add(new DialogGUIFlexibleSpace()); foreach (ConfigNode cn in rootNode.GetNodes()) { guiBaseList.Add(new DialogGUIButton(cn.name, delegate { LoadPreset(cn); }, 140.0f, 30.0f, true)); } guiBaseList.Add(new DialogGUIButton("Close", () => { }, 140.0f, 30.0f, true)); DialogGUIVerticalLayout vertLayout = new DialogGUIVerticalLayout(guiBaseList.ToArray()); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new MultiOptionDialog("LoadPreset", "", "Load Preset", HighLogic.UISkin, new Rect(0.5f, 0.5f, 150f, 30f), new DialogGUIFlexibleSpace(), vertLayout), false, HighLogic.UISkin); }