public Maps() { json.setOutputType(OutputType.json); json.setElementType(ArrayContainer.class, "maps", Map.class); json.setSerializer(Color.class, new ColorSerializer()); }
/** * リプレイデータを書き込む * * @param rd * リプレイデータ * @param model * 対象のBMS * @param lnmode * LNモード */ public void wrireReplayData(ReplayData rd, BMSModel model, int lnmode, int index) { File replaydir = new File("replay"); if (!replaydir.exists()) { replaydir.mkdirs(); } Json json = new Json(); json.setOutputType(OutputType.json); try { String path = this.getReplayDataFilePath(model, lnmode, index) + ".brd"; OutputStreamWriter fw = new OutputStreamWriter( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(path))), "UTF-8"); fw.write(json.prettyPrint(rd)); fw.flush(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
/** * コースリプレイデータを書き込む * * @param rd * リプレイデータ * @param hash * 対象のBMSハッシュ群 * @param lnmode * LNモード */ public void wrireReplayData(ReplayData[] rd, String[] hash, boolean ln, int lnmode, int index, CourseData.CourseDataConstraint[] constraint) { Json json = new Json(); json.setOutputType(OutputType.json); try { String path = this.getReplayDataFilePath(hash, ln, lnmode, index, constraint) + ".brd"; OutputStreamWriter fw = new OutputStreamWriter( new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(path))), "UTF-8"); fw.write(json.prettyPrint(rd)); fw.flush(); fw.close(); Files.deleteIfExists(Paths.get(this.getReplayDataFilePath(hash, ln, lnmode, index, constraint) + ".json")); Logger.getGlobal().info("コースリプレイを保存:" + path); } catch (IOException e) { e.printStackTrace(); } }
@Override public void save() { ObjectMap<String, AnimationDefinition> newObjects = new ObjectMap<>(); if (rootDefinition.animations == null) { return; } ObjectMap<String, AnimationDefinition> oldObjects = rootDefinition.animations; for (AnimationDefinition item : oldObjects.values()) { newObjects.put(item.getName(), item); } rootDefinition.animations = newObjects; Json json = new Json(); json.setOutputType(OutputType.json); String jsonStr = json.prettyPrint(rootDefinition); Gdx.files.external("umbracraft/" + getTitle().toLowerCase() + ".json").writeString(jsonStr, false); }
@Override public void save() { ObjectMap<String, T> newObjects = new ObjectMap<>(); if (rootDefinition.items() == null) { return; } ObjectMap<String, T> oldObjects = rootDefinition.items(); for (T item : oldObjects.values()) { newObjects.put(item.getName(), item); } rootDefinition.setItems(newObjects); Json json = new Json(); json.setOutputType(OutputType.json); String jsonStr = json.prettyPrint(rootDefinition); Gdx.files.external("umbracraft/" + getTitle().toLowerCase() + ".json").writeString(jsonStr, false); }
private void beforeExport (boolean quick) { json.setUsePrototypes(settings.skipDefaultValues); if (settings.useMinimalOutputType) json.setOutputType(OutputType.minimal); else json.setOutputType(OutputType.json); if (firstExportDone == false && quick) Log.info("Requested quick export but normal export hasn't been done since editor launch, performing normal export."); if (firstExportDone == false || quick == false) doExport(); else doExport(); //TODO do quick export firstExportDone = true; }
/** * Creates an assets handler * * @param files * object granting access to files */ public EditorGameAssets(Files files, ImageUtils imageUtils) { super(files, imageUtils); getI18N().setI18nPath(I18N_PATH); setOutputType(OutputType.json); setIgnores(); }
/** * Writes a JSON document by searching the object for * {@link org.mini2Dx.core.serialization.annotation.Field} annotations * * @param object * The object to convert to JSON * @param prettyPrint * Set to true if the JSON should be prettified * @return The object serialized as JSON * @throws SerializationException * Thrown when the object is invalid */ public <T> String toJson(T object, boolean prettyPrint) throws SerializationException { StringWriter writer = new StringWriter(); Json json = new Json(); json.setOutputType(OutputType.json); json.setWriter(writer); writeObject(null, object, null, json); String result = writer.toString(); try { writer.close(); } catch (IOException e) { throw new SerializationException(e); } if (prettyPrint) { return json.prettyPrint(result); } return result; }
/** * 難易度表データをキャッシュする * * @param td 難易度表データ */ public void write(TableData td) { try { Json json = new Json(); json.setElementType(TableData.class, "folder", ArrayList.class); json.setElementType(TableData.TableFolder.class, "songs", ArrayList.class); json.setElementType(TableData.class, "course", ArrayList.class); json.setElementType(CourseData.class, "trophy", ArrayList.class); json.setOutputType(OutputType.json); OutputStreamWriter fw = new OutputStreamWriter(new BufferedOutputStream( new GZIPOutputStream(new FileOutputStream(tabledir + "/" + td.getName() + ".bmt"))), "UTF-8"); fw.write(json.prettyPrint(td)); fw.flush(); fw.close(); } catch (IOException e) { e.printStackTrace(); } }
public void save (FileHandle handle) { Json json = new Json(); json.setOutputType(OutputType.json); json.setTypeName(null); json.setUsePrototypes(false); json.setIgnoreUnknownFields(true); json.setOutputType(OutputType.json); handle.child("project.json").writeString(json.prettyPrint(this), false); }
/** Makes a String describing the GameObject, usable to create a Prefab * * @param object - the GameObject that should be Serialized * @return the String describing the Prefab */ public static String makePrefab (GameObject object) { Json json = new Json(); json.setOutputType(OutputType.json); String temp = json.toJson(object); int transformStart = ordinalIndexOf(temp, '{', 1); int firstComponentStart = ordinalIndexOf(temp, '{', 2); String finalstring = temp.substring(0, transformStart) + temp.substring(firstComponentStart); return finalstring; }
@Override public void saveProfiles(SuccessListener result) { if (result == null) { throw new NullPointerException("Result cannot be null"); } if (Game.db().config().savePath == null) { throw new NullPointerException("Save path not configured"); } Json json = new Json(); json.setOutputType(OutputType.json); String jsonStr = json.prettyPrint(profiles); Gdx.files.external(Game.db().config().savePath + FILENAME).writeString(jsonStr, false); result.success("Game saved"); }
public void pushRemoteScore(HttpResponseListener responseListener, RemoteScore score) { String url = URL_BASE + "create"; Json json = new Json(OutputType.json); HttpRequest request = requestBuilder.newRequest().method(HttpMethods.POST).url(url).build(); request.setHeader("Content-Type", "application/json"); request.setContent(json.toJson(score, RemoteScore.class)); Gdx.app.debug("Push remote score ", json.toJson(score)); Gdx.net.sendHttpRequest(request, responseListener); }
public static void addScore (String name, int score) { Json json = new Json(); FileHandle scoresFile = Gdx.files.local(SCORES_FILE); List<Player> players = getScores(); PlayerSpec playersSpec = new PlayerSpec(); Player newPlayer = new Player(); newPlayer.setPlayerName(name); newPlayer.setScore(score); players.add(newPlayer); playersSpec.setPlayers(players); json.setOutputType(OutputType.json); scoresFile.writeString(json.prettyPrint(json.toJson(playersSpec)), false, null); scoresReseted = false; }
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(); 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(); }
public void saveGameState(String filename) throws IOException { EngineLogger.debug("SAVING GAME STATE"); if (disposed) return; 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.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING GAME", e); } finally { w.close(); } // Save Screenshot takeScreenshot(filename + ".png", SCREENSHOT_DEFAULT_WIDTH); }
public void saveModel(String chapterId) throws IOException { EngineLogger.debug("SAVING GAME MODEL"); if (disposed) return; 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.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING MODEL", e); } finally { w.close(); } }
@Override public void open() throws IOException { close(); syncFileWriter = syncPropertiesFile.writer(false); asyncFileWriter = asyncPropertiesFile.writer(false); syncJsonWriter = new JsonWriter(syncFileWriter); asyncJsonWriter = new JsonWriter(asyncFileWriter); syncJsonWriter.setOutputType(OutputType.minimal); asyncJsonWriter.setOutputType(OutputType.minimal); syncJsonWriter.array(); asyncJsonWriter.array(); }
@Override public void init () { configFile = fileAccess.getConfigFolder().child("disabledDialogs.json"); json = new Json(); json.addClassTag("String", String.class); json.setOutputType(OutputType.json); if (configFile.file().exists()) { disabledDialogs = json.fromJson(Array.class, configFile); } else { disabledDialogs = new Array<>(); } }
public String toJson() { Json j = new Json(); j.setOutputType(OutputType.json); j.setUsePrototypes(false); j.setElementType(CGCStats.class, "allGames", CGCStatGame.class); return j.toJson(this); }
ExportFormat(String name, OutputType outputType) { this.name = name; this.outputType = outputType; }
public OutputType getOutputType() { return outputType; }
public String toJson (OutputType outputType) { if (isValue()) return asString(); StringBuilder buffer = new StringBuilder(512); json(this, buffer, outputType); return buffer.toString(); }
public String toString () { if (isValue()) return name == null ? asString() : name + ": " + asString(); return (name == null ? "" : name + ": ") + prettyPrint(OutputType.minimal, 0); }
public String prettyPrint (OutputType outputType, int singleLineColumns) { PrettyPrintSettings settings = new PrettyPrintSettings(); settings.outputType = outputType; settings.singleLineColumns = singleLineColumns; return prettyPrint(settings); }
/** * ダイアログの項目をconfig.xmlに反映する */ public void commit() { config.setPlayername(players.getValue()); config.setResolution(resolution.getValue()); config.setFullscreen(fullscreen.isSelected()); config.setVsync(vsync.isSelected()); config.setBga(bgaop.getValue()); config.setBgaExpand(bgaexpand.getValue()); config.setBgmpath(bgmpath.getText()); config.setSoundpath(soundpath.getText()); config.setSystemvolume((float) systemvolume.getValue()); config.setKeyvolume((float) keyvolume.getValue()); config.setBgvolume((float) bgvolume.getValue()); config.setBmsroot(bmsroot.getItems().toArray(new String[0])); config.setUpdatesong(updatesong.isSelected()); config.setTableURL(tableurl.getItems().toArray(new String[0])); config.setShowhiddennote(showhiddennote.isSelected()); config.setAudioDriver(audio.getValue()); config.setAudioDriverName(audioname.getValue()); config.setMaxFramePerSecond(getValue(maxfps)); config.setAudioDeviceBufferSize(getValue(audiobuffer)); config.setAudioDeviceSimultaneousSources(getValue(audiosim)); config.setAudioFreqOption(audioFreqOption.getValue()); config.setAudioFastForward(audioFastForward.getValue()); config.setJudgealgorithm(JudgeAlgorithm.values()[judgealgorithm.getValue()]); config.setAutoSaveReplay( new int[]{autosavereplay1.getValue(),autosavereplay2.getValue(), autosavereplay3.getValue(),autosavereplay4.getValue()}); // jkoc_hack is integer but *.setJKOC needs boolean type config.setCacheSkinImage(usecim.isSelected()); config.setUseSongInfo(useSongInfo.isSelected()); config.setFolderlamp(folderlamp.isSelected()); config.setInputduration(getValue(inputduration)); config.setScrollDutationLow(getValue(scrolldurationlow)); config.setScrollDutationHigh(getValue(scrolldurationhigh)); commitPlayer(); Json json = new Json(); json.setOutputType(OutputType.json); try (FileWriter fw = new FileWriter("config.json")) { fw.write(json.prettyPrint(config)); fw.flush(); } catch (IOException e) { e.printStackTrace(); } }
public void commitPlayer() { if(player == null) { return; } Path p = Paths.get("player/" + player.getId() + "/config.json"); if(playername.getText().length() > 0) { player.setName(playername.getText()); } player.setRandom(scoreop.getValue()); player.setRandom2(scoreop2.getValue()); player.setDoubleoption(doubleop.getValue()); player.setGauge(gaugeop.getValue()); player.setLnmode(lntype.getValue()); player.setFixhispeed(fixhispeed.getValue()); player.setJudgetiming(getValue(judgetiming)); player.setConstant(constant.isSelected()); player.setBpmguide(bpmguide.isSelected()); player.setLegacynote(legacy.isSelected()); player.setJudgewindowrate(getValue(exjudge)); player.setNomine(nomine.isSelected()); player.setMarkprocessednote(markprocessednote.isSelected()); player.setShowjudgearea(judgeregion.isSelected()); player.setTarget(target.getValue()); player.setMisslayerDuration(getValue(misslayertime)); player.setIrname(irname.getValue()); player.setUserid(iruserid.getText()); player.setPassword(irpassword.getText()); player.setIrsend(irsend.getValue()); updateInputConfig(); updatePlayConfig(); skinController.update(player); Json json = new Json(); json.setOutputType(OutputType.json); try (FileWriter fw = new FileWriter(p.toFile())) { fw.write(json.prettyPrint(player)); fw.flush(); } catch (IOException e) { e.printStackTrace(); } }
public NetworkComponent(WebSocketClientInterface networkImpl) { this.networkImpl = networkImpl; serializer.setOutputType(OutputType.json); }
/** * Serializes a Java object to JSON. */ public static String toJson(Object value) { Json json = newJson(); json.setOutputType(OutputType.json); return json.prettyPrint(value); }
public void save() { Json json = new Json(); json.setOutputType(OutputType.json); String jsonStr = json.prettyPrint(rootDefinition); Gdx.files.external("umbracraft/" + getTitle().toLowerCase() + ".json").writeString(jsonStr, false); }
public JsonSerializer() { json.setOutputType(OutputType.javascript); }
public Json () { outputType = OutputType.minimal; }
public Json (OutputType outputType) { this.outputType = outputType; }
public String toString () { if (isValue()) return name == null ? asString() : name + ": " + asString(); else return (name == null ? "" : name + ": ") + prettyPrint(OutputType.minimal, 0); }
private void initializeJson() { json = new Json(); json.setSerializer(TaflMatch.class, new TaflMatchSerializer()); json.setSerializer(Move.class, new TaflMoveSerializer()); json.setOutputType(OutputType.minimal); }
public static void extractInkTexts(String story, String lang) throws IOException { String file = Ctx.project.getModelPath() + "/" + story + EngineAssetManager.INK_EXT; BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); StringBuilder sb = new StringBuilder(); try { String line = br.readLine(); // Replace the BOM mark if (line != null) line = line.replace('\uFEFF', ' '); while (line != null) { sb.append(line); sb.append("\n"); line = br.readLine(); } } finally { br.close(); } JsonValue root = new JsonReader().parse(sb.toString()); StringBuilder tsvString = new StringBuilder(); OrderedPropertiesBuilder builder = new OrderedPropertiesBuilder(); builder.withSuppressDateInComment(true); NewOrderedProperties prop = builder.build(); extractInkTextsInternal(root, tsvString, prop); FileUtils.writeStringToFile(new File(file + ".tsv"), tsvString.toString()); String json = root.toJson(OutputType.json); FileUtils.writeStringToFile(new File(file + ".new"), json); FileUtils.copyFile(new File(file), new File(file + ".old")); FileUtils.copyFile(new File(file + ".new"), new File(file)); new File(file + ".new").delete(); try { String file2 = file.substring(0, file.length() - EngineAssetManager.INK_EXT.length()); if(lang.equals("default")) file2 += "-ink.properties"; else file2 += "-ink" + "_" + lang + ".properties"; FileOutputStream os = new FileOutputStream(file2); Writer out = new OutputStreamWriter(os, I18N.ENCODING); prop.store(out, null); } catch (IOException e) { EditorLogger.error("ERROR WRITING BUNDLE: " + file + ".properties"); } //Ctx.project.setModified(); }
/** @see JsonWriter#setOutputType(OutputType) */ public void setOutputType (OutputType outputType) { this.outputType = outputType; }