本文整理匯總了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();
}
}