use of me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule 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();
}
use of me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule in project pnc-repressurized by TeamPneumatic.
the class GuiPressureModule method mouseClicked.
@Override
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
super.mouseClicked(par1, par2, par3);
boolean wasFocused = lowerBoundField.isFocused();
lowerBoundField.mouseClicked(par1, par2, par3);
if (wasFocused && !lowerBoundField.isFocused()) {
try {
module.lowerBound = Float.parseFloat(lowerBoundField.getText());
if (module.lowerBound < -1)
module.lowerBound = -1;
if (module.lowerBound > 30)
module.lowerBound = 30;
// lowerBoundField.setText(module.lowerBound + "");
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 0, module.lowerBound));
} catch (Exception e) {
}
}
wasFocused = higherBoundField.isFocused();
higherBoundField.mouseClicked(par1, par2, par3);
if (wasFocused && !higherBoundField.isFocused()) {
try {
module.higherBound = Float.parseFloat(higherBoundField.getText());
if (module.higherBound < -1)
module.higherBound = -1;
if (module.higherBound > 30)
module.higherBound = 30;
// higherBoundField.setText(module.higherBound + "");
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 1, module.higherBound));
} catch (Exception e) {
}
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule in project pnc-repressurized by TeamPneumatic.
the class GuiPressureModule method actionPerformed.
@Override
public void actionPerformed(IGuiWidget widget) {
super.actionPerformed(widget);
if (widget.getID() == 0) {
module.advancedConfig = ((GuiCheckBox) widget).checked;
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 2, module.advancedConfig ? 1 : 0));
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule in project pnc-repressurized by TeamPneumatic.
the class GuiPressureModuleSimple method actionPerformed.
@Override
public void actionPerformed(IGuiWidget widget) {
super.actionPerformed(widget);
switch(widget.getID()) {
case 0:
// ((GuiCheckBox)widget).checked;
module.advancedConfig = true;
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 2, module.advancedConfig ? 1 : 0));
// initGui();
break;
case 1:
if (module.lowerBound < module.higherBound) {
module.higherBound = module.lowerBound - 0.1F;
} else {
module.higherBound = module.lowerBound + 0.1F;
}
moreOrLessButton.displayString = module.lowerBound < module.higherBound ? ">" : "<";
moreOrLessButton.setTooltipText(I18n.format(module.lowerBound < module.higherBound ? "gui.tubeModule.simpleConfig.higherThan" : "gui.tubeModule.simpleConfig.lowerThan"));
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 1, module.higherBound));
break;
}
}
use of me.desht.pneumaticcraft.common.network.PacketUpdatePressureModule in project pnc-repressurized by TeamPneumatic.
the class GuiPressureModuleSimple method onGuiClosed.
@Override
public void onGuiClosed() {
NetworkHandler.sendToServer(new PacketUpdatePressureModule(module, 0, (float) thresholdField.getDoubleValue()));
super.onGuiClosed();
}
Aggregations