OptionButton: Add Tooltip to long prefix

This commit is contained in:
slprime committed 2022-08-15 22:19:38 +03:00
1 parent 4054ea04f3
commit 3f31d7d53a
3 files changed
+51 -25

No files matched your search

@@ -312,7 +312,7 @@ public class PresetsWidget extends Widget {
final int directionState = direction.contains(x + mx, y + my) ? 1 : 2;
final int deleteState = delete.contains(x + mx, y + my) ? 1 : 2;
final String displayName = cropText(tag.displayName, option.w - 6);
final String displayName = NEIClientUtils.cropText(fontRenderer, tag.displayName, option.w - 6);
final String dirName =
tag.whitelist ? translate("presets.whitelist.label") : translate("presets.blacklist.label");
@@ -456,7 +456,7 @@ public class PresetsWidget extends Widget {
@Override
public void draw(int mousex, int mousey) {
final String text = cropText(this.text, w);
final String text = NEIClientUtils.cropText(fontRenderer, this.text, w);
if (text.equals(this.text)) {
GuiDraw.drawString(text, x + w - fontRenderer.getStringWidth(text), y + (h - 8) / 2, colour);
@@ -535,24 +535,6 @@ public class PresetsWidget extends Widget {
}
};
protected static String cropText(String text, int containerWidth) {
int textWidth = fontRenderer.getStringWidth(text);
if (textWidth > containerWidth) {
textWidth += fontRenderer.getStringWidth("...");
while (textWidth > containerWidth) {
textWidth -= fontRenderer.getCharWidth(text.charAt(text.length() - 1));
text = text.substring(0, text.length() - 1);
}
return text + "...";
}
return text;
}
protected static void setEditedTag(final PresetTag tag) {
edit = tag;
openListBox = false;