Fixed device names overflowing Controller GUI

This commit is contained in:
raoulvdberge
2017-10-02 22:35:21 +02:00
parent 7572d3c0f3
commit 171d30c434
2 changed files with 11 additions and 2 deletions

View File

@@ -2,8 +2,9 @@
### 1.5.19 ### 1.5.19
- Updated Forge to 2493 (MC 1.12.2) (raoulvdberge) - Updated Forge to 2493 (MC 1.12.2) (raoulvdberge)
- Fixed RS blocks requiring a pickaxe to be broken (raoulvdberge) - Fixed Refined Storage blocks requiring a pickaxe to be broken (raoulvdberge)
- Fixed Grid GUI crash (raoulvdberge) - Fixed Grid GUI crash (raoulvdberge)
- Fixed device names overflowing Controller GUI (raoulvdberge)
### 1.5.18 ### 1.5.18
- Added Project E integration for the External Storage on the Transmutation Table (raoulvdberge) - Added Project E integration for the External Storage on the Transmutation Table (raoulvdberge)

View File

@@ -79,7 +79,7 @@ public class GuiController extends GuiBase {
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.scale(scale, scale, 1); GlStateManager.scale(scale, scale, 1);
drawString(RenderUtils.getOffsetOnScale(x + 1, scale), RenderUtils.getOffsetOnScale(y - 2, scale), node.getStack().getDisplayName()); drawString(RenderUtils.getOffsetOnScale(x + 1, scale), RenderUtils.getOffsetOnScale(y - 2, scale), trimNameIfNeeded(!fontRenderer.getUnicodeFlag(), node.getStack().getDisplayName()));
drawString(RenderUtils.getOffsetOnScale(x + 21, scale), RenderUtils.getOffsetOnScale(y + 10, scale), node.getAmount() + "x"); drawString(RenderUtils.getOffsetOnScale(x + 21, scale), RenderUtils.getOffsetOnScale(y + 10, scale), node.getAmount() + "x");
GlStateManager.popMatrix(); GlStateManager.popMatrix();
@@ -111,4 +111,12 @@ public class GuiController extends GuiBase {
private int getRows() { private int getRows() {
return Math.max(0, (int) Math.ceil((float) TileController.NODES.getValue().size() / 2F)); return Math.max(0, (int) Math.ceil((float) TileController.NODES.getValue().size() / 2F));
} }
private String trimNameIfNeeded(boolean scaled, String name) {
int max = scaled ? 20 : 13;
if (name.length() > max) {
name = name.substring(0, max) + "...";
}
return name;
}
} }