v1.2.0: added right click menu functionality to the old bag window
v1.2.0: added right click menu functionality to the old bag window
This commit is contained in:
parent
7e2b8d3672
commit
4fcf108cd3
|
@ -88,9 +88,8 @@ public class RightClickMenu extends Component {
|
|||
super.onClick();
|
||||
if (item != null){
|
||||
item.execute(Dungeon.hero, options[finalI]);
|
||||
} else {
|
||||
onSelect(finalI);
|
||||
}
|
||||
onSelect(finalI);
|
||||
RightClickMenu.this.destroy();
|
||||
RightClickMenu.this.killAndErase();
|
||||
}
|
||||
|
@ -128,11 +127,11 @@ public class RightClickMenu extends Component {
|
|||
|
||||
width = icon.width + 2 + titleText.width()+bg.marginVer();
|
||||
|
||||
if (x + width > camera.width){
|
||||
x -= (x + width - camera.width);
|
||||
if (x + width > (camera.width + camera.scroll.x)){
|
||||
x -= (x + width - (camera.width + camera.scroll.x));
|
||||
}
|
||||
if (y + height > camera.height){
|
||||
y -= (y + height - camera.height);
|
||||
if (y + height > (camera.height + camera.scroll.y)){
|
||||
y -= (y + height - (camera.height + camera.scroll.y));
|
||||
}
|
||||
|
||||
bg.x = x;
|
||||
|
|
|
@ -45,15 +45,18 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.InventorySlot;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ui.ItemSlot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RightClickMenu;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.input.KeyBindings;
|
||||
import com.watabou.input.KeyEvent;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.PointF;
|
||||
|
||||
public class WndBag extends WndTabbed {
|
||||
|
||||
|
@ -291,6 +294,34 @@ public class WndBag extends WndTabbed {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick() {
|
||||
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
|
||||
|
||||
hide();
|
||||
|
||||
} else if (selector != null) {
|
||||
|
||||
hide();
|
||||
selector.onSelect( item );
|
||||
|
||||
} else {
|
||||
|
||||
RightClickMenu r = new RightClickMenu(item){
|
||||
@Override
|
||||
public void onSelect(int index) {
|
||||
WndBag.this.hide();
|
||||
}
|
||||
};
|
||||
parent.addToFront(r);
|
||||
r.camera = camera();
|
||||
PointF mousePos = PointerEvent.currentHoverPos();
|
||||
mousePos = camera.screenToCamera((int)mousePos.x, (int)mousePos.y);
|
||||
r.setPos(mousePos.x-3, mousePos.y-3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onLongClick() {
|
||||
if (selector == null && item.defaultAction != null) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user