List of usage examples for com.badlogic.gdx.utils Json setOutputType
public void setOutputType(OutputType outputType)
From source file:com.bladecoder.engine.model.World.java
License:Apache License
public void saveWorldDesc(FileHandle file) throws IOException { float scale = EngineAssetManager.getInstance().getScale(); Json json = new Json(); json.setOutputType(OutputType.javascript); SerializationHelper.getInstance().setMode(Mode.MODEL); json.setWriter(new StringWriter()); json.writeObjectStart();/*from ww w .j a v a 2 s.co m*/ json.writeValue("width", width / scale); json.writeValue("height", height / scale); json.writeValue("initChapter", initChapter); verbs.write(json); json.writeObjectEnd(); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(json.getWriter().getWriter().toString()); else s = json.getWriter().getWriter().toString(); Writer w = file.writer(false, "UTF-8"); w.write(s); w.close(); }
From source file:com.bladecoder.engine.model.World.java
License:Apache License
public void saveGameState(String filename) throws IOException { EngineLogger.debug("SAVING GAME STATE"); if (disposed) return;/* w w w .j a v a 2 s. com*/ Json json = new Json(); json.setOutputType(OutputType.javascript); String s = null; SerializationHelper.getInstance().setMode(Mode.STATE); if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer w = EngineAssetManager.getInstance().getUserFile(filename).writer(false, "UTF-8"); try { w.write(s); w.close(); } catch (IOException e) { throw new IOException("ERROR SAVING GAME", e); } // Save Screenshot takeScreenshot(filename + ".png", SCREENSHOT_DEFAULT_WIDTH); }
From source file:com.bladecoder.engine.model.World.java
License:Apache License
public void saveModel(String chapterId) throws IOException { EngineLogger.debug("SAVING GAME MODEL"); if (disposed) return;//from w w w . j a v a 2s . c o m Json json = new Json(); json.setOutputType(OutputType.javascript); String s = null; SerializationHelper.getInstance().setMode(Mode.MODEL); if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer w = EngineAssetManager.getInstance().getModelFile(chapterId + EngineAssetManager.CHAPTER_EXT) .writer(false, "UTF-8"); try { w.write(s); w.close(); } catch (IOException e) { throw new IOException("ERROR SAVING MODEL", e); } }
From source file:com.mbrlabs.mundus.core.RuntimeExporter.java
License:Apache License
public static void export(KryoManager kryoManager, ProjectContext projectContext, FileHandle destFolder, boolean prettyPrint) throws IOException { ProjectDTO dto = new ProjectDTO(); dto.setName(projectContext.name);//from w w w .j a v a2s . com // models ModelDTO[] models = new ModelDTO[projectContext.models.size]; for (int i = 0; i < models.length; i++) { models[i] = convert(projectContext.models.get(i)); } dto.setModels(models); // terrains TerrainDTO[] terrains = new TerrainDTO[projectContext.terrains.size]; for (int i = 0; i < terrains.length; i++) { terrains[i] = convert(projectContext.terrains.get(i)); } dto.setTerrains(terrains); // textures TextureDTO[] textures = new TextureDTO[projectContext.textures.size]; for (int i = 0; i < textures.length; i++) { textures[i] = convert(projectContext.textures.get(i)); } dto.setTextures(textures); // scenes SceneDTO[] scenes = new SceneDTO[projectContext.scenes.size]; for (int i = 0; i < scenes.length; i++) { String name = projectContext.scenes.get(i); Scene scene = DescriptorConverter.convert(kryoManager.loadScene(projectContext, name), projectContext.terrains, projectContext.models); scenes[i] = convert(scene); } dto.setScenes(scenes); // write JSON if (!destFolder.exists()) { destFolder.mkdirs(); } FileHandle jsonOutput = Gdx.files.absolute(FilenameUtils.concat(destFolder.path(), "mundus")); OutputStream outputStream = new FileOutputStream(jsonOutput.path()); Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); String output = prettyPrint ? json.prettyPrint(dto) : json.toJson(dto); IOUtils.write(output, outputStream); // copy assets FileHandle assetOutput = Gdx.files.absolute(FilenameUtils.concat(destFolder.path(), "assets")); Gdx.files.absolute(FilenameUtils.concat(projectContext.path, "assets")).copyTo(assetOutput); }
From source file:com.o2d.pkayjava.editor.data.vo.EditorConfigVO.java
License:Apache License
public String constructJsonString() { String str = ""; Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); str = json.prettyPrint(this); return str;/*from w ww . j a v a 2s. c o m*/ }
From source file:com.o2d.pkayjava.editor.data.vo.ProjectVO.java
License:Apache License
public String constructJsonString() { String str = ""; Json json = new Json(); json.setOutputType(OutputType.json); str = json.prettyPrint(this); return str;/* w w w .ja va 2 s . c o m*/ }
From source file:com.strategames.engine.storage.GameMetaData.java
License:Open Source License
public String getJson() { Json json = new Json(); json.setOutputType(OutputType.minimal); return json.toJson(this); }
From source file:com.strategames.engine.utils.Level.java
License:Open Source License
@Override public String getJson() { Json json = new Json(); json.setOutputType(OutputType.minimal); return json.toJson(this); }
From source file:com.uwsoft.editor.data.vo.EditorConfigVO.java
License:Apache License
public String constructJsonString() { String str = ""; Json json = new Json(); json.setOutputType(JsonWriter.OutputType.json); str = json.toJson(this); return str;//from w w w .ja v a2 s. c om }
From source file:com.uwsoft.editor.data.vo.ProjectVO.java
License:Apache License
public String constructJsonString() { String str = ""; Json json = new Json(); json.setOutputType(OutputType.json); str = json.toJson(this); return str;/* w w w . j a v a 2s .c o m*/ }