Search in sources :

Example 1 with TubeModuleRedstoneReceiving

use of me.desht.pneumaticcraft.common.block.tubes.TubeModuleRedstoneReceiving in project pnc-repressurized by TeamPneumatic.

the class GuiPressureModule method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    super.drawScreen(mouseX, mouseY, partialTicks);
    GL11.glDisable(GL11.GL_LIGHTING);
    if (!lowerBoundField.isFocused())
        lowerBoundField.setText(PneumaticCraftUtils.roundNumberTo(module.lowerBound, 1));
    if (!higherBoundField.isFocused())
        higherBoundField.setText(PneumaticCraftUtils.roundNumberTo(module.higherBound, 1));
    FMLClientHandler.instance().getClient().getTextureManager().bindTexture(getTexture());
    int scrollbarLowerBoundX = (int) (guiLeft + 16 + (158 - 11) * (module.lowerBound / (module.maxValue + 1)));
    int scrollbarHigherBoundX = (int) (guiLeft + 16 + (158 - 11) * (module.higherBound / (module.maxValue + 1)));
    if (!Mouse.isButtonDown(0))
        waitTillRelease = false;
    if (!waitTillRelease && Mouse.isButtonDown(0)) {
        if (new Rectangle(guiLeft + 11, guiTop + 59, 158, 15).contains(mouseX, mouseY)) {
            module.higherBound = (float) (mouseX - 6 - (guiLeft + 11)) / (158 - 11) * module.maxValue;
            if (module.higherBound < -1)
                module.higherBound = -1;
            if (module.higherBound > module.maxValue)
                module.higherBound = module.maxValue;
            // higherBoundField.setText(PneumaticCraftUtils.roundNumberTo(module.higherBound, 1));
            NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 1, module.higherBound));
        } else if (new Rectangle(guiLeft + 11, guiTop + 73, 158, 15).contains(mouseX, mouseY)) {
            module.lowerBound = (float) (mouseX - 6 - (guiLeft + 11)) / (158 - 11) * module.maxValue;
            if (module.lowerBound < -1)
                module.lowerBound = -1;
            if (module.lowerBound > module.maxValue)
                module.lowerBound = module.maxValue;
            // lowerBoundField.setText(PneumaticCraftUtils.roundNumberTo(module.lowerBound, 1));
            NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 0, module.lowerBound));
        }
    }
    drawTexturedModalRect(scrollbarLowerBoundX, guiTop + 73, 183, 0, 15, 12);
    drawTexturedModalRect(scrollbarHigherBoundX, guiTop + 59, 183, 0, 15, 12);
    lowerBoundField.drawTextBox();
    higherBoundField.drawTextBox();
    /*
         * Draw graph
         */
    drawVerticalLine(graphLeft, graphHighY, graphLowY, 0xFF000000);
    for (int i = 0; i < 16; i++) {
        boolean longer = i % 5 == 0;
        if (longer) {
            fontRenderer.drawString(i + "", graphLeft - 5 - fontRenderer.getStringWidth(i + ""), graphHighY + (graphLowY - graphHighY) * (15 - i) / 15 - 3, 0xFF000000);
            drawHorizontalLine(graphLeft + 4, graphRight, graphHighY + (graphLowY - graphHighY) * (15 - i) / 15, i == 0 ? 0xFF000000 : 0x33000000);
        }
        drawHorizontalLine(graphLeft - (longer ? 5 : 3), graphLeft + 3, graphHighY + (graphLowY - graphHighY) * (15 - i) / 15, 0xFF000000);
    }
    for (int i = 0; i < 31; i++) {
        boolean longer = i % 5 == 0;
        if (longer) {
            fontRenderer.drawString(i + "", graphLeft + (graphRight - graphLeft) * i / 30 - fontRenderer.getStringWidth(i + "") / 2 + 1, graphLowY + 6, 0xFF000000);
            drawVerticalLine(graphLeft + (graphRight - graphLeft) * i / 30, graphHighY, graphLowY - 2, 0x33000000);
        }
        drawVerticalLine(graphLeft + (graphRight - graphLeft) * i / 30, graphLowY - 3, graphLowY + (longer ? 5 : 3), 0xFF000000);
    }
    if (module instanceof TubeModuleRedstoneReceiving) {
        module.onNeighborBlockUpdate();
        drawHorizontalLine(graphLeft + 4, graphRight, graphHighY + (graphLowY - graphHighY) * (15 - ((TubeModuleRedstoneReceiving) module).getReceivingRedstoneLevel()) / 15, 0xFFFF0000);
        String status = "Current threshold: " + PneumaticCraftUtils.roundNumberTo(((TubeModuleRedstoneReceiving) module).getThreshold(), 1) + " bar";
        fontRenderer.drawString(status, guiLeft + xSize / 2 - fontRenderer.getStringWidth(status) / 2, guiTop + 173, 0xFF000000);
    }
    /*
         * Draw the data in the graph 
         */
    BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
    bufferBuilder.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.disableTexture2D();
    GlStateManager.color(0, 0, 0, 1.0f);
    for (int i = 0; i < 16; i++) {
        double y = graphHighY + (graphLowY - graphHighY) * (15 - i) / 15;
        double x = graphLeft + (graphRight - graphLeft) * module.getThreshold(i) / 30;
        bufferBuilder.pos(x, y, 90.0d).color(0.25f + i * 0.05f, 0f, 0f, 1.0f).endVertex();
    }
    Tessellator.getInstance().draw();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
}
Also used : PacketUpdatePressureModule(me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule) TubeModuleRedstoneReceiving(me.desht.pneumaticcraft.common.block.tubes.TubeModuleRedstoneReceiving) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 2 with TubeModuleRedstoneReceiving

use of me.desht.pneumaticcraft.common.block.tubes.TubeModuleRedstoneReceiving in project pnc-repressurized by TeamPneumatic.

the class GuiPressureModuleSimple method initGui.

@Override
public void initGui() {
    super.initGui();
    String title = I18n.format("item." + module.getType() + ".name");
    addLabel(title, width / 2 - fontRenderer.getStringWidth(title) / 2, guiTop + 5);
    advancedMode = new GuiCheckBox(0, guiLeft + 6, guiTop + 15, 0xFF404040, "gui.tubeModule.advancedConfig").setTooltip(I18n.format("gui.tubeModule.advancedConfig.tooltip"));
    advancedMode.checked = false;
    addWidget(advancedMode);
    thresholdField = new WidgetTextFieldNumber(fontRenderer, guiLeft + 110, guiTop + 33, 30, fontRenderer.FONT_HEIGHT).setDecimals(1);
    addWidget(thresholdField);
    if (module instanceof TubeModuleRedstoneReceiving) {
        thresholdField.setValue(((TubeModuleRedstoneReceiving) module).getThreshold());
        addLabel(I18n.format("gui.tubeModule.simpleConfig.threshold"), guiLeft + 6, guiTop + 33);
    } else {
        thresholdField.setValue(module.lowerBound);
        addLabel(I18n.format("gui.tubeModule.simpleConfig.turn"), guiLeft + 6, guiTop + 33);
        moreOrLessButton = new GuiButtonSpecial(1, guiLeft + 85, guiTop + 28, 20, 20, module.lowerBound < module.higherBound ? ">" : "<");
        moreOrLessButton.setTooltipText(I18n.format(module.lowerBound < module.higherBound ? "gui.tubeModule.simpleConfig.higherThan" : "gui.tubeModule.simpleConfig.lowerThan"));
        addWidget(moreOrLessButton);
    }
    addLabel(I18n.format("gui.general.bar"), guiLeft + 145, guiTop + 34);
}
Also used : WidgetTextFieldNumber(me.desht.pneumaticcraft.client.gui.widget.WidgetTextFieldNumber) TubeModuleRedstoneReceiving(me.desht.pneumaticcraft.common.block.tubes.TubeModuleRedstoneReceiving) GuiCheckBox(me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox) GuiButtonSpecial(me.desht.pneumaticcraft.client.gui.GuiButtonSpecial)

Aggregations

TubeModuleRedstoneReceiving (me.desht.pneumaticcraft.common.block.tubes.TubeModuleRedstoneReceiving)2 GuiButtonSpecial (me.desht.pneumaticcraft.client.gui.GuiButtonSpecial)1 GuiCheckBox (me.desht.pneumaticcraft.client.gui.widget.GuiCheckBox)1 WidgetTextFieldNumber (me.desht.pneumaticcraft.client.gui.widget.WidgetTextFieldNumber)1 PacketUpdatePressureModule (me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule)1 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)1