Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private static Button createTestGuiButton(final int order,
final ResourceLocation testGuiResLoc,
final Consumer<BOWindow>... setups)
{
final Button button = new ButtonImage();
final Button button = new ButtonImage(true);
button.setPosition((order % 2) * (button.getWidth() + 20), (order / 2) * (button.getHeight() + 10));
button.setText(Component.literal(name));
button.setHandler(b -> {
Expand Down
7 changes: 2 additions & 5 deletions src/main/java/com/ldtteam/blockui/mod/ScrollingListsGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

/**
Expand Down Expand Up @@ -131,7 +130,6 @@ public void updateElement(final int index, final Pane rowPane)
window.findPaneOfTypeByID("list4remove", Button.class).setHandler(button -> renderAmount.getAndAdd(-2));

// Case 5: A list that will not update
final AtomicBoolean shouldRenderFlag = new AtomicBoolean();
final ScrollingList list5 = window.findPaneOfTypeByID("list5", ScrollingList.class);
list5.setDataProvider(new DataProvider()
{
Expand All @@ -144,17 +142,16 @@ public int getElementCount()
@Override
public boolean shouldUpdate()
{
return shouldRenderFlag.get();
return false;
}

@Override
public void updateElement(final int index, final Pane rowPane)
{
shouldRenderFlag.set(false);
rowPane.findPaneByType(Text.class).setText(Component.literal("Hi " + index + " " + UUID.randomUUID()));
}
});

window.findPaneOfTypeByID("list5update", Button.class).setHandler(button -> shouldRenderFlag.set(true));
window.findPaneOfTypeByID("list5update", Button.class).setHandler(button -> list5.refreshElementPanes(true));
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/blockui/gui/test4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<button id="list4add" pos="480 200" size="160 20" label="Add item"/>
<button id="list4remove" pos="480 220" size="160 20" label="Remove item"/>
<list id="list5" size="160 200" pos="0 240" emptytext="This list is empty" emptyscale="0.8" emptycolor="white">
<label size="152 20"/>
<text size="152 20"/>
</list>
<button id="list5update" pos="0 440" size="160 20" label="Update list"/>
</window>
</window>