MagicCombatDataButtonGroup

abstract class MagicCombatDataButtonGroup(val font: <Error class: unknown class>?, var descriptionText: String, val layout: MagicCombatButtonGroupLayout)

If possible, use org.magiclib.combatgui.MagicCombatGuiBase.addButtonGroup rather than using this class directly!

This class provides an inheritance-based option to create your buttons, whereas org.magiclib.combatgui.MagicCombatGuiBase.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

Author

Jannes

Since

1.3.0

Parameters

font

LazyFont object

descriptionText

text to be rendered above the group

layout

defines where/how the group gets rendered

Constructors

Link copied to clipboard
constructor(font: <Error class: unknown class>?, descriptionText: String, layout: MagicCombatButtonGroupLayout)

Functions

Link copied to clipboard
fun addButton(text: String, data: Any, tooltip: String, isActive: Boolean = true)

Add a new button to a button group

Link copied to clipboard

Needs to be called every frame. Checks if a button was clicked/hovered over during that frame

Link copied to clipboard
abstract fun createButtons()

Override me! Gets called on construction. Create all buttons belonging to this group in the implementation of this method. Check MagicCombatCreateSimpleButtons for an example implementation.

Link copied to clipboard
fun disableButton(title: String)

Disable (i.e. grey out and make un-clickable) button with given title/text/name

Link copied to clipboard

Hopefully self-explanatory =)

Link copied to clipboard
abstract fun executeAction(data: List<Any>, triggeringButtonData: Any? = null, deselectedButtonData: Any? = null)

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.

Link copied to clipboard
Link copied to clipboard
open fun onHover()

Override this method to perform some action when the user hovers over a button in the group.

Link copied to clipboard
abstract fun 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.

Link copied to clipboard

Refresh state (active/inactive) of all buttons

Link copied to clipboard
fun render()

Needs to be called every frame from a render-method, such as e.g. com.fs.starfarer.api.combat.BaseEveryFrameCombatPlugin.renderInUICoords

Link copied to clipboard
fun resetGrid()

Reset grid positions back to original values. Call this method if you want to e.g. change something and recreate buttons

Properties

Link copied to clipboard
val buttons: <Error class: unknown class>
Link copied to clipboard
Link copied to clipboard
val font: <Error class: unknown class>?
Link copied to clipboard