v2.2.0: ghost and wandmaker dialogues now use ItemButton
This commit is contained in:
+15
-47
@@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
@@ -34,14 +32,11 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.FetidRatSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.FetidRatSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.GnollTricksterSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.GnollTricksterSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.GreatCrabSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.GreatCrabSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
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 {
|
public class WndSadGhost extends Window {
|
||||||
|
|
||||||
@@ -86,11 +81,23 @@ public class WndSadGhost extends Window {
|
|||||||
message.setPos(0, titlebar.bottom() + GAP);
|
message.setPos(0, titlebar.bottom() + GAP);
|
||||||
add( message );
|
add( message );
|
||||||
|
|
||||||
RewardButton btnWeapon = new RewardButton( Ghost.Quest.weapon );
|
ItemButton btnWeapon = new ItemButton(){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
GameScene.show(new RewardWindow(item()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnWeapon.item( Ghost.Quest.weapon );
|
||||||
btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
btnWeapon.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
||||||
add( btnWeapon );
|
add( btnWeapon );
|
||||||
|
|
||||||
RewardButton btnArmor = new RewardButton( Ghost.Quest.armor );
|
ItemButton btnArmor = new ItemButton(){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
GameScene.show(new RewardWindow(item()));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnArmor.item( Ghost.Quest.armor );
|
||||||
btnArmor.setRect( btnWeapon.right() + BTN_GAP, btnWeapon.top(), BTN_SIZE, BTN_SIZE );
|
btnArmor.setRect( btnWeapon.right() + BTN_GAP, btnWeapon.top(), BTN_SIZE, BTN_SIZE );
|
||||||
add(btnArmor);
|
add(btnArmor);
|
||||||
|
|
||||||
@@ -122,45 +129,6 @@ public class WndSadGhost extends Window {
|
|||||||
Ghost.Quest.complete();
|
Ghost.Quest.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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() {
|
|
||||||
GameScene.show(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 {
|
private class RewardWindow extends WndInfoItem {
|
||||||
|
|
||||||
public RewardWindow( Item item ) {
|
public RewardWindow( Item item ) {
|
||||||
|
|||||||
+24
-52
@@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
@@ -33,14 +31,11 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
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 {
|
public class WndWandmaker extends Window {
|
||||||
|
|
||||||
@@ -78,12 +73,32 @@ public class WndWandmaker extends Window {
|
|||||||
message.maxWidth(WIDTH);
|
message.maxWidth(WIDTH);
|
||||||
message.setPos(0, titlebar.bottom() + GAP);
|
message.setPos(0, titlebar.bottom() + GAP);
|
||||||
add( message );
|
add( message );
|
||||||
|
|
||||||
RewardButton btnWand1 = new RewardButton( Wandmaker.Quest.wand1 );
|
ItemButton btnWand1 = new ItemButton(){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
if (Dungeon.hero.belongings.contains(questItem)) {
|
||||||
|
GameScene.show(new RewardWindow(item));
|
||||||
|
} else {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnWand1.item(Wandmaker.Quest.wand1);
|
||||||
btnWand1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
btnWand1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
||||||
add( btnWand1 );
|
add( btnWand1 );
|
||||||
|
|
||||||
RewardButton btnWand2 = new RewardButton( Wandmaker.Quest.wand2 );
|
ItemButton btnWand2 = new ItemButton(){
|
||||||
|
@Override
|
||||||
|
protected void onClick() {
|
||||||
|
if (Dungeon.hero.belongings.contains(questItem)) {
|
||||||
|
GameScene.show(new RewardWindow(item));
|
||||||
|
} else {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnWand2.item(Wandmaker.Quest.wand2);
|
||||||
btnWand2.setRect( btnWand1.right() + BTN_GAP, btnWand1.top(), BTN_SIZE, BTN_SIZE );
|
btnWand2.setRect( btnWand1.right() + BTN_GAP, btnWand1.top(), BTN_SIZE, BTN_SIZE );
|
||||||
add(btnWand2);
|
add(btnWand2);
|
||||||
|
|
||||||
@@ -115,49 +130,6 @@ public class WndWandmaker extends Window {
|
|||||||
Wandmaker.Quest.complete();
|
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() {
|
|
||||||
if (Dungeon.hero.belongings.contains(questItem)) {
|
|
||||||
GameScene.show(new RewardWindow(item));
|
|
||||||
} else {
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
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 {
|
private class RewardWindow extends WndInfoItem {
|
||||||
|
|
||||||
public RewardWindow( Item item ) {
|
public RewardWindow( Item item ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user