Search in sources :

Example 1 with ChromaHUDDescription

use of cc.hyperium.mods.chromahud.api.ChromaHUDDescription in project Hyperium by HyperiumClient.

the class AddItemsGui method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    mouseLock = mouseLock && Mouse.isButtonDown(0);
    ScaledResolution current = ResolutionUtil.current();
    drawRect(0, 0, current.getScaledWidth(), current.getScaledHeight(), new Color(0, 0, 0, 150).getRGB());
    super.drawScreen(mouseX, mouseY, partialTicks);
    ElementRenderer.startDrawing(target);
    if (adding) {
        Color defaultColor = new Color(255, 255, 255, 100);
        int cursorY = 50 + offset;
        drawCenteredString(mc.fontRendererObj, "Click Explore to see examples!", current.getScaledWidth() / 2, cursorY - 30, Color.RED.getRGB());
        List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
        for (ChromaHUDParser parser : parsers) {
            Map<String, String> names = parser.getNames();
            for (Map.Entry<String, String> entry : names.entrySet()) {
                String s = entry.getKey();
                String text1 = entry.getValue() + "";
                drawRect(current.getScaledWidth() / 2 - 80, cursorY, current.getScaledWidth() / 2 + 80, cursorY + 20, defaultColor.getRGB());
                int j = Color.RED.getRGB();
                int width = 160;
                int height = 20;
                mc.fontRendererObj.drawString(text1, ((current.getScaledWidth() >> 1) - 80 + (width >> 1) - (mc.fontRendererObj.getStringWidth(text1) >> 1)), cursorY + ((height - 8) >> 1), j, false);
                int i = ResolutionUtil.current().getScaledHeight() - (Mouse.getY() / current.getScaleFactor());
                if (Mouse.isButtonDown(0) && !mouseLock)
                    if (i >= cursorY && i <= cursorY + 23) {
                        int i1 = Mouse.getX() / current.getScaleFactor();
                        if (i1 >= current.getScaledWidth() / 2 - 80 && i1 <= current.getScaledWidth() / 2 + 80) {
                            DisplayItem item = ChromaHUDApi.getInstance().parse(s, 0, new JsonHolder().put("type", s));
                            element.getDisplayItems().add(item);
                            element.adjustOrdinal();
                            mc.displayGuiScreen(new EditItemsGui(element, mod));
                        }
                    }
                cursorY += 23;
            }
        }
    } else {
        int cursorY = 50 + offset;
        List<ChromaHUDParser> parsers = ChromaHUDApi.getInstance().getParsers();
        for (ChromaHUDParser parser : parsers) {
            ChromaHUDDescription description = parser.description();
            String text = "Items in " + description.getName() + ".";
            mc.fontRendererObj.drawString(text, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text)) >> 1, cursorY, Color.RED.getRGB(), true);
            cursorY += 30;
            Map<String, String> names = parser.getNames();
            for (Map.Entry<String, String> entry : names.entrySet()) {
                String s = entry.getKey();
                String text1 = entry.getValue() + ": ";
                DisplayElement displayElement = find(s);
                if (displayElement == null) {
                    String text2 = "ERROR LOCATING DISPLAY ELEMENT " + s;
                    mc.fontRendererObj.drawString(text2, (current.getScaledWidth() - mc.fontRendererObj.getStringWidth(text2)) >> 1, cursorY, Color.RED.getRGB(), true);
                    cursorY += 15;
                    continue;
                }
                Dimension dimensions = displayElement.getDimensions();
                int stringWidth = mc.fontRendererObj.getStringWidth(text1);
                double totalWidth = dimensions.getWidth() + stringWidth;
                double left = (current.getScaledWidth_double() - totalWidth) / 2;
                double startDraw = left + stringWidth;
                displayElement.setXloc(startDraw / current.getScaledWidth_double());
                displayElement.setYloc(((double) cursorY) / current.getScaledHeight_double());
                displayElement.drawForConfig();
                mc.fontRendererObj.drawString(text1, (float) ((current.getScaledWidth() - totalWidth) / 2), cursorY, Color.RED.getRGB(), true);
                cursorY += dimensions.getHeight() + 5;
            }
        }
    }
    ElementRenderer.endDrawing(target);
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) DisplayItem(cc.hyperium.mods.chromahud.api.DisplayItem) Dimension(cc.hyperium.mods.chromahud.api.Dimension) DisplayElement(cc.hyperium.mods.chromahud.DisplayElement) ScaledResolution(net.minecraft.client.gui.ScaledResolution) ChromaHUDParser(cc.hyperium.mods.chromahud.api.ChromaHUDParser) ChromaHUDDescription(cc.hyperium.mods.chromahud.api.ChromaHUDDescription) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

DisplayElement (cc.hyperium.mods.chromahud.DisplayElement)1 ChromaHUDDescription (cc.hyperium.mods.chromahud.api.ChromaHUDDescription)1 ChromaHUDParser (cc.hyperium.mods.chromahud.api.ChromaHUDParser)1 Dimension (cc.hyperium.mods.chromahud.api.Dimension)1 DisplayItem (cc.hyperium.mods.chromahud.api.DisplayItem)1 JsonHolder (cc.hyperium.utils.JsonHolder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1