Java Code Examples for com.badlogic.gdx.utils.Json#writeObjectEnd()

The following examples show how to use com.badlogic.gdx.utils.Json#writeObjectEnd() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CurveModule.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public void write (Json json) {
    super.write(json);
    json.writeArrayStart("points");
    for (Vector2 point : getPoints()) {
        json.writeObjectStart();
        json.writeValue("x", point.x);
        json.writeValue("y", point.y);
        json.writeObjectEnd();
    }
    json.writeArrayEnd();
}
 
Example 2
Source File: GradientColorModule.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public void write (Json json) {
	super.write(json);
	Array<ColorPoint> points = getPoints();
	json.writeArrayStart("points");
	for (ColorPoint point : points) {
           json.writeObjectStart();
           json.writeValue("r", point.color.r);
           json.writeValue("g", point.color.g);
           json.writeValue("b", point.color.b);
           json.writeValue("pos", point.pos);
           json.writeObjectEnd();
	}
	json.writeArrayEnd();
}
 
Example 3
Source File: OffsetModule.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Json json) {
    super.write(json);

    json.writeArrayStart("points");
    for (Vector2 point : getPoints()) {
        json.writeObjectStart();
        json.writeValue("x", point.x);
        json.writeValue("y", point.y);
        json.writeObjectEnd();
    }
    json.writeArrayEnd();

    json.writeObjectStart("low");
    json.writeValue("edge", lowEdge);
    json.writeValue("shape", lowShape);
    json.writeValue("side", lowSide);
    json.writeObjectStart("rect");
    json.writeValue("x", lowPos.get(0));
    json.writeValue("y", lowPos.get(1));
    json.writeValue("width", lowSize.get(0));
    json.writeValue("height", lowSize.get(1));
    json.writeObjectEnd();
    json.writeObjectEnd();

    json.writeObjectStart("high");
    json.writeValue("edge", highEdge);
    json.writeValue("shape", highShape);
    json.writeValue("side", highSide);
    json.writeObjectStart("rect");
    json.writeValue("x", highPos.get(0));
    json.writeValue("y", highPos.get(1));
    json.writeValue("width", highSize.get(0));
    json.writeValue("height", highSize.get(1));
    json.writeObjectEnd();
    json.writeObjectEnd();
}
 
Example 4
Source File: ModuleWrapper.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
  public void write (Json json) {
json.writeValue("id", getId());
if(!titleOverride.equals("")) {
          json.writeValue("titleOverride", titleOverride);
      }
json.writeValue("x", getX());
json.writeValue("y", getY());

json.writeObjectStart("module", module.getClass(), module.getClass());
json.writeValue("data", module, null);
json.writeObjectEnd();
  }
 
Example 5
Source File: ClientServerMessage.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void write(Json json, ClientServerMessage object, Class knownType) {
    json.writeObjectStart();
    json.writeValue("type", object.type.toString());
    if (object.participantId != null) json.writeValue("participant", object.participantId);
    if (object.data != null) json.writeValue("data", object.data);
    json.writeObjectEnd();
}
 
Example 6
Source File: ScaleFactorJsonSerializer.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Json json, ScaleFactorModel model, Class knownType) {
    json.writeObjectStart();
    json.writeValue("suffix", model.getSuffix());
    json.writeValue("factor", model.getFactor());
    json.writeValue("resampling", model.getResampling().name());
    json.writeObjectEnd();
}
 
Example 7
Source File: Inventory.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Json json) {
	SceneActorRef actorRef;
	
	json.writeValue("visible", visible);

	json.writeObjectStart("items");
	for (SpriteActor a : items) {
		actorRef = new SceneActorRef(a.getInitScene(), a.getId());
		json.writeValue(actorRef.toString(), a);
	}
	json.writeObjectEnd();
}
 
Example 8
Source File: UIActors.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void write(Json json) {
	SceneActorRef actorRef;

	json.writeObjectStart("actors");
	for (InteractiveActor a : actors) {
		actorRef = new SceneActorRef(a.getInitScene(), a.getId());
		json.writeValue(actorRef.toString(), a);
	}
	json.writeObjectEnd();
}
 
Example 9
Source File: JsonDOM.java    From RuinsOfRevenge with MIT License 5 votes vote down vote up
public void writeJsonArray(JsonArray array, Json json) {
	for (JsonObject obj : array.elements) {
		json.writeObjectStart();
		writeJsonObject(obj, json);
		json.writeObjectEnd();
	}
}
 
Example 10
Source File: InputFileSerializer.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Json json, InputFile model, Class knownType) {
    String path = PathUtils.relativize(model.getFileHandle().path(), root.getPath());

    json.writeObjectStart();
    json.writeValue("path", path);
    json.writeValue("type", model.getType().name());

    switch (model.getType()) {
        case Input:
            if (model.isDirectory()) {
                //### Input directory properties
                json.writeValue("dirFilePrefix", model.getDirFilePrefix());
                json.writeValue("recursive", model.isRecursive());
                json.writeValue("flattenPaths", model.isFlattenPaths());
            } else {
                //### Input file properties
                json.writeValue("regionName", model.getRegionName());
                // Ninepatch
                if (model.isProgrammaticNinePatch()) {
                    InputFile.NinePatchProps npp = model.getNinePatchProps();
                    json.writeObjectStart("ninepatch");
                    json.writeArrayStart("splits");
                    json.writeValue(npp.left);
                    json.writeValue(npp.right);
                    json.writeValue(npp.top);
                    json.writeValue(npp.bottom);
                    json.writeArrayEnd();
                    json.writeArrayStart("pads");
                    json.writeValue(npp.padLeft);
                    json.writeValue(npp.padRight);
                    json.writeValue(npp.padTop);
                    json.writeValue(npp.padBottom);
                    json.writeArrayEnd();
                    json.writeObjectEnd();
                }
            }
            break;
        case Ignore:
            //### Ignore file properties
            break;
    }
    json.writeObjectEnd();
}
 
Example 11
Source File: OperationTreeSerializer.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
@Override
public void write(Json json, OperationTree ot, Class knownType) {
	json.writeObjectStart();
	json.writeFields(ot);
	json.writeObjectEnd();
}
 
Example 12
Source File: InterpolationSerializer.java    From artemis-odb-orion with Apache License 2.0 4 votes vote down vote up
static void write(Json json, Interpolation object) {
	json.writeObjectStart(object.getClass(), null);
	json.writeFields(object);
	json.writeObjectEnd();
}
 
Example 13
Source File: ActionUtils.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public static void writeJson(Action a, Json json) {
	Class<?> clazz = a.getClass();
	json.writeObjectStart(clazz, null);
	while (clazz != null && clazz != Object.class) {
		for (Field field : clazz.getDeclaredFields()) {
			final ActionProperty property = field.getAnnotation(ActionProperty.class);
			if (property == null) {
				continue;
			}

			// json.writeField(a, field.getName());
			final boolean accessible = field.isAccessible();
			field.setAccessible(true);

			try {
				Object o = field.get(a);

				// doesn't write null fields
				if (o == null)
					continue;

				if (o instanceof SceneActorRef) {
					SceneActorRef sceneActor = (SceneActorRef) o;
					json.writeValue(field.getName(), sceneActor.toString());
				} else if (o instanceof ActorAnimationRef) {
					ActorAnimationRef aa = (ActorAnimationRef) o;
					json.writeValue(field.getName(), aa.toString());
				} else if (o instanceof Color) {
					json.writeValue(field.getName(), ((Color) o).toString());
				} else if (o instanceof Vector2) {
					json.writeValue(field.getName(), Param.toStringParam((Vector2) o));
				} else {
					json.writeValue(field.getName(), o);
				}
			} catch (IllegalArgumentException | IllegalAccessException e) {

			}

			field.setAccessible(accessible);
		}
		clazz = clazz.getSuperclass();
	}
	json.writeObjectEnd();
}