use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class GuiElementContainerResizing method calculateSizes.
@Override
public void calculateSizes() {
maxX = minX = maxY = minY = 0;
double x0, x1, y0, y1;
double x = childRoot.getX();
double y = childRoot.getY();
x0 = x1 = x;
y0 = y1 = y;
for (IGuiElement elem : getChildElements()) {
x0 = Math.min(x0, elem.getX());
y0 = Math.min(y0, elem.getY());
x1 = Math.max(x1, elem.getEndX());
y1 = Math.max(y1, elem.getEndY());
}
minX = x0 - x;
maxX = x1 - x;
minY = y0 - y;
maxY = y1 - y;
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class LedgerHelp method drawForeground.
@Override
public void drawForeground(float partialTicks) {
super.drawForeground(partialTicks);
if (!shouldDrawOpen()) {
return;
}
boolean set = false;
List<HelpPosition> elements = new ArrayList<>();
for (IGuiElement element : gui.shownElements) {
element.addHelpElements(elements);
foundAny |= elements.size() > 0;
for (HelpPosition info : elements) {
IGuiArea rect = info.target;
boolean isHovered = rect.contains(gui.mouse);
if (isHovered) {
if (selected != element && !set) {
selected = element;
GuiElementContainerHelp container = new GuiElementContainerHelp(gui, positionLedgerInnerStart);
info.info.addGuiElements(container);
if (openElements.size() == 2) {
openElements.remove(1);
}
openElements.add(container);
title = LocaleUtil.localize("gui.ledger.help") + ": " + LocaleUtil.localize(info.info.title);
calculateMaxSize();
set = true;
}
}
boolean isSelected = selected == element;
SpriteNineSliced split = SPRITE_HELP_SPLIT[isHovered ? 1 : 0][isSelected ? 1 : 0];
RenderUtil.setGLColorFromInt(info.info.colour);
split.draw(rect);
}
elements.clear();
}
GlStateManager.color(1, 1, 1);
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class Ledger_Neptune method onMouseClicked.
@Override
public void onMouseClicked(int button) {
boolean childClicked = false;
for (IGuiElement elem : openElements) {
if (elem instanceof IInteractionElement) {
((IInteractionElement) elem).onMouseClicked(button);
childClicked |= elem.contains(gui.mouse);
}
}
for (IGuiElement elem : closedElements) {
if (elem instanceof IInteractionElement) {
((IInteractionElement) elem).onMouseClicked(button);
childClicked |= elem.contains(gui.mouse);
}
}
if (!childClicked && contains(gui.mouse)) {
boolean nowOpen = false;
if (currentDifference == 1) {
currentDifference = -1;
} else {
currentDifference = 1;
nowOpen = true;
}
if (isOpenProperty != null) {
isOpenProperty.set(nowOpen);
}
}
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class GuiElementContainerHelp method recalcSize.
private void recalcSize() {
calc = true;
width = 0;
height = 0;
double w = 0;
double h = 0;
for (IGuiElement element : internalElements) {
w = Math.max(w, element.getEndX());
h = Math.max(h, element.getEndY());
}
width = w;
height = h;
calc = false;
}
use of buildcraft.lib.gui.IGuiElement in project BuildCraft by BuildCraft.
the class ElementType method deserialize.
public final IGuiElement deserialize(BuildCraftJsonGui gui, IGuiPosition parent, JsonGuiInfo info, JsonGuiElement json) {
IGuiElement element = deserialize0(gui, parent, info, json);
if (element instanceof GuiElementSimple) {
((GuiElementSimple) element).name = json.fullName;
}
gui.context.putConstant(json.fullName + ".pos", IGuiPosition.class, element);
gui.context.putConstant(json.fullName + ".area", IGuiArea.class, element);
gui.varData.addNodes(json.createTickableNodes());
List<IGuiElement> children = new ArrayList<>();
IContainingElement container;
if (element instanceof IContainingElement) {
container = (IContainingElement) element;
} else {
container = new GuiElementContainerResizing(gui, element);
container.getChildElements().add(element);
}
addChildren(gui, container.getChildElementPosition(), info, json, "children", children::add);
// Special case tooltips + help
if (json.json.has("help") && !(this instanceof ElementTypeHelp)) {
addType(gui, parent, info, json, "help", children::add, ElementTypeHelp.INSTANCE);
}
if (json.json.has("tooltip") && !(this instanceof ElementTypeToolTip)) {
addType(gui, parent, info, json, "tooltip", children::add, ElementTypeToolTip.INSTANCE);
}
if (!children.isEmpty()) {
element = container;
container.getChildElements().addAll(children);
container.calculateSizes();
}
return element;
}
Aggregations