Esempio n. 1
0
        public void End(Point tile)
        {
            if (region == null)
            {
                return;
            }

            EditorExtensionNode node = form.SelectedSquareType();

            if (node != null)
            {
                foreach (Point p in Line(start, tile))
                {
                    Vector3 loc = new Vector3(p.X + form.Map.View.X,
                                              p.Y + form.Map.View.Y, form.Map.View.Z);
                    AbstractSquare sq = (AbstractSquare)node.CreateInstance();
                    change.AddOperation(form.Map.GetSafeSquare(loc), sq, loc);
                    form.Map.SetSquare(loc, sq);
                }
            }
            if (change.Count > 0)
            {
                form.UndoRedo.AddChange(change);
            }

            change = null;

            region.Invalidate();

            region.Dispose();
            region = null;

            form.Map.ViewFrom(form.Map.View, true);
        }
Esempio n. 2
0
 public void AddingControlTwiceOnlyAddsItOnce()
 {
     var control = new EmptyControl();
     scene.Add(control);
     scene.Add(control);
     Assert.AreEqual(1, scene.Controls.Count);
 }
Esempio n. 3
0
		public void AddingControlAddsToListOfControls()
		{
			Assert.AreEqual(0, scene.Controls.Count);
			var control = new EmptyControl();
			scene.Add(control);
			Assert.AreEqual(1, scene.Controls.Count);
			Assert.AreEqual(control, scene.Controls[0]);
		}
Esempio n. 4
0
        public void AddingControlTwiceOnlyAddsItOnce()
        {
            var control = new EmptyControl();

            scene.Add(control);
            scene.Add(control);
            Assert.AreEqual(1, scene.Controls.Count);
        }
Esempio n. 5
0
        public void Start(Point tile)
        {
            region      = new EmptyControl(form.Map);
            region.Size = form.Map.Size;

            change = new SquareChange(form.Map);

            start = oldend = tile;
        }
Esempio n. 6
0
        public void Start(Point tile)
        {
            region = new EmptyControl(form.Map.Size, new Point(0, 0));
            change = new SquareChange(form.Map);

            form.Map.AddRegion(region);

            start = oldend = tile;
        }
Esempio n. 7
0
        public void AddingControlAddsToListOfControls()
        {
            Assert.AreEqual(0, scene.Controls.Count);
            var control = new EmptyControl();

            scene.Add(control);
            Assert.AreEqual(1, scene.Controls.Count);
            Assert.AreEqual(control, scene.Controls[0]);
        }
Esempio n. 8
0
        public Slider(string displayName, int defaultValue = 0, int minValue = 0, int maxValue = 100)
            : base(displayName, DefaultHeight + ThemeManager.CurrentTheme.Config.SpriteAtlas.Backgrounds.Slider.Height)
        {
            // Initialize properties
            TextObjects.AddRange(new[]
            {
                TextHandle = new Text(displayName, DefaultFont)
                {
                    TextOrientation = Text.Orientation.Top,
                    Color           = DefaultColorGold
                },
                ValueDisplayHandle = new Text("placeholder", DefaultFont)
                {
                    TextOrientation = Text.Orientation.Top,
                    TextAlign       = Text.Align.Right,
                    Color           = DefaultColorGold
                }
            });
            Background = new EmptyControl(ThemeManager.SpriteType.BackgroundSlider)
            {
                DrawBase = true
            };
            ControlHandle = new SliderHandle();
            _minValue     = Math.Min(minValue, maxValue);
            _maxValue     = Math.Max(minValue, maxValue);
            CurrentValue  = defaultValue;

            // Add handle to base
            Add(Background);
            Add(ControlHandle);

            // Listen to required events
            Background.OnLeftMouseDown += delegate
            {
                if (!ControlHandle.IsLeftMouseDown && Background.IsInside(Game.CursorPos2D))
                {
                    MoveOffset = 0 - SliderSize / 2;
                    RecalculateSliderPosition((int)Game.CursorPos2D.X - SliderSize / 2);
                    ControlHandle.IsLeftMouseDown = true;
                }
            };
            ControlHandle.OnLeftMouseDown      += delegate { MoveOffset = (int)((ControlHandle.Position.X - RelativeOffset.X) - Game.CursorPos2D.X); };
            ControlHandle.OnActiveStateChanged += delegate
            {
                if (ControlHandle.IsActive)
                {
                    ControlHandle.IsActive = false;
                }
            };

            // Initalize theme specific properties
            OnThemeChange();
        }
Esempio n. 9
0
        public void ClearingControlsDeactivatesThem()
        {
            var label = new Sprite(material, Rectangle.One)
            {
                IsActive = true
            };
            var control = new EmptyControl {
                IsActive = true
            };

            scene.Add(label);
            scene.Add(control);
            scene.Clear();
            Assert.AreEqual(0, scene.Controls.Count);
            Assert.IsFalse(label.IsActive);
            Assert.IsFalse(control.IsActive);
        }
Esempio n. 10
0
        public void HidingSceneHidesControls()
        {
            var label = new Sprite(material, Rectangle.One)
            {
                IsActive = true
            };
            var control = new EmptyControl {
                IsActive = true
            };

            scene.Add(label);
            scene.Add(control);
            scene.Hide();
            scene.Hide();
            Assert.AreEqual(2, scene.Controls.Count);
            Assert.IsFalse(label.IsVisible);
            Assert.IsFalse(control.IsVisible);
        }
Esempio n. 11
0
		public void HidingSceneHidesControls()
		{
			var label = new Sprite(material, Rectangle.One) { IsActive = true };
			var control = new EmptyControl { IsActive = true };
			scene.Add(label);
			scene.Add(control);
			scene.Hide();
			scene.Hide();
			Assert.AreEqual(2, scene.Controls.Count);
			Assert.IsFalse(label.IsVisible);
			Assert.IsFalse(control.IsVisible);
		}
Esempio n. 12
0
		public void ClearingControlsDeactivatesThem()
		{
			var label = new Sprite(material, Rectangle.One) { IsActive = true };
			var control = new EmptyControl { IsActive = true };
			scene.Add(label);
			scene.Add(control);
			scene.Clear();
			Assert.AreEqual(0, scene.Controls.Count);
			Assert.IsFalse(label.IsActive);
			Assert.IsFalse(control.IsActive);
		}