public virtual IEnumerable <TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return(Enumerable.Empty <TileChange>());
            }

            if (old.Id == _tile.Id)
            {
                return(Enumerable.Empty <TileChange>());
            }

            var selection = screen.Selection;

            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tile_x, tile_y))
                {
                    return(null);
                }
            }

            screen.ChangeTile(tile_x, tile_y, _tile.Id);

            return(new[] { new TileChange(screen, tile_x, tile_y, old.Id, _tile.Id) });
        }
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// </summary>
        public IEnumerable <TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            List <TileChange> undo = new List <TileChange>();
            bool changed           = false;

            foreach (TileBrushCell[] col in _cells)
            {
                foreach (TileBrushCell cell in col)
                {
                    var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y);

                    if (old == null)
                    {
                        continue;
                    }

                    undo.Add(new TileChange(screen, cell.x, cell.y, old.Id, cell.tile.Id));
                    if (old.Id != cell.tile.Id)
                    {
                        changed = true;
                        screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id);
                    }
                }
            }

            if (changed)
            {
                return(undo);
            }

            return(Enumerable.Empty <TileChange>());
        }
Exemple #3
0
        public EntityPlacementControlViewModel(EntityPlacement placement, EntityInfo entityInfo, ScreenDocument screen)
        {
            if (placement == null)
            {
                throw new ArgumentNullException("placement");
            }

            if (entityInfo == null)
            {
                throw new ArgumentNullException("entityInfo");
            }

            if (screen == null)
            {
                throw new ArgumentNullException("screen");
            }

            this.Placement   = placement;
            this._entityInfo = entityInfo;
            this._screen     = screen;

            DeleteCommand     = new RelayCommand(Delete);
            FlipCommand       = new RelayCommand(Flip);
            RespawnCommand    = new RelayCommand(SetRespawnMode);
            StartStateCommand = new RelayCommand(SetStartState);

            ViewModelMediator.Current.GetEvent <ZoomChangedEventArgs>().Subscribe(ZoomChanged);
        }
        protected override void UnbindScreen(ScreenDocument oldScreen)
        {
            oldScreen.EntityAdded   -= EntityAdded;
            oldScreen.EntityRemoved -= EntityRemoved;

            this.Children.Clear();
        }
Exemple #5
0
        // Initialize the ResizingAdorner.
        public ScreenResizeAdorner(UIElement adornedElement, ScreenDocument screen)
            : base(adornedElement)
        {
            Screen = screen;

            visualChildren = new VisualCollection(this);

            // Call a helper method to initialize the Thumbs
            // with a customized cursors.
            BuildAdornerCorner(ref top, Cursors.SizeNS);
            BuildAdornerCorner(ref right, Cursors.SizeWE);
            BuildAdornerCorner(ref left, Cursors.SizeWE);
            BuildAdornerCorner(ref bottom, Cursors.SizeNS);

            // Add handlers for resizing.
            left.DragDelta   += new DragDeltaEventHandler(HandleLeft);
            bottom.DragDelta += new DragDeltaEventHandler(HandleBottom);
            top.DragDelta    += new DragDeltaEventHandler(HandleTop);
            right.DragDelta  += new DragDeltaEventHandler(HandleRight);

            right.DragStarted += DragStarted;

            adornedElement.MouseEnter += adornedElement_MouseEnter;
            adornedElement.MouseLeave += adornedElement_MouseLeave;
            this.Visibility            = System.Windows.Visibility.Hidden;
        }
        protected override ScreenCanvas CreateScreenCanvas(ScreenDocument screen)
        {
            var canvas = new TileScreenCanvas(ToolProvider);

            canvas.Screen = screen;

            return(canvas);
        }
Exemple #7
0
        public void GrowLayout(ScreenDocument screen, IEnumerable <ScreenDocument> allScreens)
        {
            _area = null;

            GrowLayout(screen, allScreens, Point.Empty);

            NormalizePositions();
        }
        protected override void BindScreen(ScreenDocument newScreen)
        {
            newScreen.EntityAdded   += EntityAdded;
            newScreen.EntityRemoved += EntityRemoved;

            foreach (var placement in newScreen.Entities)
            {
                EntityAdded(placement);
            }
        }
Exemple #9
0
        protected override void BindScreen(ScreenDocument newScreen)
        {
            newScreen.Stage.EntryPointsChanged += Update;

            var player = newScreen.Stage.Project.EntityByName("Player");

            if (player != null)
            {
                _playerSprite = player.DefaultSprite;
            }
        }
Exemple #10
0
 private void SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (e.Selection != null)
     {
         _selection       = e.Selection;
         _selectionScreen = e.Screen;
     }
     else if (e.Screen == _selectionScreen)
     {
         _selection = null;
     }
 }
Exemple #11
0
        private void GrowLayout(ScreenDocument screen, IEnumerable <ScreenDocument> allScreens, Point location)
        {
            var screenPosition = new LayoutScreenPosition(screen, location);

            // add this screen
            _screens.Add(screenPosition);

            // use its joins to branch out
            foreach (var join in screen.Joins)
            {
                if (!ScreenNames.Contains(join.screenOne))
                {
                    var screenOne = allScreens.Single(s => s.Name == join.screenOne);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetTwo - join.offsetOne, -screenOne.Height);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(-screenOne.Width, join.offsetTwo - join.offsetOne);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }

                if (!ScreenNames.Contains(join.screenTwo))
                {
                    var screenTwo = allScreens.Single(s => s.Name == join.screenTwo);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetOne - join.offsetTwo, screen.Height);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(screen.Width, join.offsetOne - join.offsetTwo);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }
            }
        }
Exemple #12
0
 protected override void UnbindScreen(ScreenDocument oldScreen)
 {
     oldScreen.EntitiesChanged -= Update;
 }
Exemple #13
0
 protected override void BindScreen(ScreenDocument newScreen)
 {
     newScreen.EntitiesChanged += Update;
 }
        public void GrowLayout(ScreenDocument screen, IEnumerable<ScreenDocument> allScreens)
        {
            _area = null;

            GrowLayout(screen, allScreens, Point.Empty);

            NormalizePositions();
        }
 protected abstract ScreenCanvas CreateScreenCanvas(ScreenDocument screen);
Exemple #16
0
 protected override void UnbindScreen(ScreenDocument oldScreen)
 {
     oldScreen.Stage.EntryPointsChanged -= Update;
 }
 protected abstract void BindScreen(ScreenDocument newScreen);
Exemple #18
0
 protected override void UnbindScreen(ScreenDocument oldScreen)
 {
     _selectionBounds            = null;
     oldScreen.SelectionChanged -= UpdateSelection;
 }
 public LayoutScreenPosition(ScreenDocument screen, Point location)
 {
     Screen = screen;
     Location = location;
 }
Exemple #20
0
 protected override void BindScreen(ScreenDocument newScreen)
 {
     newScreen.TileChanged += DrawProperties;
 }
Exemple #21
0
 protected override void UnbindScreen(ScreenDocument oldScreen)
 {
     oldScreen.TileChanged -= DrawProperties;
 }
 private void ScreenAddedOrRemoved(ScreenDocument obj)
 {
     ResetScreens();
 }
 private void ScreenResized(ScreenDocument screen, int width, int height)
 {
     LayoutScreens();
 }
        private void GrowLayout(ScreenDocument screen, IEnumerable<ScreenDocument> allScreens, Point location)
        {
            var screenPosition = new LayoutScreenPosition(screen, location);
            // add this screen
            _screens.Add(screenPosition);

            // use its joins to branch out
            foreach (var join in screen.Joins)
            {
                if (!ScreenNames.Contains(join.screenOne))
                {
                    var screenOne = allScreens.Single(s => s.Name == join.screenOne);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetTwo - join.offsetOne, -screenOne.Height);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(-screenOne.Width, join.offsetTwo - join.offsetOne);
                        GrowLayout(screenOne, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }

                if (!ScreenNames.Contains(join.screenTwo))
                {
                    var screenTwo = allScreens.Single(s => s.Name == join.screenTwo);

                    if (join.type == Common.JoinType.Horizontal)
                    {
                        Point offset = new Point(join.offsetOne - join.offsetTwo, screen.Height);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                    else
                    {
                        Point offset = new Point(screen.Width, join.offsetOne - join.offsetTwo);
                        GrowLayout(screenTwo, allScreens, new Point(location.X + offset.X, location.Y + offset.Y));
                    }
                }
            }
        }
Exemple #25
0
 public LayoutScreenPosition(ScreenDocument screen, Point location)
 {
     Screen   = screen;
     Location = location;
 }
 protected abstract void UnbindScreen(ScreenDocument oldScreen);
 private void DeleteScreen(ScreenDocument screen)
 {
 }
 protected override void BindScreen(ScreenDocument newScreen)
 {
     newScreen.Stage.EntryPointsChanged += Update;
 }
Exemple #29
0
        public virtual IEnumerable<TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            var old = screen.TileAt(tile_x, tile_y);

            if (old == null)
            {
                return Enumerable.Empty<TileChange>();
            }

            if (old.Id == _tile.Id)
            {
                return Enumerable.Empty<TileChange>();
            }

            var selection = screen.Selection;
            if (selection != null)
            {
                // only paint inside selection
                if (!selection.Value.Contains(tile_x, tile_y)) return null;
            }

            screen.ChangeTile(tile_x, tile_y, _tile.Id);

            return new[] { new TileChange(screen, tile_x, tile_y, old.Id, _tile.Id) };
        }
Exemple #30
0
        private void Draw(ScreenDocument screen, int tile_x, int tile_y)
        {
            var changed = _brush.DrawOn(screen, tile_x, tile_y);

            changes.AddRange(changed);
        }
Exemple #31
0
        /// <summary>
        /// Draws the brush onto the given screen at the given tile location.
        /// </summary>
        public IEnumerable<TileChange> DrawOn(ScreenDocument screen, int tile_x, int tile_y)
        {
            List<TileChange> undo = new List<TileChange>();
            bool changed = false;
            foreach (TileBrushCell[] col in _cells)
            {
                foreach (TileBrushCell cell in col)
                {
                    var old = screen.TileAt(cell.x + tile_x, cell.y + tile_y);

                    if (old == null) continue;

                    undo.Add(new TileChange(screen, cell.x, cell.y, old.Id, cell.tile.Id));
                    if (old.Id != cell.tile.Id)
                    {
                        changed = true;
                        screen.ChangeTile(cell.x + tile_x, cell.y + tile_y, cell.tile.Id);
                    }
                }
            }

            if (changed)
            {
                return undo;
            }

            return Enumerable.Empty<TileChange>();
        }
 private void Draw(ScreenDocument screen, int tile_x, int tile_y)
 {
     var changed = _brush.DrawOn(screen, tile_x, tile_y);
     changes.AddRange(changed);
 }
Exemple #33
0
 protected override void BindScreen(ScreenDocument newScreen)
 {
     newScreen.SelectionChanged += UpdateSelection;
     UpdateSelection(newScreen.Selection);
 }