本文整理汇总了Java中com.shatteredpixel.shatteredpixeldungeon.ui.RedButton.setRect方法的典型用法代码示例。如果您正苦于以下问题:Java RedButton.setRect方法的具体用法?Java RedButton.setRect怎么用?Java RedButton.setRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.shatteredpixel.shatteredpixeldungeon.ui.RedButton
的用法示例。
在下文中一共展示了RedButton.setRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WndHardNotification
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndHardNotification(Component titlebar, String message, String btnMessage, int time) {
super(titlebar, message);
timeLeft = time;
this.btnMessage = btnMessage;
btnOkay = new RedButton(btnMessage + " (" + time +")"){
@Override
protected void onClick() {
hide();
}
};
btnOkay.setRect(0, height + GAP, width, 16);
btnOkay.enable(false);
add(btnOkay);
resize(width, (int) btnOkay.bottom());
}
示例2: WndWandmaker
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndWandmaker( final Wandmaker wandmaker, final Item item ) {
super();
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( item.image(), null ) );
titlebar.label( Utils.capitalize( item.name() ) );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
message.maxWidth = WIDTH;
message.measure();
message.y = titlebar.bottom() + GAP;
add( message );
RedButton btnBattle = new RedButton( TXT_BATTLE ) {
@Override
protected void onClick() {
selectReward( wandmaker, item, Wandmaker.Quest.wand1 );
}
};
btnBattle.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
add( btnBattle );
RedButton btnNonBattle = new RedButton( TXT_NON_BATTLE ) {
@Override
protected void onClick() {
selectReward( wandmaker, item, Wandmaker.Quest.wand2 );
}
};
btnNonBattle.setRect( 0, btnBattle.bottom() + GAP, WIDTH, BTN_HEIGHT );
add( btnNonBattle );
resize( WIDTH, (int)btnNonBattle.bottom() );
}
示例3: WndImp
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndImp( final Imp imp, final DwarfToken tokens ) {
super();
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( tokens.image(), null ) );
titlebar.label( Utils.capitalize( tokens.name() ) );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
message.maxWidth = WIDTH;
message.measure();
message.y = titlebar.bottom() + GAP;
add( message );
RedButton btnReward = new RedButton( TXT_REWARD ) {
@Override
protected void onClick() {
takeReward( imp, tokens, Imp.Quest.reward );
}
};
btnReward.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
add( btnReward );
resize( WIDTH, (int)btnReward.bottom() );
}
示例4: WndOptions
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndOptions( String title, String message, String... options ) {
super();
BitmapTextMultiline tfTitle = PixelScene.createMultiline( title, 9 );
tfTitle.hardlight( TITLE_COLOR );
tfTitle.x = tfTitle.y = MARGIN;
tfTitle.maxWidth = WIDTH - MARGIN * 2;
tfTitle.measure();
add( tfTitle );
BitmapTextMultiline tfMesage = PixelScene.createMultiline( message, 8 );
tfMesage.maxWidth = WIDTH - MARGIN * 2;
tfMesage.measure();
tfMesage.x = MARGIN;
tfMesage.y = tfTitle.y + tfTitle.height() + MARGIN;
add( tfMesage );
float pos = tfMesage.y + tfMesage.height() + MARGIN;
for (int i=0; i < options.length; i++) {
final int index = i;
RedButton btn = new RedButton( options[i] ) {
@Override
protected void onClick() {
hide();
onSelect( index );
}
};
btn.setRect( MARGIN, pos, WIDTH - MARGIN * 2, BUTTON_HEIGHT );
add( btn );
pos += BUTTON_HEIGHT + MARGIN;
}
resize( WIDTH, (int)pos );
}
示例5: WndOptions
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndOptions( String title, String message, String... options ) {
super();
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
RenderedTextMultiline tfTitle = PixelScene.renderMultiline( title, 9 );
tfTitle.hardlight( TITLE_COLOR );
tfTitle.setPos(MARGIN, MARGIN);
tfTitle.maxWidth(width - MARGIN * 2);
add( tfTitle );
RenderedTextMultiline tfMesage = PixelScene.renderMultiline( 6 );
tfMesage.text(message, width - MARGIN * 2);
tfMesage.setPos( MARGIN, tfTitle.top() + tfTitle.height() + MARGIN );
add( tfMesage );
float pos = tfMesage.bottom() + MARGIN;
for (int i=0; i < options.length; i++) {
final int index = i;
RedButton btn = new RedButton( options[i] ) {
@Override
protected void onClick() {
hide();
onSelect( index );
}
};
btn.setRect( MARGIN, pos, width - MARGIN * 2, BUTTON_HEIGHT );
add( btn );
pos += BUTTON_HEIGHT + MARGIN;
}
resize( width, (int)pos );
}
示例6: addButtons
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
private void addButtons( RedButton btn1, RedButton btn2 ) {
add( btn1 );
btn1.setRect( 0, pos > 0 ? pos += GAP : 0, (WIDTH - GAP) / 2, BTN_HEIGHT );
add( btn2 );
btn2.setRect( btn1.right() + GAP, btn1.top(), WIDTH - btn1.right() - GAP, BTN_HEIGHT );
pos += BTN_HEIGHT;
}
示例7: WndSadGhost
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndSadGhost( final Ghost ghost, final int type ) {
super();
IconTitle titlebar = new IconTitle();
BitmapTextMultiline message;
switch (type){
case 1:default:
titlebar.icon( new FetidRatSprite() );
titlebar.label( "DEFEATED FETID RAT" );
message = PixelScene.createMultiline( TXT_RAT+TXT_GIVEITEM, 6 );
break;
case 2:
titlebar.icon( new GnollTricksterSprite() );
titlebar.label( "DEFEATED GNOLL TRICKSTER" );
message = PixelScene.createMultiline( TXT_GNOLL+TXT_GIVEITEM, 6 );
break;
case 3:
titlebar.icon( new GreatCrabSprite());
titlebar.label( "DEFEATED GREAT CRAB" );
message = PixelScene.createMultiline( TXT_CRAB+TXT_GIVEITEM, 6 );
break;
}
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
message.maxWidth = WIDTH;
message.measure();
message.y = titlebar.bottom() + GAP;
add( message );
RedButton btnWeapon = new RedButton( TXT_WEAPON ) {
@Override
protected void onClick() {
selectReward( ghost, Ghost.Quest.weapon );
}
};
btnWeapon.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
add( btnWeapon );
if (!Dungeon.isChallenged( Challenges.NO_ARMOR )) {
RedButton btnArmor = new RedButton(TXT_ARMOR) {
@Override
protected void onClick() {
selectReward(ghost, Ghost.Quest.armor);
}
};
btnArmor.setRect(0, btnWeapon.bottom() + GAP, WIDTH, BTN_HEIGHT);
add(btnArmor);
resize(WIDTH, (int) btnArmor.bottom());
} else {
resize(WIDTH, (int) btnWeapon.bottom());
}
}
示例8: WndResurrect
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndResurrect( final Ankh ankh, Object causeOfDeath ) {
super();
instance = this;
WndResurrect.causeOfDeath = causeOfDeath;
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( ankh.image(), null ) );
titlebar.label( ankh.name() );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline message = PixelScene.createMultiline( TXT_MESSAGE, 6 );
message.maxWidth = WIDTH;
message.measure();
message.y = titlebar.bottom() + GAP;
add( message );
RedButton btnYes = new RedButton( TXT_YES ) {
@Override
protected void onClick() {
hide();
Statistics.ankhsUsed++;
InterlevelScene.mode = InterlevelScene.Mode.RESURRECT;
Game.switchScene( InterlevelScene.class );
}
};
btnYes.setRect( 0, message.y + message.height() + GAP, WIDTH, BTN_HEIGHT );
add( btnYes );
RedButton btnNo = new RedButton( TXT_NO ) {
@Override
protected void onClick() {
hide();
Rankings.INSTANCE.submit( false );
Hero.reallyDie( WndResurrect.causeOfDeath );
}
};
btnNo.setRect( 0, btnYes.bottom() + GAP, WIDTH, BTN_HEIGHT );
add( btnNo );
resize( WIDTH, (int)btnNo.bottom() );
}
示例9: addButton
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
private void addButton( RedButton btn ) {
add( btn );
btn.setRect( 0, pos > 0 ? pos += GAP : 0, WIDTH, BTN_HEIGHT );
pos += BTN_HEIGHT;
}
示例10: StatsTab
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public StatsTab() {
super();
String heroClass = Dungeon.hero.className();
IconTitle title = new IconTitle();
title.icon( HeroSprite.avatar( Dungeon.hero.heroClass, Dungeon.hero.tier() ) );
title.label( Utils.format( TXT_TITLE, Dungeon.hero.lvl, heroClass ).toUpperCase( Locale.ENGLISH ) );
title.color(Window.SHPX_COLOR);
title.setRect( 0, 0, WIDTH, 0 );
add( title );
float pos = title.bottom();
if (Dungeon.challenges > 0) {
RedButton btnCatalogus = new RedButton( TXT_CHALLENGES ) {
@Override
protected void onClick() {
Game.scene().add( new WndChallenges( Dungeon.challenges, false ) );
}
};
btnCatalogus.setRect( 0, pos + GAP, btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2 );
add( btnCatalogus );
pos = btnCatalogus.bottom();
}
pos += GAP + GAP;
pos = statSlot( this, TXT_STR, Integer.toString( Dungeon.hero.STR ), pos );
pos = statSlot( this, TXT_HEALTH, Integer.toString( Dungeon.hero.HT ), pos );
pos += GAP;
pos = statSlot( this, TXT_DURATION, Integer.toString( (int)Statistics.duration ), pos );
pos += GAP;
pos = statSlot( this, TXT_DEPTH, Integer.toString( Statistics.deepestFloor ), pos );
pos = statSlot( this, TXT_ENEMIES, Integer.toString( Statistics.enemiesSlain ), pos );
pos = statSlot( this, TXT_GOLD, Integer.toString( Statistics.goldCollected ), pos );
pos += GAP;
pos = statSlot( this, TXT_FOOD, Integer.toString( Statistics.foodEaten ), pos );
pos = statSlot( this, TXT_ALCHEMY, Integer.toString( Statistics.potionsCooked ), pos );
pos = statSlot( this, TXT_ANKHS, Integer.toString( Statistics.ankhsUsed ), pos );
}
示例11: WndTradeItem
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndTradeItem( final Item item, WndBag owner ) {
super();
this.owner = owner;
float pos = createDescription( item, false );
if (item.quantity() == 1) {
RedButton btnSell = new RedButton( Utils.format( TXT_SELL, item.price() ) ) {
@Override
protected void onClick() {
sell( item );
hide();
}
};
btnSell.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT );
add( btnSell );
pos = btnSell.bottom();
} else {
int priceAll= item.price();
RedButton btnSell1 = new RedButton( Utils.format( TXT_SELL_1, priceAll / item.quantity() ) ) {
@Override
protected void onClick() {
sellOne( item );
hide();
}
};
btnSell1.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT );
add( btnSell1 );
RedButton btnSellAll = new RedButton( Utils.format( TXT_SELL_ALL, priceAll ) ) {
@Override
protected void onClick() {
sell( item );
hide();
}
};
btnSellAll.setRect( 0, btnSell1.bottom() + GAP, WIDTH, BTN_HEIGHT );
add( btnSellAll );
pos = btnSellAll.bottom();
}
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( 0, pos + GAP, WIDTH, BTN_HEIGHT );
add( btnCancel );
resize( WIDTH, (int)btnCancel.bottom() );
}
示例12: StatsTab
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public StatsTab() {
Hero hero = Dungeon.hero;
IconTitle title = new IconTitle();
title.icon( HeroSprite.avatar(hero.heroClass, hero.tier()) );
title.label(Utils.format( TXT_TITLE, hero.lvl, hero.className() ).toUpperCase( Locale.ENGLISH ), 9);
title.color(Window.SHPX_COLOR);
title.setRect( 0, 0, WIDTH, 0 );
add(title);
RedButton btnCatalogus = new RedButton( TXT_CATALOGUS ) {
@Override
protected void onClick() {
hide();
GameScene.show( new WndCatalogus() );
}
};
btnCatalogus.setRect( 0, title.height(), btnCatalogus.reqWidth() + 2, btnCatalogus.reqHeight() + 2 );
add( btnCatalogus );
RedButton btnJournal = new RedButton( TXT_JOURNAL ) {
@Override
protected void onClick() {
hide();
GameScene.show( new WndJournal() );
}
};
btnJournal.setRect(
btnCatalogus.right() + 1, btnCatalogus.top(),
btnJournal.reqWidth() + 2, btnJournal.reqHeight() + 2 );
add( btnJournal );
pos = btnCatalogus.bottom() + GAP;
statSlot( TXT_STR, hero.STR() );
statSlot( TXT_HEALTH, hero.HP + "/" + hero.HT );
statSlot( TXT_EXP, hero.exp + "/" + hero.maxExp() );
pos += GAP;
statSlot( TXT_GOLD, Statistics.goldCollected );
statSlot( TXT_DEPTH, Statistics.deepestFloor );
pos += GAP;
}
示例13: WndBlacksmith
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndBlacksmith( Blacksmith troll, Hero hero ) {
super();
IconTitle titlebar = new IconTitle();
titlebar.icon( troll.sprite() );
titlebar.label( Utils.capitalize( troll.name ) );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline message = PixelScene.createMultiline( TXT_PROMPT, 6 );
message.maxWidth = WIDTH;
message.measure();
message.y = titlebar.bottom() + GAP;
add( message );
btnItem1 = new ItemButton() {
@Override
protected void onClick() {
btnPressed = btnItem1;
GameScene.selectItem( itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT );
}
};
btnItem1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.y + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
add( btnItem1 );
btnItem2 = new ItemButton() {
@Override
protected void onClick() {
btnPressed = btnItem2;
GameScene.selectItem( itemSelector, WndBag.Mode.UPGRADEABLE, TXT_SELECT );
}
};
btnItem2.setRect( btnItem1.right() + BTN_GAP, btnItem1.top(), BTN_SIZE, BTN_SIZE );
add( btnItem2 );
btnReforge = new RedButton( TXT_REFORGE ) {
@Override
protected void onClick() {
Blacksmith.upgrade( btnItem1.item, btnItem2.item );
hide();
}
};
btnReforge.enable( false );
btnReforge.setRect( 0, btnItem1.bottom() + BTN_GAP, WIDTH, 20 );
add( btnReforge );
resize( WIDTH, (int)btnReforge.bottom() );
}
示例14: WndChooseWay
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndChooseWay( final TomeOfMastery tome, final HeroSubClass way1, final HeroSubClass way2 ) {
super();
IconTitle titlebar = new IconTitle();
titlebar.icon( new ItemSprite( tome.image(), null ) );
titlebar.label( tome.name() );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
Highlighter hl = new Highlighter( way1.desc() + "\n\n" + way2.desc() + "\n\n" + TXT_MESSAGE );
BitmapTextMultiline normal = PixelScene.createMultiline( hl.text, 6 );
normal.maxWidth = WIDTH;
normal.measure();
normal.x = titlebar.left();
normal.y = titlebar.bottom() + GAP;
add( normal );
if (hl.isHighlighted()) {
normal.mask = hl.inverted();
BitmapTextMultiline highlighted = PixelScene.createMultiline( hl.text, 6 );
highlighted.maxWidth = normal.maxWidth;
highlighted.measure();
highlighted.x = normal.x;
highlighted.y = normal.y;
add( highlighted );
highlighted.mask = hl.mask;
highlighted.hardlight( TITLE_COLOR );
}
RedButton btnWay1 = new RedButton( Utils.capitalize( way1.title() ) ) {
@Override
protected void onClick() {
hide();
tome.choose( way1 );
}
};
btnWay1.setRect( 0, normal.y + normal.height() + GAP, (WIDTH - GAP) / 2, BTN_HEIGHT );
add( btnWay1 );
RedButton btnWay2 = new RedButton( Utils.capitalize( way2.title() ) ) {
@Override
protected void onClick() {
hide();
tome.choose( way2 );
}
};
btnWay2.setRect( btnWay1.right() + GAP, btnWay1.top(), btnWay1.width(), BTN_HEIGHT );
add( btnWay2 );
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( 0, btnWay2.bottom() + GAP, WIDTH, BTN_HEIGHT );
add( btnCancel );
resize( WIDTH, (int)btnCancel.bottom() );
}
示例15: WndBalance
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; //导入方法依赖的package包/类
public WndBalance( final Weapon weapon ) {
super();
IconTitle titlebar = new IconTitle( weapon );
titlebar.setRect( 0, 0, WIDTH, 0 );
add( titlebar );
BitmapTextMultiline tfMesage = PixelScene.createMultiline( Utils.format( TXT_CHOICE, weapon.name() ), 8 );
tfMesage.maxWidth = WIDTH - MARGIN * 2;
tfMesage.measure();
tfMesage.x = MARGIN;
tfMesage.y = titlebar.bottom() + MARGIN;
add( tfMesage );
float pos = tfMesage.y + tfMesage.height();
if (weapon.imbue != Weapon.Imbue.LIGHT) {
RedButton btnSpeed = new RedButton( TXT_LIGHT ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, true );
}
};
btnSpeed.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnSpeed );
pos = btnSpeed.bottom();
}
if (weapon.imbue != Weapon.Imbue.HEAVY) {
RedButton btnAccuracy = new RedButton( TXT_HEAVY ) {
@Override
protected void onClick() {
hide();
Weightstone.this.apply( weapon, false );
}
};
btnAccuracy.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnAccuracy );
pos = btnAccuracy.bottom();
}
RedButton btnCancel = new RedButton( TXT_CANCEL ) {
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect( MARGIN, pos + MARGIN, BUTTON_WIDTH, BUTTON_HEIGHT );
add( btnCancel );
resize( WIDTH, (int)btnCancel.bottom() + MARGIN );
}