diff options
| author | shedaniel <daniel@shedaniel.me> | 2019-12-15 12:45:55 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2019-12-15 12:45:55 +0800 |
| commit | fca848e6b4e5e78bd2bec39f5fa91be18d6316b3 (patch) | |
| tree | 552a8a9db0d0a5738c4607c2a424274b7be5d5de /src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java | |
| parent | 0bb99e56a3c00550d79d4966e4f3768b43e24a9b (diff) | |
| download | RoughlyEnoughItems-fca848e6b4e5e78bd2bec39f5fa91be18d6316b3.tar.gz RoughlyEnoughItems-fca848e6b4e5e78bd2bec39f5fa91be18d6316b3.tar.bz2 RoughlyEnoughItems-fca848e6b4e5e78bd2bec39f5fa91be18d6316b3.zip | |
more work on favorites
Diffstat (limited to 'src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java index 6edb9b004..b2a92b95c 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/LabelWidget.java @@ -45,6 +45,11 @@ public class LabelWidget extends WidgetWithBounds { return this; } + public LabelWidget leftAligned() { + setCentered(false); + return this; + } + public boolean isHasShadows() { return hasShadows; } @@ -93,7 +98,9 @@ public class LabelWidget extends WidgetWithBounds { public Rectangle getBounds() { int width = font.getStringWidth(text); Point pos = getPosition(); - return new Rectangle(pos.x - width / 2 - 1, pos.y - 5, width + 2, 14); + if (isCentered()) + return new Rectangle(pos.x - width / 2 - 1, pos.y - 5, width + 2, 14); + return new Rectangle(pos.x - 1, pos.y - 5, width + 2, 14); } @Override @@ -105,9 +112,15 @@ public class LabelWidget extends WidgetWithBounds { public void render(int mouseX, int mouseY, float delta) { int width = font.getStringWidth(text); Point pos = getPosition(); - if (hasShadows) - font.drawWithShadow(text, pos.x - width / 2, pos.y, defaultColor); - else font.draw(text, pos.x - width / 2, pos.y, defaultColor); + if (isCentered()) { + if (hasShadows) + font.drawWithShadow(text, pos.x - width / 2, pos.y, defaultColor); + else font.draw(text, pos.x - width / 2, pos.y, defaultColor); + } else { + if (hasShadows) + font.drawWithShadow(text, pos.x, pos.y, defaultColor); + else font.draw(text, pos.x, pos.y, defaultColor); + } } } |
