本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.ui.RedButton.width方法的典型用法代码示例。如果您正苦于以下问题:Java RedButton.width方法的具体用法?Java RedButton.width怎么用?Java RedButton.width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.ui.RedButton
的用法示例。
在下文中一共展示了RedButton.width方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
@Override
public int compare(RedButton lhs, RedButton rhs) {
if (lhs.width() < rhs.width()){
return -1;
} else if (lhs.width() == rhs.width()){
return 0;
} else {
return 1;
}
}
示例2: WndItem
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndItem( final WndBag owner, final Item item , final boolean options ) {
super();
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
IconTitle titlebar = new IconTitle( item );
titlebar.setRect( 0, 0, width, 0 );
add( titlebar );
if (item.levelKnown && item.level() > 0) {
titlebar.color( ItemSlot.UPGRADED );
} else if (item.levelKnown && item.level() < 0) {
titlebar.color( ItemSlot.DEGRADED );
}
RenderedTextMultiline info = PixelScene.renderMultiline( item.info(), 6 );
info.maxWidth(width);
info.setPos(titlebar.left(), titlebar.bottom() + GAP);
add( info );
float y = info.top() + info.height() + GAP;
float x = 0;
if (Dungeon.hero.isAlive() && options) {
ArrayList<RedButton> line = new ArrayList<>();
for (final String action:item.actions( Dungeon.hero )) {
RedButton btn = new RedButton( Messages.get(item, "ac_" + action), 8 ) {
@Override
protected void onClick() {
hide();
if (owner != null && owner.parent != null) owner.hide();
item.execute( Dungeon.hero, action );
};
};
btn.setSize( btn.reqWidth(), BUTTON_HEIGHT );
if (x + btn.width() > width || line.size() == 3) {
layoutButtons(line, width - x, y);
x = 0;
y += BUTTON_HEIGHT + 1;
line = new ArrayList<>();
}
x++;
add( btn );
line.add( btn );
if (action.equals(item.defaultAction)) {
btn.textColor( TITLE_COLOR );
}
x += btn.width();
}
layoutButtons(line, width - x, y);
}
resize( width, (int)(y + (x > 0 ? BUTTON_HEIGHT : 0)) );
}
示例3: layoutButtons
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
private static void layoutButtons(ArrayList<RedButton> line, float extraWidth, float y){
if (line == null || line.size() == 0 || extraWidth == 0) return;
if (line.size() == 1){
line.get(0).setSize(line.get(0).width()+extraWidth, BUTTON_HEIGHT);
line.get(0).setPos( 0 , y );
return;
}
ArrayList<RedButton> lineByWidths = new ArrayList<>(line);
Collections.sort(lineByWidths, widthComparator);
RedButton smallest, middle, largest;
smallest = lineByWidths.get(0);
middle = lineByWidths.get(1);
largest = null;
if (lineByWidths.size() == 3) {
largest = lineByWidths.get(2);
}
float btnDiff = middle.width() - smallest.width();
smallest.setSize(smallest.width() + Math.min(btnDiff, extraWidth), BUTTON_HEIGHT);
extraWidth -= btnDiff;
if (extraWidth > 0) {
if (largest == null) {
smallest.setSize(smallest.width() + extraWidth / 2, BUTTON_HEIGHT);
middle.setSize(middle.width() + extraWidth / 2, BUTTON_HEIGHT);
} else {
btnDiff = largest.width() - smallest.width();
smallest.setSize(smallest.width() + Math.min(btnDiff, extraWidth/2), BUTTON_HEIGHT);
middle.setSize(middle.width() + Math.min(btnDiff, extraWidth/2), BUTTON_HEIGHT);
extraWidth -= btnDiff*2;
if (extraWidth > 0){
smallest.setSize(smallest.width() + extraWidth / 3, BUTTON_HEIGHT);
middle.setSize(middle.width() + extraWidth / 3, BUTTON_HEIGHT);
largest.setSize(largest.width() + extraWidth / 3, BUTTON_HEIGHT);
}
}
}
float x = 0;
for (RedButton btn : line){
btn.setPos( x , y );
x += btn.width()+1;
}
}