Exemple #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)
            {
                ObjectsEditor editor = new ObjectsEditor(application, application.CurrentSector);
                if (gameObject is IObject)
                {
                    editor.MakeActive((IObject)gameObject);
                }
                application.SetEditor(editor);
            }
        }
        else                    //cancel creation by other buttons
        {
            application.SetToolObjects();
        }
        if (UpdateMousePos(mousePos))
        {
            Redraw();
        }
    }
    public void OnMouseButtonPress(Vector pos, int button, ModifierType Modifiers)
    {
        application.TakeUndoSnapshot( "Created Object '" + objectType + "'" );
        IGameObject gameObject = CreateObjectAt(pos);

        // switch back to object edit mode when shift was not pressed
        if((Modifiers & ModifierType.ShiftMask) == 0) {
            ObjectsEditor editor = new ObjectsEditor(application, application.CurrentSector);
            if(gameObject is IObject) {
                editor.MakeActive((IObject) gameObject);
            }
            application.SetEditor(editor);
        }
    }
    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 row    = FirstRow + (int)Math.Floor(MousePos.Y / ROW_HEIGHT);
            int column = (int)Math.Floor(MousePos.X / COLUMN_WIDTH);
            if (column >= TILES_PER_ROW)
            {
                return;
            }
            int selected = TILES_PER_ROW * row + column;
            if (selected < gameObjectTypes.Count)
            {
                if (SelectedObjectNr != selected)
                {
                    SelectedObjectNr = selected;
                    if (application.CurrentSector != null)
                    {
                        Type   type = gameObjectTypes[selected];
                        Sprite Icon = gameObjectSprites[selected];
                        if (type != null)
                        {
                            IEditor editor = new ObjectCreationEditor(application, application.CurrentSector, type, Icon);
                            application.SetEditor(editor);
                            application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name + "\"");
                        }
                        else
                        {
                            IEditor editor = new ObjectsEditor(application, application.CurrentSector);
                            application.SetEditor(editor);
                            application.PrintStatus("ObjectListWidget: none selected ");
                        }
                    }
                    QueueDraw();
                }
            }
        }
    }
 private void OnButtonPress(object o, ButtonPressEventArgs args)
 {
     if(args.Event.Button == 1) {
         Vector MousePos = new Vector((float) args.Event.X,
                                      (float) args.Event.Y);
         int row = FirstRow + (int) Math.Floor( MousePos.Y / ROW_HEIGHT );
         int column = (int) Math.Floor (MousePos.X / COLUMN_WIDTH);
         if( column >= TILES_PER_ROW ){
             return;
         }
         int selected = TILES_PER_ROW * row + column;
         if( selected  < gameObjectTypes.Count ){
             if( SelectedObjectNr != selected ){
                 SelectedObjectNr = selected;
                 if( application.CurrentSector != null ) {
                     Type type = gameObjectTypes[selected];
                     if(type != null) {
                         IEditor editor = new ObjectCreationEditor(application, application.CurrentSector, type);
                         application.SetEditor(editor);
                         application.PrintStatus("ObjectListWidget: last selected \"" + gameObjectTypes[selected].Name +"\"");
                     } else {
                         IEditor editor = new ObjectsEditor(application, application.CurrentSector);
                         application.SetEditor(editor);
                         application.PrintStatus("ObjectListWidget: none selected ");
                     }
                 }
                 QueueDraw();
             }
         }
     }
 }