v2.2.0: ghost and wandmaker dialogues now use ItemButton

This commit is contained in:
Evan Debenham
2023-08-18 13:39:38 -04:00
parent 2584717742
commit 0116fdbf57
2 changed files with 39 additions and 99 deletions

View File

@@ -21,8 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost;
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.GnollTricksterSprite;
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.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 {
@@ -86,11 +81,23 @@ public class WndSadGhost extends Window {
message.setPos(0, titlebar.bottom() + GAP);
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 );
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 );
add(btnArmor);
@@ -122,45 +129,6 @@ public class WndSadGhost extends Window {
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 {
public RewardWindow( Item item ) {

View File

@@ -21,8 +21,6 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
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.PixelScene;
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.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 {
@@ -78,12 +73,32 @@ public class WndWandmaker extends Window {
message.maxWidth(WIDTH);
message.setPos(0, titlebar.bottom() + GAP);
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 );
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 );
add(btnWand2);
@@ -115,49 +130,6 @@ 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() {
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 {
public RewardWindow( Item item ) {