-
- All Implemented Interfaces:
public abstract class DataButtonGroupIf possible, use GuiBase.addButtonGroup rather than using this class directly!
This class provides an inheritance-based option to create your buttons, whereas addButtonGroup instead allows you to pass actions for creating/refreshing buttons and the action to execute.
base class defining a group of buttons with each button representing a possible date and the whole group representing a data set defined by the sum of data of all active buttons.
In other words, this represents a row (or column) of buttons. All buttons in that row perform the same action when clicked. When a button is clicked, that action is performed with the data of all active buttons.
buttons get activated/deactivated by the user by clicking on them when a button is clicked, executeAction gets called with the sum of data of all active buttons
If, for instance, we have two buttons with corresponding data 1 and respectively, and the user activates the first button,
[1]will be passed as data to the groupAction and 1 as triggeringButtonData. If the user then clicks the second button[1, 2], will be passed as data and 2 as triggeringButtonData.Extend this class by implementing createButtons, refresh and executeAction
-
-
Field Summary
Fields Modifier and Type Field Description private final List<DataToggleButton>buttonsprivate final LazyFontfontprivate StringdescriptionTextprivate final ButtonGroupLayoutlayout
-
Constructor Summary
Constructors Constructor Description DataButtonGroup(LazyFont font, String descriptionText, ButtonGroupLayout layout)
-
Method Summary
Modifier and Type Method Description final List<DataToggleButton>getButtons()final LazyFontgetFont()final StringgetDescriptionText()final UnitsetDescriptionText(String descriptionText)final ButtonGroupLayoutgetLayout()final UnitaddButton(String text, Object data, String tooltip, Boolean isActive)final UnitresetGrid()reset grid positions back to original values call this method if you want to e.g. final UnitdisableButton(String title)disable (i.e. final UnitrefreshAllButtons(List<Object> data)refresh state (active/inactive) of all buttons final UnitenableAllButtons()hopefully self-explanatory =) final List<Object>getActiveButtonData()final Booleanadvance()needs to be called every frame. final Unitrender()needs to be called every frame from a render-method, such as e.g. abstract UnitcreateButtons()Override me! abstract Unitrefresh()Override me! abstract UnitexecuteAction(List<Object> data, Object triggeringButtonData, Object deselectedButtonData)Override me! UnitonHover()Override this method to perform some action when the user hovers over a button in the group. -
-
Constructor Detail
-
DataButtonGroup
DataButtonGroup(LazyFont font, String descriptionText, ButtonGroupLayout layout)
- Parameters:
font- LazyFont objectdescriptionText- text to be rendered above the grouplayout- defines where/how the group gets rendered
-
-
Method Detail
-
getButtons
final List<DataToggleButton> getButtons()
-
getFont
final LazyFont getFont()
-
getDescriptionText
final String getDescriptionText()
-
setDescriptionText
final Unit setDescriptionText(String descriptionText)
- Parameters:
descriptionText- text to be rendered above the group
-
getLayout
final ButtonGroupLayout getLayout()
-
resetGrid
final Unit resetGrid()
reset grid positions back to original values call this method if you want to e.g. change something and recreate buttons
-
disableButton
final Unit disableButton(String title)
disable (i.e. grey out and make un-clickable) button with given title/text/name
-
refreshAllButtons
final Unit refreshAllButtons(List<Object> data)
refresh state (active/inactive) of all buttons
- Parameters:
data- all buttons where button data is contained in this list will be set to active
-
enableAllButtons
final Unit enableAllButtons()
hopefully self-explanatory =)
-
getActiveButtonData
final List<Object> getActiveButtonData()
-
advance
final Boolean advance()
needs to be called every frame. checks if a button was clicked/hovered over during that frame
-
render
final Unit render()
needs to be called every frame from a render-method, such as e.g. BaseEveryFrameCombatPlugin::renderInUICoords
-
createButtons
abstract Unit createButtons()
Override me! gets called on construction. Create all buttons belonging to this group in the implementation of this method. cf. CreateSimpleButtons for an example implementation.
-
refresh
abstract Unit refresh()
Override me! gets called whenever a button of any group gets pressed (or something calls for a re-render) If you e.g. want to enable/disable buttons or change tooltips based on the current state, implement that logic in this method. Otherwise, an empty method will do.
-
executeAction
abstract Unit executeAction(List<Object> data, Object triggeringButtonData, Object deselectedButtonData)
Override me! gets called whenever a button in this group gets clicked. Implement the actual logic you want your button group to perform in here.
- Parameters:
data- a list of the data of all currently active buttonstriggeringButtonData- data of the button that was clicked if it was turned active.deselectedButtonData- data of the button that was clicked if it was turned inactive.
-
-
-
-