endstone/form
Classes
| Name | Description |
|---|---|
ActionForm | Represents a form with buttons that let the player take action. |
Button | Represents a button with text and an optional icon. |
Divider | Represents a divider. |
Dropdown | Represents a dropdown with a set of predefined options. |
Form | Represents a generic form. |
Header | Represents a header with a label. |
Label | Represents a text label. |
MessageForm | Represents a form with two buttons. |
ModalForm | Represents a modal form with controls. |
Slider | Represents a slider with a label. |
StepSlider | Represents a step slider with a set of predefined options. |
TextInput | Represents a text input field. |
Toggle | Represents a toggle button with a label. |
classActionForm
Defined in <endstone/form/action_form.h>
Bases: Form<ActionForm>
Represents a form with buttons that let the player take action.
Type Aliases
| Name | Description |
|---|---|
Control | |
OnSubmitCallback |
Methods
| Name | Description |
|---|---|
ActionForm | |
getContent | Get the content of the form. |
setContent | Set the content of the form. |
addButton | Adds a button to the form. |
addLabel | Adds a label to the form. |
addHeader | Adds a header to the form. |
addDivider | Adds a divider to the form. |
getControls | Get the controls of the action form. |
setControls | Set the controls of the action form. |
getOnSubmit | Gets the on submit callback of the form. |
setOnSubmit | Sets the on submit callback of the form. |
typeControl
std::variant<Button, Divider, Header, Label> ControltypeOnSubmitCallback
std::function<void(Player*, int)> OnSubmitCallbackmethActionFormexplicit
ActionForm() =defaultmethgetContentconst
Message getContent() constGet the content of the form.
Returns
| Type | Description |
|---|---|
Message | The content of the form. |
methsetContent
ActionForm& setContent(Message text)Set the content of the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The text to set as the content. |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methaddButton
ActionForm& addButton(const Message& text, const std::optional<std::string>& icon = std::nullopt, Button::OnClickCallback on_click = {})Adds a button to the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | const Message& | The text of the button |
icon | const std::optional<std::string>& | The path or URL to the icon image |
on_click | Button::OnClickCallback | The on click callback of the button |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methaddLabel
ActionForm& addLabel(const Message& text)Adds a label to the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | const Message& | The text of the label |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methaddHeader
ActionForm& addHeader(const Message& text)Adds a header to the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | const Message& | The text of the header |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methaddDivider
ActionForm& addDivider()Adds a divider to the form.
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methgetControlsconst
const std::vector<Control>& getControls() constGet the controls of the action form.
Returns
| Type | Description |
|---|---|
const std::vector<Control>& | A list of controls in the action form. |
methsetControls
ActionForm& setControls(const std::vector<Control>& controls)Set the controls of the action form.
Parameters
| Name | Type | Description |
|---|---|---|
controls | const std::vector<Control>& | The list of controls to set. |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
methgetOnSubmitconst
OnSubmitCallback getOnSubmit() constGets the on submit callback of the form.
Returns
| Type | Description |
|---|---|
OnSubmitCallback | The on submit callback of the form. |
methsetOnSubmit
ActionForm& setOnSubmit(OnSubmitCallback on_submit)Sets the on submit callback of the form.
Parameters
| Name | Type | Description |
|---|---|---|
on_submit | OnSubmitCallback | The callback to be set. |
Returns
| Type | Description |
|---|---|
ActionForm& | A reference to the current form. |
classButton
Defined in <endstone/form/controls/button.h>
Represents a button with text and an optional icon.
Type Aliases
| Name | Description |
|---|---|
OnClickCallback |
Methods
| Name | Description |
|---|---|
Button | |
Button | |
getText | Gets the text of the button. |
setText | Sets the text of the button. |
getIcon | Get the icon of the button. |
setIcon | Sets the icon for the button. |
getOnClick | Gets the on click callback of the button. |
setOnClick | Sets the on click callback of the button. |
typeOnClickCallback
std::function<void(Player*)> OnClickCallbackmethButton
Button() =defaultmethButtonexplicit
Button(Message text, std::optional<std::string> icon = std::nullopt, OnClickCallback on_click = {})methgetTextconst
Message getText() constGets the text of the button.
Returns
| Type | Description |
|---|---|
Message | The text. |
methsetText
Sets the text of the button.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The new text for the button. |
Returns
| Type | Description |
|---|---|
Button& | A reference to the current button. |
methgetIconconst
std::optional<std::string> getIcon() constGet the icon of the button.
Returns
| Type | Description |
|---|---|
std::optional<std::string> | The path or URL to the icon file |
methsetIcon
Button& setIcon(std::string icon)Sets the icon for the button.
Parameters
| Name | Type | Description |
|---|---|---|
icon | std::string | The path or URL to the icon file. |
Returns
| Type | Description |
|---|---|
Button& | A reference to the current button. |
methgetOnClickconst
OnClickCallback getOnClick() constGets the on click callback of the button.
Returns
| Type | Description |
|---|---|
OnClickCallback | The on click callback of the button. |
methsetOnClick
Button& setOnClick(OnClickCallback on_click)Sets the on click callback of the button.
Parameters
| Name | Type | Description |
|---|---|---|
on_click | OnClickCallback | The callback to be set. |
Returns
| Type | Description |
|---|---|
Button& | A reference to the current button. |
classDivider
Defined in <endstone/form/controls/divider.h>
Represents a divider.
Methods
| Name | Description |
|---|---|
Divider |
methDivider
Divider() =defaultclassDropdown
Defined in <endstone/form/controls/dropdown.h>
Represents a dropdown with a set of predefined options.
Methods
| Name | Description |
|---|---|
Dropdown | |
Dropdown | |
getLabel | Gets the label of the dropdown. |
setLabel | Sets the label of the dropdown. |
addOption | Adds a new option to the dropdown. |
getOptions | Gets the options of the dropdown. |
setOptions | Sets the options of the dropdown. |
getDefaultIndex | Gets the default index of the dropdown. |
setDefaultIndex | Sets the default index of the dropdown. |
methDropdown
Dropdown() =defaultmethDropdownexplicit
Dropdown(Message label, std::vector<std::string> options, std::optional<int> default_index = std::nullopt)methgetLabelconst
Message getLabel() constGets the label of the dropdown.
Returns
| Type | Description |
|---|---|
Message | The label of the dropdown. |
methsetLabel
Sets the label of the dropdown.
Parameters
| Name | Type | Description |
|---|---|---|
label | Message | The new label for the dropdown. |
Returns
| Type | Description |
|---|---|
Dropdown& | A reference to the dropdown itself. |
methaddOption
Dropdown& addOption(const std::string& option)Adds a new option to the dropdown.
Parameters
| Name | Type | Description |
|---|---|---|
option | const std::string& | The new option for the dropdown. |
Returns
| Type | Description |
|---|---|
Dropdown& | A reference to the dropdown itself. |
methgetOptionsconst
std::vector<std::string> getOptions() constGets the options of the dropdown.
Returns
| Type | Description |
|---|---|
std::vector<std::string> | The options of the dropdown. |
methsetOptions
Dropdown& setOptions(std::vector<std::string> options)Sets the options of the dropdown.
Parameters
| Name | Type | Description |
|---|---|---|
options | std::vector<std::string> | The new options for the dropdown. |
Returns
| Type | Description |
|---|---|
Dropdown& | A reference to the dropdown itself. |
methgetDefaultIndexconst
std::optional<int> getDefaultIndex() constGets the default index of the dropdown.
Returns
| Type | Description |
|---|---|
std::optional<int> | The default index of the dropdown. |
methsetDefaultIndex
Dropdown& setDefaultIndex(std::optional<int> default_index)Sets the default index of the dropdown.
Parameters
| Name | Type | Description |
|---|---|---|
default_index | std::optional<int> | The new default index for the dropdown. |
Returns
| Type | Description |
|---|---|
Dropdown& | A reference to the dropdown itself. |
classForm
Defined in <endstone/form/form.h>
Represents a generic form.
The Form class provides a base abstraction for different types of forms. It supports three types of forms: Action, Message, and Modal. Each form has a title, which can be a string or a translatable object.
Type Aliases
| Name | Description |
|---|---|
OnCloseCallback |
Methods
| Name | Description |
|---|---|
Form | |
getTitle | Gets the title of the form. |
setTitle | Sets the title of the form. |
setOnClose | Sets the on close callback of the form. |
getOnClose | Gets the on close callback of the form. |
typeOnCloseCallback
std::function<void(Player*)> OnCloseCallbackvartitle_protected
Message title_varon_close_protected
OnCloseCallback on_close_methFormexplicit
Form() =defaultmethgetTitleconst
Message getTitle() constGets the title of the form.
Returns
| Type | Description |
|---|---|
Message | The title of the form. |
methsetTitle
T& setTitle(Message title)Sets the title of the form.
Parameters
| Name | Type | Description |
|---|---|---|
title | Message | The title of the form to be set. |
Returns
| Type | Description |
|---|---|
T& | A reference to the current form. |
methsetOnClose
T& setOnClose(OnCloseCallback on_close)Sets the on close callback of the form.
Parameters
| Name | Type | Description |
|---|---|---|
on_close | OnCloseCallback | The callback to be set. |
Returns
| Type | Description |
|---|---|
T& | A reference to the current form. |
methgetOnCloseconst
OnCloseCallback getOnClose() constGets the on close callback of the form.
Returns
| Type | Description |
|---|---|
OnCloseCallback | The on close callback of the form. |
classHeader
Defined in <endstone/form/controls/header.h>
Represents a header with a label.
Methods
methHeader
Header() =defaultmethHeaderexplicit
Header(Message label)methgetLabelconst
Message getLabel() constGets the label of the header.
Returns
| Type | Description |
|---|---|
Message | The label of the header. |
methsetLabel
Sets the label of the header.
Parameters
| Name | Type | Description |
|---|---|---|
label | Message | The new label for the header. |
Returns
| Type | Description |
|---|---|
Header& | A reference to the current header. |
classLabel
Defined in <endstone/form/controls/label.h>
Represents a text label.
Methods
methLabel
Label() =defaultmethLabelexplicit
Label(Message text)methgetTextconst
Message getText() constGets the text of the label.
Returns
| Type | Description |
|---|---|
Message | The text of the label. |
methsetText
Sets the text of the label.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The new text for the label. |
Returns
| Type | Description |
|---|---|
Label& | A reference to the current label. |
classMessageForm
Defined in <endstone/form/message_form.h>
Bases: Form<MessageForm>
Represents a form with two buttons.
Type Aliases
| Name | Description |
|---|---|
OnSubmitCallback |
Methods
| Name | Description |
|---|---|
getContent | Get the content of the form. |
setContent | Set the content of the form. |
getButton1 | Get the text of button1. |
setButton1 | Set the text of button1. |
getButton2 | Get the text of button2. |
setButton2 | Set the text of button2. |
getOnSubmit | Gets the on submit callback of the form. |
setOnSubmit | Sets the on submit callback of the form. |
typeOnSubmitCallback
std::function<void(Player*, int)> OnSubmitCallbackmethgetContentconst
Message getContent() constGet the content of the form.
Returns
| Type | Description |
|---|---|
Message | The content of the form. |
methsetContent
MessageForm& setContent(Message text)Set the content of the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The text to set as the content. |
Returns
| Type | Description |
|---|---|
MessageForm& | A reference to the current form. |
methgetButton1const
Message getButton1() constGet the text of button1.
Returns
| Type | Description |
|---|---|
Message | The text of button1. |
methsetButton1
MessageForm& setButton1(Message text)Set the text of button1.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The text to set as the button1 text. |
Returns
| Type | Description |
|---|---|
MessageForm& | A reference to the current form. |
methgetButton2const
Message getButton2() constGet the text of button2.
Returns
| Type | Description |
|---|---|
Message | The text of button2. |
methsetButton2
MessageForm& setButton2(Message text)Set the text of button2.
Parameters
| Name | Type | Description |
|---|---|---|
text | Message | The text to set as the button2 text. |
Returns
| Type | Description |
|---|---|
MessageForm& | A reference to the current form. |
methgetOnSubmitconst
OnSubmitCallback getOnSubmit() constGets the on submit callback of the form.
Returns
| Type | Description |
|---|---|
OnSubmitCallback | The on submit callback of the form. |
methsetOnSubmit
MessageForm& setOnSubmit(OnSubmitCallback on_submit)Sets the on submit callback of the form.
Parameters
| Name | Type | Description |
|---|---|---|
on_submit | OnSubmitCallback | The callback to be set. |
Returns
| Type | Description |
|---|---|
MessageForm& | A reference to the current form. |
classModalForm
Defined in <endstone/form/modal_form.h>
Represents a modal form with controls.
Type Aliases
| Name | Description |
|---|---|
Control | |
OnSubmitCallback |
Methods
| Name | Description |
|---|---|
addControl | Adds a control to the form. |
getControls | Gets the controls of the modal form. |
setControls | Sets the controls of the modal form. |
getSubmitButton | Gets the submit button text of the form. |
setSubmitButton | Sets the submit button text of the form. |
getIcon | Get the icon of the form. |
setIcon | Sets the icon of the form. |
getOnSubmit | Gets the on submit callback of the form. |
setOnSubmit | Sets the on submit callback of the form. |
typeControl
std::variant<Dropdown, Label, Slider, StepSlider, TextInput, Toggle, Divider, Header> ControltypeOnSubmitCallback
std::function<void(Player*, std::string)> OnSubmitCallbackmethaddControl
Adds a control to the form.
Parameters
| Name | Type | Description |
|---|---|---|
control | const Control& | The control to add to the form. |
Returns
| Type | Description |
|---|---|
ModalForm& | A reference to the current form. |
methgetControlsconst
std::vector<Control> getControls() constGets the controls of the modal form.
Returns
| Type | Description |
|---|---|
std::vector<Control> | A list of controls in the modal form. |
methsetControls
ModalForm& setControls(std::vector<Control> controls)Sets the controls of the modal form.
Parameters
| Name | Type | Description |
|---|---|---|
controls | std::vector<Control> | The list of controls to set. |
Returns
| Type | Description |
|---|---|
ModalForm& | A reference to the current form. |
methgetSubmitButtonconst
std::optional<Message> getSubmitButton() constGets the submit button text of the form.
Returns
| Type | Description |
|---|---|
std::optional<Message> | The submit button text of the form. |
methsetSubmitButton
ModalForm& setSubmitButton(std::optional<Message> text)Sets the submit button text of the form.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::optional<Message> | The submit button text to set. |
Returns
| Type | Description |
|---|---|
ModalForm& | A reference to the current form. |
methgetIconconst
std::optional<std::string> getIcon() constGet the icon of the form.
Returns
| Type | Description |
|---|---|
std::optional<std::string> | The path or URL to the icon file |
methsetIcon
ModalForm& setIcon(std::optional<std::string> icon)Sets the icon of the form.
Parameters
| Name | Type | Description |
|---|---|---|
icon | std::optional<std::string> | The path or URL to the icon file. |
Returns
| Type | Description |
|---|---|
ModalForm& | A reference to the current form. |
methgetOnSubmitconst
OnSubmitCallback getOnSubmit() constGets the on submit callback of the form.
Returns
| Type | Description |
|---|---|
OnSubmitCallback | The on submit callback of the form. |
methsetOnSubmit
ModalForm& setOnSubmit(OnSubmitCallback on_submit)Sets the on submit callback of the form.
Parameters
| Name | Type | Description |
|---|---|---|
on_submit | OnSubmitCallback | The callback to be set. |
Returns
| Type | Description |
|---|---|
ModalForm& | A reference to the current form. |
classSlider
Defined in <endstone/form/controls/slider.h>
Represents a slider with a label.
Methods
| Name | Description |
|---|---|
Slider | |
Slider | |
getLabel | Gets the label of the toggle. |
setLabel | Sets the label of the toggle. |
getMin | Gets the minimum value of the slider. |
setMin | Sets the minimum value of the slider. |
getMax | Gets the maximum value of the slider. |
setMax | Sets the maximum value of the slider. |
getStep | Gets the step size of the slider. |
setStep | Sets the step size of the slider. |
getDefaultValue | Gets the default value of the slider. |
setDefaultValue | Sets the default value of the slider. |
methSlider
Slider() =defaultmethSliderexplicit
Slider(Message label, float min, float max, float step, std::optional<float> default_value = std::nullopt)methgetLabelconst
Message getLabel() constGets the label of the toggle.
Returns
| Type | Description |
|---|---|
Message | The label of the toggle. |
methsetLabel
Sets the label of the toggle.
Parameters
| Name | Type | Description |
|---|---|---|
label | Message | The new label for the toggle. |
Returns
| Type | Description |
|---|---|
Slider& | A reference to the current toggle. |
methgetMinconst
float getMin() constGets the minimum value of the slider.
Returns
| Type | Description |
|---|---|
float | The minimum value of the slider. |
methsetMin
Slider& setMin(float min)Sets the minimum value of the slider.
Parameters
| Name | Type | Description |
|---|---|---|
min | float | The new minimum value for the slider. |
Returns
| Type | Description |
|---|---|
Slider& | A reference to the current slider, for function chaining. |
methgetMaxconst
float getMax() constGets the maximum value of the slider.
Returns
| Type | Description |
|---|---|
float | The maximum value of the slider. |
methsetMax
Slider& setMax(float max)Sets the maximum value of the slider.
Parameters
| Name | Type | Description |
|---|---|---|
max | float | The new maximum value for the slider. |
Returns
| Type | Description |
|---|---|
Slider& | A reference to the current slider, for function chaining. |
methgetStepconst
float getStep() constGets the step size of the slider.
Returns
| Type | Description |
|---|---|
float | The step size of the slider. |
methsetStep
Slider& setStep(float step)Sets the step size of the slider.
Parameters
| Name | Type | Description |
|---|---|---|
step | float | The new step size for the slider. |
Returns
| Type | Description |
|---|---|
Slider& | A reference to the current slider, for function chaining. |
methgetDefaultValueconst
std::optional<float> getDefaultValue() constGets the default value of the slider.
Returns
| Type | Description |
|---|---|
std::optional<float> | The default value of the slider. |
methsetDefaultValue
Slider& setDefaultValue(std::optional<float> default_value)Sets the default value of the slider.
Parameters
| Name | Type | Description |
|---|---|---|
default_value | std::optional<float> | The new default value for the slider. |
Returns
| Type | Description |
|---|---|
Slider& | A reference to the current slider, for function chaining. |
classStepSlider
Defined in <endstone/form/controls/step_slider.h>
Bases: Dropdown
Represents a step slider with a set of predefined options.
methDropdown
Dropdown() =defaultmethDropdownexplicit
Dropdown(Message label, std::vector<std::string> options, std::optional<int> default_index = std::nullopt)classTextInput
Defined in <endstone/form/controls/text_input.h>
Represents a text input field.
Methods
| Name | Description |
|---|---|
TextInput | |
TextInput | |
getLabel | Gets the label of the text input field. |
setLabel | Sets the label of the text input field. |
getPlaceholder | Gets the placeholder of the text input field. |
setPlaceholder | Sets the placeholder of the text input field. |
getDefaultValue | Gets the default text of the text input field. |
setDefaultValue | Sets the default text of the text input field. |
methTextInput
TextInput() =defaultmethTextInputexplicit
TextInput(Message label, Message placeholder, std::optional<std::string> default_text = std::nullopt)methgetLabelconst
Message getLabel() constGets the label of the text input field.
Returns
| Type | Description |
|---|---|
Message | The label of the text input field. |
methsetLabel
Sets the label of the text input field.
Parameters
| Name | Type | Description |
|---|---|---|
label | Message | The new label for the text input field. |
Returns
| Type | Description |
|---|---|
TextInput& | A reference to the text input field itself. |
methgetPlaceholderconst
Message getPlaceholder() constGets the placeholder of the text input field.
Returns
| Type | Description |
|---|---|
Message | The placeholder of the text input field. |
methsetPlaceholder
Sets the placeholder of the text input field.
Parameters
| Name | Type | Description |
|---|---|---|
placeholder | Message | The new placeholder for the text input field. |
Returns
| Type | Description |
|---|---|
TextInput& | A reference to the text input field itself. |
methgetDefaultValueconst
std::optional<std::string> getDefaultValue() constGets the default text of the text input field.
Returns
| Type | Description |
|---|---|
std::optional<std::string> | The default text of the text input field. |
methsetDefaultValue
TextInput& setDefaultValue(std::optional<std::string> text)Sets the default text of the text input field.
Parameters
| Name | Type | Description |
|---|---|---|
text | std::optional<std::string> | The new default text for the text input field. |
Returns
| Type | Description |
|---|---|
TextInput& | A reference to the text input field itself. |
classToggle
Defined in <endstone/form/controls/toggle.h>
Represents a toggle button with a label.
Methods
| Name | Description |
|---|---|
Toggle | |
Toggle | |
getLabel | Gets the label of the toggle. |
setLabel | Sets the label of the toggle. |
getDefaultValue | Gets the default value of the toggle. |
setDefaultValue | Sets the default value of the toggle. |
methToggle
Toggle() =defaultmethToggleexplicit
Toggle(Message label, bool default_value = false)methgetLabelconst
Message getLabel() constGets the label of the toggle.
Returns
| Type | Description |
|---|---|
Message | The label of the toggle. |
methsetLabel
Sets the label of the toggle.
Parameters
| Name | Type | Description |
|---|---|---|
label | Message | The new label for the toggle. |
Returns
| Type | Description |
|---|---|
Toggle& | A reference to the current toggle. |
methgetDefaultValueconst
bool getDefaultValue() constGets the default value of the toggle.
Returns
| Type | Description |
|---|---|
bool | The default value of the toggle. |
methsetDefaultValue
Toggle& setDefaultValue(bool value)Sets the default value of the toggle.
Parameters
| Name | Type | Description |
|---|---|---|
value | bool | The new default value for the toggle. |
Returns
| Type | Description |
|---|---|
Toggle& | A reference to the current toggle. |