public bool MouseLeave()
        {
            // Avoid showing a tooltip outside the MapControl
            Map.StopTooltip();

            return(CurrentManipulator.MouseLeave());
        }
        public bool MouseMove(MouseEventArgs e)
        {
            Point   game    = Map.Display.GetGameLocation(e.Location);
            Village village = World.Default.GetVillage(game);
            Point   map     = Map.Display.GetMapLocation(game);

            // Display village tooltip
            if (village != null)
            {
                if (ActiveVillage != village.Location)
                {
                    LastActiveVillage = ActiveVillage;
                    ActiveVillage     = village.Location;
                    CurrentManipulator.ShowTooltip(village);
                }
            }
            else
            {
                Map.StopTooltip();
            }

            // Invoke the MouseMoved delegate each time the current mouse location is different from the last location
            if (_mouseMoved != null && ActiveLocation != game)
            {
                ActiveLocation = game;
                _mouseMoved(e, map, village, ActiveLocation, ActiveVillage);
            }

            return(CurrentManipulator.MouseMoveCore(new MapMouseMoveEventArgs(e, map, village)));
        }
        public bool MouseDown(MouseEventArgs e, Village village)
        {
            bool redraw = false;

            if (village != null && e.Button == MouseButtons.Left)
            {
                redraw = CurrentManipulator.OnVillageClickCore(new MapVillageEventArgs(e, village));
            }
            return(CurrentManipulator.MouseDownCore(new MapMouseEventArgs(e, village)) ||
                   redraw);
        }
        /// <summary>
        /// Changes the active manipulatormanager
        /// </summary>
        public void SetManipulator(ManipulatorManagerTypes manipulator)
        {
            if (manipulator != ManipulatorManagerTypes.Default)
            {
                _previousType = manipulator;
            }

            Map.EventPublisher.Deselect(this);

            CurrentManipulator = _manipulators[manipulator];
            CurrentManipulator.Initialize();
            Map.EventPublisher.ChangeManipulator(this, new ManipulatorEventArgs(manipulator));
        }
Ejemplo n.º 5
0
        public void Draw()
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.DepthFunc(DepthFunction.Lequal);
            program["view"].SetValue(camera.ViewMatrix);

            background.Draw();

            foreach (Layer l in layerList)
            {
                if (l != ActiveLayer || preview)
                {
                    l.Draw();
                }
            }
            if (!preview)
            {
                ActiveLayer.Draw();
            }

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

            if (showGrid && !layerCreator.Active)
            {
                gridMesh.Draw();
                originMesh.Draw();
            }

            templateMenu.Draw();
            CurrentManipulator.Draw();
            templateCreator.Draw();

            layerCreator.Draw();
        }
Ejemplo n.º 6
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();
            }
        }
 public bool MouseWheel(MouseEventArgs e)
 {
     return(CurrentManipulator.MouseWheel(e));
 }
        public bool MouseUp(MouseEventArgs e, Village village)
        {
            bool redraw = CurrentManipulator.MouseUpCore(new MapMouseEventArgs(e, village));

            return(redraw);
        }
 public bool OnVillageDoubleClick(MouseEventArgs e, Village village)
 {
     return(CurrentManipulator.OnVillageDoubleClickCore(new MapVillageEventArgs(e, village)));
 }
 public bool KeyUp(KeyEventArgs e)
 {
     return(CurrentManipulator.OnKeyUpCore(new MapKeyEventArgs(e)));
 }