From 8e47b27507ef7768b4f92c43f12bf7429677e5cf Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 31 Oct 2025 13:20:24 -0400 Subject: [PATCH] v3.3.0: various layout tweaks for long translations: - text in wndOptions buttons can now render on 2 lines if needed - stat slot text can now better dynamically resize - setting checkbox text can now resize dynamically --- .../shatteredpixeldungeon/ui/CheckBox.java | 11 +++++++++ .../ui/OptionSlider.java | 2 +- .../windows/WndGameInProgress.java | 21 +++++++++++------ .../windows/WndHero.java | 23 ++++++++++++------- .../windows/WndOptions.java | 1 + .../windows/WndRanking.java | 23 ++++++++++++------- 6 files changed, 57 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CheckBox.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CheckBox.java index 100756d67..346383d59 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CheckBox.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/CheckBox.java @@ -47,6 +47,17 @@ public class CheckBox extends RedButton { icon.x = x + width - margin - icon.width; icon.y = y + margin; PixelScene.align(icon); + + int size = 9; + while (width > 0 && text.right() > icon.x){ + size--; + remove(text); + text = PixelScene.renderTextBlock(text.text, size); + margin = (height - text.height()) / 2; + text.setPos( x + margin, y + margin); + PixelScene.align(text); + add(text); + } } public boolean checked() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java index 81c5d12dc..0354a6af3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java @@ -144,7 +144,7 @@ public abstract class OptionSlider extends Component { @Override protected void layout() { - if (title.width() > 0.7f*width){ + if (title.width() > 0.6f*width){ String titleText = title.text; remove(title); title = PixelScene.renderTextBlock(6); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java index c27d389a5..dc7aefa3b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGameInProgress.java @@ -161,15 +161,22 @@ public class WndGameInProgress extends Window { } private void statSlot( String label, String value ) { - - RenderedTextBlock txt = PixelScene.renderTextBlock( label, 8 ); - txt.setPos(0, pos); - add( txt ); int size = 8; - if (value.length() >= 14) size -=2; - if (value.length() >= 18) size -=1; - txt = PixelScene.renderTextBlock( value, size ); + RenderedTextBlock txt; + do { + txt = PixelScene.renderTextBlock( label, size ); + size--; + } while (txt.width() >= WIDTH * 0.55f); + txt.setPos(0, pos + (6 - txt.height())/2); + PixelScene.align(txt); + add( txt ); + + size = 8; + do { + txt = PixelScene.renderTextBlock( value, size ); + size--; + } while (txt.width() >= WIDTH * 0.45f); txt.setPos(WIDTH * 0.55f, pos + (6 - txt.height())/2); PixelScene.align(txt); add( txt ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java index debf9137c..ffbda9709 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java @@ -214,16 +214,23 @@ public class WndHero extends WndTabbed { } private void statSlot( String label, String value ) { - - RenderedTextBlock txt = PixelScene.renderTextBlock( label, 8 ); - txt.setPos(0, pos); - add( txt ); int size = 8; - if (value.length() >= 14) size -=2; - if (value.length() >= 18) size -=1; - txt = PixelScene.renderTextBlock( value, size ); - txt.setPos(WIDTH * 0.55f, pos); + RenderedTextBlock txt; + do { + txt = PixelScene.renderTextBlock( label, size ); + size--; + } while (txt.width() >= WIDTH * 0.55f); + txt.setPos(0, pos + (6 - txt.height())/2); + PixelScene.align(txt); + add( txt ); + + size = 8; + do { + txt = PixelScene.renderTextBlock( value, size ); + size--; + } while (txt.width() >= WIDTH * 0.45f); + txt.setPos(WIDTH * 0.55f, pos + (6 - txt.height())/2); PixelScene.align(txt); add( txt ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java index 540ec808f..65084e93b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java @@ -93,6 +93,7 @@ public class WndOptions extends Window { } }; if (hasIcon(i)) btn.icon(getIcon(i)); + btn.multiline = true; btn.enable(enabled(i)); add( btn ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java index 6bb8ec007..f3332c235 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndRanking.java @@ -297,16 +297,23 @@ public class WndRanking extends WndTabbed { } private float statSlot( Group parent, String label, String value, float pos ) { - - RenderedTextBlock txt = PixelScene.renderTextBlock( label, 7 ); - txt.setPos(0, pos); - parent.add( txt ); int size = 7; - if (value.length() >= 14) size -=1; - if (value.length() >= 18) size -=1; - txt = PixelScene.renderTextBlock( value, size ); - txt.setPos(WIDTH * 0.55f, pos); + RenderedTextBlock txt; + do { + txt = PixelScene.renderTextBlock( label, size ); + size--; + } while (txt.width() >= WIDTH * 0.55f); + txt.setPos(0, pos + (6 - txt.height())/2); + PixelScene.align(txt); + parent.add( txt ); + + size = 7; + do { + txt = PixelScene.renderTextBlock( value, size ); + size--; + } while (txt.width() >= WIDTH * 0.45f); + txt.setPos(WIDTH * 0.55f, pos + (6 - txt.height())/2); PixelScene.align(txt); parent.add( txt );