Example usage for com.badlogic.gdx.scenes.scene2d.utils Align right

List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Align right

Introduction

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

Prototype

int right

To view the source code for com.badlogic.gdx.scenes.scene2d.utils Align right.

Click Source Link

Usage

From source file:com.ahsgaming.valleyofbones.screens.ServerScreen.java

License:Apache License

@Override
public void resize(int width, int height) {
    // TODO Auto-generated method stub
    super.resize(width, height);

    Table table = new Table(getSkin());
    table.setFillParent(true);/*from   w w  w.  j  av a 2 s.c om*/

    table.add("Server").pad(10);
    table.add("Port").pad(10);
    table.add("Public?").pad(10);
    table.add("Players").pad(10);
    table.add("Status").pad(10);

    table.row();

    listNames = new List(new String[] {}, getSkin());
    table.add(listNames).pad(5);

    listPorts = new List(new String[] {}, getSkin());
    table.add(listPorts).pad(5);

    listPublics = new List(new String[] {}, getSkin());
    table.add(listPublics).pad(5);

    listPlayers = new List(new String[] {}, getSkin());
    table.add(listPlayers).pad(5);

    listStatus = new List(new String[] {}, getSkin());
    table.add(listStatus).pad(5);

    ChangeListener changeAll = new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            int index = ((List) actor).getSelectedIndex();

            listNames.setSelectedIndex(index);
            listPorts.setSelectedIndex(index);
            listPublics.setSelectedIndex(index);
            listPlayers.setSelectedIndex(index);
            listStatus.setSelectedIndex(index);
        }
    };

    listNames.setSelectedIndex(-1);
    listNames.addListener(changeAll);

    listPorts.setSelectedIndex(-1);
    listPorts.addListener(changeAll);

    listPlayers.setSelectedIndex(-1);
    listPlayers.addListener(changeAll);

    listPublics.setSelectedIndex(-1);
    listPublics.addListener(changeAll);

    listStatus.setSelectedIndex(-1);
    listStatus.addListener(changeAll);

    table.row();

    btnStopServer = new TextButton("Kill Server", getSkin(), "cancel");
    table.add(btnStopServer).colspan(5).align(Align.right);

    btnStopServer.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);

            if (listStatus.getSelectedIndex() >= 0
                    && listStatus.getSelectedIndex() < ((VOBServer) game).getGameServers().size) {
                ((VOBServer) game).getGameServers().get(listStatus.getSelectedIndex()).setStopServer(true);
            }
        }
    });

    table.row();

    txtName = new TextField("A server", getSkin());
    table.add(txtName).pad(5);

    txtPort = new TextField("" + KryoCommon.tcpPort, getSkin());
    table.add(txtPort).pad(5);

    chkPublic = new CheckBox("", getSkin());
    table.add(chkPublic).pad(5);

    TextButton btnAddServer = new TextButton("Start Server", getSkin());
    table.add(btnAddServer).pad(5).colspan(2);

    btnAddServer.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);

            addServer();
        }
    });

    stage.addActor(table);
}

From source file:com.aia.hichef.ui.n.MyWindow.java

License:Apache License

public MyWindow(String title, WindowStyle style) {
    if (title == null)
        throw new IllegalArgumentException("title cannot be null.");
    this.title = title;
    setTouchable(Touchable.enabled);/*from  w ww  .  j  a  va 2 s . c o m*/
    setClip(true);
    setStyle(style);
    setWidth(150);
    setHeight(150);
    setTitle(title);

    setHeight(100);
    buttonTable = new Table();
    addActor(buttonTable);

    addCaptureListener(new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            toFront();
            return false;
        }
    });
    addListener(new InputListener() {
        int edge;
        float startX, startY, lastX, lastY;

        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (button == 0) {
                int border = resizeBorder;
                float width = getWidth(), height = getHeight();
                edge = 0;
                if (isResizable) {
                    if (x < border)
                        edge |= Align.left;
                    if (x > width - border)
                        edge |= Align.right;
                    if (y < border)
                        edge |= Align.bottom;
                    if (y > height - border)
                        edge |= Align.top;
                    if (edge != 0)
                        border += 25;
                    if (x < border)
                        edge |= Align.left;
                    if (x > width - border)
                        edge |= Align.right;
                    if (y < border)
                        edge |= Align.bottom;
                    if (y > height - border)
                        edge |= Align.top;
                }
                if (isMovable && edge == 0 && y <= height && y >= height - getPadTop() && x >= 0 && x <= width)
                    edge = MOVE;
                dragging = edge != 0;
                startX = x;
                startY = y;
                lastX = x;
                lastY = y;
            }
            return edge != 0 || isModal;
        }

        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            dragging = false;
        }

        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            if (!dragging)
                return;
            float width = getWidth(), height = getHeight();
            float windowX = getX(), windowY = getY();

            float minWidth = getMinWidth(), maxWidth = getMaxWidth();
            float minHeight = getMinHeight(), maxHeight = getMaxHeight();
            Stage stage = getStage();
            boolean clampPosition = keepWithinStage && getParent() == stage.getRoot();

            if ((edge & MOVE) != 0) {
                float amountX = x - startX, amountY = y - startY;
                windowX += amountX;
                windowY += amountY;
            }
            if ((edge & Align.left) != 0) {
                float amountX = x - startX;
                if (width - amountX < minWidth)
                    amountX = -(minWidth - width);
                if (clampPosition && windowX + amountX < 0)
                    amountX = -windowX;
                width -= amountX;
                windowX += amountX;
            }
            if ((edge & Align.bottom) != 0) {
                float amountY = y - startY;
                if (height - amountY < minHeight)
                    amountY = -(minHeight - height);
                if (clampPosition && windowY + amountY < 0)
                    amountY = -windowY;
                height -= amountY;
                windowY += amountY;
            }
            if ((edge & Align.right) != 0) {
                float amountX = x - lastX;
                if (width + amountX < minWidth)
                    amountX = minWidth - width;
                if (clampPosition && windowX + width + amountX > stage.getWidth())
                    amountX = stage.getWidth() - windowX - width;
                width += amountX;
            }
            if ((edge & Align.top) != 0) {
                float amountY = y - lastY;
                if (height + amountY < minHeight)
                    amountY = minHeight - height;
                if (clampPosition && windowY + height + amountY > stage.getHeight())
                    amountY = stage.getHeight() - windowY - height;
                height += amountY;
            }
            lastX = x;
            lastY = y;
            setBounds(Math.round(windowX), Math.round(windowY), Math.round(width), Math.round(height));
        }

        public boolean mouseMoved(InputEvent event, float x, float y) {
            return isModal;
        }

        public boolean scrolled(InputEvent event, float x, float y, int amount) {
            return isModal;
        }

        public boolean keyDown(InputEvent event, int keycode) {
            return isModal;
        }

        public boolean keyUp(InputEvent event, int keycode) {
            return isModal;
        }

        public boolean keyTyped(InputEvent event, char character) {
            return isModal;
        }
    });
}

From source file:com.aia.hichef.ui.n.MyWindow.java

License:Apache License

protected void drawBackground(Batch batch, float parentAlpha, float x, float y) {
    float width = getWidth(), height = getHeight();
    float padTop = getPadTop();

    super.drawBackground(batch, parentAlpha, x, y);

    // Draw button table.
    buttonTable.getColor().a = getColor().a;
    buttonTable.pack();//from  w ww .ja  va 2 s  .  c  om
    buttonTable.setPosition(width - buttonTable.getWidth(),
            Math.min(height - padTop, height - buttonTable.getHeight()));
    buttonTable.draw(batch, parentAlpha);

    // Draw the title without the batch transformed or clipping applied.
    y += height;
    TextBounds bounds = titleCache.getBounds();
    if ((titleAlignment & Align.left) != 0)
        x += getPadLeft();
    else if ((titleAlignment & Align.right) != 0)
        x += width - bounds.width - getPadRight();
    else
        x += (width - bounds.width) / 2;
    if ((titleAlignment & Align.top) == 0) {
        if ((titleAlignment & Align.bottom) != 0)
            y -= padTop - bounds.height;
        else
            y -= (padTop - bounds.height) / 2;
    }
    titleCache.setColors(Color.tmp.set(getColor()).mul(style.titleFontColor));
    titleCache.setPosition((int) x, (int) y);
    titleCache.draw(batch, parentAlpha);
}

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

License:Apache License

private void initialize() {

    setTouchable(Touchable.enabled);//from w w w  .  j  a va 2 s .c om
    tabTitleTable = new Table();
    tabBodyStack = new Stack();
    selectedIndex = -1;

    // Create 1st row
    Cell<?> leftCell = add(new Image(style.titleBegin));
    Cell<?> midCell = add(tabTitleTable);
    Cell<?> rightCell = add(new Image(style.titleEnd));
    switch (tabTitleAlign) {
    case Align.left:
        leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom();
        midCell.left();
        rightCell.expandX().fillX().bottom();
        break;
    case Align.right:
        leftCell.expandX().fillX().bottom();
        midCell.right();
        rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom();
        break;
    case Align.center:
        leftCell.expandX().fillX().bottom();
        midCell.center();
        rightCell.expandX().fillX().bottom();
        break;
    default:
        throw new IllegalArgumentException("TabbedPane align must be one of left, center, right");
    }

    // Create 2nd row
    row();
    Table t = new Table();
    t.setBackground(style.bodyBackground);
    t.add(tabBodyStack);
    add(t).colspan(3).expand().fill();
}

From source file:com.ladinc.core.screens.GameScreenLobby.java

License:Creative Commons License

private Table createStepTable() {
    Table stepTable = new Table();

    stepTable.add(new Label("To Join The Game", new Label.LabelStyle(font, Color.ORANGE))).colspan(2)
            .padBottom(60f);//from  w  w w.  j a  v  a2s. c o  m
    stepTable.row();

    stepTable.add(createStep1Table()).align(Align.top).width(Value.percentWidth(0.45f, stepTable));

    stepTable.add(createStep2Table()).align(Align.top | Align.right)
            .width(Value.percentWidth(0.55f, stepTable));

    return stepTable;
}

From source file:com.strategames.catchdastars.screens.editor.GameEditorScreen.java

License:Open Source License

private ArrowImage getArrow(int[] curPos, int[] nextPos) {
    if (nextPos[0] < curPos[0]) {
        return new ArrowImage(this.textures.arrowLeft, Align.right | Align.center);
    } else if (nextPos[0] > curPos[0]) {
        return new ArrowImage(this.textures.arrowRight, Align.left | Align.center);
    } else if (nextPos[1] < curPos[1]) {
        return new ArrowImage(this.textures.arrowBottom, Align.top | Align.center);
    } else if (nextPos[1] > curPos[1]) {
        return new ArrowImage(this.textures.arrowTop, Align.bottom | Align.center);
    }/*from  ww  w .  ja  v a  2  s .  c  om*/
    return null;
}

From source file:com.strategames.engine.scenes.scene2d.ui.ScreenshotImage.java

License:Open Source License

private void alignOverlay(Overlay overlay, int align) {
    float width = getWidth();
    float height = getHeight();
    float x = 0;//w  w  w.j ava  2  s .com
    float y = 0;

    if ((align & Align.center) != 0) {
        x = (width / 2f) - (overlay.size.x / 2f);
        y = (height / 2f) - (overlay.size.y / 2f);
    }

    if ((align & Align.right) != 0) {
        x = width - overlay.size.x;
    } else if ((align & Align.left) != 0) {
        x = 0;
    }

    if ((align & Align.top) != 0) {
        y = height - overlay.size.y;
    } else if ((align & Align.bottom) != 0) {
        y = 0;
    }

    overlay.position = new Vector2(x, y);

}

From source file:com.turbogerm.helljump.screens.HighScoreScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    mScreenBackground.reset();/*w  w  w  . j  av  a  2s.  co m*/

    mGuiStage.clear();

    LabelStyle labelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    labelStyle.font = mGuiSkin.getFont("large-font");

    Array<HighScoreData> highScores = mGameData.getHighScoresData().getHighScores();
    for (int i = 0; i < highScores.size; i++) {
        float highScoreY = HellJump.VIEWPORT_HEIGHT - (i + 1) * HIGH_SCORE_HEIGHT;
        HighScoreData highScore = highScores.get(i);

        Label highScoreIndexLabel = new Label(String.valueOf(i + 1) + ".", mGuiSkin);
        highScoreIndexLabel.setBounds(HIGH_SCORE_INDEX_X, highScoreY, HIGH_SCORE_INDEX_WIDTH,
                HIGH_SCORE_HEIGHT);
        highScoreIndexLabel.setStyle(labelStyle);
        highScoreIndexLabel.setAlignment(Align.right);
        mGuiStage.addActor(highScoreIndexLabel);

        Label highScoreNameLabel = new Label(highScore.getName(), mGuiSkin);
        highScoreNameLabel.setBounds(HIGH_SCORE_NAME_X, highScoreY, HIGH_SCORE_NAME_WIDTH, HIGH_SCORE_HEIGHT);
        highScoreNameLabel.setStyle(labelStyle);
        highScoreNameLabel.setAlignment(Align.left);
        mGuiStage.addActor(highScoreNameLabel);

        Label highScoreValueLabel = new Label(String.valueOf(highScore.getScore()), mGuiSkin);
        highScoreValueLabel.setBounds(HIGH_SCORE_VALUE_X, highScoreY, HIGH_SCORE_VALUE_WIDTH,
                HIGH_SCORE_HEIGHT);
        highScoreValueLabel.setStyle(labelStyle);
        highScoreValueLabel.setAlignment(Align.right);
        mGuiStage.addActor(highScoreValueLabel);
    }

    TextureAtlas atlas = mAssetManager.get(ResourceNames.GRAPHICS_GUI_ATLAS);

    CustomImageButton button = new CustomImageButton(BUTTON_X, BUTTON_Y, atlas,
            ResourceNames.GUI_BUTTON_BACK_UP_IMAGE_NAME, ResourceNames.GUI_BUTTON_BACK_DOWN_IMAGE_NAME,
            getBackAction(), mAssetManager);
    button.addToStage(mGuiStage);
}

From source file:com.turbogerm.helljump.screens.PlayScreen.java

License:Open Source License

public PlayScreen(HellJump game) {
    super(game);/*from  w w w  . j a v  a  2  s  .c om*/

    mGuiStage.addListener(getStageInputListener());

    mGameArea = new GameArea(mCameraData, mAssetManager, mResources.getItemFont());

    LabelStyle scoreLabelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    scoreLabelStyle.font = mGuiSkin.getFont("xxxl-font");

    mScoreLabel = new Label("", mGuiSkin);
    mScoreLabel.setStyle(scoreLabelStyle);
    mScoreLabel.setAlignment(Align.right);
    mGuiStage.addActor(mScoreLabel);

    TextureAtlas atlas = mAssetManager.get(ResourceNames.GRAPHICS_GUI_ATLAS);
    TextureRegion livesRegion = atlas.findRegion(ResourceNames.GUI_PLAY_LIVES_IMAGE_NAME);
    mLivesImage = new Image(new TextureRegionDrawable(livesRegion));
    mGuiStage.addActor(mLivesImage);

    LabelStyle livesLabelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    livesLabelStyle.font = mGuiSkin.getFont("xl-font");

    mLivesLabel = new Label("", mGuiSkin);
    mLivesLabel.setStyle(livesLabelStyle);
    mLivesLabel.setAlignment(Align.left);
    mGuiStage.addActor(mLivesLabel);

    createPlayPauseButton();

    LabelStyle fpsLabelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    fpsLabelStyle.font = mGuiSkin.getFont("medium-font");
    mDebugLabel = new Label("", mGuiSkin);
    mDebugLabel.setStyle(fpsLabelStyle);
    mDebugLabel.setAlignment(Align.left);
    mGuiStage.addActor(mDebugLabel);

    mRisePositionScroll = new RisePositionScroll(mCameraData, mAssetManager);
}

From source file:com.turbogerm.suchyblocks.screens.HighScoreScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    mGuiStage.clear();/*from w ww.ja v a2 s.c om*/

    LabelStyle labelStyle = new LabelStyle(mGuiSkin.get(LabelStyle.class));
    labelStyle.font = mGuiSkin.get("large-font", BitmapFont.class); // mResources.getFont("medium");

    Array<HighScoreData> highScores = mGameData.getHighScoresData().getHighScores();
    for (int i = 0; i < highScores.size; i++) {
        float highScoreY = SuchyBlocks.VIEWPORT_HEIGHT - (i + 1) * HIGH_SCORE_HEIGHT;
        HighScoreData highScore = highScores.get(i);

        Label highScoreIndexLabel = new Label(String.valueOf(i + 1) + ".", mGuiSkin);
        highScoreIndexLabel.setBounds(HIGH_SCORE_INDEX_X, highScoreY, HIGH_SCORE_INDEX_WIDTH,
                HIGH_SCORE_HEIGHT);
        highScoreIndexLabel.setStyle(labelStyle);
        highScoreIndexLabel.setAlignment(Align.right);
        mGuiStage.addActor(highScoreIndexLabel);

        Label highScoreNameLabel = new Label(highScore.getName(), mGuiSkin);
        highScoreNameLabel.setBounds(HIGH_SCORE_NAME_X, highScoreY, HIGH_SCORE_NAME_WIDTH, HIGH_SCORE_HEIGHT);
        highScoreNameLabel.setStyle(labelStyle);
        highScoreNameLabel.setAlignment(Align.left);
        mGuiStage.addActor(highScoreNameLabel);

        Label highScoreValueLabel = new Label(String.valueOf(highScore.getScore()), mGuiSkin);
        highScoreValueLabel.setBounds(HIGH_SCORE_VALUE_X, highScoreY, HIGH_SCORE_VALUE_WIDTH,
                HIGH_SCORE_HEIGHT);
        highScoreValueLabel.setStyle(labelStyle);
        highScoreValueLabel.setAlignment(Align.right);
        mGuiStage.addActor(highScoreValueLabel);
    }

    final float buttonWidth = 360.0f;
    final float buttonHeight = 80.0f;
    final float buttonX = (SuchyBlocks.VIEWPORT_WIDTH - buttonWidth) / 2.0f;
    final float buttonY = 10.0f;

    TextureRegion backUpTextureRegion = new TextureRegion(
            (Texture) mAssetManager.get(ResourceNames.GUI_BUTTON_BACK_UP_TEXTURE));
    Drawable backUpDrawable = new TextureRegionDrawable(backUpTextureRegion);
    TextureRegion backDownTextureRegion = new TextureRegion(
            (Texture) mAssetManager.get(ResourceNames.GUI_BUTTON_BACK_DOWN_TEXTURE));
    Drawable backDownDrawable = new TextureRegionDrawable(backDownTextureRegion);
    ImageButton backButton = new ImageButton(backUpDrawable, backDownDrawable);
    backButton.setBounds(buttonX, buttonY, buttonWidth, buttonHeight);
    backButton.addListener(getBackInputListener(backButton));
    mGuiStage.addActor(backButton);
}