v3.2.3: improved bottom inset handling in hero select and inter level

This commit is contained in:
Evan Debenham
2025-08-31 15:10:31 -04:00
parent be0c65b35f
commit b9133439bd
2 changed files with 21 additions and 15 deletions

View File

@@ -100,8 +100,8 @@ public class HeroSelectScene extends PixelScene {
insets = Game.platform.getSafeInsets(PlatformSupport.INSET_BLK).scale(1f/defaultZoom); insets = Game.platform.getSafeInsets(PlatformSupport.INSET_BLK).scale(1f/defaultZoom);
int w = (int)(Camera.main.width - insets.left - insets.right); float w = (Camera.main.width - insets.left - insets.right);
int h = (int)(Camera.main.height - insets.top - insets.bottom); float h = (Camera.main.height - insets.top - insets.bottom);
background = new Image(TextureCache.createSolid(0xFF2d2f31), 0, 0, 800, 450){ background = new Image(TextureCache.createSolid(0xFF2d2f31), 0, 0, 800, 450){
@Override @Override
@@ -116,10 +116,10 @@ public class HeroSelectScene extends PixelScene {
} }
} }
}; };
background.scale.set(h/background.height); background.scale.set(Camera.main.height/background.height);
background.x = insets.left + (w - background.width())/2f; background.x = (Camera.main.width - background.width())/2f;
background.y = insets.top + (h - background.height())/2f; background.y = (Camera.main.height - background.height())/2f;
PixelScene.align(background); PixelScene.align(background);
add(background); add(background);
@@ -169,7 +169,7 @@ public class HeroSelectScene extends PixelScene {
if (cls != null) { if (cls != null) {
Window info = new WndHeroInfo(GamesInProgress.selectedClass); Window info = new WndHeroInfo(GamesInProgress.selectedClass);
if (landscape()) { if (landscape()) {
info.offset(w / 6, 0); info.offset((int)(w / 6), 0);
} }
ShatteredPixelDungeon.scene().addToFront(info); ShatteredPixelDungeon.scene().addToFront(info);
} }
@@ -327,13 +327,13 @@ public class HeroSelectScene extends PixelScene {
float curY = insets.top + h - HeroBtn.HEIGHT + 3; float curY = insets.top + h - HeroBtn.HEIGHT + 3;
for (StyledButton button : heroBtns) { for (StyledButton button : heroBtns) {
button.setRect(curX, curY, btnWidth, HeroBtn.HEIGHT); button.setRect(curX, curY, btnWidth, HeroBtn.HEIGHT + insets.bottom);
curX += btnWidth; curX += btnWidth;
} }
//add a black bar along bottom //add a darkening bar along bottom
if (insets.bottom > 0){ if (insets.bottom > 0){
SkinnedBlock bar = new SkinnedBlock(Camera.main.width, insets.bottom, TextureCache.createSolid(0xFF000000)); SkinnedBlock bar = new SkinnedBlock(Camera.main.width, insets.bottom, TextureCache.createSolid(0xAA000000));
bar.y = h + insets.top; bar.y = h + insets.top;
add(bar); add(bar);
} }
@@ -596,6 +596,12 @@ public class HeroSelectScene extends PixelScene {
setSelectedHero(cl); setSelectedHero(cl);
} }
} }
@Override
protected void layout() {
super.layout();
icon.y = y + (HEIGHT - icon.height()) / 2f;
}
} }
private class GameOptions extends Component { private class GameOptions extends Component {

View File

@@ -220,15 +220,15 @@ public class InterlevelScene extends PixelScene {
int h = (int)(Camera.main.height - insets.top - insets.bottom); int h = (int)(Camera.main.height - insets.top - insets.bottom);
background = new Image(loadingAsset); background = new Image(loadingAsset);
background.scale.set(h/background.height); background.scale.set(Camera.main.height/background.height);
if (w >= background.width()){ if (Camera.main.width >= background.width()){
background.x = insets.left + (w - background.width())/2f; background.x = (Camera.main.width - background.width())/2f;
} else { } else {
background.x = insets.left + w/2f - loadingCenter*background.scale.x; background.x = Camera.main.width/2f - loadingCenter*background.scale.x;
background.x = GameMath.gate(w - background.width(), background.x, 0); background.x = GameMath.gate(Camera.main.width - background.width(), background.x, 0);
} }
background.y = insets.top + (h - background.height())/2f; background.y = (Camera.main.height - background.height())/2f;
PixelScene.align(background); PixelScene.align(background);
add(background); add(background);