v1.2.0: Added support for item windows centered on inv pane
This commit is contained in:
parent
f8c67a0709
commit
bd79f96630
|
@ -112,7 +112,20 @@ public class InventoryPane extends Component {
|
||||||
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
|
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
|
||||||
updateInventory();
|
updateInventory();
|
||||||
} else {
|
} else {
|
||||||
Game.scene().addToFront(new WndUseItem( null, item ) );
|
Window w = new WndUseItem( null, item );
|
||||||
|
int xOfs, yOfs;
|
||||||
|
if (w.height > InventoryPane.this.height - 15){
|
||||||
|
yOfs = (camera.height - w.height)/2 - 9;
|
||||||
|
} else {
|
||||||
|
yOfs = (int)(InventoryPane.this.y)/2;
|
||||||
|
}
|
||||||
|
if (w.width > InventoryPane.this.width - 15){
|
||||||
|
xOfs = (camera.width - w.width)/2 - 9;
|
||||||
|
} else {
|
||||||
|
xOfs = (int)(InventoryPane.this.x)/2;
|
||||||
|
}
|
||||||
|
w.offset(xOfs, yOfs);
|
||||||
|
Game.scene().addToFront(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -140,7 +153,20 @@ public class InventoryPane extends Component {
|
||||||
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
|
if (lastBag != item && !lastBag.contains(item) && !item.isEquipped(Dungeon.hero)){
|
||||||
updateInventory();
|
updateInventory();
|
||||||
} else {
|
} else {
|
||||||
Game.scene().addToFront(new WndUseItem( null, item ) );
|
Window w = new WndUseItem( null, item );
|
||||||
|
int xOfs, yOfs;
|
||||||
|
if (w.height > InventoryPane.this.height - 15){
|
||||||
|
yOfs = (camera.height - w.height)/2 - 9;
|
||||||
|
} else {
|
||||||
|
yOfs = (int)(InventoryPane.this.y)/2;
|
||||||
|
}
|
||||||
|
if (w.width > InventoryPane.this.width - 15){
|
||||||
|
xOfs = (camera.width - w.width)/2 - 9;
|
||||||
|
} else {
|
||||||
|
xOfs = (int)(InventoryPane.this.x)/2;
|
||||||
|
}
|
||||||
|
w.offset(xOfs, yOfs);
|
||||||
|
Game.scene().addToFront(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class Window extends Group implements Signal.Listener<KeyEvent> {
|
||||||
protected int width;
|
protected int width;
|
||||||
protected int height;
|
protected int height;
|
||||||
|
|
||||||
|
protected int xOffset;
|
||||||
protected int yOffset;
|
protected int yOffset;
|
||||||
|
|
||||||
protected PointerArea blocker;
|
protected PointerArea blocker;
|
||||||
|
@ -51,22 +52,16 @@ public class Window extends Group implements Signal.Listener<KeyEvent> {
|
||||||
public static final int SHPX_COLOR = 0x33BB33;
|
public static final int SHPX_COLOR = 0x33BB33;
|
||||||
|
|
||||||
public Window() {
|
public Window() {
|
||||||
this( 0, 0, 0, Chrome.get( Chrome.Type.WINDOW ) );
|
this( 0, 0, Chrome.get( Chrome.Type.WINDOW ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window( int width, int height ) {
|
public Window( int width, int height ) {
|
||||||
this( width, height, 0, Chrome.get( Chrome.Type.WINDOW ) );
|
this( width, height, Chrome.get( Chrome.Type.WINDOW ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Window( int width, int height, NinePatch chrome ) {
|
public Window( int width, int height, NinePatch chrome ) {
|
||||||
this(width, height, 0, chrome);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Window( int width, int height, int yOffset, NinePatch chrome ) {
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.yOffset = yOffset;
|
|
||||||
|
|
||||||
blocker = new PointerArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
blocker = new PointerArea( 0, 0, PixelScene.uiCamera.width, PixelScene.uiCamera.height ) {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick( PointerEvent event ) {
|
protected void onClick( PointerEvent event ) {
|
||||||
|
@ -126,14 +121,21 @@ public class Window extends Group implements Signal.Listener<KeyEvent> {
|
||||||
height + chrome.marginVer() );
|
height + chrome.marginVer() );
|
||||||
|
|
||||||
camera.resize( (int)chrome.width, (int)chrome.height );
|
camera.resize( (int)chrome.width, (int)chrome.height );
|
||||||
|
|
||||||
camera.x = (int)(Game.width - camera.screenWidth()) / 2;
|
camera.x = (int)(Game.width - camera.screenWidth()) / 2;
|
||||||
|
camera.x += xOffset * camera.zoom;
|
||||||
|
|
||||||
camera.y = (int)(Game.height - camera.screenHeight()) / 2;
|
camera.y = (int)(Game.height - camera.screenHeight()) / 2;
|
||||||
camera.y += yOffset * camera.zoom;
|
camera.y += yOffset * camera.zoom;
|
||||||
|
|
||||||
shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
|
shadow.boxRect( camera.x / camera.zoom, camera.y / camera.zoom, chrome.width(), chrome.height );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void offset( int yOffset ){
|
public void offset( int xOffset, int yOffset ){
|
||||||
|
camera.x -= this.xOffset * camera.zoom;
|
||||||
|
this.xOffset = xOffset;
|
||||||
|
camera.x += xOffset * camera.zoom;
|
||||||
|
|
||||||
camera.y -= this.yOffset * camera.zoom;
|
camera.y -= this.yOffset * camera.zoom;
|
||||||
this.yOffset = yOffset;
|
this.yOffset = yOffset;
|
||||||
camera.y += yOffset * camera.zoom;
|
camera.y += yOffset * camera.zoom;
|
||||||
|
|
|
@ -40,9 +40,9 @@ public class WndTextInput extends Window {
|
||||||
//need to offset to give space for the soft keyboard
|
//need to offset to give space for the soft keyboard
|
||||||
if (!DeviceCompat.isDesktop()) {
|
if (!DeviceCompat.isDesktop()) {
|
||||||
if (PixelScene.landscape()) {
|
if (PixelScene.landscape()) {
|
||||||
offset(-45);
|
offset(0, -45);
|
||||||
} else {
|
} else {
|
||||||
offset(multiLine ? -60 : -45);
|
offset(0, multiLine ? -60 : -45);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class WndQuickBag extends Window {
|
||||||
private static Item bag;
|
private static Item bag;
|
||||||
|
|
||||||
public WndQuickBag(Bag bag){
|
public WndQuickBag(Bag bag){
|
||||||
super(0, 0, 0, Chrome.get(Chrome.Type.TOAST_TR));
|
super(0, 0, Chrome.get(Chrome.Type.TOAST_TR));
|
||||||
|
|
||||||
if( WndBag.INSTANCE != null ){
|
if( WndBag.INSTANCE != null ){
|
||||||
WndBag.INSTANCE.hide();
|
WndBag.INSTANCE.hide();
|
||||||
|
@ -156,7 +156,7 @@ public class WndQuickBag extends Window {
|
||||||
int bottom = GameScene.uiCamera.height;
|
int bottom = GameScene.uiCamera.height;
|
||||||
|
|
||||||
//offset to be above the toolbar
|
//offset to be above the toolbar
|
||||||
offset((int) (bottom/2 - 30 - height/2));
|
offset(0, (int) (bottom/2 - 30 - height/2));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -909,7 +909,7 @@ public class WndSettings extends WndTabbed {
|
||||||
index += 2;
|
index += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window credits = new Window(0, 0, 0, Chrome.get(Chrome.Type.TOAST));
|
Window credits = new Window(0, 0, Chrome.get(Chrome.Type.TOAST));
|
||||||
|
|
||||||
int w = PixelScene.landscape() ? 120 : 80;
|
int w = PixelScene.landscape() ? 120 : 80;
|
||||||
if (totalCredits >= 25) w *= 1.5f;
|
if (totalCredits >= 25) w *= 1.5f;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user