Java 类com.badlogic.gdx.utils.JsonReader 实例源码

项目:nhglib    文件:SceneLoader.java   
private Scene getScene(byte[] bytes) {
    Scene scene = null;

    try {
        String json = new String(bytes, "UTF-8");

        SceneJson sceneJson = new SceneJson(nhg);
        sceneJson.parse(new JsonReader().parse(json).get("scene"));

        scene = sceneJson.get();
    } catch (UnsupportedEncodingException e) {
        if (Nhg.debugLogs) e.printStackTrace();
    }

    return scene;
}
项目:cachebox3.0    文件:ApiStatusResultParser.java   
public int get(String resultString){
    final AtomicInteger st = new AtomicInteger(-1);
    try {
        (new JsonReader() {
            public void number(String name, long value, String stringValue) {
                super.number(name, value, stringValue);
                if (name.equals("StatusCode")) {
                    st.set((int) value);
                }
            }
        }).parse(resultString);
    } catch (Exception e) {
        LoggerFactory.getLogger(ApiStatusResultParser.class).error("Ask for Api state! Result:{}", resultString);
        e.printStackTrace();
    }
    return st.get();
}
项目:fabulae    文件:AnimationMap.java   
public ObjectMap<Integer, Array<AnimationDescription>> readTextureDescriptor(FileHandle textureDescriptor)
        throws IOException {

    JsonValue descriptor = new JsonReader().parse(textureDescriptor);

    JsonValue frame = descriptor.get("frame");
    frameWidth = frame.getInt("width");
    frameHeight = frame.getInt("height");
    frameDuration = 1 / frame.getFloat("fps");

    JsonValue offset = descriptor.get("middleOffset");
    middleOffset = new Vector2(offset.getInt("x", 0), offset.getInt("y", 0));
    middleOffsets = new ObjectMap<T, Vector2>();

    JsonValue object = descriptor.get("object");
    objectWidth = object.getInt("width");
    objectHeight = object.getInt("height");

    ObjectMap<Integer, Array<AnimationDescription>> returnValue = new ObjectMap<Integer, Array<AnimationDescription>>();
    for (JsonValue animation : descriptor.get("animations")) {
        readAnimation(animation, returnValue);
    }
    return returnValue;
}
项目:RavTech    文件:RemoveChangeable.java   
@Override
public void undo () {
    JsonValue jsonData = new JsonReader().parse(gameComponent);
    Json json = new Json();
    GameObject tempObject = new GameObject();
    tempObject.readValue(json, jsonData);
    GameComponent toAddComponent = tempObject.getComponentByName(componentType);
    tempObject.getComponents().removeValue(tempObject.getComponentByName(componentType), true);
    tempObject.destroy();
    if (pathToComponent.lastIndexOf('/') == 0) {
        toAddComponent.setParent(null);
        RavTech.currentScene.addGameObject((GameObject)toAddComponent);
    } else {
        GameObject component = (GameObject)GameObjectTraverseUtil
            .gameComponentFromPath(pathToComponent.substring(0, pathToComponent.lastIndexOf('/')));
        toAddComponent.setParent(component);
        component.addComponent(toAddComponent);
    }
}
项目:RavTech    文件:CreateChangeable.java   
@Override
public void redo () {
    GameComponent parent = GameObjectTraverseUtil.gameComponentFromPath(pathToComponent);
    JsonValue jsonData = new JsonReader().parse(gameComponent);
    Json json = new Json();
    if (parent != null) {
        ((GameObject)parent).readValue(json, jsonData);
        removePath = GameObjectTraverseUtil
            .pathFromGameComponent(((GameObject)parent).getComponents().get(((GameObject)parent).getComponents().size - 1));
    } else {
        GameObject object = new GameObject();
        object.readValue(json, jsonData);
        GameObject newObject = (GameObject)object.getComponents().get(1);
        newObject.setParent(null);
        removePath = GameObjectTraverseUtil.pathFromGameComponent(newObject);
        RavTech.currentScene.addGameObject(newObject);
    }
    componentType = jsonData.getString("componenttype");
}
项目:eamaster    文件:SimulationRunner.java   
public SimulationRunner() {
    logger.info("Loading models");
    ModelBuilder builder = new ModelBuilder();
    models.put("box", builder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));

    G3dModelLoader loader = new G3dModelLoader(new JsonReader());
    models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
    models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
    models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));


    Bullet.init();
    logger.info("Initialized Bullet");
}
项目:eamaster    文件:ImportTest.java   
@Override
public void create () {
    super.create();

    ModelLoader g3djLoader = new G3dModelLoader(new JsonReader());
    model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj"));
    disposables.add(model);

    importer = new MyImporter((btDynamicsWorld)world.collisionWorld);
    importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet"));

    camera.position.set(10f, 15f, 20f);
    camera.up.set(0, 1, 0);
    camera.lookAt(-10, 8, 0);
    camera.update();
}
项目:TheConsole_POC    文件:AliasManager.java   
public AliasManager(Database.SectionAccessor aliasStorage) {
    JsonReader reader = new JsonReader();
    JsonValue value = aliasStorage.root;

    if (value.size == 0) {
        // probably empty
        return;
    }

    JsonValue aliases = reader.parse(value.asString());
    JsonValue node = aliases.child;
    while (node != null) {
        put(node.name, node.asString());
        node = node.next;
    }
}
项目:sioncore    文件:EntityFactory.java   
public void loadArchetypes() {
    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(ARCHETYPES_FILE));
        JsonIterator entitiesIt = root.iterator();

        while (entitiesIt.hasNext()) {
            JsonValue entity = entitiesIt.next();
            loadEntityArchetype(Gdx.files.internal(entity.asString()));
        }
    }
    catch (Exception e) {
        logger.error("failed to process entity list " + ARCHETYPES_FILE);
    }
}
项目:sioncore    文件:ParticleEffectPools.java   
public ParticleEffectPools() {
    logger = new Logger(TAG, Env.debugLevel);

    logger.info("initialising");

    pools = new ObjectMap<String, ParticleEffectPool>();

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(PARTICLES_FILE));
        JsonIterator particlesIt = root.iterator();

        while (particlesIt.hasNext()) {
            JsonValue particleValue = particlesIt.next();
            String effectName = particleValue.asString();
            logger.info("loading " + effectName);
            ParticleEffect effect = new ParticleEffect();
            effect.load(Gdx.files.internal(effectName), Gdx.files.internal(PARTICLES_FOLDER));

            pools.put(effectName, new ParticleEffectPool(effect,
                                                         Env.particlePoolInitialCapacity,
                                                         Env.particlePoolMaxCapacity));
        }
    }
    catch (Exception e) {
        logger.error("failed to list directory " + PARTICLES_FILE);
    }
}
项目:sioncore    文件:Assets.java   
private void loadGroups(String assetFile) {
        groups = new ObjectMap<String, Array<Asset>>();

        logger.info("loading file " + assetFile);

//      try {
            Json json = new Json();
            JsonReader reader = new JsonReader();
            JsonValue root = reader.parse(Gdx.files.internal(assetFile));

            JsonIterator groupIt = root.iterator();

            while (groupIt.hasNext()) {
                JsonValue groupValue = groupIt.next();

                if (groups.containsKey(groupValue.name)) {
                    logger.error("group " + groupValue.name + " already exists, skipping");
                    continue;
                }

                logger.info("registering group " + groupValue.name);

                Array<Asset> assets = new Array<Asset>();

                JsonIterator assetIt = groupValue.iterator();

                while (assetIt.hasNext()) {
                    JsonValue assetValue = assetIt.next();

                    Asset asset = json.fromJson(Asset.class, assetValue.toString());
                    assets.add(asset);
                }

                groups.put(groupValue.name, assets);
            }
//      }
//      catch (Exception e) {
//          logger.error("error loading file " + assetFile + " " + e.getMessage());
//      }
    }
项目:sioncore    文件:MapBodyManager.java   
private void loadMaterialsFile(FileHandle materialsFile) {
    logger.info("adding default material");

    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 1.0f;
    fixtureDef.friction = 1.0f;
    fixtureDef.restitution = 0.0f;
    materials.put("default", fixtureDef);

    logger.info("loading materials file");

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(materialsFile);
        JsonIterator materialIt = root.iterator();

        while (materialIt.hasNext()) {
            JsonValue materialValue = materialIt.next();

            if (!materialValue.has("name")) {
                logger.error("material without name");
                continue;
            }

            String name = materialValue.getString("name");

            fixtureDef = new FixtureDef();
            fixtureDef.density = materialValue.getFloat("density", 1.0f);
            fixtureDef.friction = materialValue.getFloat("friction", 1.0f);
            fixtureDef.restitution = materialValue.getFloat("restitution", 0.0f);
            logger.info("adding material " + name);
            materials.put(name, fixtureDef);
        }

    } catch (Exception e) {
        logger.error("error loading " + materialsFile.name() + " " + e.getMessage());
    }
}
项目:libgdxcn    文件:AssetManager.java   
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
    setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
    setLoader(Music.class, new MusicLoader(resolver));
    setLoader(Pixmap.class, new PixmapLoader(resolver));
    setLoader(Sound.class, new SoundLoader(resolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
    setLoader(Texture.class, new TextureLoader(resolver));
    setLoader(Skin.class, new SkinLoader(resolver));
    setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
    setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
    setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
    setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
    setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
    setLoader(Model.class, ".obj", new ObjLoader(resolver));
    executor = new AsyncExecutor(1);
}
项目:libgdxcn    文件:ImportTest.java   
@Override
public void create () {
    super.create();

    ModelLoader g3djLoader = new G3dModelLoader(new JsonReader());
    model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj"));
    disposables.add(model);

    importer = new MyImporter((btDynamicsWorld)world.collisionWorld);
    importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet"));

    camera.position.set(10f, 15f, 20f);
    camera.up.set(0, 1, 0);
    camera.lookAt(-10, 8, 0);
    camera.update();
}
项目:libgdx_g3db_converter    文件:G3DBConverter.java   
/** <p>
 * Convert a text JSON file into binary JSON. The new file will be saved in the same folder as the original one with the
 * {@code gd3b} extension.
 * </p>
 * 
 * @param g3djFile Handle to the original G3DJ file.
 * @param overwrite If {@code true} the new file will overwrite any previous file with the same name. Otherwise append a
 *           counter at the end of the file name to make it unique.
 * @throws IOException If there's an exception while reading the input file or writing the output file. */
public void convert (FileHandle g3djFile, boolean overwrite) throws IOException {
    FileHandle newFile = new FileHandle(g3djFile.pathWithoutExtension() + ".g3db");
    int noOverwriteCounter = 0;
    while (!overwrite && newFile.exists()) {
        newFile = new FileHandle(g3djFile.pathWithoutExtension() + "(" + (++noOverwriteCounter) + ").g3db");
    }

    OutputStream fileOutputStream = newFile.write(false);
    UBJsonWriter writer = new UBJsonWriter(fileOutputStream);
    JsonReader reader = new JsonReader();

    try {
        JsonValue root = reader.parse(g3djFile);
        writeObject(root, writer);

    } finally {
        writer.close();
    }
}
项目:gdx-gamesvcs    文件:GameJoltClient.java   
/**
 * Helper method when just interested if GameJolt request was successful
 */
protected boolean parseSuccessFromResponse(String json) {
    JsonValue response = null;
    boolean success;
    try {
        response = new JsonReader().parse(json).get("response");
        success = response != null && response.getBoolean("success");
    } catch (Throwable t) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot parse GameJolt response: " + json, t);
        success = false;
    }
    return success;
}
项目:bobbybird    文件:MenuState.java   
private void createMenu() {
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);

    FileHandle fileHandle = Gdx.files.local(Core.DATA_PATH + "/data.json");
    JsonReader reader = new JsonReader();
    JsonValue val = reader.parse(fileHandle);

    Label title = new Label(val.getString("title"), skin, "title");
    root.add(title).padTop(50.0f).padBottom(75.0f);

    root.row();
    BouncingImage image = new BouncingImage(getCharacter());
    root.add(image);

    root.row();
    ImageButton imageButton = new  ImageButton(skin, "play");
    root.add(imageButton).padTop(75.0f).expandY().top();
    imageButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            getCore().getAssetManager().get(Core.DATA_PATH + "/sfx/jump.wav", Sound.class).play();
            showCharacterDialog();
        }
    });
}
项目:joe    文件:PropertyConfiguration.java   
protected PropertyConfiguration(String filename, String root1, String root2) {
    this.filename = filename;
    this.root1 = root1;
    this.root2 = root2;

    typePropertiesMap = new ConcurrentHashMap<String, Properties>();
    typeClassMap = new ConcurrentHashMap<String, String>();

    JsonReader jsonReader = new JsonReader();
    parseConfiguration(jsonReader.parse(Gdx.files.internal(filename)));
}
项目:skin-composer    文件:TexturePackerFileProcessor.java   
private void merge (Settings settings, File settingsFile) {
    try {
        json.readFields(settings, new JsonReader().parse(new FileReader(settingsFile)));
    } catch (Exception ex) {
        throw new GdxRuntimeException("Error reading settings file: " + settingsFile, ex);
    }
}
项目:fabulae    文件:StringTableLoader.java   
@Override
public StringTable load (AssetManager assetManager, String fileName, FileHandle file, StringResourceParameter parameter) {
    FileHandle csvFile = resolve(fileName);
    StringTable returnValue = new StringTable();

    for (JsonValue child : new JsonReader().parse(csvFile)) {
        addValue(child, returnValue, "");
    }

    return returnValue;
}
项目:RavTech    文件:RemoveChangeable.java   
@Override
public void redo () {
    GameObject component = (GameObject)GameObjectTraverseUtil.gameComponentFromPath(pathToComponent);
    JsonValue jsonData = new JsonReader().parse(gameComponent);
    componentType = jsonData.getString("componenttype");
    if (componentType.equals("GameObject"))
        componentType = jsonData.getString("name");
    /*
     *
     * for(GameComponent tempComponent: component.getComponents())
     */
    component.destroy();
}
项目:libgdxjam    文件:PhysicsDataLoader.java   
private void loadData(String fileName, FileHandle file) {       
    logger.info("loading " + fileName);

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        loadBodyDef(root);
        loadMassData(root);
        loadFixtureDefs(root);

    } catch (Exception e) {
        logger.error("error loading " + fileName + "\n" + e.getStackTrace());
    }
}
项目:libgdxjam    文件:AnimationStateDataLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationStateDataLoaderParameter parameter) {
    logger.info("loading " + fileName);

    data = new AnimationStateData(manager.get(parameter.skeletonName, SkeletonData.class));

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        float defaultBlend = root.get("defaultBlend").asFloat();

        logger.info("default blend: " + defaultBlend + "s");

        data.setDefaultMix(defaultBlend);

        JsonIterator blendIt = root.get("blends").iterator();

        while (blendIt.hasNext()) {
            JsonValue blendValue = blendIt.next();
            String from = blendValue.get("from").asString(); 
            String to = blendValue.get("to").asString();
            float duration = blendValue.get("duration").asFloat();

            data.setMix(from, to , duration);

            logger.info("blend: " + from + " -> " + to + " [" + duration + "s]");
        }
    }
    catch (Exception e) {
        logger.error("error loading " + fileName + " " + e.getMessage());
    }
}
项目:TheEndlessCastle    文件:BodyEditorDAL.java   
private Model readJson(String str) {
    Model m = new Model();

    JsonValue map = new JsonReader().parse(str);

    JsonValue bodyElem = map.getChild("rigidBodies");
    for (; bodyElem != null; bodyElem = bodyElem.next()) {
        RigidBodyModel rbModel = readRigidBody(bodyElem);
        m.rigidBodies.put(rbModel.name, rbModel);
    }

    return m;
}
项目:gdx-facebook    文件:JsonResultUnitTests.java   
@Test
public void setGetJsonValue() {
    JsonReader writer = new JsonReader();
    JsonValue value = writer.parse("{testValue:2}");
    fixture.setJsonValue(value);
    assertEquals(value, fixture.getJsonValue());
}
项目:gdx-facebook    文件:JsonResultUnitTests.java   
@Test
public void constructorWithJsonValue() {
    JsonReader writer = new JsonReader();
    JsonValue value = writer.parse("{testValue:5}");
    fixture = new JsonResult(value);
    assertEquals(value, fixture.getJsonValue());

    assertTrue(fixture.getJsonValue().has("testValue"));
    assertEquals(5, fixture.getJsonValue().getInt("testValue"));
}
项目:Mundus    文件:SceneLoader.java   
public Scene load(String name) {
    final JsonReader reader = new JsonReader();
    final JsonValue json = reader.parse(root.child(name));

    Scene scene = new Scene();
    scene.setId(json.getInt(JsonScene.ID));
    scene.setName(json.getString(JsonScene.NAME));

    // game objects
    for(JsonValue go : json.get(JsonScene.GAME_OBJECTS)) {
        scene.sceneGraph.addGameObject(convertGameObject(scene.sceneGraph, go));
    }

    return scene;
}
项目:Aftamath    文件:JsonSerializer.java   
/**
 * find savegame file; if file at index exists, preload data and store it into a parseable string
 * @param path loafus cramwell of slurmpville, how do I door?
 * @return string of format "playerType/lname/llocation/lplayTime"
 */
public static String getSummary(FileHandle path){
    try{
        return new JsonReader().parse(path).getString("summary");
    } catch (Exception e){
        e.printStackTrace();
        return null;
    }
}
项目:sioncore    文件:SpriteAnimationLoader.java   
/**
 * Aynchronously loads the animation data animations
 */
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationParameter parameter) {
    logger.info("loading " + fileName);

    animationData = new SpriteAnimationData();

    // Retrieve texture
    animationData.texture = manager.get(stripExtension(fileName) + ".png", Texture.class);

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        animationData.rows = root.getInt("rows");
        animationData.columns = root.getInt("columns");
        animationData.frameDuration = root.getFloat("frameDuration");

        JsonValue animations = root.get("animations");
        JsonIterator animationsIt = animations.iterator();
        boolean first = true;

        while (animationsIt.hasNext()) {
            JsonValue animationValue = animationsIt.next();

            String name = animationValue.getString("name");
            String frames = animationValue.getString("frames");

            Animation animation = new Animation(animationData.frameDuration,
                                                getAnimationFrames(animationData.texture, frames),
                                                getPlayMode(animationValue.getString("mode", "normal")));
            animationData.animations.put(name, animation);

            logger.info("" + fileName + " loaded animation " + name);

            if (first) {
                animationData.defaultAnimation = animation;
                first = false;
            }
        }
    } catch (Exception e) {
        logger.error("error loading file " + fileName + " " + e.getMessage());
    }
}
项目:sioncore    文件:AnimationStateDataLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationStateDataLoaderParameter parameter) {
    logger.info("loading " + fileName);

    data = new AnimationStateData(manager.get(parameter.skeletonName, SkeletonData.class));

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        float defaultBlend = root.get("defaultBlend").asFloat();

        logger.info("default blend: " + defaultBlend + "s");

        data.setDefaultMix(defaultBlend);

        JsonIterator blendIt = root.get("blends").iterator();

        while (blendIt.hasNext()) {
            JsonValue blendValue = blendIt.next();
            String from = blendValue.get("from").asString(); 
            String to = blendValue.get("to").asString();
            float duration = blendValue.get("duration").asFloat();

            data.setMix(from, to , duration);

            logger.info("blend: " + from + " -> " + to + " [" + duration + "s]");
        }
    }
    catch (Exception e) {
        logger.error("error loading " + fileName + " " + e.getMessage());
    }
}
项目:sioncore    文件:PhysicsLoader.java   
private void loadData(String fileName, FileHandle file) {
    logger.info("loading " + fileName);

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        loadBodyDef(root);
        loadMassData(root);
        loadFixtureDefs(root);

    } catch (Exception e) {
        logger.error("error loading " + fileName + " " + e.getMessage());
    }
}
项目:libgdxcn    文件:TexturePackerFileProcessor.java   
private void merge (Settings settings, File settingsFile) {
    try {
        json.readFields(settings, new JsonReader().parse(new FileReader(settingsFile)));
    } catch (Exception ex) {
        throw new GdxRuntimeException("Error reading settings file: " + settingsFile, ex);
    }
}
项目:gaiasky    文件:JsonLoader.java   
@Override
public Array<? extends SceneGraphNode> loadData() {
    Array<T> bodies = new Array<T>();

    try {
        JsonReader json = new JsonReader();
        for (String filePath : filePaths) {
            FileHandle file = Gdx.files.internal(filePath);
            JsonValue model = json.parse(file.read());
            JsonValue child = model.get("objects").child;
            int size = 0;
            while (child != null) {
                size++;
                String clazzName = child.getString("impl");

                Class<Object> clazz = (Class<Object>) ClassReflection.forName(clazzName);

                // Convert to object and add to list
                T object = (T) convertJsonToObject(child, clazz);

                bodies.add(object);

                child = child.next;
            }
            Logger.info(this.getClass().getSimpleName(), I18n.bundle.format("notif.nodeloader", size, filePath));
        }

    } catch (Exception e) {
        Logger.error(e);
    }

    return bodies;
}
项目:gaiasky    文件:GeoJsonLoader.java   
@Override
public Array<? extends SceneGraphNode> loadData() {
    Array<T> bodies = new Array<T>();

    try {
        JsonReader json = new JsonReader();
        for (String filePath : filePaths) {
            FileHandle file = Gdx.files.internal(filePath);
            JsonValue model = json.parse(file.read());
            JsonValue child = model.get("features").child;
            int size = 0;
            while (child != null) {
                size++;

                // Convert to object and add to list
                T object = (T) convertJsonToArea(child);

                bodies.add(object);

                child = child.next;
            }
            Logger.info(this.getClass().getSimpleName(), I18n.bundle.format("notif.nodeloader", size, filePath));
        }

    } catch (Exception e) {
        Logger.error(e);
    }

    return bodies;
}
项目:bladecoder-adventure-engine    文件:World.java   
/**
 * Load the world description in 'world.json'.
 * 
 * @throws IOException
 */
public void loadWorldDesc() throws IOException {

    String worldFilename = EngineAssetManager.WORLD_FILENAME;

    if (!EngineAssetManager.getInstance().getModelFile(worldFilename).exists()) {

        // Search the world file with ".json" ext if not found.
        worldFilename = EngineAssetManager.WORLD_FILENAME + ".json";

        if (!EngineAssetManager.getInstance().getModelFile(worldFilename).exists()) {
            EngineLogger.error("ERROR LOADING WORLD: world file not found.");
            dispose();
            throw new IOException("ERROR LOADING WORLD: world file not found.");
        }
    }

    SerializationHelper.getInstance().setMode(Mode.MODEL);

    JsonValue root = new JsonReader()
            .parse(EngineAssetManager.getInstance().getModelFile(worldFilename).reader("UTF-8"));

    Json json = new Json();
    json.setIgnoreUnknownFields(true);

    int width = json.readValue("width", Integer.class, root);
    int height = json.readValue("height", Integer.class, root);

    // We know the world width, so we can set the scale
    EngineAssetManager.getInstance().setScale(width, height);
    float scale = EngineAssetManager.getInstance().getScale();

    setWidth((int) (width * scale));
    setHeight((int) (height * scale));
    setInitChapter(json.readValue("initChapter", String.class, root));
    verbs.read(json, root);
    I18N.loadWorld(EngineAssetManager.MODEL_DIR + EngineAssetManager.WORLD_FILENAME);
}
项目:bladecoder-adventure-engine    文件:World.java   
public void loadChapter(String chapterName) throws IOException {
    if (!disposed)
        dispose();

    init();

    long initTime = System.currentTimeMillis();

    SerializationHelper.getInstance().setMode(Mode.MODEL);

    if (chapterName == null)
        chapterName = initChapter;

    currentChapter = chapterName;

    if (EngineAssetManager.getInstance().getModelFile(chapterName + EngineAssetManager.CHAPTER_EXT).exists()) {

        JsonValue root = new JsonReader().parse(EngineAssetManager.getInstance()
                .getModelFile(chapterName + EngineAssetManager.CHAPTER_EXT).reader("UTF-8"));

        Json json = new Json();
        json.setIgnoreUnknownFields(true);

        read(json, root);

        I18N.loadChapter(EngineAssetManager.MODEL_DIR + chapterName);

        customProperties.put(WorldProperties.CURRENT_CHAPTER.toString(), chapterName);
        customProperties.put(WorldProperties.PLATFORM.toString(), Gdx.app.getType().toString());
    } else {
        EngineLogger.error(
                "ERROR LOADING CHAPTER: " + chapterName + EngineAssetManager.CHAPTER_EXT + " doesn't exists.");
        dispose();
        throw new IOException(
                "ERROR LOADING CHAPTER: " + chapterName + EngineAssetManager.CHAPTER_EXT + " doesn't exists.");
    }

    EngineLogger.debug("MODEL LOADING TIME (ms): " + (System.currentTimeMillis() - initTime));
}
项目:bladecoder-adventure-engine    文件:DisableActionAction.java   
public Action getAction() {
    if(action == null) {
        Json json = new Json();
        JsonValue root = new JsonReader().parse(serializedAction);
        action =  ActionUtils.readJson(json, root);
    }

    return action;
}
项目:gdx.automation    文件:JsonInputRecordReader.java   
public JsonInputRecordReader(FileHandle input) {
    super(input);
    reader = new JsonReader();
    recordProperties = readRecordProperties(new RecordProperties());
    staticProperties = readStaticValues(new StaticProperties());
    readSyncProperties();
    readAsyncProperties();
}
项目:ninja-rabbit    文件:BodyEditorLoader.java   
private Model readJson(final String str) {
    Model m = new Model();
    JsonValue rootElem = new JsonReader().parse(str);

    JsonValue bodiesElems = rootElem.get("rigidBodies");

    for (int i = 0; i < bodiesElems.size; i++) {
        JsonValue bodyElem = bodiesElems.get(i);
        RigidBodyModel rbModel = readRigidBody(bodyElem);
        m.rigidBodies.put(rbModel.name, rbModel);
    }

    return m;
}
项目:JavaLib    文件:BodyEditorLoader.java   
private Model readJson(String str) {
    Model m = new Model();
    JsonValue rootElem = new JsonReader().parse(str);

    JsonValue bodiesElems = rootElem.get("rigidBodies");

    for (int i = 0; i < bodiesElems.size; i++) {
        JsonValue bodyElem = bodiesElems.get(i);
        RigidBodyModel rbModel = readRigidBody(bodyElem);
        m.rigidBodies.put(rbModel.name, rbModel);
    }

    return m;
}