use of de.johni0702.minecraft.gui.element.ComposedGuiElement in project jGui by ReplayMod.
the class AbstractGuiContainer method draw.
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
super.draw(renderer, size, renderInfo);
if (backgroundColor != null && renderInfo.getLayer() == 0) {
renderer.drawRect(0, 0, size.getWidth(), size.getHeight(), backgroundColor);
}
for (final Map.Entry<GuiElement, Pair<ReadablePoint, ReadableDimension>> e : layedOutElements.entrySet()) {
GuiElement element = e.getKey();
boolean strict;
if (element instanceof ComposedGuiElement) {
if (((ComposedGuiElement) element).getMaxLayer() < renderInfo.layer) {
continue;
}
strict = renderInfo.layer == 0;
} else {
if (element.getLayer() != renderInfo.layer) {
continue;
}
strict = true;
}
final ReadablePoint ePosition = e.getValue().getLeft();
final ReadableDimension eSize = e.getValue().getRight();
try {
OffsetGuiRenderer eRenderer = new OffsetGuiRenderer(renderer, ePosition, eSize, strict);
eRenderer.startUsing();
e.getKey().draw(eRenderer, eSize, renderInfo.offsetMouse(ePosition.getX(), ePosition.getY()).layer(renderInfo.getLayer() - e.getKey().getLayer()));
eRenderer.stopUsing();
} catch (Exception ex) {
CrashReport crashReport = CrashReport.create(ex, "Rendering Gui");
renderInfo.addTo(crashReport);
CrashReportSection category = crashReport.addElement("Gui container details");
MCVer.addDetail(category, "Container", this::toString);
MCVer.addDetail(category, "Width", () -> "" + size.getWidth());
MCVer.addDetail(category, "Height", () -> "" + size.getHeight());
MCVer.addDetail(category, "Layout", layout::toString);
category = crashReport.addElement("Gui element details");
MCVer.addDetail(category, "Element", () -> e.getKey().toString());
MCVer.addDetail(category, "Position", ePosition::toString);
MCVer.addDetail(category, "Size", eSize::toString);
if (e.getKey() instanceof GuiContainer) {
MCVer.addDetail(category, "Layout", () -> ((GuiContainer) e.getKey()).getLayout().toString());
}
throw new CrashException(crashReport);
}
}
}
use of de.johni0702.minecraft.gui.element.ComposedGuiElement in project jGui by ReplayMod.
the class AbstractGuiContainer method layout.
@Override
public void layout(ReadableDimension size, RenderInfo renderInfo) {
super.layout(size, renderInfo);
if (size == null)
return;
try {
layedOutElements = layout.layOut(this, size);
} catch (Exception ex) {
CrashReport crashReport = CrashReport.create(ex, "Gui Layout");
renderInfo.addTo(crashReport);
CrashReportSection category = crashReport.addElement("Gui container details");
MCVer.addDetail(category, "Container", this::toString);
MCVer.addDetail(category, "Layout", layout::toString);
throw new CrashException(crashReport);
}
for (final Map.Entry<GuiElement, Pair<ReadablePoint, ReadableDimension>> e : layedOutElements.entrySet()) {
GuiElement element = e.getKey();
if (element instanceof ComposedGuiElement) {
if (((ComposedGuiElement) element).getMaxLayer() < renderInfo.layer) {
continue;
}
} else {
if (element.getLayer() != renderInfo.layer) {
continue;
}
}
ReadablePoint ePosition = e.getValue().getLeft();
ReadableDimension eSize = e.getValue().getRight();
element.layout(eSize, renderInfo.offsetMouse(ePosition.getX(), ePosition.getY()).layer(renderInfo.getLayer() - element.getLayer()));
}
}
Aggregations