tab.update(); if (!tab.isVisible()) { continue; tab.drawForeground(mouseX, mouseY); yPosLeft += tab.currentHeight; } else { tab.drawForeground(mouseX, mouseY); yPosRight += tab.currentHeight; tab.update(); if (!tab.isVisible()) { continue; tab.setPosition(0, yPosLeft); tab.drawBackground(mouseX, mouseY, partialTick); yPosLeft += tab.currentHeight; } else { tab.setPosition(xSize, yPosRight); tab.drawBackground(mouseX, mouseY, partialTick); yPosRight += tab.currentHeight;
@Override public List<Rectangle> getGuiExtraAreas(GuiContainerCore guiContainer) { List<Rectangle> tabBoxes = new ArrayList<>(); for (TabBase tab : guiContainer.tabs) { Rectangle4i rect = tab.getBounds(); tabBoxes.add(new Rectangle(rect.x, rect.y, rect.w, rect.h)); } return tabBoxes; }
protected TabBase getTabAtPosition(int mX, int mY) { int xShift = 0; int yShift = 4; for (TabBase tab : tabs) { if (!tab.isVisible() || tab.side == TabBase.RIGHT) { continue; } tab.setCurrentShift(xShift, yShift); if (tab.intersectsWith(mX, mY, xShift, yShift)) { return tab; } yShift += tab.currentHeight; } xShift = xSize; yShift = 4; for (TabBase tab : tabs) { if (!tab.isVisible() || tab.side == TabBase.LEFT) { continue; } tab.setCurrentShift(xShift, yShift); if (tab.intersectsWith(mX, mY, xShift, yShift)) { return tab; } yShift += tab.currentHeight; } return null; }
/** * Corrects for shadowing differences in tabs to ensure that they always look nice - used in font rendering, typically. */ protected int posXOffset() { return posX() + sideOffset(); }
public TabBase addTab(TabBase tab, int index) { int yOffset = 4; for (TabBase tab1 : tabs) { if (tab1.side == tab.side && tab1.isVisible()) { yOffset += tab1.currentHeight; } } tab.setPosition(tab.side == TabBase.LEFT ? 0 : xSize, yOffset); tabs.add(index, tab); if (TabTracker.getOpenedLeftTab() != null && tab.getClass().equals(TabTracker.getOpenedLeftTab())) { tab.setFullyOpen(); } else if (TabTracker.getOpenedRightTab() != null && tab.getClass().equals(TabTracker.getOpenedRightTab())) { tab.setFullyOpen(); } return tab; }
@Override public void drawForeground(int mouseX, int mouseY) { mouseX -= this.posX(); mouseY -= this.posY; GlStateManager.pushMatrix(); GlStateManager.translate(this.posX(), this.posY, 0.0F); drawForeground(); for (ElementBase element : elements) { if (element.isVisible()) { element.drawForeground(mouseX, mouseY); } } GlStateManager.popMatrix(); }
@Override public void drawBackground(int mouseX, int mouseY, float gameTicks) { mouseX -= this.posX(); mouseY -= this.posY; GlStateManager.pushMatrix(); GlStateManager.translate(this.posX(), this.posY, 0.0F); drawBackground(); for (ElementBase element : elements) { if (element.isVisible()) { element.drawBackground(mouseX, mouseY, gameTicks); } } GlStateManager.popMatrix(); }
@Override protected void drawBackground() { super.drawBackground(); if (!isFullyOpened()) { return; } float colorR = (backgroundColor >> 16 & 255) / 255.0F * 0.6F; float colorG = (backgroundColor >> 8 & 255) / 255.0F * 0.6F; float colorB = (backgroundColor & 255) / 255.0F * 0.6F; GlStateManager.color(colorR, colorG, colorB, 1.0F); gui.drawTexturedModalRect(24, 16, 16, 20, 64, 24); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); }
if (!tab.onMousePressed(mX, mY, mouseButton)) { for (int i = tabs.size(); i-- > 0; ) { TabBase other = tabs.get(i); if (other != tab && other.open && other.side == tab.side) { other.toggleOpen(); tab.toggleOpen(); return;
@Override public void onMouseReleased(int mouseX, int mouseY) { mouseX -= this.posX(); mouseY -= this.posY; for (int i = elements.size(); i-- > 0; ) { ElementBase c = elements.get(i); if (!c.isVisible() || !c.isEnabled()) { // no bounds checking on mouseUp events continue; } c.onMouseReleased(mouseX, mouseY); } }
@Override public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) throws IOException { int shiftedMouseX = mouseX - this.posX(); int shiftedMouseY = mouseY - this.posY; if (!isFullyOpened()) { return false; } if (!scrollable || shiftedMouseY < 16 || shiftedMouseX < 108) { return super.onMousePressed(mouseX, mouseY, mouseButton); } if (shiftedMouseY < 52) { firstLine = MathHelper.clamp(firstLine - 1, 0, maxFirstLine); } else { firstLine = MathHelper.clamp(firstLine + 1, 0, maxFirstLine); } return true; }
protected void updateElements() { for (ElementBase element : elements) { element.setVisible(this.isFullyOpened()); } }
public void addTooltips(List<String> tooltip) { TabBase tab = getTabAtPosition(mouseX, mouseY); if (tab != null) { tab.addTooltip(tooltip); } ElementBase element = getElementAtPosition(mouseX, mouseY); if (element != null && element.isVisible()) { element.addTooltip(tooltip); } }
@Override public void handleMouseInput() throws IOException { int x = Mouse.getEventX() * width / mc.displayWidth; int y = height - Mouse.getEventY() * height / mc.displayHeight - 1; mouseX = x - guiLeft; mouseY = y - guiTop; int wheelMovement = Mouse.getEventDWheel(); if (wheelMovement != 0) { for (int i = elements.size(); i-- > 0; ) { ElementBase c = elements.get(i); if (!c.isVisible() || !c.isEnabled() || !c.intersectsWith(mouseX, mouseY)) { continue; } if (c.onMouseWheel(mouseX, mouseY, wheelMovement)) { return; } } TabBase tab = getTabAtPosition(mouseX, mouseY); if (tab != null && tab.onMouseWheel(mouseX, mouseY, wheelMovement)) { return; } if (onMouseWheel(mouseX, mouseY, wheelMovement)) { return; } } super.handleMouseInput(); }
public TabBase addTab(TabBase tab) { int yOffset = 4; for (TabBase tab1 : tabs) { if (tab1.side == tab.side && tab1.isVisible()) { yOffset += tab1.currentHeight; } } tab.setPosition(tab.side == TabBase.LEFT ? 0 : xSize, yOffset); tabs.add(tab); if (TabTracker.getOpenedLeftTab() != null && tab.getClass().equals(TabTracker.getOpenedLeftTab())) { tab.setFullyOpen(); } else if (TabTracker.getOpenedRightTab() != null && tab.getClass().equals(TabTracker.getOpenedRightTab())) { tab.setFullyOpen(); } return tab; }
@Override protected void drawBackground() { super.drawBackground(); if (!isFullyOpened()) { return; } float colorR = (backgroundColor >> 16 & 255) / 255.0F * 0.6F; float colorG = (backgroundColor >> 8 & 255) / 255.0F * 0.6F; float colorB = (backgroundColor & 255) / 255.0F * 0.6F; GlStateManager.color(colorR, colorG, colorB, 1.0F); gui.drawTexturedModalRect(16, 20, 16, 20, 64, 64); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); }
@Override public void update(int mouseX, int mouseY) { super.update(mouseX, mouseY); mouseX -= this.posX(); mouseY -= this.posY; for (int i = elements.size(); i-- > 0; ) { ElementBase c = elements.get(i); if (c.isVisible() && c.isEnabled()) { c.update(mouseX, mouseY); } } }
return super.onMousePressed(mouseX, mouseY, mouseButton);
@Override protected void drawBackground() { super.drawBackground(); if (!isFullyOpened()) { return; } float colorR = (backgroundColor >> 16 & 255) / 255.0F * 0.6F; float colorG = (backgroundColor >> 8 & 255) / 255.0F * 0.6F; float colorB = (backgroundColor & 255) / 255.0F * 0.6F; GlStateManager.color(colorR, colorG, colorB, 1.0F); gui.drawTexturedModalRect(24, 16, 16, 20, 64, 24); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); }