public ElementButton(GuiContainerCore gui, int posX, int posY, String name, int sheetX, int sheetY, int hoverX, int hoverY, int sizeX, int sizeY, String texture) { super(gui, posX, posY, sizeX, sizeY); setGuiManagedClicks(true); setName(name); setTexture(texture, texW, texH); this.sheetX = sheetX; this.sheetY = sheetY; this.hoverX = hoverX; this.hoverY = hoverY; }
public ElementTextField setText(String text) { selectionStart = 0; selectionEnd = textLength; writeText(text); return this; }
public int getContentHeight() { FontRenderer font = getFontRenderer(); int height = font.FONT_HEIGHT; if (multiline) { for (int i = 0; i < textLength; ++i) { if (text[i] == '\n') { height += font.FONT_HEIGHT; } } } return height; }
@Override public void onMouseReleased(int mouseX, int mouseY) { if (!pressed) { boolean focus = isFocused(); setFocused(false); if (focus && !isFocused()) { onFocusLost(); } } pressed = selecting = false; }
@Override public void initGui() { super.initGui(); addElement(new ElementEnergyStored(this, 80, 18, baseTile.getEnergyStorage())); addElement(new ElementFluidTank(this, 152, 9, baseTile.getTank(0))); duration = (ElementDualScaled) addElement(new ElementDualScaled(this, 115, 35).setSize(16, 16).setTexture(TEX_FLAME_GREEN, 32, 16)); }
@Override protected void updateElementInformation() { super.updateElementInformation(); slotInput.setVisible(baseTile.hasSideType(INPUT_ALL) || baseTile.hasSideType(OMNI)); slotTankOutput.setVisible(baseTile.hasSideType(OUTPUT_ALL) || baseTile.hasSideType(OMNI)); progressFluid.setFluid(baseTile.getTankFluid()); progressFluid.setSize(baseTile.getScaledProgress(PROGRESS), 16); progressOverlay.setQuantity(baseTile.getScaledProgress(PROGRESS)); speed.setQuantity(baseTile.getScaledSpeed(SPEED)); }
@Override protected void updateElementInformation() { super.updateElementInformation(); slotInput.setVisible(baseTile.hasSideType(INPUT_ALL) || baseTile.hasSideType(OMNI)); slotOutput.setVisible(baseTile.hasSideType(OUTPUT_ALL) || baseTile.hasSideType(OMNI)); progress.setQuantity(baseTile.getScaledProgress(SPEED)); tankBackground.setVisible(myTile.augmentRepair()); tank.setVisible(myTile.augmentRepair()); modeOverlay.setVisible(myTile.augmentWireless()); }
@Override public boolean onMousePressed(int x, int y, int mouseButton) { if (!managedClicks) { return super.onMousePressed(x, y, mouseButton); } if (isEnabled()) { gui.handleElementButtonClick(getName(), mouseButton); return true; } return false; }
public ElementTextField setFocused(boolean focused) { if (isFocusable()) { isFocused = focused; resetCaretFlash(); } return this; }
protected int getTextColor(int mouseX, int mouseY) { if (!isEnabled()) { return -6250336; } else if (intersectsWith(mouseX, mouseY)) { return 16777120; } else { return 14737632; } }
@Override public void drawBackground(int mouseX, int mouseY, float gameTicks) { drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); drawModalRect(posX, posY, posX + sizeX, posY + sizeY, isEnabled() ? backgroundColor : disabledColor); }
public ElementButton(GuiContainerCore gui, int posX, int posY, int sizeX, int sizeY, int sheetX, int sheetY, int hoverX, int hoverY, String texture) { super(gui, posX, posY, sizeX, sizeY); setGuiManagedClicks(false); setTexture(texture, texW, texH); this.sheetX = sheetX; this.sheetY = sheetY; this.hoverX = hoverX; this.hoverY = hoverY; }
public ElementSlider setLimits(int min, int max) { _valueMin = min; _valueMax = max; setValue(_value); return this; }
@Override public void update(int mouseX, int mouseY) { if (_isDragging) { dragSlider(mouseX - posX, mouseY - posY); } }
public void scrollUp() { if (_firstIndexDisplayed > 0) { _firstIndexDisplayed--; } onScrollV(_firstIndexDisplayed); }
@Override public void onMouseReleased(int mouseX, int mouseY) { if (_isDragging) { onStopDragging(); } _isDragging = false; }
@Override public void onMouseReleased(int mouseX, int mouseY) { if (rightClick) { rightClick = false; } else { super.onMouseReleased(mouseX, mouseY); } }
@Override public void drawBackground(int mouseX, int mouseY, float gameTicks) { drawModalRect(posX - 1, posY - 1, posX + sizeX + 1, posY + sizeY + 1, borderColor); drawModalRect(posX, posY, posX + sizeX, posY + sizeY, backgroundColor); }
@Override public boolean onMousePressed(int mouseX, int mouseY, int mouseButton) { _isDragging = mouseButton == 0; update(mouseX, mouseY); return true; }