private void OnAddComponentPressed() { ListSelectionDialog compTypeSelector = new ListSelectionDialog { FilteredType = typeof(Component), SelectType = true }; DialogResult result = compTypeSelector.ShowDialog(); if (result == DialogResult.OK) { UndoRedoManager.BeginMacro("Add Component"); foreach (GameObject obj in this.GetValue().Cast <GameObject>()) { // Skip adding components that already exist in the target object Component existingComponent = obj.GetComponent(compTypeSelector.TypeReference); if (existingComponent != null && existingComponent.GetType() == compTypeSelector.TypeReference) { continue; } UndoRedoManager.Do(new CreateComponentAction(obj, compTypeSelector.TypeReference)); } UndoRedoManager.EndMacro("Add Component"); this.PerformGetValue(); this.ParentGrid.Invalidate(); } // Keeps add component button from being locked to the pressed // state caused by the SelectionDialog being modal this.curButton = -1; this.curButtonHovered = false; this.curButtonPressed = false; }
private void OnAddComponentClicked() { ListSelectionDialog compTypeSelector = new ListSelectionDialog { FilteredType = typeof(Component), SelectType = true }; DialogResult result = compTypeSelector.ShowDialog(); this.dialogClosedTime = DateTime.Now; if (result == DialogResult.OK) { UndoRedoManager.BeginMacro("Add Component"); foreach (GameObject obj in this.GetValue().Cast <GameObject>()) { // Skip adding components that already exist in the target object Component existingComponent = obj.GetComponent(compTypeSelector.TypeReference); if (existingComponent != null && existingComponent.GetType() == compTypeSelector.TypeReference) { continue; } UndoRedoManager.Do(new CreateComponentAction(obj, compTypeSelector.TypeReference)); } UndoRedoManager.EndMacro("Add Component"); this.PerformGetValue(); this.ParentGrid.Invalidate(); } }
protected void ShowContentSelectionDialog() { ListSelectionDialog resourceSelectionForm = new ListSelectionDialog { FilteredType = this.FilteredType, ResourcePath = this.ReferenceName }; DialogResult result = resourceSelectionForm.ShowDialog(); if (result == DialogResult.OK) { DataObject dataObject = new DataObject(); if (resourceSelectionForm.ResourceReference != null) { dataObject.SetContentRefs(new[] { resourceSelectionForm.ResourceReference }); } else if (this.ReferenceType == typeof(GameObject)) { dataObject.SetGameObjectRefs(new[] { resourceSelectionForm.GameObjectReference }); } else { dataObject.SetComponentRefs(new[] { resourceSelectionForm.ComponentReference }); } DeserializeFromData(dataObject); } }
public static IObservable <T> ShowSelectionDialog <T>(this Activity activity, string title, IEnumerable <SelectOption <T> > options, int initialSelectionIndex = 0) { return(Observable.Create <T>(observer => { var dialog = new ListSelectionDialog <T>(activity, title, options, initialSelectionIndex, observer.CompleteWith); activity.RunOnUiThread(dialog.Show); return Disposable.Empty; })); }
/// <summary> /// Gets a concrete type from the user that extends from the given type. /// </summary> /// <param name="type">The abstract type to get a concrete type for</param> /// <param name="typeWithRequirement">The type that needs this requirement satisfied</param> private static Type GetRequiredConcreteType(Type type, Type typeWithRequirement) { ListSelectionDialog typeDialog = new ListSelectionDialog { FilteredType = type, SelectType = true, HeaderText = string.Format("{0} requires one of the following components. Please select one.", typeWithRequirement.GetTypeCSCodeName(true)) }; DialogResult result = typeDialog.ShowDialog(); return(result == DialogResult.OK ? typeDialog.TypeReference : null); }
internal void SelectDB() { List <string> databases = blockStore.GetDatabaseList(); ListSelectionDialog dialog = new ListSelectionDialog(); dialog.Populate(databases); if (dialog.ShowDialog() == DialogResult.OK) { string db = dialog.SelectedItem(); if (db != "") { SelectDB(db); } } }
internal void SelectGateConfigForDemodulation() { List <string> gateConfigNames = new List <string>(this.currentGateSetDictionary.Keys); ListSelectionDialog dialog = new ListSelectionDialog(); dialog.Populate(gateConfigNames); if (dialog.ShowDialog() == DialogResult.OK) { string gateConfigSelected = dialog.SelectedItem(); if (gateConfigSelected != "") { selectedGateConfigName = gateConfigSelected; } } }
public override void Update() { if (this.UpdataButton.IsClicked) { DialogsManager.HideDialog(this); SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>(); foreach (TerrainChunk terrainChunk in subsystemTerrain.Terrain.AllocatedChunks) { foreach (SubsystemBlockBehavior subsystemBlockBehavior in GameManager.Project.FindSubsystem <SubsystemBlockBehaviors>().BlockBehaviors) { subsystemBlockBehavior.OnChunkDiscarding(terrainChunk); } int chunkX = terrainChunk.Coords.X; int chunkY = terrainChunk.Coords.Y; subsystemTerrain.Dispose(); subsystemTerrain.Load(new ValuesDictionary()); player.ComponentGui.DisplaySmallMessage("刷新完成!", true, false); } } if (this.OKButton.IsClicked) { DialogsManager.HideDialog(this); } if (this.UpdataWorldButton.IsClicked) { DialogsManager.HideDialog(this); WorldInfo world = GameManager.WorldInfo; GameManager.SaveProject(true, true); GameManager.DisposeProject(); object[] expr_E9 = new object[2]; expr_E9[0] = world; ScreensManager.SwitchScreen("GameLoading", expr_E9); } if (this.paletteButton.IsClicked) { DialogsManager.ShowDialog(null, new CreatorModAPIEditPaletteDialog(worldSettings.Palette)); } Texture2D texture = this.blockTexturesCache.GetTexture(this.worldSettings.BlocksTextureName); this.blocksTextureIcon.Subtexture = new Subtexture(texture, Vector2.Zero, Vector2.One); this.blocksTextureLabel.Text = BlocksTexturesManager.GetDisplayName(this.worldSettings.BlocksTextureName); this.blocksTextureDetails.Text = string.Format("{0}x{1}", texture.Width, texture.Height); if (this.blocksTextureButton.IsClicked) { BlocksTexturesManager.UpdateBlocksTexturesList(); ListSelectionDialog dialog = new ListSelectionDialog("Select Blocks Texture", BlocksTexturesManager.BlockTexturesNames, 64f, delegate(object item) { XElement node = ContentManager.Get <XElement>("Widgets/BlocksTextureItem"); ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(this, node, null); Texture2D texture2 = this.blockTexturesCache.GetTexture((string)item); containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Text", true).Text = BlocksTexturesManager.GetDisplayName((string)item); containerWidget.Children.Find <LabelWidget>("BlocksTextureItem.Details", true).Text = string.Format("{0}x{1}", texture2.Width, texture2.Height); containerWidget.Children.Find <RectangleWidget>("BlocksTextureItem.Icon", true).Subtexture = new Subtexture(texture2, Vector2.Zero, Vector2.One); return(containerWidget); }, delegate(object item) { this.worldSettings.BlocksTextureName = (string)item; SubsystemBlocksTexture subsystemBlocksTexture = GameManager.Project.FindSubsystem <SubsystemBlocksTexture>(); subsystemBlocksTexture.Dispose(); subsystemBlocksTexture.Load(new ValuesDictionary()); }); DialogsManager.ShowDialog(null, dialog); } if (this.supernaturalCreaturesButton.IsClicked) { this.worldSettings.AreSupernaturalCreaturesEnabled = !this.worldSettings.AreSupernaturalCreaturesEnabled; } if (this.environmentBehaviorButton.IsClicked) { IList <int> enumValues2 = EnumUtils.GetEnumValues(typeof(EnvironmentBehaviorMode)); this.worldSettings.EnvironmentBehaviorMode = (EnvironmentBehaviorMode)((enumValues2.IndexOf((int)this.worldSettings.EnvironmentBehaviorMode) + 1) % enumValues2.Count); } if (this.timeOfDayButton.IsClicked) { IList <int> enumValues3 = EnumUtils.GetEnumValues(typeof(TimeOfDayMode)); this.worldSettings.TimeOfDayMode = (TimeOfDayMode)((enumValues3.IndexOf((int)this.worldSettings.TimeOfDayMode) + 1) % enumValues3.Count); } if (this.weatherEffectsButton.IsClicked) { this.worldSettings.AreWeatherEffectsEnabled = !this.worldSettings.AreWeatherEffectsEnabled; } if (this.adventureRespawnButton.IsClicked) { this.worldSettings.IsAdventureRespawnAllowed = !this.worldSettings.IsAdventureRespawnAllowed; } if (this.adventureSurvivalMechanicsButton.IsClicked) { this.worldSettings.AreAdventureSurvivalMechanicsEnabled = !this.worldSettings.AreAdventureSurvivalMechanicsEnabled; } if (this.terrainGenerationButton.IsClicked) { IList <int> enumValues = EnumUtils.GetEnumValues(typeof(TerrainGenerationMode)); DialogsManager.ShowDialog(null, new ListSelectionDialog("Select World Type", enumValues, 56f, (object e) => ((TerrainGenerationMode)e).ToString(), delegate(object e) { this.worldSettings.TerrainGenerationMode = (TerrainGenerationMode)e; SubsystemTerrain subsystemTerrain = GameManager.Project.FindSubsystem <SubsystemTerrain>(); if ((TerrainGenerationMode)e == TerrainGenerationMode.Flat) { subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGeneratorFlat(subsystemTerrain); } else { subsystemTerrain.TerrainContentsGenerator = new TerrainContentsGenerator(subsystemTerrain); } })); } if (this.seaLevelOffsetSlider.IsSliding) { this.worldSettings.SeaLevelOffset = (int)this.seaLevelOffsetSlider.Value; } if (this.temperatureOffsetSlider.IsSliding) { this.worldSettings.TemperatureOffset = this.temperatureOffsetSlider.Value; } if (this.humidityOffsetSlider.IsSliding) { this.worldSettings.HumidityOffset = this.humidityOffsetSlider.Value; } if (this.biomeSizeSlider.IsSliding) { this.worldSettings.BiomeSize = this.biomeSizes[MathUtils.Clamp((int)this.biomeSizeSlider.Value, 0, this.biomeSizes.Length - 1)]; } if (this.islandSizeEW.IsSliding) { this.worldSettings.IslandSize.X = this.islandSizes[MathUtils.Clamp((int)this.islandSizeEW.Value, 0, this.islandSizes.Length - 1)]; } if (this.islandSizeNS.IsSliding) { this.worldSettings.IslandSize.Y = this.islandSizes[MathUtils.Clamp((int)this.islandSizeNS.Value, 0, this.islandSizes.Length - 1)]; } if (this.flatTerrainLevelSlider.IsSliding) { this.worldSettings.TerrainLevel = (int)this.flatTerrainLevelSlider.Value; } if (this.flatTerrainBlockButton.IsClicked) { int[] items = new int[] { 8, 2, 7, 3, 67, 66, 4, 5, 26, 73, 21, 46, 47, 15, 62, 68, 126, 71, 1 }; DialogsManager.ShowDialog(null, new ListSelectionDialog("Select Block", items, 72f, delegate(object index) { XElement node = ContentManager.Get <XElement>("Widgets/SelectBlockItem"); ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(null, node, null); containerWidget.Children.Find <BlockIconWidget>("SelectBlockItem.Block", true).Contents = (int)index; containerWidget.Children.Find <LabelWidget>("SelectBlockItem.Text", true).Text = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index)); return(containerWidget); }, delegate(object index) { this.worldSettings.TerrainBlockIndex = (int)index; })); } if (this.flatTerrainMagmaOceanCheckbox.IsClicked) { this.worldSettings.TerrainOceanBlockIndex = ((this.worldSettings.TerrainOceanBlockIndex == 18) ? 92 : 18); } this.islandTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Island); this.flatTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Flat); this.continentTerrainPanel.IsVisible = (this.worldSettings.TerrainGenerationMode == TerrainGenerationMode.Continent); this.flatTerrainLevelSlider.Value = (float)this.worldSettings.TerrainLevel; this.flatTerrainLevelSlider.Text = this.worldSettings.TerrainLevel.ToString(); this.flatTerrainBlock.Contents = this.worldSettings.TerrainBlockIndex; this.flatTerrainMagmaOceanCheckbox.IsChecked = (this.worldSettings.TerrainOceanBlockIndex == 92); this.seaLevelOffsetSlider.Value = (float)this.worldSettings.SeaLevelOffset; this.seaLevelOffsetSlider.Text = WorldOptionsScreen.FormatOffset((float)this.worldSettings.SeaLevelOffset); this.temperatureOffsetSlider.Value = this.worldSettings.TemperatureOffset; this.temperatureOffsetSlider.Text = WorldOptionsScreen.FormatOffset(this.worldSettings.TemperatureOffset); this.humidityOffsetSlider.Value = this.worldSettings.HumidityOffset; this.humidityOffsetSlider.Text = WorldOptionsScreen.FormatOffset(this.worldSettings.HumidityOffset); this.biomeSizeSlider.Value = (float)FindNearestIndex(this.biomeSizes, this.worldSettings.BiomeSize); this.biomeSizeSlider.Text = this.worldSettings.BiomeSize.ToString() + "x"; this.islandSizeEW.Value = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.X); this.islandSizeEW.Text = this.worldSettings.IslandSize.X.ToString(); this.islandSizeNS.Value = (float)FindNearestIndex(this.islandSizes, this.worldSettings.IslandSize.Y); this.islandSizeNS.Text = this.worldSettings.IslandSize.Y.ToString(); this.supernaturalCreaturesButton.Text = (this.worldSettings.AreSupernaturalCreaturesEnabled ? "Enabled" : "Disabled"); this.environmentBehaviorButton.Text = this.worldSettings.EnvironmentBehaviorMode.ToString(); this.timeOfDayButton.Text = this.worldSettings.TimeOfDayMode.ToString(); this.weatherEffectsButton.Text = (this.worldSettings.AreWeatherEffectsEnabled ? "Enabled" : "Disabled"); this.adventureRespawnButton.Text = (this.worldSettings.IsAdventureRespawnAllowed ? "Allowed" : "Not Allowed"); this.adventureSurvivalMechanicsButton.Text = (this.worldSettings.AreAdventureSurvivalMechanicsEnabled ? "Enabled" : "Disabled"); this.terrainGenerationLabel.Text = this.worldSettings.TerrainGenerationMode.ToString(); }