Search in sources :

Example 1 with TrackingTask

use of logisticspipes.blocks.stats.TrackingTask in project LogisticsPipes by RS485.

the class GuiStatistics method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouse_x, int mouse_y) {
    GL11.glColor4d(1.0D, 1.0D, 1.0D, 1.0D);
    for (int i = 0; i < TAB_COUNT; i++) {
        GuiGraphics.drawGuiBackGround(mc, guiLeft + (25 * i) + 2, guiTop - 2, guiLeft + 27 + (25 * i), guiTop + 35, zLevel, false, true, true, false, true);
    }
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop + 20, right, bottom, zLevel, true);
    GuiGraphics.drawGuiBackGround(mc, guiLeft + (25 * current_Tab) + 2, guiTop - 2, guiLeft + 27 + (25 * current_Tab), guiTop + 38, zLevel, true, true, true, false, true);
    // First Tab
    GuiGraphics.drawStatsBackground(mc, guiLeft + 6, guiTop + 3);
    // Second Tab
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    RenderHelper.enableGUIStandardItemLighting();
    ItemStack stack = new ItemStack(Blocks.crafting_table, 0);
    GuiScreen.itemRender.renderItemAndEffectIntoGUI(fontRendererObj, getMC().renderEngine, stack, guiLeft + 31, guiTop + 3);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GuiScreen.itemRender.zLevel = 0.0F;
    if (current_Tab == 0) {
        itemDisplay_1.renderItemArea(zLevel);
        itemDisplay_1.renderPageNumber(right - 40, guiTop + 28);
        if (itemDisplay_1.getSelectedItem() != null) {
            TrackingTask task = null;
            for (TrackingTask taskLoop : tile.tasks) {
                if (taskLoop.item == itemDisplay_1.getSelectedItem().getItem()) {
                    task = taskLoop;
                    break;
                }
            }
            if (task != null) {
                GuiGraphics.drawSlotBackground(mc, guiLeft + 10, guiTop + 99);
                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
                GL11.glEnable(GL11.GL_LIGHTING);
                GL11.glEnable(GL11.GL_DEPTH_TEST);
                RenderHelper.enableGUIStandardItemLighting();
                GuiScreen.itemRender.renderItemAndEffectIntoGUI(fontRendererObj, getMC().renderEngine, task.item.makeNormalStack(1), guiLeft + 11, guiTop + 100);
                GL11.glDisable(GL11.GL_LIGHTING);
                GL11.glDisable(GL11.GL_DEPTH_TEST);
                GuiScreen.itemRender.zLevel = 0.0F;
                mc.fontRenderer.drawString(StringUtils.getWithMaxWidth(task.item.getFriendlyName(), 136, fontRendererObj), guiLeft + 32, guiTop + 104, Color.getValue(Color.DARKER_GREY), false);
                int xOrigo = xCenter - 68;
                int yOrigo = yCenter + 90;
                drawLine(xOrigo, yOrigo, xOrigo + 150, yOrigo, Color.DARKER_GREY);
                drawLine(xOrigo, yOrigo, xOrigo, yOrigo - 80, Color.DARKER_GREY);
                for (int k = -4; k < 5; k++) {
                    int begin = -4;
                    if (k == -4) {
                        begin = -1;
                    }
                    if (k == 0) {
                        begin = -1;
                    }
                    if (k == 4) {
                        begin = -1;
                    }
                    drawLine(xOrigo + begin, yCenter + 50 + k * 10, xOrigo + 5, yCenter + 50 + k * 10, Color.DARKER_GREY);
                }
                for (int k = 0; k < 16; k++) {
                    drawLine(xOrigo + k * 10, yOrigo - 4, xOrigo + k * 10, yOrigo + 4, Color.DARKER_GREY);
                }
                int time_left = 15 + move_left * 15;
                int time_right = move_left * 15;
                String right = "";
                String left = "";
                if (time_right == 0) {
                    right = "Now";
                } else {
                    if (time_right / 60 != 0) {
                        right += (time_right / 60) + "h";
                    }
                    if (time_right % 60 != 0) {
                        right += (time_right % 60) + "min";
                    }
                }
                if (time_left / 60 != 0) {
                    left += (time_left / 60) + "h";
                }
                if (time_left % 60 != 0) {
                    left += (time_left % 60) + "min";
                }
                fontRendererObj.drawString(left, xOrigo - 12, yOrigo + 6, 0x404040);
                fontRendererObj.drawString(right, xOrigo + 153 - fontRendererObj.getStringWidth(right), yOrigo + 6, 0x404040);
                long[] data = new long[task.amountRecorded.length];
                int pos = 0;
                for (int i = task.arrayPos - 1; i >= 0; i--) {
                    data[pos++] = task.amountRecorded[i];
                }
                for (int i = task.amountRecorded.length - 1; i >= task.arrayPos; i--) {
                    data[pos++] = task.amountRecorded[i];
                }
                long lowest = Long.MAX_VALUE;
                long highest = Long.MIN_VALUE;
                int first = (15 * move_left);
                for (int i = first; i <= first + 15 && i < data.length; i++) {
                    long point = data[i];
                    if (point > highest) {
                        highest = point;
                    }
                    if (point < lowest) {
                        lowest = point;
                    }
                }
                double averagey = ((double) highest + lowest) / 2;
                fontRendererObj.drawString(StringUtils.getFormatedStackSize(highest, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize(highest, false)), guiTop + 117, 0x404040);
                fontRendererObj.drawString(StringUtils.getFormatedStackSize((long) averagey, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize((long) averagey, false)), yCenter + 46, 0x404040);
                fontRendererObj.drawString(StringUtils.getFormatedStackSize(lowest, false), xOrigo - 1 - fontRendererObj.getStringWidth(StringUtils.getFormatedStackSize(lowest, false)), bottom - 23, 0x404040);
                float yScale = 80F / Math.max(highest - lowest, 0.5F);
                int x = xOrigo + 150;
                double yOff = data[first] - averagey;
                int y = (yOrigo - 80 / 2) - (int) (yOff * yScale);
                for (int i = first + 1; i < data.length; i++) {
                    long point = data[i];
                    int x1 = x - 10;
                    if (x1 < guiLeft + 15) {
                        break;
                    }
                    yOff = point - averagey;
                    int y1 = (yOrigo - 80 / 2) - (int) (yOff * yScale);
                    drawLine(x1, y1, x, y, Color.RED);
                    drawRect(x - 1, y - 1, x + 2, y + 2, Color.BLACK);
                    x = x1;
                    y = y1;
                }
                drawRect(x - 1, y - 1, x + 2, y + 2, Color.BLACK);
            }
        }
    } else if (current_Tab == 1) {
        itemDisplay_2.renderItemArea(zLevel);
        itemDisplay_2.renderPageNumber(right - 50, guiTop + 66);
    }
    super.drawGuiContainerBackgroundLayer(f, mouse_x, mouse_y);
}
Also used : ItemStack(net.minecraft.item.ItemStack) TrackingTask(logisticspipes.blocks.stats.TrackingTask)

Example 2 with TrackingTask

use of logisticspipes.blocks.stats.TrackingTask in project LogisticsPipes by RS485.

the class AddItemToTrackPacket method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsStatisticsTileEntity tile = this.getTile(player.getEntityWorld(), LogisticsStatisticsTileEntity.class);
    boolean found = false;
    for (TrackingTask task : tile.tasks) {
        if (task.item.equals(item)) {
            found = true;
            break;
        }
    }
    if (!found) {
        TrackingTask task = new TrackingTask();
        task.item = item;
        tile.tasks.add(task);
    }
}
Also used : LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) TrackingTask(logisticspipes.blocks.stats.TrackingTask)

Example 3 with TrackingTask

use of logisticspipes.blocks.stats.TrackingTask in project LogisticsPipes by RS485.

the class GuiAddTracking method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id == 0 && itemDisplay.getSelectedItem() != null) {
        boolean found = false;
        for (TrackingTask task : tile.tasks) {
            if (task.item.equals(itemDisplay.getSelectedItem().getItem())) {
                found = true;
                break;
            }
        }
        if (found) {
            setSubGui(new GuiMessagePopup(StringUtils.translate(PREFIX + "alreadytracked")));
        } else {
            MainProxy.sendPacketToServer(PacketHandler.getPacket(AddItemToTrackPacket.class).setItem(itemDisplay.getSelectedItem().getItem()).setTilePos(tile));
            TrackingTask task = new TrackingTask();
            task.item = itemDisplay.getSelectedItem().getItem();
            tile.tasks.add(task);
            exitGui();
        }
    } else if (guibutton.id == 1) {
        itemDisplay.nextPage();
    } else if (guibutton.id == 2) {
        itemDisplay.prevPage();
    } else if (guibutton.id == 3) {
        refreshItems();
    } else if (guibutton.id == 8) {
        GuiCheckBox button = (GuiCheckBox) guibutton;
        Configs.DISPLAY_POPUP = button.change();
        Configs.savePopupState();
    } else if (guibutton.id == 20) {
        itemDisplay.cycle();
    }
    super.actionPerformed(guibutton);
}
Also used : AddItemToTrackPacket(logisticspipes.network.packets.block.AddItemToTrackPacket) GuiCheckBox(logisticspipes.utils.gui.GuiCheckBox) TrackingTask(logisticspipes.blocks.stats.TrackingTask)

Example 4 with TrackingTask

use of logisticspipes.blocks.stats.TrackingTask in project LogisticsPipes by RS485.

the class StatisticsGui method readData.

@Override
public void readData(LPDataInput input) {
    super.readData(input);
    trackingList = input.readArrayList(data1 -> {
        TrackingTask object = new TrackingTask();
        object.readFromLPData(data1);
        return object;
    });
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) Setter(lombok.Setter) Getter(lombok.Getter) LPDataInput(network.rs485.logisticspipes.util.LPDataInput) LPDataOutput(network.rs485.logisticspipes.util.LPDataOutput) GuiProvider(logisticspipes.network.abstractguis.GuiProvider) GuiStatistics(logisticspipes.gui.GuiStatistics) List(java.util.List) EntityPlayer(net.minecraft.entity.player.EntityPlayer) LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) CoordinatesGuiProvider(logisticspipes.network.abstractguis.CoordinatesGuiProvider) TrackingTask(logisticspipes.blocks.stats.TrackingTask) Container(net.minecraft.inventory.Container) TrackingTask(logisticspipes.blocks.stats.TrackingTask)

Example 5 with TrackingTask

use of logisticspipes.blocks.stats.TrackingTask in project LogisticsPipes by RS485.

the class RemoveAmoundTask method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsStatisticsTileEntity tile = this.getTile(player.getEntityWorld(), LogisticsStatisticsTileEntity.class);
    Iterator<TrackingTask> iter = tile.tasks.iterator();
    while (iter.hasNext()) {
        TrackingTask task = iter.next();
        if (task.item == item) {
            iter.remove();
            break;
        }
    }
}
Also used : LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) TrackingTask(logisticspipes.blocks.stats.TrackingTask)

Aggregations

TrackingTask (logisticspipes.blocks.stats.TrackingTask)5 LogisticsStatisticsTileEntity (logisticspipes.blocks.stats.LogisticsStatisticsTileEntity)3 List (java.util.List)1 GuiStatistics (logisticspipes.gui.GuiStatistics)1 CoordinatesGuiProvider (logisticspipes.network.abstractguis.CoordinatesGuiProvider)1 GuiProvider (logisticspipes.network.abstractguis.GuiProvider)1 AddItemToTrackPacket (logisticspipes.network.packets.block.AddItemToTrackPacket)1 DummyContainer (logisticspipes.utils.gui.DummyContainer)1 GuiCheckBox (logisticspipes.utils.gui.GuiCheckBox)1 Getter (lombok.Getter)1 Setter (lombok.Setter)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Container (net.minecraft.inventory.Container)1 ItemStack (net.minecraft.item.ItemStack)1 LPDataInput (network.rs485.logisticspipes.util.LPDataInput)1 LPDataOutput (network.rs485.logisticspipes.util.LPDataOutput)1