v1.2.0: fixed keypresses not cancelling inventory pane selection
This commit is contained in:
parent
2f17a264ea
commit
83c83e7b25
|
@ -40,6 +40,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndUseItem;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.input.KeyEvent;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
|
@ -50,6 +51,7 @@ import com.watabou.noosa.PointerArea;
|
|||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.Point;
|
||||
import com.watabou.utils.PointF;
|
||||
import com.watabou.utils.Signal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -61,6 +63,8 @@ public class InventoryPane extends Component {
|
|||
//used to prevent clicks through the BG normally, or to cancel selectors if they're enabled
|
||||
private PointerArea blocker;
|
||||
|
||||
private Signal.Listener keyBlocker;
|
||||
|
||||
private static InventoryPane instance;
|
||||
|
||||
private ArrayList<InventorySlot> equipped;
|
||||
|
@ -129,6 +133,18 @@ public class InventoryPane extends Component {
|
|||
blocker.target = bg; //targets bg when there is no selector, otherwise targets itself
|
||||
add (blocker);
|
||||
|
||||
keyBlocker = new Signal.Listener<KeyEvent>(){
|
||||
@Override
|
||||
public boolean onSignal(KeyEvent keyEvent) {
|
||||
if (keyEvent.pressed && isSelecting()){
|
||||
selector = null;
|
||||
updateInventory();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
equipped = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++){
|
||||
InventorySlot btn = new InventoryPaneSlot(null);
|
||||
|
@ -243,8 +259,10 @@ public class InventoryPane extends Component {
|
|||
public void updateInventory(){
|
||||
if (selector == null){
|
||||
blocker.target = bg;
|
||||
KeyEvent.removeKeyListener(keyBlocker);
|
||||
} else {
|
||||
blocker.target = blocker;
|
||||
KeyEvent.addKeyListener(keyBlocker);
|
||||
}
|
||||
|
||||
Belongings stuff = Dungeon.hero.belongings;
|
||||
|
|
Loading…
Reference in New Issue
Block a user