v2.2.0: very early and incomplete impl. of new blacksmith window
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
windows.wndblacksmith.prompt=Ok, a deal is a deal, here's what I can do for you: I can reforge 2 items and turn them into one of a better quality.
|
||||
windows.wndblacksmith.select=Reforge an item
|
||||
windows.wndblacksmith.reforge=Reforge them
|
||||
windows.wndblacksmithold.prompt=Ok, a deal is a deal, here's what I can do for you: I can reforge 2 items and turn them into one of a better quality.
|
||||
windows.wndblacksmithold.select=Reforge an item
|
||||
windows.wndblacksmithold.reforge=Reforge them
|
||||
|
||||
windows.wndchallenges.title=Challenges
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBlacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBlacksmithOld;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
@@ -202,12 +203,11 @@ public class Blacksmith extends NPC {
|
||||
Game.runOnRenderThread(new Callback() {
|
||||
@Override
|
||||
public void call() {
|
||||
GameScene.show( new WndBlacksmith( Blacksmith.this, Dungeon.hero ) );
|
||||
GameScene.show( new WndBlacksmithOld( Blacksmith.this, Dungeon.hero ) );
|
||||
}
|
||||
});
|
||||
|
||||
//only the reforge window at the moment
|
||||
} else if (Quest.favor >= 500) {
|
||||
} else if (Quest.favor > 0) {
|
||||
|
||||
Game.runOnRenderThread(new Callback() {
|
||||
@Override
|
||||
@@ -350,12 +350,12 @@ public class Blacksmith extends NPC {
|
||||
private static boolean completed;
|
||||
|
||||
//reward tracking. Stores remaining favor, the pickaxe, and how many of each reward has been chosen
|
||||
private static int favor;
|
||||
private static Item pickaxe;
|
||||
private static int reforges; //also used by the pre-v2.2.0 version of the quest
|
||||
private static int hardens;
|
||||
private static int upgrades;
|
||||
private static int smiths;
|
||||
public static int favor;
|
||||
public static Item pickaxe;
|
||||
public static int reforges; //also used by the pre-v2.2.0 version of the quest
|
||||
public static int hardens;
|
||||
public static int upgrades;
|
||||
public static int smiths;
|
||||
|
||||
public static void reset() {
|
||||
type = 0;
|
||||
|
||||
@@ -21,115 +21,75 @@
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
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 java.util.ArrayList;
|
||||
|
||||
public class WndBlacksmith extends Window {
|
||||
|
||||
private static final int BTN_SIZE = 36;
|
||||
private static final float GAP = 2;
|
||||
private static final float BTN_GAP = 10;
|
||||
private static final int WIDTH = 116;
|
||||
|
||||
private ItemButton btnPressed;
|
||||
|
||||
private ItemButton btnItem1;
|
||||
private ItemButton btnItem2;
|
||||
private RedButton btnReforge;
|
||||
|
||||
public WndBlacksmith( Blacksmith troll, Hero hero ) {
|
||||
|
||||
private static final int WIDTH_P = 120;
|
||||
private static final int WIDTH_L = 160;
|
||||
|
||||
private static final int GAP = 2;
|
||||
|
||||
//A LOT still to do here!
|
||||
public WndBlacksmith(Blacksmith troll, Hero hero ) {
|
||||
super();
|
||||
|
||||
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
IconTitle titlebar = new IconTitle();
|
||||
titlebar.icon( troll.sprite() );
|
||||
titlebar.label( Messages.titleCase( troll.name() ) );
|
||||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
||||
titlebar.setRect( 0, 0, width, 0 );
|
||||
add( titlebar );
|
||||
|
||||
|
||||
RenderedTextBlock message = PixelScene.renderTextBlock( Messages.get(this, "prompt"), 6 );
|
||||
message.maxWidth( WIDTH);
|
||||
message.maxWidth( width );
|
||||
message.setPos(0, titlebar.bottom() + GAP);
|
||||
add( message );
|
||||
|
||||
btnItem1 = new ItemButton() {
|
||||
|
||||
|
||||
ArrayList<RedButton> buttons = new ArrayList<>();
|
||||
|
||||
//TODO
|
||||
RedButton pickaxe = new RedButton("_Pickaxe (250 favor):_ \"I guess I can give you the pickaxe back if you really want it. I've got plenty more.\"", 6){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
btnPressed = btnItem1;
|
||||
GameScene.selectItem( itemSelector );
|
||||
}
|
||||
};
|
||||
btnItem1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
||||
add( btnItem1 );
|
||||
|
||||
btnItem2 = new ItemButton() {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
btnPressed = btnItem2;
|
||||
GameScene.selectItem( itemSelector );
|
||||
}
|
||||
};
|
||||
btnItem2.setRect( btnItem1.right() + BTN_GAP, btnItem1.top(), BTN_SIZE, BTN_SIZE );
|
||||
add( btnItem2 );
|
||||
|
||||
btnReforge = new RedButton( Messages.get(this, "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() );
|
||||
}
|
||||
|
||||
protected WndBag.ItemSelector itemSelector = new WndBag.ItemSelector() {
|
||||
|
||||
@Override
|
||||
public String textPrompt() {
|
||||
return Messages.get(WndBlacksmith.class, "select");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?extends Bag> preferredBag(){
|
||||
return Belongings.Backpack.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemSelectable(Item item) {
|
||||
return item.isUpgradable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && btnPressed.parent != null) {
|
||||
btnPressed.item( item );
|
||||
|
||||
if (btnItem1.item() != null && btnItem2.item() != null) {
|
||||
String result = Blacksmith.verify( btnItem1.item(), btnItem2.item() );
|
||||
if (result != null) {
|
||||
GameScene.show( new WndMessage( result ) );
|
||||
btnReforge.enable( false );
|
||||
} else {
|
||||
btnReforge.enable( true );
|
||||
}
|
||||
Blacksmith.Quest.pickaxe.collect(Dungeon.hero.belongings.backpack);
|
||||
Blacksmith.Quest.favor -= 250;
|
||||
Blacksmith.Quest.pickaxe = null;
|
||||
WndBlacksmith.this.hide();
|
||||
if (Blacksmith.Quest.favor > 0) {
|
||||
GameScene.show(new WndBlacksmith(troll, hero));
|
||||
}
|
||||
}
|
||||
};
|
||||
pickaxe.enable(Blacksmith.Quest.pickaxe != null && Blacksmith.Quest.favor >= 250);
|
||||
buttons.add(pickaxe);
|
||||
|
||||
|
||||
float pos = message.bottom() + 3*GAP;
|
||||
for (RedButton b : buttons){
|
||||
b.leftJustify = true;
|
||||
b.multiline = true;
|
||||
b.setSize(width, b.reqHeight());
|
||||
b.setRect(0, pos, width, b.reqHeight());
|
||||
b.enable(b.active); //so that it's visually reflected
|
||||
add(b);
|
||||
pos = b.bottom() + GAP;
|
||||
}
|
||||
};
|
||||
|
||||
resize(width, (int)pos);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2023 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.bags.Bag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
|
||||
//pre-v2.2.0
|
||||
public class WndBlacksmithOld extends Window {
|
||||
|
||||
private static final int BTN_SIZE = 36;
|
||||
private static final float GAP = 2;
|
||||
private static final float BTN_GAP = 10;
|
||||
private static final int WIDTH = 116;
|
||||
|
||||
private ItemButton btnPressed;
|
||||
|
||||
private ItemButton btnItem1;
|
||||
private ItemButton btnItem2;
|
||||
private RedButton btnReforge;
|
||||
|
||||
public WndBlacksmithOld(Blacksmith troll, Hero hero ) {
|
||||
|
||||
super();
|
||||
|
||||
IconTitle titlebar = new IconTitle();
|
||||
titlebar.icon( troll.sprite() );
|
||||
titlebar.label( Messages.titleCase( troll.name() ) );
|
||||
titlebar.setRect( 0, 0, WIDTH, 0 );
|
||||
add( titlebar );
|
||||
|
||||
RenderedTextBlock message = PixelScene.renderTextBlock( Messages.get(this, "prompt"), 6 );
|
||||
message.maxWidth( WIDTH);
|
||||
message.setPos(0, titlebar.bottom() + GAP);
|
||||
add( message );
|
||||
|
||||
btnItem1 = new ItemButton() {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
btnPressed = btnItem1;
|
||||
GameScene.selectItem( itemSelector );
|
||||
}
|
||||
};
|
||||
btnItem1.setRect( (WIDTH - BTN_GAP) / 2 - BTN_SIZE, message.top() + message.height() + BTN_GAP, BTN_SIZE, BTN_SIZE );
|
||||
add( btnItem1 );
|
||||
|
||||
btnItem2 = new ItemButton() {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
btnPressed = btnItem2;
|
||||
GameScene.selectItem( itemSelector );
|
||||
}
|
||||
};
|
||||
btnItem2.setRect( btnItem1.right() + BTN_GAP, btnItem1.top(), BTN_SIZE, BTN_SIZE );
|
||||
add( btnItem2 );
|
||||
|
||||
btnReforge = new RedButton( Messages.get(this, "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() );
|
||||
}
|
||||
|
||||
protected WndBag.ItemSelector itemSelector = new WndBag.ItemSelector() {
|
||||
|
||||
@Override
|
||||
public String textPrompt() {
|
||||
return Messages.get(WndBlacksmithOld.class, "select");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?extends Bag> preferredBag(){
|
||||
return Belongings.Backpack.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean itemSelectable(Item item) {
|
||||
return item.isUpgradable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null && btnPressed.parent != null) {
|
||||
btnPressed.item( item );
|
||||
|
||||
if (btnItem1.item() != null && btnItem2.item() != null) {
|
||||
String result = Blacksmith.verify( btnItem1.item(), btnItem2.item() );
|
||||
if (result != null) {
|
||||
GameScene.show( new WndMessage( result ) );
|
||||
btnReforge.enable( false );
|
||||
} else {
|
||||
btnReforge.enable( true );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user