codechicken.lib.vec.Rectangle4i Java Examples

The following examples show how to use codechicken.lib.vec.Rectangle4i. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptionUtilities.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void drawIcons() {
    int x = buttonX();
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(120, 24, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(120, 12, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(168, 24, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(144, 12, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(180, 24, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(132, 12, 12, 12));
    x += 24;
    RenderHelper.enableGUIStandardItemLighting();
    GlStateManager.enableRescaleNormal();
    ItemStack sword = new ItemStack(Items.DIAMOND_SWORD);
    sword.addEnchantment(Enchantment.getEnchantmentByLocation("sharpness"), 1);
    GuiHelper.drawItem(x + 2, 2, sword);
    x += 24;
    GuiHelper.drawItem(x + 2, 2, new ItemStack(Items.POTIONITEM));
    x += 24;
    GuiHelper.drawItem(x + 2, 2, new ItemStack(Blocks.STONE));
    x += 24;
}
 
Example #2
Source File: RenderUtils.java    From CodeChickenLib with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static void renderFluidGauge(FluidStack stack, Rectangle4i rect, double density, double res) {
    if (!shouldRenderFluid(stack))
        return;

    int alpha = 255;
    if (stack.getFluid().isGaseous())
        alpha = (int) (fluidDensityToAlpha(density) * 255);
    else {
        int height = (int) (rect.h * density);
        rect.y += rect.h - height;
        rect.h = height;
    }

    TextureAtlasSprite tex = prepareFluidRender(stack, alpha);
    CCRenderState.startDrawing();
    renderFluidQuad(
            new Vector3(rect.x, rect.y + rect.h, 0),
            new Vector3(rect.w, 0, 0),
            new Vector3(0, -rect.h, 0), tex, res);
    CCRenderState.draw();
    postFluidRender();
}
 
Example #3
Source File: OptionStringSet.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public boolean clickButton(int mousex, int mousey, int button) {
    int x = buttonX();
    List<String> values = values();
    for (int i = 0; i < options.size(); i++) {
        if (new Rectangle4i(x, 0, 20, 20).contains(mousex, mousey)) {
            String s = options.get(i);
            boolean set = values.contains(s);
            if (button == 0 && !set) {
                setValue(s);
                return true;
            }
            if (button == 1 && set) {
                remValue(s);
                return true;
            }
            return false;
        }
        x += 24;
    }
    return false;
}
 
Example #4
Source File: SubsetWidget.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) {
    int w = windowBounds().width;
    Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot));
    if(slot < sorted.size()) {
        SubsetTag tag = sorted.get(slot);
        LayoutManager.getLayoutStyle().drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my));
    }
    else {
        ItemStack stack = state.items.get(slot-sorted.size());
        boolean hidden = SubsetWidget.isHidden(stack);

        int itemx = w/2-8;
        int itemy = 1;

        LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);

        GuiContainerManager.drawItem(x+itemx, y+itemy, stack);
        if(new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my))
            SubsetWidget.hoverStack = stack;
    }
}
 
Example #5
Source File: ItemPanel.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void draw(int mousex, int mousey) {
    if (itemsPerPage == 0)
        return;

    GuiContainerManager.enableMatrixStackLogging();
    int index = firstIndex;
    for (int i = 0; i < rows * columns && index < items.size(); i++) {
        if (validSlotMap[i]) {
            Rectangle4i rect = getSlotRect(i);
            if (rect.contains(mousex, mousey))
                drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight

            GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, items.get(index));

            index++;
        }
    }
    GuiContainerManager.disableMatrixStackLogging();
}
 
Example #6
Source File: SubsetWidget.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
protected void drawSlot(int slot, int x, int y, int mx, int my, float frame) {
    int w = windowBounds().width;
    Rectangle4i r = new Rectangle4i(x, y, w, getSlotHeight(slot));
    if (slot < sorted.size()) {
        SubsetTag tag = sorted.get(slot);
        LayoutManager.getLayoutStyle().drawSubsetTag(tag.displayName(), x, y, r.w, r.h, tag.state.state, r.contains(mx, my));
    } else {
        ItemStack stack = state.items.get(slot - sorted.size());
        boolean hidden = SubsetWidget.isHidden(stack);

        int itemx = w / 2 - 8;
        int itemy = 1;

        LayoutManager.getLayoutStyle().drawSubsetTag(null, x, y, r.w, r.h, hidden ? 0 : 2, false);

        GuiHelper.drawItem(x + itemx, y + itemy, stack);
        if (new Rectangle4i(itemx, itemy, 16, 16).contains(mx, my)) {
            SubsetWidget.hoverStack = stack;
        }
    }
}
 
Example #7
Source File: ItemPanel.java    From NotEnoughItems with MIT License 6 votes vote down vote up
@Override
public void draw(int mousex, int mousey) {
    if (itemsPerPage == 0) {
        return;
    }

    GuiHelper.enableMatrixStackLogging();
    int index = firstIndex;
    for (int i = 0; i < rows * columns && index < items.size(); i++) {
        if (validSlotMap[i]) {
            Rectangle4i rect = getSlotRect(i);
            if (rect.contains(mousex, mousey)) {
                drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);//highlight
            }

            GuiHelper.drawItem(rect.x + 1, rect.y + 1, items.get(index));

            index++;
        }
    }
    GuiHelper.disableMatrixStackLogging();
}
 
Example #8
Source File: OptionStringSet.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public boolean clickButton(int mousex, int mousey, int button) {
    int x = buttonX();
    List<String> values = values();
    for (int i = 0; i < options.size(); i++) {
        if (new Rectangle4i(x, 0, 20, 20).contains(mousex, mousey)) {
            String s = options.get(i);
            boolean set = values.contains(s);
            if (button == 0 && !set) {
                setValue(s);
                return true;
            }
            if (button == 1 && set) {
                remValue(s);
                return true;
            }
            return false;
        }
        x += 24;
    }
    return false;
}
 
Example #9
Source File: ItemPanel.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private boolean slotValid(GuiContainer gui, int i) {
    Rectangle4i rect = getSlotRect(i);
    for (INEIGuiHandler handler : GuiInfo.guiHandlers)
        if (handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h))
            return false;
    return true;
}
 
Example #10
Source File: OptionTextField.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
    if (new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
        String tip = translateN(name + ".tip");
        if (!tip.equals(name + ".tip")) {
            currenttip.add(tip);
        }
    }
    return currenttip;
}
 
Example #11
Source File: GuiOptionList.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void drawWorldSelector(Option o, int mousex, int mousey) {
    Rectangle4i b = worldButtonSize();
    boolean set = o.hasWorldOverride();
    boolean mouseover = b.contains(mousex, mousey);
    GlStateManager.color(1, 1, 1, 1);
    LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, !set ? 0 : mouseover ? 2 : 1);
    drawStringC("W", b.x, b.y, b.w, b.h, -1);
}
 
Example #12
Source File: GuiHighlightTips.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public Rectangle4i selectionBox() {
    Point pos = renderPos();
    Dimension size = displaySize();
    Dimension rect = sampleSize();
    return new Rectangle4i(
            (size.width - rect.width) * pos.x / 10000,
            (size.height - rect.height) * pos.y / 10000,
            rect.width, rect.height);
}
 
Example #13
Source File: OptionStringSet.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
    if (new Rectangle4i(4, 4, 50, 20).contains(mousex, mousey)) {
        currenttip.add(translateN(name + ".tip"));
    }
    int x = buttonX();
    for (String option : options) {
        if (new Rectangle4i(x, 0, 20, 20).contains(mousex, mousey)) {
            currenttip.add(translateN(name + "." + option));
        }

        x += 24;
    }
    return currenttip;
}
 
Example #14
Source File: OptionStringSet.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
    if (new Rectangle4i(4, 4, 50, 20).contains(mousex, mousey))
        currenttip.add(translateN(name + ".tip"));
    int x = buttonX();
    for (String option : options) {
        if (new Rectangle4i(x, 0, 20, 20).contains(mousex, mousey))
            currenttip.add(translateN(name + "." + option));

        x += 24;
    }
    return currenttip;
}
 
Example #15
Source File: OptionTextField.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public List<String> handleTooltip(int mousex, int mousey, List<String> currenttip) {
    if (new Rectangle4i(10, 0, textField.x - 10, 20).contains(mousex, mousey)) {
        String tip = translateN(name + ".tip");
        if (!tip.equals(name + ".tip"))
            currenttip.add(tip);
    }
    return currenttip;
}
 
Example #16
Source File: ItemPanel.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public boolean contains(int px, int py) {
    GuiContainer gui = NEIClientUtils.getGuiContainer();
    Rectangle4i rect = new Rectangle4i(px, py, 1, 1);
    for (INEIGuiHandler handler : GuiInfo.guiHandlers)
        if (handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h))
            return false;

    return super.contains(px, py);
}
 
Example #17
Source File: OptionGamemodes.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawIcons() {
    int x = buttonX();
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(132, 12, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(156, 12, 12, 12));
    x += 24;
    LayoutManager.drawIcon(x + 4, 4, new Rectangle4i(168, 12, 12, 12));
    x += 24;
}
 
Example #18
Source File: LayoutStyleTMIOld.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawButton(Button b, int mousex, int mousey) {
    int cwidth = b.contentWidth();
    if ((b.state & 0x4) != 0) {
        cwidth += stateOff.w;
    }
    int textx = b.x + (b.w - cwidth) / 2;
    int texty = b.y + (b.h - 8) / 2;

    drawRect(b.x, b.y, b.w, b.h, b.contains(mousex, mousey) ? 0xee401008 : 0xee000000);

    Rectangle4i icon = b.getRenderIcon();
    if (icon == null) {
        drawString(b.getRenderLabel(), textx, texty, -1);
    } else {
        int icony = b.y + (b.h - icon.h) / 2;
        LayoutManager.drawIcon(textx, icony, icon);
        if ((b.state & 0x3) == 2) {
            drawRect(textx, icony, icon.w, icon.h, 0x80000000);
        }

        if ((b.state & 0x4) != 0) {
            Rectangle4i stateimage;
            if ((b.state & 0x3) == 1) {
                stateimage = stateOn;
            } else if ((b.state & 0x3) == 2) {
                stateimage = stateDisabled;
            } else {
                stateimage = stateOff;
            }
            LayoutManager.drawIcon(textx + icon.w, icony, stateimage);
        }
    }
}
 
Example #19
Source File: LayoutStyleTMIOld.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void init() {
    delete.icon = new Rectangle4i(24, 12, 12, 12);
    gamemode.icons[0] = new Rectangle4i(12, 12, 12, 12);
    gamemode.icons[1] = new Rectangle4i(36, 12, 12, 12);
    gamemode.icons[2] = new Rectangle4i(48, 12, 12, 12);
    rain.icon = new Rectangle4i(0, 12, 12, 12);
    magnet.icon = new Rectangle4i(60, 24, 12, 12);
    timeButtons[0].icon = new Rectangle4i(12, 24, 12, 12);
    timeButtons[1].icon = new Rectangle4i(0, 24, 12, 12);
    timeButtons[2].icon = new Rectangle4i(24, 24, 12, 12);
    timeButtons[3].icon = new Rectangle4i(36, 24, 12, 12);
    heal.icon = new Rectangle4i(48, 24, 12, 12);
    dropDown.x = 93;
}
 
Example #20
Source File: LayoutStyleMinecraft.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void drawButton(Button b, int mousex, int mousey) {
    GlStateManager.disableLighting();
    GlStateManager.color(1, 1, 1, 1);

    int tex;
    if ((b.state & 0x3) == 2) {
        tex = 0;
    } else if ((b.state & 0x4) == 0 && b.contains(mousex, mousey) ||//not a state button and mouseover
            (b.state & 0x3) == 1)//state active
    {
        tex = 2;
    } else {
        tex = 1;
    }
    LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, tex);

    Rectangle4i icon = b.getRenderIcon();
    if (icon == null) {
        int colour = tex == 2 ? 0xffffa0 : tex == 0 ? 0x601010 : 0xe0e0e0;

        drawStringC(b.getRenderLabel(), b.x + b.w / 2, b.y + (b.h - 8) / 2, colour);
    } else {
        GlStateManager.color(1, 1, 1, 1);

        int iconx = b.x + (b.w - icon.w) / 2;
        int icony = b.y + (b.h - icon.h) / 2;
        LayoutManager.drawIcon(iconx, icony, icon);
    }
}
 
Example #21
Source File: LayoutStyleMinecraft.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public void init() {
    delete.icon = new Rectangle4i(144, 12, 12, 12);
    gamemode.icons[0] = new Rectangle4i(132, 12, 12, 12);
    gamemode.icons[1] = new Rectangle4i(156, 12, 12, 12);
    gamemode.icons[2] = new Rectangle4i(168, 12, 12, 12);
    rain.icon = new Rectangle4i(120, 12, 12, 12);
    magnet.icon = new Rectangle4i(180, 24, 12, 12);
    timeButtons[0].icon = new Rectangle4i(132, 24, 12, 12);
    timeButtons[1].icon = new Rectangle4i(120, 24, 12, 12);
    timeButtons[2].icon = new Rectangle4i(144, 24, 12, 12);
    timeButtons[3].icon = new Rectangle4i(156, 24, 12, 12);
    heal.icon = new Rectangle4i(168, 24, 12, 12);
    dropDown.x = 90;
}
 
Example #22
Source File: ItemPanel.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private boolean slotValid(GuiContainer gui, int i) {
    Rectangle4i rect = getSlotRect(i);
    for (INEIGuiHandler handler : GuiInfo.guiHandlers) {
        if (handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h)) {
            return false;
        }
    }
    return true;
}
 
Example #23
Source File: GuiOptionList.java    From NotEnoughItems with MIT License 5 votes vote down vote up
private void drawWorldSelector(Option o, int mousex, int mousey) {
    Rectangle4i b = worldButtonSize();
    boolean set = o.hasWorldOverride();
    boolean mouseover = b.contains(mousex, mousey);
    GlStateManager.color(1, 1, 1, 1);
    LayoutManager.drawButtonBackground(b.x, b.y, b.w, b.h, true, !set ? 0 : mouseover ? 2 : 1);
    drawStringC("W", b.x, b.y, b.w, b.h, -1);
}
 
Example #24
Source File: ItemPanel.java    From NotEnoughItems with MIT License 5 votes vote down vote up
@Override
public boolean contains(int px, int py) {
    GuiContainer gui = NEIClientUtils.getGuiContainer();
    Rectangle4i rect = new Rectangle4i(px, py, 1, 1);
    for (INEIGuiHandler handler : GuiInfo.guiHandlers) {
        if (handler.hideItemPanelSlot(gui, rect.x, rect.y, rect.w, rect.h)) {
            return false;
        }
    }

    return super.contains(px, py);
}
 
Example #25
Source File: LayoutManager.java    From NotEnoughItems with MIT License 5 votes vote down vote up
public static void drawIcon(int x, int y, Rectangle4i image) {
    changeTexture("nei:textures/nei_sprites.png");
    GlStateManager.color(1, 1, 1, 1);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    drawTexturedModalRect(x, y, image.x, image.y, image.w, image.h);
    GlStateManager.disableBlend();
}
 
Example #26
Source File: DataDumper.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public Rectangle4i dumpButtonSize() {
    int width = 80;
    return new Rectangle4i(slot.slotWidth() - width, 0, width, 20);
}
 
Example #27
Source File: GuiScrollPane.java    From CodeChickenCore with MIT License 4 votes vote down vote up
public Rectangle4i bounds() {
    return new Rectangle4i(x, y, width, height);
}
 
Example #28
Source File: ItemPanelDumper.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public Rectangle4i resButtonSize() {
    int width = 50;
    return new Rectangle4i(modeButtonSize().x - width - 6, 0, width, 20);
}
 
Example #29
Source File: ItemPanel.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public Rectangle4i getSlotRect(int i) {
    return getSlotRect(i / columns, i % columns);
}
 
Example #30
Source File: GuiOptionList.java    From NotEnoughItems with MIT License 4 votes vote down vote up
public Rectangle4i worldButtonSize() {
    return new Rectangle4i(0, 2, 20, 20);
}