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); }
public static DialogGUIToggleGroup GUIToggleGroup(Action optionBuilder, Modifier <DialogGUIToggleGroup> modifier = null) { DialogGUIToggleGroup element = new DialogGUIToggleGroup(Declare(optionBuilder).Select(e => e as DialogGUIToggle).ToArray()); if (modifier != null) { element = modifier(element); } _elements.Add(element); return(element); }
public override List <DialogGUIBase> getContentComponents() { List <DialogGUIBase> layout = new List <DialogGUIBase>(); DialogGUILabel msgLbl = new DialogGUILabel("Decide how the vessel's frequency list should be updated whenever one antenna is changed (eg extended/retracted or frequency change).", 100, 32); layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { msgLbl })); DialogGUIToggleGroup toggleGrp = new DialogGUIToggleGroup(); DialogGUIVerticalLayout nameColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIVerticalLayout descriptionColumn = new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft); DialogGUIToggle toggleBtn1 = new DialogGUIToggle((cncVessel.FreqListOperation == FrequencyListOperation.AutoBuild) ? true : false, "", delegate(bool b) { ListOperationSelected(b, FrequencyListOperation.AutoBuild); }, 20, 32); DialogGUILabel nameLabel1 = new DialogGUILabel("Auto Build", style); nameLabel1.size = new Vector2(80, 32); DialogGUILabel descriptionLabel1 = new DialogGUILabel("Rebuild the list from all antennas automatically", style); descriptionLabel1.size = new Vector2(350, 32); toggleGrp.AddChild(toggleBtn1); nameColumn.AddChild(nameLabel1); descriptionColumn.AddChild(descriptionLabel1); DialogGUIToggle toggleBtn2 = new DialogGUIToggle((cncVessel.FreqListOperation == FrequencyListOperation.LockList) ? true : false, "", delegate(bool b) { ListOperationSelected(b, FrequencyListOperation.LockList); }, 20, 32); DialogGUILabel nameLabel2 = new DialogGUILabel("Lock List", style); nameLabel2.size = new Vector2(80, 32); DialogGUILabel descriptionLabel2 = new DialogGUILabel("Disallow any change in the current list (except for staging)", style); descriptionLabel2.size = new Vector2(350, 32); toggleGrp.AddChild(toggleBtn2); nameColumn.AddChild(nameLabel2); descriptionColumn.AddChild(descriptionLabel2); /* * DialogGUIToggle toggleBtn3 = new DialogGUIToggle((cncVessel.FreqListOperation == FrequencyListOperation.UpdateOnly) ? true : false, "", delegate (bool b) { ListOperationSelected(b, FrequencyListOperation.UpdateOnly); }, 20, 32); * DialogGUILabel nameLabel3 = new DialogGUILabel("Freq Only", style); nameLabel3.size = new Vector2(80, 32); * DialogGUILabel descriptionLabel3 = new DialogGUILabel("Update the affected frequency in the list only (not yet)", style); descriptionLabel3.size = new Vector2(350, 32); * toggleGrp.AddChild(toggleBtn3); * nameColumn.AddChild(nameLabel3); * descriptionColumn.AddChild(descriptionLabel3); */ layout.Add(new DialogGUIHorizontalLayout(true, false, 0, new RectOffset(), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIVerticalLayout(false, false, 0, new RectOffset(), TextAnchor.MiddleLeft, toggleGrp), nameColumn, descriptionColumn })); return(layout); }
/// <summary> /// This function gets called when the user clicks the "New Game" button in the main menu /// </summary> void OnNewGameBtnTap() { // Grab internal values FieldInfo createGameDialog = typeof(MainMenu).GetFields(BindingFlags.NonPublic | BindingFlags.Instance) .FirstOrDefault(f => f.FieldType == typeof(PopupDialog)); if (createGameDialog == null) { return; } FieldInfo newGameMode = typeof(MainMenu).GetFields(BindingFlags.NonPublic | BindingFlags.Static) .FirstOrDefault(f => f.FieldType == typeof(Game.Modes)); if (newGameMode == null) { return; } FieldInfo newGameParameters = typeof(MainMenu).GetFields(BindingFlags.NonPublic | BindingFlags.Static) .FirstOrDefault(f => f.FieldType == typeof(GameParameters)); if (newGameParameters == null) { return; } MethodInfo UpdatedGameParameters = typeof(MainMenu).GetMethod("UpdatedGameParameters", BindingFlags.NonPublic | BindingFlags.Instance); if (UpdatedGameParameters == null) { return; } // Descent into the popup dialog 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; } DialogGUIHorizontalLayout d3 = d2.children[1] as DialogGUIHorizontalLayout; if (d3 == null) { return; } DialogGUIVerticalLayout d4 = d3.children[2] as DialogGUIVerticalLayout; if (d4 == null) { return; } DialogGUIToggleGroup d5 = d4.children[0] as DialogGUIToggleGroup; if (d5 == null) { return; } // Create the new layout DialogGUIToggle scienceboxButton = new DialogGUIToggle( (Game.Modes)newGameMode.GetValue(null) == Game.Modes.SCIENCE_SANDBOX && Sciencebox, Localizer.Format("#LOC_SCIENCEBOX_NAME"), b => { if ((Game.Modes)newGameMode.GetValue(null) != Game.Modes.SCIENCE_SANDBOX) { newGameMode.SetValue(null, Game.Modes.SCIENCE_SANDBOX); newGameParameters.SetValue(null, UpdatedGameParameters.Invoke(menu, new[] { newGameParameters.GetValue(null) })); } Sciencebox = true; }, 200f, 30f); DialogGUIToggle scienceButton = new DialogGUIToggle((Game.Modes)newGameMode.GetValue(null) == Game.Modes.SCIENCE_SANDBOX && !Sciencebox, Localizer.Format("#autoLOC_190714"), b => { if ((Game.Modes)newGameMode.GetValue(null) != Game.Modes.SCIENCE_SANDBOX) { newGameMode.SetValue(null, Game.Modes.SCIENCE_SANDBOX); newGameParameters.SetValue(null, UpdatedGameParameters.Invoke(menu, new[] { newGameParameters.GetValue(null) })); } Sciencebox = false; }, 200f, 30f); d5.children.Insert(2, scienceboxButton); d5.children[1] = scienceButton; d4.children[0] = d5; d3.children[2] = d4; d2.children[1] = d3; d1.children[0] = d2; dialog.dialogToDisplay.Options[0] = d1; DialogGUIBox scienceboxBox = new DialogGUIBox(string.Empty, -1f, 100f, () => (Game.Modes)newGameMode.GetValue(null) == Game.Modes.SCIENCE_SANDBOX && Sciencebox, new DialogGUIBase[] { new DialogGUIHorizontalLayout(false, false, 2f, new RectOffset(8, 8, 8, 8), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIImage(new Vector2(96f, 96f), Vector2.zero, Color.white, menu.scienceSandboxIcon), new DialogGUILabel( Localizer.Format("#LOC_SCIENCEBOX_TEXT1") + "\n\n" + Localizer.Format("#LOC_SCIENCEBOX_TEXT2"), menu.guiSkinDef.SkinDef.customStyles[6], true, true) }) }); DialogGUIBox scienceBox = new DialogGUIBox(string.Empty, -1f, 100f, () => (Game.Modes)newGameMode.GetValue(null) == Game.Modes.SCIENCE_SANDBOX && !Sciencebox, new DialogGUIBase[] { new DialogGUIHorizontalLayout(false, false, 2f, new RectOffset(8, 8, 8, 8), TextAnchor.MiddleLeft, new DialogGUIBase[] { new DialogGUIImage(new Vector2(96f, 96f), Vector2.zero, Color.white, menu.scienceSandboxIcon), new DialogGUILabel( Localizer.Format("#autoLOC_190750") + "\n\n" + Localizer.Format("#autoLOC_190751"), menu.guiSkinDef.SkinDef.customStyles[6], true, true) }) }); List <DialogGUIBase> elements = dialog.dialogToDisplay.Options.ToList(); elements[2] = scienceBox; elements.Insert(3, scienceboxBox); dialog.dialogToDisplay.Options = elements.ToArray(); 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); }