static DragAndDrop.Source builder(final Actor actor){ return new DragAndDrop.Source(actor) { @Override public DragAndDrop.Payload dragStart(InputEvent event, float x, float y, int pointer) { DragAndDrop.Payload payload = new DragAndDrop.Payload(); payload.setDragActor(new Label(actor.getName(), VisUI.getSkin())); final Label validLabel = new Label(actor.getName(), VisUI.getSkin()); validLabel.setColor(Color.BLUE); payload.setValidDragActor(validLabel); final Label invalidLabel = new Label(actor.getName(), VisUI.getSkin()); invalidLabel.setColor(Color.RED); payload.setInvalidDragActor(invalidLabel); return payload; } }; }
@Override public DragAndDrop.Payload dragStart(InputEvent event, float x, float y, int pointer) { // if(sourceSlot.isEmpty())return payload; TowerObject tower = (TowerObject) sourceSlot.getLast(); DragAndDrop.Payload payload = super.dragStart(event, x, y, pointer); if (payload == null)return null; Level.getMap().setBuild(true, tower, payload); //start drawing build grid Image i = ((Image)payload.getValidDragActor());//nullPointer Image inv = ((Image)payload.getDragActor()); TextureRegionDrawable t = new TextureRegionDrawable(new TextureRegion(tower.getPrototype().getTowerTexture())); i.setDrawable(t); inv.setDrawable(t); dragAndDrop.setDragActorPosition(-i.getWidth()/2, i.getHeight()/2); return payload; }
@Override public void dragStop(InputEvent event, float x, float y, int pointer, DragAndDrop.Payload payload, DragAndDrop.Target target) { Level.getMap().setBuild(false, null, null);// end drawing build grid super.dragStop(event, x, y, pointer, payload, target); if (target instanceof TileTarget) { TowerObject tower = ((TowerObject) payloadSlot.getLast()); if (tower != null) { // Build MapTile targetTile = ((MapTileActor) target.getActor()).getMapTile(); if(targetTile.build(tower)) { // if (amount > 1) { // sourceSlot.add(item, amount - 1); // } }else { sourceSlot.add(payloadSlot.takeAll()); // return; } } } }
public OverallInventory(Inventory[] customInventories){ super(GDefence.getInstance().assetLoader.getWord("arsenal"), GDefence.getInstance().assetLoader.getSkin(), "description"); getTitleLabel().setAlignment(Align.center); setMovable(false); dragAndDrop = new DragAndDrop(); AssetLoader l = GDefence.getInstance().assetLoader; actors = new InventoryActor[3]; actors[0] = new InventoryActor(customInventories[0], dragAndDrop, l.getSkin()); actors[0].getTitleLabel().setText(l.getWord("towers")); actors[1] = new InventoryActor(customInventories[1], dragAndDrop, l.getSkin()); actors[1].getTitleLabel().setText(l.getWord("spells")); actors[2] = new InventoryActor(customInventories[2], dragAndDrop, l.getSkin()); actors[2].getTitleLabel().setText(l.getWord("details")); createButtons(); }
public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) { super(GDefence.getInstance().assetLoader.getWord("towers"), skin, "description"); getTitleLabel().setAlignment(Align.center); setMovable(false); this.inventory = inventory; this.dragAndDrop = dragAndDrop; this.dragAndDrop.setButton(-1); this.dragAndDrop.setTapSquareSize(2); this.dragAndDrop.setDragTime(30); this.skin = skin; //TextButton closeButton = new TextButton("X", skin); //closeButton.addListener(new HidingClickListener(this)); //add(closeButton).height(getPadTop());// //getButtonTable().add(closeButton).height(getPadTop()); setDefaults(); initCells(/*dragAndDrop, */skin, inventory);// pack(); //setVisible(false); setVisible(true); }
public ArkScreen(Skin uiSkin, InputMultiplexer multiplexer) { ani = new Ani(); skin = uiSkin; this.multiplexer = multiplexer; spriteBatch = new SpriteBatch(); stage = new Stage(); dragAndDrop = new DragAndDrop(); App.TUTORIAL_CONTROLLER.register(stage, ani); App.TUTORIAL_CONTROLLER.nextStepFor(this.getClass()); fuelProgressBar = new ShipProgressBar(ShipProgressBar.ProgressType.FUEL); fuelProgressBar.updateFromShipProperties(); shieldProgressBar = new ShipProgressBar(ShipProgressBar.ProgressType.SHIELD); shieldProgressBar.updateFromShipProperties(); stage.addActor(fuelProgressBar); stage.addActor(shieldProgressBar); }
public TasktableActor(DragAndDrop dragAndDrop, Skin skin) { super("Aktivitäten", skin); Table table = new Table(); setTable(skin, table, "scrollPaneWindowTasksCalendar"); for (Slot slot : tasktable.getSlots()) { SlotActor slotActor = new SlotActor(skin, slot); dragAndDrop.addSource(new SlotSource(slotActor)); dragAndDrop.addTarget(new SlotTarget(slotActor)); dragAndDrop.setDragActorPosition(-CalendarScreen.WIDTHTASK / 2, CalendarScreen.HEIGHTTASK / 2); table.add(slotActor).width(CalendarScreen.WIDTHTASK).height(CalendarScreen.HEIGHTTASK); table.row().padTop(5); } getScrollTable().setFlickScroll(false); getScrollTable().setFadeScrollBars(false); setBounds(AppMain.WIDTH - 212, 70, 210, AppMain.HEIGHT - 72); setMovable(false); pad(8); }
public AnimationEdition(Controller controller) { super(); skin = controller.getApplicationAssets().getSkin(); align(Align.top); DragAndDrop dragAndDrop = new DragAndDrop(); buttonReg = new HashMap<IconTextButton, Class<Effect>>(); drawableReg = new HashMap<Class<Effect>, Drawable>(); backgroundTweens = skin.getDrawable("bg-dark"); add(new TweensTypeTab(dragAndDrop, controller)).left(); row(); AnimationTimeline timeline = new AnimationTimeline(dragAndDrop, controller); add(timeline).expandX().fill(); row(); add(new Separator(true, skin)); row(); add(timeline.getAddButton()).fill().expandX(); row(); add(new Separator(true, skin)); }
public void init(){ //Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class); // inventoryActor = new InventoryActor(User.getTowerInventory(), new DragAndDrop(), // GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class)); inventoryActor = new OverallInventory(); stage.addActor(inventoryActor); inventoryActor.init(); inventoryActor.setPosition(100, 250); towerMap = new TowerMap(GDefence.getInstance().assetLoader.getSkin()); GDefence.getInstance().user.setTowerMap(towerMap); stage.addActor(towerMap); final TextButton towerMapButton = new TextButton(GDefence.getInstance().assetLoader.getWord("tower_map"), GDefence.getInstance().assetLoader.getSkin(), "description"); towerMapButton.setPosition(Gdx.graphics.getWidth() - 200, Gdx.graphics.getHeight() - 100); towerMapButton.setSize(140, 40); towerMapButton.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { towerMap.setVisible(true); towerMap.toFront(); return true; } }); stage.addActor(towerMapButton); TowerCraftPanel towerCraftPanel = new TowerCraftPanel(new DragAndDrop(), inventoryActor, GDefence.getInstance().assetLoader.getSkin()); stage.addActor(towerCraftPanel); towerCraftPanel.init(); // inventoryActor.addTarget(towerCraftPanel.getRecipeSlot()); // inventoryActor.addSlotAsSourceTarget(towerCraftPanel.getDragAndDrop()); }
public TowerCraftPanel(DragAndDrop dragAndDrop, OverallInventory overallInventory, Skin skin) { super(GDefence.getInstance().assetLoader.getWord("craft_panel"), skin, "description"); getTitleLabel().setAlignment(Align.center); setMovable(false); setDefaults(); setResizable(false); this.dragAndDrop = dragAndDrop; this.skin = skin; setSourceTargetInventory(overallInventory); recipeSlot = new SlotActor(skin, new Slot(Recipe.class/*, null, 0*/)); recipeListener = new RecipeListener(); recipeSlot.getSlot().addListener(recipeListener); // resultListener = new ResultListener(); resultSlot = new SlotActor(skin, new Slot(TowerObject.class/*, null, 0*/)); add(recipeSlot).align(Align.center); row(); add();//3 max component size add().size(0, 0); add().size(0, 0); row(); add(); pack();//delete this to do resizable setSize(180, 250); // recipeSlot.setRound(true); // recipeSlot.setClip(false); sourceTargetInventory.addTarget(recipeSlot); dragAndDrop.addSource(new SlotSource(recipeSlot)); sourceTargetInventory.addSlotAsTarget(dragAndDrop); componentSlots = new Array<SlotActor>(); componentListeners = new Array<ComponentListener>(); }
@Override protected void ifSlotTarget(DragAndDrop.Target target) { Slot targetSlot = ((SlotActor) target.getActor()).getSlot(); if (targetSlot.matches(payloadSlot) || targetSlot.getPrototype() == null) { targetSlot.add(payloadSlot.takeAll()); } }
@Override protected void ifSlotTarget(DragAndDrop.Target target) { Slot targetSlot = ((SlotActor) target.getActor()).getSlot(); if (!targetSlot.isFull() && (targetSlot.matches(payloadSlot) || targetSlot.getPrototype() == null)) { Item item = sourceSlot.getPrototype(); if(GDefence.getInstance().user.deleteGold(item.getGlobalCost())){ targetSlot.add(payloadSlot.takeAll()); } else { // System.out.println("No enough money"); } } else { //dont swap items } }
@Override public void dragStop(InputEvent event, float x, float y, int pointer, DragAndDrop.Payload payload, DragAndDrop.Target target) { if (target instanceof SellTarget) { Item item = payloadSlot.getPrototype(); int amount = payloadSlot.getAmount(); if (item != null) { GDefence.getInstance().user.addGold(item.getGlobalCost() * amount); } else { GDefence.getInstance().log("SellSlotSource: Item - null"); } return; } super.dragStop(event, x, y, pointer, payload, target); /*else if(target instanceof GemGradeTarget){ Slot targetSlot = ((SlotActor) target.getActor()).getSlot(); if(targetSlot.isEmpty()){//targetSlot.getPrototype() == null int noNeed = 0; if (payloadSlot.getAmount() > 1){ noNeed = payloadSlot.getAmount() - 1; } targetSlot.add(payloadSlot.take(1)); if(noNeed > 0) { sourceSlot.add(payloadSlot.takeAll());//all remaining } } } else if(target instanceof TowerCraftTarget){ // }*/ }
@Override public boolean drag(DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) { // Image i = ((Image)payload.getDragActor()); //dragAndDrop.setDragActorPosition(-i.getWidth()/2, i.getHeight()/2);//not optimized //TextureRegionDrawable t = new TextureRegionDrawable(new TextureRegion(AssetLoader.rockTower)); //i.setDrawable(t); //Level.getMap().setRangeTower(payload.getDragActor().getX(), payload.getDragActor().getY()); return true; }
@Override public boolean drag(DragAndDrop.Source source, DragAndDrop.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 show() { stage = new Stage(); Gdx.input.setInputProcessor(stage); // Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class); Skin skin = new Skin(Gdx.files.internal("skins/uiskin.json")); DragAndDrop dragAndDrop = new DragAndDrop(); // inventoryActor = new InventoryActor(new Inventory(), dragAndDrop, skin); stage.addActor(inventoryActor); inventoryActor.init(); }
public static void populateInventory(Table targetTable, Array<InventoryItemLocation> inventoryItems, DragAndDrop draganddrop, String defaultName, boolean disableNonDefaultItems){ clearInventoryItems(targetTable); Array<Cell> cells = targetTable.getCells(); for(int i = 0; i < inventoryItems.size; i++){ InventoryItemLocation itemLocation = inventoryItems.get(i); InventoryItem.ItemTypeID itemTypeID = InventoryItem.ItemTypeID.valueOf(itemLocation.getItemTypeAtLocation()); InventorySlot inventorySlot = ((InventorySlot)cells.get(itemLocation.getLocationIndex()).getActor()); for( int index = 0; index < itemLocation.getNumberItemsAtLocation(); index++ ){ InventoryItem item = InventoryItemFactory.getInstance().getInventoryItem(itemTypeID); String itemName = itemLocation.getItemNameProperty(); if( itemName == null || "".equals(itemName.trim())){ item.setName(defaultName); }else{ item.setName(itemName); } inventorySlot.add(item); if( item.getName().equalsIgnoreCase(defaultName) ){ draganddrop.addSource(new InventorySlotSource(inventorySlot, draganddrop)); }else if( disableNonDefaultItems == false ){ draganddrop.addSource(new InventorySlotSource(inventorySlot, draganddrop)); } } } }
@Override public void show() { stage = new Stage(); Gdx.input.setInputProcessor(stage); Skin skin = LibgdxUtils.assets.get("skins/uiskin.json", Skin.class); DragAndDrop dragAndDrop = new DragAndDrop(); inventoryActor = new InventoryActor(new Inventory(), dragAndDrop, skin); stage.addActor(inventoryActor); }
public InventoryActor(Inventory inventory, DragAndDrop dragAndDrop, Skin skin) { super("Inventory...", skin); TextButton closeButton = new TextButton("X", skin); closeButton.addListener(new HidingClickListener(this)); getButtonTable().add(closeButton).height(getPadTop()); setPosition(400, 100); defaults().space(8); row().fill().expandX(); int i = 0; for (Slot slot : inventory.getSlots()) { SlotActor slotActor = new SlotActor(skin, slot); dragAndDrop.addSource(new SlotSource(slotActor)); dragAndDrop.addTarget(new SlotTarget(slotActor)); add(slotActor); i++; if (i % 5 == 0) { row(); } } pack(); // it is hidden by default setVisible(false); }
public DefaultDragAndDropTarget () { dummyTarget = new DragAndDrop.Target(new Actor()) { @Override public boolean drag (DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) { return false; } @Override public void drop (DragAndDrop.Source source, DragAndDrop.Payload payload, float x, float y, int pointer) { } }; }
public AnimationTimeline(DragAndDrop dragAndDrop, final Controller controller) { align(Align.top); dragNDrop = dragAndDrop; Table tracks = new Table(); scroll = new DraggableScrollPane(tracks, dragNDrop, 20, 50); trackLayouts = new Array<TrackEffectLayout>(); add(scroll).fill().expand().left(); this.controller = controller; addNewTrack = new Container(new IconButton( skin.getDrawable("plus24x24"), skin)); addNewTrack.setBackground(skin.getDrawable("blank")); addNewTrack.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { controller.action(AddTrackEffect.class, animation, new TrackEffect()); } }); animation = new Animation(); controller.getModel().addSelectionListener(this); animationListener = createListListener(); trackListener = createTrackEffectListener(); controller.getModel().addListListener(animation.getEffects(), animationListener); }
/** * Create a {@link EditTweensBar} with background and {@link DragAndDrop}. * */ public EditTweensBar(Drawable background, DragAndDrop dragAndDrop, Controller controller) { this(background, null, controller, controller.getApplicationAssets() .getSkin()); dragNDrop = dragAndDrop; }
/** * Create a {@link EditTweensBar} with background and with * {@link DragAndDrop}. The {@link StretchableButton}s created by drag and * drop have own background <b>backgroundTweens</b>. */ public EditTweensBar(Drawable background, Drawable backgroundTweens, DragAndDrop dragAndDrop, Controller controller) { this(background, backgroundTweens, controller, controller .getApplicationAssets().getSkin()); dragNDrop = dragAndDrop; }
public DraggableScrollPane(Actor widget, DragAndDrop dragAndDrop, float zone, float speed) { super(widget); actionZone = zone; drag = dragAndDrop; scrollSpeed = speed; setFlingTime(0.0f); setFadeScrollBars(false); setOverscroll(false, false); }
private void addActorToSelectList(GridGroup table,DragAndDrop dragAndDrop ,Actor actor){ actor.setName(actor.getClass().getSimpleName()); table.addActor(actor); dragAndDrop.addSource(SourceBuilder.builder(actor)); }
public InventoryDragAndDrop() { dragAndDrop = new DragAndDrop(); }
public StoreDragAndDrop() { dragAndDrop = new DragAndDrop(); }
public void init(){ inventoryActor = new InventoryActor(User.getTowerInventory(), new DragAndDrop(), GDefence.getInstance().assetLoader.getSkin()){ @Override protected void addSourceTarget(SlotActor slotActor) { dragAndDrop.addSource(new SellSlotSource(slotActor)); dragAndDrop.addTarget(new SlotTarget(slotActor)); } @Override protected void setDefaults() { setPosition(100, 250); defaults().space(8); defaults().size(60, 60); row().fill().expandX(); setRowNumber(7); setRows(4); } }; // storeBuyPanel = new StoreBuyPanel(new StoreBuyInventory()); // storeBuyPanel.store(ItemEnum.Tower.Basic, 1); // storeBuyPanel.store(ItemEnum.Tower.Rock, 1); // storeBuyPanel.store(ItemEnum.Tower.Arrow, 1); // storeBuyPanel.store(ItemEnum.Tower.Range, 1); // storeBuyPanel = new StoreBuyPanel(inventoryActor.getDragAndDrop()); // User.setStorePanel(storeBuyPanel); // storeBuyPanel.addSlots(inventoryActor); storeBuyPanel.setPosition(740, 200); stage.addActor(inventoryActor); inventoryActor.init(); stage.addActor(storeBuyPanel); storeBuyPanel.init(); storeBuyPanel.addFastMove(inventoryActor.getInventory()); stage.addActor(new GoldPanel(1100, 500, 100, 90)); }
public void load(final int level){ saveInventory = new Inventory[3]; saveInventory[0] = new Inventory(User.getTowerInventory()); saveInventory[1] = new Inventory(User.getSpellInventory()); saveInventory[2] = new Inventory(User.getDetailInventory()); // inventoryActor = new InventoryActor(saveInventory, new DragAndDrop(), // GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class)); inventoryActor = new OverallInventory(saveInventory); stage.addActor(inventoryActor); inventoryActor.init(); preparationTowerInventoryActor = new PreparationTowerInventoryActor(new DragAndDrop(), GDefence.getInstance().assetLoader.getSkin()); inventoryActor.getActor(0).addFastMoving(preparationTowerInventoryActor.getInventory()); preparationTowerInventoryActor.setPosition(700, 250); inventoryActor.addTarget(preparationTowerInventoryActor); inventoryActor.addSlotAsTarget(preparationTowerInventoryActor.getDragAndDrop()); // inventoryActor.addSlots(preparationTowerInventoryActor); // preparationTowerInventoryActor.addSlots(inventoryActor); stage.addActor(preparationTowerInventoryActor); preparationTowerInventoryActor.init(); inventoryActor.setPosition(100, 50); preparationSpellInventoryActor = new PreparationSpellInventoryActor(new DragAndDrop(), GDefence.getInstance().assetLoader.getSkin()); inventoryActor.getActor(1).addFastMoving(preparationSpellInventoryActor.getInventory()); preparationSpellInventoryActor.setPosition(700, 100); inventoryActor.addTarget(preparationSpellInventoryActor); inventoryActor.addSlotAsTarget(preparationSpellInventoryActor.getDragAndDrop()); // preparationSpellInventoryActor.addSlots(inventoryActor); stage.addActor(preparationSpellInventoryActor); preparationSpellInventoryActor.init(); TextButton startButton = new TextButton(GDefence.getInstance().assetLoader.getWord("start"), GDefence.getInstance().assetLoader.getSkin()); startButton.setSize(150, 70); startButton.setPosition(/*Gdx.graphics.getWidth() - 200*/1080, 30); startButton.addListener(new InputListener(){ public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { GDefence.getInstance().setScreen(new LevelLoadingScreen(level, preparationTowerInventoryActor.getInventory(), preparationSpellInventoryActor.getInventory())); return true; } }); stage.addActor(startButton); }
public void setBuild(boolean build, TowerObject rangeTower, DragAndDrop.Payload payload) {// isBuild = build; this.rangeTower = rangeTower; this.payload = payload; }
public PreparationTowerInventoryActor(DragAndDrop dragAndDrop, Skin skin) { super(new PreparationTowerInventory(), dragAndDrop, skin); getTitleLabel().setText(GDefence.getInstance().assetLoader.getWord("levelTowers")); }
public PreparationSpellInventoryActor(DragAndDrop dragAndDrop, Skin skin) { super(new PreparationSpellInventory(), dragAndDrop, skin); getTitleLabel().setText(GDefence.getInstance().assetLoader.getWord("levelSpells")); }
public DragAndDrop getDragAndDrop() { return dragAndDrop; }
public StoreBuyPanel(/*Inventory inventory*/DragAndDrop dragAndDrop) { super(GDefence.getInstance().assetLoader.getWord("store"), GDefence.getInstance().assetLoader.getSkin(), "description"); this.dragAndDrop = dragAndDrop; getTitleLabel().setAlignment(Align.center); setMovable(false); setResizable(false); // setFillParent(true); // setHeight(500); // init(); }
public GemGradePanel(DragAndDrop dragAndDrop, OverallInventory inventory, Skin skin) { super(GDefence.getInstance().assetLoader.getWord("grade_panel"), skin, "description"); getTitleLabel().setAlignment(Align.center); setMovable(false); // g = new Array<HorizontalGroup>(); g = new HorizontalGroup[4]; // g[0] = new HorizontalGroup(); for (int i = 0; i < g.length; i++){ g[i] = new HorizontalGroup(); g[i].space(12); g[i].setVisible(false); add(g[i]); row(); } g[0].setVisible(true); setDefaults(); this.dragAndDrop = dragAndDrop; this.inventory = inventory; gradeTowerSlot = new SlotActor(skin, new Slot(1, TowerObject.class, SpellObject.class)); gradeTowerSlot.getSlot().addListener(new GradeSlotListener()); inventory.addTarget(gradeTowerSlot); dragAndDrop.addSource(new SlotSource(gradeTowerSlot)); inventory.addSlotAsTarget(dragAndDrop); g[0].addActor(gradeTowerSlot);//.align(Align.topLeft); // add(g[0]); // debugAll(); g[0].pack(); g[1].pack(); g[2].pack(); g[3].pack(); pack(); setVisible(true); }
public LevelShopSource(SlotActor actor, DragAndDrop dragAndDrop) { super(actor); this.dragAndDrop = dragAndDrop; }
public void addSlotAsTarget(DragAndDrop d){//split into 2 methods for (InventoryActor i:actors){ // i.addThisAsSource(d); i.addThisAsTarget(d); } }
public TileTarget(MapTileActor tile, DragAndDrop dragAndDrop) { super(tile); this.tile = tile; this.dragAndDrop = dragAndDrop; //System.out.println(((MapTileActor)getActor()).getMapTile()); }
@Override public void reset(DragAndDrop.Source source, DragAndDrop.Payload payload) { getActor().setColor(Color.GREEN); }