v0.9.1: Improved window UI for sad ghost rewards
This commit is contained in:
parent
acfc24b97c
commit
8f16b90667
|
@ -134,9 +134,9 @@ windows.wndsadghost.crab_title=DEFEATED GREAT CRAB
|
|||
windows.wndsadghost.rat=Thank you, that horrid rat is slain and I can finally rest... I wonder what twisted magic created such a foul creature...
|
||||
windows.wndsadghost.gnoll=Thank you, that scheming gnoll is slain and I can finally rest... I wonder what twisted magic made it so smart...
|
||||
windows.wndsadghost.crab=Thank you, that giant crab is slain and I can finally rest... I wonder what twisted magic allowed it to live so long...
|
||||
windows.wndsadghost.give_item=\n\nPlease take one of these items, they are useless to me now... Maybe they will help you in your journey...\n\nAlso... There is an item lost in this dungeon that is very dear to me... If you ever... find my... rose......
|
||||
windows.wndsadghost.weapon=Ghost's weapon
|
||||
windows.wndsadghost.armor=Ghost's armor
|
||||
windows.wndsadghost.give_item=Please take one of these items, they are useless to me now... Maybe they will help you in your journey...\n\nAlso... There is an item lost in this dungeon that is very dear to me... If you ever... find my... rose......
|
||||
windows.wndsadghost.confirm=Confirm
|
||||
windows.wndsadghost.cancel=Cancel
|
||||
windows.wndsadghost.farewell=Farewell, adventurer!
|
||||
|
||||
windows.wndsettings$displaytab.title=Display Settings
|
||||
|
|
|
@ -204,12 +204,16 @@ public class Ghost extends NPC {
|
|||
|
||||
public static Weapon weapon;
|
||||
public static Armor armor;
|
||||
public static Weapon.Enchantment enchant;
|
||||
public static Armor.Glyph glyph;
|
||||
|
||||
public static void reset() {
|
||||
spawned = false;
|
||||
|
||||
weapon = null;
|
||||
armor = null;
|
||||
enchant = null;
|
||||
glyph = null;
|
||||
}
|
||||
|
||||
private static final String NODE = "sadGhost";
|
||||
|
@ -221,6 +225,8 @@ public class Ghost extends NPC {
|
|||
private static final String DEPTH = "depth";
|
||||
private static final String WEAPON = "weapon";
|
||||
private static final String ARMOR = "armor";
|
||||
private static final String ENCHANT = "enchant";
|
||||
private static final String GLYPH = "glyph";
|
||||
|
||||
public static void storeInBundle( Bundle bundle ) {
|
||||
|
||||
|
@ -234,10 +240,15 @@ public class Ghost extends NPC {
|
|||
|
||||
node.put( GIVEN, given );
|
||||
node.put( DEPTH, depth );
|
||||
node.put( PROCESSED, processed);
|
||||
node.put( PROCESSED, processed );
|
||||
|
||||
node.put( WEAPON, weapon );
|
||||
node.put( ARMOR, armor );
|
||||
|
||||
if (enchant != null) {
|
||||
node.put(ENCHANT, enchant);
|
||||
node.put(GLYPH, glyph);
|
||||
}
|
||||
}
|
||||
|
||||
bundle.put( NODE, node );
|
||||
|
@ -257,6 +268,11 @@ public class Ghost extends NPC {
|
|||
|
||||
weapon = (Weapon)node.get( WEAPON );
|
||||
armor = (Armor)node.get( ARMOR );
|
||||
|
||||
if (node.contains(ENCHANT)) {
|
||||
enchant = (Weapon.Enchantment) node.get(ENCHANT);
|
||||
glyph = (Armor.Glyph) node.get(GLYPH);
|
||||
}
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
|
@ -308,10 +324,10 @@ public class Ghost extends NPC {
|
|||
weapon.upgrade(itemLevel);
|
||||
armor.upgrade(itemLevel);
|
||||
|
||||
//10% to be enchanted
|
||||
//10% to be enchanted. We store it separately so enchant status isn't revealed early
|
||||
if (Random.Int(10) == 0){
|
||||
weapon.enchant();
|
||||
armor.inscribe();
|
||||
enchant = Weapon.Enchantment.random();
|
||||
glyph = Armor.Glyph.random();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,28 +21,42 @@
|
|||
|
||||
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.Ghost;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.Weapon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.FetidRatSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.GnollTricksterSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.GreatCrabSprite;
|
||||
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 WndSadGhost 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;
|
||||
|
||||
Ghost ghost;
|
||||
|
||||
public WndSadGhost( final Ghost ghost, final int type ) {
|
||||
|
||||
super();
|
||||
|
||||
this.ghost = ghost;
|
||||
|
||||
IconTitle titlebar = new IconTitle();
|
||||
RenderedTextBlock message;
|
||||
|
@ -50,17 +64,17 @@ public class WndSadGhost extends Window {
|
|||
case 1:default:
|
||||
titlebar.icon( new FetidRatSprite() );
|
||||
titlebar.label( Messages.get(this, "rat_title") );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "rat")+Messages.get(this, "give_item"), 6 );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "rat")+"\n\n"+Messages.get(this, "give_item"), 6 );
|
||||
break;
|
||||
case 2:
|
||||
titlebar.icon( new GnollTricksterSprite() );
|
||||
titlebar.label( Messages.get(this, "gnoll_title") );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "gnoll")+Messages.get(this, "give_item"), 6 );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "gnoll")+"\n\n"+Messages.get(this, "give_item"), 6 );
|
||||
break;
|
||||
case 3:
|
||||
titlebar.icon( new GreatCrabSprite());
|
||||
titlebar.label( Messages.get(this, "crab_title") );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "crab")+Messages.get(this, "give_item"), 6 );
|
||||
message = PixelScene.renderTextBlock( Messages.get(this, "crab")+"\n\n"+Messages.get(this, "give_item"), 6 );
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -71,33 +85,29 @@ public class WndSadGhost extends Window {
|
|||
message.maxWidth(WIDTH);
|
||||
message.setPos(0, titlebar.bottom() + GAP);
|
||||
add( message );
|
||||
|
||||
RedButton btnWeapon = new RedButton( Ghost.Quest.weapon.trueName() + " :" + Ghost.Quest.weapon.STRReq(0) ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
selectReward( ghost, Ghost.Quest.weapon );
|
||||
}
|
||||
};
|
||||
btnWeapon.setRect( 0, message.top() + message.height() + GAP, WIDTH, BTN_HEIGHT );
|
||||
|
||||
RewardButton btnWeapon = new RewardButton( Ghost.Quest.weapon );
|
||||
btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
||||
add( btnWeapon );
|
||||
|
||||
RedButton btnArmor = new RedButton( Ghost.Quest.armor.trueName() + " :" + Ghost.Quest.armor.STRReq(0) ) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
selectReward(ghost, Ghost.Quest.armor);
|
||||
}
|
||||
};
|
||||
btnArmor.setRect(0, btnWeapon.bottom() + GAP, WIDTH, BTN_HEIGHT);
|
||||
RewardButton btnArmor = new RewardButton( Ghost.Quest.armor );
|
||||
btnArmor.setRect( btnWeapon.right() + BTN_GAP, btnWeapon.top(), BTN_SIZE, BTN_SIZE );
|
||||
add(btnArmor);
|
||||
|
||||
resize(WIDTH, (int) btnArmor.bottom());
|
||||
resize(WIDTH, (int) btnArmor.bottom() + BTN_GAP);
|
||||
}
|
||||
|
||||
private void selectReward( Ghost ghost, Item reward ) {
|
||||
private void selectReward( Item reward ) {
|
||||
|
||||
hide();
|
||||
|
||||
if (reward == null) return;
|
||||
|
||||
if (reward instanceof Weapon && Ghost.Quest.enchant != null){
|
||||
((Weapon) reward).enchant(Ghost.Quest.enchant);
|
||||
} else if (reward instanceof Armor && Ghost.Quest.glyph != null){
|
||||
((Armor) reward).inscribe(Ghost.Quest.glyph);
|
||||
}
|
||||
|
||||
reward.identify();
|
||||
if (reward.doPickUp( Dungeon.hero )) {
|
||||
|
@ -111,4 +121,72 @@ public class WndSadGhost extends Window {
|
|||
|
||||
Ghost.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 );
|
||||
}
|
||||
}
|
||||
|
||||
public 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();
|
||||
|
||||
WndSadGhost.this.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() {
|
||||
RewardWindow.this.hide();
|
||||
}
|
||||
};
|
||||
btnCancel.setRect(btnConfirm.right()+2, height+2, btnConfirm.width(), 16);
|
||||
add(btnCancel);
|
||||
|
||||
resize(width, (int)btnCancel.bottom());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user