protected MyGuiControlCheckbox addCheckBox(StringBuilder text, bool enabled = true, List<MyGuiControlBase> controlGroup = null, Vector4? color = null) { MyGuiControlLabel label = new MyGuiControlLabel(this, m_currentPosition, null, text, color ?? m_defaultColor, MyGuiConstants.LABEL_TEXT_SCALE * MyGuiConstants.DEBUG_LABEL_TEXT_SCALE * m_scale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); float labelWidth = label.GetTextSize().Size.X + 0.02f; m_maxWidth = Math.Max(m_maxWidth, labelWidth); label.Enabled = enabled; Controls.Add(label); Vector2? m = this.GetSize(); Vector2 checkBoxSize = MyGuiConstants.CHECKBOX_SIZE * m_scale; MyGuiControlCheckbox checkBox = new MyGuiControlCheckbox(this, m_currentPosition + new Vector2(m.Value.X - 2 * checkBoxSize.X - m_checkBoxOffset, 0), checkBoxSize, false, 0.8f * (color ?? m_defaultColor)); checkBox.Enabled = enabled; Controls.Add(checkBox); m_currentPosition.Y += 0.04f * m_scale; if (controlGroup != null) { controlGroup.Add(label); controlGroup.Add(checkBox); } return checkBox; }
protected MyGuiControlSlider addSlider(StringBuilder text, float valueMin, float valueMax, Vector4? color = null) { MyGuiControlLabel label = new MyGuiControlLabel(this, m_currentPosition, null, text, color ?? m_defaultColor, MyGuiConstants.LABEL_TEXT_SCALE * 0.8f * m_scale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); float labelWidth = label.GetTextSize().Size.X + 0.02f; m_maxWidth = Math.Max(m_maxWidth, labelWidth); Controls.Add(label); m_currentPosition.Y += 0.04f * m_scale; MyGuiControlSlider slider = new MyGuiControlSlider(this, m_currentPosition + new Vector2(0.1f, 0) * m_scale, 0.2f, valueMin, valueMax, color ?? m_defaultColor, new System.Text.StringBuilder(" {0}"), 0.1f, 3, 0.65f * m_scale, m_scale); Controls.Add(slider); m_currentPosition.Y += 0.05f * m_scale; return slider; }
protected void AddLabel(StringBuilder text, Vector4 color, float scale, List<MyGuiControlBase> controlGroup = null, MyGuiFont font = null) { MyGuiControlLabel label = new MyGuiControlLabel(this, m_currentPosition, null, text, color, MyGuiConstants.LABEL_TEXT_SCALE * MyGuiConstants.DEBUG_LABEL_TEXT_SCALE * scale * m_scale, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, font); float labelWidth = label.GetTextSize().Size.X + 0.02f; m_maxWidth = Math.Max(m_maxWidth, labelWidth); Controls.Add(label); m_currentPosition.Y += 0.04f * m_scale; if (controlGroup != null) controlGroup.Add(label); }
public MyGuiScreenEditorOptions() : base(new Vector2(0.5f, 0.5f), MyGuiConstants.SCREEN_BACKGROUND_COLOR, null) { m_enableBackgroundFade = true; m_size = new Vector2(0.49f, 0.75f); m_displaySavePlayerShipOption = MyGuiScreenGamePlay.Static.GetGameType() == MyGuiScreenGamePlayType.EDITOR_STORY; AddCaption(MyTextsWrapperEnum.EditorOptions, new Vector2(0, 0.02f)); Vector2 controlsOriginLeft = new Vector2(-m_size.Value.X / 2.0f + 0.05f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsOriginRight = new Vector2(-m_size.Value.X / 2.0f + 0.181f, -m_size.Value.Y / 2.0f + 0.125f); Vector2 controlsDelta = new Vector2(0, 0.0525f); int dPos = 0; // enable/disable all bounding boxes displaying MyGuiControlLabel label1 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.DisplayUnselectedBounding, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); //Controls.Add(label1); float labelWidth = label1.GetTextSize().Size.X + 0.05f; //m_displayUnselectedCheckbox = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); //Controls.Add(m_displayUnselectedCheckbox); // display prefab container bounding MyGuiControlLabel label2 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.DisplayPrefabContainerBounding, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label2); m_displayPrefabContainerBounding = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_displayPrefabContainerBounding); dPos++; // display prefab container axis MyGuiControlLabel labelPrefabContainerAxis = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.DisplayPrefabContainerAxis, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(labelPrefabContainerAxis); m_displayPrefabContainerAxis = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_displayPrefabContainerAxis); dPos++; // display voxel bounding MyGuiControlLabel lblVoxelBounding = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.DisplayVoxelBounding, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(lblVoxelBounding); m_displayVoxelBounding = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_displayVoxelBounding); dPos++; // use camera crosshair option MyGuiControlLabel label3 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.UseCameraCrosshair, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label3); m_useCameraCrosshairCheckbox = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), false, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_useCameraCrosshairCheckbox); dPos++; // enable lightw in editor: MyGuiControlLabel label5 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.EnableLightsInEditor, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label5); m_enableLightsInEditorCheckbox = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_enableLightsInEditorCheckbox); dPos++; // enable snap point filter MyGuiControlLabel label7 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.EnableSnapPointFilter, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label7); m_enableSnapPointFilter = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_enableSnapPointFilter); dPos++; // fixed snap point size MyGuiControlLabel label8 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.FixedSnapPointSize, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label8); m_fixedSnapPointSize = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_fixedSnapPointSize); dPos++; // enable object pivot MyGuiControlLabel label10 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.LabelEnableObjectPivot, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label10); m_enableObjectPivot = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, label10); Controls.Add(m_enableObjectPivot); dPos++; // enable textsDrawing MyGuiControlLabel label11 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.LabelEnableTextsDrawing, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label11); m_enableTextsDrawing = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR, label10); Controls.Add(m_enableTextsDrawing); dPos++; // save player ship MyGuiControlLabel label9 = new MyGuiControlLabel(this, controlsOriginLeft + dPos * controlsDelta, null, MyTextsWrapperEnum.LabelSavePlayerShip, MyGuiConstants.LABEL_TEXT_COLOR, MyGuiConstants.LABEL_TEXT_SCALE, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER); Controls.Add(label9); m_savePlayerShip = new MyGuiControlCheckbox(this, controlsOriginLeft + dPos * controlsDelta + new Vector2(labelWidth, 0), true, MyGuiConstants.CHECKBOX_BACKGROUND_COLOR); Controls.Add(m_savePlayerShip); //label9.Visible = m_displaySavePlayerShipOption; //m_savePlayerShip.Visible = m_displaySavePlayerShipOption; // Buttons OK and CANCEL Vector2 buttonDelta = new Vector2(0.1f, m_size.Value.Y / 2.0f - MyGuiConstants.MESSAGE_BOX_BORDER_AREA_Y - MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE.Y / 2.0f - 0.01f); Controls.Add(new MyGuiControlButton(this, new Vector2(-buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Ok, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnOkClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); Controls.Add(new MyGuiControlButton(this, new Vector2(+buttonDelta.X, buttonDelta.Y), MyGuiConstants.MESSAGE_BOX_BUTTON_SIZE, MyGuiConstants.BUTTON_BACKGROUND_COLOR, MyTextsWrapperEnum.Cancel, MyGuiConstants.BUTTON_TEXT_COLOR, MyGuiConstants.BUTTON_TEXT_SCALE, OnCancelClick, MyGuiControlButtonTextAlignment.CENTERED, true, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, true)); // Update controls with values from config file UpdateFromConfig(); UpdateControls(m_settingsOld); UpdateSettings(m_settingsNew); }