當前位置: 首頁>>代碼示例>>Java>>正文


Java FontRenderer.trimStringToWidth方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:iChun,項目名稱:GeneralLaymansAestheticSpyingScreen,代碼行數:17,代碼來源:GuiProjectorList.java

示例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();
    }
}
 
開發者ID:iChun,項目名稱:GeneralLaymansAestheticSpyingScreen,代碼行數:19,代碼來源:GuiChannelList.java

示例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();
    }
}
 
開發者ID:iChun,項目名稱:Clef,代碼行數:34,代碼來源:GuiTrackList.java


注:本文中的net.minecraft.client.gui.FontRenderer.trimStringToWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。