Refine search
@Override public Preferences getPreferences(String name) { if (preferences.containsKey(name)) { return preferences.get(name); } else { Preferences prefs = new HeadlessPreferences(name, this.preferencesdir); preferences.put(name, prefs); return prefs; } }
public void add (String name, Object resource, Class type) { if (name == null) throw new IllegalArgumentException("name cannot be null."); if (resource == null) throw new IllegalArgumentException("resource cannot be null."); ObjectMap<String, Object> typeResources = resources.get(type); if (typeResources == null) { typeResources = new ObjectMap(type == TextureRegion.class || type == Drawable.class || type == Sprite.class ? 256 : 64); resources.put(type, typeResources); } typeResources.put(name, resource); }
/** Sets the value of all localized strings to String placeholder so hardcoded, unlocalized values can be easily spotted. * The I18NBundle won't be able to reset values after calling debug and should only be using during testing. * * @param placeholder */ public void debug(String placeholder) { ObjectMap.Keys<String> keys = properties.keys(); if(keys == null) return; for(String s : keys) { properties.put(s, placeholder); } } }
public boolean has (String name, Class type) { ObjectMap<String, Object> typeResources = resources.get(type); if (typeResources == null) return false; return typeResources.containsKey(name); }
/** Clears the map and reduces the size of the backing arrays to be the specified capacity, if they are larger. The reduction * is done by allocating new arrays, though for large arrays this can be faster than clearing the existing array. */ public void clear (int maximumCapacity) { if (capacity <= maximumCapacity) { clear(); return; } size = 0; resize(maximumCapacity); }
@Override public void beforeGroup (int group, Array<Decal> contents) { if (group == GROUP_BLEND) { Gdx.gl.glEnable(GL20.GL_BLEND); contents.sort(cameraSorter); } else { for (int i = 0, n = contents.size; i < n; i++) { Decal decal = contents.get(i); Array<Decal> materialGroup = materialGroups.get(decal.material); if (materialGroup == null) { materialGroup = arrayPool.obtain(); materialGroup.clear(); usedArrays.add(materialGroup); materialGroups.put(decal.material, materialGroup); } materialGroup.add(decal); } contents.clear(); for (Array<Decal> materialGroup : materialGroups.values()) { contents.addAll(materialGroup); } materialGroups.clear(); arrayPool.freeAll(usedArrays); usedArrays.clear(); } }
public FileHandle[] list (String url, FilenameFilter filter) { Array<FileHandle> files = new Array<FileHandle>(); for (String path : texts.keys()) { if (isChild(path, url) && filter.accept(new File(url), path.substring(url.length() + 1))) { files.add(new GwtFileHandle(this, path, FileType.Internal)); } } FileHandle[] list = new FileHandle[files.size]; System.arraycopy(files.items, 0, list, 0, list.length); return list; }
public V next () { if (!hasNext) throw new NoSuchElementException(); if (!valid) throw new GdxRuntimeException("#iterator() cannot be used nested."); V value = (V)map.get(keys.get(nextIndex)); currentIndex = nextIndex; nextIndex++; hasNext = nextIndex < map.size; return value; }
/** @return all bodies currently in the simulation */ public void getBodies (Array<Body> bodies) { bodies.clear(); bodies.ensureCapacity(this.bodies.size); for (Iterator<Body> iter = this.bodies.values(); iter.hasNext();) { bodies.add(iter.next()); } }
public void create () { json = new Json(); test.stringField = "stringvalue"; test.byteArrayField = new byte[] {2, 1, 0, -1, -2}; test.map = new ObjectMap(); test.map.put("one", 1); test.map.put("two", 2); test.map.put("nine", 9); test.stringArray = new Array(); test.stringArray.add("meow"); test.stringArray.add("moo"); test.objectArray = new Array(); test.objectArray.add("meow"); test.map = new ObjectMap(); roundTrip(test); test.map.put("one", 1); roundTrip(test); test.map.put("two", 2); test.map.put("nine", 9); roundTrip(test); test.map.put("\nst\nuff\n", 9); test.map.put("\r\nst\r\nuff\r\n", 9); roundTrip(test);
/** Returns the reference count of an asset. * @param fileName */ public synchronized int getReferenceCount (String fileName) { Class type = assetTypes.get(fileName); if (type == null) throw new GdxRuntimeException("Asset not loaded: " + fileName); return assets.get(type).get(fileName).getRefCount(); }
@Override protected void onLoaded () { if (currentlyLoading == null || currentlyLoading.isEmpty()) return; instances.clear(); animationControllers.clear(); final ModelInstance instance = new ModelInstance(assets.get(currentlyLoading, Model.class)); for (Material m : instance.materials) m.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, 0.8f)); instances.add(instance); if (instance.animations.size > 0) animationControllers.put(instance, new AnimationController(instance)); currentlyLoading = null; }
public TiledMap load (String fileName) { try { FileHandle tideFile = resolve(fileName); root = xml.parse(tideFile); ObjectMap<String, Texture> textures = new ObjectMap<String, Texture>(); for (FileHandle textureFile : loadTileSheets(root, tideFile)) { textures.put(textureFile.path(), new Texture(textureFile)); } DirectImageResolver imageResolver = new DirectImageResolver(textures); TiledMap map = loadMap(root, tideFile, imageResolver); map.setOwnedResources(textures.values().toArray()); return map; } catch (IOException e) { throw new GdxRuntimeException("Couldn't load tilemap '" + fileName + "'", e); } }
private Object[] getDefaultValues (Class type) { if (!usePrototypes) return null; if (classToDefaultValues.containsKey(type)) return classToDefaultValues.get(type); Object object; try { object = newInstance(type); } catch (Exception ex) { classToDefaultValues.put(type, null); return null; ObjectMap<String, FieldMetadata> fields = getFields(type); Object[] values = new Object[fields.size]; classToDefaultValues.put(type, values); for (FieldMetadata metadata : fields.values()) { Field field = metadata.field; if (readDeprecated && ignoreDeprecated && field.isAnnotationPresent(Deprecated.class)) continue;
public void detach(int aEventType, Listener aListener) { Array<Listener> listeners = mListeners.get(aEventType); if(listeners != null) { listeners.removeValue(aListener, true); if(listeners.size == 0) mListeners.remove(aEventType); } }
/** Creates and adds a new and unique SaveData object to the save data map */ public SaveData createSaveData (String key) { SaveData saveData = new SaveData(this); if (uniqueData.containsKey(key)) throw new RuntimeException("Key already used, data must be unique, use a different key"); uniqueData.put(key, saveData); return saveData; }