List of usage examples for com.badlogic.gdx.graphics.g2d TextureRegion setRegion
public void setRegion(TextureRegion region)
From source file:com.kotcrab.vis.editor.module.project.TextureCacheModule.java
License:Apache License
private void reloadCache() { if (cacheFile.exists()) { TextureAtlas oldCache = null;//from www. j av a 2s. c om if (cache != null) oldCache = cache; cache = new TextureAtlas(cacheFile); for (Entry<String, TextureRegion> e : regions.entries()) { String path = e.key; String regionName = FilenameUtils.removeExtension(path); TextureRegion region = e.value; TextureRegion newRegion = cache.findRegion(regionName); if (newRegion == null) { Texture texture = textures.get(path); if (texture == null) { Log.warn(TAG, "Missing texture for region: " + path); region.setRegion(missingRegion); } else { if (DEBUG_LOG) Log.debug(TAG, "Update region using texture: " + path); region.setRegion(new TextureRegion(texture)); } } else { if (textures.containsKey(path)) { if (DEBUG_LOG) Log.debug(TAG, "Dispose texture " + path); textures.get(path).dispose(); textures.remove(path); } if (DEBUG_LOG) Log.debug(TAG, "Update region using cache " + path); region.setRegion(newRegion); } } if (DEBUG_LOG) Log.debug(TAG, "Post update regions array size " + regions.size); disposeCacheLater(oldCache); App.eventBus.post(new ResourceReloadedEvent(EnumSet.of(ResourceType.TEXTURES))); } else Log.error(TAG, "Texture cache not ready, probably they aren't any textures in project or packer failed"); }