Add status indicators

Allow removal of elements from gui containers
This commit is contained in:
johni0702
2015-10-04 21:15:06 +02:00
parent aa3eb463ee
commit fc4dc86355
3 changed files with 19 additions and 0 deletions

View File

@@ -40,6 +40,13 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
}
}.setSize(Integer.MAX_VALUE, 20);
/**
* This is not used by the replay module itself but may be used by other modules/extras to show
* when they're active.
*/
public final GuiPanel statusIndicatorPanel = new GuiPanel(this).setSize(100, 20)
.setLayout(new HorizontalLayout(HorizontalLayout.Alignment.RIGHT).setSpacing(5));
public GuiReplayOverlay(final ReplayHandler replayHandler) {
this.replayHandler = replayHandler;
@@ -49,6 +56,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
protected void layout(GuiReplayOverlay container, int width, int height) {
pos(topPanel, 10, 10);
size(topPanel, width - 20, 20);
pos(statusIndicatorPanel, width / 2, height - 25);
width(statusIndicatorPanel, width / 2 - 5);
}
});

View File

@@ -107,6 +107,14 @@ public abstract class AbstractGuiContainer<T extends AbstractGuiContainer<T>>
return getThis();
}
@Override
public T removeElement(GuiElement element) {
if (elements.remove(element) != null) {
layedOutElements.remove(element);
}
return getThis();
}
@Override
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
try {

View File

@@ -39,5 +39,6 @@ public interface GuiContainer<T extends GuiContainer<T>> extends ComposedGuiElem
Map<GuiElement, LayoutData> getElements();
T addElements(LayoutData layoutData, GuiElement...elements);
T removeElement(GuiElement element);
}