public class GuiMenu extends GuiModalWindow
If there are more than 12 items, the menu displays them in chunks of 12, with an up and a down button to page among the chunks.
GuiMenu inherits all the behaviours and methods of GuiModalWindow, including the management of the mouse cursor, of click events, of the close button and of the 'display stack'.
If the autoClose parameter is set to true in the constructor, the menu will automatically 'pop' itself away, closing and freeing itself, when an item is clicked on. If the autoClose parameter is set to false, the menu will remain on the screen, and another GuiModalWindow can be 'pushed' above it, or it can be closed and freed manually.
Important: due to the way Rising World plug-ins are loaded, this class cannot instantiated or used in any way from within the onEnable() method of a plug-in, as it is impossible to be sure that, at that moment, the RWGui plug-in has already been loaded.
The first moment one can be sure that all plug-ins have been loaded, and it is safe to use this class, is when (or after) the first player connects to the server (either dedicated or local).
autoClose, callback, layout, listenerRef, plugin, prevWindow, titleBar
Constructor and Description |
---|
GuiMenu(net.risingworld.api.Plugin plugin,
java.lang.String titleText,
RWGui.RWGuiCallback callback)
Creates a new GuiMenu with autoClose enabled.
|
GuiMenu(net.risingworld.api.Plugin plugin,
java.lang.String titleText,
RWGui.RWGuiCallback callback,
boolean autoClose)
Creates a new GuiMenu.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(java.lang.String text,
java.lang.Integer id,
java.lang.Object data)
Adds a new menu item with the associated id and data.
|
int |
addItem(java.lang.String text,
java.lang.Integer id,
java.lang.Object data)
Deprecated.
|
int |
removeChild(int itemIndex)
Removes the menu item at the itemIndex index.
|
int |
removeChild(java.lang.String itemText)
Removes the first menu item with given item text.
|
int |
removeItem(int itemIndex)
Deprecated.
|
int |
removeItem(java.lang.String itemText)
Deprecated.
|
addChild, addChild, close, free, getItemId, layout, onClick, onTextEntry, pop, poppush, push, removeChild, setCallback, setMargin, setPadding, show
destroy, equals, getAlpha, getBorderColor, getBorderThickness, getColor, getHeight, getHoverColor, getID, getParent, getParentID, getPivot, getPositionX, getPositionY, getWidth, hashCode, isRelativeBorderThickness, isRelativePosition, isRelativeSize, isVisible, refresh, removeFromParent, setAlpha, setBorderColor, setBorderColor, setBorderThickness, setColor, setColor, setPivot, setPosition, setSize, setVisible
public GuiMenu(net.risingworld.api.Plugin plugin, java.lang.String titleText, RWGui.RWGuiCallback callback, boolean autoClose)
plugin
- the plug-in the GuiMenu is intended for. This
is only needed to manage the internal event listener
and has no effects on the plug-in itself.titleText
- the text of the title.callback
- the callback object to which to report events. Can
be null, but in this case no event will reported
until an actual callback object is set with the
setCallback() method.autoClose
- whether the menu should automatically close when an
item is selected or not.public GuiMenu(net.risingworld.api.Plugin plugin, java.lang.String titleText, RWGui.RWGuiCallback callback)
plugin
- the plug-in the GuiMenu is intended for. This
is only needed to manage the internal event listener
and has no effects on the plug-in itself.titleText
- the text of the title.callback
- the callback object to which to report events. Can
be null, but in this case no event will reported
until an actual callback object is set with the
setCallback() method.public void addChild(java.lang.String text, java.lang.Integer id, java.lang.Object data)
id can be any Integer and id's should be all different from one another within each dialogue box.
The data parameter can be any Java object and can store additional information required to deal with the element, when a click event is reported for it via the callback object. It can also be null if no additional info is needed for the element.
id and data are reported by the callback object upon click events.
text
- the text of the new menu item.id
- the id associated with the item.data
- the data associated with the element; may be null for
elements which need no additional data other than their id.@Deprecated public int addItem(java.lang.String text, java.lang.Integer id, java.lang.Object data)
public int removeChild(int itemIndex)
itemIndex
- the index of the menu item to remove.@Deprecated public int removeItem(int itemIndex)
public int removeChild(java.lang.String itemText)
If more items with the same text exist, only the first is removed.
itemText
- the text of the menu item to remove.@Deprecated public int removeItem(java.lang.String itemText)