use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.
the class GuidePageBase method renderPage.
protected void renderPage(int x, int y, int width, int height, int index) {
// Even => first page, draw page back button and first page index
if (index % 2 == 0) {
// Back page button
if (index != 0) {
GuiIcon icon = GuiGuide.TURN_BACK;
GuiRectangle turnBox = new GuiRectangle(x, y + height, icon.width, icon.height);
if (turnBox.contains(gui.mouse)) {
icon = GuiGuide.TURN_BACK_HOVERED;
}
icon.drawAt(turnBox);
}
// Page index
String text = (index + 1) + " / " + numPages;
double textX = x + GuiGuide.PAGE_LEFT_TEXT.width / 2 - getFontRenderer().getStringWidth(text) / 2;
getFontRenderer().drawString(text, (int) textX, (int) (y + height) + 6, 0);
} else {
// Back page button
if (index + 1 < numPages) {
GuiIcon icon = GuiGuide.TURN_FORWARDS;
GuiRectangle turnBox = new GuiRectangle(x + width - icon.width, y + height, icon.width, icon.height);
if (turnBox.contains(gui.mouse)) {
icon = GuiGuide.TURN_FORWARDS_HOVERED;
}
icon.drawAt(turnBox);
}
// Page index
if (index + 1 <= numPages) {
String text = (index + 1) + " / " + numPages;
double textX = x + (GuiGuide.PAGE_RIGHT_TEXT.width - getFontRenderer().getStringWidth(text)) / 2;
getFontRenderer().drawString(text, (int) textX, (int) (y + height) + 6, 0);
}
}
}
use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.
the class GuiElectronicLibrary method iterateSnapshots.
private void iterateSnapshots(ISnapshotIterator iterator) {
List<Snapshot.Key> list = getSnapshots().getList();
GuiRectangle rect = new GuiRectangle(mainGui.rootElement.getX() + 8, mainGui.rootElement.getY() + 22, 154, 8);
for (int i = 0; i < list.size(); i++) {
iterator.call(i, rect, list.get(i));
rect = rect.offset(0, 8);
}
}
use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.
the class GuiUtil method moveAreaToCentre.
public static IGuiArea moveAreaToCentre(IGuiArea area) {
if (area instanceof GuiRectangle || area instanceof IConstantNode) {
return moveRectangleToCentre(area.asImmutable());
}
DoubleSupplier posX = () -> (AREA_WHOLE_SCREEN.getWidth() - area.getWidth()) / 2;
DoubleSupplier posY = () -> (AREA_WHOLE_SCREEN.getHeight() - area.getHeight()) / 2;
return IGuiArea.create(posX, posY, area::getWidth, area::getHeight);
}
use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.
the class GuiUtil method scissor0.
private static void scissor0() {
GuiRectangle total = null;
for (GuiRectangle rect2 : scissorRegions) {
if (total == null) {
total = rect2;
continue;
}
double minX = Math.max(total.x, rect2.x);
double minY = Math.max(total.y, rect2.y);
double maxX = Math.min(total.getEndX(), rect2.getEndX());
double maxY = Math.min(total.getEndY(), rect2.getEndY());
total = new GuiRectangle(minX, minY, maxX - minX, maxY - minY);
}
if (total == null) {
throw new IllegalStateException("Cannot call scissor0 when there are no more regions!");
}
scissor0(total);
}
use of buildcraft.lib.gui.pos.GuiRectangle in project BuildCraft by BuildCraft.
the class GuiElementStatementSource method iterateSlots.
private void iterateSlots(ISlotIter<S> iter) {
int dx = left ? -1 : 1;
int sx = left ? 3 : 0;
int ex = sx + dx * 4;
int x = sx;
int y = 0;
for (StatementGroup<S> group : ctx.getAllPossible()) {
int visited = 0;
for (S slot : group.getValues()) {
double px = getX() + x * 18;
double py = getY() + y * 18;
iter.iterate(slot, new GuiRectangle(px, py, 18, 18));
visited++;
x += dx;
if (x == ex) {
x = sx;
y++;
}
}
if (visited > 0 && x != sx) {
x = sx;
y++;
}
}
}
Aggregations