Search in sources :

Example 1 with IGuiResource

use of com.teampolymer.polymer.core.client.resources.IGuiResource in project polymer-core by teampolymer.

the class SchematicViewOverlay method renderOverlay.

public void renderOverlay(MatrixStack ms, float pt) {
    Minecraft mc = Minecraft.getInstance();
    MainWindow mainWindow = mc.getWindow();
    if (!initialized)
        init(mc, mainWindow.getGuiScaledWidth(), mainWindow.getGuiScaledHeight());
    int x = (mainWindow.getGuiScaledWidth() - w) / 2 + 15;
    int y = mainWindow.getGuiScaledHeight() - h - 75;
    ms.pushPose();
    ms.translate(0, -yOffset, focused ? 100 : 0);
    IGuiResource gray = GuiResources.TOOLBAR_BACKGROUND;
    RenderSystem.enableBlend();
    RenderSystem.defaultBlendFunc();
    RenderSystem.color4f(1, 1, 1, focused ? 3 / 4f : .3f);
    Minecraft.getInstance().getTextureManager().bind(gray.getLocation());
    blit(ms, x - 15, y, gray.getStartX(), gray.getStartY(), w, h, gray.getWidth(), gray.getHeight());
    float toolTipAlpha = yOffset / 10;
    List<ITextComponent> toolTip = currentAction().getDescription();
    int stringAlphaComponent = ((int) (toolTipAlpha * 0xFF)) << 24;
    if (toolTipAlpha > 0.25f) {
        int height = h + 22 + 10 * (toolTip.size() - 1);
        boolean disabled = !currentAction().isEnabled();
        if (disabled) {
            height += 12;
        }
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(.7f, .7f, .8f, toolTipAlpha);
        blit(ms, x - 15, y, gray.getStartX(), gray.getStartY(), w, height, gray.getWidth(), gray.getHeight());
        RenderSystem.color4f(1, 1, 1, 1);
        RenderSystem.disableBlend();
        int yOff = y;
        if (toolTip.size() > 0) {
            yOff += 38;
            font.draw(ms, toolTip.get(0), x - 10, yOff, 0xEEEEEE + stringAlphaComponent);
        }
        if (toolTip.size() > 1) {
            yOff += 12;
            font.draw(ms, toolTip.get(1), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (toolTip.size() > 2) {
            yOff += 10;
            font.draw(ms, toolTip.get(2), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (toolTip.size() > 3) {
            yOff += 10;
            font.draw(ms, toolTip.get(3), x - 10, yOff, 0xCCDDFF + stringAlphaComponent);
        }
        if (disabled) {
            yOff += 12;
            font.draw(ms, new TranslationTextComponent("gui.polymer.locator.control.misc.disabled"), x - 10, yOff, 0xCCCCDD + stringAlphaComponent);
        }
    }
    RenderSystem.color4f(1, 1, 1, 1);
    if (actions.length > 1) {
        String keyName = KeysRegistry.TOOL_CTRL_KEY.getTranslatedKeyMessage().getString().toUpperCase(Locale.ROOT);
        int width = minecraft.getWindow().getGuiScaledWidth();
        if (!focused)
            drawCenteredString(ms, font, I18n.get(holdToFocus, keyName), width / 2, y - 10, 0xCCDDFF);
        else
            drawCenteredString(ms, font, scrollToCycle, width / 2, y - 10, 0xCCDDFF);
    } else {
        x += 65;
    }
    for (int i = 0; i < actions.length; i++) {
        ms.pushPose();
        float alpha = focused ? 1 : .2f;
        if (i == current) {
            ms.translate(0, -10, 0);
            drawCenteredString(ms, font, actions[i].getName(), x + i * 40 + 24, y + 28, 0xCCDDFF);
            alpha = 1;
        }
        IGuiResource icon = actions[i].getIcon();
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(0, 0, 0, alpha * .2f);
        icon.draw(ms, 0, x + i * 40 + 17, y + 12);
        if (actions[i].isEnabled()) {
            RenderSystem.color4f(1, 1, 1, alpha);
        } else {
            RenderSystem.color4f(.7f, .7f, .7f, alpha);
        }
        icon.draw(ms, 0, x + i * 40 + 16, y + 11);
        ms.popPose();
    }
    RenderSystem.disableBlend();
    RenderSystem.defaultBlendFunc();
    ms.popPose();
}
Also used : MainWindow(net.minecraft.client.MainWindow) ITextComponent(net.minecraft.util.text.ITextComponent) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Minecraft(net.minecraft.client.Minecraft) IGuiResource(com.teampolymer.polymer.core.client.resources.IGuiResource)

Aggregations

IGuiResource (com.teampolymer.polymer.core.client.resources.IGuiResource)1 MainWindow (net.minecraft.client.MainWindow)1 Minecraft (net.minecraft.client.Minecraft)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)1