private MyGuiControlSliderBase AddSliderBase(String text, MyGuiSliderProperties props, Vector4?color = null) { MyGuiControlSliderBase slider = new MyGuiControlSliderBase( position: m_currentPosition, width: 460f / MyGuiConstants.GUI_OPTIMAL_SIZE.X, props: props, labelScale: 0.75f * m_scale, originAlign: MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP, labelFont: MyFontEnum.Debug); slider.DebugScale = m_sliderDebugScale; slider.ColorMask = color ?? m_defaultColor; Controls.Add(slider); MyGuiControlLabel label = new MyGuiControlLabel( position: m_currentPosition + new Vector2(0.015f, 0f), text: text, colorMask: color ?? m_defaultTextColor, textScale: MyGuiConstants.DEFAULT_TEXT_SCALE * 0.8f * m_scale, font: MyFontEnum.Debug); label.OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP; float labelWidth = label.GetTextSize().X + 0.02f; m_maxWidth = Math.Max(m_maxWidth, labelWidth); Controls.Add(label); m_currentPosition.Y += slider.Size.Y + Spacing; return(slider); }
protected MyGuiControlSliderBase AddSlider(String text, MyGuiSliderProperties properties, Func <float> getter, Action <float> setter, Vector4?color = null) { MyGuiControlSliderBase slider = AddSliderBase(text, properties, color); slider.Value = getter(); slider.UserData = setter; slider.ValueChanged = delegate(MyGuiControlSliderBase sender) { var ac = (Action <float>)sender.UserData; ac(sender.Value); ValueChanged(sender); }; return(slider); }