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); }
@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; // } }
@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); } } }
@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; // } }
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()); } }); }
/** 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(); }
@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)); }
@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); }
@Override public void drop(Source source, Payload payload, float x, float y, int pointer) { }
@Override public void reset(Source source, Payload payload) { getActor().setColor(Color.LIGHT_GRAY); }
@Override public boolean drag(Source source, Payload payload, float x, float y, int pointer) { return true; }
@Override public void reset(Source source, Payload payload) { }
@Override public void drop(Source source, Payload payload, float x, float y, int pointer) {}
@Override public void reset(Source source, Payload payload) {}
/** Called when EditorEntitySupport must create drop source for assets drag and drop */ Source createDropSource (VisDragAndDrop dragAndDrop, FileItem item);
public void removeSource (Source source) { DragListener dragListener = sourceListeners.remove(source); source.getActor().removeCaptureListener(dragListener); }
public void removeSource(Source source) { drag.removeSource(source); }