GaldurItemGrid
classclient onlysince 1.0.0com.galdurstudio.galdurui.api.widget.GaldurItemGrid
Themed scrolling item grid, to show thousands of items with their amounts: a storage network's contents, a catalogue, a recipe list...
These are not real menu slots: the grid only shows a list of Entry
and reports clicks. The mod keeps the list up to date (from server packets, for instance),
filters and sorts it, and sends the server what the player wants to do with a click. The list
is read every frame: it can change at any time without rebuilding the
widget.
List<GaldurItemGrid.Entry> contents = ...; // kept up to date by the modGaldurItemGrid grid = GaldurItemGrid.of(9, 6, () -> contents) .onClick((index, entry, button, shift) -> askServer(entry, button, shift));- Rendering: only the visible rows are drawn (columns × rows cells),
whatever the list size. Each cell uses the
slotsprite and the short amount ofGaldurItemSlot("64", "1,2k", "64k"). - Scrolling: by whole rows, with the wheel (one row per notch) or the scrollbar, which can be grabbed and dragged. The scrollbar only shows when the items do not fit.
- Hover:
accent_hoveroutline,accentveil and the item tooltip, with the exact amount above 1,000. - Click: left or right, with the Shift state, on an occupied cell.
- Disabled (
active = false): muted amounts, no click or hover; scrolling still works for browsing. - JEI / EMI: when one is installed, hovering an item and pressing R or U shows its recipes, on any screen.
Sizes from the theme: spacing.scrollbar_width. A cell is 18 × 18 pixels, like a
vanilla slot.
Fields 1
CELL_SIZE
staticSide of a cell, frame included.
Constructors 1
GaldurItemGrid
protectedPrefer of().
PARAMETERS
Methods 7
of
staticPARAMETERS
RETURNSGaldurItemGrid — a grid of columns × rows visible cells, scrollbar included, at
(0, 0) for a layout to place
onClick
Sets the action triggered by a click on an occupied cell. Only one action is kept.
PARAMETERS
RETURNSGaldurItemGrid — this grid, for chaining
onScroll
Sets the action called when the first visible row changes, to keep it when the widget is rebuilt (resize). Only one action is kept.
PARAMETERS
RETURNSGaldurItemGrid — this grid, for chaining
getScrollRow
RETURNSint — the first visible row
setScrollRow
Scrolls the grid, clamped between the first and the last possible row.
PARAMETERS
getEntryAt
PARAMETERS
RETURNSEntry — the item under the mouse, or null
getCellAreaAt
PARAMETERS
RETURNSRect2i — the screen-space bounds of the occupied cell under this point, or null
Nested types 2
Entry
An item shown by the grid.
ClickHandler
Action triggered by a click on an occupied cell.