Example usage for com.badlogic.gdx.scenes.scene2d.ui Align TOP

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Align TOP

Introduction

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

Prototype

int TOP

To view the source code for com.badlogic.gdx.scenes.scene2d.ui Align TOP.

Click Source Link

Usage

From source file:com.digitale.screens.CharPicker.java

License:Open Source License

public CharPicker() {
    try {/*from   ww w  .ja v a 2s . c  om*/
        Renderer.bindMeshes(3);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    Stardust3d.currencharacteruid = "" + Stardust3d.charList[0].getUid();
    int charListLength = 0;
    for (int i = 0; i < Stardust3d.charList.length; i++) {

        if (Stardust3d.charList[i].getFirstname() != null) {
            tempEntries[i] = new String("");
            tempEntries[i] = (Stardust3d.charList[i].getFirstname() + " "
                    + Stardust3d.charList[i].getSurname());
            tempEntries[i] = tempEntries[i] + ("  System " + Stardust3d.charList[i].getSystem()// + " Sta "
            //+ Stardust3d.charList[i].getStamina() + " Int "
            //+ Stardust3d.charList[i].getIntelligence() + " Soc " + Stardust3d.charList[i].getSocial()
            //+ " Dex " + Stardust3d.charList[i].getDexterity() + " Led "
            //+ Stardust3d.charList[i].getLeadership() + " Rec "
            //+ Stardust3d.charList[i].getRecuperation()
                    + ".  Flying: " + Util.asCapFirstChar(Stardust3d.charList[i].getShipname()));
            charListLength++;
        } else {
            tempEntries[i] = "";
        }
        listEntries = new String[charListLength];
        for (int j = 0; j < listEntries.length; j++) {
            listEntries[j] = tempEntries[j];
        }
    }

    currentAvatar = Stardust3d.charList[0].getAvatar();
    OrthographicCamera camera;
    batch = new SpriteBatch();
    skin = new Skin(Gdx.files.internal("data/uiskin.json"), Gdx.files.internal("data/uiskin.png"));
    xfadeTexture = new Texture(Gdx.files.internal("data/blackpixel.png"), Format.RGB565, true);
    xfadeTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    background = new Texture(Gdx.files.internal("data/bgpland.jpg"));
    camera = new OrthographicCamera();
    camera.setToOrtho(false, Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getHeight());

    fadeIn();
    stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
    Gdx.input.setInputProcessor(stage);
    final Button buttonEnterGame = new TextButton("Enter Game", skin.getStyle(TextButtonStyle.class),
            "button-enter-game");
    final Button buttonNewCharacter = new TextButton("New Character", skin.getStyle(TextButtonStyle.class),
            "button-enter-game");
    final Button buttonDeleteCharacter = new TextButton("Delete Character",
            skin.getStyle(TextButtonStyle.class), "button-enter-game");
    final SelectBox dropdown = new SelectBox(listEntries, skin.getStyle(SelectBoxStyle.class), "combo");
    final List list = new List(listEntries, skin.getStyle(ListStyle.class), "list");
    setAvatarPicture();
    if (Stardust3d.charList[0].getFirstname() == null) {
        selectedCharacter = "    ";
    } else {
        selectedCharacter = (Stardust3d.charList[0].getFirstname() + " " + Stardust3d.charList[0].getSurname());
    }
    final Label fpsLabel = new Label(selectedCharacter, skin.getStyle(LabelStyle.class), "label");

    Window window = new Window("Choose Character", skin.getStyle(WindowStyle.class), "window");
    if (Stardust3d.DEBUG)
        window.debug();
    window.x = window.y = 0;
    window.setFillParent(true);
    window.setMovable(false);
    window.align(Align.TOP);
    window.defaults().pad(5);
    window.defaults().spaceBottom(5).align("top");
    window.row().fill().expandX().maxHeight(28);
    window.add(buttonNewCharacter);
    window.add(buttonDeleteCharacter);
    window.add(buttonEnterGame);
    window.row();

    window.add(dropdown).colspan(3);
    window.row();
    window.add(imageActor).size(128, 128);
    window.add(fpsLabel).colspan(2).align("centre");
    window.add();
    window.pack();

    stage.addActor(window);

    dropdown.setSelectionListener(new SelectionListener() {
        @Override
        public void selected(Actor actor, int index, String value) {
            SoundManager.playuiclick();
            selectedCharacter = (Stardust3d.charList[index].getFirstname() + " "
                    + Stardust3d.charList[index].getSurname());
            Stardust3d.currencharacteruid = "" + Stardust3d.charList[index].getUid();
            currentAvatar = Stardust3d.charList[index].getAvatar();
            setAvatarPicture();
            ((Label) stage.findActor("label")).setText(selectedCharacter);

        }
    });

    buttonEnterGame.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {
            if (Stardust3d.DEBUG)
                System.out.println("Charpicker Close");
            SoundManager.playuiclick();
            if (Stardust3d.DEBUG)
                System.out.println("character ID" + Stardust3d.currencharacteruid);
            if (Integer.valueOf(Stardust3d.currencharacteruid) != 0) {
                //populate game from db, based on this char
                Stardust3d.gameMode = 4;
                //init character
                Stardust3d.MyDataOp.get3dChar(Integer.valueOf(Stardust3d.currencharacteruid));
                //
                if (!Stardust3d.DEBUG) {
                    String passed = Stardust3d.MyDataOp.postChat(Stardust3d.myCharacter.getFirstname() + " "
                            + Stardust3d.myCharacter.getSurname() + " has joined the game.", 1, 48);
                }
                Stardust3d.MyDataOp.getInventory(Integer.valueOf(Stardust3d.currencharacteruid), true);
                Stardust3d.MyDataOp.getSolarSystem(Stardust3d.myCharacter.getX(), Stardust3d.myCharacter.getX(),
                        Stardust3d.myCharacter.getZ());
                Stardust3d.MyDataOp.getLocalPlayers(Stardust3d.myCharacter.getX(),
                        Stardust3d.myCharacter.getY(), Stardust3d.myCharacter.getZ(), true);
                Stardust3d.MyDataOp.start();

                try {
                    Renderer.bindMeshes(4);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                doneflag = true;
            } else {
                stage.addActor(
                        Actors.bottomToast("Please select a character before entering the game.", 4, skin));
            }
        }
    });
    buttonNewCharacter.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();
            if (Stardust3d.numberOfCharacters >= 10) {
                SoundManager.playError();
                stage.addActor(Actors.bottomToast(
                        "You already have 10 characters, you must delete one first, before you can create a new one.",
                        4, skin));
            } else {
                // startNewCharActivity();
                Stardust3d.gameMode = 15;
                stage.addActor(Actors.bottomToast("Creating new character", 4, skin));
                doneflag = true;
            }
        }
    });

    DialogListener dialogListener = (new DialogListener() {

        @Override
        public void optionSelected(int option) {
            System.out.println("option " + option);
            if (option == 1) {
                System.out.println("no");
                stage.removeActor(dialog);
            }
            if (option == 0) {
                System.out.println("yes");
                System.out.println("DELETED" + selectedCharacter + " " + Stardust3d.currencharacteruid);
                stage.removeActor(dialog);
            }

        }

    });
    dialogTexts = ("Are you sure you wish to delete " + selectedCharacter
            + ", and all the contents of thier inventory?");
    dialog = (Actors.twoOptionsDialog(selectedCharacter, dialogListener, "Delete Character", "Yes", "No",
            skin));
    buttonDeleteCharacter.setClickListener(new ClickListener() {

        public void click(Actor actor, float x, float y) {

            SoundManager.playuiclick();

            stage.addActor(dialog);

        }
    });
}

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

License:Apache License

@Override
public void layout() {
    computeBounds();//  ww w  . j  a  va 2s .  c  o m

    if (wrap) {
        float prefHeight = getPrefHeight();
        if (prefHeight != lastPrefHeight) {
            lastPrefHeight = prefHeight;
            invalidateHierarchy();
        }
    }

    float y;
    if ((labelAlign & Align.TOP) != 0) {
        y = cache.getFont().isFlipped() ? 0 : height - bounds.height;
        y += style.font.getDescent();
    } else if ((labelAlign & Align.BOTTOM) != 0) {
        y = cache.getFont().isFlipped() ? height - bounds.height : 0;
        y -= style.font.getDescent();
    } else
        y = (height - bounds.height) / 2;
    if (!cache.getFont().isFlipped())
        y += bounds.height;

    float x;
    if ((labelAlign & Align.LEFT) != 0)
        x = 0;
    else if ((labelAlign & Align.RIGHT) != 0) {
        x = width - bounds.width;
    } else
        x = (width - bounds.width) / 2;

    if (wrap)
        cache.setWrappedText(text, x, y, bounds.width, lineAlign);
    else
        cache.setMultiLineText(text, x, y, bounds.width, lineAlign);
}