From 225c194de847adaab7b84dca2eb32b99074069b6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 13 Jun 2020 14:46:00 -0400 Subject: [PATCH] v0.8.1: bags now appear again in their own bag window --- .../items/bags/MagicalHolster.java | 4 ++++ .../items/bags/PotionBandolier.java | 4 ++++ .../items/bags/ScrollHolder.java | 4 ++++ .../items/bags/VelvetPouch.java | 4 ++++ .../shatteredpixeldungeon/windows/WndBag.java | 20 +++++++++++++------ 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/MagicalHolster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/MagicalHolster.java index 516037d26..749ac6d8e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/MagicalHolster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/MagicalHolster.java @@ -44,6 +44,10 @@ public class MagicalHolster extends Bag { return false; } } + + public int capacity(){ + return 19; + } @Override public boolean collect( Bag container ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/PotionBandolier.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/PotionBandolier.java index de05b8a98..663dd5259 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/PotionBandolier.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/PotionBandolier.java @@ -43,6 +43,10 @@ public class PotionBandolier extends Bag { } } + public int capacity(){ + return 19; + } + @Override public int price() { return 40; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java index 8dff4122c..4076ca10e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/ScrollHolder.java @@ -44,6 +44,10 @@ public class ScrollHolder extends Bag { return false; } } + + public int capacity(){ + return 19; + } @Override public void onDetach( ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/VelvetPouch.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/VelvetPouch.java index 6eeac1333..70171a6eb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/VelvetPouch.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/bags/VelvetPouch.java @@ -45,6 +45,10 @@ public class VelvetPouch extends Bag { return false; } } + + public int capacity(){ + return 19; + } @Override public int price() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java index 2c0c25db7..d86f91227 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBag.java @@ -221,9 +221,19 @@ public class WndBag extends WndTabbed { placeItem( stuff.misc1 != null ? stuff.misc1 : new Placeholder( ItemSpriteSheet.RING_HOLDER ) ); placeItem( stuff.misc2 != null ? stuff.misc2 : new Placeholder( ItemSpriteSheet.RING_HOLDER ) ); - // Items in the bag + //the container itself if it's not the root backpack + if (container != Dungeon.hero.belongings.backpack){ + placeItem(container); + count--; //don't count this one, as it's not actually inside of itself + } + + // Items in the bag, except other containers (they have tags at the bottom) for (Item item : container.items.toArray(new Item[0])) { - placeItem( item ); + if (!(item instanceof Bag)) { + placeItem( item ); + } else { + count++; + } } // Free Space @@ -235,8 +245,6 @@ public class WndBag extends WndTabbed { protected void placeItem( final Item item ) { count++; - - if (item instanceof Bag) return; int x = col * (SLOT_WIDTH + SLOT_MARGIN); int y = TITLE_HEIGHT + row * (SLOT_HEIGHT + SLOT_MARGIN); @@ -346,7 +354,7 @@ public class WndBag extends WndTabbed { super( item ); this.item = item; - if (item instanceof Gold) { + if (item instanceof Gold || item instanceof Bag) { bg.visible = false; } @@ -433,7 +441,7 @@ public class WndBag extends WndTabbed { @Override protected void onClick() { - if (!lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){ + if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){ hide();