Skip to content

Commit 5b8bac4

Browse files
committed
add method for additional children to the screen
1 parent 69e7add commit 5b8bac4

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/gregtech/api/metatileentity/multiblock/ui/MultiblockUIFactory.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public class MultiblockUIFactory {
5858
private int width = 198, height = 202;
5959
private int screenHeight = 109;
6060
private Supplier<IWidget> customScreen;
61+
private Consumer<List<IWidget>> childrenConsumer;
6162

6263
public MultiblockUIFactory(@NotNull MultiblockWithDisplayBase mte) {
6364
this.mte = mte;
@@ -285,6 +286,11 @@ public MultiblockUIFactory customScreen(Supplier<IWidget> customScreen) {
285286
return this;
286287
}
287288

289+
public MultiblockUIFactory addScreenChildren(Consumer<List<IWidget>> consumer) {
290+
this.childrenConsumer = consumer;
291+
return this;
292+
}
293+
288294
protected Widget<?> createScreen(PanelSyncManager syncManager) {
289295
ParentWidget<?> root = new ParentWidget<>();
290296
if (customScreen != null && customScreen.get() != null) {
@@ -294,14 +300,22 @@ protected Widget<?> createScreen(PanelSyncManager syncManager) {
294300
display.setAction(this.displayText);
295301
display.sync("display", syncManager);
296302

297-
root.child(new ScrollWidget<>(new VerticalScrollData())
303+
var scrollWidget = new ScrollWidget<>(new VerticalScrollData())
298304
.sizeRel(1f)
299305
.child(new RichTextWidget()
300306
.sizeRel(1f)
301307
.alignment(Alignment.TopLeft)
302308
.margin(4, 4)
303309
.autoUpdate(true)
304-
.textBuilder(display::build)));
310+
.textBuilder(display::build));
311+
312+
if (this.childrenConsumer != null) {
313+
List<IWidget> extra = new ArrayList<>();
314+
this.childrenConsumer.accept(extra);
315+
extra.forEach(scrollWidget::child);
316+
}
317+
318+
root.child(scrollWidget);
305319
}
306320

307321
return root.child(createIndicator(syncManager))

0 commit comments

Comments
 (0)