Example usage for com.badlogic.gdx.graphics.g2d.freetype FreeTypeFontGeneratorLoader FreeTypeFontGeneratorLoader

List of usage examples for com.badlogic.gdx.graphics.g2d.freetype FreeTypeFontGeneratorLoader FreeTypeFontGeneratorLoader

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d.freetype FreeTypeFontGeneratorLoader FreeTypeFontGeneratorLoader.

Prototype

public FreeTypeFontGeneratorLoader(FileHandleResolver resolver) 

Source Link

Usage

From source file:ca.hiphiparray.amazingmaze.Assets.java

License:Open Source License

/**
 * {@link Assets} constructor.//from   w  ww.  j a v a 2 s.  c  o m
 * Calling this constructor loads in all of the game assets.
 * As such, only one {@link Assets} instance should ever be created.
 */
public Assets() {
    manager = new AssetManager();

    // Allow loading FreeTypeFonts.
    FileHandleResolver resolver = new InternalFileHandleResolver();
    manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));

    loadSkin();
    loadMapResources();
    setupMouseAnimation();

    manager.load(GAME_LOGO, Texture.class);
    manager.load(COMPANY_LOGO, Texture.class);
    manager.load(LIFE_HUD_IMAGE, Texture.class);
    manager.load(MENU_BACKGROUND_IMAGE, Texture.class);
    manager.load(MINI_BACKGROUND, Texture.class);
    manager.load(PENCIL_BUTTON, Texture.class);
    manager.load(ERASER_BUTTON, Texture.class);
    manager.load(HELP_BUTTON, Texture.class);
    manager.load(CHECK_BUTTON, Texture.class);
    manager.load(CLEAR_BUTTON, Texture.class);

    loadMusic();

    manager.finishLoading();
}

From source file:com.bladecoder.engine.assets.EngineAssetManager.java

License:Apache License

protected EngineAssetManager(FileHandleResolver resolver) {
    super(resolver);

    resResolver = new EngineResolutionFileResolver(resolver);
    setLoader(Texture.class, new TextureLoader(resResolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resResolver));
    setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));

    Texture.setAssetManager(this);
}

From source file:com.kotcrab.vis.runtime.font.FreeTypeFontProvider.java

License:Apache License

@Override
public void setLoaders(AssetManager assetManager) {
    assetManager.setLoader(FreeTypeFontGenerator.class,
            new FreeTypeFontGeneratorLoader(assetManager.getFileHandleResolver()));
    assetManager.setLoader(BitmapFont.class, ".ttf",
            new FreetypeFontLoader(assetManager.getFileHandleResolver()));
}

From source file:free.hacknet.game.Assets.java

License:Open Source License

public static void init() {

    manager.setLoader(FreeTypeFontGenerator.class,
            new FreeTypeFontGeneratorLoader(new InternalFileHandleResolver()));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(new InternalFileHandleResolver()));
}

From source file:game.dataAccessLayer.AssetsHandler.java

/**
 * Loads all listed assets in given XML file.
 * @param AssetsListFileName The name of the XML file listing all assets to be loaded by assets handler.
 *///from w w w. ja  v  a  2 s .c  om
@SuppressWarnings("unchecked")
public void Load(String AssetsListFileName) {
    _assetsManager = new AssetManager();
    _assetsManager.setLoader(ShaderProgram.class, new ShaderLoader(new InternalFileHandleResolver()));
    _assetsManager.setLoader(FreeTypeFontGenerator.class,
            new FreeTypeFontGeneratorLoader(new InternalFileHandleResolver()));
    _assetsManager.setLoader(BodyEditorDAL.class, new BodyEditorLoader(new InternalFileHandleResolver()));

    _assets = new HashMap<String, TypedAssetDescriptor>();
    //_assetsByType = new EnumMap<TypedAssetDescriptor.AssetTypeEnum, ArrayList<TypedAssetDescriptor>>(TypedAssetDescriptor.AssetTypeEnum.class);
    //for(TypedAssetDescriptor.AssetTypeEnum type : TypedAssetDescriptor.AssetTypeEnum.values())
    //   _assetsByType.put(type, new ArrayList<TypedAssetDescriptor>());

    // XML assets list parsing (TODO: do it in background thread?)
    try {
        DocumentBuilder DBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document AssetsDoc = DBuilder.parse(Gdx.files.internal(AssetsListFileName).path());
        AssetsDoc.getDocumentElement().normalize();

        // Logo
        // TODO: take resolution into account
        NodeList IconNodes = AssetsDoc.getElementsByTagName(_ICON_TAG_NAME);
        if (IconNodes.getLength() > 0)
            _iconPath = IconNodes.item(0).getTextContent();

        // Licenses
        NodeList LicenseNodes = AssetsDoc.getElementsByTagName(_LICENSE_TAG_NAME);
        _licenses = new ObjectMap<String, String>(LicenseNodes.getLength());
        for (int idx = 0; idx < LicenseNodes.getLength(); idx++) {
            Element LicenseNode = (Element) LicenseNodes.item(idx);
            _licenses.put(LicenseNode.getAttribute(_NAME_ATTRIBUTE), LicenseNode.getTextContent());
        }

        // Assets
        NodeList AssetsOwnerNodes = AssetsDoc.getElementsByTagName(_ASSETS_TAG_NAME);
        if (AssetsOwnerNodes.getLength() > 0) {
            NodeList AssetsNodes = AssetsOwnerNodes.item(0).getChildNodes();

            // Load assets and store their description
            for (int i = 0; i < AssetsNodes.getLength(); i++) {
                Node AssetNode = AssetsNodes.item(i);
                if (AssetNode.getNodeType() == Node.ELEMENT_NODE) {
                    Element AssetElement = (Element) AssetNode;
                    TypedAssetDescriptor assetDescriptor;
                    AssetTypeEnum type = TypedAssetDescriptor.AssetTypeEnum.valueOf(AssetElement.getTagName());

                    AssetLicense AssetLicense;
                    String LicenseName = AssetElement.getAttribute(_LICENSE_ATTRIBUTE_NAME);
                    String Credits = AssetElement.getAttribute(_CREDITS_TEXT_ATTRIBUTE_NAME);
                    if (Credits != null && Credits != "")
                        AssetLicense = new AssetLicense(LicenseName, _licenses.get(LicenseName), Credits);
                    else
                        AssetLicense = new AssetLicense(LicenseName, _licenses.get(LicenseName));

                    switch (type) {
                    case texture:
                        // Loads texture so that it is filtered correctly
                        TextureParameter TextureParam = new TextureParameter();
                        TextureParam.minFilter = TextureFilter.MipMapLinearLinear;
                        TextureParam.magFilter = TextureFilter.Linear;
                        TextureParam.genMipMaps = true;
                        assetDescriptor = new TypedAssetDescriptor(AssetElement.getAttribute(_NAME_ATTRIBUTE),
                                AssetElement.getTextContent(), type, TextureParam, AssetLicense);
                        break;
                    case shader:
                        ShaderParameter shaderParam = new ShaderParameter();
                        shaderParam.VertexShaderPath = TypedAssetDescriptor._ASSETS_TYPES
                                .get(AssetTypeEnum.shader).directory
                                + AssetElement.getAttribute(_SHADER_VERTEX_ATTRIBUTE_NAME);
                        assetDescriptor = new TypedAssetDescriptor(AssetElement.getAttribute(_NAME_ATTRIBUTE),
                                AssetElement.getTextContent(), type, shaderParam, AssetLicense);
                        break;
                    default:
                        assetDescriptor = new TypedAssetDescriptor(AssetElement.getAttribute(_NAME_ATTRIBUTE),
                                AssetElement.getTextContent(), type, AssetLicense);
                    }

                    _assetsManager.load(assetDescriptor);
                    _assets.put(assetDescriptor.AssetName, assetDescriptor);
                    //_assetsByType.get(assetDescriptor.AssetType).add(assetDescriptor);
                }
            }
        } else {
            // TODO: show error message
        }
    } catch (Exception e) {
        e.printStackTrace();
        // TODO: show error message
    }
}

From source file:org.bladecoder.bladeengine.assets.EngineAssetManager.java

License:Apache License

protected EngineAssetManager(FileHandleResolver resolver) {
    super(resolver);

    Resolution[] r = getResolutions(resolver);

    if (r == null || r.length == 0) {
        EngineLogger.error("No resolutions defined. Maybe your 'assets' folder doesn't exists or it's empty");
        return;/*ww w .j ava  2s.  co m*/
    }

    resResolver = new EngineResolutionFileResolver(resolver, r);
    setLoader(Texture.class, new TextureLoader(resResolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resResolver));
    setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));

    Texture.setAssetManager(this);

    Resolution choosed = EngineResolutionFileResolver.choose(r);

    EngineLogger.debug("Resolution choosed: " + choosed.suffix);
}