Exemple #1
0
        //---------------------------------------------------------------------------

        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            UndoManager.Get().StartUndo(LayerManager.Get().Mode);

            var pos = e.GetPosition(TilesCanvas);

            m_LastClicked = pos;
            m_LastMoved   = m_LastClicked;
            m_Dragging    = true;
        }
Exemple #2
0
        //---------------------------------------------------------------------------

        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            m_Clicked = e.GetPosition(this);
            m_Dragged = new Point(0, 0);

            UndoManager.Get().StartUndo(LayerManager.Get().Mode);

            MapManager.Get().ExecuteAction(
                (int)m_Clicked.X / PxTileWidth,
                (int)m_Clicked.Y / PxTileHeight,
                e.LeftButton == MouseButtonState.Pressed);
        }
Exemple #3
0
        //---------------------------------------------------------------------------

        public LevelCanvas()
        {
            InitializeComponent();
            DataContext = this;

            LevelManager.Get().RegisterCanvas(this);

            EditManager.Get().Register(EEditMode.Tiles, TilesEditMode);
            EditManager.Get().Register(EEditMode.Eraser, EraserEditMode);
            EditManager.Get().Register(EEditMode.Selection, SelectionEditMode);
            EditManager.Get().Register(EEditMode.Fill, FillEditMode);
            EditManager.Get().Register(EEditMode.Blocker, BlockerEditMode);

            EditManager.Get().ChangeMode(EEditMode.Tiles);

            LayerManager.Get().Register(ELayerMode.First, FirstLayer);
            LayerManager.Get().Register(ELayerMode.Second, SecondLayer);
            LayerManager.Get().Register(ELayerMode.Third, ThirdLayer);

            LayerManager.Get().ChangeMode(ELayerMode.First);

            #region Keybindings
            InputManager.Get().RegisterShortcut(Key.Z, ModifierKeys.Control, () =>
            {
                UndoManager.Get().Undo();
            });

            InputManager.Get().RegisterShortcut(Key.Y, ModifierKeys.Control, () =>
            {
                UndoManager.Get().Redo();
            });

            InputManager.Get().RegisterShortcut(Key.T, ModifierKeys.Control, () =>
            {
                EditManager.Get().ChangeMode(EEditMode.Tiles);
            });

            InputManager.Get().RegisterShortcut(Key.E, ModifierKeys.Control, () =>
            {
                EditManager.Get().ChangeMode(EEditMode.Eraser);
            });

            InputManager.Get().RegisterShortcut(Key.S, ModifierKeys.Control, () =>
            {
                EditManager.Get().ChangeMode(EEditMode.Selection);
            });

            InputManager.Get().RegisterShortcut(Key.F, ModifierKeys.Control, () =>
            {
                EditManager.Get().ChangeMode(EEditMode.Fill);
            });

            InputManager.Get().RegisterShortcut(Key.B, ModifierKeys.Control, () =>
            {
                EditManager.Get().ChangeMode(EEditMode.Blocker);
            });

            InputManager.Get().RegisterShortcut(Key.F1, ModifierKeys.None, () =>
            {
                LayerManager.Get().ChangeMode(ELayerMode.First);
            });

            InputManager.Get().RegisterShortcut(Key.F2, ModifierKeys.None, () =>
            {
                LayerManager.Get().ChangeMode(ELayerMode.Second);
            });

            InputManager.Get().RegisterShortcut(Key.F3, ModifierKeys.None, () =>
            {
                LayerManager.Get().ChangeMode(ELayerMode.Third);
            });
            #endregion
        }
Exemple #4
0
        //---------------------------------------------------------------------------

        private void OnRedoClicked(object sender, EventArgs e)
        {
            UndoManager.Get().Redo();
        }
Exemple #5
0
        //---------------------------------------------------------------------------

        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            UndoManager.Get().StopUndo();
        }
Exemple #6
0
        //---------------------------------------------------------------------------

        private void OnUndo(object sender, EventArgs e)
        {
            UndoManager.Get().Undo();
        }