List of usage examples for com.badlogic.gdx.utils ObjectMap keys
public Keys<K> keys()
From source file:com.ahsgaming.starbattle.json.Utils.java
License:Apache License
public static String toJsonProperty(String key, Object value) { String valueStr = value.toString(); if (value instanceof ObjectMap) { valueStr = "{"; ObjectMap<String, Object> om = (ObjectMap<String, Object>) value; for (String k : om.keys()) { valueStr += toJsonProperty(k, om.get(k)); }// www .ja v a 2 s .c o m valueStr += "}"; } else if (value instanceof Array) { valueStr = "["; Array<Object> oa = (Array<Object>) value; for (Object o : oa) { valueStr += toJsonProperty(null, o); } valueStr += "]"; } if (value instanceof String) return (key != null ? "\"" + key + "\":" : "") + "\"" + valueStr + "\","; return (key != null ? "\"" + key + "\":" : "") + valueStr + ","; }
From source file:com.ahsgaming.valleyofbones.TextureManager.java
License:Apache License
public void loadTexturePackage(String name) { map.clear();//from w w w . j av a2s. co m JsonReader jsonReader = new JsonReader(); Object rObj = jsonReader.parse(Gdx.files.internal(name + "/package.json")); ObjectMap<String, Object> mapObjs = (ObjectMap<String, Object>) rObj; for (String key : mapObjs.keys()) { ObjectMap<String, Object> createObj = (ObjectMap<String, Object>) mapObjs.get(key); String file = ""; int x = 0, y = 0, w = 0, h = 0; if (createObj.containsKey("file")) { file = name + "/" + createObj.get("file").toString(); } if (createObj.containsKey("x")) { x = (int) Float.parseFloat(createObj.get("x").toString()); } if (createObj.containsKey("y")) { y = (int) Float.parseFloat(createObj.get("y").toString()); } if (createObj.containsKey("w")) { w = (int) Float.parseFloat(createObj.get("w").toString()); } if (createObj.containsKey("h")) { h = (int) Float.parseFloat(createObj.get("h").toString()); } Gdx.app.log(LOG, String.format("Loading %s from %s", key, file)); map.put(key, loadTextureRegion(file, x, y, w, h)); } }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
void write1ResType(ObjectMap<String, ? extends Object> typeResources, Class<? extends Object> resType, Json json) {/* ww w .java2 s . c om*/ // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { json.writeObjectStart(styleName); write1Style(json, resType, typeResources, styleName); json.writeObjectEnd(); } }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** ?? name */ public String resolveObjectName(Class<?> classType, Object object) { ObjectMap<String, ?> objectMap = super.getAll(classType); if (objectMap == null) { return null; }//from w ww. jav a 2s . c o m Iterator<String> keys = objectMap.keys(); while (keys.hasNext()) { String key = keys.next(); Object obj = objectMap.get(key); if (obj.equals(object)) { return key; } } return null; }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isStyleInUse(Skin skin, String targetStyleName, Class<T> targetStyleClazz) { if (skin == null || targetStyleName == null || targetStyleName.trim().length() == 0 || targetStyleClazz == null) { throw new IllegalArgumentException("skin?targetStyleName and targetStyleClazz can not null"); }//from w w w . j a va 2 s. c om try { for (String widget : widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == targetStyleClazz) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == targetStyleClazz) { @SuppressWarnings("unchecked") T fieldObj = (T) field.get(objStyle); String fieldObjStyleName = skin.find(fieldObj); if (targetStyleName.equals(fieldObjStyleName)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isResInUse(Skin skin, T target) { if (skin == null || target == null) { throw new IllegalArgumentException("skin and target can not null"); }//from w ww .j a va 2s .co m try { Class<?> clazzTarget = target.getClass(); for (String widget : widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == clazzTarget) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == clazzTarget) { @SuppressWarnings("unchecked") T f = (T) field.get(objStyle); if (target.equals(f)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.pastew.autogearbox.handlers.Box2DSprite.java
License:Apache License
/** draws all the {@link Box2DSprite Box2DSprites} on the {@link Body} or {@link Fixture} that hold them in their user data in the given {@link World} */ public static void draw(Batch batch, World world, boolean sortByZ) { @SuppressWarnings("unchecked") Array<Body> tmpBodies = Pools.obtain(Array.class); world.getBodies(tmpBodies);/*from www. j a v a 2 s . c o m*/ if (sortByZ) { @SuppressWarnings("unchecked") ObjectMap<Box2DSprite, Object> tmpZMap = Pools.obtain(ObjectMap.class); tmpZMap.clear(); for (Body body : tmpBodies) { Box2DSprite tmpBox2DSprite; if ((tmpBox2DSprite = userDataAccessor.apply(body.getUserData())) != null) tmpZMap.put(tmpBox2DSprite, body); for (Fixture fixture : body.getFixtureList()) if ((tmpBox2DSprite = userDataAccessor.apply(fixture.getUserData())) != null) tmpZMap.put(tmpBox2DSprite, fixture); } @SuppressWarnings("unchecked") Array<Box2DSprite> tmpKeys = Pools.obtain(Array.class); Iterator<Box2DSprite> keys = tmpZMap.keys(); while (keys.hasNext()) tmpKeys.add(keys.next()); tmpKeys.sort(zComparator); for (Box2DSprite key : tmpKeys) { Object value = tmpZMap.get(key); if (value instanceof Body) key.draw(batch, (Body) value); else key.draw(batch, (Fixture) value); } tmpKeys.clear(); tmpZMap.clear(); Pools.free(tmpKeys); Pools.free(tmpZMap); } else for (Body body : tmpBodies) { Box2DSprite tmpBox2DSprite; if ((tmpBox2DSprite = userDataAccessor.apply(body.getUserData())) != null) tmpBox2DSprite.draw(batch, body); for (Fixture fixture : body.getFixtureList()) if ((tmpBox2DSprite = userDataAccessor.apply(fixture.getUserData())) != null) tmpBox2DSprite.draw(batch, fixture); } tmpBodies.clear(); Pools.free(tmpBodies); }
From source file:com.sasluca.lcl.utils.collections.LCLMap.java
License:Apache License
public ObjectMap.Keys<KEY> getKeys() { return m_ObjectMap.keys(); }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.graphics.Box2DSprite.java
License:Apache License
/** draws all the {@link Box2DSprite Box2DSprites} on the {@link Body} or {@link Fixture} that hold them in their user data in the given {@link World} */ public static void draw(Batch batch, World world, boolean sortByZ) { @SuppressWarnings("unchecked") Array<Body> tmpBodies = Pools.obtain(Array.class); Box2DSprite tmpBox2DSprite;/* w ww .ja va2 s. c om*/ world.getBodies(tmpBodies); if (sortByZ) { @SuppressWarnings("unchecked") ObjectMap<Box2DSprite, Object> tmpZMap = Pools.obtain(ObjectMap.class); tmpZMap.clear(); for (Body body : tmpBodies) { if ((tmpBox2DSprite = userDataAccessor.apply(body.getUserData())) != null) tmpZMap.put(tmpBox2DSprite, body); for (Fixture fixture : body.getFixtureList()) if ((tmpBox2DSprite = userDataAccessor.apply(fixture.getUserData())) != null) tmpZMap.put(tmpBox2DSprite, fixture); } @SuppressWarnings("unchecked") Array<Box2DSprite> tmpKeys = Pools.obtain(Array.class); Iterator<Box2DSprite> keys = tmpZMap.keys(); while (keys.hasNext()) tmpKeys.add(keys.next()); tmpKeys.sort(zComparator); for (Box2DSprite key : tmpKeys) { Object value = tmpZMap.get(key); if (value instanceof Body) key.draw(batch, (Body) value); else key.draw(batch, (Fixture) value); } tmpKeys.clear(); tmpZMap.clear(); Pools.free(tmpKeys); Pools.free(tmpZMap); } else for (Body body : tmpBodies) { if ((tmpBox2DSprite = userDataAccessor.apply(body.getUserData())) != null) tmpBox2DSprite.draw(batch, body); for (Fixture fixture : body.getFixtureList()) if ((tmpBox2DSprite = userDataAccessor.apply(fixture.getUserData())) != null) tmpBox2DSprite.draw(batch, fixture); } tmpBodies.clear(); Pools.free(tmpBodies); }
From source file:com.vlaaad.dice.game.config.purchases.PurchaseData.java
License:Open Source License
public static ObjectMap.Keys<String> skus() { return purchaseInfo.keys(); }