public PasteAndReverseNotesOperation(Model model, SelectionArea selectionArea, Position position)
        {
            if (model == null || selectionArea == null || position == null)
            {
                Logger.Error("引数にnullのものが含まれるため、操作を行えません。", true);
                Canceled = true;
                return;
            }

            var paste   = new PasteNotesOperation(model, selectionArea, position);
            var reverse = new ReverseNotesOperation(model, selectionArea);

            Canceled = paste.Canceled && reverse.Canceled;

            Invoke += () =>
            {
                paste.Invoke();
                reverse.Invoke();
            };
            Undo += () =>
            {
                reverse.Undo();
                paste.Undo();
            };
        }
        public ClearAreaNotesOperation(Model model, SelectionArea selectionArea)
        {
            if (model == null || selectionArea == null)
            {
                Logger.Error("引数にnullのものが含まれるため、操作を行えません。", true);
                Canceled = true;
                return;
            }

            var tmpArea = new SelectionArea(selectionArea);
            var book    = model.NoteBook;

            selectionArea.Reset();

            Invoke += () =>
            {
                book.UnPutRange(tmpArea.SelectedNoteList);
                book.UnPutRange(tmpArea.SelectedLongNoteList);
            };
            Undo += () =>
            {
                book.PutRange(tmpArea.SelectedNoteList);
                book.PutRange(tmpArea.SelectedLongNoteList);
            };
        }
Exemple #3
0
    void handleDragSelect()
    {
        if (Input.GetMouseButtonDown(0))
        {
            dragStartPos = Input.mousePosition;
        }

        if (Input.GetMouseButton(0))
        {
            dragEndPosition = Input.mousePosition;
        }

        if (Input.GetMouseButtonUp(0))
        {
            GameObject[] mobs = GameObject.FindGameObjectsWithTag("Mob");
            SelectionArea area = new SelectionArea();
            area.startvector = Vector2.Min(Camera.main.ScreenToWorldPoint(dragStartPos), Camera.main.ScreenToWorldPoint(dragEndPosition));
            area.endvector = Vector2.Max(Camera.main.ScreenToWorldPoint(dragStartPos), Camera.main.ScreenToWorldPoint(dragEndPosition)); ;

            foreach (GameObject mob in mobs)
            {
                mob.SendMessage("HandleSelection", area);
            }

            dragStartPos = Vector2.zero;
            dragEndPosition = Vector2.zero;
        }
    }
    public void SetCollisionArea(SelectionArea area, Song song)
    {
        xPosition          = area.xPos;
        collisionAreaXSize = area.width;

        _areaChartPosMin = area.tickMin;
        _areaChartPosMax = area.tickMax;
    }
 private void OnAreaHoverEnter(SelectionArea selectedArea)
 {
     if (!m_CurrentlyHoveredAreas.Contains(selectedArea))
     {
         m_CurrentlyHoveredAreas.Add(selectedArea);
         CheckSelection();
     }
 }
Exemple #6
0
        public bool IsValid(int x, int y)
        {
            if (!IsActive)
            {
                return(true);
            }

            return(SelectionArea.Contains(x, y));
        }
 private void OnAreaHoverLeave(SelectionArea selectedArea)
 {
     if (m_CurrentlyHoveredAreas.Contains(selectedArea))
     {
         m_CurrentlyHoveredAreas.Remove(selectedArea);
         selectedArea.SelectionAreaDisplay.NoHighlights();
         CheckSelection();
     }
 }
 protected override void OnKeyDown(KeyEventArgs e)
 {
     base.OnKeyDown(e);
     KeyUpdateSelectionAreaPreview(e);
     if (e.KeyCode == Keys.Escape)
     {
         _selectionArea = null;
         Invalidate();
     }
 }
 void DidSelectArea(SelectionArea area)
 {
     if (Network.isServer)
     {
         NetworkServerCreateScaffolding(Network.player, area.origin, area.destination, (int)playerBlockType);
     }
     else
     {
         networkView.RPC("NetworkServerCreateScaffolding", RPCMode.Server, Network.player, area.origin, area.destination, (int)playerBlockType);
     }
 }
 public ReverseNotesOperation(Model model, SelectionArea selectionArea)
 {
     Invoke += () =>
     {
         selectionArea.ReverseNotes(model.NoteBook, model.LaneBook);
     };
     Undo += () =>
     {
         selectionArea.ReverseNotes(model.NoteBook, model.LaneBook);
     };
 }
        public CopyNotesOperation(SelectionArea selectionArea)
        {
            // NOTE: ClipBoardに「送る」っていうのは多分送るオブジェクトに参照をするだけであって、
            //       その場でシリアライズされたりはしない感じなはず(ディープコピーするのはそのため)
            Clipboard.SetDataObject(selectionArea.DeepCopy());
            Status.OnPasteChanged(true);
            Canceled = true;

            Invoke += () => Logger.Warn("何もしない");
            Undo   += () => Logger.Warn("何もしない");
        }
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);
            Capture = false;
            _depthBar.MouseUp(e, Size);

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (_roomMouseClicked != null)
                {
                    if (_roomsToMove != null)
                    {
                        _editor.UndoManager.PushRoomsMoved(_roomsToMove.ToList(), _overallDelta);
                        _roomsToMove = null;
                    }

                    _roomMouseClicked = null;
                    Invalidate();
                }
                break;

            case MouseButtons.Right:
                var distance = new Vector2(_startMousePosition.X, _startMousePosition.Y) - new Vector2(e.Location.X, e.Location.Y);
                if (distance.Length() < 4.0f)
                {
                    _currentContextMenu?.Dispose();
                    Vector2 clickPos = FromVisualCoord(e.Location);
                    if (_editor.SelectedRooms.Contains(DoPicking(clickPos)))
                    {
                        _currentContextMenu = new SelectedRoomContextMenu(_editor, this, clickPos);
                    }
                    else
                    {
                        _currentContextMenu = new Space2DMapContextMenu(_editor, this, clickPos);
                    }
                    _currentContextMenu.Show(PointToScreen(e.Location));
                }

                _viewMoveMouseWorldCoord = null;
                break;
            }
            _currentlyEditedDepthProbeIndex = null;
            _roomMouseClicked = null;
            _roomsToMove      = null;

            if (_selectionArea != null)
            { // Change room selection
                _editor.SelectRoomsAndResetCamera(_selectionArea.GetRoomSelection(this));
                _selectionArea = null;
                Invalidate();
            }
        }
Exemple #13
0
 void Update()
 {
     if (gameObject != null)
     {
         GameObject.Destroy(gameObject);
     }
     if (Input.GetMouseButtonDown(0))
     {
         start = MouseToWorld(Input.mousePosition);
     }
     if (Input.GetMouseButton(0))
     {
         gameObject = new GameObject("Selection @ " + Mathf.RoundToInt(start.Value.x) + ", " + Mathf.RoundToInt(start.Value.z));
         if (start.HasValue)
         {
             Vector3?end = MouseToWorld(Input.mousePosition);
             if (end.HasValue)
             {
                 // loop through all stuff between two oints on same height
                 SelectionArea selectionArea = new SelectionArea(start.Value.x, start.Value.z, end.Value.x, end.Value.z);
                 for (int x = selectionArea.startX; x <= selectionArea.endX; x++)
                 {
                     for (int z = selectionArea.startZ; z <= selectionArea.endZ; z++)
                     {
                         // for debugging visual
                         GameObject o = (GameObject)Instantiate(selection, new Vector3(x, Mathf.Floor(start.Value.y), z), Quaternion.identity);
                         o.transform.parent = gameObject.transform;
                     }
                 }
             }
         }
     }
     if (Input.GetMouseButtonUp(0))
     {
         Vector3?end = MouseToWorld(Input.mousePosition);
         if (end.HasValue)
         {
             SelectionArea selectionArea = new SelectionArea(start.Value.x, start.Value.z, end.Value.x, end.Value.z);
             for (int x = selectionArea.startX; x <= selectionArea.endX; x++)
             {
                 for (int z = selectionArea.startZ; z <= selectionArea.endZ; z++)
                 {
                     // TEST to see if the targets are mutable
                     //DeleteBlock (x, Mathf.FloorToInt (start.Value.y), z);
                     // enable selected status
                 }
             }
         }
         start = null;
     }
 }
    void DidSelectArea(SelectionArea area)
    {
        if (Network.isServer)
        {
            NetworkServerBuild(area.origin, area.destination);
        }
        else
        {
            // The call must be relayed through the server to preserve RPC ordering
            networkView.RPC ("NetworkServerBuild", RPCMode.Server, area.origin, area.destination);

            // Could do some prediction here, however it could be tricky manipulating the world
        }
    }
        public static SelectionArea operator +(SelectionArea a, SelectionArea b)
        {
            SelectionArea area = a;

            if (area.tickMin >= area.tickMax)
            {
                return(b);
            }

            if (area.tickMin > b.tickMin)
            {
                area.tickMin = b.tickMin;
            }

            if (area.tickMax < b.tickMax)
            {
                area.tickMax = b.tickMax;
            }

            // Extend the rect
            float xMin, xMax;

            if (area.xPos < b.xPos)
            {
                xMin = area.xPos;
            }
            else
            {
                xMin = b.xPos;
            }

            if (area.xPos + area.width > b.xPos + b.width)
            {
                xMax = area.xPos + area.width;
            }
            else
            {
                xMax = b.xPos + b.width;
            }

            area.xPos  = xMin;
            area.width = xMax - xMin;

            return(area);
        }
        protected override void OnMouseDoubleClick(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            Vector2 clickPos = FromVisualCoord(e.Location);

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (!ModifierKeys.HasFlag(Keys.Shift))
                {
                    int?currentProbeIndex = FindClosestProbe(clickPos);
                    if (currentProbeIndex.HasValue)
                    {
                        _depthBar.DepthProbes.RemoveAt(currentProbeIndex.Value);
                    }
                    else
                    {
                        _depthBar.DepthProbes.Add(new DepthBar.DepthProbe(_depthBar)
                        {
                            Position = clickPos
                        });
                    }
                    Invalidate();
                }
                break;

            case MouseButtons.Middle:
                Room clickedRoom  = DoPicking(clickPos);
                Keys modifierKeys = ModifierKeys;
                if (clickedRoom != null)
                {
                    IEnumerable <Room> connectedRooms = _editor.Level.GetConnectedRooms(clickedRoom);
                    connectedRooms = WinFormsUtils.BoolCombine(_editor.SelectedRooms, _editor.Level.GetConnectedRooms(clickedRoom), ModifierKeys);
                    connectedRooms =     // Don't use the currently clicked room because it was already processed with the previous single click.
                                     _editor.SelectedRooms.Where(room => room == clickedRoom || room == clickedRoom.AlternateOpposite)
                                     .Concat(
                        connectedRooms.Where(room => room != clickedRoom && room != clickedRoom.AlternateOpposite));
                    _editor.SelectRoomsAndResetCamera(connectedRooms);
                }
                _selectionArea = null;
                break;
            }
        }
        public static SelectionArea operator -(SelectionArea a, SelectionArea b)
        {
            SelectionArea area = a;

            if (b.xPos < area.xPos && b.xPos + b.width > area.xPos + area.width)
            {
                // Eligable to reduce the tick size
                if (area.tickMin >= b.tickMin)
                {
                    area.tickMin = b.tickMax;
                }

                if (area.tickMax <= b.tickMax)
                {
                    area.tickMax = b.tickMin;
                }

                if (area.tickMin > area.tickMax)
                {
                    area.tickMin = area.tickMax;
                }
            }

            if (b.tickMax > area.tickMax && b.tickMin < area.tickMin)
            {
                // Eligable to reduce the width
                if (area.xPos >= b.xPos)
                {
                    float originalXPos = area.xPos;
                    area.xPos   = b.xPos + b.width;
                    area.width -= area.xPos - originalXPos;
                }

                if (area.xPos + area.width <= b.xPos + b.width)
                {
                    area.width = b.xPos - area.xPos;
                }
            }

            return(area);
        }
Exemple #18
0
		void Update ()
		{
				if (gameObject != null)
						GameObject.Destroy (gameObject);
				if (Input.GetMouseButtonDown (0)) {
						start = MouseToWorld (Input.mousePosition);
				}
				if (Input.GetMouseButton (0)) {
						gameObject = new GameObject ("Selection @ " + Mathf.RoundToInt (start.Value.x) + ", " + Mathf.RoundToInt (start.Value.z));
						if (start.HasValue) {
								Vector3? end = MouseToWorld (Input.mousePosition);
								if (end.HasValue) {
										// loop through all stuff between two oints on same height
										SelectionArea selectionArea = new SelectionArea (start.Value.x, start.Value.z, end.Value.x, end.Value.z);
										for (int x = selectionArea.startX; x <= selectionArea.endX; x++) {
												for (int z = selectionArea.startZ; z <= selectionArea.endZ; z++) {
														// for debugging visual
														GameObject o = (GameObject)Instantiate (selection, new Vector3 (x, Mathf.Floor (start.Value.y), z), Quaternion.identity);
														o.transform.parent = gameObject.transform;
												}
										}
								}
						}
				}
				if (Input.GetMouseButtonUp (0)) {

						Vector3? end = MouseToWorld (Input.mousePosition);
						if (end.HasValue) {
								SelectionArea selectionArea = new SelectionArea (start.Value.x, start.Value.z, end.Value.x, end.Value.z);
								for (int x = selectionArea.startX; x <= selectionArea.endX; x++) {
										for (int z = selectionArea.startZ; z <= selectionArea.endZ; z++) {
												// TEST to see if the targets are mutable
												//DeleteBlock (x, Mathf.FloorToInt (start.Value.y), z);
												// enable selected status
										}
								}
						}
						start = null;
				}
		}
        public CutNotesOperation(Model model, SelectionArea selectionArea)
        {
            if (model == null || selectionArea == null)
            {
                Logger.Error("引数にnullのものが含まれるため、操作を行えません。", true);
                Canceled = true;
                return;
            }

            var tmpArea = new SelectionArea(selectionArea);
            var clearOp = new ClearAreaNotesOperation(model, selectionArea);

            Invoke += () =>
            {
                new CopyNotesOperation(tmpArea).Invoke();
                clearOp.Invoke();
            };
            Undo += () =>
            {
                clearOp.Undo();
            };
        }
        public PasteNotesOperation(Model model, SelectionArea selectionArea, Position position)
        {
            if (model == null || selectionArea == null || position == null)
            {
                Logger.Error("引数にnullのものが存在するため、操作を行えません。", true);
                Canceled = true;
                return;
            }

            var           book    = model.NoteBook;
            SelectionArea tmpArea = null;

            if (Clipboard.GetDataObject().GetData(typeof(SelectionArea)) is SelectionArea data)
            {
                tmpArea = data;
            }
            else
            {
                Logger.Error("クリップボードにデータが無かったため操作を行えません。");
                Canceled = true;
                return;
            }

            tmpArea.Relocate(position, model.LaneBook);

            Invoke += () =>
            {
                selectionArea.Reset(tmpArea);
                book.PutRange(tmpArea.SelectedNoteList);
                book.PutRange(tmpArea.SelectedLongNoteList);
            };
            Undo += () =>
            {
                selectionArea.Reset();
                book.UnPutRange(tmpArea.SelectedNoteList);
                book.UnPutRange(tmpArea.SelectedLongNoteList);
            };
        }
Exemple #21
0
 void HandleSelection(SelectionArea area)
 {
     if (gameObject.transform.position.x >= area.startvector.x && gameObject.transform.position.x <= area.endvector.x && gameObject.transform.position.y >= area.startvector.y && gameObject.transform.position.y <= area.endvector.y)
     {
         Debug.LogWarning("Handling selection on mob");
         transform.Find("Selector").gameObject.SetActive(true);
     } else
     {
         transform.Find("Selector").gameObject.SetActive(false);
     }
 }
Exemple #22
0
 void DidSelectArea(SelectionArea area)
 {
     Build(area.origin, area.destination);
 }
        protected override void OnMouseDown(MouseEventArgs e)
        {
            base.OnMouseDown(e);

            var clickPos = FromVisualCoord(e.Location);

            if (!_depthBar.MouseDown(e, Size, clickPos))
            {
                return;
            }

            _lastMousePosition = e.Location;

            //https://stackoverflow.com/questions/14191219/receive-mouse-move-even-cursor-is-outside-control
            Capture = true; // Capture mouse for zoom and panning

            switch (e.Button)
            {
            case MouseButtons.Left:
                // Check for depth probe
                int?currentProbeIndex = FindClosestProbe(clickPos);

                if (ModifierKeys.HasFlag(Keys.Alt))
                {
                    if (currentProbeIndex.HasValue)
                    {
                        // Remove depth probe closest to mouse pointer
                        _depthBar.DepthProbes.RemoveAt(currentProbeIndex.Value);
                    }
                    else
                    {
                        // Add depth probe under mouse pointer
                        _currentlyEditedDepthProbeIndex = _depthBar.DepthProbes.Count;
                        _depthBar.DepthProbes.Add(new DepthBar.DepthProbe(_depthBar)
                        {
                            Position = clickPos
                        });
                    }
                    Invalidate();
                }
                else if (currentProbeIndex.HasValue)
                {
                    // Depth probe normally selected
                    _currentlyEditedDepthProbeIndex = FindClosestProbe(clickPos);
                }
                else
                {
                    _overallDelta     = VectorInt3.Zero;
                    _roomMouseClicked = DoPicking(clickPos);
                    if (_roomMouseClicked == null)
                    {
                        _editor.SelectedRooms = new[] { _editor.SelectedRoom };
                        _selectionArea        = new SelectionArea {
                            _area = new Rectangle2(clickPos, clickPos)
                        };
                    }
                    else
                    {
                        if (ModifierKeys != Keys.None || !_editor.SelectedRooms.Contains(_roomMouseClicked))
                        {
                            _editor.SelectRoomsAndResetCamera(WinFormsUtils.BoolCombine(_editor.SelectedRooms,
                                                                                        new[] { _roomMouseClicked }, ModifierKeys));
                        }
                        _roomMouseOffset = clickPos - _roomMouseClicked.SectorPos;
                    }
                }
                break;

            case MouseButtons.Right:
                _startMousePosition = e.Location;

                // Move view with mouse cursor
                // Mouse cursor is a fixed point
                _viewMoveMouseWorldCoord = clickPos;
                break;

            case MouseButtons.Middle:
                _selectionArea = new SelectionArea {
                    _area = new Rectangle2(clickPos, clickPos)
                };
                break;

            case MouseButtons.XButton1:
                // Remove depth probe closest to mouse pointer
                currentProbeIndex = FindClosestProbe(clickPos);
                if (currentProbeIndex.HasValue)
                {
                    _depthBar.DepthProbes.RemoveAt(currentProbeIndex.Value);
                    Invalidate();
                }
                break;

            case MouseButtons.XButton2:
                // Add depth probe under mouse pointer
                _currentlyEditedDepthProbeIndex = _depthBar.DepthProbes.Count;
                _depthBar.DepthProbes.Add(new DepthBar.DepthProbe(_depthBar)
                {
                    Position = clickPos
                });
                Invalidate();
                break;
            }
        }
 void DidSelectArea(SelectionArea area)
 {
     Scaffolding scaffolding = CreateScaffolding(area.origin, area.destination, playerBlockType);
     TrackScaffolding(scaffolding);
     BuildNext();
 }
 public void SetData(SongObject[] data, SelectionArea area, Song song)
 {
     this.data = data;
     SetCollisionArea(area, song);
 }
Exemple #26
0
        public void SetTileXY(ref int x, ref int y, ref TilePicker tile, ref SelectionArea selection)
        {
            if (selection.IsValid(new PointInt32(x, y)))
            {
                Tile curTile = this.Tiles[x, y];

                if (tile.Tile.IsActive)
                {
                    if (!tile.TileMask.IsActive || (curTile.Type == tile.TileMask.Value && curTile.IsActive))
                    {
                        if (tile.IsEraser)
                        {
                            curTile.IsActive = false;
                        }
                        else
                        {
                            //TODO: i don't like redundant conditionals, but its a fix
                            if (!tile.TileMask.IsActive)
                            {
                                curTile.IsActive = true;
                            }

                            curTile.Type = tile.Tile.Value;

                            // if the tile is solid and there isn't a mask, remove the liquid
                            if (!tile.TileMask.IsActive && WorldSettings.Tiles[curTile.Type].IsSolid && curTile.Liquid > 0)
                            {
                                curTile.Liquid = 0;
                            }
                        }
                    }
                }


                if (tile.Wall.IsActive)
                {
                    if (!tile.WallMask.IsActive || (curTile.Wall == tile.WallMask.Value))
                    {
                        if (tile.IsEraser)
                        {
                            curTile.Wall = 0;
                        }
                        else
                        {
                            curTile.Wall = tile.Wall.Value;
                        }
                    }
                }

                if (tile.Liquid.IsActive && (!curTile.IsActive || !WorldSettings.Tiles[curTile.Type].IsSolid))
                {
                    if (tile.IsEraser)
                    {
                        curTile.Liquid = 0;
                        curTile.IsLava = false;
                    }
                    else
                    {
                        curTile.Liquid = 255;
                        curTile.IsLava = tile.Liquid.IsLava;
                    }
                }
            }
        }