Java 类com.badlogic.gdx.assets.AssetLoaderParameters 实例源码

项目:Quilly-s-Castle    文件:Utils.java   
private static <T, P extends AssetLoaderParameters<T>> void loadAsset(String filePath, Class<T> type, AssetLoader<T, P> loader) {
if (filePath == null || filePath.trim().isEmpty()) {
    Gdx.app.debug(TAG, "Trying to load a " + type.getSimpleName() + " with empty filePath");
    return;
}

if (fileResolver.resolve(filePath).exists()) {
    assetManager.setLoader(type, loader);
    assetManager.load(filePath, type);

    assetManager.finishLoading();
    Gdx.app.debug(TAG, type.getSimpleName() + " loaded: " + filePath);
} else {
    Gdx.app.debug(TAG, type.getSimpleName() + " does not exist: " + filePath);
}
   }
项目:dice-heroes    文件:LevelsLoader.java   
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) {
    Yaml yaml = new Yaml();
    ObjectMap<String, BaseLevelDescription> data = new ObjectMap<String, BaseLevelDescription>();
    for (Object o : yaml.loadAll(resolve(fileName).read())) {
        HashMap<String, Object> value = (HashMap<String, Object>) o;
        String type = MapHelper.get(value, "type", "level");
        try {
            BaseLevelDescription desc = types.get(type).getConstructor(Map.class).newInstance(value);
            data.put(desc.name, desc);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
    levels = new Levels(data);
    Config.levels = levels;
}
项目:fabulae    文件:LoaderUtil.java   
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
        AssetLoader<T, P> loader, P parameter,
        @SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
        Element root) throws IOException {
    Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
    for (Element singleImport : imports) {
        String filename = singleImport.get(XMLUtil.XML_FILENAME);
        FileHandle file = parentFile.parent().child(filename);
        if (!file.exists()) {
            throw new GdxRuntimeException("Import " + file.path()
                    + " from import for " + parentFile.name()
                    + " does not exist.");
        }
        dependencies.addAll(loader.getDependencies(filename, file, parameter));
    }
}
项目:nvlist    文件:GdxTextureStore.java   
@Override
@Nullable
protected AssetLoaderParameters<Texture> getLoadParams(FilePath imagePath) {
    IImageDefinition imageDef = getImageDef(imagePath);
    if (imageDef == null) {
        return null;
    }

    TextureParameter params = new TextureParameter();

    params.minFilter = GdxTextureUtil.toGdxFilter(imageDef.getMinifyFilter());
    params.magFilter = GdxTextureUtil.toGdxFilter(imageDef.getMagnifyFilter());

    params.wrapU = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeX());
    params.wrapV = GdxTextureUtil.toGdxWrap(imageDef.getTilingModeY());

    return params;
}
项目:libgdxcn    文件:FlameMain.java   
public <T> T load (String resource, Class<T> type, AssetLoader loader, AssetLoaderParameters<T> params) {   
    String resolvedPath = new String(resource).replaceAll("\\\\", "/");
    boolean exist = assetManager.isLoaded(resolvedPath, type);
    T oldAsset = null;
    if(exist){
        oldAsset = assetManager.get(resolvedPath, type);
        for(int i=assetManager.getReferenceCount(resolvedPath); i > 0; --i)
            assetManager.unload(resolvedPath);
    }

    AssetLoader<T, AssetLoaderParameters<T>> currentLoader = assetManager.getLoader(type);
    if(loader != null)
        assetManager.setLoader(type, loader); 

    assetManager.load(resource, type, params);
    assetManager.finishLoading();
    T res = assetManager.get(resolvedPath);
    if(currentLoader != null)
        assetManager.setLoader(type, currentLoader);

    if(exist)
        EventManager.get().fire(EVT_ASSET_RELOADED, new Object[]{oldAsset, res});

    return res;
}
项目:droidtowers    文件:MemoryTrackingAssetManager.java   
private <T> AssetLoaderParameters<T> makeAssetLoaderParameter(String fileName, Class<T> type) {
    AssetLoaderParameters<T> parameter;
    if (type.equals(Texture.class)) {
        parameter = (AssetLoaderParameters<T>) new TextureLoader.TextureParameter();
    } else if (type.equals(TextureAtlas.class)) {
        parameter = (AssetLoaderParameters<T>) new TextureAtlasLoader.TextureAtlasParameter();
    } else if (type.equals(Sound.class)) {
        parameter = (AssetLoaderParameters<T>) new SoundLoader.SoundParameter();
    } else if (type.equals(BitmapFont.class)) {
        parameter = (AssetLoaderParameters<T>) new BitmapFontLoader.BitmapFontParameter();
    } else if (type.equals(Pixmap.class)) {
        parameter = (AssetLoaderParameters<T>) new PixmapLoader.PixmapParameter();
    } else if (type.equals(Music.class)) {
        parameter = (AssetLoaderParameters<T>) new MusicLoader.MusicParameter();
    } else {
        parameter = null;
    }

    return parameter;
}
项目:ead    文件:JsonLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName,
        FileHandle file, AssetLoaderParameters<T> parameter) {
    // FIXME temporary fix. Some of the files has erroneous '
    String contents = file
            .readString()
            .replaceAll(
                    "'(https?:\\/\\/)([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?(\\?.*)?'",
                    "\"http\"");

    object = gameAssets.fromJson(clazz == Object.class ? null : clazz,
            contents);
    if (object == null) {
        throw new RuntimeException(fileName
                + " name is an empty file. Impossible to load json");
    }
}
项目:cll1-gdx    文件:AbstractScreen.java   
public synchronized <T> T loadAndGet(String fileName, Class<T> type, AssetLoaderParameters<T> parameter) {
    if (!isLoaded(fileName)) {
        load(fileName, type, parameter);
        finishLoadingAsset(fileName);
    }
    return super.get(fileName, type);
}
项目:dice-heroes    文件:ProfessionsLoader.java   
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) {
    Yaml yaml = new Yaml();
    ObjectMap<String, ProfessionDescription> data = new ObjectMap<String, ProfessionDescription>();
    for (Object o : yaml.loadAll(resolve(fileName).read())) {
        Map professionData = (Map) o;
        ProfessionDescription profession = new ProfessionDescription(professionData);
        data.put(profession.name, profession);
    }
    professions = new Professions(data);
    Config.professions = professions;
}
项目:dice-heroes    文件:YamlAllLoader.java   
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Array> parameter) {
    Iterable<Object> data = new Yaml().loadAll(file.read());
    Array<Object> list = new Array<Object>();
    for(Object o : data){
        list.add(o);
    }
    this.list = list;
}
项目:dice-heroes    文件:AbilitiesLoader.java   
@Override @SuppressWarnings("unchecked") public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Abilities> parameter) {
    Yaml yaml = new Yaml();
    ObjectMap<String, Ability> data = new ObjectMap<String, Ability>();
    for (Object o : yaml.loadAll(resolve(fileName).read())) {
        HashMap<String, Object> value = (HashMap<String, Object>) o;
        Ability description = new Ability(value);
        data.put(description.name, description);
    }
    abilities = new Abilities(data);
    Config.abilities = abilities;
}
项目:dice-heroes    文件:ItemsLoader.java   
@Override public void loadAsync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Items> parameter) {
    Constructor constructor = new Constructor(Item.class);
    Yaml yaml = new Yaml(constructor);
    ObjectMap<String, Item> data = new ObjectMap<String, Item>();
    for (Object o : yaml.loadAll(resolve(fileName).read())) {
        Item item = (Item) o;
        data.put(item.name, item);
    }
    items = new Items(data);
    Config.items = items;
}
项目:fabulae    文件:AtlassedAssetManager.java   
@Override
public synchronized <T> void load(String fileName, Class<T> type,
        AssetLoaderParameters<T> parameter) {
    if (fileName.contains(TEXTURE_REGION_SEPARATOR)) {
        fileName = fileName.substring(0, fileName.lastIndexOf(TEXTURE_REGION_SEPARATOR)+TEXTURE_REGION_SEPARATOR_LENGTH-1);
        super.load(fileName, TextureAtlas.class, null);
    } else {
        super.load(fileName, type, parameter);
    }
}
项目:RavTech    文件:DummySceneLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Scene> parameter) {
    scene = new Json().fromJson(Scene.class, serializedScene);
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    for (int i = 0; i < scene.gameObjects.size; i++)
        scene.gameObjects.get(i).load(assetDependencies);
    return assetDependencies;
}
项目:RavTech    文件:ProjectLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Project> parameter) {
    project = new Json().fromJson(Project.class, file.readString());
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    return assetDependencies;
}
项目:RavTech    文件:SceneLoader.java   
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, AssetLoaderParameters<Scene> parameter) {
    scene = new Json().fromJson(Scene.class, file.readString());
    Array<AssetDescriptor> assetDependencies = new Array<AssetDescriptor>();
    for (int i = 0; i < scene.gameObjects.size; i++)
        scene.gameObjects.get(i).load(assetDependencies);
    return assetDependencies;
}
项目:RavTech    文件:ScriptComponent.java   
public void setScript (String scriptPath) {
    RavTech.files.addDependency(scriptPath, this);
    if (scriptPath.startsWith("/"))
        scriptPath = scriptPath.substring(1);
    path = scriptPath;
    if (RavTech.files.getAssetManager().isLoaded(path))
        RavTech.files.getAssetManager().unload(path);
    RavTech.files.getAssetManager().load(new AssetDescriptor<String>(path, String.class, new AssetLoaderParameters<String>()));
    RavTech.files.finishLoading();
    finishedLoading();
}
项目:gdx-pd    文件:MidiSequenceLoader.java   
@Override
public MidiSequence loadSync(AssetManager manager, String fileName, FileHandle file,
        AssetLoaderParameters<MidiSequence> parameter) {
    MidiSequence sequence = this.sequence;
    this.sequence = null;
    return sequence;
}
项目:TheEndlessCastle    文件:TypedAssetDescriptor.java   
@SuppressWarnings("unchecked")
public TypedAssetDescriptor(String assetName, String fileName, AssetTypeEnum assetType, AssetLoaderParameters<T> params, AssetLicense license) {
    // AssetDescriptor<T>.FileName is actually an internal path >.<
    super(_ASSETS_TYPES.get(assetType).directory + fileName, _ASSETS_TYPES.get(assetType).assetClass, params);
    AssetType = assetType;
    AssetName = assetName;
    License = license;
}
项目:gdx-autumn-mvc    文件:AssetService.java   
/** Schedules loading of the selected asset, if it was not scheduled already.
 *
 * @param assetPath assetPath internal path to the asset.
 * @param assetClass assetClass class of the asset.
 * @param loadingParameters specific loading parameters.
 * @param <Type> type of asset class to load. */
public <Type> void load(final String assetPath, final Class<Type> assetClass,
        final AssetLoaderParameters<Type> loadingParameters) {
    if (isAssetNotScheduled(assetPath)) {
        assetManager.load(assetPath, assetClass, loadingParameters);
    }
}
项目:gdx-autumn-mvc    文件:AssetService.java   
/** Immediately loads the chosen asset. Schedules loading of the asset if it wasn't selected to be loaded already.
 *
 * @param assetPath internal path to the asset.
 * @param assetClass class of the loaded asset.
 * @param loadingParameters used if asset is not already loaded.
 * @return instance of the loaded asset.
 * @param <Type> type of asset class to load. */
public <Type> Type finishLoading(final String assetPath, final Class<Type> assetClass,
        final AssetLoaderParameters<Type> loadingParameters) {
    if (assetManager.isLoaded(assetPath)) {
        return assetManager.get(assetPath, assetClass);
    }
    if (!eagerAssetManager.isLoaded(assetPath)) {
        eagerAssetManager.load(assetPath, assetClass, loadingParameters);
        eagerAssetManager.finishLoadingAsset(assetPath);
    }
    return eagerAssetManager.get(assetPath, assetClass);
}
项目:gdx-lml    文件:AssetService.java   
/** Schedules loading of the selected asset, if it was not scheduled already.
 *
 * @param assetPath assetPath internal path to the asset.
 * @param assetClass assetClass class of the asset.
 * @param loadingParameters specific loading parameters.
 * @param <Type> type of asset class to load. */
public <Type> void load(final String assetPath, final Class<Type> assetClass,
        final AssetLoaderParameters<Type> loadingParameters) {
    if (isAssetNotScheduled(assetPath)) {
        assetManager.load(assetPath, assetClass, loadingParameters);
    }
}
项目:gdx-lml    文件:AssetService.java   
/** Immediately loads the chosen asset. Schedules loading of the asset if it wasn't selected to be loaded already.
 *
 * @param assetPath internal path to the asset.
 * @param assetClass class of the loaded asset.
 * @param loadingParameters used if asset is not already loaded.
 * @return instance of the loaded asset.
 * @param <Type> type of asset class to load. */
public <Type> Type finishLoading(final String assetPath, final Class<Type> assetClass,
        final AssetLoaderParameters<Type> loadingParameters) {
    if (assetManager.isLoaded(assetPath)) {
        return assetManager.get(assetPath, assetClass);
    }
    if (!eagerAssetManager.isLoaded(assetPath)) {
        eagerAssetManager.load(assetPath, assetClass, loadingParameters);
        eagerAssetManager.finishLoadingAsset(assetPath);
    }
    return eagerAssetManager.get(assetPath, assetClass);
}
项目:sioncore    文件:Asset.java   
@Override
public void read(Json json, JsonValue jsonData) {
    try {
        type = Class.forName(jsonData.get("type").asString());
    } catch (Exception e) {
        type = null;
    }

    path = jsonData.get("path").asString();

    JsonValue parametersValue = jsonData.get("parameters");
    parameters = parametersValue != null ? json.fromJson(AssetLoaderParameters.class, parametersValue.toString()) : null;
}
项目:CodeBase    文件:AssetManagerX.java   
public <T> void loadAssetList(String filename, Class<T> clazz,
        AssetLoaderParameters<T> parameter) {
    try {
        HashMap<String, String> baseMap = getBaseMap(clazz);

        HashMap<String, String> map = JacksonReader.readMap(filename, String.class);
        for (Entry<String, String> entry : map.entrySet()) {
            String file = prefixFilename(clazz, entry.getValue());
            load(file, clazz, parameter);
            baseMap.put(entry.getKey(), file);
        }
    } catch (Exception e) {
        throw new GdxRuntimeException("Error reading file: " + filename, e);
    }
}
项目:CodeBase    文件:AssetManagerX.java   
public <T> void loadAssetListByKey(String filename, Class<T> clazz,
        AssetLoaderParameters<T> parameter) {
    try {
        HashMap<String, String> baseMap = getBaseMap(clazz);

        HashMap<String, String> map = JacksonReader.readMap(filename, String.class);
        for (Entry<String, String> entry : map.entrySet()) {
            String file = prefixFilename(clazz, entry.getKey());
            load(file, clazz, parameter);
            baseMap.put(entry.getKey(), file);
        }
    } catch (Exception e) {
        throw new GdxRuntimeException("Error reading file: " + filename, e);
    }
}
项目:droidtowers    文件:MemoryTrackingAssetManager.java   
@Override
public synchronized <T> void load(String fileName, Class<T> type, AssetLoaderParameters<T> parameter) {
    if (parameter == null) {
        parameter = makeAssetLoaderParameter(fileName, type);
    }
    if (parameter != null) {
        final LoadedCallback prevCallback = parameter.loadedCallback;
        parameter.loadedCallback = new LoadedCallback() {
            @Override
            public void finishedLoading(AssetManager assetManager, String fileName, Class type) {
                Gdx.app.log(MemoryTrackingAssetManager.class.getSimpleName(), "Loaded: " + fileName);

                if (type.equals(Texture.class)) {
                    currentMemory += calculateTextureSize(assetManager, fileName);
                }

                if (prevCallback != null) {
                    prevCallback.finishedLoading(assetManager, fileName, type);
                }

                AssetLoadCompleteEvent e = Pools.obtain(AssetLoadCompleteEvent.class);
                e.setFileName(fileName);
                e.setType(type);
                eventBus.post(e);
                Pools.free(e);
            }
        };
    }

    super.load(fileName, type, parameter);
}
项目:tafl    文件:TaflLevelDataLoader.java   
@Override
public TaflLevel loadSync(AssetManager manager, String fileName,
        FileHandle file, AssetLoaderParameters<TaflLevel> parameter) {

    TaflLevel level = json.fromJson(TaflLevel.class, file);
    return level;
}
项目:gaiasky    文件:AssetBean.java   
public static void addAsset(String assetName, Class assetClass, AssetLoaderParameters params) {
    if (assetManager == null) {
        assetDescriptors.add(new AssetBean(assetName, assetClass, params));
    } else {
        assetManager.load(assetName, assetClass, params);
    }
}
项目:ead    文件:GameAssets.java   
@Override
public <T> void get(String fileName, Class<T> clazz,
        AssetLoaderParameters<T> parameters, AssetLoadedCallback<T> callback) {
    if (referencePath != null) {
        fileName = referencePath + fileName;
    }
    super.get(fileName, clazz, parameters, callback);
}
项目:ead    文件:Assets.java   
public Assets(Files files) {
    setEnumNames(false);
    this.files = files;
    listeners = new Array<AssetLoadingListener>();
    assetManager = new AssetManager(this);
    assetManager.setErrorListener(this);
    i18n = new I18N(this);
    setLoader(Skin.class, new ExtendedSkinLoader(this));
    setLoader(Texture.class, new URLTextureLoader(this));
    setLoader(SkeletonData.class, new SkeletonLoader(this));
    assetManager.setErrorListener(new AssetErrorListener() {
        @Override
        public void error(AssetDescriptor asset, Throwable throwable) {
            AssetLoaderParameters params = asset.params;
            if (params != null) {
                LoadedCallback loadedCallback = params.loadedCallback;
                if (loadedCallback instanceof ErrorCallback) {
                    ((ErrorCallback) loadedCallback).errored(
                            asset.fileName, asset.type, throwable);
                }
            } else {
                Gdx.app.error("Assets", "Exception loading asset",
                        throwable);
            }
        }
    });
}
项目:ead    文件:Assets.java   
/**
 * Adds the given asset to the loading queue of the Assets.
 * 
 * @param fileName
 *            the file name (interpretation depends on {@link GameAssets})
 * @param clazz
 *            the type of the asset.
 * @param parameters
 *            asset params
 * @param callback
 *            to be called with the loaded asset
 */
public <T> void get(String fileName, Class<T> clazz,
        AssetLoaderParameters<T> parameters, AssetLoadedCallback<T> callback) {
    if (assetManager.isLoaded(fileName, clazz)) {
        callback.loaded(fileName, assetManager.get(fileName, clazz));
    } else {
        if (parameters == null) {
            parameters = getDefaultParameters(clazz, callback);
        } else {
            parameters.loadedCallback = new AssetParameters<T>(callback);
        }
        assetManager.load(fileName, clazz, parameters);
    }
}
项目:ead    文件:ScaledTextureLoader.java   
@Override
public Array<AssetDescriptor> getDependencies(String fileName,
        FileHandle file, AssetLoaderParameters<ScaledTexture> parameter) {
    String imageName = fileName;
    if (fileName.toLowerCase().endsWith(".tex")) {
        imageName = fileName.substring(0, fileName.lastIndexOf("."));
    }

    FileHandle imageFile = gameAssets.resolve(imageName);
    imageUtils.imageSize(imageFile, size);
    if (imageUtils.validSize(size)) {
        scale = 1.0f;
        return Array.with(assetDescriptor = new AssetDescriptor(imageFile,
                Texture.class, textureParameter));
    } else {
        FileHandle scaleProperty = gameAssets
                .resolveProject(ModelStructure.METADATA_PATH
                        + imageFile.name() + ".prop");
        FileHandle scaled = gameAssets
                .resolveProject(ModelStructure.METADATA_PATH
                        + imageFile.name() + ".scaled");
        if (!imageFile.exists() || !scaleProperty.exists()) {
            scale = imageUtils.scale(imageFile, scaled);
            scaleProperty.writeString(scale + "", false);
        } else {
            scale = Float.parseFloat(scaleProperty.readString());
        }
        return Array.with(assetDescriptor = new AssetDescriptor(scaled,
                Texture.class, textureParameter));
    }
}
项目:spezi-gdx    文件:Assets.java   
public static void loadSkin() {
    AssetLoaderParameters<SpeziSkin> skinParameter = new SpeziSkinLoader.SkinParameter(
            DEFAULT_SKIN_ATLAS, 1.0f);

    Assets.getManager().load(DEFAULT_SKIN_JSON, SpeziSkin.class,
            skinParameter);
}
项目:nhglib    文件:Asset.java   
public Asset(String alias, String source, Class assetClass, AssetLoaderParameters parameters) {
    this(alias, source, assetClass);
    this.parameters = parameters;
}
项目:dice-heroes    文件:ProfessionsLoader.java   
@Override public Professions loadSync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) {
    return professions;
}
项目:dice-heroes    文件:ProfessionsLoader.java   
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Professions> parameter) {
    return null;
}
项目:dice-heroes    文件:LevelsLoader.java   
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) {
    return null;
}
项目:dice-heroes    文件:LevelsLoader.java   
@Override public Levels loadSync(AssetManager manager, String fileName, FileHandle file, AssetLoaderParameters<Levels> parameter) {
    return levels;
}
项目:dice-heroes    文件:YamlAllLoader.java   
@Override public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, AssetLoaderParameters<Array> parameter) {
    return null;
}