use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class MetaData method read.
@Override
public void read(Json json, JsonValue jsonData) {
JsonValue arr = jsonData.get("scopeDefaults");
int iter = 0;
for (JsonValue item : arr) {
NumericalValue val = new NumericalValue();
val.set(item.get(0).asFloat(), item.get(1).asFloat(), item.get(2).asFloat(), item.get(3).asFloat());
TalosMain.Instance().globalScope.setDynamicValue(iter++, val);
}
// preview widget stuff
if (jsonData.has("previewCamPos")) {
JsonValue camPos = jsonData.get("previewCamPos");
TalosMain.Instance().UIStage().PreviewWidget().setCameraPos(camPos.getFloat("x", 0), camPos.getFloat("y", 0));
} else {
TalosMain.Instance().UIStage().PreviewWidget().setCameraPos(0, 0);
}
TalosMain.Instance().UIStage().PreviewWidget().setBackgroundImage(jsonData.getString("bgImagePath", null));
TalosMain.Instance().UIStage().PreviewWidget().setGridVisible(jsonData.getBoolean("isGridVisible", true));
TalosMain.Instance().UIStage().PreviewWidget().setImageIsBackground(jsonData.getBoolean("bgImageIsInBack", true));
TalosMain.Instance().UIStage().PreviewWidget().setBgImageSize(jsonData.getFloat("bgImageSize", 10));
TalosMain.Instance().UIStage().PreviewWidget().setGridSize(jsonData.getFloat("gridSize", 1));
TalosMain.Instance().UIStage().PreviewWidget().setCameraZoom(jsonData.getFloat("previewCamZoom", 1.4285715f));
// particle position
ParticleEffectInstance particleEffect = TalosMain.Instance().TalosProject().getParticleEffect();
if (particleEffect != null) {
float pPosX = jsonData.getFloat("particlePositionX", 0);
float pPosY = jsonData.getFloat("particlePositionY", 0);
particleEffect.setPosition(pPosX, pPosY);
}
JsonValue resourcePaths = jsonData.get("resourcePaths");
if (resourcePaths != null) {
iter = 0;
for (JsonValue item : resourcePaths) {
final String filePath = item.asString();
resourcePathStrings.add(filePath);
}
}
}
use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class BoundEffect method read.
@Override
public void read(Json json, JsonValue jsonData) {
String effectName = jsonData.getString("effectName");
String effectPath = parent.getWorkspace().getPath(effectName + ".p");
FileHandle effectHandle = TalosMain.Instance().ProjectController().findFile(effectPath);
this.name = effectName;
if (effectHandle == null || !effectHandle.exists()) {
throw new GdxRuntimeException("Particle effect not found");
}
parent.getWorkspace().registerTalosAssets(effectHandle);
// TODO: refactor this
ParticleEffectDescriptor descriptor = new ParticleEffectDescriptor();
descriptor.setAssetProvider(TalosMain.Instance().TalosProject().getProjectAssetProvider());
descriptor.load(effectHandle);
parent.getWorkspace().getVfxLibrary().put(name, descriptor);
// track this file
TalosMain.Instance().FileTracker().trackFile(effectHandle, parent.getWorkspace().bvb.particleTracker);
this.particleEffectDescriptor = descriptor;
positionAttachment = json.readValue(AttachmentPoint.class, jsonData.get("positionAttachment"));
JsonValue valueAttachmentsJson = jsonData.get("valueAttachments");
for (JsonValue valueAttachmentJson : valueAttachmentsJson) {
AttachmentPoint point = json.readValue(AttachmentPoint.class, valueAttachmentJson);
valueAttachments.add(point);
}
setStartEvent(jsonData.getString("startEvent", ""));
setCompleteEvent(jsonData.getString("completeEvent", ""));
isStandalone = jsonData.getBoolean("isStandalone", false);
isBehind = jsonData.getBoolean("isBehind");
isNested = jsonData.getBoolean("isNested");
// setForever(startEvent.equals("") && completeEvent.equals(""));
}
use of com.badlogic.gdx.utils.JsonValue in project talos by rockbite.
the class OffsetModule method read.
@Override
public void read(Json json, JsonValue jsonData) {
super.read(json, jsonData);
points.clear();
final JsonValue points = jsonData.get("points");
for (JsonValue point : points) {
createPoint(point.get(0).asFloat(), point.get(1).asFloat());
}
final JsonValue low = jsonData.get("low");
final JsonValue high = jsonData.get("high");
lowEdge = low.getBoolean("edge");
highEdge = high.getBoolean("edge");
lowShape = low.getInt("shape");
highShape = high.getInt("shape");
lowSide = low.getInt("side");
highSide = high.getInt("side");
final JsonValue lowRect = low.get("rect");
final JsonValue highRect = high.get("rect");
lowPos.set(lowRect.getFloat("x"), lowRect.getFloat("y"));
lowSize.set(lowRect.getFloat("width"), lowRect.getFloat("height"));
highPos.set(highRect.getFloat("x"), highRect.getFloat("y"));
highSize.set(highRect.getFloat("width"), highRect.getFloat("height"));
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class ElementUtils method cloneElement.
public static Object cloneElement(Object e) {
Json json = new BladeJson(Ctx.project.getWorld(), Mode.MODEL);
if (e instanceof Action) {
StringWriter buffer = new StringWriter();
json.setWriter(buffer);
ActionUtils.writeJson((Action) e, json);
String str = buffer.toString();
EditorLogger.debug(str);
JsonValue root = new JsonReader().parse(str);
return ActionUtils.readJson(Ctx.project.getWorld(), json, root);
} else if (e instanceof Scene) {
String str = json.toJson(e, (Class<?>) null);
Scene s = new Scene(((Scene) e).getWorld());
JsonValue root = new JsonReader().parse(str);
s.read(json, root);
return s;
} else {
String str = json.toJson(e, (Class<?>) null);
return json.fromJson(e.getClass(), str);
}
}
use of com.badlogic.gdx.utils.JsonValue in project bladecoder-adventure-engine by bladecoder.
the class ModelTools method extractInkTexts.
public static void extractInkTexts(String file, String lang) throws IOException {
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());
// .tsv generation to help in translation
StringBuilder tsvString = new StringBuilder();
// .md generation to have a better readable document of texts
StringBuilder mdString = new StringBuilder();
OrderedPropertiesBuilder builder = new OrderedPropertiesBuilder();
builder.withSuppressDateInComment(true);
OrderedProperties prop = builder.build();
extractInkTextsInternal(root, tsvString, mdString, prop);
FileUtils.writeStringToFile(new File(file + ".tsv"), tsvString.toString());
FileUtils.writeStringToFile(new File(file + ".txt"), mdString.toString());
String json = root.toJson(OutputType.json);
FileUtils.writeStringToFile(new File(file), json);
try {
String file2 = file.substring(0, file.length() - EngineAssetManager.INK_EXT.length());
if (lang == null || lang.isEmpty() || 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");
}
}
Aggregations