void AddVoxelMaterialCombobox(Vector2 labelPosition, Vector2 comboboxPosition, MyMwcVoxelMaterialsEnum?selectedMaterial) { //choose material label m_selectMaterialLabel = new MyGuiControlLabel(this, labelPosition, null, MyTextsWrapperEnum.AsteroidMaterial, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(m_selectMaterialLabel); //COMBOBOX - voxel materials enum m_selectVoxelMapMaterialCombobox = new MyGuiControlCombobox(this, comboboxPosition, MyGuiControlPreDefinedSize.LONGMEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 11, true, false, true); foreach (MyMwcVoxelMaterialsEnum enumValue in MyGuiAsteroidHelpers.MyMwcVoxelMaterialsEnumValues) { MyGuiVoxelMaterialHelper voxelMaterialHelper = MyGuiAsteroidHelpers.GetMyGuiVoxelMaterialHelper(enumValue); if (voxelMaterialHelper != null) { m_selectVoxelMapMaterialCombobox.AddItem((int)enumValue, voxelMaterialHelper.Icon, voxelMaterialHelper.Description); } } int selectedIndex; if (selectedMaterial == null) { selectedIndex = 0; } else { selectedIndex = (int)selectedMaterial.Value; } m_selectVoxelMapMaterialCombobox.SelectItemByKey(selectedIndex); m_selectVoxelMapMaterialCombobox.OnSelectItemDoubleClick += OnDoubleClick; Controls.Add(m_selectVoxelMapMaterialCombobox); }
void GenerateAsteroidMaterialPreviews(int sizeInPixels, DirectoryInfo directoryInfo) { var directoryGuiHelpers = Directory.CreateDirectory(Path.Combine(directoryInfo.FullName, "GuiHelpers")); int index = 1; foreach (MyMwcVoxelMaterialsEnum enumValue in MyGuiAsteroidHelpers.MyMwcVoxelMaterialsEnumValues) { Debug.WriteLine(string.Format("Exporting voxel Material Preview {0}/{1} ..", index++, MyGuiAsteroidHelpers.MyMwcVoxelMaterialsEnumValues.Count)); var result = RenderAsteroidMaterialPreview(enumValue, sizeInPixels, sizeInPixels, 1); var materialHelper = MyGuiAsteroidHelpers.GetMyGuiVoxelMaterialHelper(enumValue); string fileName = Path.Combine(directoryGuiHelpers.FullName, string.Format("{0}.dds", Path.GetFileName(materialHelper.Icon.Name))); if (File.Exists(fileName)) { File.Delete(fileName); } //TODO //MyDDSFile.DDSToFile(fileName, true, result, false); } }
void Init() { m_enableBackgroundFade = true; m_size = new Vector2(0.92f, 0.95f); // Add screen title AddCaption(); Vector2 originDelta = new Vector2(0.02f, 0); Vector2 controlsOriginLeft = GetControlsOriginLeftFromScreenSize() + originDelta; Vector2 controlsOriginRight = GetControlsOriginRightFromScreenSize() + originDelta; // Decide if screen is for editing existing phys object or adding new if (HasEntity()) { //controlsOriginLeft.X += 0.5f * MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X; controlsOriginLeft.Y += 0.075f; //AddEditPositionControls(); AddVoxelMaterialCombobox( controlsOriginLeft + new Vector2(0.1f, -0.02f), controlsOriginLeft + new Vector2(MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2.0f, 0) + 2 * CONTROLS_DELTA + new Vector2(0.1f, -0.065f), m_entity.VoxelMaterial); if (this.m_entity is MyVoxelMap) { Vector2 buttonDelta = new Vector2(-0.15f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f - 0.085f); Controls.Add(new MyGuiControlButton(this, new Vector2(buttonDelta.X, buttonDelta.Y), new Vector2(0.25f, 0.0475f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.RemoveVoxels, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnClearClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); buttonDelta.X = -buttonDelta.X; Controls.Add(new MyGuiControlButton(this, new Vector2(buttonDelta.X, buttonDelta.Y), new Vector2(0.25f, 0.0475f), MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.RemoveAllVoxelHands, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnClearVoxelHands, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); } Vector2 controlsColumn2OriginLabel = new Vector2(controlsOriginLeft.X + MyGuiConstants.COMBOBOX_LONGMEDIUM_SIZE.X / 2 + MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X + 0.03f, -m_size.Value.Y / 2.0f + 0.04f); Vector2 controlsColumn2Origin = new Vector2(controlsColumn2OriginLabel.X + 0.02f, -m_size.Value.Y / 2.0f + 0.04f); m_positionX = new MyGuiControlTextbox(this, controlsColumn2Origin + 3 * CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, "", 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); m_positionY = new MyGuiControlTextbox(this, controlsColumn2Origin + 4 * CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, "", 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); m_positionZ = new MyGuiControlTextbox(this, controlsColumn2Origin + 5 * CONTROLS_DELTA + new Vector2(MyGuiConstants.TEXTBOX_MEDIUM_SIZE.X / 2.0f, 0), MyGuiControlPreDefinedSize.MEDIUM, "", 20, MyGuiConstants.TEXTBOX_BACKGROUND_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiControlTextboxType.NORMAL); Controls.Add(new MyGuiControlLabel(this, controlsColumn2OriginLabel + 3 * CONTROLS_DELTA, null, MyTextsWrapperEnum.X, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(new MyGuiControlLabel(this, controlsColumn2OriginLabel + 4 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Y, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(new MyGuiControlLabel(this, controlsColumn2OriginLabel + 5 * CONTROLS_DELTA, null, MyTextsWrapperEnum.Z, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_positionX); Controls.Add(m_positionY); Controls.Add(m_positionZ); m_positionX.Text = m_entity.WorldMatrix.Translation.X.ToString(); m_positionY.Text = m_entity.WorldMatrix.Translation.Y.ToString(); m_positionZ.Text = m_entity.WorldMatrix.Translation.Z.ToString(); m_changeMaterial = new MyGuiControlCheckbox(this, controlsColumn2OriginLabel + 6 * CONTROLS_DELTA + new Vector2(0.16f, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(new MyGuiControlLabel(this, controlsColumn2OriginLabel + 6 * CONTROLS_DELTA, null, MyTextsWrapperEnum.ChangeMaterial, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); Controls.Add(m_changeMaterial); AddOkAndCancelButtonControls(); } else { #region Asteroid Type //choose asteroid type label //Controls.Add(new MyGuiControlLabel(this, controlsOriginLeft + 1 * CONTROLS_DELTA + new Vector2(0, -0.0f), null, MyTextsWrapperEnum.AsteroidType, MyGuiConstants.LABEL_TEXT_COLOR, // MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); //COMBOBOX - asteroid type m_selectAsteroidTypeCombobox = new MyGuiControlCombobox(this, controlsOriginRight + 1 * CONTROLS_DELTA + new Vector2(-controlsOriginRight.X, -0.045f), MyGuiControlPreDefinedSize.MEDIUM, MyGuiConstants.COMBOBOX_BACKGROUND_COLOR, MyGuiConstants.COMBOBOX_TEXT_SCALE, 2); foreach (MyGuiAsteroidTypesEnum enumValue in MyGuiAsteroidHelpers.MyGuiAsteroidTypeEnumValues) { MyGuiAsteroidHelper asteroidTypeHelper = MyGuiAsteroidHelpers.GetMyGuiAsteroidTypeHelper(enumValue); m_selectAsteroidTypeCombobox.AddItem((int)enumValue, null, asteroidTypeHelper.Description); } m_selectAsteroidTypeCombobox.SelectItemByKey(0); Controls.Add(m_selectAsteroidTypeCombobox); m_selectAsteroidTypeCombobox.OnSelect += OnComboboxAsteroidTypeSelect; #endregion ReloadControls(); AddOkAndCancelButtonControls(); } }
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 } }
private void RecreateDynamicProperties() { Vector2 controlsOriginLeft = m_position + new Vector2(-m_size.Value.X / 2.0f + 0.025f, -m_size.Value.Y / 2.0f + 0.025f); controlsOriginLeft.Y = m_offsetForSizeProperties; Vector2 labelOffset = new Vector2(-0.015f, 0f); Vector2 controlsDelta = MyGuiConstants.CONTROLS_DELTA * 0.6f; #region shape size slidebar foreach (MyGuiControlBase oldControl in m_dynamicControls) { m_controls.Remove(oldControl); } m_dynamicControls.Clear(); float propScale = 0.65f; float sliderWidth = MyGuiConstants.SLIDER_WIDTH * 1.2f; for (int i = 0; i < MyEditorVoxelHand.VoxelHandShape.GetPropertiesCount(); i++) { MyGuiControlLabel label = new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyEditorVoxelHand.VoxelHandShape.GetPropertyName(i), MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE * propScale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); MyGuiControlSlider voxelShapeSizeSlider = new MyGuiControlSlider(m_parent, controlsOriginLeft + new Vector2(0.145f, 0), sliderWidth, MyVoxelConstants.MIN_VOXEL_HAND_SIZE, MyVoxelConstants.MAX_VOXEL_HAND_SIZE * MyVoxelConstants.VOXEL_SIZE_IN_METRES, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder("{0}"), 0.05f, 0, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f, propScale); m_dynamicControls.Add(label); m_dynamicControls.Add(voxelShapeSizeSlider); m_controls.Add(label); m_controls.Add(voxelShapeSizeSlider); voxelShapeSizeSlider.SetValue(MyEditorVoxelHand.VoxelHandShape.GetPropertyValue(i)); voxelShapeSizeSlider.UserData = i; voxelShapeSizeSlider.OnChange += OnSizeSliderChange; controlsOriginLeft += new Vector2(0, MyGuiConstants.SLIDER_HEIGHT * propScale * 0.75f); } controlsOriginLeft += new Vector2(0, MyGuiConstants.SLIDER_HEIGHT * propScale); #endregion #region shape distance slidebar if (m_voxelShapeDistanceLabel != null) { m_voxelShapeDistanceLabel.SetPosition(controlsOriginLeft + labelOffset); m_voxelShapeDistanceSlider.SetPosition(controlsOriginLeft + new Vector2(0.145f, 0)); } else { m_controls.Add(m_voxelShapeDistanceLabel = new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandShapeDistance, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE * propScale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); m_voxelShapeDistanceSlider = new MyGuiControlSlider(m_parent, controlsOriginLeft + new Vector2(0.145f, 0), sliderWidth, MyVoxelConstants.MIN_VOXEL_HAND_DISTANCE, MyVoxelConstants.MAX_VOXEL_HAND_DISTANCE, MyGuiConstants.SLIDER_BACKGROUND_COLOR, new StringBuilder("{0:0.00}"), 0.05f, 2, MyGuiConstants.LABEL_TEXT_SCALE * 0.85f, propScale); m_controls.Add(m_voxelShapeDistanceSlider); m_voxelShapeDistanceSlider.SetValue(MyEditorVoxelHand.GetShapeDistance()); m_voxelShapeDistanceSlider.OnChange += OnDistanceSliderChange; } #endregion controlsOriginLeft += MyGuiConstants.CONTROLS_DELTA; #region shape material Vector2 iconSize = new Vector2(0.095f, 0.095f); if (m_voxelShapeMaterialLabel != null) { m_voxelShapeMaterialLabel.SetPosition(controlsOriginLeft + labelOffset); controlsOriginLeft += controlsDelta; m_voxelShapeMaterialCombobox.SetPosition(new Vector2(controlsOriginLeft.X - 0.015f + MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, controlsOriginLeft.Y)); } else { m_controls.Add(m_voxelShapeMaterialLabel = new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, MyTextsWrapperEnum.EditVoxelHandShapeMaterial, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER)); controlsOriginLeft += controlsDelta; m_voxelShapeMaterialCombobox = new MyGuiControlCombobox(m_parent, new Vector2(controlsOriginLeft.X - 0.015f, controlsOriginLeft.Y) + new Vector2(MyGuiConstants.COMBOBOX_MEDIUM_SIZE.X / 2.0f, iconSize.Y / 2.5f), MyGuiControlPreDefinedSize.MEDIUM, iconSize, new Vector2(0.015f, 0f), MyGuiConstants.COMBOBOX_BACKGROUND_COLOR * 0.7f, MyGuiConstants.COMBOBOX_TEXT_SCALE, 4, true, false, true); foreach (MyMwcVoxelMaterialsEnum voxelMaterial in MyGuiAsteroidHelpers.MyMwcVoxelMaterialsEnumValues) { MyGuiVoxelMaterialHelper voxelMaterialHelper = MyGuiAsteroidHelpers.GetMyGuiVoxelMaterialHelper(voxelMaterial); m_voxelShapeMaterialCombobox.AddItem((int)voxelMaterial, voxelMaterialHelper.Icon, voxelMaterialHelper.Description); } m_controls.Add(m_voxelShapeMaterialCombobox); m_voxelShapeMaterialCombobox.OnSelect += OnComboboxItemSelect; } #endregion controlsOriginLeft += 3.4f * MyGuiConstants.CONTROLS_DELTA; if (m_attachDetachVoxelHandCheckbox != null) { m_controls.Remove(m_attachDetachVoxelHandCheckbox); } if (m_detachLabel != null) { m_controls.Remove(m_detachLabel); } MyTextsWrapperEnum text = MyEditorVoxelHand.DetachedVoxelHand == null ? MyTextsWrapperEnum.DetachVoxelHand : MyTextsWrapperEnum.AttachVoxelHand; m_detachLabel = new MyGuiControlLabel(m_parent, controlsOriginLeft + labelOffset, null, text, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE * propScale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); m_controls.Add(m_detachLabel); m_attachDetachVoxelHandCheckbox = new MyGuiControlCheckbox(m_parent, new Vector2(controlsOriginLeft.X + 5 * MyGuiConstants.CHECKBOX_SIZE.X, controlsOriginLeft.Y), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, m_detachLabel); m_attachDetachVoxelHandCheckbox.OnCheck += OnAttachClick; m_controls.Add(m_attachDetachVoxelHandCheckbox); LoadSortedControlsByPriority(); }