Example usage for com.badlogic.gdx.graphics Color WHITE

List of usage examples for com.badlogic.gdx.graphics Color WHITE

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics Color WHITE.

Prototype

Color WHITE

To view the source code for com.badlogic.gdx.graphics Color WHITE.

Click Source Link

Usage

From source file:com.jumpbuttonstudios.vikingdodge.Assets.java

License:Apache License

/** Loads the required assets into the skin for the loading screen UI */
public static void loadingScreenUIDependencies() {
    skin.add("menu_bg", new TextureRegionDrawable(new TextureRegion(get(UI_MENU_BG))));
    skin.add("logo", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_LOGO))));
    skin.add("label", new LabelStyle(get(UI_FONT), Color.WHITE));
}

From source file:com.jumpbuttonstudios.vikingdodge.Assets.java

License:Apache License

/** Add all the requires user interface assets to the skin */
public static void loadUI() {

    /* ALL BUTTON STUFF */
    ButtonStyle style = new ButtonStyle();
    /* Create play button */
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PLAY)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PLAY_PRESSED)));
    skin.add("play", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HOWTO)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HOWTO_PRESSED)));
    skin.add("howToButton", style);

    /* Create login button */
    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LOGIN)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LOGIN_PRESSED)));
    skin.add("login", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LOGOUT)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LOGOUT_PRESSED)));
    skin.add("logout", style);

    /* Create highscores button */
    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HIGHSCORES)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HIGHSCORES_PRESSED)));
    skin.add("highscores", style);

    /* Create left and right buttons */
    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LEFT)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_LEFT_PRESSED)));
    style.over = style.down;//w w w  . j  a va  2  s .  c  o  m
    skin.add("left", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_RIGHT)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_RIGHT_PRESSED)));
    style.over = style.down;
    skin.add("right", style);

    /* Create jump and throw buttons */
    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_JUMP)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_JUMP_PRESSED)));
    skin.add("jump", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_THROW)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_THROW_PRESSED)));
    skin.add("throw", style);

    /* Create pause popup stuff */
    skin.add("pauseClosed", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_PAUSE))));
    skin.add("pauseOpen", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_PAUSE_OPEN))));

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_RESUME)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_RESUME_PRESSED)));
    skin.add("resumeButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PAUSE)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PAUSE_PRESSED)));
    skin.add("pauseButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_REDO)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_REDO_PRESSED)));
    skin.add("redoButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_MAINMENU)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_MAINMENU_PRESSED)));
    skin.add("exitButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_EMPTY)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_EMPTY)));
    skin.add("emptyButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_OK)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_OK_PRESSED)));
    skin.add("okButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HELP)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_HELP_PRESSED)));
    skin.add("helpButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_REGISTER)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_REGISTER_PRESSED)));
    skin.add("registerButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_BACK)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_BACK_PRESSED)));
    skin.add("backButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_MAIN_MENU_GO)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_MAIN_MENU_GO_PRESSED)));
    skin.add("mainmenuGoButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PLAYAGAIN)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_PLAYAGAIN_PRESSED)));
    skin.add("playagainButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_FACEBOOK)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_FACEBOOK_PRESSED)));
    skin.add("facebookButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_TWITTER)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_TWITTER_PRESSED)));
    skin.add("twitterButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_JBS)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_JBS_PRESSED)));
    skin.add("jbsButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_VOLUME_OFF)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_VOLUME_OFF_PRESSED)));
    skin.add("soundOffButton", style);

    style = new ButtonStyle();
    style.up = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_VOLUME_ON)));
    style.down = new TextureRegionDrawable(new TextureRegion(get(UI_BUTTON_VOLUME_ON_PRESSED)));
    skin.add("soundOnButton", style);

    /* Main menu login/out shit */
    skin.add("loginWindow", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_LOGIN))));
    skin.add("logoutWindow", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_LOGOUT))));
    skin.add("wrongInfo", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_WRONG_INFO))));
    skin.add("noConnection", new TextureRegionDrawable(new TextureRegion(get(UI_WINDOW_NO_CONNECTION))));
    skin.add("avatarBox", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_AVATAR_BOX))));
    skin.add("avatarBoxLogged",
            new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_AVATAR_BOX_LOGGED_IN))));
    skin.add("welcomeBar", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_WELCOME_BAR))));

    TextFieldStyle textFieldStyle = new TextFieldStyle();
    textFieldStyle.font = get(UI_FONT);
    textFieldStyle.fontColor = Color.BLACK;
    skin.add("field", TextFieldStyle.class);

    /* HIGHSCORE SCREEN PANELS */
    skin.add("personalPanel", new TextureRegionDrawable(new TextureRegion(get(UI_PANEL_PERSONAL))));
    skin.add("globalPanel", new TextureRegionDrawable(new TextureRegion(get(UI_PANEL_GLOBAL))));
    skin.add("friendsPanel", new TextureRegionDrawable(new TextureRegion(get(UI_PANEL_FRIENDS))));

    skin.add("bronzeHelmet", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_HELMET_BRONZE))));
    skin.add("silverHelmet", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_HELMET_SILVER))));
    skin.add("goldHelmet", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_HELMET_GOLD))));

    skin.add("playerBar", new TextureRegionDrawable(new TextureRegion(get(UI_WIDGET_PLAYERBAR))));

    skin.add("smallLabel", new LabelStyle(get(UI_FONT_SMALL), Color.WHITE));
    skin.add("largeLabel", new LabelStyle(get(UI_FONT_LARGE), Color.WHITE));

    /* That dark panel thing */
    skin.add("darkBG", new TextureRegionDrawable(new TextureRegion(get(EFFECT_DARK_BG))));

    TextButtonStyle textButtonStyle = new TextButtonStyle();
    textButtonStyle.font = get(UI_FONT);
    skin.add("default", textButtonStyle);

    uiLoaded = true;

}

From source file:com.jumpbuttonstudios.vikingdodge.ui.popup.LoginPopup.java

License:Apache License

@Override
public void create() {
    setScreenPositions(vikingDodge.getUi().getWidth() / 2 - (background.getWidth() / 2), 850,
            vikingDodge.getUi().getWidth() / 2 - (background.getWidth() / 2),
            vikingDodge.getUi().getHeight() / 2 - (background.getHeight() / 2));

    usernameAndPasswordTable = new Table();
    style = new TextFieldStyle();

    style.font = Assets.get(Assets.UI_FONT_TEXT_FIELD);
    style.fontColor = Color.WHITE;
    style.disabledFontColor = Color.ORANGE;

    username = new TextField("", style);
    password = new TextField("", style);
    password.setPasswordCharacter('*');
    password.setPasswordMode(true);/*  w  w w. j  a  va 2  s.c o m*/

    buttonsTable = new Table();

    help = new Button(Assets.skin.get("helpButton", ButtonStyle.class));
    ok = new Button(Assets.skin.get("okButton", ButtonStyle.class));
    register = new Button(Assets.skin.get("registerButton", ButtonStyle.class));

    // TODO Remove later, testing
    //      username.setText("gibbo");
    //      password.setText("tycoon");
}

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

License:Open Source License

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

    // Fonts//w  w w  .ja va2 s.c o  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;
}

From source file:com.jupiter.europa.screen.overlay.PauseMenu.java

License:Open Source License

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

    skin.add("button-font", EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(BUTTON_FONT).toString()));
    skin.add("title-font", EuropaGame.game.getAssetManager()
            .get(FileLocations.FONTS_DIRECTORY.resolve(TITLE_FONT).toString()));

    // Set the background texture
    Pixmap pixmap = new Pixmap(1, (int) 1, Pixmap.Format.RGB888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();/*w w  w  .  j  av a 2  s .  c  o m*/
    skin.add("background", new Texture(pixmap));

    // Create a Label style for the title
    Label.LabelStyle titleStyle = new Label.LabelStyle();
    titleStyle.background = skin.newDrawable("background", TRANSPARENT);
    titleStyle.font = skin.getFont("title-font");
    titleStyle.fontColor = Color.BLACK;
    skin.add("default", titleStyle);

    //Create a button style
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.up = skin.newDrawable("background", TRANSPARENT);
    textButtonStyle.down = skin.newDrawable("background", TRANSPARENT);
    textButtonStyle.checked = skin.newDrawable("background", TRANSPARENT);
    textButtonStyle.over = skin.newDrawable("background", TRANSPARENT);
    textButtonStyle.disabled = skin.newDrawable("background", TRANSPARENT);
    textButtonStyle.font = skin.getFont("button-font");
    textButtonStyle.fontColor = Color.TEAL;
    textButtonStyle.overFontColor = Color.YELLOW;
    textButtonStyle.disabledFontColor = Color.GRAY;
    textButtonStyle.pressedOffsetX = 2f;
    textButtonStyle.pressedOffsetY = -3f;
    skin.add("default", textButtonStyle);
    //        
    //        skin = EmergenceGame.game.getAssetManager().get(
    //                new File(FileLocations.SKINS_DIRECTORY, "main_menu.skin").getPath());
    pauseMenuSkin = skin;
}

From source file:com.jupiter.europa.screen.overlay.Scene2DOverlay.java

License:Open Source License

@Override
public void removed() {
    if (this.isBlocking() && EuropaGame.game.isSuspended()) {
        EuropaGame.game.wake();/*w  w  w . java2s  . c  o m*/
    }

    if (this.getTint() != null) {
        this.screen.setTint(Color.WHITE);
    }
}

From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java

License:Creative Commons License

private void assembleMenuGroup(TextureAtlas atlas) {

    infiniteLeftDecorator = new ActorDecorator() {
        @Override//from   w  w  w .j a  v a  2  s  .  c  om
        public void applyAdjustment(Actor actor, float v) {
            if (actor.getRight() <= 0f) {
                actor.setPosition(actor.getX() + (actor.getWidth() * 2f), 0f);
            }
        }
    };

    checkedMenuOptionDecorator = new PulsingScaleDecorator(0.025f, 1f);

    float w = stage.getWidth();
    float h = stage.getHeight();
    //Add BG
    bgGroup.addActor(new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_BG), Color.BLACK));

    GenericActor moon = new GenericActor(600f, 500f, MOON_WIDTH, MOON_HEIGHT,
            atlas.findRegion(AtlasUtil.ANI_TITLE_MOON), Color.YELLOW);
    moon.addDecorator(new ShakeDecorator(5f, 5f, 4f));
    moon.addDecorator(new OscillatingDecorator(5f, 10f, 2.5f));
    bgGroup.addActor(moon);
    //add Clouds5 setup
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C5), -25f);

    //Add Skyline2
    bgGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_SKYLINE2), Color.BLACK));

    //Add Cloud 4
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C4), -25f);

    //Add Cloud 3
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C3), -75f);

    //Add Skyline1
    bgGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_SKYLINE1), Color.BLACK));

    //Add Title
    bgGroup.addActor(new GenericActor(150f, 25f, TITLE_WIDTH, TITLE_HEIGHT,
            atlas.findRegion(AtlasUtil.ANI_TITLE_TITLE), Color.WHITE));

    //Add Cloud 2
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C2), -100);

    //Add Cloud 1
    addClouds(atlas.findRegion(AtlasUtil.ANI_TITLE_C1), -125f);

    //Add Platform
    menuGroup.addActor(
            new GenericActor(0f, 0f, w, h, atlas.findRegion(AtlasUtil.ANI_TITLE_PLATFORM), Color.BLACK));

    //Add Edison
    Animation eddyAni = new Animation(EDISON_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDISON));
    menuGroup.addActor(new AnimatedActor(0f, 0f, EDISON_WIDTH, EDISON_HEIGHT, eddyAni, 0f));
    //Add Edyn
    Animation edynAni = new Animation(EDYN_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDYN));
    menuGroup.addActor(new AnimatedActor(w - EDYN_WIDTH, 0f, EDYN_WIDTH, EDYN_HEIGHT, edynAni, 0f));

    Animation edynEyes = new Animation(EYE_CYCLE_RATE, atlas.findRegions(AtlasUtil.ANI_TITLE_EDYN_EYES));
    AnimatedActor eyes = new AnimatedActor(w - EDYN_WIDTH, 0f, EDYN_WIDTH, EDYN_HEIGHT, edynEyes, 0f);
    eyes.setIsLooping(false);
    eyes.addDecorator(new ActorDecorator() {
        private float secondsBeforeBlink = 0f;
        private float elapsedSeconds = 0f;
        private Random rand = new Random(System.currentTimeMillis());

        @Override
        public void applyAdjustment(Actor actor, float v) {
            AnimatedActor a = ((AnimatedActor) actor);

            if (a.isAnimationComplete()) {
                elapsedSeconds += v;
                if (elapsedSeconds >= secondsBeforeBlink) {
                    a.setState(AnimatedActor.DEFAULT_STATE, true);
                    elapsedSeconds = 0f;
                    secondsBeforeBlink = rand.nextInt(MAX_BLINK_INTERVAL) + MIN_BLINK_INTERVAL;
                }
            }
        }
    });

    menuGroup.addActor(eyes);

    Array<TextureAtlas.AtlasRegion> escapeImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_PLAY_BTN);
    TextureRegionDrawable escapeUp = new TextureRegionDrawable(escapeImgs.get(0));
    TextureRegionDrawable escapeDown = new TextureRegionDrawable(escapeImgs.get(1));

    startGameButton = new ImageButton(escapeUp, escapeDown, escapeDown);
    startGameButton.setSize(PLAY_BTN_WIDTH, PLAY_BTN_HEIGHT);
    startGameButton.addListener(listener);
    //startGameButton.setPosition(buttonX, buttonY);
    startGameButton.setChecked(true);

    startUiContainer = new DecoratedUIContainer(startGameButton);
    startUiContainer.setSize(PLAY_BTN_WIDTH, PLAY_BTN_HEIGHT);
    startUiContainer.setPosition(buttonX, buttonY);
    startUiContainer.addDecorator(checkedMenuOptionDecorator);
    menuGroup.addActor(startUiContainer);

    Array<TextureAtlas.AtlasRegion> optionsImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_OPT_BTN);
    TextureRegionDrawable optionsUp = new TextureRegionDrawable(optionsImgs.get(0));
    TextureRegionDrawable optionsDown = new TextureRegionDrawable(optionsImgs.get(1));
    optionsButton = new ImageButton(optionsUp, optionsDown, optionsDown);
    optionsButton.setSize(OPTS_BTN_WIDTH, OPTS_BTN_HEIGHT);

    //optionsButton.setPosition(buttonX, buttonY - (optionsButton.getHeight()));
    optionsButton.addListener(listener);
    optionsUiContainer = new DecoratedUIContainer(optionsButton);
    optionsUiContainer.setPosition(buttonX, buttonY - (PLAY_BTN_HEIGHT));
    optionsUiContainer.setSize(OPTS_BTN_WIDTH, OPTS_BTN_HEIGHT);
    //optUiContainer.addDecorator(checkedMenuOptionDecorator);
    menuGroup.addActor(optionsUiContainer);

    Array<TextureAtlas.AtlasRegion> hsImgs = atlas.findRegions(AtlasUtil.ANI_TITLE_HIGHSCORE_BTN);
    TextureRegionDrawable hsUp = new TextureRegionDrawable(hsImgs.get(0));
    TextureRegionDrawable hsDown = new TextureRegionDrawable(hsImgs.get(1));

    highScoreButton = new ImageButton(hsUp, hsDown, hsDown);
    highScoreButton.setSize(HS_BTN_WIDTH, HS_BTN_HEIGHT);
    highScoreButton.addListener(listener);

    highScoreUiContainer = new DecoratedUIContainer(highScoreButton);
    highScoreUiContainer.setSize(HS_BTN_WIDTH, HS_BTN_HEIGHT);
    highScoreUiContainer.setPosition(buttonX, optionsUiContainer.getY() - (PLAY_BTN_HEIGHT));
    menuGroup.addActor(highScoreUiContainer);
}

From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java

License:Creative Commons License

private void assembleOptionsGroup(TextureAtlas atlas) {

    /*/*from  w  w w  . j  a va 2 s  . c o m*/
     * Gather values
     */
    float sfxVolValue = gameProcessor.getStoredFloat(GameOptions.SFX_MUSIC_VOLUME_PREF_KEY);
    sfxVolValue = sfxVolValue < 0f ? 0f : sfxVolValue;
    float bgVolValue = gameProcessor.getStoredFloat(GameOptions.BG_MUSIC_VOLUME_PREF_KEY);
    bgVolValue = bgVolValue < 0f ? 0f : bgVolValue;

    charValue = gameProcessor.getStoredString(GameOptions.CHARACTER_SELECT_KEY);
    if (charValue == null || "".equals(charValue.trim())) {
        charValue = AnimationUtil.CHARACTER_2;
    }

    /*
     * Gather Reference Interatctions
     */
    Skin skin = gameProcessor.getAssetManager().get(AssetsUtil.DEFAULT_SKIN, AssetsUtil.SKIN);
    sfx = gameProcessor.getAssetManager().get(AssetsUtil.SND_SHIELD_ON, AssetsUtil.SOUND);

    /*
     * Add Scaffolding
     */
    GenericActor runnerScaffold = new GenericActor(0f, 0f, optionsGroup.getWidth(), optionsGroup.getHeight(),
            atlas.findRegion(AtlasUtil.ANI_OPTIONS_RUNNERSCAFFOLD), Color.WHITE);
    optionsGroup.addActor(runnerScaffold);

    GenericActor volumeScaffold = new GenericActor(0f, 0f, optionsGroup.getWidth(), optionsGroup.getHeight(),
            atlas.findRegion(AtlasUtil.ANI_OPTIONS_VOLUMESCAFFOLD), Color.WHITE);
    optionsGroup.addActor(volumeScaffold);

    Animation techAAni = new Animation(1f / 2f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_TECH_A));
    AnimatedActor techA = new AnimatedActor(TECHA_X, TECHA_Y, TECHA_W, TECHA_H, techAAni, 0f);
    optionsGroup.addActor(techA);
    Animation techBAni = new Animation(1f / 2f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_TECH_B));
    AnimatedActor techB = new AnimatedActor(TECHB_X, TECHB_Y, TECHB_W, TECHB_H, techBAni, 0f);
    optionsGroup.addActor(techB);

    /*
     * Add Player Buttons
     */
    Animation charAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_CHARSELECT));
    charIndicator = new AnimatedActor(CHAR_SEL_X, CHAR_SEL_Y, CHAR_SEL_W, CHAR_SEL_H, charAni, 0f);
    charIndicator.setTargetKeyFrame(1);
    optionsGroup.addActor(charIndicator);

    Animation edynDefCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_SELECT),
            Animation.PlayMode.REVERSED);
    Animation edynCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_SELECT));
    edynCircle = new AnimatedActor(EDYN_CIRCLE_X, EDYN_CIRCLE_Y, EDYN_CIRCLE_W, EDYN_CIRCLE_H, edynDefCircleAni,
            0f);
    edynCircle.addStateAnimation("SELECTED", edynCircleAni);
    edynCircle.setIsLooping(false);
    optionsGroup.addActor(edynCircle);
    Array<TextureAtlas.AtlasRegion> edynImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDYN_EYES);
    TextureRegionDrawable edynUp = new TextureRegionDrawable(edynImgs.get(0));
    TextureRegionDrawable edynDown = new TextureRegionDrawable(edynImgs.get(1));
    edynSelect = new ImageButton(edynUp, edynDown, edynDown);

    edynSelect.setSize(CHAR_CIRCLE_SIZE, CHAR_CIRCLE_SIZE);
    edynSelect.setPosition(EDYN_SELECT_X, CHAR_CIRCLE_Y);
    edynSelect.addListener(listener);
    edynSelect.setChecked(AnimationUtil.CHARACTER_2.equals(charValue));
    optionsGroup.addActor(edynSelect);

    Animation eddyDefCircleAni = new Animation(0.5f / 10f,
            atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_SELECT), Animation.PlayMode.REVERSED);
    Animation eddyCircleAni = new Animation(0.5f / 10f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_SELECT));
    eddyCircle = new AnimatedActor(EDISON_CIRCLE_X, EDISON_CIRCLE_Y, EDISON_CIRCLE_W, EDISON_CIRCLE_H,
            eddyDefCircleAni, 0f);
    eddyCircle.addStateAnimation("SELECTED", eddyCircleAni);
    eddyCircle.setIsLooping(false);
    optionsGroup.addActor(eddyCircle);

    Array<TextureAtlas.AtlasRegion> edisonImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_EDISON_EYES);
    TextureRegionDrawable edisonUp = new TextureRegionDrawable(edisonImgs.get(0));
    TextureRegionDrawable edisonDown = new TextureRegionDrawable(edisonImgs.get(1));
    edisonSelect = new ImageButton(edisonUp, edisonDown, edisonDown);
    edisonSelect.setSize(CHAR_CIRCLE_SIZE, CHAR_CIRCLE_SIZE);
    edisonSelect.setPosition(EDISON_SELECT_X, CHAR_CIRCLE_Y);
    edisonSelect.addListener(listener);
    edisonSelect.setChecked(AnimationUtil.CHARACTER_1.equals(charValue));
    optionsGroup.addActor(edisonSelect);

    charDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putString(GameOptions.CHARACTER_SELECT_KEY, charValue);
        }
    };

    /*
     * Add Main Menu Button
     */
    Array<TextureAtlas.AtlasRegion> mmImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_MAINMENU);
    TextureRegionDrawable mmDown = new TextureRegionDrawable(mmImgs.get(1));
    mainMenuButton = new ImageButton(new TextureRegionDrawable(mmImgs.get(0)), mmDown, mmDown);
    mainMenuButton.setSize(MM_W, MM_H);
    mainMenuButton.setPosition(MM_X, MM_Y);
    mainMenuButton.addListener(listener);
    optionsGroup.addActor(mainMenuButton);

    /*
     * Add Sliders
     */
    Animation bgAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_MUSIC));
    bgIndicator = new AnimatedActor(MUSIC_X, MUSIC_Y, MUSIC_W, MUSIC_H, bgAni, 0f);
    bgIndicator.setTargetKeyFrame(0);
    optionsGroup.addActor(bgIndicator);

    bgVolumeSet = new Slider(0f, 1f, 0.1f, false, skin);
    bgVolumeSet.setValue(bgVolValue);
    bgVolumeSet.setPosition(319f, 190f);
    bgVolumeSet.setSize(500f, 20f);
    optionsGroup.addActor(bgVolumeSet);
    bgDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putFloat(GameOptions.BG_MUSIC_VOLUME_PREF_KEY, bgVolumeSet.getValue());
        }
    };

    bgVolumeSet.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            gameProcessor.saveGameData(bgDataSaver);
            gameProcessor.setBGMusicVolume(bgVolumeSet.getValue());
        }
    });

    Animation sfxAni = new Animation(1f, atlas.findRegions(AtlasUtil.ANI_OPTIONS_SFX));
    sfxIndicator = new AnimatedActor(SFX_X, SFX_Y, SFX_W, SFX_H, sfxAni, 0f);
    sfxIndicator.setTargetKeyFrame(0);
    optionsGroup.addActor(sfxIndicator);

    sfxVolumeSet = new Slider(0f, 1f, 0.1f, false, skin);
    sfxVolumeSet.setValue(sfxVolValue);
    sfxVolumeSet.setPosition(208f, 68f);
    sfxVolumeSet.setSize(500f, 20f);
    optionsGroup.addActor(sfxVolumeSet);
    sfxDataSaver = new IDataSaver() {
        @Override
        public void updatePreferences(Preferences prefs) {
            prefs.putFloat(GameOptions.SFX_MUSIC_VOLUME_PREF_KEY, sfxVolumeSet.getValue());
        }
    };

    sfxVolumeSet.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            gameProcessor.saveGameData(sfxDataSaver);
            sfx.play(sfxVolumeSet.getValue());
        }
    });

    selectCharacter(edynSelect.isChecked());

    TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
    style.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_32, AssetsUtil.BITMAP_FONT);
    style.fontColor = Color.CYAN;

    TextButton credits = new TextButton("BG Music By DST under Creative Commons License", style);

    credits.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.net.openURI("http://creativecommons.org/licenses/by/3.0/legalcode");
            Gdx.net.openURI("http://www.nosoapradio.us/");
        }
    });
    credits.setPosition(optionsGroup.getWidth() / 2 - (credits.getWidth() / 2), 0f);
    optionsGroup.addActor(credits);
}

From source file:com.kasetagen.game.bubblerunner.screen.BubbleRunnerMenu.java

License:Creative Commons License

private void assembleHighScoreView(TextureAtlas atlas) {
    GenericActor highScoreScaffold = new GenericActor(0f, 0f, stage.getWidth(), stage.getHeight(),
            atlas.findRegion(AtlasUtil.ANI_HIGH_SCORE_BG), Color.BLACK);
    highScoreGroup.addActor(highScoreScaffold);

    /*/*from   w  ww .j  a  va 2  s .c o  m*/
     * Add Labels
     */
    Label.LabelStyle style = new Label.LabelStyle();
    style.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_64, AssetsUtil.BITMAP_FONT);
    highScoreLabel = new Label("High Score: " + UIUtil.convertIntToDigitsString(GameStats.MAX_SCORE_DIGITS, 0),
            style);
    highComboLabel = new Label("High Combo: " + UIUtil.convertIntToDigitsString(GameStats.MAX_COMBO_DIGITS, 0),
            style);
    adjustHighScores(scoreValue, comboValue);
    highScoreGroup.addActor(highScoreLabel);
    highScoreGroup.addActor(highComboLabel);

    /*
     * Add Clear Button
     */
    TextButton.TextButtonStyle tbStyle = new TextButton.TextButtonStyle();
    tbStyle.font = gameProcessor.getAssetManager().get(AssetsUtil.NEUROPOL_64, AssetsUtil.BITMAP_FONT);
    tbStyle.fontColor = Color.WHITE;
    tbStyle.downFontColor = Color.CYAN;
    float tbXPadding = 100f;
    float tbYPadding = 50f;
    clearScoresButton = new TextButton("Clear Scores", tbStyle);
    clearScoresButton.addListener(new ClickListener() {
        IDataSaver scoreClearer = new IDataSaver() {
            @Override
            public void updatePreferences(Preferences preferences) {
                preferences.putInteger(GameStats.HIGH_SCORE_KEY, 0);
                preferences.putInteger(GameStats.HIGH_COMBO_KEY, 0);
                preferences.putInteger(GameStats.MOST_MISSES_KEY, 0);
            }
        };

        @Override
        public void clicked(InputEvent event, float x, float y) {
            gameProcessor.saveGameData(scoreClearer);
            adjustHighScores(0, 0);
        }
    });
    clearScoresButton.setPosition(tbXPadding, tbYPadding);
    highScoreGroup.addActor(clearScoresButton);

    /*
    * Add Main Menu Button
    */
    Array<TextureAtlas.AtlasRegion> mmImgs = atlas.findRegions(AtlasUtil.ANI_OPTIONS_MAINMENU);
    TextureRegionDrawable mmDown = new TextureRegionDrawable(mmImgs.get(1));
    closeScoresButton = new TextButton("Main Menu", tbStyle);
    //closeScoresButton.setSize(300f, 100f);
    closeScoresButton.setPosition(highScoreGroup.getWidth() - (closeScoresButton.getWidth() + tbXPadding),
            tbYPadding);
    closeScoresButton.addListener(listener);
    highScoreGroup.addActor(closeScoresButton);
}

From source file:com.kevlanche.threedeetest.ScalableObjLoader.java

License:Apache License

/** loads .mtl file */
public void load(FileHandle file) {
    String line;//from w  ww  . ja  va 2  s .c  om
    String[] tokens;
    String curMatName = "default";
    Color difcolor = Color.WHITE;
    Color speccolor = Color.WHITE;
    float opacity = 1.f;
    float shininess = 0.f;
    String texFilename = null;

    if (file == null || file.exists() == false)
        return;

    BufferedReader reader = new BufferedReader(new InputStreamReader(file.read()), 4096);
    try {
        while ((line = reader.readLine()) != null) {

            if (line.length() > 0 && line.charAt(0) == '\t')
                line = line.substring(1).trim();

            tokens = line.split("\\s+");

            if (tokens[0].length() == 0) {
                continue;
            } else if (tokens[0].charAt(0) == '#')
                continue;
            else {
                final String key = tokens[0].toLowerCase();
                if (key.equals("newmtl")) {
                    ModelMaterial mat = new ModelMaterial();
                    mat.id = curMatName;
                    mat.diffuse = new Color(difcolor);
                    mat.specular = new Color(speccolor);
                    mat.opacity = opacity;
                    mat.shininess = shininess;
                    if (texFilename != null) {
                        ModelTexture tex = new ModelTexture();
                        tex.usage = ModelTexture.USAGE_DIFFUSE;
                        tex.fileName = new String(texFilename);
                        if (mat.textures == null)
                            mat.textures = new Array<ModelTexture>(1);
                        mat.textures.add(tex);
                    }
                    materials.add(mat);

                    if (tokens.length > 1) {
                        curMatName = tokens[1];
                        curMatName = curMatName.replace('.', '_');
                    } else
                        curMatName = "default";

                    difcolor = Color.WHITE;
                    speccolor = Color.WHITE;
                    opacity = 1.f;
                    shininess = 0.f;
                } else if (key.equals("kd") || key.equals("ks")) // diffuse or specular
                {
                    float r = Float.parseFloat(tokens[1]);
                    float g = Float.parseFloat(tokens[2]);
                    float b = Float.parseFloat(tokens[3]);
                    float a = 1;
                    if (tokens.length > 4)
                        a = Float.parseFloat(tokens[4]);

                    if (tokens[0].toLowerCase().equals("kd")) {
                        difcolor = new Color();
                        difcolor.set(r, g, b, a);
                    } else {
                        speccolor = new Color();
                        speccolor.set(r, g, b, a);
                    }
                } else if (key.equals("tr") || key.equals("d")) {
                    opacity = Float.parseFloat(tokens[1]);
                } else if (key.equals("ns")) {
                    shininess = Float.parseFloat(tokens[1]);
                } else if (key.equals("map_kd")) {
                    texFilename = file.parent().child(tokens[1]).path();
                }
            }
        }
        reader.close();
    } catch (IOException e) {
        return;
    }

    // last material
    ModelMaterial mat = new ModelMaterial();
    mat.id = curMatName;
    mat.diffuse = new Color(difcolor);
    mat.specular = new Color(speccolor);
    mat.opacity = opacity;
    mat.shininess = shininess;
    if (texFilename != null) {
        ModelTexture tex = new ModelTexture();
        tex.usage = ModelTexture.USAGE_DIFFUSE;
        tex.fileName = new String(texFilename);
        if (mat.textures == null)
            mat.textures = new Array<ModelTexture>(1);
        mat.textures.add(tex);
    }
    materials.add(mat);

    return;
}