v0.9.2a: improved the reward UI for the wandmaker

This commit is contained in:
Evan Debenham 2021-03-08 19:34:25 -05:00
parent bbceaa9fa2
commit 2d4ffec6a0
2 changed files with 94 additions and 22 deletions

View File

@ -122,7 +122,7 @@ public class WndSadGhost extends Window {
Ghost.Quest.complete();
}
public class RewardButton extends Component {
private class RewardButton extends Component {
protected NinePatch bg;
protected ItemSlot slot;
@ -161,7 +161,7 @@ public class WndSadGhost extends Window {
}
}
public class RewardWindow extends WndInfoItem {
private class RewardWindow extends WndInfoItem {
public RewardWindow( Item item ) {
super(item);

View File

@ -21,30 +21,43 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.NinePatch;
import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.ui.Component;
public class WndWandmaker extends Window {
private static final int WIDTH = 120;
private static final int BTN_HEIGHT = 20;
private static final float GAP = 2;
private static final int BTN_SIZE = 32;
private static final int BTN_GAP = 5;
private static final int GAP = 2;
Wandmaker wandmaker;
Item item;
public WndWandmaker( final Wandmaker wandmaker, final Item item ) {
super();
this.wandmaker = wandmaker;
this.item = item;
IconTitle titlebar = new IconTitle();
titlebar.icon(new ItemSprite(item.image(), null));
@ -66,28 +79,18 @@ public class WndWandmaker extends Window {
message.setPos(0, titlebar.bottom() + GAP);
add( message );
RedButton btnWand1 = new RedButton( Messages.titleCase(Wandmaker.Quest.wand1.name()) ) {
@Override
protected void onClick() {
selectReward( wandmaker, item, Wandmaker.Quest.wand1 );
}
};
btnWand1.setRect(0, message.top() + message.height() + GAP, WIDTH, BTN_HEIGHT);
RewardButton btnWand1 = new RewardButton( Wandmaker.Quest.wand1 );
btnWand1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
add( btnWand1 );
RedButton btnWand2 = new RedButton( Messages.titleCase(Wandmaker.Quest.wand2.name()) ) {
@Override
protected void onClick() {
selectReward( wandmaker, item, Wandmaker.Quest.wand2 );
}
};
btnWand2.setRect(0, btnWand1.bottom() + GAP, WIDTH, BTN_HEIGHT);
add( btnWand2 );
RewardButton btnWand2 = new RewardButton( Wandmaker.Quest.wand2 );
btnWand2.setRect( btnWand1.right() + BTN_GAP, btnWand1.top(), BTN_SIZE, BTN_SIZE );
add(btnWand2);
resize(WIDTH, (int) btnWand2.bottom());
}
private void selectReward( Wandmaker wandmaker, Item item, Wand reward ) {
private void selectReward( Item reward ) {
if (reward == null){
return;
@ -111,4 +114,73 @@ public class WndWandmaker extends Window {
Wandmaker.Quest.complete();
}
public class RewardButton extends Component {
protected NinePatch bg;
protected ItemSlot slot;
public RewardButton( Item item ){
bg = Chrome.get( Chrome.Type.RED_BUTTON);
add( bg );
slot = new ItemSlot( item ){
@Override
protected void onPointerDown() {
bg.brightness( 1.2f );
Sample.INSTANCE.play( Assets.Sounds.CLICK );
}
@Override
protected void onPointerUp() {
bg.resetColor();
}
@Override
protected void onClick() {
ShatteredPixelDungeon.scene().addToFront(new RewardWindow(item));
}
};
add(slot);
}
@Override
protected void layout() {
super.layout();
bg.x = x;
bg.y = y;
bg.size( width, height );
slot.setRect( x + 2, y + 2, width - 4, height - 4 );
}
}
private class RewardWindow extends WndInfoItem {
public RewardWindow( Item item ) {
super(item);
RedButton btnConfirm = new RedButton(Messages.get(WndSadGhost.class, "confirm")){
@Override
protected void onClick() {
RewardWindow.this.hide();
selectReward( item );
}
};
btnConfirm.setRect(0, height+2, width/2-1, 16);
add(btnConfirm);
RedButton btnCancel = new RedButton(Messages.get(WndSadGhost.class, "cancel")){
@Override
protected void onClick() {
hide();
}
};
btnCancel.setRect(btnConfirm.right()+2, height+2, btnConfirm.width(), 16);
add(btnCancel);
resize(width, (int)btnCancel.bottom());
}
}
}