Exemple #1
0
 public void SetData()
 {
     pointStart    = Snap.GetSnapPoint(ToolBox.snapType, -image.Width, -image.Height);
     pointEnd      = pointStart.Offset(image.Width, image.Height);
     mode          = ImageUI.instance.ImagePositionMode;
     transmittance = ImageUI.instance.Transmittance;
     if (mode == ImagePositionMode.Screen)
     {
         pointStart -= Main.screenPosition;
     }
 }
Exemple #2
0
        public void UpdateCursor()
        {
            if (cursorShape == null || cursorSnapShape == null)
            {
                cursorShape           = new ShapeRect();
                cursorSnapShape       = new ShapeRect();
                cursorShape.width     = LinePropertyUI.instance.GetLineWidth(LinePropertyTarget.Cursor);
                cursorShape.color     = LinePropertyUI.instance.GetColor(LinePropertyTarget.Cursor);
                cursorSnapShape.width = LinePropertyUI.instance.GetLineWidth(LinePropertyTarget.CursorSnap);
                cursorSnapShape.color = LinePropertyUI.instance.GetColor(LinePropertyTarget.CursorSnap);
            }

            if (ModContent.GetInstance <TeraCADConfig>().isDrawCursor)
            {
                cursorShape.pointStart = Main.MouseWorld.ToTileCoordinates().ToVector2() * 16;
                cursorShape.pointEnd   = cursorShape.pointStart.Offset(ModUtils.tileSize, ModUtils.tileSize);
            }

            if (ModContent.GetInstance <TeraCADConfig>().isDrawCursorSnap)
            {
                cursorSnapShape.pointStart = Snap.GetSnapPoint(ToolBox.snapType).Offset(-2, -2);
                cursorSnapShape.pointEnd   = cursorSnapShape.pointStart.Offset(4, 4);
            }
        }
Exemple #3
0
        public void Update()
        {
            UpdateCursor();

            if (ToolBox.ContainsPoint(Main.MouseScreen) || Main.gameMenu)
            {
                return;
            }

            if (ToolBox.SelectedTool == ToolType.Select || ToolBox.SelectedTool == ToolType.Eraser)
            {
                UpdateSelectTool();
                return;
            }
            if (ToolBox.SelectedTool == ToolType.ParallelCopy)
            {
                UpdateSelectTool();
            }

            if (Main.mouseRight)
            {
                step  = 0;
                shape = null;
                parallelCopyTargetShape = null;
                parallelCopyShapes.Clear();
            }

            switch (step)
            {
            case 0:
                if (Main.mouseLeft)
                {
                    switch (ToolBox.SelectedTool)
                    {
                    case ToolType.Line:
                        shape            = new ShapeLine();
                        shape.pointStart = shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                        step             = 1;
                        break;

                    case ToolType.Rect:
                        shape            = new ShapeRect();
                        shape.pointStart = shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                        step             = 1;
                        break;

                    case ToolType.Circle:
                        shape            = new ShapeCircle();
                        shape.pointStart = shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                        step             = 1;
                        break;

                    case ToolType.Image:
                        if (UISlotImage.SelectedImage != null)
                        {
                            list.Add(shape.Clone());
                            step = 1;
                        }
                        break;

                    case ToolType.AllClear:
                        list.Clear();
                        break;

                    case ToolType.ParallelCopy:
                        if (0 < hoverShapes.Count)
                        {
                            parallelCopyTargetShape = hoverShapes[hoverShapes.Count - 1];
                            step = 1;
                        }
                        break;
                    }
                }
                else
                {
                    if (ToolBox.SelectedTool == ToolType.Image)
                    {
                        (shape as ShapeImage)?.SetData();
                    }
                }
                break;

            case 1:
                if (ToolBox.SelectedTool == ToolType.Image)
                {
                    if (!Main.mouseLeft)
                    {
                        step = 0;
                    }
                }
                else if (ToolBox.SelectedTool == ToolType.ParallelCopy)
                {
                    if (!Main.mouseLeft)
                    {
                        step = 2;
                    }
                }
                else
                {
                    shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                    if (!Main.mouseLeft)
                    {
                        step = 2;
                    }
                }
                break;

            case 2:
                if (ToolBox.SelectedTool == ToolType.ParallelCopy)
                {
                    ParallelCopy();
                    if (Main.mouseLeft && 0 < parallelCopyShapes.Count)
                    {
                        list.AddRange(parallelCopyShapes);
                        parallelCopyTargetShape = null;
                        parallelCopyShapes.Clear();
                        step = 3;
                    }
                }
                else
                {
                    shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                    if (Main.mouseLeft)
                    {
                        shape.pointEnd = Snap.GetSnapPoint(ToolBox.snapType);
                        list.Add(shape);
                        step = 3;
                    }
                }
                break;

            case 3:
                if (!Main.mouseLeft)
                {
                    step = 0;
                }
                break;
            }
        }