Exemplo n.º 1
0
    public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers)
    {
        if (button == 1)
        {
            IGameObject gameObject = CreateObjectAt(MousePos);

            // switch back to object edit mode when shift was not pressed
            if ((Modifiers & ModifierType.ShiftMask) == 0)
            {
                ObjectSelectTool editor = new ObjectSelectTool(application, application.CurrentSector);
                if (gameObject is IObject)
                {
                    editor.MakeActive((IObject)gameObject);
                }
                application.SetTool(editor);
            }
        }
        else                    //cancel creation by other buttons
        {
            application.SetToolObjects();
        }
        if (UpdateMousePos(mousePos))
        {
            Redraw();
        }
    }
Exemplo n.º 2
0
        private void CommandPaste()
        {
            if (CommandCanPaste())
            {
                ObjectSelectionClipboard clip = ObjectSelectionClipboard.CopyFromClipboard(Layer.Level.Project);
                if (clip == null)
                {
                    return;
                }

                ObjectSelectTool tool = _currentTool as ObjectSelectTool;
                if (tool == null)
                {
                    SetCurrentTool(NewSelectTool());
                }

                _selectionManager.ClearSelection();

                CenterObjectsInViewport(clip.Objects);

                Command command = new ObjectAddCommand(Layer, clip.Objects, _selectionManager);
                LayerContext.History.Execute(command);

                foreach (ObjectInstance inst in clip.Objects)
                {
                    //Layer.AddObject(inst);
                    _selectionManager.AddObjectToSelection(inst);
                }
            }
        }
Exemplo n.º 3
0
        private ObjectSelectTool NewSelectTool()
        {
            Treefrog.Framework.Imaging.Size gridSize = new Treefrog.Framework.Imaging.Size(Layer.GridWidth, Layer.GridHeight);
            ObjectSelectTool tool = new ObjectSelectTool(LayerContext, Layer, gridSize, _selectionManager);

            tool.BindObjectSourceController(_objectController);

            return(tool);
        }
Exemplo n.º 4
0
    private void OnButtonPress(object o, ButtonPressEventArgs args)
    {
        if (args.Event.Button == 1)
        {
            application.SetToolObjects();

            Vector MousePos = new Vector((float)args.Event.X,
                                         (float)args.Event.Y);
            int?objectNr = GetObjectNrByPosition(MousePos);
            int selected;
            if (!objectNr.HasValue)
            {
                return;
            }
            else
            {
                selected = (int)objectNr;
            }
            if (selected < gameObjectTypes.Count)
            {
                if (SelectedObjectNr != selected)
                {
                    SelectedObjectNr = selected;
                    if (application.CurrentSector != null)
                    {
                        Type   type = gameObjectTypes[selected];
                        Sprite Icon = gameObjectSprites[selected];
                        if (type != null)
                        {
                            ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name + "\"");
                        }
                        else
                        {
                            ITool editor = new ObjectSelectTool(application, application.CurrentSector);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: none selected ");
                        }
                    }
                    QueueDraw();
                }
            }
        }
    }
Exemplo n.º 5
0
        private void SetCurrentTool(PointerTool tool)
        {
            ObjectSelectTool objTool = _currentTool as ObjectSelectTool;

            if (objTool != null)
            {
                objTool.Cancel();

                _selectionManager.ClearSelection();
                _commandManager.RemoveCommandSubscriber(objTool);
            }

            _currentTool = tool;

            objTool = _currentTool as ObjectSelectTool;
            if (objTool != null && objTool.CommandManager != null)
            {
                _commandManager.AddCommandSubscriber(objTool);
            }
        }
Exemplo n.º 6
0
 protected ToolState(ObjectSelectTool tool)
 {
     Tool = tool;
 }
Exemplo n.º 7
0
 public SelectionTimeoutToolState(ObjectSelectTool tool)
     : base(tool)
 {
 }
Exemplo n.º 8
0
 public SelectionStandbyToolState(ObjectSelectTool tool)
     : base(tool)
 {
 }
Exemplo n.º 9
0
            public SelectionRotatingToolState(ObjectSelectTool tool, ObjectInstance hitObject)
                : base(tool)
            {
                HitObject = hitObject;
                InitialPosition = hitObject.Position;
                InitialCenter = hitObject.ImageBounds.Center;
                InitialAngle = hitObject.Rotation;

                float radius = Tool.MaxBoundingDiagonal(HitObject) / 2 + 5;
                Annot = new CircleAnnot(HitObject.ImageBounds.Center, radius);
                Annot.Outline = Outline;
                Annot.OutlineGlow = OutlineGlow;
                Tool._annots.Add(Annot);
            }
Exemplo n.º 10
0
 public SelectionMovingToolState(ObjectSelectTool tool)
     : base(tool)
 {
 }
Exemplo n.º 11
0
 public SelectionAreaToolState(ObjectSelectTool tool)
     : base(tool)
 {
 }
Exemplo n.º 12
0
 public ReleaseToolState(ObjectSelectTool tool)
     : base(tool)
 {
 }
Exemplo n.º 13
0
    private void OnButtonPress(object o, ButtonPressEventArgs args)
    {
        if(args.Event.Button == 1) {
            application.SetToolObjects();

            Vector MousePos = new Vector((float) args.Event.X,
                                         (float) args.Event.Y);
            int? objectNr = GetObjectNrByPosition(MousePos);
            int selected;
            if (!objectNr.HasValue) {
                return ;
            } else {
                selected = (int)objectNr;
            }
            if( selected  < gameObjectTypes.Count ){
                if( SelectedObjectNr != selected ){
                    SelectedObjectNr = selected;
                    if( application.CurrentSector != null ) {
                        Type type = gameObjectTypes[selected];
                        Sprite Icon = gameObjectSprites[selected];
                        if(type != null) {
                            ITool editor = new ObjectCreationTool(application, application.CurrentSector, type, Icon);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name +"\"");
                        } else {
                            ITool editor = new ObjectSelectTool(application, application.CurrentSector);
                            application.SetTool(editor);
                            application.PrintStatus("ObjectListWidget: none selected ");
                        }
                    }
                    QueueDraw();
                }
            }
        }
    }
Exemplo n.º 14
0
    public void OnMouseButtonPress(Vector mousePos, int button, ModifierType Modifiers)
    {
        if (button == 1){
            IGameObject gameObject = CreateObjectAt(MousePos);

            // switch back to object edit mode when shift was not pressed
            if((Modifiers & ModifierType.ShiftMask) == 0) {
                ObjectSelectTool editor = new ObjectSelectTool(application, application.CurrentSector);
                if(gameObject is IObject) {
                    editor.MakeActive((IObject) gameObject);
                }
                application.SetTool(editor);
            }
        } else {	//cancel creation by other buttons
            application.SetToolObjects();
        }
        if (UpdateMousePos(mousePos))
            Redraw();
    }