Search in sources :

Example 1 with TextFieldEnder

use of com.enderio.core.client.gui.widget.TextFieldEnder in project EnderIO by SleepyTrousers.

the class GuiTelePad method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindGuiTexture();
    int sx = (width - xSize) / 2;
    int sy = (height - ySize) / 2;
    drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
    // draw power / fluid background
    int u = TelePadConfig.telepadFluidUse.get() > 0 ? 200 : 187;
    int v = 0;
    drawTexturedModalRect(sx + powerX - 1, sy + powerY - 1, u, v, 12, 122);
    if (TelePadConfig.telepadFluidUse.get() > 0 && te.getFluidAmount() > 0) {
        RenderUtil.renderGuiTank(te.getTank(), sx + fluidX, sy + fluidY, 0, 10, fluidScale);
        bindGuiTexture();
        drawTexturedModalRect(sx + fluidX, sy + fluidY, 213, v, 10, fluidScale);
    }
    int progressScaled = Util.getProgressScaled(progressScale, te);
    drawTexturedModalRect(sx + progressX, sy + progressY, 0, ySize, progressScaled, 10);
    FontRenderer fnt = getFontRenderer();
    String[] text = { "X", "Y", "Z", "DIM" };
    for (int i = 0; i < text.length; i++) {
        TextFieldEnder f = textFields.get(i);
        fnt.drawString(NullHelper.first(text[i]), f.x - (fnt.getStringWidth(NullHelper.first(text[i], "")) / 2) - 10, f.y + ((f.height - fnt.FONT_HEIGHT) / 2) + 1, 0x000000);
        if (!f.getCanLoseFocus()) {
            IconEIO.map.render(IconEIO.LOCK_LOCKED, f.x + f.width - 2, f.y - 2, true);
        }
    }
    Entity e = te.getCurrentTarget();
    if (e != null) {
        String name = e.getName();
        fnt.drawString(name, sx + xSize / 2 - fnt.getStringWidth(name) / 2, sy + progressY + fnt.FONT_HEIGHT + 6, 0x000000);
    } else if (te.wasBlocked()) {
        String s = Lang.GUI_TELEPAD_ERROR_BLOCKED.get();
        fnt.drawString(s, sx + xSize / 2 - fnt.getStringWidth(s) / 2, sy + progressY + fnt.FONT_HEIGHT + 6, 0xAA0000);
    }
    String name = te.getTarget().getName();
    fnt.drawStringWithShadow(name, sx + xSize / 2 - fnt.getStringWidth(name) / 2, getGuiTop() + 10, 0xffffff);
    super.drawGuiContainerBackgroundLayer(p_146976_1_, p_146976_2_, p_146976_3_);
}
Also used : Entity(net.minecraft.entity.Entity) FontRenderer(net.minecraft.client.gui.FontRenderer) TextFieldEnder(com.enderio.core.client.gui.widget.TextFieldEnder)

Example 2 with TextFieldEnder

use of com.enderio.core.client.gui.widget.TextFieldEnder in project EnderIO by SleepyTrousers.

the class GuiPowerMonitor method drawControls.

private void drawControls(int sx, int sy) {
    FontRenderer fr = getFontRenderer();
    int textColor = ColorUtil.getRGB(engineControlEnabled.isSelected() ? Color.black : Color.darkGray);
    int x0 = sx + TEXT_MARGIN_LEFT;
    int y0 = sy + TEXT_MARGIN_TOP;
    // Emit signal when storage less
    String engineTxt1 = Lang.GUI_POWER_MONITOR_ENGINE_1.get().trim();
    // than
    String engineTxt2 = Lang.GUI_POWER_MONITOR_ENGINE_2.get().trim();
    // % full.
    String engineTxt3 = Lang.GUI_POWER_MONITOR_ENGINE_3.get().trim();
    // Stop when storage greater than
    String engineTxt4 = Lang.GUI_POWER_MONITOR_ENGINE_4.get().trim();
    // or equal to
    String engineTxt5 = Lang.GUI_POWER_MONITOR_ENGINE_5.get().trim();
    List<Object> elems = new ArrayList<Object>();
    elems.add(engineControlEnabled);
    elems.addAll(Arrays.asList(engineTxt1.split("(\\s+)")));
    elems.addAll(Arrays.asList(engineTxt2.split("(\\s+)")));
    elems.add(engineControlStart);
    elems.addAll(Arrays.asList(engineTxt3.split("(\\s+)")));
    elems.addAll(Arrays.asList(engineTxt4.split("(\\s+)")));
    elems.addAll(Arrays.asList(engineTxt5.split("(\\s+)")));
    elems.add(engineControlStop);
    elems.addAll(Arrays.asList(engineTxt3.split("(\\s+)")));
    int x = 0, y = 0;
    for (Object elem : elems) {
        int elemWidth = 0;
        if (elem instanceof String) {
            elemWidth = fr.getStringWidth((String) elem);
        } else if (elem instanceof CheckBox) {
            elemWidth = ((CheckBox) elem).width;
        } else if (elem instanceof TextFieldEnder) {
            elemWidth = ((TextFieldEnder) elem).width;
        }
        if (x + elemWidth > TEXT_WIDTH) {
            x = 0;
            y += CONTROL_LF_PX;
            if (" ".equals(elem)) {
                continue;
            }
        }
        if (elem instanceof String) {
            fr.drawString((String) elem, x0 + x, y0 + y + TEXT_Y_OFFSET, textColor);
        } else if (elem instanceof CheckBox) {
            ((CheckBox) elem).x = x0 + x;
            ((CheckBox) elem).y = y0 + y;
        } else if (elem instanceof TextFieldEnder) {
            ((TextFieldEnder) elem).x = x0 + x;
            ((TextFieldEnder) elem).y = y0 + y;
        }
        x += elemWidth + fr.getStringWidth(" ");
    }
}
Also used : CheckBox(com.enderio.core.client.gui.button.CheckBox) ArrayList(java.util.ArrayList) PowerToolObject(crazypants.enderio.powertools.init.PowerToolObject) ConduitObject(crazypants.enderio.conduits.init.ConduitObject) FontRenderer(net.minecraft.client.gui.FontRenderer) TextFieldEnder(com.enderio.core.client.gui.widget.TextFieldEnder)

Aggregations

TextFieldEnder (com.enderio.core.client.gui.widget.TextFieldEnder)2 FontRenderer (net.minecraft.client.gui.FontRenderer)2 CheckBox (com.enderio.core.client.gui.button.CheckBox)1 ConduitObject (crazypants.enderio.conduits.init.ConduitObject)1 PowerToolObject (crazypants.enderio.powertools.init.PowerToolObject)1 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.entity.Entity)1