The dialog object

From Scenario League Wiki
Jump to navigationJump to search

Back To TOTPP Functions

title (get/set)

dialog.title -> string

Returns the title of the dialog.


width (get/set)

dialog.width -> integer

Returns the width of the dialog.


height (get/set)

dialog.height -> integer

Returns the height of the dialog. Normally this does not need to be set, since the height is automatically calculated from the height of the items.


addText

dialog:addText(string)

Adds a static text string to the dialog.


addOption

dialog:addOption(string, id)

Adds a selectable option to the dialog, with label given by `string`. `id` is an integer value returned by dialog:show if this option was selected. Can not be used in conjunction with dialog:addCheckbox.


addCheckbox

dialog:addCheckbox(string, id, initial=false)

Adds a checkbox to the dialog, with label given by `string`. `id` is an integer value that can be used in dialog:getCheckboxState to retrieve the state after calling dialog:show. `initial` is an optional boolean parameter, if set to `true` the checkbox will be checked initially. Can not be used in conjunction with dialog:addOption.


getCheckboxState

dialog:getCheckboxState(id) -> boolean

Returns the state of the checkbox identified by `id` after dialog:show has been called.


show

dialog:show() -> integer

Renders the dialog on screen. If this is an option dialog, returns the id of the selected option (see dialog:addOption). If this is a checkbox dialog, returns 0 if OK was pressed, -1 if Exit was pressed. Use dialog:getCheckboxState to query the individual checkboxes. This method can only be called once per dialog. It will return an error if invoked a second time.


Example

dialog = civ.ui.createDialog()

dialog.title = "My first dialog"

dialog.width = 250

dialog:addOption("Foo", 1)

dialog:addOption("Bar", 2)

dialog:show()