bool configSetSlider(string key, string value, Configuration.Options options) { switch (value.ToLower()) { case "top": case "t": sliderOrientation_ = SliderOrientation.Top; break; case "left": case "l": sliderOrientation_ = SliderOrientation.Left; break; case "bottom": case "b": sliderOrientation_ = SliderOrientation.Bottom; break; case "right": case "r": sliderOrientation_ = SliderOrientation.Right; break; default: log(Console.LogType.Error, $"Invalid slider orientation '{value}'"); return(false); } sliderWidth_ = options.asFloat(0, 0.03f); sliderColor_ = options.asColor(1, Color.WhiteSmoke); return(true); }
public UISlider(AddSliderNode Node, ParserState State, UIScreen Screen) : base(Screen) { Name = Node.Name; m_ID = Node.ID; Position = new Vector2(Node.SliderPosition.Numbers[0], Node.SliderPosition.Numbers[1]); if (!State.InSharedPropertiesGroup) { Image = m_Screen.GetImage(Node.Image); Image.Position = Position; } else { Image = m_Screen.GetImage(State.Image); Image.Position = Position; } if (Node.MinimumValue != null) m_Minimumvalue = (int)Node.MinimumValue; if (Node.MaximumValue != null) m_MaximumValue = (int)Node.MaximumValue; if (!State.InSharedPropertiesGroup) { m_Size = new Vector2(Node.Size.Numbers[0], Node.Size.Numbers[1]); m_Orientation = (SliderOrientation)Node.Orientation; } else { m_Size = State.Size; m_Orientation = (SliderOrientation)State.Orientation; } }
private void CopySlider(MenuSlider _element, bool ignoreUnityUI) { if (ignoreUnityUI) { uiSlider = null; } else { uiSlider = _element.uiSlider; } label = _element.label; isClickable = _element.isClickable; textEffects = _element.textEffects; outlineSize = _element.outlineSize; amount = _element.amount; minValue = _element.minValue; maxValue = _element.maxValue; anchor = _element.anchor; sliderTexture = _element.sliderTexture; sliderType = _element.sliderType; sliderDisplayType = _element.sliderDisplayType; sliderOrientation = _element.sliderOrientation; blockSize = _element.blockSize; useFullWidth = _element.useFullWidth; varID = _element.varID; numberOfSteps = _element.numberOfSteps; actionListOnChange = _element.actionListOnChange; uiSelectableHideStyle = _element.uiSelectableHideStyle; base.Copy(_element); }
/** * Initialises the MenuElement when it is created within MenuManager. */ public override void Declare() { uiSlider = null; label = "Slider"; isVisible = true; isClickable = true; numSlots = 1; amount = 1f; minValue = 0f; maxValue = 1f; anchor = TextAnchor.MiddleLeft; sliderType = AC_SliderType.CustomScript; sliderDisplayType = SliderDisplayType.FillBar; sliderOrientation = SliderOrientation.Horizontal; blockSize = new Vector2(0.05f, 1f); useFullWidth = false; varID = 0; textEffects = TextEffects.None; outlineSize = 2f; numberOfSteps = 0; actionListOnChange = null; uiSelectableHideStyle = UISelectableHideStyle.DisableObject; base.Declare(); }
public void Should_set_orientation_property_of_the_slider() { const SliderOrientation orientation = SliderOrientation.Horizontal; builder.Orientation(orientation); component.Orientation.ShouldEqual(orientation); }
public Slider(IComposition parent, SliderOrientation orientation, float value = 0f, float leftValue = 0f, float rightValue = 10f) : base(parent) { Orientation = orientation; LeftValue = leftValue; RightValue = rightValue; Value = value; }
public OldSlider(Rect2D rect, string Name, SliderOrientation Orientation) : base(rect) { this.Name = Name; this.Orientation = Orientation; this.MouseDown += this.MDown; }
public Slider(RectangleF Rect, bool AllowSmoothMotion = false) : base(Rect) { this.AllowSmoothMotion = AllowSmoothMotion; Orientation = (Rect.Width > Rect.Height) ? SliderOrientation.Horizontal : SliderOrientation.Vertical; HandleRectangleSize = Orientation == SliderOrientation.Horizontal ? new SizeF(HandleLength, Rect.Height - Padding * 2) : new SizeF(Rect.Width - Padding * 2, HandleLength); DragEvent += Drag; MouseUpEvent += MouseUp; MouseDownEvent += MouseDown; HoverEndEvent += LeaveHover; HoverEvent += Hover; }
/// <summary> /// Creates a slider with a numbe of fixed options. /// </summary> /// <param name="name"></param> /// <param name="caption"></param> /// <param name="position"></param> /// <param name="shape"></param> /// <param name="currentOption"></param> /// <param name="orientation"></param> /// <param name="options"></param> public Slider(string name, string caption, Vector2 position, OABB shape, int currentOption, UIAction onChange, SliderOrientation orientation, params string[] options) : base(name, position, shape) { this.minValue = 0; this.maxValue = options.Length - 1; this.options = options; this.step = 1; this.Caption = caption; this.rect = shape; this.sliderOrientation = orientation; this.snap = true; currentValue = -1; SetValue(currentValue); this.OnChange = onChange; }
/// <summary> /// Creates a value slider /// </summary> /// <param name="name"></param> /// <param name="caption"></param> /// <param name="position"></param> /// <param name="shape"></param> /// <param name="minValue"></param> /// <param name="maxValue"></param> /// <param name="currentValue"></param> /// <param name="step"></param> /// <param name="orientation"></param> /// <param name="snap">The value always snaps to the indicated steps</param> public Slider(string name, string caption, Vector2 position, OABB shape, float minValue, float maxValue, float currentValue, float step, UIAction onChange, SliderOrientation orientation, bool snap) : base(name, position, shape) { this.minValue = minValue; this.maxValue = maxValue; this.step = step; this.Caption = caption; this.rect = shape; this.sliderOrientation = orientation; this.snap = snap; this.currentValue = -1; SetValue(currentValue); this.OnChange = onChange; OnMouseDown = DoMouseDown; OnMouseUp = DoMouseUp; OnMouseMove = DoMouseMove; }
public SliderBar(XmlNode sliderXml, GUI_Base parent, object owner) : base(sliderXml, parent, owner) { //Load in the Image for the slider and the bar XmlNode barImageXML = sliderXml["SliderBarImage"]; XmlNode sliderImageXML = sliderXml["SliderImage"]; if (barImageXML != null) { backgroundImage = LoadTextureFromXML(barImageXML); } if (sliderImageXML != null) { sliderImage = LoadTextureFromXML(sliderImageXML); } //Load in the min, max and Starting values for the control. try { minValue = Convert.ToInt32(sliderXml["MinValue"].InnerText); maxValue = Convert.ToInt32(sliderXml["MaxValue"].InnerText); currentValue = Convert.ToInt32(sliderXml["InitialValue"].InnerText); } catch (NullReferenceException) { uint result = MessageBox(new IntPtr(0), string.Format("Error loading in slider values in {0}", controlName), "Error In slider XML", 0); minValue = 0; maxValue = 100; currentValue = 50; } sliderLength = Math.Abs(maxValue - minValue); XmlNode orientationXML = sliderXml["Orientation"]; if (orientationXML != null && orientationXML.InnerText == "Vertical") { orientation = SliderOrientation.Vertical; } else { orientation = SliderOrientation.Horizontal; } }
public UISlider(AddSliderNode Node, ParserState State, UIScreen Screen) : base(Screen) { Name = Node.Name; m_ID = Node.ID; Position = new Vector2(Node.SliderPosition.Numbers[0], Node.SliderPosition.Numbers[1]); if (!State.InSharedPropertiesGroup) { Image = m_Screen.GetImage(Node.Image); Image.Position = Position; } else { Image = m_Screen.GetImage(State.Image); Image.Position = Position; } if (Node.MinimumValue != null) { m_Minimumvalue = (int)Node.MinimumValue; } if (Node.MaximumValue != null) { m_MaximumValue = (int)Node.MaximumValue; } if (!State.InSharedPropertiesGroup) { m_Size = new Vector2(Node.Size.Numbers[0], Node.Size.Numbers[1]); m_Orientation = (SliderOrientation)Node.Orientation; } else { m_Size = State.Size; m_Orientation = (SliderOrientation)State.Orientation; } }
public void Orientation_should_return_builder() { const SliderOrientation orientation = SliderOrientation.Horizontal; builder.Orientation(orientation).ShouldBeType <SliderBuilder <int> >(); }
/// <summary>Sets orientation of the range slider.</summary> public RangeSliderBuilder <T> Orientation(SliderOrientation orientation) { Component.Orientation = orientation; return(this); }
protected void renderSlider(AddSpriteDelegate addSprite, RenderTarget rt, Vector2 position, Vector2 size, bool doubleSided, float ratio, Dictionary <float, Color> barGradient, SliderOrientation sliderOrientation, float sliderWidth, Color sliderColor) { ratio = !doubleSided ? ((ratio * 2f) - 1f) * 0.5f : ratio * 0.5f; bool vertical = sliderOrientation == SliderOrientation.Left || sliderOrientation == SliderOrientation.Right; float rotation = vertical ? 0f : (float)Math.PI * 0.5f; Vector2 rtPosition = position + rt.DisplayOffset; Vector2 sliderSize; Vector2 sliderPosition; Vector2 barPosition; Vector2 barSize; const float barHeightFactor = 0.8f; const float sliderHeightFactor = 0.9f; if (vertical) { sliderSize = new Vector2(size.X * sliderHeightFactor, sliderWidth * size.Y); barSize = new Vector2(size.X * barHeightFactor, size.Y - sliderSize.Y); if (sliderOrientation == SliderOrientation.Left) { barPosition = new Vector2(position.X + (size.X - barSize.X) * 0.5f, position.Y); sliderPosition = new Vector2(rtPosition.X - (size.X - sliderSize.X) * 0.5f, rtPosition.Y - ratio * barSize.Y); } else { barPosition = new Vector2(position.X - (size.X - barSize.X) * 0.5f, position.Y); sliderPosition = new Vector2(rtPosition.X + (size.X - sliderSize.X) * 0.5f, rtPosition.Y - ratio * barSize.Y); } } else { sliderSize = new Vector2(sliderWidth * size.X, size.Y * sliderHeightFactor); barSize = new Vector2(size.Y * barHeightFactor, size.X - sliderSize.X); if (sliderOrientation == SliderOrientation.Top) { barPosition = new Vector2(position.X, position.Y + (size.Y - barSize.X) * 0.5f); sliderPosition = new Vector2(rtPosition.X + ratio * barSize.Y, rtPosition.Y - (size.Y - sliderSize.Y) * 0.5f); } else { barPosition = new Vector2(position.X, position.Y - (size.Y - barSize.X) * 0.5f); sliderPosition = new Vector2(rtPosition.X + ratio * barSize.Y, rtPosition.Y + (size.Y - sliderSize.Y) * 0.5f); } } if (doubleSided == true) { Dictionary <float, Color> clamped = new Dictionary <float, Color>(); foreach (var pair in barGradient) { clamped.Add((pair.Key * 0.5f) + 0.5f, pair.Value); } renderSegmentedBar(addSprite, rt, barPosition, barSize, rotation, false, 0, 0f, "", 1f, clamped, 0f, Color.White, new Color(0, 0, 0, 0)); } else { renderSegmentedBar(addSprite, rt, barPosition, barSize, rotation, false, 0, 0f, "", 1f, barGradient, 0f, Color.White, new Color(0, 0, 0, 0)); } // draw slider if (vertical) { if (sliderOrientation == SliderOrientation.Left) { addSprite(new MySprite(SpriteType.TEXTURE, IconNameCircle, new Vector2(sliderPosition.X - sliderSize.X * 0.5f + sliderSize.Y * 0.5f, sliderPosition.Y), new Vector2(sliderSize.X), sliderColor)); addSprite(new MySprite(SpriteType.TEXTURE, "Triangle", new Vector2(sliderPosition.X + sliderSize.X * 0.5f - sliderSize.Y * 0.5f, sliderPosition.Y), new Vector2(sliderSize.Y, sliderSize.Y), sliderColor, rotation: (float)(Math.PI * 0.5f))); addSprite(new MySprite(SpriteType.TEXTURE, IconNameSquareSimple, new Vector2(sliderPosition.X - sliderSize.Y * 0.25f, sliderPosition.Y), new Vector2(sliderSize.X - sliderSize.Y * 1.5f, sliderSize.Y), sliderColor)); } else { addSprite(new MySprite(SpriteType.TEXTURE, IconNameCircle, new Vector2(sliderPosition.X + sliderSize.X * 0.5f - sliderSize.Y * 0.5f, sliderPosition.Y), new Vector2(sliderSize.X), sliderColor)); addSprite(new MySprite(SpriteType.TEXTURE, "Triangle", new Vector2(sliderPosition.X - sliderSize.X * 0.5f + sliderSize.Y * 0.5f, sliderPosition.Y), new Vector2(sliderSize.Y, sliderSize.Y), sliderColor, rotation: (float)(Math.PI * 1.5f))); addSprite(new MySprite(SpriteType.TEXTURE, IconNameSquareSimple, new Vector2(sliderPosition.X + sliderSize.Y * 0.25f, sliderPosition.Y), new Vector2(sliderSize.X - sliderSize.Y * 1.5f, sliderSize.Y), sliderColor)); } } else { if (sliderOrientation == SliderOrientation.Top) { addSprite(new MySprite(SpriteType.TEXTURE, IconNameCircle, new Vector2(sliderPosition.X, sliderPosition.Y - sliderSize.Y * 0.5f + sliderSize.X * 0.5f), new Vector2(sliderSize.X), sliderColor)); addSprite(new MySprite(SpriteType.TEXTURE, "Triangle", new Vector2(sliderPosition.X, sliderPosition.Y + sliderSize.Y * 0.5f - sliderSize.X * 0.5f), new Vector2(sliderSize.X, sliderSize.X), sliderColor, rotation: (float)(Math.PI))); addSprite(new MySprite(SpriteType.TEXTURE, IconNameSquareSimple, new Vector2(sliderPosition.X, sliderPosition.Y - sliderSize.X * 0.25f), new Vector2(sliderSize.X, sliderSize.Y - sliderSize.X * 1.5f), sliderColor)); } else { addSprite(new MySprite(SpriteType.TEXTURE, IconNameCircle, new Vector2(sliderPosition.X, sliderPosition.Y + sliderSize.Y * 0.5f - sliderSize.X * 0.5f), new Vector2(sliderSize.X), sliderColor)); addSprite(new MySprite(SpriteType.TEXTURE, "Triangle", new Vector2(sliderPosition.X, sliderPosition.Y - sliderSize.Y * 0.5f + sliderSize.X * 0.5f), new Vector2(sliderSize.X, sliderSize.X), sliderColor)); addSprite(new MySprite(SpriteType.TEXTURE, IconNameSquareSimple, new Vector2(sliderPosition.X, sliderPosition.Y + sliderSize.X * 0.25f), new Vector2(sliderSize.X, sliderSize.Y - sliderSize.X * 1.5f), sliderColor)); } } }
public override void ShowGUI(Menu menu) { string apiPrefix = "(AC.PlayerMenus.GetElementWithName (\"" + menu.title + "\", \"" + title + "\") as AC.MenuSlider)"; MenuSource source = menu.menuSource; CustomGUILayout.BeginVertical(); sliderType = (AC_SliderType)CustomGUILayout.EnumPopup("Slider affects:", sliderType, apiPrefix + ".sliderType", "What the slider's value represents"); if (source == MenuSource.AdventureCreator) { label = CustomGUILayout.TextField("Label text:", label, apiPrefix + ".label", "The text that's displayed on-screen"); } if (sliderType == AC_SliderType.CustomScript) { ShowClipHelp(); amount = CustomGUILayout.Slider("Default value:", amount, minValue, maxValue, apiPrefix + ".amount", "The slider's default value"); } else if (sliderType == AC_SliderType.FloatVariable) { varID = AdvGame.GlobalVariableGUI("Global float var:", varID, VariableType.Float, "The global Float variable whose value is linked to the slider"); } if (sliderType == AC_SliderType.CustomScript || sliderType == AC_SliderType.FloatVariable) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Min. value:", GUILayout.Width(80f)); minValue = EditorGUILayout.FloatField(minValue); EditorGUILayout.LabelField("Max. value:", GUILayout.Width(80f)); maxValue = EditorGUILayout.FloatField(maxValue); EditorGUILayout.EndHorizontal(); maxValue = Mathf.Max(minValue, maxValue); } else { minValue = 0f; maxValue = 1f; } actionListOnChange = (ActionListAsset)CustomGUILayout.ObjectField <ActionListAsset> ("ActionList on change:", actionListOnChange, false, apiPrefix + ".actionListOnChange"); if (source == MenuSource.AdventureCreator) { numberOfSteps = CustomGUILayout.IntField("Number of steps:", numberOfSteps, apiPrefix + ".numberOfSteps", "The number of descrete values the slider can have"); } if (source == MenuSource.AdventureCreator) { sliderOrientation = (SliderOrientation)CustomGUILayout.EnumPopup("Orientation:", sliderOrientation, apiPrefix + ".sliderOrientation", "Which way the slider is orientated"); if (sliderOrientation == SliderOrientation.Horizontal) { useFullWidth = CustomGUILayout.Toggle("Use full width?", useFullWidth, apiPrefix + ".useFullWidth", "If True, then the slider will be drawn across the whole width of the element. Otherwise, it will be drawn across only half."); } sliderDisplayType = (SliderDisplayType)CustomGUILayout.EnumPopup("Display type:", sliderDisplayType, apiPrefix + ".sliderDisplayType", "The display type of the slider"); if (sliderDisplayType == SliderDisplayType.MoveableBlock) { blockSize = EditorGUILayout.Vector2Field(new GUIContent("Block size:", "The dimensions of the block"), blockSize); } } else { uiSlider = LinkedUiGUI <Slider> (uiSlider, "Linked Slider:", source, "The Unity UI Slider this is linked to"); uiSelectableHideStyle = (UISelectableHideStyle)CustomGUILayout.EnumPopup("When invisible:", uiSelectableHideStyle, apiPrefix + ".uiSelectableHideStyle", "The method by which this element is hidden from view when made invisible"); CustomGUILayout.EndVertical(); CustomGUILayout.BeginVertical(); } isClickable = CustomGUILayout.Toggle("User can change value?", isClickable, apiPrefix + ".isClickable", "If True, the slider is interactive and can be modified by the user"); CustomGUILayout.EndVertical(); base.ShowGUI(menu); }
public GThumbSlider(int x, int y, SliderOrientation orientation) : base(x, y) { this._orientation = orientation; }
public Slider(string name, string caption, Vector2 position, OABB shape, float minValue, float maxValue, float currentValue, float step, UIAction onChange, SliderOrientation orientation) : this(name, caption, position, shape, minValue, maxValue, currentValue, step, onChange, orientation, false) { }