本文整理汇总了Java中net.minecraft.client.gui.FontRenderer.trimStringToWidth方法的典型用法代码示例。如果您正苦于以下问题:Java FontRenderer.trimStringToWidth方法的具体用法?Java FontRenderer.trimStringToWidth怎么用?Java FontRenderer.trimStringToWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.client.gui.FontRenderer
的用法示例。
在下文中一共展示了FontRenderer.trimStringToWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSlot
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
if(idx >= 0 && idx < channels.size())
{
FontRenderer font = this.parent.getFontRenderer();
TileEntityGlassMaster channel = channels.get(idx);
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 1F);
String info = (channel.setChannel.isEmpty() ? I18n.translateToLocal("glass.gui.notSet") : channel.setChannel.startsWith("public") ? I18n.translateToLocal("glass.gui.public") : "") + (!channel.setChannel.isEmpty() ? " " + channel.setChannel.substring(channel.setChannel.indexOf(":") + 1) : "");
info = info + " (" + channel.getPos().getX() + ", " + channel.getPos().getY() + ", " + channel.getPos().getZ() + ")";
String name = font.trimStringToWidth(info, (listWidth - 10) * 2);
font.drawString(name, (this.left + 2) * 2, top * 2, idx % 2 == 0 ? 0xFFFFFF : 0xAAAAAA);
GlStateManager.popMatrix();
}
}
示例2: drawSlot
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
if(idx >= 0 && idx < channels.size())
{
FontRenderer font = this.parent.getFontRenderer();
String channel = channels.get(idx);
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 1F);
String name = font.trimStringToWidth(channel.substring(channel.indexOf(":") + 1), (listWidth - 10) * 2);
if(channel.startsWith("public:"))
{
name = I18n.translateToLocal("glass.gui.public") + " " + name;
}
font.drawString(name, (this.left + 2) * 2, top * 2, idx % 2 == 0 ? 0xFFFFFF : 0xAAAAAA);
GlStateManager.popMatrix();
}
}
示例3: drawSlot
import net.minecraft.client.gui.FontRenderer; //导入方法依赖的package包/类
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
if(idx >= 0 && idx < tracks.size())
{
FontRenderer font = this.parent.getFontRenderer();
TrackFile track = tracks.get(idx);
GlStateManager.pushMatrix();
GlStateManager.scale(0.5F, 0.5F, 1F);
String trim = font.trimStringToWidth(track.track.getTitle(), (listWidth - 10) * 2);
if(isSelected(idx) && !track.track.getTitle().endsWith(trim))
{
int lengthDiff = (int)Math.ceil((track.track.getTitle().length() - trim.length()) * 1.4D);
String newString = track.track.getTitle().substring(lengthDiff);
int val = ((parent.scrollTicker % (lengthDiff * 2 + 40)) / 2) - 10;
if(val < 0)
{
val = 0;
}
String newTrim = font.trimStringToWidth(track.track.getTitle().substring(val), (listWidth - 10) * 2);
if(newString.length() > newTrim.length())
{
trim = newString;
}
else
{
trim = newTrim;
}
}
font.drawString(trim, (this.left + 2) * 2, top * 2, idx % 2 == 0 ? 0xFFFFFF : 0xAAAAAA);
GlStateManager.popMatrix();
}
}