Beispiel #1
0
		public void ChangeMaterialsToDefaultMaterial()
		{
			var selectedControls = new List<Entity2D>();
			selectedControls.Add(new Slider(Rectangle.One));
			uiControl.SetMaterials(selectedControls);
			var defaultTheme = new Slider(Rectangle.One).Get<Theme>();
			Assert.AreEqual(defaultTheme.Slider.Name, uiControl.SelectedMaterial);
			Assert.AreEqual(defaultTheme.SliderPointerMouseover.Name, uiControl.SelectedHoveredMaterial);
			Assert.AreEqual(defaultTheme.SliderPointer.Name, uiControl.SelectedPressedMaterial);
			Assert.AreEqual(defaultTheme.SliderDisabled.Name, uiControl.SelectedDisabledMaterial);
		}
Beispiel #2
0
 public void AddControlToScene(Control control, UIEditorScene scene)
 {
     Control newControl = null;
     if (control.GetType() == typeof(Picture))
         newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
     else if (control.GetType() == typeof(Label))
     {
         newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
         newControl.Set(control.Get<Material>());
     }
     else if (control.GetType() == typeof(Button))
         newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
     else if (control.GetType() == typeof(Slider))
         newControl = new Slider(control.Get<Theme>(), control.DrawArea);
     newControl.AddTag(control.GetTags()[0]);
     newControl.RenderLayer = control.RenderLayer;
     scene.Scene.Add(newControl);
 }
Beispiel #3
0
		public virtual void CreateSliders()
		{
			horizontalSlider = new Slider(new Theme(), new Rectangle(0, 0, 1, 1));
			horizontalSlider.MaxValue = 0;
			horizontalSlider.Value = 0;
			verticalSlider = new Slider(new Theme(), new Rectangle(0, 0, 1, 1)) { Rotation = 90 };
			verticalSlider.MaxValue = 0;
			verticalSlider.Value = 0;
			horizontalSlider.ValueChanged += value =>
			{
				SetCameraPosition();
				CalculateSliderPositionAndScale();
			};
			verticalSlider.ValueChanged += value =>
			{
				SetCameraPosition();
				CalculateSliderPositionAndScale();
			};
			CalculateSliderPositionAndScale();
			Hide();
		}
Beispiel #4
0
		public void AddControlToScene(Control control)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Get<Material>());
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton(control.Get<Theme>(), control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider(control.Get<Theme>(), control.DrawArea);
			newControl.RenderLayer = control.RenderLayer;
			if (!newControl.Contains<AnchoringState>())
				newControl.Add(new AnchoringState()); //ncrunch: no coverage
			CheckIfAnyMaterialIsCorrupt(newControl);
			Scene.Add(newControl);
		}
		private void AddVolumeControlToOptionsMenu()
		{
			var volume = new FontText(Font.Default, "Volume: 100",
				new Rectangle(0.45f, 0.475f, 0.2f, 0.05f))
			{
				HorizontalAlignment = HorizontalAlignment.Left,
				RenderLayer = 4
			};
			var volumeSlider = new Slider(new Rectangle(0.65f, 0.475f, 0.2f, 0.05f)) { RenderLayer = 4 };
			volumeSlider.ValueChanged += value => volume.Text = "Volume: " + value;
			optionsMenu.Add(volume);
			optionsMenu.Add(volumeSlider);
		}
Beispiel #6
0
			private void AddSoundOption()
			{
				var labelTheme = new Theme();
				labelTheme.Label = new Material(ShaderFlags.Position2DColoredTextured, "SoundLabel");
				var label = new Label(labelTheme,
					Rectangle.FromCenter(0.3f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.2f, 0.1f));
				Add(label);

				var soundSlider = new Slider(menuTheme,
					Rectangle.FromCenter(0.6f, ScreenSpace.Current.Viewport.Top + 0.6f, 0.4f, 0.05f))
				{
					MaxValue = 100,
					MinValue = 0,
					Value = (int)(Settings.Current.SoundVolume * 100)
				};
				soundSlider.ValueChanged += val =>
				{
					Settings.Current.SoundVolume = val / 100.0f;
					if (!parent.EnterSound.IsAnyInstancePlaying)
						parent.EnterSound.Play(Settings.Current.SoundVolume);
				};
				soundSlider.Start<SettingsUpdater>();
				Add(soundSlider);
			}
 public void SetUp()
 {
     ellipse = new Ellipse(Vector2D.Half, 0.2f, 0.1f, Color.Blue);
     ellipse.Add(new Name("name"));
     writer = new EntityWriter(ellipse);
     drawAreaBox = writer.scene.Controls[1] as TextBox;
     colorRSlider = writer.scene.Controls[3] as Slider;
     colorGSlider = writer.scene.Controls[5] as Slider;
     colorBSlider = writer.scene.Controls[7] as Slider;
     colorASlider = writer.scene.Controls[9] as Slider;
     nameBox = writer.scene.Controls[11] as TextBox;
     rotationBox = writer.scene.Controls[13] as TextBox;
     rotationCenterBox = writer.scene.Controls[15] as TextBox;
 }
		private static string CreateMethodToSliderValueChangedEventString(Slider slider)
		{
			string controlName = slider.Name;
			var methodsToSliderValueChangedAssignmentString = "";
			methodsToSliderValueChangedAssignmentString += "			var " + controlName +
				" = scene.Controls.FirstOrDefault(control => ((Control)control).Name == " + '"' +
				controlName + '"' + ");\n";
			methodsToSliderValueChangedAssignmentString += "			" + controlName +
				".ValueChanged = () => " + controlName + "ValueChanged(value);\n";
			return methodsToSliderValueChangedAssignmentString;
		}
Beispiel #9
0
 public void SetUp()
 {
     center = Rectangle.FromCenter(0.5f, 0.5f, 0.5f, 0.1f);
     slider = new Slider(center);
     slider.Add(new FontText(Font.Default, "", new Rectangle(0.5f, 0.7f, 0.2f, 0.1f)));
     slider.Start<DisplaySliderValue>();
     InitializeMouse();
 }
Beispiel #10
0
            private void AddColorSliders()
            {
                sliderRed = new Slider(parentMenu.menuTheme, new Rectangle(0.4f, 0.3f, 0.4f, 0.1f))
                {
                    RenderLayer = 5,
                    MaxValue = 255,
                    MinValue = 0
                };
                sliderRed.ValueChanged += value =>
                {
                    parentMenu.gameColors[currentColorIndex].R = (byte)value;
                    UpdateColorDisplay();
                };
                Add(sliderRed);

                sliderGreen = new Slider(parentMenu.menuTheme, new Rectangle(0.4f, 0.45f, 0.4f, 0.1f))
                {
                    RenderLayer = 5,
                    MaxValue = 255,
                    MinValue = 0
                };
                sliderGreen.ValueChanged += value =>
                {
                    parentMenu.gameColors[currentColorIndex].G = (byte)value;
                    UpdateColorDisplay();
                };
                Add(sliderGreen);

                sliderBlue = new Slider(parentMenu.menuTheme, new Rectangle(0.4f, 0.6f, 0.4f, 0.1f))
                {
                    RenderLayer = 5,
                    MaxValue = 255,
                    MinValue = 0
                };
                sliderBlue.ValueChanged += value =>
                {
                    parentMenu.gameColors[currentColorIndex].B = (byte)value;
                    UpdateColorDisplay();
                };
                Add(sliderBlue);

                UpdateSliderValues();
            }
Beispiel #11
0
		public void AddControlToScene(Control control, Scene scene)
		{
			Control newControl = null;
			if (control.GetType() == typeof(Picture))
				newControl = new Picture((control as Picture).Theme, control.Material, control.DrawArea);
			else if (control.GetType() == typeof(Label))
			{
				newControl = new Label((control as Picture).Theme, control.DrawArea, (control as Label).Text);
				newControl.Set(control.Get<BlendMode>());
				newControl.Set(control.Material);
			}
			else if (control.GetType() == typeof(Button))
				newControl = new Button((control as Picture).Theme, control.DrawArea, (control as Button).Text);
			else if (control.GetType() == typeof(InteractiveButton))
				newControl = new InteractiveButton((control as Picture).Theme, control.DrawArea,
					(control as Button).Text);
			else if (control.GetType() == typeof(Slider))
				newControl = new Slider((control as Picture).Theme, control.DrawArea);
			newControl.Name = control.Name;
			if (newControl.Name == null && newControl.GetTags()[0] != null)
				newControl.Name = newControl.GetTags()[0];
			newControl.RenderLayer = control.RenderLayer;
			if (!control.Contains<AnchoringState>())
				newControl.Set(new AnchoringState()); //ncrunch: no coverage
			else
				newControl.Set(control.Get<AnchoringState>());
			scene.Add(newControl);
		}
Beispiel #12
0
		private static void SetDefaultSliderName(Slider newSlider, UIEditorScene uiEditorScene)
		{
			uiEditorScene.UIImagesInList.Add(newSlider.Name);
			if (uiEditorScene.UIImagesInList[0] == null)
				uiEditorScene.UIImagesInList[0] = newSlider.Name;
		}
Beispiel #13
0
		private static Slider AddNewSliderToList(Vector2D position, UIEditorScene uiEditorScene)
		{
			var newSlider = new Slider(new Theme(),
				Rectangle.FromCenter(position, new Size(0.15f, 0.03f)));
			uiEditorScene.Scene.Add(newSlider);
			SetDefaultSliderName(newSlider, uiEditorScene);
			return newSlider;
		}
Beispiel #14
0
		private static Control LoadControl(BinaryReader reader, bool doNotNullRead,
			byte[] versionBytes)
		{
			var controlType = reader.ReadString();
			Control control;
			if (controlType == "Button")
				control = new Button();
			else if (controlType == "InteractiveButton")
				control = new InteractiveButton();
			else if (controlType == "Picture")
				control = new Picture();
			else if (controlType == "Label")
				control = new Label();
			else if (controlType == "Slider")
				control = new Slider();
			else
				throw new ControlTypeNotImplemented(controlType);
			if (doNotNullRead)
				reader.ReadBoolean();
			LoadControl(control, reader, versionBytes);
			return control;
		}
Beispiel #15
0
 private static void SetDefaultSliderName(Slider newSlider, UIEditorScene uiEditorScene)
 {
     bool freeName = false;
     int numberOfNames = 0;
     while (!freeName)
         if (uiEditorScene.UIImagesInList.Contains(NewSliderId + numberOfNames))
             numberOfNames++;
         else
             freeName = true;
     uiEditorScene.UIImagesInList.Add(NewSliderId + numberOfNames);
     if (uiEditorScene.UIImagesInList[0] == null)
         uiEditorScene.UIImagesInList[0] = NewSliderId + numberOfNames;
     newSlider.AddTag(NewSliderId + numberOfNames);
 }
		public void AddNewSliderToScene()
		{
			var slider = new Slider(Rectangle.One);
			slider.AddTag("slider");
			CheckTypeOfNewControl(slider, "Slider1");
		}