Esempio n. 1
0
 public void ChangeTool(Guid toolGuid)
 {
     _currMapPlugin = (Plugins.IMapPlugin)tools[toolGuid];
     if (SelectedPluginChanged != null)
         SelectedPluginChanged(new ToolEventArgs(_currMapPlugin));
     _currMapPlugin.GetButton().Checked = true;
 }
Esempio n. 2
0
        private void toolchanged(object sender, EventArgs e)
        {
            ToolButton tb = (ToolButton)sender;

            if (!tb.Checked)
            {
                return;
            }
            _currMapPlugin = (Plugins.IMapPlugin)tools[tb.guid];
            if (SelectedPluginChanged != null)
            {
                SelectedPluginChanged(new ToolEventArgs(_currMapPlugin));
            }
        }
Esempio n. 3
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (!live || ParentMap.IsBrush)
            {
                return;
            }

            mdown = false;

            if (bDragging)
            {
                Cursor    = Cursors.Default;
                Capture   = false;
                bDragging = false;

                if (bSliding)
                {
                    bSliding           = bSlidingLeft = bSlidingRight = bSlidingDown = bSlidingUp = false;
                    slideTimer.Enabled = false;
                }
            }

            if (bDraggingTool)
            {
                setupMapCursorLocation(ref currMapEventInfo.end, e.X, e.Y);
                currMapDragTool.MouseUp(currMapEventInfo);
                bDraggingTool = false;

                if (currMapEventInfo.bDirty)
                {
                    Invalidate();
                }
                currMapEventInfo.bDirty = false;
            }

            ParentMap.bUpdating = false;

            currMapPlugin   = null;
            currMapTool     = null;
            currMapDragTool = null;
        }
Esempio n. 4
0
 private void toolchanged(object sender, EventArgs e)
 {
     ToolButton tb = (ToolButton)sender;
     if(!tb.Checked) return;
     _currMapPlugin = (Plugins.IMapPlugin)tools[tb.guid];
     if(SelectedPluginChanged != null)
         SelectedPluginChanged(new ToolEventArgs(_currMapPlugin));
 }
Esempio n. 5
0
 public ToolEventArgs(Plugins.IMapPlugin imp)
 {
     selectedPlugin=imp;
 }
Esempio n. 6
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (!live || ParentMap.IsBrush)
                return;

            mdown = false;

            if (bDragging) {
                Cursor = Cursors.Default;
                Capture = false;
                bDragging = false;

                if (bSliding) {
                    bSliding = bSlidingLeft = bSlidingRight = bSlidingDown = bSlidingUp = false;
                    slideTimer.Enabled = false;
                }
            }

            if (bDraggingTool) {
                setupMapCursorLocation(ref currMapEventInfo.end, e.X, e.Y);
                currMapDragTool.MouseUp(currMapEventInfo);
                bDraggingTool = false;

                if (currMapEventInfo.bDirty)
                    Invalidate();
                currMapEventInfo.bDirty = false;
            }

            ParentMap.bUpdating = false;

            currMapPlugin = null;
            currMapTool = null;
            currMapDragTool = null;
        }
Esempio n. 7
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!live || ParentMap.IsBrush)
                return;

            mdown = true;
            if (Global.editedLayer.type == LayerType.Entity) {

                if (Global.SelectedEntity != null) {
                    Global.SelectedEntity.TileX = Global.MapCursorLocation.X;
                    Global.SelectedEntity.TileY = Global.MapCursorLocation.Y;
                }
                return;
            }

            currMapPlugin = Global.toolPalette.currMapPlugin;
            if (currMapPlugin == null)
                return;

            //get the tool to be used
            currMapTool = currMapPlugin.getTool(
                    e.Button == MouseButtons.Left,
                    e.Button == MouseButtons.Right,
                    ((Control.ModifierKeys & Keys.Shift) != 0),
                    ((Control.ModifierKeys & Keys.Control) != 0),
                    ((Control.ModifierKeys & Keys.Alt) != 0)
                    );
            if (currMapTool == null)
                return;

            //ensure that the tool to be used works with the current edited layer
            MapLayer ml = null;

            foreach (LayerType t in currMapTool.layerTypes) {
                if (t == Global.editedLayer.type)
                    ml = Global.editedLayer;
            }

            if (ml == null) {
                currMapTool = null;
                return;
            }

            Capture = true;
            bDragging = true;
            ParentMap.bUpdating = true;

            //setup eventinfo
            currMapEventInfo = new Plugins.MapEventInfo();
            //currMapEventInfo.invalidateEvent += new EventHandler(invalidateEvent);

            currMapEventInfo.editedMap = ParentMap;
            currMapEventInfo.editedLayer = ml;
            currMapEventInfo.editedLayerIndex = ParentMap.Layers.IndexOf(ml);
            currMapEventInfo.lb = ((e.Button & MouseButtons.Left) > 0);
            currMapEventInfo.rb = ((e.Button & MouseButtons.Right) > 0);
            currMapEventInfo.opManager = Global.opManager;
            setupMapCursorLocation(ref currMapEventInfo.start, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.current, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.previous, e.X, e.Y);
            currMapEventInfo.bDirty = false;
            if (currMapTool is Plugins.IMapDragTool) {
                bDraggingTool = true;
                currMapDragTool = (Plugins.IMapDragTool)currMapTool;
                currMapDragTool.MouseDown(currMapEventInfo);
                currMapDragTool.MouseMove(currMapEventInfo);
                if (currMapDragTool is Plugins.IMapDragTileTool)
                    ((Plugins.IMapDragTileTool)currMapDragTool).MouseMoveTile(currMapEventInfo);
            }
            if (currMapTool is Plugins.IMapClickTool) {
                ((Plugins.IMapClickTool)currMapTool).MouseClick(currMapEventInfo);
            }
            if (currMapEventInfo.bDirty)
                Invalidate();
            currMapEventInfo.bDirty = false;
        }
Esempio n. 8
0
 public ToolEventArgs(Plugins.IMapPlugin imp)
 {
     selectedPlugin = imp;
 }
Esempio n. 9
0
 public void registerPlugin(Plugins.IMapPlugin mapPlugin, Guid guid)
 {
     tools[guid] = mapPlugin;
 }
Esempio n. 10
0
 public void registerButton(ToolButton tb, Plugins.IMapPlugin mapPlugin)
 {
     tb.guid = mapPlugin.guid;
     tools[mapPlugin.guid] = mapPlugin;
     tb.CheckedChanged    += new EventHandler(toolchanged);
 }
Esempio n. 11
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!live || ParentMap.IsBrush)
            {
                return;
            }


            mdown = true;
            if (Global.editedLayer.type == LayerType.Entity)
            {
                if (Global.SelectedEntity != null)
                {
                    Global.SelectedEntity.TileX = Global.MapCursorLocation.X;
                    Global.SelectedEntity.TileY = Global.MapCursorLocation.Y;
                }
                return;
            }

            currMapPlugin = Global.toolPalette.currMapPlugin;
            if (currMapPlugin == null)
            {
                return;
            }


            //get the tool to be used
            currMapTool = currMapPlugin.getTool(
                e.Button == MouseButtons.Left,
                e.Button == MouseButtons.Right,
                ((Control.ModifierKeys & Keys.Shift) != 0),
                ((Control.ModifierKeys & Keys.Control) != 0),
                ((Control.ModifierKeys & Keys.Alt) != 0)
                );
            if (currMapTool == null)
            {
                return;
            }

            //ensure that the tool to be used works with the current edited layer
            MapLayer ml = null;

            foreach (LayerType t in currMapTool.layerTypes)
            {
                if (t == Global.editedLayer.type)
                {
                    ml = Global.editedLayer;
                }
            }

            if (ml == null)
            {
                currMapTool = null;
                return;
            }

            Capture             = true;
            bDragging           = true;
            ParentMap.bUpdating = true;


            //setup eventinfo
            currMapEventInfo = new Plugins.MapEventInfo();
            //currMapEventInfo.invalidateEvent += new EventHandler(invalidateEvent);

            currMapEventInfo.editedMap        = ParentMap;
            currMapEventInfo.editedLayer      = ml;
            currMapEventInfo.editedLayerIndex = ParentMap.Layers.IndexOf(ml);
            currMapEventInfo.lb        = ((e.Button & MouseButtons.Left) > 0);
            currMapEventInfo.rb        = ((e.Button & MouseButtons.Right) > 0);
            currMapEventInfo.opManager = Global.opManager;
            setupMapCursorLocation(ref currMapEventInfo.start, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.current, e.X, e.Y);
            setupMapCursorLocation(ref currMapEventInfo.previous, e.X, e.Y);
            currMapEventInfo.bDirty = false;
            if (currMapTool is Plugins.IMapDragTool)
            {
                bDraggingTool   = true;
                currMapDragTool = (Plugins.IMapDragTool)currMapTool;
                currMapDragTool.MouseDown(currMapEventInfo);
                currMapDragTool.MouseMove(currMapEventInfo);
                if (currMapDragTool is Plugins.IMapDragTileTool)
                {
                    ((Plugins.IMapDragTileTool)currMapDragTool).MouseMoveTile(currMapEventInfo);
                }
            }
            if (currMapTool is Plugins.IMapClickTool)
            {
                ((Plugins.IMapClickTool)currMapTool).MouseClick(currMapEventInfo);
            }
            if (currMapEventInfo.bDirty)
            {
                Invalidate();
            }
            currMapEventInfo.bDirty = false;
        }