private void PopulateMutuallyConnectedCubeGrids(HashSet <MyAntennaSystem.BroadcasterInfo> playerMutualConnection) { m_shipsInRange.ClearItems(); bool isCubeGrid = m_openInventoryInteractedEntityRepresentative is MyCubeGrid; //You should always be selectable m_shipsInRange.AddItem(m_openInventoryInteractedEntityRepresentative.EntityId, new StringBuilder(m_openInventoryInteractedEntityRepresentative.DisplayName)); foreach (var connection in playerMutualConnection) { if (m_shipsInRange.TryGetItemByKey(connection.EntityId) == null) { m_shipsInRange.AddItem(connection.EntityId, new StringBuilder(connection.Name)); } } m_shipsInRange.Visible = true; m_button.Visible = true; m_shipsInRange.SortItemsByValueText(); //if the interacted entity is not in the combobox, it means we're watching a disconnected ship so it should be red (somehow) if (m_shipsInRange.TryGetItemByKey(m_interactedEntityRepresentative.EntityId) == null) { if (m_interactedEntityRepresentative is MyCubeGrid) { m_shipsInRange.AddItem(m_interactedEntityRepresentative.EntityId, new StringBuilder((m_interactedEntityRepresentative as MyCubeGrid).DisplayName)); } } m_shipsInRange.SelectItemByKey(m_interactedEntityRepresentative.EntityId); }
public void InitControls() { AddActivatedCheckbox(new Vector2(-0.07f, -0.1f), CargoBox.Activated); AddIdTextBox(new Vector2(-0.16f, -0.15f), CargoBox.EntityId.Value.NumericValue); m_cargoBoxTypeCombobox = new MyGuiControlCombobox( this, new Vector2(0, -0.2f), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 6, false, false, false); foreach (MyMwcObjectBuilder_CargoBox_TypesEnum cargoBoxType in Enum.GetValues(typeof(MyMwcObjectBuilder_CargoBox_TypesEnum))) { var cargoBoxHelper = MyGuiObjectBuilderHelpers.GetGuiHelper( MyMwcObjectBuilderTypeEnum.CargoBox, (int)cargoBoxType); m_cargoBoxTypeCombobox.AddItem((int)cargoBoxType, MyGuiManager.GetBlankTexture(), cargoBoxHelper.Description); } m_cargoBoxTypeCombobox.SortItemsByValueText(); m_cargoBoxTypeCombobox.SelectItemByKey((int)CargoBox.CargoBoxType); Controls.Add(m_cargoBoxTypeCombobox); }
private void CreatePlanetsSpawnMenu(float separatorSize, float usableWidth) { float min = MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? 100 : 19000; float max = /*MyFakes.ENABLE_EXTENDED_PLANET_OPTIONS ? (6378.1f * 1000 * 2) :*/ 120000f; MyGuiControlSlider slider = null; slider = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: min, maxValue: max, labelText: String.Empty, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug, intValue: true); slider.DebugScale = m_sliderDebugScale; slider.ColorMask = Color.White.ToVector4(); Controls.Add(slider); var label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(slider.Size.X + 0.005f, slider.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_currentPosition.Y += slider.Size.Y; m_currentPosition.Y += separatorSize; slider.ValueChanged += (MyGuiControlSlider s) => { StringBuilder sb = new StringBuilder(); MyValueFormatter.AppendDistanceInBestUnit(s.Value, sb); label.Text = sb.ToString(); m_procAsteroidSizeValue = s.Value; }; slider.Value = 8000; m_procAsteroidSeed = CreateSeedButton(m_procAsteroidSeedValue, usableWidth); m_planetCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetPlanetsGeneratorsDefinitions()) { m_planetCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_planetCombobox.ItemSelected += OnPlanetCombobox_ItemSelected; m_planetCombobox.SortItemsByValueText(); m_planetCombobox.SelectItemByIndex(0); } CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, x => { int seed = GetProceduralAsteroidSeed(m_procAsteroidSeed); CreatePlanet(seed, slider.Value); CloseScreenNow(); }); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_scale = 0.7f; AddCaption("Cutscenes", Color.Yellow.ToVector4()); AddShareFocusHint(); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_comboCutscenes = AddCombo(); m_playButton = AddButton(new StringBuilder("Play"), onClick_PlayButton); m_addCutsceneButton = AddButton(new StringBuilder("Add cutscene"), onClick_AddCutsceneButton); m_deleteCutsceneButton = AddButton(new StringBuilder("Delete cutscene"), onClick_DeleteCutsceneButton); m_currentPosition.Y += 0.01f; AddLabel("Nodes", Color.Yellow.ToVector4(), 1); m_comboNodes = AddCombo(); m_comboNodes.ItemSelected += m_comboNodes_ItemSelected; m_addNodeButton = AddButton(new StringBuilder("Add node"), onClick_AddNodeButton); m_deleteNodeButton = AddButton(new StringBuilder("Delete node"), onClick_DeleteNodeButton); m_nodeTimeSlider = AddSlider("Node time", 0, 0, 100, OnNodeTimeChanged); var cutscenes = MySession.Static.GetComponent <MySessionComponentCutscenes>(); m_comboCutscenes.ClearItems(); foreach (var key in cutscenes.GetCutscenes().Keys) { m_comboCutscenes.AddItem(key.GetHashCode(), key); } m_comboCutscenes.SortItemsByValueText(); m_comboCutscenes.ItemSelected += m_comboCutscenes_ItemSelected; AddLabel("Waypoints", Color.Yellow.ToVector4(), 1); m_comboWaypoints = AddCombo(); m_comboWaypoints.ItemSelected += m_comboWaypoints_ItemSelected; m_currentPosition.Y += 0.01f; m_spawnButton = AddButton(new StringBuilder("Spawn entity"), onSpawnButton); m_removeAllButton = AddButton(new StringBuilder("Remove all"), onRemoveAllButton); if (m_comboCutscenes.GetItemsCount() > 0) { m_comboCutscenes.SelectItemByIndex(0); } }
protected void RecreateHandItemsCombo() { m_handItemsCombo = AddCombo(); m_handItemDefinitions.Clear(); foreach (var handItemDef in MyDefinitionManager.Static.GetHandItemDefinitions()) { var def = MyDefinitionManager.Static.GetDefinition(handItemDef.PhysicalItemId); int handItemKey = m_handItemDefinitions.Count; m_handItemDefinitions.Add(handItemDef); m_handItemsCombo.AddItem(handItemKey, def.DisplayNameText); } m_handItemsCombo.SortItemsByValueText(); m_handItemsCombo.ItemSelected += handItemsCombo_ItemSelected; }
private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale); m_physicalObjectCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { if (!definition.Public) { continue; } var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) { continue; } int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText); } m_physicalObjectCombobox.SortItemsByValueText(); m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex); m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected; } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale); m_amountTextbox = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly); m_amountTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_amountTextbox.TextChanged += OnAmountTextChanged; Controls.Add(m_amountTextbox); m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y; m_errorLabel = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale); m_errorLabel.Visible = false; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject); m_currentPosition.Y += separatorSize; }
void UdpateCuesCombo(MyGuiControlCombobox box) { box.ClearItems(); long key = 0; foreach (var cue in MyAudio.Static.CueDefinitions) { if ((m_currentCategorySelectedItem == ALL_CATEGORIES) || (m_currentCategorySelectedItem == cue.Category.ToString())) { box.AddItem(key, new StringBuilder(cue.SubtypeId.ToString())); key++; } } box.SortItemsByValueText(); if (box.GetItemsCount() > 0) { box.SelectItemByIndex(0); } }
private void CreateAsteroidsSpawnMenu(float separatorSize, float usableWidth) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; }
public void ReloadControls() { Vector2 originDelta = new Vector2(0.02f, 0); Vector2 controlsOriginLeft = GetControlsOriginLeftFromScreenSize() + originDelta; if (GetAsteroidType() == MyGuiAsteroidTypesEnum.VOXEL) { #region Voxel File //choose asteroid label m_selectAsteroidLabel = new MyGuiControlLabel(this, controlsOriginLeft + 2.5f * CONTROLS_DELTA + new Vector2(0.02f, -0.02f), null, MyTextsWrapperEnum.AsteroidName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_selectAsteroidLabel); //COMBOBOX - voxel files m_selectVoxelMapCombobox = new MyGuiControlCombobox(this, controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f + 0.02f, -0.065f), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 11, true, false, true); foreach (MyMwcVoxelFilesEnum enumValue in MyGuiAsteroidHelpers.MyMwcVoxelFilesEnumValues) { MyGuiAsteroidHelper voxelFileHelper = MyGuiAsteroidHelpers.GetMyGuiVoxelFileHelper(enumValue); Debug.Assert(voxelFileHelper.Description != null); m_selectVoxelMapCombobox.AddItem((int)enumValue, voxelFileHelper.Icon, voxelFileHelper.Description); } m_selectVoxelMapCombobox.SortItemsByValueText(); m_selectVoxelMapCombobox.SelectItemByKey(1); m_selectVoxelMapCombobox.OnSelectItemDoubleClick += OnDoubleClick; Controls.Add(m_selectVoxelMapCombobox); #endregion #region Voxel Material Vector2 delta = new Vector2(m_selectVoxelMapCombobox.GetSize().Value.X + 0.02f, 0); AddVoxelMaterialCombobox( controlsOriginLeft + 2.5f * CONTROLS_DELTA + delta + new Vector2(0.14f, -0.02f), controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0) + delta + new Vector2(0.14f, -0.065f), null); #endregion } else if (GetAsteroidType() == MyGuiAsteroidTypesEnum.STATIC) { #region Static Asteroid m_selectAsteroidLabel = new MyGuiControlLabel(this, controlsOriginLeft + 2.5f * CONTROLS_DELTA + new Vector2(0.02f, -0.02f), null, MyTextsWrapperEnum.AsteroidName, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_selectAsteroidLabel); //COMBOBOX - static asteroids m_selectVoxelMapCombobox = new MyGuiControlCombobox(this, controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f + 0.02f, -0.065f), MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 11, true, false, true); m_selectVoxelMapCombobox.OnSelectItemDoubleClick += OnDoubleClick; foreach (MyMwcObjectBuilder_StaticAsteroid_TypesEnum enumValue in MyGuiAsteroidHelpers.MyMwcStaticAsteroidTypesEnumValues) { MyGuiAsteroidHelper staticAsteroidHelper = MyGuiAsteroidHelpers.GetStaticAsteroidTypeHelper(enumValue); if (staticAsteroidHelper != null) { m_selectVoxelMapCombobox.AddItem((int)enumValue, staticAsteroidHelper.Icon, staticAsteroidHelper.Description); } } m_selectVoxelMapCombobox.SelectItemByIndex(0); Controls.Add(m_selectVoxelMapCombobox); Vector2 delta = new Vector2(m_selectVoxelMapCombobox.GetSize().Value.X + 0.02f, 0); AddVoxelMaterialCombobox( controlsOriginLeft + 2.5f * CONTROLS_DELTA + delta + new Vector2(0.14f, -0.02f), controlsOriginLeft + 4.5f * CONTROLS_DELTA + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0) + delta + new Vector2(0.14f, -0.065f), null); m_selectVoxelMapMaterialCombobox.SelectItemByKey(0); // Select default material #endregion } }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_scale = 0.7f; AddCaption("Render Character", Color.Yellow.ToVector4()); AddShareFocusHint(); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; if (MySession.ControlledEntity == null || !(MySession.ControlledEntity is MyCharacter)) { AddLabel("None active character", Color.Yellow.ToVector4(), 1.2f); return; } MyCharacter playerCharacter = MySession.LocalCharacter; if (!constructor) { playerCharacter.DebugMode = true; } AddSlider("Max slope", playerCharacter.Definition.MaxSlope, 0f, 89f, (slider) => { playerCharacter.Definition.MaxSlope = slider.Value; }); AddLabel(playerCharacter.Model.AssetName, Color.Yellow.ToVector4(), 1.2f); AddLabel("Animation A:", Color.Yellow.ToVector4(), 1.2f); m_animationComboA = AddCombo(); int i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationComboA.AddItem(i++, new StringBuilder(animation.Key)); } m_animationComboA.SelectItemByIndex(0); AddLabel("Animation B:", Color.Yellow.ToVector4(), 1.2f); m_animationComboB = AddCombo(); i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationComboB.AddItem(i++, new StringBuilder(animation.Key)); } m_animationComboB.SelectItemByIndex(0); m_blendSlider = AddSlider("Blend time", 0.5f, 0, 3, null); AddButton(new StringBuilder("Play A->B"), OnPlayBlendButtonClick); m_currentPosition.Y += 0.01f; m_animationCombo = AddCombo(); i = 0; foreach (var animation in playerCharacter.Definition.AnimationNameToSubtypeName) { m_animationCombo.AddItem(i++, new StringBuilder(animation.Key)); } m_animationCombo.SortItemsByValueText(); m_animationCombo.SelectItemByIndex(0); m_loopCheckbox = AddCheckBox("Loop", false, null); m_currentPosition.Y += 0.02f; foreach (var name in playerCharacter.Definition.BoneSets.Keys) { var checkBox = AddCheckBox(name, false, null); checkBox.UserData = name; if (name == "Body") { checkBox.IsChecked = true; } } AddButton(new StringBuilder("Play animation"), OnPlayButtonClick); AddCheckBox("Draw damage and hit hapsules", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_SHOW_DAMAGE)); m_currentPosition.Y += 0.01f; }
void CreateControls(Vector2 controlsOrigin, Vector2 sliderOffset) { m_nameLabel = new MyGuiControlLabel(this, controlsOrigin - new Vector2(0, 2 * CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Name, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_nameTextBox = new MyGuiControlTextbox(this, controlsOrigin - new Vector2(-0.2f, 2 * CONTROLS_DELTA.Y), MyGuiControlPreDefinedSize.MEDIUM, DummyPoint.Name ?? String.Empty, 512, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); m_nameTextBox.TextChanged = OnTextChange; Controls.Add(m_nameLabel); Controls.Add(m_nameTextBox); m_typeComboBox = new MyGuiControlCombobox(this, controlsOrigin - new Vector2(-0.25f, CONTROLS_DELTA.Y), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE); m_typeComboBox.AddItem(0, new StringBuilder("Box")); m_typeComboBox.AddItem(1, new StringBuilder("Sphere")); m_typeComboBox.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_typeComboBox_OnSelect); Controls.Add(m_typeComboBox); MyGuiControlLabel typeLabel = new MyGuiControlLabel(this, controlsOrigin - new Vector2(-0.0f, CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Width, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); typeLabel.UpdateText("Type"); Controls.Add(typeLabel); float checkBoxOffset = 0.507f; //Enabled Controls.Add(new MyGuiControlLabel(this, controlsOrigin - new Vector2(-checkBoxOffset, 2 * CONTROLS_DELTA.Y), null, MyTextsWrapperEnum.Enabled, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_enabled = new MyGuiControlCheckbox(this, controlsOrigin - new Vector2(-checkBoxOffset, 2 * CONTROLS_DELTA.Y) + new Vector2(0.1f, 0f), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); m_enabled.OnCheck += OnEnabledChange; Controls.Add(m_enabled); // Active AddActivatedCheckbox(controlsOrigin - new Vector2(-checkBoxOffset, CONTROLS_DELTA.Y), DummyPoint.Activated); float sliderMax = 50000; //Width slider m_widthSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f), new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Width), MyGuiSizeEnumFlags.All, sliderOffset.X); m_widthSize.OnValueChange += OnWidthChange; Controls.Add(m_widthSize); //Height slider m_heightSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f) + 1 * CONTROLS_DELTA, new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Height), MyGuiSizeEnumFlags.All, sliderOffset.X); m_heightSize.OnValueChange += OnHeightChange; Controls.Add(m_heightSize); //Depth slider m_depthSize = new MyGuiControlSize(this, controlsOrigin + new Vector2(0.35f, 0f) + 2 * CONTROLS_DELTA, new Vector2(0.7f, MyGuiConstants.SLIDER_HEIGHT), Vector4.Zero, null, 0f, 0.1f, sliderMax, MyTextsWrapper.Get(MyTextsWrapperEnum.Depth), MyGuiSizeEnumFlags.All, sliderOffset.X); m_depthSize.OnValueChange += OnDepthChange; Controls.Add(m_depthSize); MyGuiControlLabel idLabel = new MyGuiControlLabel(this, controlsOrigin + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Depth, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(idLabel); idLabel.UpdateText("ID: " + m_entity.EntityId.ToString()); int controlsDelta = 4; // Flags m_colorArea = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta++ *CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_colorArea.OnCheck += OnFlagChange; m_colorAreaLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ColorArea, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_colorArea); Controls.Add(m_colorAreaLabel); m_playerStart = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_playerStart.OnCheck += OnPlayerStartFlagChange; m_playerStartLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.PlayerStart, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_playerStart); Controls.Add(m_playerStartLabel); m_mothershipStart = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_mothershipStart.OnCheck += OnMothershipStartFlagChange; m_mothershipStartLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.MothershipStart, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_mothershipStart); Controls.Add(m_mothershipStartLabel); m_detector = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_detector.OnCheck += OnFlagChange; m_detectorLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.Detector, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_detector); Controls.Add(m_detectorLabel); m_sideMission = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_sideMission.OnCheck += OnFlagChange; m_sideMissionLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SideMission, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_sideMission); Controls.Add(m_sideMissionLabel); m_particleEffect = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_particleEffect.OnCheck += OnFlagChange; m_particleEffectLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.ParticleEffect, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_particleEffectLabel); Controls.Add(m_particleEffect); m_respawnPoint = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_respawnPoint.OnCheck += OnFlagChange; m_respawnPointLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.RespawnPoint, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_respawnPointLabel); Controls.Add(m_respawnPoint); m_safeArea = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_safeArea.OnCheck += OnFlagChange; m_safeAreaLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SafeArea, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_safeArea); Controls.Add(m_safeAreaLabel); m_survivePrefabDestruction = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_survivePrefabDestruction.OnCheck += OnFlagChange; m_survivePrefabDestructionLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.SurvivePrefabDestruction, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_survivePrefabDestructionLabel); Controls.Add(m_survivePrefabDestruction); m_textureQuad = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_textureQuad.OnCheck += OnFlagChange; m_textureQuadLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.TextureQuad, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_textureQuad); Controls.Add(m_textureQuadLabel); m_note = new MyGuiControlCheckbox(this, controlsOrigin + controlsDelta * CONTROLS_DELTA, false, MyGuiConstants.RADIOBUTTON_BACKGROUND_COLOR); m_note.OnCheck += OnFlagChange; m_noteLabel = new MyGuiControlLabel(this, controlsOrigin + new Vector2(MyGuiConstants.RADIOBUTTON_SIZE.X, 0.0f) + controlsDelta++ *CONTROLS_DELTA, null, MyTextsWrapperEnum.Note, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_note); Controls.Add(m_noteLabel); Vector2 columnOffset = new Vector2(0.15f, 0); Vector2 labelColumnOffset = new Vector2(0.18f, 0); // Red slider m_redSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Red, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_redSlider = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 4 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_redSlider.OnChange = OnComponentChange; Controls.Add(m_redSliderLabel); Controls.Add(m_redSlider); // Green slider m_greenSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Green, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_greenSlider = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 5 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_greenSlider.OnChange = OnComponentChange; Controls.Add(m_greenSliderLabel); Controls.Add(m_greenSlider); // Blue slider m_blueSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Blue, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_blueSlider = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 6 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_blueSlider.OnChange = OnComponentChange; Controls.Add(m_blueSliderLabel); Controls.Add(m_blueSlider); // Alpha slider m_alphaSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 7 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Alpha, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_alphaSlider = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 7 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, MyEditorConstants.COLOR_COMPONENT_MIN_VALUE, MyEditorConstants.COLOR_COMPONENT_MAX_VALUE, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_alphaSlider.OnChange = OnComponentChange; m_alphaSliderValueLabel = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 7 * CONTROLS_DELTA + new Vector2(0.4f, 0), null, new StringBuilder("0"), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); // scale slider m_userScaleSliderLabel = new MyGuiControlLabel(this, labelColumnOffset + controlsOrigin + 8 * CONTROLS_DELTA, null, MyTextsWrapperEnum.UserScale, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_userScaleSlider = new MyGuiControlSlider(this, columnOffset + controlsOrigin + sliderOffset + 8 * CONTROLS_DELTA, MyGuiConstants.SLIDER_WIDTH, 0.01f, 3.9f, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder(), MyGuiConstants.SLIDER_WIDTH_LABEL, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f); m_userScaleSlider.OnChange = OnComponentChange; m_userScaleLabel = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 8 * CONTROLS_DELTA + new Vector2(0.4f, 0), null, new StringBuilder("0"), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_alphaSliderLabel); Controls.Add(m_alphaSliderValueLabel); Controls.Add(m_alphaSlider); Controls.Add(m_userScaleSliderLabel); Controls.Add(m_userScaleSlider); Controls.Add(m_userScaleLabel); // Particle effect //m_particleNameLabel = new MyGuiControlLabel(this, columnOffset + controlsOrigin + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ParticleEffect, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_particleCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 9 * CONTROLS_DELTA + sliderOffset, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 5, false, false, false); foreach (var p in MyParticlesLibrary.GetParticleEffects()) { m_particleCombo.AddItem(p.GetID(), new StringBuilder(p.Name)); m_particleCombo.SortItemsByValueText(); } m_particleCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_particleCombo_OnSelect); //Controls.Add(m_particleNameLabel); Controls.Add(m_particleCombo); m_respawnPointCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 10 * CONTROLS_DELTA + sliderOffset, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 4); foreach (MyMwcObjectBuilder_FactionEnum enumValue in MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_ShipFactionNationalityEnumValues) { MyGuiHelperBase factionNationalityHelper = MyGuiSmallShipHelpers.GetMyGuiSmallShipFactionNationality(enumValue); m_respawnPointCombo.AddItem((int)enumValue, null, factionNationalityHelper.Description); } m_respawnPointCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_repawnPointCombo_OnSelect); Controls.Add(m_respawnPointCombo); m_secretCombo = new MyGuiControlCombobox(this, columnOffset + controlsOrigin + 7 * CONTROLS_DELTA + sliderOffset, MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 4); m_secretCombo.AddItem(0, null, new StringBuilder("No secret")); foreach (var room in MySecretRooms.SecretRooms) { m_secretCombo.AddItem(room.Key, null, new StringBuilder(room.Value)); } m_secretCombo.OnSelect += new MyGuiControlCombobox.OnComboBoxSelectCallback(m_secretCombo_OnSelect); Controls.Add(m_secretCombo); UpdateValues(); }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); AddCaption("Cube blocks", Color.Yellow.ToVector4()); m_combo = AddCombo(); m_combo.Position = new Vector2(-0.15f, -0.35f); Dictionary <long, int> dict = new Dictionary <long, int>(); Dictionary <long, StringBuilder> names = new Dictionary <long, StringBuilder>(); foreach (var entity in MyEntities.GetEntities()) { if (entity is MyCubeGrid) { var grid = entity as MyCubeGrid; foreach (var block in grid.GetBlocks()) { long defId = block.BlockDefinition.Id.GetHashCode(); if (!dict.ContainsKey(defId)) { dict.Add(defId, 0); } dict[defId]++; string cubesize = ""; switch (block.BlockDefinition.CubeSize) { case MyCubeSize.Large: cubesize = "Large"; break; case MyCubeSize.Small: cubesize = "Small"; break; } StringBuilder blockName = new StringBuilder().Append("[").Append(cubesize).Append("] ").Append(block.BlockDefinition.DisplayNameText); if (!names.ContainsKey(defId)) { names.Add(defId, blockName); } } } } int qt; StringBuilder name; foreach (var key in names.Keys) //could be dict.Keys too { if (names.TryGetValue(key, out name) && dict.TryGetValue(key, out qt)) { m_combo.AddItem(key, name.Append(": ").Append(qt)); } } m_combo.SortItemsByValueText(); if (m_combo.GetItemsCount() > 0) { m_combo.SelectItemByIndex(0); } m_button = AddButton(new StringBuilder("Remove All"), onClick_RemoveAllBlocks); m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default; m_button.Position = new Vector2(0.0f, -0.25f); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.35f); AddCheckBox("Enable use object highlight", null, MemberHelper.GetMember(() => MyFakes.ENABLE_USE_OBJECT_HIGHLIGHT)); AddCheckBox("Show grids decay", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_GRIDS_DECAY)); m_dummyDrawDistanceSlider = AddSlider("Dummies draw distance", MyDebugDrawSettings.DEBUG_DRAW_MODEL_DUMMIES_DISTANCE, 0, 100, null); m_dummyDrawDistanceSlider.ValueChanged = DummyDrawDistanceSliderChanged; m_currentPosition += new Vector2(0.00f, 0.21f); AddCheckBox("Debug draw all mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_ALL, onClick_DebugDrawMountPointsAll); AddCheckBox("Debug draw mount points", MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS, onClick_DebugDrawMountPoints); AddCheckBox("Forward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS0)); AddCheckBox("Backward", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS1)); AddCheckBox("Left", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS2)); AddCheckBox("Right", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS3)); AddCheckBox("Up", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS4)); AddCheckBox("Down", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AXIS5)); AddCheckBox("Draw autogenerated", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_MOUNT_POINTS_AUTOGENERATE)); AddCheckBox("CubeBlock Integrity", null, MemberHelper.GetMember(() => MyDebugDrawSettings.DEBUG_DRAW_BLOCK_INTEGRITY)); m_button = AddButton(new StringBuilder("Resave mountpoints"), onClick_Save); m_button.VisualStyle = MyGuiControlButtonStyleEnum.Default; }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); m_currentPosition = -m_size.Value / 2.0f + new Vector2(0.02f, 0.10f); m_currentPosition.Y += 0.01f; m_scale = 0.7f; AddCaption("Audio FX", Color.Yellow.ToVector4()); AddShareFocusHint(); if (MyAudio.Static is MyNullAudio) { return; } m_categoriesCombo = AddCombo(); List <MyStringId> categories = MyAudio.Static.GetCategories(); m_categoriesCombo.AddItem(0, new StringBuilder(ALL_CATEGORIES)); int catCount = 1; foreach (var category in categories) { m_categoriesCombo.AddItem(catCount++, new StringBuilder(category.ToString()));//jn:TODO get rid of ToString } m_categoriesCombo.SortItemsByValueText(); m_categoriesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(categoriesCombo_OnSelect); m_cuesCombo = AddCombo(); m_cuesCombo.ItemSelected += new MyGuiControlCombobox.ItemSelectedDelegate(cuesCombo_OnSelect); m_cueVolumeSlider = AddSlider("Volume", 1f, 0f, 1f, null); m_cueVolumeSlider.ValueChanged = CueVolumeChanged; m_applyVolumeToCategory = AddButton(new StringBuilder("Apply to category"), OnApplyVolumeToCategorySelected); m_applyVolumeToCategory.Enabled = false; m_cueVolumeCurveCombo = AddCombo(); foreach (var curveType in Enum.GetValues(typeof(MyCurveType))) { m_cueVolumeCurveCombo.AddItem((int)curveType, new StringBuilder(curveType.ToString())); } m_effects = AddCombo(); m_effects.AddItem(0, new StringBuilder("")); catCount = 1; foreach (var effect in MyDefinitionManager.Static.GetAudioEffectDefinitions()) { m_effects.AddItem(catCount++, new StringBuilder(effect.Id.SubtypeName)); } m_effects.SelectItemByIndex(0); m_effects.ItemSelected += effects_ItemSelected; m_cueMaxDistanceSlider = AddSlider("Max distance", 0, 0, 2000, null); m_cueMaxDistanceSlider.ValueChanged = MaxDistanceChanged; m_applyMaxDistanceToCategory = AddButton(new StringBuilder("Apply to category"), OnApplyMaxDistanceToCategorySelected); m_applyMaxDistanceToCategory.Enabled = false; m_cueVolumeVariationSlider = AddSlider("Volume variation", 0, 0, 10, null); m_cueVolumeVariationSlider.ValueChanged = VolumeVariationChanged; m_cuePitchVariationSlider = AddSlider("Pitch variation", 0, 0, 500, null); m_cuePitchVariationSlider.ValueChanged = PitchVariationChanged; m_soloCheckbox = AddCheckBox("Solo", false, null); m_soloCheckbox.IsCheckedChanged = SoloChanged; MyGuiControlButton btn = AddButton(new StringBuilder("Play selected"), OnPlaySelected); btn.CueEnum = GuiSounds.None; AddButton(new StringBuilder("Stop selected"), OnStopSelected); AddButton(new StringBuilder("Save"), OnSave); AddButton(new StringBuilder("Reload"), OnReload); if (m_categoriesCombo.GetItemsCount() > 0) { m_categoriesCombo.SelectItemByIndex(0); } }
public override void RecreateControls(bool constructor) { base.RecreateControls(constructor); if (m_asteroid_showPlanet) { CreatePlanetMenu(); return; } Vector2 cbOffset = new Vector2(-0.05f, 0.0f); Vector2 controlPadding = new Vector2(0.02f, 0.02f); // X: Left & Right, Y: Bottom & Top float textScale = 0.8f; float separatorSize = 0.01f; float usableWidth = SCREEN_SIZE.X - HIDDEN_PART_RIGHT - controlPadding.X * 2; float hiddenPartTop = (SCREEN_SIZE.Y - 1.0f) / 2.0f; m_currentPosition = -m_size.Value / 2.0f; m_currentPosition += controlPadding; m_currentPosition.Y += hiddenPartTop; m_scale = textScale; var caption = AddCaption(MySpaceTexts.ScreenDebugSpawnMenu_Caption, Color.White.ToVector4(), controlPadding + new Vector2(-HIDDEN_PART_RIGHT, hiddenPartTop)); m_currentPosition.Y += MyGuiConstants.SCREEN_CAPTION_DELTA_Y + separatorSize; if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS || MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroids), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_SelectAsteroidType), Vector4.One, m_scale); var combo = AddCombo(); combo.AddItem(1, MySpaceTexts.ScreenDebugSpawnMenu_PredefinedAsteroids); combo.AddItem(2, MySpaceTexts.ScreenDebugSpawnMenu_ProceduralAsteroids); // DA: Remove from MySpaceTexts and just hardcode until release. Leave a todo so you don't forget about it before release of planets. combo.AddItem(3, MySpaceTexts.ScreenDebugSpawnMenu_Planets); combo.SelectItemByKey(m_asteroid_showPlanet ? 3 : m_asteroid_showPredefinedOrProcedural ? 1 : 2); combo.ItemSelected += () => { m_asteroid_showPredefinedOrProcedural = combo.GetSelectedKey() == 1; m_asteroid_showPlanet = combo.GetSelectedKey() == 3; RecreateControls(false); }; } if (MyFakes.ENABLE_SPAWN_MENU_ASTEROIDS && m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Asteroid), Vector4.One, m_scale); m_asteroidCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetVoxelMapStorageDefinitions()) { m_asteroidCombobox.AddItem((int)definition.Id.SubtypeId, definition.Id.SubtypeId.ToString()); } m_asteroidCombobox.ItemSelected += OnAsteroidCombobox_ItemSelected; m_asteroidCombobox.SortItemsByValueText(); m_asteroidCombobox.SelectItemByIndex(m_lastSelectedAsteroidIndex); } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnLoadAsteroid); m_currentPosition.Y += separatorSize; } if (MyFakes.ENABLE_SPAWN_MENU_PROCEDURAL_ASTEROIDS && !m_asteroid_showPredefinedOrProcedural) { AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSize), Vector4.One, m_scale); m_procAsteroidSize = new MyGuiControlSlider( position: m_currentPosition, width: 400f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, minValue: 5.0f, maxValue: 500f, labelText: String.Empty, labelDecimalPlaces: 2, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); m_procAsteroidSize.DebugScale = m_sliderDebugScale; m_procAsteroidSize.ColorMask = Color.White.ToVector4(); Controls.Add(m_procAsteroidSize); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(m_procAsteroidSize.Size.X + 0.005f, m_procAsteroidSize.Size.Y / 2), text: String.Empty, colorMask: Color.White.ToVector4(), textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER; Controls.Add(label); m_procAsteroidSize.ValueChanged += (MyGuiControlSlider s) => { label.Text = MyValueFormatter.GetFormatedFloat(s.Value, 2) + "m"; m_procAsteroidSizeValue = s.Value; }; m_procAsteroidSize.Value = m_procAsteroidSizeValue; m_currentPosition.Y += m_procAsteroidSize.Size.Y; m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ProceduralSeed), Color.White.ToVector4(), m_scale); m_procAsteroidSeed = new MyGuiControlTextbox(m_currentPosition, m_procAsteroidSeedValue, 20, Color.White.ToVector4(), m_scale, MyGuiControlTextboxType.Normal); m_procAsteroidSeed.TextChanged += (MyGuiControlTextbox t) => { m_procAsteroidSeedValue = t.Text; }; m_procAsteroidSeed.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; Controls.Add(m_procAsteroidSeed); m_currentPosition.Y += m_procAsteroidSize.Size.Y + separatorSize; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_GenerateSeed, generateSeedButton_OnButtonClick); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_AsteroidGenerationCanTakeLong), Color.Red.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnAsteroid, OnSpawnProceduralAsteroid); m_currentPosition.Y += separatorSize; } CreateObjectsSpawnMenu(separatorSize, usableWidth); }
private void CreateObjectsSpawnMenu(float separatorSize, float usableWidth) { AddSubcaption(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_Items), Color.White.ToVector4(), new Vector2(-HIDDEN_PART_RIGHT, 0.0f)); AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemType), Vector4.One, m_scale); m_physicalObjectCombobox = AddCombo(); { foreach (var definition in MyDefinitionManager.Static.GetAllDefinitions()) { if (!definition.Public) { continue; } var physicalItemDef = definition as MyPhysicalItemDefinition; if (physicalItemDef == null || physicalItemDef.CanSpawnFromScreen == false) { continue; } int key = m_physicalItemDefinitions.Count; m_physicalItemDefinitions.Add(physicalItemDef); m_physicalObjectCombobox.AddItem(key, definition.DisplayNameText); } m_physicalObjectCombobox.SortItemsByValueText(); m_physicalObjectCombobox.SelectItemByIndex(m_lastSelectedFloatingObjectIndex); m_physicalObjectCombobox.ItemSelected += OnPhysicalObjectCombobox_ItemSelected; } m_currentPosition.Y += separatorSize; AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_ItemAmount), Vector4.One, m_scale); m_amountTextbox = new MyGuiControlTextbox(m_currentPosition, m_amount.ToString(), 6, null, m_scale, MyGuiControlTextboxType.DigitsOnly); m_amountTextbox.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; m_amountTextbox.TextChanged += OnAmountTextChanged; Controls.Add(m_amountTextbox); m_currentPosition.Y += separatorSize + m_amountTextbox.Size.Y; m_errorLabel = AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_InvalidAmount), Color.Red.ToVector4(), m_scale); m_errorLabel.Visible = false; CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnObject, OnSpawnPhysicalObject); MyCharacterDetectorComponent comp; MyTerminalBlock detected = null; bool enableButton = false; if (MySession.Static.LocalCharacter != null && MySession.Static.LocalCharacter.Components.TryGet(out comp) && comp.UseObject != null) { detected = comp.DetectedEntity as MyTerminalBlock; } string name = "-"; if (detected != null && detected.HasInventory && detected.HasLocalPlayerAccess()) { name = detected.CustomName.ToString(); enableButton = true; } AddLabel(MyTexts.GetString(MySpaceTexts.ScreenDebugSpawnMenu_CurrentTarget) + name, Color.White.ToVector4(), m_scale); CreateDebugButton(usableWidth, MySpaceTexts.ScreenDebugSpawnMenu_SpawnTargeted, OnSpawnIntoContainer, enableButton); m_currentPosition.Y += separatorSize; }