package io.github.moulberry.notenoughupdates.mbgui; import org.lwjgl.util.vector.Vector2f; import java.util.*; public class MBGuiGroupFloating extends MBGuiGroup { private LinkedHashMap children; public MBGuiGroupFloating(int width, int height, LinkedHashMap children) { this.width = width; this.height = height; this.children = children; recalculate(); } public Map getChildrenMap() { return Collections.unmodifiableMap(children); } @Override public void recalculate() { for(MBGuiElement child : children.keySet()) { child.recalculate(); } for(Map.Entry entry : children.entrySet()) { MBGuiElement child = entry.getKey(); MBAnchorPoint anchorPoint = entry.getValue(); float x = anchorPoint.anchorPoint.x * width - anchorPoint.anchorPoint.x * child.getWidth() + anchorPoint.offset.x; float y = anchorPoint.anchorPoint.y * height - anchorPoint.anchorPoint.y * child.getHeight() + anchorPoint.offset.y; childrenPosition.put(child, new Vector2f(x, y)); } } @Override public Collection getChildren() { return children.keySet(); } }