Class Layout
java.lang.Object
me.agent.vgui.api.contents.Layout
A character-mask layout for a view. Each string is one row; each character is one slot.
Map characters to items with
where(char, ViewItem), then apply the layout via
ViewContents.applyLayout(Layout) or a
ViewBuilder.
The characters '.' and ' ' always mean "leave the slot empty" and
cannot be mapped. Unmapped characters are also left empty, which makes them useful as
named regions for Pagination.slots(Layout, char).
Layout layout = Layout.of(
"#########",
"#ppppppp#",
"#ppppppp#",
"#<..c..>#")
.where('#', ViewItem.of(filler))
.where('<', ViewItem.pagePrevious(prevArrow))
.where('>', ViewItem.pageNext(nextArrow))
.where('c', ViewItem.closeButton(barrier));
-
Method Summary
Modifier and TypeMethodDescriptioncharcharAt(int slot) The character at a flat slot index.intcolumns()Number of columns (length of each row string).static LayoutCreates a layout from row strings.static LayoutCreates a layout from row strings.resolve()Resolves the layout to a map of flat slot index to item, in reading order.introws()Number of rows in this layout.intsize()Total number of slots covered by this layout.int[]slotsOf(char character) All flat slot indexes whose layout character equalscharacter, in reading order.Maps a character to an item.
-
Method Details
-
of
-
of
-
where
Maps a character to an item. Passingnullremoves the mapping.- Throws:
IllegalArgumentException- for'.'or' '(always empty)
-
rows
public int rows()Number of rows in this layout. -
columns
public int columns()Number of columns (length of each row string). -
size
public int size()Total number of slots covered by this layout. -
charAt
public char charAt(int slot) The character at a flat slot index. -
slotsOf
public int[] slotsOf(char character) All flat slot indexes whose layout character equalscharacter, in reading order. -
resolve
-