Java Code Examples for com.badlogic.gdx.utils.Align#right()

The following examples show how to use com.badlogic.gdx.utils.Align#right() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RadialBlurEffect.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
/**
 * Specify the zoom origin in {@link Align} bits.
 * @see Align
 */
public void setOrigin(int align) {
    final float originX;
    final float originY;
    if ((align & Align.left) != 0) {
        originX = 0f;
    } else if ((align & Align.right) != 0) {
        originX = 1f;
    } else {
        originX = 0.5f;
    }
    if ((align & Align.bottom) != 0) {
        originY = 0f;
    } else if ((align & Align.top) != 0) {
        originY = 1f;
    } else {
        originY = 0.5f;
    }
    setOrigin(originX, originY);
}
 
Example 2
Source File: ZoomEffect.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
/**
 * Specify the zoom origin in {@link Align} bits.
 * @see Align
 */
public void setOrigin(int align) {
    final float originX;
    final float originY;
    if ((align & Align.left) != 0) {
        originX = 0f;
    } else if ((align & Align.right) != 0) {
        originX = 1f;
    } else {
        originX = 0.5f;
    }
    if ((align & Align.bottom) != 0) {
        originY = 0f;
    } else if ((align & Align.top) != 0) {
        originY = 1f;
    } else {
        originY = 0.5f;
    }
    setOrigin(originX, originY);
}
 
Example 3
Source File: MenuScreen.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
private int getAlign() {
	if (getStyle().align == null || "center".equals(getStyle().align))
		return Align.center;

	if ("top".equals(getStyle().align))
		return Align.top;

	if ("bottom".equals(getStyle().align))
		return Align.bottom;

	if ("left".equals(getStyle().align))
		return Align.left;

	if ("right".equals(getStyle().align))
		return Align.right;

	return Align.center;
}
 
Example 4
Source File: AlignUtils.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public static String getAlign(int align) {
	switch (align) {
	case Align.bottomRight:
		return "bottom-right";
	case Align.bottomLeft:
		return "bottom-left";
	case Align.topRight:
		return "top-right";
	case Align.topLeft:
		return "top-left";
	case Align.right:
		return "right";
	case Align.left:
		return "left";
	case Align.bottom:
		return "bottom";
	case Align.top:
		return "top";
	case Align.center:
		return "center";
	}

	return "";
}
 
Example 5
Source File: AlignUtils.java    From bladecoder-adventure-engine with Apache License 2.0 6 votes vote down vote up
public static int getAlign(String s) {
	if ("bottom-right".equals(s))
		return Align.bottomRight;
	else if ("bottom-left".equals(s))
		return Align.bottomLeft;
	else if ("top-right".equals(s))
		return Align.topRight;
	else if ("top-left".equals(s))
		return Align.topLeft;
	else if ("right".equals(s))
		return Align.right;
	else if ("left".equals(s))
		return Align.left;
	else if ("bottom".equals(s))
		return Align.bottom;
	else if ("top".equals(s))
		return Align.top;
	else if ("center".equals(s))
		return Align.center;

	return 0;
}
 
Example 6
Source File: NinePatchModuleWrapper.java    From talos with Apache License 2.0 5 votes vote down vote up
@Override
protected void configureSlots () {
    addInputSlot("input",  NinePatchModule.INPUT);
    addOutputSlot("output", NinePatchModule.OUTPUT);

    leftSplit = new IntegerInputWidget("left split", getSkin());
    leftWrapper.add(leftSplit).left().expandX().padLeft(3).row();

    rightSplit = new IntegerInputWidget("right split", getSkin(), Align.right);
    rightWrapper.add(rightSplit).right().expandX().padRight(3).row();

    topSplit = new IntegerInputWidget("top split", getSkin());
    leftWrapper.add(topSplit).left().expandX().padLeft(3);

    bottomSplit = new IntegerInputWidget("bottom split", getSkin(), Align.right);
    rightWrapper.add(bottomSplit).right().expandX().padRight(3);

    ChangeListener changeListener = new ChangeListener() {
        @Override
        public void changed (ChangeEvent event, Actor actor) {
            updateValues();
        }
    };

    leftSplit.addListener(changeListener);
    rightSplit.addListener(changeListener);
    topSplit.addListener(changeListener);
    rightWrapper.addListener(changeListener);
}
 
Example 7
Source File: CCLabel.java    From cocos-ui-libgdx with Apache License 2.0 5 votes vote down vote up
@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {

    final TTFLabelStyle labelStyle = editor.createLabelStyle(widget,
        widget.getLabelText(), editor.getColor(widget.getCColor(), 0));

    TTFLabel label = new TTFLabel(widget.getLabelText(), labelStyle);
    // 水平
    int h = Integer.MAX_VALUE;
    if ("HT_Center".equals(widget.getHorizontalAlignmentType())) {
        h = Align.center;
    } else if ("HT_Left".equals(widget.getHorizontalAlignmentType())) {
        h = Align.left;
    } else if ("HT_Right".equals(widget.getHorizontalAlignmentType())) {
        h = Align.right;
    }

    // 垂直
    int v = Integer.MAX_VALUE;
    if ("HT_Center".equals(widget.getVerticalAlignmentType())) {
        v = Align.center;
    } else if ("HT_Top".equals(widget.getVerticalAlignmentType())) {
        v = Align.top;
    } else if ("HT_Bottom".equals(widget.getVerticalAlignmentType())) {
        v = Align.bottom;
    }

    if (v != Integer.MAX_VALUE) {
        label.setAlignment(h, v);
    }

    return label;
}
 
Example 8
Source File: TextRenderer.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public static float getAlignDx(float width, int align) {
	if ((align & Align.left) != 0)
		return 0;
	else if ((align & Align.right) != 0)
		return -width;
	else if ((align & Align.center) != 0)
		return -width / 2.0f;

	return -width / 2.0f;
}
 
Example 9
Source File: AnimationRenderer.java    From bladecoder-adventure-engine with Apache License 2.0 5 votes vote down vote up
public static float getAlignDx(float width, int align) {
	if ((align & Align.left) != 0)
		return 0;
	else if ((align & Align.right) != 0)
		return -width;
	else if ((align & Align.center) != 0)
		return -width / 2.0f;

	return -width / 2.0f;
}
 
Example 10
Source File: TabbedPane.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
private void initialize () {

		setTouchable(Touchable.enabled);
		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();
	}
 
Example 11
Source File: EditWidget.java    From skin-composer with MIT License 4 votes vote down vote up
@Override
public void layout() {
    super.layout();
    temp.set(0, 0);
    
    if (followActor != null) {
        followActor.localToStageCoordinates(temp);
        stageToLocalCoordinates(temp);
        setBounds(temp.x, temp.y, followActor.getWidth(), followActor.getHeight());
    } else if (cell != null) {
        var table = cell.getTable();
        temp.set(table.getPadLeft(), table.getPadBottom());

        var contentWidth = 0f;
        var contentHeight = 0f;
        for (int i = 0; i < table.getColumns(); i++) {
            contentWidth += table.getColumnWidth(i);
        }
        for (int i = 0; i < table.getRows(); i++) {
            contentHeight += table.getRowHeight(i);
        }

        if ((table.getAlign() & Align.right) != 0) {
            temp.add(table.getWidth() - contentWidth - table.getPadLeft() - table.getPadRight(), 0);
        } else if ((table.getAlign() & Align.left) == 0) {
            temp.add((table.getWidth() - contentWidth - table.getPadLeft() - table.getPadRight()) / 2, 0);
        }

        if ((table.getAlign() & Align.top) != 0) {
            temp.add(0, table.getHeight() - contentHeight - table.getPadBottom()  - table.getPadTop());
        } else if ((table.getAlign() & Align.bottom) == 0) {
            temp.add(0, (table.getHeight() - contentHeight - table.getPadBottom() - table.getPadTop()) / 2);
        }
        
        table.localToStageCoordinates(temp);
        stageToLocalCoordinates(temp);
        
        var xpos = 0f;
        var ypos = 0f;
        
        for (int i = 0; i < cell.getColumn(); i++) {
            xpos += table.getColumnWidth(i);
        }
        
        for (int i = table.getRows() - 1; i > cell.getRow(); i--) {
            ypos += table.getRowHeight(i);
        }

        var cellWidth = 0;
        for (int i = cell.getColumn(); i < cell.getColumn() + cell.getColspan(); i++) {
            cellWidth += table.getColumnWidth(i);
        }
        
        setBounds(temp.x + xpos, temp.y + ypos, cellWidth, table.getRowHeight(cell.getRow()));
    }
}
 
Example 12
Source File: SpellsQuickPanel.java    From riiablo with Apache License 2.0 4 votes vote down vote up
public SpellsQuickPanel(final HotkeyButton o, final boolean leftSkills) {
  this.observer = o;
  this.leftSkills = leftSkills;

  Riiablo.assets.load(SkilliconDescriptor);
  Riiablo.assets.finishLoadingAsset(SkilliconDescriptor);
  Skillicon = Riiablo.assets.get(SkilliconDescriptor);

  CharSkilliconDescriptor = new AssetDescriptor[7];
  CharSkillicon = new DC6[CharSkilliconDescriptor.length];
  for (int i = 0; i < CharSkilliconDescriptor.length; i++) {
    CharSkilliconDescriptor[i] = new AssetDescriptor<>(SPELLS_PATH + CharacterClass.get(i).spellIcons + ".DC6", DC6.class, DC6Loader.DC6Parameters.COMBINE);
    Riiablo.assets.load(CharSkilliconDescriptor[i]);
    Riiablo.assets.finishLoadingAsset(CharSkilliconDescriptor[i]);
    CharSkillicon[i] = Riiablo.assets.get(CharSkilliconDescriptor[i]);
  }

  SIZE = Gdx.app.getType() == Application.ApplicationType.Android ? 64 : 48;
  ALIGN = leftSkills ? Align.left : Align.right;

  keyMappings = new ObjectMap<>(31);
  tables = new Table[5];
  for (int i = tables.length - 1; i >= 0; i--) {
    Table table = tables[i] = new Table();
    add(table).align(ALIGN).row();
  }
  pack();
  //setDebug(true, true);

  mappedKeyListener = new MappedKeyStateAdapter() {
    @Override
    public void onPressed(MappedKey key, int keycode) {
      HotkeyButton button = keyMappings.get(key);
      if (button == null) return;
      // TODO: Assign
      ControlPanel controlPanel = Riiablo.game.controlPanel;
      if (leftSkills) {
        controlPanel.getLeftSkill().copy(button);
      } else {
        controlPanel.getRightSkill().copy(button);
      }
    }
  };
  for (MappedKey Skill : Keys.Skill) Skill.addStateListener(mappedKeyListener);
  Riiablo.charData.addSkillListener(this);
}
 
Example 13
Source File: TextRenderer.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void draw(SpriteBatch batch, float x, float y, float scaleX, float scaleY, float rotation, Color tint) {

	float dx = getAlignDx(getWidth(), orgAlign);
	float dy = getAlignDy(getHeight(), orgAlign);

	if (font != null && text != null) {

		if (tint != null && !tint.equals(color)) {
			color.set(tint);

			String tt = text;

			if (tt.charAt(0) == I18N.PREFIX)
				tt = world.getI18N().getString(tt.substring(1));

			if (editorTranslatedText != null)
				tt = editorTranslatedText;

			layout.setText(font, tt, color, 0, textAlign, false);
		}

		Matrix4 tm = batch.getTransformMatrix();
		tmp.set(tm);

		float originX = dx;
		float originY = layout.height + dy;

		if (textAlign == Align.right)
			originX += getWidth();
		else if (textAlign == Align.center)
			originX += getWidth() / 2;

		tm.translate(x, y, 0).rotate(0, 0, 1, rotation).scale(scaleX, scaleY, 1).translate(originX, originY, 0);

		batch.setTransformMatrix(tm);

		font.draw(batch, layout, 0, 0);

		batch.setTransformMatrix(tmp);
	} else {
		RectangleRenderer.draw(batch, x + dx * scaleX, y + dy * scaleY, getWidth() * scaleX, getHeight() * scaleY,
				Color.RED);
	}
}