public EntityConfig getEntityConfig(String name) { if (entityConfigs.containsKey(name)) return entityConfigs.get(name); else if (entityConfigs.containsKey("entities/" + name)) return entityConfigs.get("entities/" + name); logger.error("Entity config not found: " + name); return null; }
public WeaponConfig getWeaponConfig(String name) { if (weaponConfigs.containsKey(name)) return weaponConfigs.get(name); else if (weaponConfigs.containsKey("weapons/" + name)) return weaponConfigs.get("weapons/" + name); logger.error("Weapon config not found: " + name); return null; }
@Override public <T> T sendHttpRequest(HttpRequest httpRequest, Class<T> type) throws IOException { Object ret = httpResponses.get(httpRequest.getUrl()); if (ret == null) { ret = httpResponses.get(DEFAULT_RESPONSE); } return (T) ret; }
@Override public void cancelHttpRequest(HttpRequest httpRequest) { HttpResponseListener httpResponseListener = listeners.get(httpRequest); Request request = requests.get(httpRequest); if (httpResponseListener != null && request != null) { request.cancel(); httpResponseListener.cancelled(); requests.remove(httpRequest); listeners.remove(httpRequest); } }
protected void processDir(Entry inputDir, ArrayList<Entry> files) throws Exception { // Start with a copy of a parent dir's settings or the default settings. Settings settings = null; File parent = inputDir.inputFile; while (true) { if (parent.equals(root)) break; parent = parent.getParentFile(); settings = dirToSettings.get(parent); if (settings != null) { settings = new Settings(settings); break; } } if (settings == null) settings = new Settings(defaultSettings); dirToSettings.put(inputDir.inputFile, settings); // Merge settings from pack.json file. File settingsFile = new File(inputDir.inputFile, "pack.json"); if (settingsFile.exists()) json.readFields(settings, new JsonReader().parse(new FileReader(settingsFile))); // Pack. TexturePacker2 packer = new TexturePacker2(root, settings); for (Entry file : files) packer.addImage(file.inputFile); packer.pack(inputDir.outputDir, packFileName); }
public void destrueix() { Iterator<String> claus = imatges.keys(); while (claus.hasNext()) { String clau = claus.next(); imatges.get(clau).dispose(); } }
public float getMix(Animation from, Animation to) { tempKey.a1 = from; tempKey.a2 = to; Float time = animationToMixTime.get(tempKey); if (time == null) return 0; return time; }
@Override public void updateUIFromEntities( ImmutableArray<EntityProxy> proxies, Field field, Class<?> fieldType) throws ReflectiveOperationException { Vector2ArrayView view = views.get(field); if (proxies.size() > 1) view.setMultipleSelected(true); else view.setVectors(EntityUtils.getFirstEntityComponent(proxies, VisPolygon.class).vertices); }
@Override public Preferences getPreferences(String name) { Preferences pref = prefs.get(name); if (pref == null) { pref = new GwtPreferences(name); prefs.put(name, pref); } return pref; }
@Override public void updateUIFromEntities( ImmutableArray<EntityProxy> proxies, Field field, Class<?> fieldType) throws ReflectiveOperationException { StringStringMapView view = views.get(field); if (proxies.size() > 1) view.multipleSelected(); else view.setMap(EntityUtils.getFirstEntityComponent(proxies, Variables.class)); }
/** * Helper method to apply one animation to either an objectmap for blending or directly to the * bones. */ protected static void applyAnimation( final ObjectMap<Node, Transform> out, final Pool<Transform> pool, final float alpha, final Animation animation, final float time) { for (final NodeAnimation nodeAnim : animation.nodeAnimations) { final Node node = nodeAnim.node; node.isAnimated = true; // Find the keyframe(s) final int n = nodeAnim.keyframes.size - 1; int first = 0, second = -1; for (int i = 0; i < n; i++) { if (time >= nodeAnim.keyframes.get(i).keytime && time <= nodeAnim.keyframes.get(i + 1).keytime) { first = i; second = i + 1; break; } } // Apply the first keyframe: final Transform transform = tmpT; final NodeKeyframe firstKeyframe = nodeAnim.keyframes.get(first); transform.set(firstKeyframe.translation, firstKeyframe.rotation, firstKeyframe.scale); // Lerp the second keyframe if (second > first) { final NodeKeyframe secondKeyframe = nodeAnim.keyframes.get(second); final float t = (time - firstKeyframe.keytime) / (secondKeyframe.keytime - firstKeyframe.keytime); transform.lerp( secondKeyframe.translation, secondKeyframe.rotation, secondKeyframe.scale, t); } // Apply the transform, either directly to the bone or to out when blending if (out == null) transform.toMatrix4(node.localTransform); else { if (out.containsKey(node)) { if (alpha == 1.f) out.get(node).set(transform); else out.get(node).lerp(transform, alpha); } else { out.put(node, pool.obtain().set(transform)); } } } }
@Override public void shutdown() { Application app = Gdx.app; if (instances.get(app) == this) { instances.remove(app); listenerTexture.dispose(); speakerTexture.dispose(); EventService.unsubscribe(this); } }
@Override public Preferences getPreferences(String name) { if (preferences.containsKey(name)) { return preferences.get(name); } else { Preferences prefs = new LwjglPreferences(name); preferences.put(name, prefs); return prefs; } }
private Material convertMaterial(ModelMaterial mtl, TextureProvider textureProvider) { Material result = new Material(); result.id = mtl.id; if (mtl.ambient != null) result.set(new ColorAttribute(ColorAttribute.Ambient, mtl.ambient)); if (mtl.diffuse != null) result.set(new ColorAttribute(ColorAttribute.Diffuse, mtl.diffuse)); if (mtl.specular != null) result.set(new ColorAttribute(ColorAttribute.Specular, mtl.specular)); if (mtl.emissive != null) result.set(new ColorAttribute(ColorAttribute.Emissive, mtl.emissive)); if (mtl.reflection != null) result.set(new ColorAttribute(ColorAttribute.Reflection, mtl.reflection)); if (mtl.shininess > 0f) result.set(new FloatAttribute(FloatAttribute.Shininess, mtl.shininess)); if (mtl.opacity != 1.f) result.set( new BlendingAttribute(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA, mtl.opacity)); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); // FIXME mipmapping totally ignored, filters totally ignored, uvScaling/uvTranslation totally // ignored if (mtl.textures != null) { for (ModelTexture tex : mtl.textures) { Texture texture; if (textures.containsKey(tex.fileName)) { texture = textures.get(tex.fileName); } else { texture = textureProvider.load(tex.fileName); textures.put(tex.fileName, texture); disposables.add(texture); } TextureDescriptor descriptor = new TextureDescriptor(texture); descriptor.minFilter = Texture.TextureFilter.Linear; descriptor.magFilter = Texture.TextureFilter.Linear; descriptor.uWrap = Texture.TextureWrap.Repeat; descriptor.vWrap = Texture.TextureWrap.Repeat; switch (tex.usage) { case ModelTexture.USAGE_DIFFUSE: result.set(new TextureAttribute(TextureAttribute.Diffuse, descriptor)); break; case ModelTexture.USAGE_SPECULAR: result.set(new TextureAttribute(TextureAttribute.Specular, descriptor)); break; case ModelTexture.USAGE_BUMP: result.set(new TextureAttribute(TextureAttribute.Bump, descriptor)); break; case ModelTexture.USAGE_NORMAL: result.set(new TextureAttribute(TextureAttribute.Normal, descriptor)); break; } } } return result; }
@Override public Preferences getPreferences(String name) { if (preferences.containsKey(name)) { return preferences.get(name); } else { Preferences prefs = new Lwjgl3Preferences( new Lwjgl3FileHandle( new File(config.preferencesDirectory, name), config.preferencesFileType)); preferences.put(name, prefs); return prefs; } }
private TextureRegion getAtlasRegion(AtlasRegionAsset asset) { String relativePath = asset.getPath(); TextureAtlas atlas = atlases.get(relativePath); if (atlas == null) return missingRegion; if (asset.getRegionName() == null) { return new TextureRegion(atlas.getTextures().first()); } else { TextureRegion region = atlas.findRegion(asset.getRegionName()); if (region == null) return missingRegion; return region; } }
public static void render(DebugRenderContext context, AudioSourceComponent sourceComponent) { Application app = Gdx.app; if (app == null) { return; } AudioDebugRenderer renderer = instances.get(app); if (renderer == null) { renderer = new AudioDebugRenderer(); instances.put(app, renderer); } renderer.renderSource(context, sourceComponent); }
public void updateBinding(int keycode) { ObjectMap<String, Binding> bindings = game.getBindings(); Binding binding = bindings.get(this.focusedAction); String character = game.map.get(keycode); if (character != null) { binding.character = character; binding.keyCode = keycode; System.out.println( "Updating action: " + this.focusedAction + " to " + keycode + " " + binding.character); bindings.put(focusedAction, binding); } else { System.out.println("Couldnt map character: " + keycode); } }
private TextureRegion getCachedGfxRegion(TextureRegionAsset asset) { String relativePath = asset.getPath(); String regionName = FileUtils.removeFirstSeparator(FilenameUtils.removeExtension(relativePath)); TextureRegion region = regions.get(regionName); if (region == null) { if (cache != null) region = cache.findRegion(regionName); if (region == null) region = new TextureRegion(loadingRegion); regions.put(relativePath, region); } return region; }
private void updateAtlas(FileHandle file) { String relativePath = fileAccess.relativizeToAssetsFolder(file); TextureAtlas atlas = atlases.get(relativePath); if (atlas != null) { atlases.remove(relativePath); atlas.dispose(); } if (file.exists()) { atlases.put(relativePath, new TextureAtlas(file)); App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURES)); App.eventBus.post(new ResourceReloadedEvent(ResourceReloadedEvent.RESOURCE_TEXTURE_ATLASES)); } }
private void continueConversation(DialogBox last) { DialogBox next; currentDialog++; if (currentDialog == conversation.length) { for (DialogBox value : people.values().toArray()) value.setCallback(null); if (callback != null) callback.onCompleted(); return; } next = people.get(speakingOrder[currentDialog]); next.setText(conversation[currentDialog]); last.setVisible(false); next.setVisible(true); }
public void addListener(File root, RootNameListener listener) { String cachedName = nameCache.get(root); if (cachedName != null) { listener.setRootName(cachedName); return; } ListenerSet set = listeners.get(root); if (set == null) { set = new ListenerSet(); listeners.put(root, set); } set.add(listener); processRoot(root); }
public void startConversation() { currentDialog = 0; for (DialogBox value : people.values().toArray()) { value.setVisible(false); value.setCallback( new DialogCallback() { @Override public void onEvent(int type, DialogBox source) { if (type == DialogCallback.CLICKED_AFTER_END) continueConversation(source); } }); } DialogBox first = people.get(speakingOrder[currentDialog]); first.setText(conversation[currentDialog]); first.setVisible(true); }
@Override public Actor getUIByField(Class type, Field field) { return views.get(field); }
public Texture obtenirImatge(String nom) { return imatges.get(nom); }
protected Material convertMaterial(ModelMaterial mtl, TextureProvider textureProvider) { Material result = new Material(); result.id = mtl.id; if (mtl.ambient != null) result.set(new ColorAttribute(ColorAttribute.Ambient, mtl.ambient)); if (mtl.diffuse != null) result.set(new ColorAttribute(ColorAttribute.Diffuse, mtl.diffuse)); if (mtl.specular != null) result.set(new ColorAttribute(ColorAttribute.Specular, mtl.specular)); if (mtl.emissive != null) result.set(new ColorAttribute(ColorAttribute.Emissive, mtl.emissive)); if (mtl.reflection != null) result.set(new ColorAttribute(ColorAttribute.Reflection, mtl.reflection)); if (mtl.shininess > 0f) result.set(new FloatAttribute(FloatAttribute.Shininess, mtl.shininess)); if (mtl.opacity != 1.f) result.set( new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, mtl.opacity)); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); // FIXME uvScaling/uvTranslation totally ignored if (mtl.textures != null) { for (ModelTexture tex : mtl.textures) { Texture texture; if (textures.containsKey(tex.fileName)) { texture = textures.get(tex.fileName); } else { texture = textureProvider.load(tex.fileName); textures.put(tex.fileName, texture); disposables.add(texture); } TextureDescriptor descriptor = new TextureDescriptor(texture); descriptor.minFilter = texture.getMinFilter(); descriptor.magFilter = texture.getMagFilter(); descriptor.uWrap = texture.getUWrap(); descriptor.vWrap = texture.getVWrap(); float offsetU = tex.uvTranslation == null ? 0f : tex.uvTranslation.x; float offsetV = tex.uvTranslation == null ? 0f : tex.uvTranslation.y; float scaleU = tex.uvScaling == null ? 1f : tex.uvScaling.x; float scaleV = tex.uvScaling == null ? 1f : tex.uvScaling.y; switch (tex.usage) { case ModelTexture.USAGE_DIFFUSE: result.set( new TextureAttribute( TextureAttribute.Diffuse, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_SPECULAR: result.set( new TextureAttribute( TextureAttribute.Specular, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_BUMP: result.set( new TextureAttribute( TextureAttribute.Bump, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_NORMAL: result.set( new TextureAttribute( TextureAttribute.Normal, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_AMBIENT: result.set( new TextureAttribute( TextureAttribute.Ambient, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_EMISSIVE: result.set( new TextureAttribute( TextureAttribute.Emissive, descriptor, offsetU, offsetV, scaleU, scaleV)); break; case ModelTexture.USAGE_REFLECTION: result.set( new TextureAttribute( TextureAttribute.Reflection, descriptor, offsetU, offsetV, scaleU, scaleV)); break; } } } return result; }
public TextureAtlas getAtlas(String relativePath) { return atlases.get(relativePath); }
public boolean cmpKeys(String keyName, int inKey) { int[] arr = keys.get(keyName); for (int a : arr) if (a == inKey) return true; return false; }
@Override public TextureAtlas getAtlas(String name) { return atlases.get(name); }
/** @return May be null. */ public Attachment getAttachment(int slotIndex, String name) { if (slotIndex < 0) throw new IllegalArgumentException("slotIndex must be >= 0."); lookup.set(slotIndex, name); return attachments.get(lookup); }