Example usage for com.badlogic.gdx.scenes.scene2d.ui Skin getFont

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Skin getFont

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui Skin getFont.

Prototype

public BitmapFont getFont(String name) 

Source Link

Usage

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.FloatValueLabel.java

License:Apache License

public FloatValueLabel(CharSequence text, float initialValue, Skin skin, String fontName, Color color) {
    this(text, initialValue, new LabelStyle(skin.getFont(fontName), color));
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.FloatValueLabel.java

License:Apache License

public FloatValueLabel(CharSequence text, float initialValue, Skin skin, String fontName, String colorName) {
    this(text, initialValue, new LabelStyle(skin.getFont(fontName), skin.getColor(colorName)));
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.FpsLabel.java

License:Apache License

public FpsLabel(CharSequence text, Skin skin, String fontName, Color color) {
    this(text, new LabelStyle(skin.getFont(fontName), color));
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.FpsLabel.java

License:Apache License

public FpsLabel(CharSequence text, Skin skin, String fontName, String colorName) {
    this(text, new LabelStyle(skin.getFont(fontName), skin.getColor(colorName)));
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.IntValueLabel.java

License:Apache License

public IntValueLabel(CharSequence text, int initialValue, Skin skin, String fontName, Color color) {
    this(text, initialValue, new LabelStyle(skin.getFont(fontName), color));
}

From source file:com.badlogic.gdx.ai.tests.utils.scene2d.IntValueLabel.java

License:Apache License

public IntValueLabel(CharSequence text, int initialValue, Skin skin, String fontName, String colorName) {
    this(text, initialValue, new LabelStyle(skin.getFont(fontName), skin.getColor(colorName)));
}

From source file:com.bladecoder.engine.ui.defaults.ScenePointer.java

License:Apache License

public ScenePointer(Skin skin) {
    //      this.skin = skin;
    font = skin.getFont("desc");
    pointerIcon = skin.getAtlas().findRegion(POINTER_ICON);
    leaveIcon = skin.getAtlas().findRegion(LEAVE_ICON);
    hotspotIcon = skin.getAtlas().findRegion(HOTSPOT_ICON);
    reset();//from w w w  .  j  av a 2 s.c o m
}

From source file:com.gsn.engine.template.GsnLabel.java

License:Apache License

/** Creates a label, using a {@link LabelStyle} that has a BitmapFont with the specified name from the skin and the specified
 * color. *//* ww  w  . j  a  v a 2 s  . co m*/
public GsnLabel(String text, String fontName, Color color, Skin skin) {
    this(text, new LabelStyle(skin.getFont(fontName), color), null);
}

From source file:com.gsn.engine.template.GsnLabel.java

License:Apache License

/** Creates a label, using a {@link LabelStyle} that has a BitmapFont with the specified name and the specified color from the
 * skin. *///from   w w  w .j  a v  a2 s  . co  m
public GsnLabel(String text, String fontName, String colorName, Skin skin) {
    this(text, new LabelStyle(skin.getFont(fontName), skin.getColor(colorName)), null);
}

From source file:com.jupiter.europa.screen.MainMenuScreen.java

License:Open Source License

private static void buildMainMenuSkin() {
    Skin skin = new Skin();

    // Fonts/*from   w w  w.ja  v a2  s .  co  m*/
    skin.add(BUTTON_FONT_KEY, EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(BUTTON_FONT).toString()));
    skin.add(TITLE_FANCY_FONT_KEY, EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(TITLE_FANCY_FONT).toString()));
    skin.add(TITLE_FONT_KEY, EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(TITLE_FONT).toString()));
    skin.add(LIST_FONT_KEY,
            EuropaGame.game.getAssetManager().get(FileLocations.FONTS_DIRECTORY.resolve(LIST_FONT).toString()));
    skin.add(TEXT_FIELD_FONT_KEY, EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(TEXT_FIELD_FONT).toString()));
    skin.add(INFO_LABEL_FONT_KEY, EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(INFO_LABEL_FONT).toString()));

    // Set the background texture
    Pixmap pixmap = new Pixmap(1, (int) 1, Pixmap.Format.RGB888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    skin.add(SOLID_TEXTURE_KEY, new Texture(pixmap));
    Drawable transparentDrawable = skin.newDrawable(SOLID_TEXTURE_KEY, TRANSPARENT);

    // Get values from the atlas
    skin.addRegions(
            EuropaGame.game.getAssetManager().get(MAIN_MENU_SKIN_DIRECTORY.resolve(ATLAS_KEY).toString()));

    // Colors
    Color textButtonFontColor = new Color(0.85f, 0.85f, 0.85f, 1.0f);

    // Set images
    Drawable textButtonBackground = new TextureRegionDrawable(
            skin.get(BUTTON_BACKGROUND_KEY, TextureRegion.class));
    textButtonBackground.setLeftWidth(32);
    textButtonBackground.setRightWidth(32);
    textButtonBackground.setTopHeight(5);
    textButtonBackground.setBottomHeight(5);
    skin.add(BUTTON_BACKGROUND_KEY, textButtonBackground);

    Drawable textButtonBackgroundDown = new TextureRegionDrawable(
            skin.get(BUTTON_DOWN_KEY, TextureRegion.class));
    textButtonBackgroundDown.setLeftWidth(32);
    textButtonBackgroundDown.setRightWidth(32);
    textButtonBackgroundDown.setTopHeight(5);
    textButtonBackgroundDown.setBottomHeight(5);
    skin.add(BUTTON_DOWN_KEY, textButtonBackgroundDown);

    Drawable listSelection = new TextureRegionDrawable(skin.get(LIST_SELECTION_KEY, TextureRegion.class));
    listSelection.setLeftWidth(7);
    listSelection.setRightWidth(7);
    listSelection.setTopHeight(0);
    listSelection.setBottomHeight(0);
    skin.add(LIST_SELECTION_KEY, listSelection);

    Drawable tabButtonBackground = new TextureRegionDrawable(
            skin.get(TAB_BUTTON_BACKGROUND_KEY, TextureRegion.class));
    tabButtonBackground.setLeftWidth(5);
    tabButtonBackground.setRightWidth(5);
    tabButtonBackground.setTopHeight(0);
    tabButtonBackground.setBottomHeight(0);
    skin.add(TAB_BUTTON_BACKGROUND_KEY, tabButtonBackground);

    Drawable tabButtonBackgroundSelected = new TextureRegionDrawable(
            skin.get(TAB_BUTTON_SELECTED_KEY, TextureRegion.class));
    tabButtonBackgroundSelected.setLeftWidth(5);
    tabButtonBackgroundSelected.setRightWidth(5);
    tabButtonBackgroundSelected.setTopHeight(0);
    tabButtonBackgroundSelected.setBottomHeight(0);
    skin.add(TAB_BUTTON_SELECTED_KEY, tabButtonBackgroundSelected);

    Drawable titleBackground = new TextureRegionDrawable(skin.get(TITLE_BACKGROUND_KEY, TextureRegion.class));
    titleBackground.setLeftWidth(10);
    titleBackground.setRightWidth(10);
    titleBackground.setTopHeight(0);
    titleBackground.setBottomHeight(0);
    skin.add(TITLE_BACKGROUND_KEY, titleBackground);

    Drawable numberIncreaseDrawable = new TextureRegionDrawable(
            skin.get(NUMBER_SELECTOR_INCREASE_KEY, TextureRegion.class));
    numberIncreaseDrawable.setLeftWidth(0);
    numberIncreaseDrawable.setRightWidth(0);
    numberIncreaseDrawable.setTopHeight(0);
    numberIncreaseDrawable.setBottomHeight(0);
    skin.add(NUMBER_SELECTOR_INCREASE_KEY, numberIncreaseDrawable);

    Drawable numberDecreaseDrawable = new TextureRegionDrawable(
            skin.get(NUMBER_SELECTOR_DECREASE_KEY, TextureRegion.class));
    numberDecreaseDrawable.setLeftWidth(0);
    numberDecreaseDrawable.setRightWidth(0);
    numberDecreaseDrawable.setTopHeight(0);
    numberDecreaseDrawable.setBottomHeight(0);
    skin.add(NUMBER_SELECTOR_DECREASE_KEY, numberDecreaseDrawable);

    skin.add(DIALOG_BACKGROUND_KEY,
            skin.newDrawable(new TextureRegionDrawable(skin.get(DIALOG_BACKGROUND_KEY, TextureRegion.class)),
                    new Color(1.0f, 1.0f, 1.0f, 1.0f)));
    skin.add(POPUP_BACKGROUND_KEY,
            skin.newDrawable(new TextureRegionDrawable(skin.get(POPUP_BACKGROUND_KEY, TextureRegion.class)),
                    new Color(1.0f, 1.0f, 1.0f, 1.0f)));
    skin.add(LIST_BACKGROUND_KEY,
            skin.newDrawable(new TextureRegionDrawable(skin.get(LIST_BACKGROUND_KEY, TextureRegion.class)),
                    new Color(1.0f, 1.0f, 1.0f, 1.0f)));
    skin.add(LIST_SELECTION_KEY,
            skin.newDrawable(new TextureRegionDrawable(skin.get(LIST_SELECTION_KEY, TextureRegion.class)),
                    new Color(1.0f, 1.0f, 1.0f, 1.0f)));
    skin.add(CREDITS_BACKGROUND_KEY,
            skin.newDrawable(new TextureRegionDrawable(skin.get(CREDITS_BACKGROUND_KEY, TextureRegion.class)),
                    new Color(1.0f, 1.0f, 1.0f, 1.0f)));

    Drawable dropdownListBackground = skin.newDrawable(
            new TextureRegionDrawable(skin.get(DROP_DOWN_LIST_BACKGROUND, TextureRegion.class)),
            new Color(1, 1, 1, 1));
    dropdownListBackground.setLeftWidth(28);
    dropdownListBackground.setRightWidth(28);
    dropdownListBackground.setTopHeight(0);
    dropdownListBackground.setBottomHeight(0);
    skin.add(DROP_DOWN_LIST_BACKGROUND, dropdownListBackground);

    // Create a Label style for the title
    Label.LabelStyle titleStyle = new Label.LabelStyle();
    titleStyle.background = transparentDrawable;
    titleStyle.font = skin.getFont(TITLE_FONT_KEY);
    titleStyle.fontColor = new Color(Color.BLACK);
    skin.add(DEFAULT_KEY, titleStyle);

    // Fancy Character Label Style
    Label.LabelStyle fancyTitleStyle = new Label.LabelStyle();
    fancyTitleStyle.background = transparentDrawable;
    fancyTitleStyle.font = skin.getFont(TITLE_FANCY_FONT_KEY);
    fancyTitleStyle.fontColor = new Color(Color.BLACK);
    skin.add(FANCY_KEY, fancyTitleStyle);

    // Create a Label style for dialogs
    LabelStyle infoStyle = new LabelStyle();
    infoStyle.background = transparentDrawable;
    infoStyle.font = skin.getFont(INFO_LABEL_FONT_KEY);
    infoStyle.fontColor = new Color(Color.BLACK);
    skin.add(INFO_STYLE_KEY, infoStyle);

    // Default Button Style
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = textButtonBackground;
    textButtonStyle.down = textButtonBackgroundDown;
    textButtonStyle.checked = textButtonBackground;
    textButtonStyle.over = textButtonBackgroundDown;
    textButtonStyle.disabled = textButtonBackground;
    textButtonStyle.font = skin.getFont(BUTTON_FONT_KEY);
    textButtonStyle.fontColor = textButtonFontColor;
    textButtonStyle.disabledFontColor = new Color(0.3f, 0.3f, 0.3f, 1.0f);
    //        textButtonStyle.pressedOffsetX = 2f;
    //        textButtonStyle.pressedOffsetY = -3f;
    skin.add(DEFAULT_KEY, textButtonStyle);

    // Tab Button Style
    TextButtonStyle tabButtonStyle = new TextButtonStyle();
    tabButtonStyle.up = tabButtonBackground;
    tabButtonStyle.down = tabButtonBackground;
    tabButtonStyle.checked = tabButtonBackgroundSelected;
    tabButtonStyle.over = tabButtonBackground;
    tabButtonStyle.disabled = tabButtonBackground;
    tabButtonStyle.font = skin.getFont(BUTTON_FONT_KEY);
    tabButtonStyle.fontColor = textButtonFontColor;
    tabButtonStyle.overFontColor = textButtonFontColor;
    tabButtonStyle.disabledFontColor = new Color(Color.GRAY);
    skin.add(TAB_STYLE_KEY, tabButtonStyle);

    // Create a TextField style
    TextFieldStyle textFieldStyle = new TextFieldStyle();
    textFieldStyle.background = skin.newDrawable(SOLID_TEXTURE_KEY, new Color(0f, 0f, 0f, 0.1f));
    textFieldStyle.selection = skin.newDrawable(SOLID_TEXTURE_KEY, new Color(0f, 0f, 1f, 0.3f));
    textFieldStyle.cursor = skin.newDrawable(SOLID_TEXTURE_KEY, Color.BLACK);
    textFieldStyle.font = skin.getFont(TEXT_FIELD_FONT_KEY);
    textFieldStyle.fontColor = Color.BLACK;
    skin.add(DEFAULT_KEY, textFieldStyle);

    // Create a List style
    ListStyle listStyle = new ListStyle();
    listStyle.font = skin.getFont(LIST_FONT_KEY);
    listStyle.fontColorSelected = Color.BLACK;
    listStyle.fontColorUnselected = Color.BLACK;
    listStyle.selection = listSelection;
    listStyle.background = transparentDrawable;
    skin.add(DEFAULT_KEY, listStyle);

    // Create a Scroll Pane Style
    ScrollPaneStyle scrollPaneStyle = new ScrollPaneStyle();
    scrollPaneStyle.background = transparentDrawable;
    //        scrollPaneStyle.vScroll = skin.newDrawable(MainMenuScreen.SCROLL_BAR_VERTICAL_KEY);
    //        scrollPaneStyle.vScrollKnob = skin.newDrawable(MainMenuScreen.SCROLL_BAR_VERTICAL_KNOB_KEY);
    skin.add(DEFAULT_KEY, scrollPaneStyle);

    // Create a Dialog Style
    WindowStyle dialogStyle = new WindowStyle();
    dialogStyle.background = new SpriteDrawable(
            new Sprite(EuropaGame.game.getAssetManager().get(BACKGROUND_FILE_NAME, Texture.class)));
    dialogStyle.titleFont = skin.getFont(TITLE_FONT_KEY);
    dialogStyle.titleFontColor = new Color(Color.BLACK);
    skin.add(DEFAULT_KEY, dialogStyle);

    // Popup Dialog Style
    WindowStyle popupStyle = new WindowStyle();
    popupStyle.titleFont = skin.getFont(TITLE_FONT_KEY);
    popupStyle.titleFontColor = new Color(Color.BLACK);
    skin.add(POPUP_DIALOG_STYLE_KEY, popupStyle);

    // Create a Slider Skin
    SliderStyle sliderStyle = new SliderStyle();
    sliderStyle.background = new TextureRegionDrawable(skin.get(SLIDER_BACKGROUND_KEY, TextureRegion.class));
    sliderStyle.knob = new TextureRegionDrawable(skin.get(SLIDER_KNOB_KEY, TextureRegion.class));
    skin.add(DEFAULT_KEY, sliderStyle);

    // Create a Drop Down Menu Skin
    SelectBoxStyle selectBoxStyle = new SelectBoxStyle();
    selectBoxStyle.background = textButtonBackground;
    selectBoxStyle.backgroundOpen = textButtonBackgroundDown;
    selectBoxStyle.backgroundOver = textButtonBackgroundDown;
    selectBoxStyle.scrollStyle = scrollPaneStyle;
    selectBoxStyle.font = skin.getFont(TEXT_FIELD_FONT_KEY);
    selectBoxStyle.fontColor = textButtonFontColor;
    ListStyle selectBoxListStyle = new ListStyle();
    selectBoxListStyle.font = skin.getFont(LIST_FONT_KEY);
    selectBoxListStyle.fontColorSelected = textButtonFontColor;
    selectBoxListStyle.fontColorUnselected = textButtonFontColor;
    selectBoxListStyle.selection = skin.newDrawable(SOLID_TEXTURE_KEY, SELECTION_COLOR);
    selectBoxListStyle.background = dropdownListBackground;
    selectBoxStyle.listStyle = selectBoxListStyle;
    skin.add(DEFAULT_KEY, selectBoxStyle);

    // NumberSelectorStyle
    NumberSelectorStyle numberStyle = new NumberSelectorStyle();
    numberStyle.decrease = numberDecreaseDrawable;
    numberStyle.increase = numberIncreaseDrawable;
    numberStyle.minimumNumberSize = 50;
    numberStyle.numberLabelStyle = infoStyle;
    numberStyle.spacing = COMPONENT_SPACING;
    skin.add(DEFAULT_KEY, numberStyle);

    // AttributeSelectorStyle
    MultipleNumberSelectorStyle attrStyle = new MultipleNumberSelector.MultipleNumberSelectorStyle();
    attrStyle.labelStyle = infoStyle;
    attrStyle.numberSelectorStyle = numberStyle;
    attrStyle.spacing = COMPONENT_SPACING;
    skin.add(DEFAULT_KEY, attrStyle);

    mainMenuSkin = skin;
}