예제 #1
0
        public virtual void PaintToHDC(IntPtr hDC, RoomEditorState state)
        {
            _objectBaselines.Clear();
            foreach (RoomObject obj in _room.Objects)
            {
                if (obj.Baseline <= 0)
                {
                    obj.EffectiveBaseline = obj.StartY;
                }
                else
                {
                    obj.EffectiveBaseline = obj.Baseline;
                }
                _objectBaselines.Add(obj);
            }
            _objectBaselines.Sort();

            foreach (RoomObject obj in _objectBaselines)
            {
                if (!VisibleItems.Contains(GetUniqueName(obj)))
                {
                    continue;
                }
                int height = GetSpriteHeightForGameResolution(obj.Image);
                int ypos   = AdjustYCoordinateForWindowScroll(obj.StartY, state) - (height * state.ScaleFactor);
                Factory.NativeProxy.DrawSpriteToBuffer(obj.Image, AdjustXCoordinateForWindowScroll(obj.StartX, state), ypos, state.ScaleFactor);
            }
        }
예제 #2
0
        private Character GetCharacter(int x, int y, RoomEditorState state)
        {
            foreach (Character character in _game.RootCharacterFolder.AllItemsFlat)
            {
                if (_room.Number != character.StartingRoom)
                {
                    continue;
                }

                if (!VisibleItems.Contains(character.ScriptName) || LockedItems.Contains(character.ScriptName))
                {
                    continue;
                }

                AgsView view = _game.FindViewByID(character.NormalView);

                if (view != null && view.Loops.Count > 0)
                {
                    if (HitTest(x, y, character, view))
                    {
                        return(character);
                    }
                }
            }
            return(null);
        }
예제 #3
0
        public virtual void Paint(Graphics graphics, RoomEditorState state)
        {
            if ((_mouseDown) && (_drawMode == AreaDrawMode.Line))
            {
                int penWidth    = (int)GetScaleFactor(state);
                int extraOffset = penWidth / 2;
                Pen pen         = GetPenForArea(_drawingWithArea);
                pen = new Pen(pen.Color, penWidth);
                graphics.DrawLine(pen, state.RoomXToWindow(_mouseDownX) + extraOffset,
                                  state.RoomYToWindow(_mouseDownY) + extraOffset,
                                  state.RoomXToWindow(_currentMouseX) + extraOffset,
                                  state.RoomYToWindow(_currentMouseY) + extraOffset);
                pen.Dispose();
            }
            else if ((_mouseDown) && (_drawMode == AreaDrawMode.Rectangle))
            {
                int mousePressedAtX = state.RoomXToWindow(_mouseDownX);
                int mousePressedAtY = state.RoomYToWindow(_mouseDownY);
                int mouseNowAtX     = state.RoomXToWindow(_currentMouseX);
                int mouseNowAtY     = state.RoomYToWindow(_currentMouseY);
                EnsureSmallestNumberIsFirst(ref mousePressedAtX, ref mouseNowAtX);
                EnsureSmallestNumberIsFirst(ref mousePressedAtY, ref mouseNowAtY);
                mouseNowAtX += (int)GetScaleFactor(state) - 1;
                mouseNowAtY += (int)GetScaleFactor(state) - 1;

                graphics.FillRectangle(GetBrushForArea(_drawingWithArea), mousePressedAtX, mousePressedAtY, mouseNowAtX - mousePressedAtX + 1, mouseNowAtY - mousePressedAtY + 1);
            }
        }
예제 #4
0
        public override bool MouseMove(int x, int y, RoomEditorState state)
        {
            if (_draggingBaseline)
            {
                int newBaseline = (y + state.ScrollOffsetY) / state.ScaleFactor;
                if (newBaseline < 0)
                {
                    newBaseline = 0;
                }
                if (newBaseline >= _room.Height)
                {
                    newBaseline = _room.Height - 1;
                }
                _room.WalkBehinds[_selectedArea].Baseline = newBaseline;
                _room.Modified      = true;
                state.CurrentCursor = Cursors.HSplit;
                return(true);
            }

            if (base.MouseMove(x, y, state))
            {
                return(true);
            }

            if (IsCursorOnHorizontalEdge(y, GetCurrentAreaBaselineScreenY(state), state))
            {
                state.CurrentCursor = Cursors.HSplit;
            }

            return(false);
        }
예제 #5
0
        public virtual bool MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int        x   = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            int        y   = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;
            RoomObject obj = GetObject(x, y);

            if (obj != null)
            {
                SetSelectedObject(obj);
                Factory.GUIController.SetPropertyGridObject(obj);
                if (e.Button == MouseButtons.Right)
                {
                    ShowContextMenu(e, state);
                }
                else
                if (!obj.Locked)
                {
                    _movingObjectWithMouse = true;
                    _mouseOffsetX          = x - obj.StartX;
                    _mouseOffsetY          = y - obj.StartY;
                }
            }
            if (_selectedObject == null)
            {
                if (e.Button == MouseButtons.Right)
                {
                    ShowContextMenu(e, state);
                    return(true);
                }
                return(false);
            }
            return(true);
        }
예제 #6
0
        public bool MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            if (e.Button == MouseButtons.Middle)
            {
                return(false);
            }

            int       xClick    = state.WindowXToRoom(e.X);
            int       yClick    = state.WindowYToRoom(e.Y);
            Character character = GetCharacter(xClick, yClick, state);

            if (character != null)
            {
                SelectCharacter(character, xClick, yClick, state);
            }
            else
            {
                _selectedCharacter = null;
            }

            if (_selectedCharacter != null)
            {
                Factory.GUIController.SetPropertyGridObject(_selectedCharacter);
                return(true);
            }
            return(false);
        }
예제 #7
0
        public bool MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            if (e.Button == MouseButtons.Middle)
            {
                return(false);
            }

            _mouseDown = true;
            int x = state.WindowXToRoom(e.X);
            int y = state.WindowYToRoom(e.Y);

            if (IsCursorOnVerticalEdge(x, _room.LeftEdgeX, SelectedEdge.Left) && SetSelectedEdge(SelectedEdge.Left))
            {
            }
            else if (IsCursorOnVerticalEdge(x, _room.RightEdgeX, SelectedEdge.Right) && SetSelectedEdge(SelectedEdge.Right))
            {
            }
            else if (IsCursorOnHorizontalEdge(y, _room.TopEdgeY, SelectedEdge.Top) && SetSelectedEdge(SelectedEdge.Top))
            {
            }
            else if (IsCursorOnHorizontalEdge(y, _room.BottomEdgeY, SelectedEdge.Bottom) && SetSelectedEdge(SelectedEdge.Bottom))
            {
            }
            else
            {
                _selectedEdge = SelectedEdge.None;
            }

            _lastSelectedEdge = _selectedEdge;
            return(_selectedEdge != SelectedEdge.None);
        }
예제 #8
0
        public virtual void PaintToHDC(IntPtr hDC, RoomEditorState state)
        {
            _objectBaselines.Clear();
            foreach (RoomObject obj in _room.Objects)
            {
                if (obj.Baseline <= 0)
                {
                    obj.EffectiveBaseline = obj.StartY;
                }
                else
                {
                    obj.EffectiveBaseline = obj.Baseline;
                }
                _objectBaselines.Add(obj);
            }
            _objectBaselines.Sort();

            foreach (RoomObject obj in _objectBaselines)
            {
                int height = GetSpriteHeightForGameResolution(obj.Image);
                int ypos = AdjustYCoordinateForWindowScroll(obj.StartY, state) - (height * state.ScaleFactor);
				Factory.NativeProxy.DrawSpriteToBuffer(obj.Image, AdjustXCoordinateForWindowScroll(obj.StartX, state), ypos, state.ScaleFactor);
            }
            
        }
예제 #9
0
        public virtual bool MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int        x   = state.WindowXToRoom(e.X);
            int        y   = state.WindowYToRoom(e.Y);
            RoomObject obj = GetObject(x, y);

            if (obj != null)
            {
                SetSelectedObject(obj);
                Factory.GUIController.SetPropertyGridObject(obj);
                if (e.Button == MouseButtons.Right)
                {
                    ShowContextMenu(e, state);
                }
                else if (!DesignItems[GetItemID(obj)].Locked)
                {
                    _movingObjectWithMouse = true;
                    _mouseOffsetX          = x - obj.StartX;
                    _mouseOffsetY          = y - obj.StartY;
                }
            }
            if (_selectedObject == null)
            {
                if (e.Button == MouseButtons.Right)
                {
                    ShowContextMenu(e, state);
                    return(true);
                }
                return(false);
            }
            return(true);
        }
예제 #10
0
        public virtual bool MouseMove(int x, int y, RoomEditorState state)
        {
            int realX = (x + state.ScrollOffsetX) / state.ScaleFactor;
            int realY = (y + state.ScrollOffsetY) / state.ScaleFactor;

            if ((_movingObject) && (realY < _room.Height) &&
                (realX < _room.Width) && (realY >= 0) && (realX >= 0))
            {
                if (_selectedObject == null)
                {
                    _movingObject = false;
                }
                else
                {
                    int newX = realX - _mouseOffsetX;
                    int newY = realY - _mouseOffsetY;
                    if ((newX != _selectedObject.StartX) ||
                        (newY != _selectedObject.StartY))
                    {
                        _selectedObject.StartX = SetObjectCoordinate(newX);
                        _selectedObject.StartY = SetObjectCoordinate(newY);
                        _room.Modified         = true;
                    }
                }
                return(true);
            }
            return(false);
        }
예제 #11
0
        public void MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int xClick = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            int yClick = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            _selectedCharacter = null;

            foreach (Character character in _game.RootCharacterFolder.AllItemsFlat)
            {
                if (_room.Number == character.StartingRoom)
                {
                    AgsView view = _game.FindViewByID(character.NormalView);

                    if (view != null && view.Loops.Count > 0)
                    {
                        SelectCharacter(view, character, xClick, yClick, state);
                    }
                }
            }

            if (_selectedCharacter != null)
            {
                Factory.GUIController.SetPropertyGridObject(_selectedCharacter);
            }
            else
            {
                Factory.GUIController.SetPropertyGridObject(_room);
            }
        }
예제 #12
0
        public override bool MouseUp(MouseEventArgs e, RoomEditorState state)
        {
            if (_draggingBaseline)
            {
                _draggingBaseline = false;
                return(true);
            }
            else if (!IsFilterOn())
            {
                return(base.MouseUp(e, state));
            }
            else
            {
                bool handledMouseUp = base.MouseUp(e, state);

                if ((_room.WalkBehinds[SelectedArea].Baseline < 1) &&
                    (!_shownTooltip))
                {
                    _tooltip.Show("After painting the area, remember to set its baseline by dragging the line down from the top of the background.", _panel, e.X, e.Y - 70, 5000);
                    _shownTooltip = true;
                    return(true);
                }

                return(handledMouseUp);
            }
        }
예제 #13
0
        private void DrawCharacter(Character character, RoomEditorState state)
        {
            AgsView view = _game.FindViewByID(character.NormalView);

            if (view != null && view.Loops.Count > 0)
            {
                int spriteNum = 0;

                //this is a check to make certain that loop 0 frame 0 of the character normalview has an image;
                //if not, it defaults to using spriteNum 0
                if (view.Loops[0].Frames.Count > 0)
                {
                    ViewFrame thisFrame = view.Loops[0].Frames[0];
                    spriteNum = thisFrame.Image;
                }
                int xPos = state.RoomXToWindow(character.StartX);
                int yPos = state.RoomYToWindow(character.StartY);
                int spriteWidth, spriteHeight;
                Utilities.GetSizeSpriteWillBeRenderedInGame(spriteNum, out spriteWidth, out spriteHeight);
                spriteWidth  = state.RoomSizeToWindow(spriteWidth);
                spriteHeight = state.RoomSizeToWindow(spriteHeight);

                Factory.NativeProxy.DrawSpriteToBuffer(spriteNum, xPos - spriteWidth / 2, yPos - spriteHeight, state.Scale);
            }
        }
예제 #14
0
        private void DrawCharacter(Character character, RoomEditorState state)
        {
            AgsView view = _game.FindViewByID(character.NormalView);

            if (view != null && view.Loops.Count > 0)
            {
                int scale = state.ScaleFactor;

                int spriteNum = 0;

                //this is a check to make certain that loop 0 frame 0 of the character normalview has an image;
                //if not, it defaults to using spriteNum 0
                if (view.Loops[0].Frames.Count > 0)
                {
                    ViewFrame thisFrame = view.Loops[0].Frames[0];
                    spriteNum = thisFrame.Image;
                }
                int xPos         = AdjustXCoordinateForWindowScroll(character.StartX, state); // character.StartX* scale;
                int yPos         = AdjustYCoordinateForWindowScroll(character.StartY, state); // character.StartY* scale;
                int spriteWidth  = GetSpriteWidthForGameResolution(spriteNum) * scale;        // Factory.NativeProxy.GetRelativeSpriteWidth(spriteNum) * scale;
                int spriteHeight = GetSpriteHeightForGameResolution(spriteNum) * scale;       // Factory.NativeProxy.GetRelativeSpriteHeight(spriteNum) * scale;

                Factory.NativeProxy.DrawSpriteToBuffer(spriteNum, xPos - spriteWidth / 2, yPos - spriteHeight, scale);
            }
        }
예제 #15
0
        private Character GetCharacter(int x, int y, RoomEditorState state)
        {
            foreach (Character character in _game.RootCharacterFolder.AllItemsFlat)
            {
                DesignTimeProperties p;
                if (!DesignItems.TryGetValue(GetItemID(character), out p))
                {
                    continue; // character is not in the room
                }
                if (!p.Visible || p.Locked)
                {
                    continue;
                }

                AgsView view = _game.FindViewByID(character.NormalView);

                if (view != null && view.Loops.Count > 0)
                {
                    if (HitTest(x, y, character, view))
                    {
                        return(character);
                    }
                }
            }
            return(null);
        }
예제 #16
0
        public virtual void Paint(Graphics graphics, RoomEditorState state)
        {
            if (_selectedObject != null)
            {
                int width  = GetSpriteWidthForGameResolution(_selectedObject.Image);
                int height = GetSpriteHeightForGameResolution(_selectedObject.Image);
                int xPos   = AdjustXCoordinateForWindowScroll(_selectedObject.StartX, state);
                int yPos   = AdjustYCoordinateForWindowScroll(_selectedObject.StartY, state) - (height * state.ScaleFactor);
                Pen pen    = new Pen(Color.Goldenrod);
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                graphics.DrawRectangle(pen, xPos, yPos, width * state.ScaleFactor, height * state.ScaleFactor);

                if (_movingObjectWithMouse)
                {
                    System.Drawing.Font font = new System.Drawing.Font("Arial", 10.0f);
                    string toDraw            = String.Format("X:{0}, Y:{1}", _selectedObject.StartX, _selectedObject.StartY);

                    int scaledx = xPos + (width * state.ScaleFactor / 2) - ((int)graphics.MeasureString(toDraw, font).Width / 2);
                    int scaledy = yPos - (int)graphics.MeasureString(toDraw, font).Height;
                    if (scaledx < 0)
                    {
                        scaledx = 0;
                    }
                    if (scaledy < 0)
                    {
                        scaledy = 0;
                    }

                    graphics.DrawString(toDraw, font, pen.Brush, (float)scaledx, (float)scaledy);
                }
            }
        }
예제 #17
0
        public virtual bool MouseMove(int x, int y, RoomEditorState state)
        {
            _currentMouseX = ScreenToGameX(x, state);
            _currentMouseY = ScreenToGameY(y, state);

            if (_drawMode == AreaDrawMode.Select)
            {
                state.CurrentCursor = _selectCursor;
            }
            else
            {
                state.CurrentCursor = Cursors.Cross;
            }

            if (_mouseDown)
            {
                if (_drawMode == AreaDrawMode.Freehand)
                {
                    Factory.NativeProxy.DrawLineOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea);
                    _mouseDownX = _currentMouseX;
                    _mouseDownY = _currentMouseY;
                    UpdateUndoButtonEnabledState();
                }

                return(true);
            }

            return(false);
        }
예제 #18
0
        public override bool MouseMove(int x, int y, RoomEditorState state)
        {
            if (_draggingBaseline)
            {
                int newBaseline = (y + state.ScrollOffsetY) / state.ScaleFactor;
                if (newBaseline < 0)
                {
                    newBaseline = 0;
                }
                if (newBaseline >= _room.Height)
                {
                    newBaseline = _room.Height - 1;
                }
                _room.WalkBehinds[_selectedArea].Baseline = newBaseline;
                _room.Modified = true;
                state.CurrentCursor = Cursors.HSplit;
                return true;
            }

            if (base.MouseMove(x, y, state))
            {
                return true;
            }

            if (IsCursorOnHorizontalEdge(y, GetCurrentAreaBaselineScreenY(state), state))
            {
                state.CurrentCursor = Cursors.HSplit;
            }

            return false;
        }
예제 #19
0
 public void MouseUp(MouseEventArgs e, RoomEditorState state)
 {
     if (e.Button == MouseButtons.Middle)
     {
         ShowCoordMenu(e, state);
     }
 }
예제 #20
0
        private void SelectCharacter(AgsView view, Character character, int xClick, int yClick, RoomEditorState state)
        {
            int spriteNum = 0;

            if (view.Loops[0].Frames.Count > 0)
            {
                ViewFrame thisFrame = view.Loops[0].Frames[0];
                spriteNum = thisFrame.Image;
            }

            int width = GetSpriteWidthForGameResolution(spriteNum);
            int height = GetSpriteHeightForGameResolution(spriteNum);

            if ((xClick >= character.StartX - (width / 2)) && (xClick < character.StartX + (width / 2)) &&
                (yClick >= character.StartY - height) && (yClick < character.StartY))
            {
                if (!state.DragFromCenter)
                {
                    _mouseOffsetX = xClick - character.StartX;
                    _mouseOffsetY = yClick - character.StartY;
                }
                else
                {
                    _mouseOffsetX = 0;
                    _mouseOffsetY = 0;
                }
                _selectedCharacter = character;
                _movingCharacterWithMouse = true;
            }
        }
예제 #21
0
        public virtual void PaintToHDC(IntPtr hDC, RoomEditorState state)
        {
            _objectBaselines.Clear();
            foreach (RoomObject obj in _room.Objects)
            {
                if (obj.Baseline <= 0)
                {
                    obj.EffectiveBaseline = obj.StartY;
                }
                else
                {
                    obj.EffectiveBaseline = obj.Baseline;
                }
                _objectBaselines.Add(obj);
            }
            _objectBaselines.Sort();

            foreach (RoomObject obj in _objectBaselines)
            {
                if (!DesignItems[GetItemID(obj)].Visible)
                {
                    continue;
                }
                int width, height;
                Utilities.GetSizeSpriteWillBeRenderedInGame(obj.Image, out width, out height);
                int ypos = state.RoomYToWindow(obj.StartY - height);
                Factory.NativeProxy.DrawSpriteToBuffer(obj.Image, state.RoomXToWindow(obj.StartX), ypos, state.Scale);
            }
        }
예제 #22
0
        public void MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int xClick = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            int yClick = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            _selectedCharacter = null;

            foreach (Character character in _game.Characters)
            {
                if (_room.Number == character.StartingRoom)
                {
                    AgsView view = _game.FindViewByID(character.NormalView);

                    if (view != null && view.Loops.Count > 0)
                    {
                        SelectCharacter(view, character, xClick, yClick, state);
                    }
                }
            }

            if (_selectedCharacter != null)
            {
                Factory.GUIController.SetPropertyGridObject(_selectedCharacter);
            }
            else
            {
                Factory.GUIController.SetPropertyGridObject(_room);
            }
        }
예제 #23
0
        public void MouseUp(MouseEventArgs e, RoomEditorState state)
        {
			if (e.Button == MouseButtons.Middle)
			{
				ShowCoordMenu(e, state);
			}
        }
예제 #24
0
        public virtual bool MouseUp(MouseEventArgs e, RoomEditorState state)
        {
            _mouseDown = false;
            AreaDrawMode drawMode = Enabled ? _drawMode : AreaDrawMode.Select;

            if (IsLocked(_selectedArea) && drawMode != AreaDrawMode.Select)
            {
                return(false);
            }

            if (_shouldSetDrawModeOnMouseUp)
            {
                _shouldSetDrawModeOnMouseUp = false;
                SetDrawMode();
            }
            else if (drawMode == AreaDrawMode.Line)
            {
                Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw);
                Factory.NativeProxy.DrawLineOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea);
                _panel.Invalidate();
                UpdateUndoButtonEnabledState();
            }
            else if (drawMode == AreaDrawMode.Rectangle)
            {
                Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw);
                Factory.NativeProxy.DrawFilledRectOntoMask(_room, this.MaskToDraw, _mouseDownX, _mouseDownY, _currentMouseX, _currentMouseY, _drawingWithArea);
                _panel.Invalidate();
                UpdateUndoButtonEnabledState();
            }
            else
            {
                return(false);
            }
            return(true);
        }
예제 #25
0
        public void Paint(Graphics graphics, RoomEditorState state)
        {
            Pen pen = new Pen(Color.Goldenrod);

            pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;

            if (_selectedCharacter != null)
            {
                Rectangle rect = GetCharacterRect(_selectedCharacter, state);
                graphics.DrawRectangle(pen, rect);

                if (_movingCharacterWithMouse)
                {
                    System.Drawing.Font font = new System.Drawing.Font("Arial", 10.0f);
                    string toDraw            = String.Format("X:{0}, Y:{1}", _selectedCharacter.StartX, _selectedCharacter.StartY);

                    int scaledx = rect.X + (rect.Width / 2) - ((int)graphics.MeasureString(toDraw, font).Width / 2);
                    int scaledy = rect.Y - (int)graphics.MeasureString(toDraw, font).Height;
                    if (scaledx < 0)
                    {
                        scaledx = 0;
                    }
                    if (scaledy < 0)
                    {
                        scaledy = 0;
                    }

                    graphics.DrawString(toDraw, font, pen.Brush, scaledx, scaledy);
                }
            }
        }
예제 #26
0
        public void MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int x = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            int y = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            if (IsCursorOnVerticalEdge(x, _room.LeftEdgeX))
            {
                _selectedEdge = SelectedEdge.Left;
            }
            else if (IsCursorOnVerticalEdge(x, _room.RightEdgeX))
            {
                _selectedEdge = SelectedEdge.Right;
            }
            else if (IsCursorOnHorizontalEdge(y, _room.TopEdgeY))
            {
                _selectedEdge = SelectedEdge.Top;
            }
            else if (IsCursorOnHorizontalEdge(y, _room.BottomEdgeY))
            {
                _selectedEdge = SelectedEdge.Bottom;
            }
            else
            {
                _selectedEdge = SelectedEdge.None;
            }
        }
예제 #27
0
        public override bool MouseMove(int x, int y, RoomEditorState state)
        {
            if (_draggingBaseline)
            {
                int newBaseline = (y + state.ScrollOffsetY) / state.ScaleFactor;
                if (newBaseline < 0)
                {
                    newBaseline = 0;
                }
                if (newBaseline >= _room.Height)
                {
                    newBaseline = _room.Height - 1;
                }
                _room.WalkBehinds[SelectedArea].Baseline = newBaseline;
                _room.Modified = true;
                return(true);
            }

            if (base.MouseMove(x, y, state))
            {
                return(true);
            }

            return(false);
        }
예제 #28
0
        public bool MouseMove(int x, int y, RoomEditorState state)
        {
            x += state.ScrollOffsetX;
            y += state.ScrollOffsetY;
            int  scaleFactor = state.ScaleFactor;
            bool refresh     = false;

            if (_selectedEdge != SelectedEdge.None)
            {
                MoveEdgeWithMouse(x / scaleFactor, y / scaleFactor);
                _room.Modified = true;
                refresh        = true;
            }

            string toolTipText = null;

            if (IsCursorOnVerticalEdge(x / scaleFactor, _room.LeftEdgeX))
            {
                state.CurrentCursor = Cursors.VSplit;
                toolTipText         = "Left edge";
            }
            else if (IsCursorOnVerticalEdge(x / scaleFactor, _room.RightEdgeX))
            {
                state.CurrentCursor = Cursors.VSplit;
                toolTipText         = "Right edge";
            }
            else if (IsCursorOnHorizontalEdge(y / scaleFactor, _room.TopEdgeY))
            {
                state.CurrentCursor = Cursors.HSplit;
                toolTipText         = "Top edge";
            }
            else if (IsCursorOnHorizontalEdge(y / scaleFactor, _room.BottomEdgeY))
            {
                state.CurrentCursor = Cursors.HSplit;
                toolTipText         = "Bottom edge";
            }
            else
            {
                state.CurrentCursor = Cursors.Default;
            }

            if (toolTipText != null)
            {
                // Tooltip.Show is quite a slow function, so make sure it's not
                // called too often
                if ((Math.Abs(x - _tooltipX) > 5) || (Math.Abs(y - _tooltipY) > 5) ||
                    (_tooltipText != toolTipText) || (!_tooltip.Active))
                {
                    _tooltip.Show(toolTipText, _panel, (x - state.ScrollOffsetX) - 10, (y - state.ScrollOffsetY) + 5);
                    _tooltipX    = x;
                    _tooltipY    = y;
                    _tooltipText = toolTipText;
                }
            }
            else if (_tooltip.Active)
            {
                _tooltip.Hide(_panel);
            }
            return(refresh);
        }
예제 #29
0
        /// <summary>
        /// Draw hint overlay.
        /// NOTE: this is NOT drawing on actual mask, which is performed when
        /// user releases mouse button.
        /// </summary>
        public virtual void Paint(Graphics graphics, RoomEditorState state)
        {
            int roomPixel     = state.RoomSizeToWindow(1);
            int halfRoomPixel = roomPixel / 2;

            if ((_mouseDown) && (_drawMode == AreaDrawMode.Line))
            {
                int penWidth = (int)(roomPixel * GetHintScaleFactor(state));
                Pen pen      = GetPenForArea(_drawingWithArea);
                pen = new Pen(pen.Color, penWidth);
                graphics.DrawLine(pen, state.RoomXToWindow(_mouseDownX) + halfRoomPixel,
                                  state.RoomYToWindow(_mouseDownY) + halfRoomPixel,
                                  state.RoomXToWindow(_currentMouseX) + halfRoomPixel,
                                  state.RoomYToWindow(_currentMouseY) + halfRoomPixel);
                pen.Dispose();
            }
            else if ((_mouseDown) && (_drawMode == AreaDrawMode.Rectangle))
            {
                int x1 = state.RoomXToWindow(_mouseDownX);
                int y1 = state.RoomYToWindow(_mouseDownY);
                int x2 = state.RoomXToWindow(_currentMouseX);
                int y2 = state.RoomYToWindow(_currentMouseY);
                EnsureSmallestNumberIsFirst(ref x1, ref x2);
                EnsureSmallestNumberIsFirst(ref y1, ref y2);
                graphics.FillRectangle(GetBrushForArea(_drawingWithArea),
                                       x1, y1, x2 - x1 + roomPixel, y2 - y1 + roomPixel);
            }
        }
예제 #30
0
 private void SelectCursor(int x, int y, RoomEditorState state)
 {
     state.CurrentCursor = Cursors.Default;
     if (_layer != null)
     {
         state.CurrentCursor = _layer.GetCursor(x, y, state);
     }
     else
     {
         state.CurrentCursor = null;
     }
     if (state.CurrentCursor != null)
     {
         bufferedPanel1.Cursor = state.CurrentCursor;
         return;
     }
     for (int layerIndex = _layers.Count - 1; layerIndex >= 0; layerIndex--)
     {
         IRoomEditorFilter layer = _layers[layerIndex];
         if (IsLocked(layer))
         {
             continue;
         }
         Cursor tmpCursor = layer.GetCursor(x, y, state);
         if (tmpCursor != null)
         {
             state.CurrentCursor = tmpCursor;
         }
     }
     bufferedPanel1.Cursor = state.CurrentCursor ?? Cursors.Default;
 }
예제 #31
0
        public virtual bool MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            if (e.Button == MouseButtons.Middle)
            {
                return(false);
            }

            int x = state.WindowXToRoom(e.X);
            int y = state.WindowYToRoom(e.Y);

            AreaDrawMode drawMode = IsFilterOn() ? _drawMode : AreaDrawMode.Select;

            if (IsLocked(_selectedArea) && drawMode != AreaDrawMode.Select)
            {
                return(false);
            }

            if (drawMode == AreaDrawMode.Freehand)
            {
                Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw);
            }

            _drawingWithArea = _selectedArea;

            if (e.Button == MouseButtons.Right)
            {
                _drawingWithArea = 0;
            }

            if ((drawMode == AreaDrawMode.Line) ||
                (drawMode == AreaDrawMode.Freehand) ||
                (drawMode == AreaDrawMode.Rectangle))
            {
                if (_selectedArea == 0)
                {
                    _tooltip.Show("You are currently using the eraser. To draw new areas, change the selection in the list above the Properties Pane.", _panel, e.X, e.Y - 70, 2000);
                }
                _mouseDown     = true;
                _mouseDownX    = x;
                _mouseDownY    = y;
                _room.Modified = true;
            }
            else if (drawMode == AreaDrawMode.Fill)
            {
                Factory.NativeProxy.CreateUndoBuffer(_room, this.MaskToDraw);
                Factory.NativeProxy.DrawFillOntoMask(_room, this.MaskToDraw, x, y, _drawingWithArea);
                _room.Modified = true;
                UpdateUndoButtonEnabledState();
            }
            else if (drawMode == AreaDrawMode.Select)
            {
                int area = Factory.NativeProxy.GetAreaMaskPixel(_room, this.MaskToDraw, x, y);
                if (area != 0 && !IsLocked(area))
                {
                    SelectedArea = area;
                    SelectedAreaChanged(_selectedArea);
                }
            }
            return(true);
        }
예제 #32
0
 public void Paint(Graphics graphics, RoomEditorState state)
 {
     int scaleFactor = state.ScaleFactor;
     DrawDoubleWidthVerticalLine(graphics, _room.LeftEdgeX * scaleFactor - state.ScrollOffsetX, scaleFactor);
     DrawDoubleWidthVerticalLine(graphics, _room.RightEdgeX * scaleFactor - state.ScrollOffsetX, scaleFactor);
     DrawDoubleHeightHorizontalLine(graphics, _room.TopEdgeY * scaleFactor - state.ScrollOffsetY, scaleFactor);
     DrawDoubleHeightHorizontalLine(graphics, _room.BottomEdgeY * scaleFactor - state.ScrollOffsetY, scaleFactor);
 }
예제 #33
0
 public Cursor GetCursor(int x, int y, RoomEditorState state)
 {
     if (_movingObjectWithMouse) return Cursors.Hand;
     x = state.WindowXToRoom(x);
     y = state.WindowYToRoom(y);
     if (GetObject(x, y) != null) return Cursors.Default;
     return null;
 }
예제 #34
0
 public virtual Cursor GetCursor(int x, int y, RoomEditorState state)
 {
     if (_drawMode == AreaDrawMode.Select)
     {
         return(_selectCursor);
     }
     return(Cursors.Cross);
 }
예제 #35
0
 public void MouseDownAlways(MouseEventArgs e, RoomEditorState state)
 {
     if (!IsFilterOn())
     {
         DeselectArea();
         _drawingWithArea = 0;
         _drawMode        = AreaDrawMode.Select;
     }
 }
예제 #36
0
 public bool MouseUp(MouseEventArgs e, RoomEditorState state)
 {
     if (e.Button == MouseButtons.Middle)
     {
         ShowCoordMenu(e, state);
         return(true);
     }
     return(false);
 }
예제 #37
0
 public override void MouseDown(MouseEventArgs e, RoomEditorState state)
 {
     if (IsCursorOnHorizontalEdge(e.Y, GetCurrentAreaBaselineScreenY(state), state))
     {
         _draggingBaseline = true;
     }
     else
     {
         base.MouseDown(e, state);
     }
 }
예제 #38
0
 public void DoubleClick(RoomEditorState state)
 {
     if (_lastSelectedObject != null)
     {
         Sprite chosenSprite = SpriteChooser.ShowSpriteChooser(_lastSelectedObject.Image);
         if (chosenSprite != null)
         {
             _lastSelectedObject.Image = chosenSprite.Number;
         }
     }
 }
예제 #39
0
		public override void Paint(Graphics graphics, RoomEditorState state)
		{
			int lineYPos = GetCurrentAreaBaselineScreenY(state);
			Pen pen = (Pen)GetPenForArea(_selectedArea).Clone();
			pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;

			for (int i = 0; i < state.ScaleFactor; i++)
			{
				graphics.DrawLine(pen, 0, lineYPos + i, graphics.VisibleClipBounds.Right, lineYPos + i);
			}

			base.Paint(graphics, state);
		}
예제 #40
0
        public override void Paint(Graphics graphics, RoomEditorState state)
        {
            base.Paint(graphics, state);

            foreach (RoomHotspot hotspot in _room.Hotspots)
            {
                if ((hotspot.WalkToPoint.X > 0) && (hotspot.WalkToPoint.Y > 0))
                {
                    int x = (hotspot.WalkToPoint.X * state.ScaleFactor) - state.ScrollOffsetX;
                    int y = (hotspot.WalkToPoint.Y * state.ScaleFactor) - state.ScrollOffsetY;
                    graphics.DrawLine(Pens.Red, x - 4, y - 4, x + 4, y + 4);
                    graphics.DrawLine(Pens.RosyBrown, x - 4, y + 4, x + 4, y - 4);
                    graphics.DrawString(hotspot.ID.ToString(), new System.Drawing.Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold), Brushes.Gold, x + 4, y - 7);
                }
            }
        }
예제 #41
0
        public override void MouseUp(MouseEventArgs e, RoomEditorState state)
        {
            if (_draggingBaseline)
            {
                _draggingBaseline = false;
            }
            else
            {
                base.MouseUp(e, state);

                if ((_room.WalkBehinds[_selectedArea].Baseline < 1) &&
                    (!_shownTooltip))
                {
                    _tooltip.Show("After painting the area, remember to set its baseline by dragging the line down from the top of the background.", _panel, e.X, e.Y - 70, 5000);
                    _shownTooltip = true;
                }
            }
        }
예제 #42
0
		private void ShowCoordMenu(MouseEventArgs e, RoomEditorState state)
		{
			EventHandler onClick = new EventHandler(CoordMenuEventHandler);
			ContextMenuStrip menu = new ContextMenuStrip();
			menu.Items.Add(new ToolStripMenuItem("Copy mouse coordinates to clipboard", null, onClick, MENU_ITEM_COPY_COORDS));

			_menuClickX = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
			_menuClickY = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            if ((Factory.AGSEditor.CurrentGame.Settings.UseLowResCoordinatesInScript) &&
                (_room.Resolution == RoomResolution.HighRes))
            {
                _menuClickX /= 2;
                _menuClickY /= 2;
            }

			menu.Show(_panel, e.X, e.Y);
		}
 private int GameToScreenX(int gameX, RoomEditorState state)
 {
     return (gameX * state.ScaleFactor) - state.ScrollOffsetX;
 }
 private int GameToScreenY(int gameY, RoomEditorState state)
 {
     return (gameY * state.ScaleFactor) - state.ScrollOffsetY;
 }
예제 #45
0
 public void Paint(Graphics graphics, RoomEditorState state)
 {
 }
예제 #46
0
 public void MouseDown(MouseEventArgs e, RoomEditorState state)
 {
 }
예제 #47
0
        public virtual void MouseUp(MouseEventArgs e, RoomEditorState state)
        {
            _movingObjectWithMouse = false;
            _lastSelectedObject = _selectedObject;

            if (e.Button == MouseButtons.Middle)
            {
                ShowCoordMenu(e, state);
            }
        }
예제 #48
0
 public void PaintToHDC(IntPtr hDC, RoomEditorState state)
 {
 }
예제 #49
0
 public void MouseDown(MouseEventArgs e, RoomEditorState state)
 {
     int x = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
     int y = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;
     if (IsCursorOnVerticalEdge(x, _room.LeftEdgeX))
     {
         _selectedEdge = SelectedEdge.Left;
     }
     else if (IsCursorOnVerticalEdge(x, _room.RightEdgeX))
     {
         _selectedEdge = SelectedEdge.Right;
     }
     else if (IsCursorOnHorizontalEdge(y, _room.TopEdgeY))
     {
         _selectedEdge = SelectedEdge.Top;
     }
     else if (IsCursorOnHorizontalEdge(y, _room.BottomEdgeY))
     {
         _selectedEdge = SelectedEdge.Bottom;
     }
     else
     {
         _selectedEdge = SelectedEdge.None;
     }
 }
예제 #50
0
        public virtual void MouseDown(MouseEventArgs e, RoomEditorState state)
        {
            int x = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            int y = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;
            _selectedObject = null;

            for (int i = _objectBaselines.Count - 1; i >= 0; i--)
            {
                RoomObject obj = _objectBaselines[i];
                int width = GetSpriteWidthForGameResolution(obj.Image);
                int height = GetSpriteHeightForGameResolution(obj.Image);
                if ((x >= obj.StartX) && (x < obj.StartX + width) &&
                    (y >= obj.StartY - height) && (y < obj.StartY))
                {
                    _selectedObject = obj;
                    Factory.GUIController.SetPropertyGridObject(obj);
                    if (e.Button == MouseButtons.Right)
                    {
                        ShowContextMenu(e, state);
                    }
                    else
                    {
                        _movingObjectWithMouse = true;
                        _mouseOffsetX = x - obj.StartX;
                        _mouseOffsetY = y - obj.StartY;
                    }
                    break;
                }
            }
            if (_selectedObject == null)
            {
                Factory.GUIController.SetPropertyGridObject(_room);
                if (e.Button == MouseButtons.Right)
                {
                    ShowContextMenu(e, state);
                }
            }
        }
예제 #51
0
        private void ShowContextMenu(MouseEventArgs e, RoomEditorState state)
        {
            EventHandler onClick = new EventHandler(ContextMenuEventHandler);
            ContextMenuStrip menu = new ContextMenuStrip();
            if (_selectedObject != null)
            {
                menu.Items.Add(new ToolStripMenuItem("Delete", null, onClick, MENU_ITEM_DELETE));
                menu.Items.Add(new ToolStripSeparator());
            }
            menu.Items.Add(new ToolStripMenuItem("Place New Object Here", null, onClick, MENU_ITEM_NEW));
            if (_selectedObject != null)
            {
                menu.Items.Add(new ToolStripMenuItem("Copy Object Coordinates to Clipboard", null, onClick, MENU_ITEM_OBJECT_COORDS));
            }
            _menuClickX = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            _menuClickY = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            menu.Show(_panel, e.X, e.Y);
        }
예제 #52
0
 private int AdjustYCoordinateForWindowScroll(int y, RoomEditorState state)
 {
     return (y - (state.ScrollOffsetY / state.ScaleFactor)) * state.ScaleFactor;
 }
예제 #53
0
 private int AdjustXCoordinateForWindowScroll(int x, RoomEditorState state)
 {
     return (x - (state.ScrollOffsetX / state.ScaleFactor)) * state.ScaleFactor;
 }
예제 #54
0
        public virtual void Paint(Graphics graphics, RoomEditorState state)
        {
            if (_selectedObject != null)
            {
                int width = GetSpriteWidthForGameResolution(_selectedObject.Image);
                int height = GetSpriteHeightForGameResolution(_selectedObject.Image);
                int xPos = AdjustXCoordinateForWindowScroll(_selectedObject.StartX, state);
                int yPos = AdjustYCoordinateForWindowScroll(_selectedObject.StartY, state) - (height * state.ScaleFactor);
                Pen pen = new Pen(Color.Goldenrod);
                pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                graphics.DrawRectangle(pen, xPos, yPos, width * state.ScaleFactor, height * state.ScaleFactor);

                if (_movingObjectWithMouse)
                {
                    System.Drawing.Font font = new System.Drawing.Font("Arial", 10.0f);
                    string toDraw = String.Format("X:{0}, Y:{1}", _selectedObject.StartX, _selectedObject.StartY);

                    int scaledx = xPos + (width * state.ScaleFactor / 2) - ((int)graphics.MeasureString(toDraw, font).Width / 2);
                    int scaledy = yPos - (int)graphics.MeasureString(toDraw, font).Height;
                    if (scaledx < 0) scaledx = 0;
                    if (scaledy < 0) scaledy = 0;

                    graphics.DrawString(toDraw, font, pen.Brush, (float)scaledx, (float)scaledy);
                }
            }
        }
예제 #55
0
        public bool MouseMove(int x, int y, RoomEditorState state)
        {
            x += state.ScrollOffsetX;
            y += state.ScrollOffsetY;
            int scaleFactor = state.ScaleFactor;
            bool refresh = false;
            if (_selectedEdge != SelectedEdge.None)
            {
                MoveEdgeWithMouse(x / scaleFactor, y / scaleFactor);
                _room.Modified = true;
                refresh = true;
            }

            string toolTipText = null;
            if (IsCursorOnVerticalEdge(x / scaleFactor, _room.LeftEdgeX))
            {
                state.CurrentCursor = Cursors.VSplit;
                toolTipText = "Left edge";
            }
            else if (IsCursorOnVerticalEdge(x / scaleFactor, _room.RightEdgeX))
            {
                state.CurrentCursor = Cursors.VSplit;
                toolTipText = "Right edge";
            }
            else if (IsCursorOnHorizontalEdge(y / scaleFactor, _room.TopEdgeY))
            {
                state.CurrentCursor = Cursors.HSplit;
                toolTipText = "Top edge";
            }
            else if (IsCursorOnHorizontalEdge(y / scaleFactor, _room.BottomEdgeY))
            {
                state.CurrentCursor = Cursors.HSplit;
                toolTipText = "Bottom edge";
            }
            else
            {
                state.CurrentCursor = Cursors.Default;
            }

            if (toolTipText != null)
            {
                // Tooltip.Show is quite a slow function, so make sure it's not
                // called too often
                if ((Math.Abs(x - _tooltipX) > 5) || (Math.Abs(y - _tooltipY) > 5) ||
                    (_tooltipText != toolTipText) || (!_tooltip.Active))
                {
                    _tooltip.Show(toolTipText, _panel, (x - state.ScrollOffsetX) - 10, (y - state.ScrollOffsetY) + 5);
                    _tooltipX = x;
                    _tooltipY = y;
                    _tooltipText = toolTipText;
                }
            }
            else if (_tooltip.Active)
            {
                _tooltip.Hide(_panel);
            }
            return refresh;
        }
예제 #56
0
 public bool MouseMove(int x, int y, RoomEditorState state)
 {
     return false;
 }
예제 #57
0
        private void ShowCoordMenu(MouseEventArgs e, RoomEditorState state)
        {
            EventHandler onClick = new EventHandler(CoordMenuEventHandler);
            ContextMenuStrip menu = new ContextMenuStrip();
            menu.Items.Add(new ToolStripMenuItem("Copy mouse coordinates to clipboard", null, onClick, MENU_ITEM_COPY_COORDS));

            _menuClickX = (e.X + state.ScrollOffsetX) / state.ScaleFactor;
            _menuClickY = (e.Y + state.ScrollOffsetY) / state.ScaleFactor;

            menu.Show(_panel, e.X, e.Y);
        }
예제 #58
0
        public virtual bool MouseMove(int x, int y, RoomEditorState state)
        {
            if (!_movingObjectWithMouse) return false;
            int realX = (x + state.ScrollOffsetX) / state.ScaleFactor;
            int realY = (y + state.ScrollOffsetY) / state.ScaleFactor;

            if ((_movingObjectWithMouse) && (realY < _room.Height) &&
                (realX < _room.Width) && (realY >= 0) && (realX >= 0))
            {
                int newX = realX - _mouseOffsetX;
                int newY = realY - _mouseOffsetY;
                return MoveObject(newX, newY);
            }
            return false;
        }
예제 #59
0
 public void MouseUp(MouseEventArgs e, RoomEditorState state)
 {
     _selectedEdge = SelectedEdge.None;
 }
예제 #60
0
 public void DoubleClick(RoomEditorState state)
 {
 }