public override void DuplicateSelected()
        {
            List <EditorObject> newObjects = new List <EditorObject>();

            foreach (EditorObject obj in objectList)
            {
                if (obj.Selected)
                {
                    EditorObject copy = null;

                    if (obj is SolidObject)
                    {
                        copy = new SolidObject(this, obj, editor);
                    }
                    if (obj is EventObject)
                    {
                        copy = new EventObject(this, (obj as EventObject), editor);
                    }

                    if (copy != null)
                    {
                        newObjects.Add(copy);
                    }
                }
            }

            if (newObjects.Count > 0)
            {
                CreateObject(newObjects.ToArray());

                editor.DeselectAll();

                foreach (EditorObject obj in newObjects)
                {
                    editor.SelectAdd(obj.Vertices);
                }
            }
        }
 public SolidObject(Layer layer, EditorObject copy, Editor e)
     : base(layer, copy, e)
 {
 }
Exemple #3
0
        public void Logic()
        {
            CalculateDelta();
            UpdateEditMode();

            tilesetList.Logic();
            templateCreator.Logic();
            templateMenu.Logic();
            layerCreator.Logic();

            camera.Logic();

            CurrentManipulator.Logic();

            if (!Paused)
            {
                {
                    float mousex = MouseInput.Current.Position.X;
                    float mousey = MouseInput.Current.Position.Y;

                    mousex = (float)Math.Round(mousex);
                    mousey = (float)Math.Round(mousey);

                    Console.Clear();
                    Console.WriteLine(mousex + ", " + mousey);
                }

                if (KeyboardInput.Current[Key.LControl])
                {
                    if (KeyboardInput.KeyPressed(Key.Z))
                    {
                        Undo();
                    }

                    if (KeyboardInput.KeyPressed(Key.Y))
                    {
                        Redo();
                    }

                    if (KeyboardInput.KeyPressed(Key.D))
                    {
                        DuplicateSelected();
                    }

                    if (KeyboardInput.KeyPressed(Key.B))
                    {
                        background.LoadTexture();
                    }

                    if (KeyboardInput.KeyPressed(Key.Delete) && MessageBox.Show("Are you sure you want to delete this layer?", "Please confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        DeleteLayer(ActiveLayer);
                    }
                }
                else
                {
                    if (KeyboardInput.KeyPressed(Key.G))
                    {
                        showGrid = !showGrid;
                    }

                    if (KeyboardInput.KeyPressed(Key.B))
                    {
                        background.show = !background.show;
                    }

                    if (KeyboardInput.KeyPressed(Key.L))
                    {
                        preview = !preview;
                    }

                    if (KeyboardInput.KeyPressed(Key.H))
                    {
                        hideVertices = !hideVertices;
                    }

                    if (KeyboardInput.KeyPressed(Key.Z))
                    {
                        hideSolids = !hideSolids;
                    }

                    if (KeyboardInput.KeyPressed(Key.F1))
                    {
                        if (dataForm == null)
                        {
                            dataForm = new LevelDataForm(this);
                            dataForm.Show();
                        }
                        else
                        {
                            dataForm.Dispose();
                            dataForm = null;
                        }
                    }

                    if (KeyboardInput.KeyPressed(Key.F2))
                    {
                        List <EventObject> events = new List <EventObject>();

                        foreach (EditorObject o in ActiveObjects)
                        {
                            if ((o is EventObject) && o.Selected)
                            {
                                events.Add(o as EventObject);
                            }
                        }

                        if (events.Count > 0)
                        {
                            new EventForm(events.ToArray()).Show();
                        }
                    }

                    if (KeyboardInput.KeyPressed(Key.Delete))
                    {
                        DeleteSelected();
                    }
                }

                if (KeyboardInput.KeyPressed(Key.Minus))
                {
                    MoveSelected(1);
                }
                if (KeyboardInput.KeyPressed(Key.Slash))
                {
                    MoveSelected(-1);
                }

                if (MouseInput.ButtonPressed(MouseButton.Right))
                {
                    DeselectAll();
                }
                if (MouseInput.ButtonPressed(MouseButton.Left) && !CurrentManipulator.Hovered && !templateMenu.Hovered)
                {
                    Vertex       v     = GetVertexAt(MouseInput.Current.Position);
                    EditorObject obj   = GetObjectAt(MouseInput.Current.Position);
                    Layer        layer = GetHoveredLayer();

                    if (layer != null)
                    {
                        SetActiveLayer(layer);
                    }
                    if (v != null)
                    {
                        Select(v);
                    }
                    else if (obj != null)
                    {
                        obj.Select();
                    }
                    else
                    {
                        selectionBox = new SelectionBox(MouseInput.Current.Position, this);
                    }
                }

                if (MouseInput.ButtonReleased(MouseButton.Left) && selectionBox != null)
                {
                    if (KeyboardInput.Current[Key.LControl])
                    {
                        Deselect(selectionBox.GetObjects().ToArray());
                    }
                    else
                    {
                        Select(selectionBox.GetObjects().ToArray());
                    }

                    selectionBox.Dispose();
                    selectionBox = null;
                }

                if (selectionBox != null)
                {
                    selectionBox.Logic();
                }

                ActiveLayer.Logic();
            }
        }
Exemple #4
0
 public void CreateObject(EditorObject obj)
 {
     ActiveLayer.CreateObject(obj);
 }