List of usage examples for com.badlogic.gdx.utils ObjectMap entries
public Entries<K, V> entries()
From source file:com.dongbat.game.registry.AbilityRegistry.java
/** * Parse ability info from String that was loaded from load() function * * @param abilityString ability String need to parse */// ww w.j a va 2 s .c o m private static void parseAbility(String abilityString) { String[] frags = abilityString.split("\\r?\\n"); ObjectMap<String, String> common = new ObjectMap<String, String>(); ObjectMap<Integer, ObjectMap<String, String>> levelMaps = new ObjectMap<Integer, ObjectMap<String, String>>(); ObjectMap<String, String> abilityData; for (String frag : frags) { String[] split = frag.split(":"); common.put(split[0].trim(), split[1].trim()); } String name = common.remove("name"); String clazz = common.remove("class"); for (ObjectMap.Entry<String, String> entry : common.entries()) { String[] phongs = entry.value.split("\\|"); abilityData = new ObjectMap<String, String>(); for (String phong : phongs) { String[] minh = phong.split("="); abilityData.put(minh[0].trim(), minh[1].trim()); } levelMaps.put(Integer.parseInt(entry.key.trim()), abilityData); } registry.put(name, new Entry(clazz, levelMaps)); }
From source file:com.dongbat.game.registry.BuffRegistry.java
/** * Parse buff info from String that was loaded from load() function * * @param buffString buff String need to parse *//*w w w . j av a 2s .com*/ public static void parseBuffs(String buffString) { String[] lines = buffString.split("\\r?\\n"); ObjectMap<String, String> common = new ObjectMap<String, String>(); ObjectMap<Integer, ObjectMap<String, String>> levelMaps = new ObjectMap<Integer, ObjectMap<String, String>>(); ObjectMap<String, String> buffData; for (String line : lines) { String[] split = line.split(":"); common.put(split[0], split[1]); } String name = common.remove("name"); String clazz = common.remove("class"); for (ObjectMap.Entry<String, String> entry : common.entries()) { String[] phongs = entry.value.split("\\|"); buffData = new ObjectMap<String, String>(); for (String phong : phongs) { String[] minh = phong.split("="); buffData.put(minh[0].trim(), minh[1].trim()); } levelMaps.put(Integer.parseInt(entry.key.trim()), buffData); } registry.put(name, new Entry(clazz, levelMaps)); }
From source file:com.kotcrab.vis.editor.serializer.cloner.ObjectMapCloner.java
License:Apache License
@Override protected ObjectMap cloneObject(ObjectMap original, IDeepCloner cloner, Map<Object, Object> clones) { ObjectMap copy = new ObjectMap(); for (Object o : original.entries()) { Entry entry = (Entry) o;//from w w w . j av a 2 s. c o m copy.put(cloner.deepClone(entry.key, clones), cloner.deepClone(entry.value, clones)); } return copy; }
From source file:com.kotcrab.vis.editor.serializer.json.ObjectMapJsonSerializer.java
License:Apache License
@Override public JsonElement serialize(ObjectMap<K, V> objMap, Type typeOfSrc, JsonSerializationContext context) { JsonArray jsonArray = new JsonArray(); for (ObjectMap.Entry<K, V> entry : objMap.entries()) { JsonObject jsonObject = new JsonObject(); jsonObject.add("key", context.serialize(entry.key, entry.key.getClass())); jsonObject.add("value", context.serialize(entry.value, entry.value.getClass())); GsonUtils.appendClassProperty(jsonObject, entry.key, context, PROPERTY_CLASS_KEY); GsonUtils.appendClassProperty(jsonObject, entry.value, context, PROPERTY_CLASS_VALUE); jsonArray.add(jsonObject);//from w w w. ja v a 2 s . c om } return jsonArray; }
From source file:com.stercore.code.net.dermetfan.utils.libgdx.maps.TileAnimator.java
License:Apache License
/** sorts the frames of the animation by their orderedKey value if it exists * @param animations the animations to sort * @param orderedKey the key of the frame property * @return the animations with sorted frames * @see #sortFrames(Array, String) */ public static ObjectMap<String, Array<StaticTiledMapTile>> sortFrames( ObjectMap<String, Array<StaticTiledMapTile>> animations, String orderedKey) { Entry<String, Array<StaticTiledMapTile>> entry; Entries<String, Array<StaticTiledMapTile>> entries = animations.entries(); while (entries.hasNext) { entry = entries.next();//from ww w . j av a 2 s . com for (StaticTiledMapTile entryTile : entry.value) if (entryTile.getProperties().containsKey(orderedKey)) { sortFrames(entry.value, orderedKey); break; } } return animations; }
From source file:com.uwsoft.editor.data.manager.TextureManager.java
License:Apache License
public void loadCurrentProjectSkin(String fontPath) { // projectSkin = DataManager.getInstance().getSkinFromStyle(); File styleFile = new File(fontPath, "styles.dt"); FileHandle f = new FileHandle(styleFile); if (styleFile.isFile() && styleFile.exists()) { //System.out.println(f.readString()); projectSkin = new MySkin(f); ObjectMap<String, BitmapFont> map = projectSkin.getAll(BitmapFont.class); for (Entry<String, BitmapFont> entry : map.entries()) { projectSkin.getFont(entry.key).getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); }//from w w w. j a v a 2 s .c o m } }
From source file:com.vlaaad.dice.PvpPlayStateCallback.java
License:Open Source License
@Override public void onWin(BaseLevelDescription level, LevelResult result, ObjectMap<Player, IParticipant> playersToParticipants, final PvpPlayState.RestartCallback callback) { Array<RewardResult> rewards = app.applyLevelResult(level, result, true); Array<IParticipant> opponents = new Array<IParticipant>(); for (ObjectMap.Entry<Player, IParticipant> e : playersToParticipants.entries()) { if (e.key.inRelation(result.viewer, PlayerRelation.enemy)) { opponents.add(e.value);// ww w .j a v a 2 s.c o m } } String shareText = Config.thesaurus.localize("pvp-share", Thesaurus.params() .with("opponents", Thesaurus.Util.enumerate(Config.thesaurus, opponents, IParticipant.STRINGIFIER)) .with("pvp-cant-stop-me", opponents.size > 1 ? "pvp-cant-stop-me.many" : "pvp-cant-stop-me.one")); Config.mobileApi.services().incrementScore("CgkIsNnQ2ZcKEAIQFw", 1) .addListener(new IFutureListener<Boolean>() { @Override public void onHappened(Boolean success) { Logger.debug("todo"); } }); winWindow = new PvpWinWindow(); winWindow.show(new PvpWinWindow.Params(rewards, shareText, result, new PvpWinWindow.Callback() { @Override public void onClose() { winWindow = null; app.setState(app.gameMapState); } @Override public void onRestart() { winWindow = null; callback.onRestart(); } }, app.userData)); }
From source file:com.vlaaad.dice.states.PvpPlayState.java
License:Open Source License
public void prepare(LevelDescription level, ObjectMap<IParticipant, Fraction> fractions, int seed) { if (prepareFuture != null) prepareFuture.happen();// ww w . j a va 2 s .c om this.level = level; ObjectMap<Fraction, Player> players = new ObjectMap<Fraction, Player>(); Player viewer = null; for (ObjectMap.Entry<IParticipant, Fraction> e : fractions.entries()) { Fraction f = e.value; Player player = new Player(f, level.relations.get(f)); if (e.key == session.getMe()) { viewer = player; } participantsToPlayers.put(e.key, player); playersToParticipants.put(player, e.key); players.put(f, player); } if (viewer == null) throw new IllegalStateException("WTF! viewer is null!"); viewer.setPotions(userData.potions); for (Die die : userData.dice()) { viewer.addDie(die); } world = new World(viewer, players, PlayerHelper.defaultColors, level, stage); world.addController(ViewController.class); world.addController(CreatureInfoController.class); world.init(); world.addController(PvpLoadLevelController.class); world.addController(SpawnController.class); world.addController(new RandomController(world, seed)); world.dispatcher.add(SpawnController.START, new EventListener<Void>() { @Override public void handle(EventType<Void> type, Void aVoid) { world.removeController(SpawnController.class); showPrepareWindow(); listener.sendToServer(new SpawnedToServer(world.viewer)); } }); }
From source file:es.eucm.ead.editor.assets.ApplicationAssets.java
License:Open Source License
/** * Loads and returns the Preferences object for the application. This method * loads user-defined preferences by using libgdx's support. These prefs * work across platforms. In desktop, these preferences are typically stored * in a ".prefs" folder under the user's home dir (e.g. * "C:/Users/Javier/.prefs/{@value #PREFERENCES_NAME}"). * /*www.j av a 2s . c o m*/ * Before returning these preferences, a set of default properties stored in * json format (in file {@link #DEFAULT_PREFERENCES_FILE}) are added, in * case they are not present. * * @return The {@link es.eucm.ead.editor.control.Preferences} object for the * controller. */ public Preferences loadPreferences() { // Load default preferences. The default preferences are stored in a // json file under the // path DEFAULT_PREFERENCES_FILE (e.g. "preferences.json"). This file // looks similar to this: /* * { "windowMaximized": true, "windowWidth": 800, "windowHeight": 600 } */ // Where the part before : means the key for the preference and the part // after : is the value FileHandle preferencesFile = resolve(DEFAULT_PREFERENCES_FILE); ObjectMap<String, Object> defaultPreferences = new Json().fromJson(ObjectMap.class, preferencesFile); /* * Load user preferences. For this, libGDX's support is used. LibGDX * stores the preferences persistently ina file called PREFERENCES_NAME * under a folder ".prefs" that is usually located on the user's main * folder */ com.badlogic.gdx.Preferences libGDXPreferences = Gdx.app.getPreferences(PREFERENCES_NAME); // Combine default and user-defined preferences. All default preferences // not present in // user-defined prefs are added to the libgdx's object for (ObjectMap.Entry<String, Object> e : defaultPreferences.entries()) { if (!libGDXPreferences.contains(e.key)) { if (e.value.getClass() == Boolean.class) { libGDXPreferences.putBoolean(e.key, (Boolean) e.value); } else if (e.value.getClass() == Integer.class) { libGDXPreferences.putInteger(e.key, (Integer) e.value); } else if (e.value.getClass() == Float.class) { libGDXPreferences.putFloat(e.key, (Float) e.value); } else { libGDXPreferences.putString(e.key, e.value.toString()); } } } // Return the preferences object, a wrapper for libGDX's preferences // object return new Preferences(libGDXPreferences); }
From source file:es.eucm.ead.engine.assets.loaders.ExtendedSkinLoader.java
License:Open Source License
@Override public Skin loadSync(AssetManager manager, String fileName, FileHandle file, SkinParameter parameter) { String textureAtlasPath;/* ww w . j ava2 s . c o m*/ ObjectMap<String, Object> resources; if (parameter == null) { textureAtlasPath = file.pathWithoutExtension() + ".atlas"; resources = null; } else { textureAtlasPath = parameter.textureAtlasPath; resources = parameter.resources; } TextureAtlas atlas = manager.get(textureAtlasPath, TextureAtlas.class); Skin skin = new ExtendedSkin(assets, atlas); if (resources != null) { for (Entry<String, Object> entry : resources.entries()) { skin.add(entry.key, entry.value); } } skin.load(file); return skin; }