Java 类com.badlogic.gdx.scenes.scene2d.utils.DragAndDrop.Source 实例源码

项目:GDXJam    文件:CommandCardContainer.java   
public void addSquad (final Entity squad, final int index) {
        final SquadCommandCard squadCard = new SquadCommandCard(squad, index, skin);
        Source source = new Source(squadCard) {

            @Override
            public Payload dragStart (InputEvent event, float x, float y, int pointer) {
                Payload payload = new Payload();

// payload.setDragActor(new Label("Test", skin));
                SquadCommandCard card = new SquadCommandCard(squad, index, skin);
                payload.setDragActor(card);
// payload.setDragActor(squadTable);
                return payload;
            }
        };

        dragAndDrop.addSource(source);

        cardSlots.get(index).setCard(squadCard);
    }
项目:GDefence    文件:SlotTarget.java   
@Override
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
    Slot payloadSlot = (Slot) payload.getObject();
    // if (targetSlot.getPrototype() == payloadSlot.getPrototype() ||
    // targetSlot.getPrototype() == null) {
    getActor().setColor(Color.WHITE);
    return true;
    // } else {
    // getActor().setColor(Color.DARK_GRAY);
    // return false;
    // }
}
项目:Inspiration    文件:InventorySlotTarget.java   
@Override
public void drop(Source source, Payload payload, float x, float y, int pointer) {
    InventoryItem sourceActor = (InventoryItem) payload.getDragActor();
    InventoryItem targetActor = _targetSlot.getTopInventoryItem();
    InventorySlot sourceSlot = ((InventorySlotSource)source).getSourceSlot();

    if( sourceActor == null ) {
        return;
    }

    //First, does the slot accept the source item type?
    if( !_targetSlot.doesAcceptItemUseType(sourceActor.getItemUseType()))  {
        //Put item back where it came from, slot doesn't accept item
        sourceSlot.add(sourceActor);
        return;
    }

    if( !_targetSlot.hasItem() ){
        _targetSlot.add(sourceActor);
    }else{
        //If the same item and stackable, add
        if( sourceActor.isSameItemType(targetActor) && sourceActor.isStackable()){
            _targetSlot.add(sourceActor);
        }else{
            //If they aren't the same items or the items aren't stackable, then swap
            InventorySlot.swapSlots(sourceSlot, _targetSlot, sourceActor);
        }
    }

}
项目:libgdx-utils    文件:SlotTarget.java   
@Override
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
    Slot payloadSlot = (Slot) payload.getObject();
    // if (targetSlot.getItem() == payloadSlot.getItem() ||
    // targetSlot.getItem() == null) {
    getActor().setColor(Color.WHITE);
    return true;
    // } else {
    // getActor().setColor(Color.DARK_GRAY);
    // return false;
    // }
}
项目:vis-editor    文件:AssetDragAndDrop.java   
private void addAtlasSource (AtlasItem item) {
    dragAndDrop.addSource(new Source(item) {
        @Override
        public Payload dragStart (InputEvent event, float x, float y, int pointer) {
            return createTexturePayload(item.getRegion(), item.getAtlasAsset());
        }
    });
}
项目:vis-editor    文件:VisDragAndDrop.java   
/** Removes all targets and sources. */
public void clear () {
    targets.clear();
    for (Entry<Source, DragListener> entry : sourceListeners.entries())
        entry.key.getActor().removeCaptureListener(entry.value);
    sourceListeners.clear();
}
项目:vis-editor    文件:SpriterEditorSupport.java   
@Override
public Source createDropSource (VisDragAndDrop dragAndDrop, FileItem item) {
    String relativePath = fileAccess.relativizeToAssetsFolder(item.getFile());
    FileHandle dataFile = item.getFile().parent().child(".vis").child("data.json");
    if (dataFile.exists() == false) return null;
    SpriterAssetData data = spriterDataIO.loadData(dataFile);
    return new VisDropSource(dragAndDrop, item).defaultView("New Spriter Animation \n (drop on scene to add)").setPayload(new SpriterAsset(relativePath, data.imageScale));
}
项目:vis-editor    文件:SpineEditorSupport.java   
@Override
public Source createDropSource (VisDragAndDrop dragAndDrop, FileItem item) {
    FileHandle atlasFile = FileUtils.sibling(item.getFile(), "atlas");
    FileHandle skeletonFile = item.getFile();

    String atlasPath = fileAccess.relativizeToAssetsFolder(atlasFile);
    String skeletonPath = fileAccess.relativizeToAssetsFolder(skeletonFile);

    SpineAssetDescriptor asset = new SpineAssetDescriptor(atlasPath, skeletonPath, 1);

    return new VisDropSource(dragAndDrop, item).defaultView("New Spine Animation \n (drop on scene to add)").setPayload(asset);
}
项目:GDefence    文件:SlotTarget.java   
@Override
public void drop(Source source, Payload payload, float x, float y, int pointer) {
}
项目:GDefence    文件:SlotTarget.java   
@Override
public void reset(Source source, Payload payload) {
    getActor().setColor(Color.LIGHT_GRAY);
}
项目:Inspiration    文件:InventorySlotTarget.java   
@Override
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
    return true;
}
项目:Inspiration    文件:InventorySlotTarget.java   
@Override
public void reset(Source source, Payload payload) {
}
项目:Terminkalender    文件:SlotTarget.java   
@Override
public boolean drag(Source source, Payload payload, float x, float y, int pointer) {
    return true;
}
项目:Terminkalender    文件:SlotTarget.java   
@Override
public void drop(Source source, Payload payload, float x, float y, int pointer) {}
项目:Terminkalender    文件:SlotTarget.java   
@Override
public void reset(Source source, Payload payload) {}
项目:libgdx-utils    文件:SlotTarget.java   
@Override
public void drop(Source source, Payload payload, float x, float y, int pointer) {
}
项目:libgdx-utils    文件:SlotTarget.java   
@Override
public void reset(Source source, Payload payload) {
    getActor().setColor(Color.LIGHT_GRAY);
}
项目:vis-editor    文件:EditorEntitySupport.java   
/** Called when EditorEntitySupport must create drop source for assets drag and drop */
Source createDropSource (VisDragAndDrop dragAndDrop, FileItem item);
项目:vis-editor    文件:VisDragAndDrop.java   
public void removeSource (Source source) {
    DragListener dragListener = sourceListeners.remove(source);
    source.getActor().removeCaptureListener(dragListener);
}
项目:ead    文件:DraggableScrollPane.java   
public void removeSource(Source source) {
    drag.removeSource(source);
}