List of usage examples for com.badlogic.gdx.utils Json writeArrayStart
public void writeArrayStart(String name)
From source file:com.bladecoder.engine.model.Verb.java
License:Apache License
@Override public void write(Json json) { if (SerializationHelper.getInstance().getMode() == Mode.MODEL) { json.writeValue("id", id); json.writeValue("target", target); json.writeValue("state", state); json.writeValue("icon", icon); json.writeArrayStart("actions"); for (Action a : actions) { ActionUtils.writeJson(a, json); }//from ww w . j ava2 s .c o m json.writeArrayEnd(); } else { json.writeValue("ip", ip); json.writeArrayStart("actions"); for (Action a : actions) { if (a instanceof Serializable) { json.writeObjectStart(); ((Serializable) a).write(json); json.writeObjectEnd(); } } json.writeArrayEnd(); } }
From source file:com.github.fauu.helix.manager.AreaManager.java
License:Open Source License
public void create(String name, int width, int length) { Json json = new Json(); IntVector2 dimensions = new IntVector2(width, length); FileHandle file = Gdx.files.internal("area/" + name + ".json"); try {/*from w w w . j ava 2 s . c o m*/ json.setWriter(new JsonWriter(new FileWriter(file.file()))); } catch (IOException e) { e.printStackTrace(); } json.writeObjectStart(); json.writeValue("width", dimensions.x); json.writeValue("length", dimensions.y); json.writeArrayStart("tiles"); for (int y = 0; y < dimensions.y; y++) { for (int x = 0; x < dimensions.x; x++) { json.writeObjectStart(); json.writeValue("permissions", TilePermission.LEVEL0.toString()); json.writeObjectEnd(); } } json.writeArrayEnd(); json.writeObjectEnd(); try { json.getWriter().close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.github.fauu.helix.manager.AreaManager.java
License:Open Source License
public void save() { Json json = new Json(); String name = nameMapper.get(area).get(); FileHandle file = Gdx.files.internal("area/" + name + ".json"); IntVector2 dimensions = dimensionsMapper.get(area).get(); AreaType type = areaTypeMapper.get(area).get(); try {/*from ww w.jav a 2s.c om*/ json.setWriter(new JsonWriter(new FileWriter(file.file()))); } catch (IOException e) { e.printStackTrace(); } json.writeObjectStart(); json.writeValue("width", dimensions.x); json.writeValue("length", dimensions.y); json.writeValue("type", type); json.writeArrayStart("tiles"); Tile[][] tiles = tilesMapper.get(area).get(); for (int y = 0; y < dimensions.y; y++) { for (int x = 0; x < dimensions.x; x++) { Tile tile = tiles[y][x]; json.writeObjectStart(); json.writeValue("permissions", tile.getPermissions().toString()); if (tile.getAreaPassage() != null) { TileAreaPassage passage = tile.getAreaPassage(); json.writeObjectStart("passage"); json.writeValue("area", passage.getTargetAreaName()); json.writeObjectStart("position"); json.writeValue("x", passage.getTargetCoords().x); json.writeValue("y", passage.getTargetCoords().y); json.writeObjectEnd(); json.writeObjectEnd(); } json.writeObjectEnd(); } } json.writeArrayEnd(); json.writeObjectEnd(); try { json.getWriter().close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.jupiter.europa.entity.component.EffectsComponent.java
License:Open Source License
@Override public void write(Json json) { json.writeArrayStart(EFFECTS_KEY); this.effects.stream().forEach((Effect effect) -> { json.writeObjectStart();/*from ww w . java 2 s . com*/ json.writeValue(EFFECT_CLASS_KEY, effect.getClass().getName()); json.writeValue(EFFECT_DATA_KEY, effect, effect.getClass()); json.writeObjectEnd(); }); json.writeArrayEnd(); }
From source file:com.jupiter.europa.entity.effects.MultiEffect.java
License:Open Source License
@Override public void write(Json json) { json.writeArrayStart(EFFECTS_KEY); for (Effect effect : this.effects) { json.writeObjectStart();/*from ww w . j a v a 2 s . c o m*/ json.writeValue(EFFECT_CLASS_KEY, effect.getClass().getName()); json.writeValue(EFFECT_DATA_KEY, effect, effect.getClass()); json.writeObjectEnd(); } json.writeArrayEnd(); }
From source file:com.jupiter.europa.entity.EuropaEntity.java
License:Open Source License
@Override public void write(Json json) { json.writeValue(OLD_ID_KEY, this.getId()); json.writeArrayStart(COMPONENTS_KEY); for (Component component : this.getComponents()) { if (component instanceof Serializable) { json.writeObjectStart();//from w w w . j av a 2s .co m json.writeValue(COMPONENT_CLASS_KEY, component.getClass().getName()); json.writeValue(COMPONENT_DATA_KEY, component, component.getClass()); json.writeObjectEnd(); } } json.writeArrayEnd(); }
From source file:com.jupiter.europa.entity.Party.java
License:Open Source License
@Override public void write(Json json) { json.writeValue(PARTY_MEMBERS_KEY, this.partyMembers, HashMap.class); json.writeArrayStart(ACTIVE_PARTY_MEMBERS_KEY); for (EuropaEntity entity : this.getActivePartyMembers()) { json.writeValue(Mappers.name.get(entity).getName()); }//from w w w . ja v a 2 s. c o m json.writeArrayEnd(); }
From source file:com.jupiter.europa.entity.trait.TraitPool.java
License:Open Source License
@Override public void write(Json json) { json.writeValue(CAPACITY_KEY, this.capacity); json.writeArrayStart(SELECTED_KEY); this.selected.stream().forEach((T item) -> { json.writeObjectStart();/* w w w . j a va 2 s . c o m*/ json.writeValue(ITEM_CLASS_KEY, item.getClass().getName()); json.writeValue(ITEM_DATA_KEY, item, item.getClass()); json.writeObjectEnd(); }); json.writeArrayEnd(); }
From source file:com.strategames.engine.gameobject.types.Door.java
License:Open Source License
@Override protected void writeValues(Json json) { json.writeArrayStart("nextLevelPosition"); json.writeValue(entryLevel[0]);/*from w w w. j ava 2 s . c o m*/ json.writeValue(entryLevel[1]); json.writeArrayEnd(); }
From source file:io.piotrjastrzebski.dungen.DungeonGenerator.java
License:Apache License
public String toJson(JsonWriter.OutputType outputType, boolean pretty) { Json json = new Json(outputType); StringWriter writer = new StringWriter(); json.setWriter(writer);/* w w w . j ava 2s .c o m*/ json.writeObjectStart(); json.writeValue("grid-size", settings.getGridSize()); json.writeArrayStart("rooms"); for (Room room : rooms) { if (room.isUnused()) continue; json.writeObjectStart(); json.writeValue("id", room.id); if (room.isMain) { json.writeValue("type", "main"); } else if (room.isHallway) { json.writeValue("type", "hallway"); } else if (room.isExtra) { json.writeValue("type", "extra"); } json.writeValue("bounds", room.bounds); json.writeObjectEnd(); } json.writeArrayEnd(); json.writeArrayStart("paths"); for (HallwayPath path : paths) { json.writeObjectStart(); json.writeValue("id", path.id); json.writeValue("start-room", path.roomA.id); json.writeValue("end-room", path.roomB.id); json.writeValue("start", path.start); if (path.hasBend) { json.writeValue("mid", path.bend); } json.writeValue("end", path.end); json.writeArrayStart("overlaps"); for (Room room : path.overlap) { json.writeValue(room.id); } json.writeArrayEnd(); json.writeObjectEnd(); } json.writeArrayEnd(); json.writeObjectEnd(); if (pretty) { return json.prettyPrint(writer.toString()); } else { return writer.toString(); } }