List of usage examples for com.badlogic.gdx.utils Array contains
public boolean contains(T value, boolean identity)
From source file:com.ahsgaming.valleyofbones.Player.java
License:Apache License
public static Color getUnusedColor(Array<Player> players) { Array<Color> usedColors = new Array<Color>(); for (Player p : players) { usedColors.add(p.getPlayerColor()); }/* w w w .j a v a 2 s .c om*/ Color use = Player.AUTOCOLORS[0]; for (Color color : Player.AUTOCOLORS) { if (!usedColors.contains(color, true)) { use = color; break; } } return use; }
From source file:com.algodal.gdxscreen.GdxTransition.java
License:Apache License
final void unloadAssets(GdxScreen[] visible, GdxScreen[] hidden) { Array<String> visibleAssets = new Array<>(); Array<String> hiddenAssets = new Array<>(); for (GdxScreen screen : visible) visibleAssets.addAll(screen.assetRefs); for (GdxScreen screen : hidden) hiddenAssets.addAll(screen.assetRefs); for (String assetRef : hiddenAssets) if (!visibleAssets.contains(assetRef, false)) if (getGame().assetMap.get(assetRef).isloaded()) getGame().assetMap.get(assetRef).unload(); }
From source file:com.badlogic.gdx.spriter.demo.SpriterDemoApp.java
private void changeCharacterMaps(Array<SpriterCharacterMap> selected) { Array<SpriterCharacterMap> current = animator.getCharacterMaps(); for (SpriterCharacterMap currentMap : current) if (!selected.contains(currentMap, true)) animator.removeCharacterMap(currentMap); for (SpriterCharacterMap selectedMap : selected) if (!current.contains(selectedMap, true)) animator.addCharacterMap(selectedMap); }
From source file:com.betmansmall.game.gameLogic.mapLoader.MapLoader.java
License:Apache License
/** Loads the images in image layers * @param root the root XML element//from ww w.j a va 2 s.c o m * @return a list of filenames for images inside image layers * @throws IOException */ protected Array<FileHandle> loadImages(Element root, FileHandle tmxFile) throws IOException { Array<FileHandle> images = new Array<FileHandle>(); for (Element imageLayer : root.getChildrenByName("imagelayer")) { Element image = imageLayer.getChildByName("image"); String source = image.getAttribute("source", null); if (source != null) { FileHandle handle = getRelativeFileHandle(tmxFile, source); if (!images.contains(handle, false)) { images.add(handle); } } } return images; }
From source file:com.intrepid.nicge.controller.ControllerManager.java
private void removeControllers(Array<Controller> controllers) { Array<JoystickPad> removes = new Array<>(); for (JoystickPad joystickPad : joystickPads) { if (!controllers.contains(joystickPad.getController(), true)) { removes.add(joystickPad);//from www. ja v a 2 s . c om } } joystickPads.removeAll(removes, true); }
From source file:com.kotcrab.vis.editor.module.project.ShaderCacheModule.java
License:Apache License
private void reloadShaders(boolean showSuccessMessage) { shaders.clear();/* ww w. ja va2 s .co m*/ Array<FileHandle> handled = new Array<>(); FileUtils.streamFilesRecursively(fileAccess.getAssetsFolder(), file -> { if (handled.contains(file, false)) return; FileHandle vertexFile = null; FileHandle fragmentFile = null; if (file.extension().equals("frag")) { fragmentFile = file; vertexFile = file.sibling(file.nameWithoutExtension() + ".vert"); } if (file.extension().equals("vert")) { vertexFile = file; fragmentFile = file.sibling(file.nameWithoutExtension() + ".frag"); } if (vertexFile != null && vertexFile.exists()) handled.add(vertexFile); if (fragmentFile != null && fragmentFile.exists()) handled.add(fragmentFile); if (vertexFile == null && fragmentFile == null) { return; } if (vertexFile == null || vertexFile.exists() == false) { toastModule.show(new DetailsToast("Shader compilation not possible, missing vertex file!", "Error", "Missing vertex file for fragment: " + fragmentFile.name())); return; } if (fragmentFile == null || fragmentFile.exists() == false) { toastModule.show(new DetailsToast("Shader compilation not possible, missing fragment file!", "Error", "Missing fragment file for fragment: " + vertexFile.name())); return; } ShaderProgram shader = new ShaderProgram(vertexFile, fragmentFile); if (shader.isCompiled() == false) { toastModule.show( new DetailsToast("Shader " + vertexFile.nameWithoutExtension() + " compilation failed!", "Error", shader.getLog()), 5); } else { if (showSuccessMessage) toastModule.show("Shader " + vertexFile.nameWithoutExtension() + " successfully compiled", 2); String vertPath = fileAccess.relativizeToAssetsFolder(vertexFile); String fragPath = fileAccess.relativizeToAssetsFolder(fragmentFile); ShaderAsset asset = new ShaderAsset(vertPath, fragPath); shaders.put(asset, shader); } }); }
From source file:com.kotcrab.vis.editor.ui.scene.SceneOutline.java
License:Apache License
public void rebuildOutline() { buildGroupNodeState(tree.getNodes()); tree.clearChildren();/*from w w w.j av a 2s . c o m*/ Values<EntityProxy> proxies = proxyCache.getCache().values(); Array<EntityProxy> ignoreProxies = new Array<>(); for (EntityProxy proxy : proxies) { if (ignoreProxies.contains(proxy, true)) { continue; } int gid = proxy.getLastGroupId(); if (gid != -1) { Array<EntityProxy> result = entitiesCollector.collect(proxy.getLayerID(), gid); ignoreProxies.addAll(result); buildTreeRecursively(result, gid, null); } else { tree.add(new ProxyNode(proxy)); } } expandedNodes.clear(); }
From source file:com.kotcrab.vis.editor.ui.scene.SceneOutline.java
License:Apache License
private void buildTreeRecursively(Array<EntityProxy> groupProxies, int gid, Node parent) { GroupNode groupRoot = new GroupNode(groupProxies.first().getLayerID(), gid); if (parent == null) tree.add(groupRoot);//ww w .ja va 2s. c o m else parent.add(groupRoot); if (expandedNodes.contains(gid)) { groupRoot.setExpanded(true); } Array<EntityProxy> ignoreProxies = new Array<>(); for (EntityProxy proxy : groupProxies) { if (ignoreProxies.contains(proxy, true)) { continue; } int gidBefore = proxy.getGroupIdBefore(gid); if (gidBefore != -1) { Array<EntityProxy> result = entitiesCollector.collect(proxy.getLayerID(), gidBefore); ignoreProxies.addAll(result); buildTreeRecursively(result, gidBefore, groupRoot); continue; } groupRoot.add(new ProxyNode(proxy)); } }
From source file:com.kotcrab.vis.runtime.util.SpriteSheetHelper.java
License:Apache License
private ImmutableArray<String> createAnimationList() { final Array<String> list = new Array<String>(); for (TextureAtlas.AtlasRegion atlasRegion : atlas.getRegions()) { if (atlasRegion.index == -1) continue; if (list.contains(atlasRegion.name, false)) continue; list.add(atlasRegion.name);/*from w ww . j a v a2 s . c o m*/ } return new ImmutableArray<String>(list); }
From source file:com.kotcrab.vis.ui.widget.file.FilePopupMenu.java
License:Apache License
public void build(Array<FileHandle> favorites, FileHandle file) { this.file = file; clearChildren();//from w w w . j av a2 s . c om addItem(newDirectory); addSeparator(); if (file.type() == FileType.Absolute || file.type() == FileType.External) addItem(delete); if (file.type() == FileType.Absolute) { addItem(showInExplorer); if (file.isDirectory()) { if (favorites.contains(file, false)) addItem(removeFromFavorites); else addItem(addToFavorites); } } }