use of codechicken.lib.vec.Rectangle4i in project Galacticraft by micdoodle8.
the class OptionStringSet method clickButton.
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;
}
use of codechicken.lib.vec.Rectangle4i in project Galacticraft by micdoodle8.
the class ItemPanel method contains.
@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);
}
use of codechicken.lib.vec.Rectangle4i in project Galacticraft by micdoodle8.
the class GuiModListScroll method draw.
public static void draw(GuiModList gui, int mouseX, int mouseY) {
ModContainer selectedMod = ReflectionManager.getField(GuiModList.class, ModContainer.class, gui, "selectedMod");
if (selectedMod != lastMod) {
lastMod = selectedMod;
scroll = 0;
timeStart = ClientUtils.getRenderTime();
}
if (!scrollMods.contains(selectedMod) || selectedMod.getMetadata().autogenerated) {
return;
}
int y1 = calcDescY(gui, selectedMod);
int y1draw = y1 + 10;
int y2 = gui.height - 38;
int x1 = ReflectionManager.getField(GuiModList.class, Integer.class, gui, "listWidth") + 20;
int x2 = gui.width - 20;
if (x2 - x1 <= 20) {
return;
}
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
GlStateManager.colorMask(false, false, false, false);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
// clear stencil buffer
GuiDraw.drawRect(0, 0, gui.width, gui.height, -1);
screenshotStencil(1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
// add description area (even below button)
GuiDraw.drawRect(x1, y1, gui.width - x1, gui.height - y1, -1);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
// subtract done button
GuiDraw.drawRect(gui.width / 2 - 75, y2, 200, 20, -1);
screenshotStencil(2);
GlStateManager.colorMask(true, true, true, true);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// fill stencil with background
gui.drawDefaultBackground();
GlStateManager.colorMask(false, false, false, false);
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
GuiDraw.drawRect(0, 0, gui.width, gui.height, -1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
GuiDraw.drawRect(x1, y1draw, x2 - x1, y2 - y1draw, -1);
screenshotStencil(3);
GlStateManager.colorMask(true, true, true, true);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
String description = selectedMod.getMetadata().description;
int height = GuiDraw.fontRenderer.listFormattedStringToWidth(description, x2 - x1).size() * GuiDraw.fontRenderer.FONT_HEIGHT;
boolean needsScroll = height > y2 - y1draw;
if ((ClientUtils.getRenderTime() - timeStart) > 40 && needsScroll) {
double dt = ClientUtils.getRenderTime() - lastFrameTime;
if (new Rectangle4i(x1, y1draw, x2 - x1, y2 - y1draw).contains(mouseX, mouseY)) {
double d = Keyboard.isKeyDown(Keyboard.KEY_UP) ? -1 : Keyboard.isKeyDown(Keyboard.KEY_DOWN) ? 1 : 0;
scroll += d * dt * 1.5;
} else {
scroll += dt * 0.2;
}
}
lastFrameTime = ClientUtils.getRenderTime();
// draw description
double dy = scroll % (height + 20);
GlStateManager.pushMatrix();
GlStateManager.translate(0, -dy, 0);
GuiDraw.fontRenderer.drawSplitString(description, x1, y1draw, x2 - x1, 0xDDDDDD);
if (needsScroll) {
GlStateManager.translate(0, height + 20, 0);
GuiDraw.fontRenderer.drawSplitString(description, x1, y1draw, x2 - x1, 0xDDDDDD);
}
GlStateManager.popMatrix();
glDisable(GL_STENCIL_TEST);
}
use of codechicken.lib.vec.Rectangle4i in project Galacticraft by micdoodle8.
the class ItemPanel method draw.
@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)) {
// highlight
drawRect(rect.x, rect.y, rect.w, rect.h, 0xee555555);
}
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, items.get(index));
index++;
}
}
GuiContainerManager.disableMatrixStackLogging();
}
Aggregations