v0.6.3a: fixed various rare crashes with the alchemy window
This commit is contained in:
parent
6d53f238bc
commit
8d09f897a5
|
@ -86,25 +86,27 @@ public class WndAlchemy extends Window {
|
|||
|
||||
h += desc.height() + 6;
|
||||
|
||||
synchronized (inputs) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
inputs[i] = new WndBlacksmith.ItemButton(){
|
||||
inputs[i] = new WndBlacksmith.ItemButton() {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
if (item != null){
|
||||
if (!item.collect()){
|
||||
if (item != null) {
|
||||
if (!item.collect()) {
|
||||
Dungeon.level.drop(item, Dungeon.hero.pos);
|
||||
}
|
||||
item = null;
|
||||
slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
|
||||
}
|
||||
GameScene.selectItem( itemSelector, WndBag.Mode.ALCHEMY, Messages.get(WndAlchemy.class, "select") );
|
||||
GameScene.selectItem(itemSelector, WndBag.Mode.ALCHEMY, Messages.get(WndAlchemy.class, "select"));
|
||||
}
|
||||
};
|
||||
inputs[i].setRect(10, h, BTN_SIZE, BTN_SIZE);
|
||||
add(inputs[i]);
|
||||
h += BTN_SIZE + 2;
|
||||
}
|
||||
}
|
||||
|
||||
btnCombine = new RedButton(""){
|
||||
Image arrow;
|
||||
|
@ -211,10 +213,11 @@ public class WndAlchemy extends Window {
|
|||
protected WndBag.Listener itemSelector = new WndBag.Listener() {
|
||||
@Override
|
||||
public void onSelect( Item item ) {
|
||||
if (item != null) {
|
||||
synchronized (inputs) {
|
||||
if (item != null && inputs[0] != null) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i].item == null){
|
||||
if (item instanceof Dart){
|
||||
if (inputs[i].item == null) {
|
||||
if (item instanceof Dart) {
|
||||
inputs[i].item(item.detachAll(Dungeon.hero.belongings.backpack));
|
||||
} else {
|
||||
inputs[i].item(item.detach(Dungeon.hero.belongings.backpack));
|
||||
|
@ -222,9 +225,10 @@ public class WndAlchemy extends Window {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
updateState();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private<T extends Item> ArrayList<T> filterInput(Class<? extends T> itemClass){
|
||||
|
@ -276,8 +280,9 @@ public class WndAlchemy extends Window {
|
|||
Dungeon.level.drop(result, Dungeon.hero.pos);
|
||||
}
|
||||
|
||||
for (int i = 0; i < inputs.length; i++){
|
||||
if (inputs[i].item != null) {
|
||||
synchronized (inputs) {
|
||||
for (int i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i] != null && inputs[i].item != null) {
|
||||
if (inputs[i].item.quantity() <= 0) {
|
||||
inputs[i].slot.item(new WndBag.Placeholder(ItemSpriteSheet.SOMETHING));
|
||||
inputs[i].item = null;
|
||||
|
@ -286,6 +291,7 @@ public class WndAlchemy extends Window {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
btnCombine.enable(false);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user