DIALOG
(WIP)
Dialogs are a more advanced form of user interface whose layout can be completely customised.
Contents
Syntax
The definition of a dialog consists of three different blocks of script; a layout, a list of text strings used in the dialog and a buttons section which handles button responses from the client.
Layout
The layout section of the dialog defines how the dialog will look to clients.
[DIALOG defname]
script
The script text can be a complete script that is executed in the same way as a function or trigger script, and can even contain conditional statements to display different layouts to different clients if desired. The default object is the character or item that the dialog has been called upon, and SRC is the Characters#Clients client who is viewing the dialog. If the dialog ends with a "RETURN 1" then Sphere will cancel displaying the dialog.
In addition to the usual functions, properties and references you would have access to in a normal script, there are also functions that place elements on to the dialog. The following table lists all elements that can be used:
Name | Description |
button x y gump_down gump_up is_pressable page id | Places a button on to the page |
buttontileart x y gump_down gump_up is_pressable page id tile_id tile_hue tile_x tile_Y | Places a button on to the page, with an item image placed over the top as part of the button. |
checkbox x y gump_check gump_uncheck initial_state id | Places a checkbox on to the page. |
checkertrans x y width height | Adds a transparent area of the dialog. |
croppedtext x y width height colour text_index | Places some text on to the page that wraps to specified boundaries. |
dcroppedtext x y width height colour text | Places some text on to the page that wraps to specified boundaries. |
dorigin x y' | |
dhtmlgump x y width height text has_background has_scrollbar | Places some HTML text on to the page. |
dtext x y colour text | Places some text on to the page. |
dtextentry x y width height colour id text | Places a text entry field on to the page where the client can enter text. |
dtextentrylimited x y width height colour id limit text | Places a text entry field on to the page where the client can enter a limited amount of text. |
group id | Defines a new group ID, for grouping sets of radio buttons. |
gumppic x y gump hue | Places a gump on to the page. |
gumppictiled x y width height gump | Tiles a gump over an area of the page. |
htmlgump x y width height text_index has_background has_scrollbar | Places some HTML text on to the page. |
noclose | Prevents the dialog from being closed when right-clicked. |
nodispose | Prevents the dialog from being closed by the "Close Dialogs" macro. |
nomove | Prevents the dialog from being moved around the screen. |
page num | Changes the current page to id. |
radio x y gump_check gump_uncheck initial_state id | Places a radio button on to the page. |
resizepic x y gump width height | Places a multi-part gump on to the page, often used for dialog backgrounds. |
text x y colour text_index | Places some text on to the page. |
textentry x y width height colour id text_index | Places a text entry field on to the page where the client can enter text. |
textentrylimited x y width height colour id text_index limit | Places a text entry field on to the page where the client can enter a limited amount of text. |
tilepic x y item_id | Places an item image on to the page. |
tilepichue x y item_id hue | Places a coloured item image on to the page. |
tooltip cliloc_id | Places a tooltip on to the page. |
xmfhtmlgump x y width height clilod_id has_background has_scrollbar | Places some localised HTML text on to the page. |
xmfhtmlgumpcolor x y width height cliloc_id has_background has_scrollbar colour | Places some localised HTML text on to the page with the specified colour. |
xmfhtmltok x y width height has_background has_scrollbar colour cliloc_id @args@ | Places some localised HTML text on to the page, with arguments to the cliloc (multiple arguments separated by @). |
Text
The text section of the dialog simply lists the different text strings used in the dialog's layout. When using dialog elements that represent text, such as text or htmlgump, an index into the TEXT block will be specified so that the client knows which text to actually display on that dialog element. This dialog section is optional, and may be omitted if there are no text elements on the dialog or if the newer dialog text elements, such as dtext or dhtmlgump, are used because their text string is specified in the layout and Sphere will automatically populate the TEXT block for you.
[DIALOG defname TEXT]
string1
string2
string3
Buttons
This section contains button triggers that fires when the client presses a certain button on the dialog. There are two ways that a button press can be handled, the syntaxc for both is shown below:
[DIALOG defname BUTTON]
ON=button_id
script
ON=button_id_start button_id_end
script
The first "ON=button_id" will handle the button press for the button with the matching ID, the second will handle any button press where the ID is between button_id_start and button_id_end.
Note: If the client cancels the dialog by right clicking it, the trigger for button 0 will be fired.