Package transientlibs.preui.objects.gui.elements

Source Code of transientlibs.preui.objects.gui.elements.TransientGDXFont

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package transientlibs.preui.objects.gui.elements;

import transientlibs.preui.objects.gui.interfaces.IFont;
import transientlibs.preui.objects.gui.interfaces.IColour;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import transientlibs.bindedobjects.core.GDXFonts;
import transientlibs.processors.misc.Detonator;
import transientlibs.slick2d.util.Log;

/**
*
** @author kibertoad
*/
public class TransientGDXFont implements IFont{

    public BitmapFont font;
    public SpriteBatch batch;
    public GDXFonts fontInfo;

    @Override
    public GDXFonts getFontInfo() {
        return fontInfo;
    }

   
    public TransientGDXFont (GDXFonts fromFonts) {
//        this (fromFonts.file1, fromFonts.file2);       

        FileHandle path1 = new FileHandle (fromFonts.file1);
        FileHandle path2 = new FileHandle (fromFonts.file2);
       
        //if (fromFonts.font.font.isFlipped()) {
        font = new BitmapFont (path1, path2, false);       
        //} else {
        //font = new BitmapFont (path1, path2, true);                   
        //}
       
        fontInfo = fromFonts;               
    }
   
    public TransientGDXFont (String fromFile, String fromFile2) {
        FileHandle path1 = new FileHandle (fromFile);
        FileHandle path2 = new FileHandle (fromFile2);
        font = new BitmapFont (path1, path2, false);
    }
   
    public TransientGDXFont (BitmapFont setFont) {
        font = setFont;
    }

    @Override
    public int getWidth(String forText) {
        //Log.info("Width: "+((int) font.getBounds(forText).width));
        return (int) font.getBounds(forText).width;
       
       
    }

    @Override
    public int getHeight(String forText) {
        //Log.info("Width: "+((int) font.getBounds(forText).height));
        return (int) font.getBounds(forText).height;
    }



    @Override
    public void setBatch(SpriteBatch toBatch) {
        batch = toBatch;
    }

    @Override
    public void drawString(int onx, int ony, String string) {
        drawString(onx, ony, string, null);
    }

    @Override
    public String getName() {
        return fontInfo.LName.value;
    }

    @Override
    public void drawString(SpriteBatch spriteBatch, int onx, int ony, String theLine) {
        font.draw(spriteBatch, theLine, onx, ony);
    }

    @Override
    public void drawString(SpriteBatch spriteBatch, int onx, int ony, String theLine, IColour colour) {
     if (colour != null)  {
         //Log.info("Font not null: "+(font != null));
         //Log.info("GDXC not null: "+(colour.getGDXColour() != null));
         font.setColor(colour.getGDXColour());
         //Log.info("Color is not null: "+colour.toString()+", text:"+ theLine);
     }
     //else {
     //    Log.info("Color is null: "+", text:"+ theLine);
     //}
     drawString(spriteBatch, onx, Detonator.INSTANCE.currentGenericGame.getScreenHeight() - ony, theLine);
    }
   
    @Override
    public void drawString(float onX, float onY, String theLine, IColour colour) {
        if (colour != null) {font.setColor(colour.getGDXColour());}
       
        //Log.info("Font not null: "+(font != null));
        //Log.info("Batch not null: "+(batch != null));
        //Log.info("Line not null: "+(theLine != null));
       
        font.draw(batch, theLine, onX, onY);
    }   
   
}
TOP

Related Classes of transientlibs.preui.objects.gui.elements.TransientGDXFont

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.