Show message while loading itempanel (#286)

* Show message while loading itempanel

* Move to ItemsGrid

* Add bookmark message

* ItemList

* Revert "Add bookmark message"

This reverts commit 030b5ed1ef.

* Item List

* Use Label

* clean
This commit is contained in:
miozune authored and GitHub committed 2022-08-31 10:43:22 +02:00
1 parent 748cfe3754
commit e93d23e444
6 files changed
+36

No files matched your search

@@ -41,6 +41,8 @@ public class ItemsGrid {
protected boolean[] invalidSlotMap;
protected Label messageLabel = new Label(getMessageOnEmpty(), true);
@Nullable
private Framebuffer framebuffer = null;
@@ -104,6 +106,9 @@ public class ItemsGrid {
rows = height / SLOT_SIZE;
paddingLeft = (width % SLOT_SIZE) / 2;
messageLabel.x = marginLeft + width / 2;
messageLabel.y = marginTop + height / 2;
}
public void shiftPage(int shift) {
@@ -305,6 +310,12 @@ public class ItemsGrid {
}
}
public void setVisible() {
if (getItems().isEmpty() && getMessageOnEmpty() != null) {
LayoutManager.addWidget(messageLabel);
}
}
protected void drawItem(Rectangle4i rect, int idx) {
GuiContainerManager.drawItem(rect.x + 1, rect.y + 1, getItem(idx));
}
@@ -345,4 +356,8 @@ public class ItemsGrid {
return r >= rows || c >= columns || !isInvalidSlot(slt);
}
public String getMessageOnEmpty() {
return null;
}
}