These script functions provide a complete toolkit for creating graphical interfaces in AGAST. The scripts documented here deal with setting up the GUI system and creating groups of controls.

The Midnight toolkit is implemented entirely within AGAST scripts, and was originally developed by Pat "ARKBAN" Bohan.

Functions




function Midnight_Setup (font, fontColor, scrollArrowImageResource)

Initializes the Midnight GUI system. If the GUI system has already been initialized, calling this script again will destroy all controls. Midnight_Setup() is usually called at the beginning of the game.

Parameters

font Default font for Midnight controls.

fontColor Default font color for Midnight controls.

scrollArrowImageResource Sprite containing scrollbar arrow graphics.
Notes

This script can be found in the standard file MidnightData.s.




function Midnight_findNextUnusedMidnightGroupID

Finds the next available Midnight group. Call this script first when creating a new interface window.

Returns

The index of the new group.

Notes

This script can be found in the standard file MidnightData.s.




function Midnight_HideGroup (givenGroupID)

Makes all controls in the specified group invisible.

Parameters

givenGroupID Index of the group to hide.
Notes

This script can be found in the standard file MidnightData.s.




function Midnight_ShowGroup (givenGroupID)

Makes all controls in the specified group visible.

Parameters

givenGroupID Index of the group to show.
Notes

This script can be found in the standard file MidnightData.s.




function Midnight_Destroy

Removes all Midnight controls and unmarks all resources used by Midnight.

Notes

This script can be found in the standard file MidnightData.s.




function Midnight_DestroyControl (givenControl)

Removes an individual Midnight control.

Parameters

givenControl Index of the control to remove.
Notes

This script can be found in the standard file MidnightData.s.




function Midnight_DestroyGroup (givenGroupID)

Removes all controls in the specified group.

Parameters

givenGroupID Index of the group to remove.
Notes

This script can be found in the standard file MidnightData.s.




function Midnight_StartExclusive

Starts the Midnight GUI system in exclusive mode. In this mode, Midnight runs as a menu handler. No other scripts will execute while Midnight is running.

Notes

This script can be found in the standard file MidnightData.s.




function Midnight_StartNonExclusive

Starts the Midnight GUI system in non-exclusive mode. Other scripts may execute, other events may occur, and input is processed normally.

Notes

This script can be found in the standard file MidnightData.s.




function Midnight_StartInputExclusive

Starts the Midnight GUI system in input-exclusive mode. Other scripts may execute while Midnight is running, but only Midnight will receive input.

Notes

This script can be found in the standard file MidnightData.s.




function Midnight_Create_Frame (givenGroupID, givenX1, givenY1, givenX2, givenY2)

Creates a rectangular frame control. Frames are generally used as backdrops for other controls.

Parameters

givenGroupID Group to add the frame to.

givenX1 Left X-coordinate of the frame.

givenY1 Top Y-coordinate of the frame.

givenX2 Right X-coordinate of the frame.

givenY2 Bottom Y-coordinate of the frame.
Returns

Index of the frame object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_GradientFrame (givenGroupID, givenX1, givenY1, givenX2, givenY2)

Creates a rectangular frame control with a gradient fill. Frames are generally used as backdrops for other controls.

Parameters

givenGroupID Group to add the frame to.

givenX1 Left X-coordinate of the frame.

givenY1 Top Y-coordinate of the frame.

givenX2 Right X-coordinate of the frame.

givenY2 Bottom Y-coordinate of the frame.
Returns

Index of the frame object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_Button (givenGroupID, givenX1, givenY1, givenX2, givenY2, givenText, givenActionScript)

Creates a rectangular button with a text label inside.

Parameters

givenGroupID Group to add the button to.

givenX1 Left X-coordinate of the button.

givenY1 Top Y-coordinate of the button.

givenX2 Right X-coordinate of the button.

givenY2 Bottom Y-coordinate of the button.

givenText Text label for the button.

givenActionScript Script to be called when the user clicks on the button.
Returns

Index of the button object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_Label (givenGroupID, givenX1, givenY1, givenText)

Creates a simple text label.

Parameters

givenGroupID Group to add the label to.

givenX1 X-coordinate of the label.

givenY1 Y-coordinate of the label.

givenText Text for the label.
Returns

Index of the label object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_ConcaveBorder (givenGroupID, givenX1, givenY1, givenX2, givenY2)

Creates a rectangular border with a concave (inward) bevel.

Parameters

givenGroupID Group to add the border to.

givenX1 Left X-coordinate of the border.

givenY1 Top Y-coordinate of the border.

givenX2 Right X-coordinate of the border.

givenY2 Bottom Y-coordinate of the border.
Returns

Index of the border object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_ConvexBorder (givenGroupID, givenX1, givenY1, givenX2, givenY2)

Creates a rectangular border with a convex (outward) bevel.

Parameters

givenGroupID Group to add the border to.

givenX1 Left X-coordinate of the border.

givenY1 Top Y-coordinate of the border.

givenX2 Right X-coordinate of the border.

givenY2 Bottom Y-coordinate of the border.
Returns

Index of the border object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_CheckBox (givenGroupID, givenX1, givenY1, givenText, givenDefaultValue)

Creates a checkbox, which can be set to either True or False.

Parameters

givenGroupID Group to add the checkbox to.

givenX1 X-coordinate of the checkbox.

givenY1 Y-coordinate of the checkbox.

givenText Text label for the checkbox.

givenDefaultValue Initial value of the checkbox. May be either True for checked or False for unchecked.
Returns

Index of the checkbox object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_RadioButton (givenGroupID, givenX1, givenY1, givenText, givenRadioGroup, givenDefaultValue)

Creates a radio button. Radio buttons are similar to checkboxes, but only one button in a given group can be set to True.

Parameters

givenGroupID Group to add the radio button to.

givenX1 X-coordinate of the radio button.

givenY1 Y-coordinate of the radio button.

givenText Text label for the radio button.

givenRadioGroup Group of radio buttons this button belongs to. Only one button in a group can be True at any given time. (This group number can be any non-negative variable.)

givenDefaultValue Initial value of the radio button. May be either True for checked or False for unchecked.
Returns

Index of the radio button object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_TextInput (givenGroupID, givenX1, givenY1, givenX2, givenDefaultText)

Creates a text box which the user can select and type into.

Parameters

givenGroupID Group to add the text input box to.

givenX1 Left X-coordinate of the text input box.

givenY1 Y-coordinate of the text input box.

givenX2 Right X-coordinate of the text input box.

givenDefaultText Starting text for the box. (This text may be modified by the user.)
Returns

Index of the text input object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_VerticalScrollBar (givenGroupID, givenX1, givenY1, givenX2, givenY2, givenMaxValue, givenCurrValue)

Creates a vertical scroll bar.

Parameters

givenGroupID Group to add the scroll bar to.

givenX1 Left X-coordinate of the scroll bar.

givenY1 Top Y-coordinate of the scroll bar.

givenX2 Right X-coordinate of the scroll bar.

givenY2 Bottom Y-coordinate of the scroll bar.

givenMaxValue Maximum value of the scroll bar.

givenCurrValue Starting value of the scroll bar. (Must be between 0 and givenMaxValue.
Returns

Index of the scroll bar object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_HorizontalScrollBar (givenGroupID, givenX1, givenY1, givenX2, givenY2, givenMaxValue, givenCurrValue)

Creates a horizontal scroll bar.

Parameters

givenGroupID Group to add the scroll bar to.

givenX1 Left X-coordinate of the scroll bar.

givenY1 Top Y-coordinate of the scroll bar.

givenX2 Right X-coordinate of the scroll bar.

givenY2 Bottom Y-coordinate of the scroll bar.

givenMaxValue Maximum value of the scroll bar.

givenCurrValue Starting value of the scroll bar. (Must be between 0 and givenMaxValue.
Returns

Index of the scroll bar object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_Sprite (givenGroupID, givenX1, givenY1, givenX2, givenY2, givenSpriteResource, givenSpriteFrame)

Creates a sprite control. This is either an image or a single frame of a sprite.

Parameters

givenGroupID Group to add the sprite control to.

givenX1 Left X-coordinate of the sprite.

givenY1 Top Y-coordinate of the sprite.

givenX2 Right X-coordinate of the sprite's input region.

givenY2 Bottom Y-coordinate of the sprite's input region.

givenSpriteResource Sprite resource to draw.

givenSpriteFrame Frame of givenSpriteResource to draw.
Returns

Index of the sprite object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_Create_ListBox (givenGroupID, givenX1, givenY1, givenX2, givenTextRows)

Creates a scrollable list of text labels.

Parameters

givenGroupID Group to add the list box to.

givenX1 Left X-coordinate of the list box.

givenY1 Top Y-coordinate of the list box.

givenX2 Right X-coordinate of the list box.

givenTextRows Number of rows of text to be displayed at one time.
Returns

Index of the list box object.

Notes

This script can be found in the standard file MidnightCreate.s.




function Midnight_SetUserActionScript (givenControl, givenScript)

Specifies a script to be called when the user clicks on or otherwise interacts with the control.

Parameters

givenControl Control to set the action script for.

givenScript Index of action script to use.
Notes

This script can be found in the standard file MidnightControlClass.s.

Menus.s from the SampleGame uses this script extensively.