fe.add_image()
fe.add_artwork()
fe.add_surface()
fe.add_clone()
fe.add_text()
fe.add_listbox()
fe.add_shader()
fe.add_sound()
fe.add_ticks_callback()
fe.add_transition_callback()
fe.game_info()
fe.get_art()
fe.get_input_state()
fe.get_input_pos()
fe.signal()
fe.set_display()
fe.add_signal_handler()
fe.remove_signal_handler()
fe.do_nut()
fe.load_module()
fe.plugin_command()
fe.plugin_command_bg()
fe.path_expand()
fe.get_config()
The Attract-mode layout sets out what gets displayed to the user. Layouts
consist of a layout.nut
script file and a collection of related resources
(images, other scripts, etc.) used by the script.
Layouts are stored under the "layouts" subdirectory of the Attract-Mode config directory. Each layout is stored in its own separate subdirectory or archive file (Attract-Mode can read layouts and plugins directly from .zip, .7z, .rar, .tar.gz, .tar.bz2 and .tar files).
Each layout can have one or more layout*.nut
script files. The "Toggle
Layout" command in Attract-Mode allows users to cycle between each of the
layout*.nut
script files located in the layout's directory. Attract-Mode
remembers the last layout file toggled to for each layout and will go back
to that same file the next time the layout is loaded. This allows for
variations of a particular layout to be implemented and easily selected by
the user (for example, a layout could provide a layout.nut
for horizontal
monitor orientations and a layout-vert.nut
for vertical).
The Attract-Mode screen saver and intro modes are really just special case
layouts. The screensaver gets loaded after a user-configured period of
inactivity, while the intro mode gets run when the frontend first starts and
exits as soon as any action is triggered (for example if the user hits the
select button). The screen saver script is located in the screensaver.nut
file stored in the "screensaver" subdirectory. The intro script is located
in the intro.nut
file stored in the "intro" subdirectory.
Plug-ins are similar to layouts in that they consist of at least one squirrel
script file and a collection of related resources. Plug-ins are stored in the
"plugins" subdirectory of the Attract-Mode config directory. Plug-ins can be a
single ".nut" file stored in this subdirectory. They can also have their own
separate subdirectory or archive file (in which case the script itself needs to
be in a file called plugin.nut
).
Attract-Mode's layouts are scripts written in the Squirrel programming language. Squirrel's standard "Blob", "IO", "Math", "String" and "System" library functions are available for use in a script. For more information on programming in Squirrel and using its standard libraries, consult the Squirrel manuals:
Attract-Mode includes the following home-brewed extensions to the squirrel language and standard libraries:
zip_extract_archive( zipfile, filename )
function that will open a
specified zipfile
archive file and extract filename
from it, returning
the contents as a squirrel blob.zip_get_dir( zipfile )
function that will return an array of the
filenames contained in the zipfile
archive file.Supported archive formats are: .zip, .7z, .rar, .tar.gz, .tar.bz2 and .tar
All of the functions, objects and classes that Attract-Mode exposes to
Squirrel are arranged under the fe
table, which is bound to Squirrel's
root table.
Example:
fe.layout.base_rotation = RotateScreen.Right;
fe.add_image( "bg.png", 0, 0 );
local marquee = fe.add_artwork( "marquee", 256, 20, 512, 256 );
marquee.set_rgb( 100, 100, 100 );
The remainder of this document describes the functions, objects, classes and constants that are exposed to layout and plug-in scripts.
Image names, as well as the messages displayed by Text and Listbox objects, can all contain one or more "Magic Tokens". Magic tokens are enclosed in square brackets, and the frontend automatically updates them accordingly as the user navigates the frontend. So for example, a Text message set to "[Manufacturer]" will be automatically updated with the appropriate Manufacturer's name. There are more examples below.
[DisplayName]
- the name of the current display[ListSize]
- the number of items in the game list[ListEntry]
- the number of the current selection in the game list[FilterName]
- the name of the filter[Search]
- the search rule currently applied to the game list[SortName]
- the attribute that the list was sorted by[Name]
- the short name of the selected game[Title]
- the full name of the selected game[Emulator]
- the emulator to use for the selected game[CloneOf]
- the short name of the game that the selection is a
clone of[Year]
- the year for the selected game[Manufacturer]
- the manufacturer for the selected game[Category]
- the category for the selected game[Players]
- the number of players for the selected game[Rotation]
- the rotation for the selected game[Control]
- the primary control for the selected game[Status]
- the emulation status for the selected game[DisplayCount]
- the number of displays for the selected game[DisplayType]
- the display type for the selected game[AltRomname]
- the alternative Romname for the selected game[AltTitle]
- the alternative title for the selected game[PlayedTime]
- the amount of time the selected game has been
played[PlayedCount]
- the number of times the selected game has been
played[SortValue]
- the value used to order the selected game in the
list[System]
- the first "System" name configured for the selected
game's emulator[SystemN]
- the last "System" name configured for the selected
game's emulator[!<function_name>]
. When used, Attract-Mode will run the
corresponding function (defined in the squirrel "root table"). This
function should then return the string value that you wish to have
replace the magic token. The function defined in squirrel can optionally
have up to two parameters passed to it. If it is defined with a first
parameter, Attract-Mode will supply the appropriate indexoffset in that
parameter when it calls the function. If a second parameter is present
as well, the appropriate filteroffset is supplied.Examples:
// Add a text that displays the filter name and list location
//
fe.add_text( "[FilterName] [[ListEntry]/[ListSize]]",
0, 0, 400, 20 );
// Add an image that will match to the first word in the
// Manufacturer name (i.e. "Atari.png", "Nintendo.jpg")
//
function strip_man( ioffset )
{
local m = fe.game_info(Info.Manufacturer,ioffset);
return split( m, " " )[0];
}
fe.add_image( "[!strip_man]", 0, 0 );
// Add a text that will display a copyright message if both
// the manufacturer name and a year are present. Otherwise,
// just show the Manufactuer name.
//
function well_formatted()
{
local m = fe.game_info( Info.Manufacturer );
local y = fe.game_info( Info.Year );
if (( m.len() > 0 ) && ( y.len() > 0 ))
return "Copyright " + y + ", " + m;
return m;
}
fe.add_text( "[!well_formatted]", 0, 0 );
fe.add_image()
fe.add_image( name )
fe.add_image( name, x, y )
fe.add_image( name, x, y, w, h )
Adds an image or video to the end of Attract-Mode's draw list.
Magic Tokens can be used in the supplied "name", in which case Attract-Mode will dynamically update the image in response to navigation.
Parameters:
name
is ignored
(if present) and Attract-Mode will load any supported media file that
matches the Magic Token. See Magic Tokens for more info.Return Value:
fe.Image
which can be used to
interact with the added image/video.fe.add_artwork()
fe.add_artwork( label )
fe.add_artwork( label, x, y )
fe.add_artwork( label, x, y, w, h )
Add an artwork to the end of Attract-Mode's draw list. The image/video displayed in an artwork is updated automatically whenever the user changes the game selection.
Parameters:
Return Value:
fe.Image
which can be used to
interact with the added artwork.fe.add_surface()
fe.add_surface( w, h )
Add a surface to the end of Attract-Mode's draw list. A surface is an off- screen texture upon which you can draw other image, artwork, text, listbox and surface objects. The resulting texture is treated as a static image by Attract-Mode which can in turn have image effects applied to it (scale, position, pinch, skew, shaders, etc) when it is drawn.
Parameters:
Return Value:
fe.Image
which can be used to
interact with the added surface.fe.add_clone()
fe.add_clone( img )
Clone an image, artwork or surface object and add the clone to the back of Attract-Mode's draw list. The texture pixel data of the original and clone is shared as a result.
Parameters:
fe.Image
.Return Value:
fe.Image
which can be used to
interact with the added clone.fe.add_text()
fe.add_text( msg, x, y, w, h )
Add a text label to the end of Attract-Mode's draw list.
Magic Tokens can be used in the supplied "msg", in which case Attract-Mode will dynamically update the msg in response to navigation.
Parameters:
Return Value:
fe.Text
which can be used to
interact with the added text.fe.add_listbox()
fe.add_listbox( x, y, w, h )
Add a listbox to the end of Attract-Mode's draw list.
Parameters:
Return Value:
fe.ListBox
which can be used to
interact with the added text.fe.add_shader()
fe.add_shader( type, file1, file2 )
fe.add_shader( type, file1 )
fe.add_shader( type )
Add a GLSL shader (vertex and/or fragment) for use in the layout.
Parameters:
type - the type of shader to add. Can be one of the following values:
Shader.VertexAndFragment
- add a combined vertex and fragment shaderShader.Vertex
- add a vertex shaderShader.Fragment
- add a fragment shaderShader.Empty
- add an empty shader. An object's shader property can
be set to an empty shader to stop using a shader on that object where
one was set previously.file1 - the name of the shader file located in the layout/plugin directory. For the VertexAndFragment type, this should be the vertex shader.
Return Value:
fe.Shader
which can be used to
interact with the added shader.Shaders are implemented using the SFML API. For more information please see: http://www.sfml-dev.org/tutorials/2.1/graphics-shader.php
The minimal vertex shader expected is as follows:
void main()
{
// transform the vertex position
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
// transform the texture coordinates
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
// forward the vertex color
gl_FrontColor = gl_Color;
}
The minimal fragment shader expected is as follows:
uniform sampler2D texture;
void main()
{
// lookup the pixel in the texture
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
// multiply it by the color
gl_FragColor = gl_Color * pixel;
}
fe.add_sound()
fe.add_sound( name, reuse )
fe.add_sound( name )
Add an audio file that can then be played by Attract-Mode.
Parameters:
Return Value:
fe.Sound
which can be used to
interact with the sound.fe.add_ticks_callback()
fe.add_ticks_callback( environment, function_name )
fe.add_ticks_callback( function_name )
Register a function in your script to get "tick" callbacks. Tick callbacks occur continuously during the running of the frontend. The function that is registered should be in the following form:
function tick( tick_time )
{
// do stuff...
}
The single parameter passed to the tick function is the amount of time (in milliseconds) since the layout began.
Parameters:
Return Value:
fe.add_transition_callback()
fe.add_transition_callback( environment, function_name )
fe.add_transition_callback( function_name )
Register a function in your script to get transition callbacks. Transition callbacks are triggered by certain events in the frontend. The function that is registered should be in the following form:
function transition( ttype, var, transition_time )
{
local redraw_needed = false;
// do stuff...
if ( redraw_needed )
return true;
return false;
}
The ttype
parameter passed to the transition function indicates what is
happening. It will have one of the following values:
Transition.StartLayout
Transition.EndLayout
Transition.ToNewSelection
Transition.FromOldSelection
Transition.ToGame
Transition.FromGame
Transition.ToNewList
Transition.EndNavigation
Transition.ShowOverlay
Transition.HideOverlay
Transition.NewSelOverlay
The value of the var
parameter passed to the transition function depends
upon the value of ttype
:
When ttype
is Transition.ToNewSelection
, var
indicates the index
offset of the selection being transitioned to (i.e. -1 when moving back
one position in the list, 1 when moving forward one position, 2 when
moving forward two positions, etc.)
When ttype
is Transition.FromOldSelection
, var
indicates the index
offset of the selection being transitioned from (i.e. 1 after moving back
one position in the list, -1 after moving forward one position, -2 after
moving forward two positions, etc.)
When ttype
is Transition.StartLayout
, var
will be one of the
following:
FromTo.Frontend
if the frontend is just starting,FromTo.ScreenSaver
if the layout is starting (or the list is being
loaded) because the built-in screen saver has stopped, orFromTo.NoValue
otherwise.When ttype
is Transition.EndLayout
, var
will be:
FromTo.Frontend
if the frontend is shutting down,FromTo.ScreenSaver
if the layout is stopping because the built-in
screen saver is starting, orFromTo.NoValue
otherwise.When ttype
is Transition.ToNewList
, var
indicates the filter index
offset of the filter being transitioned to (i.e. -1 when moving back one
filter, 1 when moving forward) if known, otherwise var
is 0.
When ttype
is Transition.ShowOverlay
, var will be:
Overlay.Custom
if a script generated overlay is being shownOverlay.Exit
if the exit menu is being shownOverlay.Displays
if the displays menu is being shownOverlay.Filters
if the filters menu is being shownOverlay.Tags
if the tags menu is being shownWhen ttype
is Transition.NewSelOverlay
, var will be the index of the
new selection in the Overlay menu.
When ttype
is Transition.ToGame
, Transition.FromGame
,
Transition.EndNavigation
, or Transition.HideOverlay
, var
will be
FromTo.NoValue
.
The transition_time
parameter passed to the transition function is the
amount of time (in milliseconds) since the transition began.
The transition function must return a boolean value. It should return
true
if a redraw is required, in which case Attract-Mode will redraw the
screen and immediately call the transition function again with an updated
transition_time
.
The transition function must eventually return false
to notify
Attract-Mode that the transition effect is done, allowing the normal
operation of the frontend to proceed.
Parameters:
Return Value:
fe.game_info()
fe.game_info( id )
fe.game_info( id, index_offset )
fe.game_info( id, index_offset, filter_offset )
Get information about the selected game.
Parameters:
Info.Name
Info.Title
Info.Emulator
Info.CloneOf
Info.Year
Info.Manufacturer
Info.Category
Info.Players
Info.Rotation
Info.Control
Info.Status
Info.DisplayCount
Info.DisplayType
Info.AltRomname
Info.AltTitle
Info.Extra
Info.Favourite
Info.Tags
Info.PlayedCount
Info.PlayedTime
Info.FileIsAvailable
Info.System
Return Value:
fe.get_art()
fe.get_art( label )
fe.get_art( label, index_offset )
fe.get_art( label, index_offset, filter_offset )
fe.get_art( label, index_offset, filter_offset, flags )
Get the filename of an artwork for the selected game. If multiple files are matched, one is chosen randomly and returned.
Parameters:
Art.Default
Art.ImageOnly
(only return an image match, no videos)Return Value:
|
character: "fe.get_input_state()
fe.get_input_state( input_id )
Check if a specific keyboard key, mouse button, joystick button or joystick direction is currently pressed, or check if any input mapped to a particular frontend action is pressed.
Parameter:
input_id - [string] the input to test. This can be a string in the same format as used in the attract.cfg file for input mappings. For example, "LControl" will check the left control key, "Joy0 Up" will check the up direction on the first joystick, "Mouse MiddleButton" will check the middle mouse button, and "select" will check for any input mapped to the game select button...
Note that mouse moves and mouse wheel movements are not available through this function.
Return Value:
true
if input is pressed, false
otherwise.fe.get_input_pos()
fe.get_input_pos( input_id )
Return the current position for the specified joystick axis.
Parameter:
Return Value:
fe.signal()
fe.signal( signal_str )
Signal that a particular frontend action should occur.
Parameters:
Return Value:
fe.set_display()
fe.set_display( index )
Change to the display at the specified index. This should align with the index of the fe.displays array that contains the intended display.
NOTE that changing the display causes all layout and plugin scripts to reload.
Parameters:
fe.list.display_index
.Return Value:
fe.add_signal_handler()
fe.add_signal_handler( environment, function_name )
fe.add_signal_handler( function_name )
Register a function in your script to handle signals. Signals are sent
whenever a mapped control is used by the user or whenever a layout or
plugin script uses the fe.signal()
function. The function
that is registered should be in the following form:
function handler( signal_str )
{
local no_more_processing = false;
// do stuff...
if ( no_more_processing )
return true;
return false;
}
The signal_str
parameter passed to the handler function is a string
that identifies the signal that has been given. This string will
correspond to the signal_str
parameter values of fe.signal()
The signal handler function should return a boolean value. It should
return true
if no more processing should be done on this signal.
It should return false
if signal processing is to continue, in which
case this signal will be dealt with in the default manner by the
frontend.
Parameters:
Return Value:
fe.remove_signal_handler()
fe.remove_signal_handler( environment, function_name )
fe.remove_signal_handler( function_name )
Remove a signal handler that has been added with the
fe.add_signal_handler()
function.
Parameters:
Return Value:
fe.do_nut()
fe.do_nut( name )
Execute another Squirrel script.
Parameters:
Return Value:
fe.load_module()
fe.load_module( name )
Loads a module (a "library" Squirrel script).
Parameters:
Return Value:
true
if the module was loaded, `false' if it was not found.fe.plugin_command()
fe.plugin_command( executable, arg_string )
fe.plugin_command( executable, arg_string, environment, callback_function )
fe.plugin_command( executable, arg_string, callback_function )
Execute a plug-in command and wait until the command is done.
Parameters:
callback_function - a string containing the name of the function in Squirrel to call with any output that the executable provides on stdout. The function should be in the following form:
function callback_function( op )
{
}
If provided, this function will be called with each output line in op
.
Return Value:
fe.plugin_command_bg()
fe.plugin_command_bg( executable, arg_string )
Execute a plug-in command in the background and return immediately.
Parameters:
Return Value:
fe.path_expand()
fe.path_expand( path )
Expand the given path name. A leading ~
or $HOME
token will be become
the user's home directory. On Windows systems, a leading %SYSTEMROOT%
token will become the path to the Windows directory and a leading
%PROGRAMFILES%
will become the path to the "Program Files" directory.
Parameters:
Return Value:
fe.get_config()
Get the user configured settings for this layout/plugin/screensaver/intro.
NOTE this function will not return valid settings when called from a callback function registered with fe.addtickscallback(), fe.addtransitioncallback() or fe.addsignalhandler()
Parameters:
Return Value:
A table containing each of the applicable user configured settings. A layout or plug-in can signal its user configured settings to Attract-Mode by defining a class named "UserConfig" at the very start of the script. In the case a layouts, the "UserConfig" class must be located in a file named 'layout.nut' in the layout directory.
For an example, please see one of the plug-ins included with Attract- Mode or the "Attrac-Man" layout.
fe.ambient_sound
fe.ambient_sound
is an instance of the fe.Sound
class and can be used to
control the ambient sound track.
fe.layout
fe.layout
is an instance of the fe.LayoutGlobals
class and is where
global layout settings are stored.
fe.list
fe.list
is an instance of the fe.CurrentList
class and is where current
display settings are stored.
fe.overlay
fe.overlay
is an instance of the fe.Overlay
class and is where overlay
functionality may be accessed.
fe.obj
fe.obj
contains the Attract-Mode draw list. It is an array of fe.Image
,
fe.Text
and fe.ListBox
instances.
fe.displays
fe.displays
contains information on the available displays. It is an array
of fe.Display
instances.
fe.filters
fe.filters
contains information on the available filters. It is an array
of fe.Filter
instances.
fe.monitors
fe.monitors
is an array of fe.Monitor
instances, and provides the
mechanism for interacting with the various monitors in a multi-monitor setup.
There will always be at least one entry in this list, and the first entry
will always be the "primary" monitor.
fe.script_dir
When Attract-Mode runs a layout or plug-in script, fe.script_dir
is set to
the layout or plug-in's directory.
fe.script_file
When Attract-Mode runs a layout or plug-in script, fe.script_file
is set to
the name of the layout or plug-in script file.
fe.nv
The fe.nv table can be used by layouts and plugins to store persistent values. The values in this table get saved by Attract-Mode whenever the layout changes and are saved to disk when Attract-Mode is shut down. Boolean, integer, float, string, array and table values can be stored in this table.
fe.LayoutGlobals
This class is a container for global layout settings. The instance of this
class is the fe.layout
object. This class cannot be otherwise instantiated
in a script.
Properties:
width
- Get/set the layout width. Default value is ScreenWidth
.height
- Get/set the layout height. Default value is ScreenHeight
.font
- Get/set the layout font name. Default value is the default
font configured for Attract-Mode.base_rotation
- Get/set the base (i.e the default) orientation of the
layout. This can be one of the following values:
RotateScreen.None
(default)RotateScreen.Right
RotateScreen.Flip
RotateScreen.Left
toggle_rotation
- Get/set the "toggle" orientation of the layout. The
toggle rotation is added to the base_rotation
to determine what the
actual rotation is at any given time. The user can change this value
using the Rotation Toggle inputs. This can be one of the following
values:
RotateScreen.None
(default)RotateScreen.Right
RotateScreen.Flip
RotateScreen.Left
page_size
- Get/set the number of entries to jump each time the "Page
Up" or "Page Down" button is pressed.preserve_aspect_ratio
- Get/set whether the overall layout aspect ratio
should be preserved by the frontend. Default value is false.time
- Get the number of millseconds that the layout has been showing.Notes:
( fe.layout.base_rotation + fe.layout.toggle_rotation ) % 4
fe.CurrentList
This class is a container for status information regarding the current display.
The instance of this class is the fe.list
object. This class cannot be
otherwise instantiated in a script.
Properties:
name
- Get the name of the current display.display_index
- Gett the index of the current display. Use the
fe.set_display()
function if you want to change the current display.filter_index
- Get/set the index of the currently selected filter.
(see fe.filters
for the list of available filters).index
- Get/set the index of the currently selected game.search_rule
- Get/set the search rule applied to the current game list.
If you set this and the resulting search finds no results, then the
current game list remains displayed in its entirety. If there are
results, then those results are shown instead, until search_rule is
cleared or the user navigates away from the display/filter.size
- Get the size of the current game list. If a search rule has
been applied, this will be the number of matches found (if > 0)fe.Overlay
This class is a container for overlay functionality. The instance of this
class is the fe.overlay
object. This class cannot be otherwise instantiated
in a script.
Properties:
is_up
- Get whether the overlay is currently being displayed (i.e. config
mode, etc).Member Functions:
set_custom_controls( caption_text, options_listbox )
set_custom_controls( caption_text )
set_custom_controls()
- tells the frontend that the layout will provide
custom controls for displaying overlay menus such as the exit dialog,
displays menu, etc. The caption_text
parameter is the FeText object
that the frontend end should use to display the overlay caption (i.e.
"Exit Attract-Mode?"). The options_listbox
parameter is the FeListBox
object that the frontend should use to display the overlay options.clear_custom_controls()
- tell the frontend that the layout will NOT
do any custom control handling for overlay menus. This will result in
the frontend using its built-in default menus instead for overlays.list_dialog( options, title, default_sel, cancel_sel )
list_dialog( options, title, default_sel )
list_dialog( options, title )
list_dialog( options )
- The list_dialog function prompts the user with
a menu containing a list of options, returning the index of the selection.
The options
parameter is an array of strings that are the menu options
to display in the list. The title
parameter is a caption for the list.
default_sel
is the index of the entry to be selected initially (default
is 0). cancel_sel
is the index to return if the user cancels (default
is -1). The return value is the index selected by the user.edit_dialog( msg, text )
- Prompt the user to input/edit text. The
msg
parameter is the prompt caption. text
is the initial text to be
edited. The return value a the string of text as edited by the user.splash_message( msg, second_msg="" )
- immediately provide text feedback
to the user. This could be useful during computationally-intensive
operations.fe.Display
This class is a container for information about the available displays.
Instances of this class are contained in the fe.displays
array. This class
cannot otherwise be instantiated in a script.
Properties:
name
- Get the name of the display.layout
- Get the layout used by this display.romlist
- Get the romlist used by this display.in_cycle
- Get whether the display is shown in the prev display/next
display cycle.in_menu
- Get whether the display is shown in the "Displays Menu"fe.Filter
This class is a container for information about the available filters.
Instances of this class are contained in the fe.filters
array. This class
cannot otherwise be instantiated in a script.
Properties:
name
- Get the filter name.index
- Get the index of the currently selected game in this filter.size
- Get the size of the game list in this filter.sort_by
- Get the attribute that the game list has been sorted by.
Will be equal to one of the following values:
Info.NoSort
Info.Name
Info.Title
Info.Emulator
Info.CloneOf
Info.Year
Info.Manufacturer
Info.Category
Info.Players
Info.Rotation
Info.Control
Info.Status
Info.DisplayCount
Info.DisplayType
Info.AltRomname
Info.AltTitle
Info.Extra
Info.Favourite
Info.Tags
Info.PlayedCount
Info.PlayedTime
Info.FileIsAvailable
reverse_order
- [bool] Will be equal to true if the list order has been
reversed.list_limit
- Get the value of the list limit applied to the filter game
list.fe.Monitor
This class represents a monitor in Attract-Mode, and provides the interface
to the extra monitors in a multi-monitor setup. Instances of this class are
contained in the fe.monitors
array. This class cannot otherwise be
instantiated in a script.
Properties:
num
- Get the monitor number.width
- Get the monitor width in pixels.height
- Get the monitor height in pixels.Member Functions:
add_image()
- add an image to the end of this monitor's draw list (see
fe.add_image()
for parameters and return value).add_artwork()
- add an artwork to the end of this monitor's draw list
(see fe.add_artwork()
for parameters and return value).add_clone()
- add a clone to the end of this monitor's draw list (see
fe.add_clone()
for parameters and return value).add_text()
- add a text to the end of this monitor's draw list (see
fe.add_text()
for parameters and return value).add_listbox()
- add a listbox to the end of this monitor's draw list
(see fe.add_listbox()
for parameters and return value).add_surface()
- add a surface to the end of this monitor's draw list
(see fe.add_surface()
for parameters and return value).Notes:
fe.monitors
array is always the "primary" display
for the system.fe.Image
The class representing an image in Attract-Mode. Instances of this class
are returned by the add_image()
, add_artwork()
, add_surface
and
add_clone()
functions and also appear in the fe.obj
array (the
Attract-Mode draw list). This class cannot be otherwise instantiated in
a script.
Properties:
x
- Get/set x position of top left corner (in layout coordinates).y
- Get/set y position of top left corner (in layout coordinates).width
- Get/set width of image (in layout coordinates), 0 if the
image is unscaled. Default value is 0.height
- Get/set height of image (in layout coordinates), if 0 the
image is unscaled. Default value is 0.visible
- Get/set whether image is visible (boolean). Default value
is true
.rotation
- Get/set rotation of image. Range is [0 ... 360]. Default
value is 0.red
- Get/set red colour level for image. Range is [0 ... 255].
Default value is 255.green
- Get/set green colour level for image. Range is [0 ... 255].
Default value is 255.blue
- Get/set blue colour level for image. Range is [0 ... 255].
Default value is 255.alpha
- Get/set alpha level for image. Range is [0 ... 255]. Default
value is 255.index_offset
- Get/set offset from current selection for the artwork/
dynamic image to display. For example, set to -1 for the image
corresponding to the previous list entry, or 1 for the next list entry,
etc. Default value is 0.filter_offset
- Get/set filter offset from current filter for the
artwork/dynamic image to display. For example, set to -1 for an image
indexed in the previous filter, or 1 for the next filter, etc. Default
value is 0.skew_x
- Get/set the amount of x-direction image skew (in layout
coordinates). Default value is 0. Use a negative value to skew the
image to the left instead.skew_y
- Get/set the amount of y-direction image skew (in layout
coordinates). Default value is 0. Use a negative value to skew the
image up instead.pinch_x
- Get/set the amount of x-direction image pinch (in layout
coordinates). Default value is 0. Use a negative value to expand
towards the bottom instead.pinch_y
- Get/set the amount of y-direction image pinch (in layout
coordinates). Default value is 0. Use a negative value to expand
towards the right instead.texture_width
- Get the width of the image texture (in pixels).
* see Notes.texture_height
- Get the height of the image texture (in pixels).
* see Notes.subimg_x
- Get/set the x position of top left corner of the image
texture sub-rectangle to display. Default value is 0.subimg_y
- Get/set the y position of top left corner of the image
texture sub-rectangle to display. Default value is 0.subimg_width
- Get/set the width of the image texture sub-rectangle
to display. Default value is texture_width
.subimg_height
- Get/set the height of the image texture sub-rectangle
to display. Default value is texture_height
.video_flags
- [image & artwork only] Get/set video flags for this
object. These flags allow you to override Attract-Mode's default video
playback behaviour. Can be set to any combination of none or more of the
following (i.e. Vid.NoAudio | Vid.NoLoop
):
Vid.Default
Vid.ImagesOnly
(disable video playback, display images instead)Vid.NoAudio
(silence the audio track)Vid.NoAutoStart
(don't automatically start video playback)Vid.NoLoop
(don't loop video playback)video_playing
- [image & artwork only] Get/set whether video is
currently playing in this artwork (boolean).video_duration
- Get the video duration (in milliseconds).video_time
- Get the time that the video is current at (in milliseconds).preserve_aspect_ratio
- Get/set whether the aspect ratio from the source
image is to be preserved. Default value is false
.file_name
- [image & artwork only] Get/set the name of the image/video
file being shown. Note that if you set this on an artwork or a dynamic
image object it will get reset the next time the user changes the game
selection. If file_name is contained in an archive, this string should be
formatted: "shader
- Get/set the GLSL shader for this image. This can only be set to
an instance of the class fe.Shader
(see: fe.add_shader()
).trigger
- Get/set the transition that triggers updates of this artwork/
dynamic image. Can be set to Transition.ToNewSelection
or
Transition.EndNavigation
. Default value is Transition.ToNewSelection
.smooth
- Get/set whether the image is to be smoothed. Default value can
be configured in attract.cfgzorder
- Get/set the Image's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.Member Functions:
set_rgb( r, g, b )
- Set the red, green and blue colour values for the
image. Range is [0 ... 255].set_pos( x, y )
- Set the image position (in layout coordinates).set_pos( x, y, width, height )
- Set the image position and size (in
layout coordinates).swap( other_img )
- swap the texture contents of this object (and all
of its clones) with the contents of "other_img" (and all of its clones).
If an image or artwork is swapped, its video attributes (video_flags
and video_playing
) will be swapped as well.fix_masked_image()
- Takes the colour of the top left pixel in the image
and makes all the pixels in the image with that colour transparent.load_from_archive( archive, filename )
- Load the image from the
specified archive file (.zip, etc).add_image()
- [surface only] add an image to the end of this surface's
draw list (see fe.add_image()
for parameters and return
value).add_artwork()
- [surface only] add an artwork to the end of this
surface's draw list (see fe.add_artwork()
for parameters
and return value).add_clone()
- [surface only] add a clone to the end of this surface's
draw list (see fe.add_clone()
for parameters and return
value).add_text()
- [surface only] add a text to the end of this surface's draw
list (see fe.add_text()
for parameters and return value).add_listbox()
- [surface only] add a listbox to the end of this
surface's draw list (see fe.add_listbox()
for parameters
and return value).add_surface()
- [surface only] add a surface to the end of this
surface's draw list (see fe.add_surface()
for parameters
and return value).texture_width
, texture_height
and file_name
attributes are not available when a layout or plug-in
script first adds the artwork/dynamic image resource. These attributes
are available during transition callbacks, and in particular during the
Transition.FromOldSelection
and Transition.ToNewList
transitions.
Example:```` squirrel local myart = fe.addartwork( "snap", 0, 0, 100, 100 );
fe.addtransitioncallback("artworktransition"); function artworktransition( ttype, var, ttime ) { if (( ttype == Transition.FromOldSelection ) || ( ttype == Transition.ToNewList )) { // // do stuff with myart's texturewidth or textureheight here... // // for example, flip the image vertically: myart.subimgheight = -1 * textureheight; myart.subimgy = texture_height; }
return false;
}
````
subimg_height
property to
-1 * texture_height
and subimg_y
to texture_height
.subimg_width
property to
-1 * texture_width
and subimg_x
to texture_width
.```` squirrel
// flip "img" vertically function flipy( img ) { img.subimgheight = -1 * img.textureheight; img.subimgy = img.texture_height; } ````
fe.Text
The class representing a text label in Attract-Mode. Instances of this
class are returned by the add_text()
functions and also appear in the
fe.obj
array (the Attract-Mode draw list). This class cannot be
otherwise instantiated in a script.
Properties:
* msg
- Get/set the text label's message. Magic tokens can be used here,
see Magic Tokens for more information.
* x
- Get/set x position of top left corner (in layout coordinates).
* y
- Get/set y position of top left corner (in layout coordinates).
* width
- Get/set width of text (in layout coordinates).
* height
- Get/set height of text (in layout coordinates).
* visible
- Get/set whether text is visible (boolean). Default value
is true
.
* rotation
- Get/set rotation of text. Range is [0 ... 360]. Default
value is 0.
* red
- Get/set red colour level for text. Range is [0 ... 255].
Default value is 255.
* green
- Get/set green colour level for text. Range is [0 ... 255].
Default value is 255.
* blue
- Get/set blue colour level for text. Range is [0 ... 255].
Default value is 255.
* alpha
- Get/set alpha level for text. Range is [0 ... 255]. Default
value is 255.
* index_offset
- Get/set offset from current game selection for text
info to display. For example, set to -1 to show text info for the
previous list entry, or 1 for the next list entry. Default value is 0.
* filter_offset
- Get/set filter offset from current filter for the
text info to display. For example, set to -1 to show text info for
a selection in the previous filter, or 1 for the next filter, etc.
Default value is 0.
* bg_red
- Get/set red colour level for text background. Range is
[0 ... 255]. Default value is 0.
* bg_green
- Get/set green colour level for text background. Range is
[0 ... 255]. Default value is 0.
* bg_blue
- Get/set blue colour level for text background. Range is
[0 ... 255]. Default value is 0.
* bg_alpha
- Get/set alpha level for text background. Range is [0 ...
255]. Default value is 0 (transparent).
* charsize
- Get/set the forced character size. If this is <= 0
then Attract-Mode will autosize based on height
. Default value is -1.
* style
- Get/set the text style. Can be a combination of one or more
of the following (i.e. Style.Bold | Style.Italic
):
- Style.Regular
(default)
- Style.Bold
- Style.Italic
- Style.Underlined
* align
- Get/set the text alignment. Can be one of the following
values:
- Align.Centre
(default)
- Align.Left
- Align.Right
* word_wrap
- Get/set whether word wrapping is enabled in this text
(boolean). Default is false
.
* msg_width
- Get the width of the text message, in layout coordinates.
* font
- Get/set the name of the font used for this text. Default is
the layout font name.
* shader
- Get/set the GLSL shader for this text. This can only be set to
an instance of the class fe.Shader
(see: fe.add_shader()
).
* zorder
- Get/set the Text's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.
Member Functions:
set_rgb( r, g, b )
- Set the red, green and blue colour values for the
text. Range is [0 ... 255].set_bg_rgb( r, g, b )
- Set the red, green and blue colour values for
the text background. Range is [0 ... 255].set_pos( x, y )
- Set the text position (in layout coordinates).set_pos( x, y, width, height )
- Set the text position and size (in
layout coordinates).fe.ListBox
The class representing the listbox in Attract-Mode. Instances of this
class are returned by the add_listbox()
functions and also appear in the
fe.obj
array (the Attract-Mode draw list). This class cannot be
otherwise instantiated in a script.
Properties:
x
- Get/set x position of top left corner (in layout coordinates).y
- Get/set y position of top left corner (in layout coordinates).width
- Get/set width of listbox (in layout coordinates).height
- Get/set height of listbox (in layout coordinates).visible
- Get/set whether listbox is visible (boolean). Default value
is true
.rotation
- Get/set rotation of listbox. Range is [0 ... 360]. Default
value is 0.red
- Get/set red colour level for text. Range is [0 ... 255].
Default value is 255.green
- Get/set green colour level for text. Range is [0 ... 255].
Default value is 255.blue
- Get/set blue colour level for text. Range is [0 ... 255].
Default value is 255.alpha
- Get/set alpha level for text. Range is [0 ... 255].
Default value is 255.index_offset
- Not used.filter_offset
- Get/set filter offset from current filter for the
text info to display. For example, set to -1 to show info for the
previous filter, or 1 for the next filter, etc. Default value is 0.bg_red
- Get/set red colour level for background. Range is
[0 ... 255]. Default value is 0.bg_green
- Get/set green colour level for background. Range is
[0 ... 255]. Default value is 0.bg_blue
- Get/set blue colour level for background. Range is
[0 ... 255]. Default value is 0.bg_alpha
- Get/set alpha level for background. Range is [0 ...
255]. Default value is 0 (transparent).sel_red
- Get/set red colour level for selection text. Range is
[0 ... 255]. Default value is 255.sel_green
- Get/set green colour level for selection text. Range is
[0 ... 255]. Default value is 255.sel_blue
- Get/set blue colour level for selection text. Range is
[0 ... 255]. Default value is 0.sel_alpha
- Get/set alpha level for selection text. Range is
[0 ... 255]. Default value is 255.selbg_red
- Get/set red colour level for selection background. Range
is [0 ... 255]. Default value is 0.selbg_green
- Get/set green colour level for selection background.
Range is [0 ... 255]. Default value is 0.selbg_blue
- Get/set blue colour level for selection background.
Range is [0 ... 255]. Default value is 255.selbg_alpha
- Get/set alpha level for selection background. Range is
[0 ... 255]. Default value is 255.rows
- Get/set the number of listbox rows. Default value is 11.charsize
- Get/set the forced character size. If this is <= 0
then Attract-Mode will autosize based on the value of height
/rows
.
Default value is -1.style
- Get/set the text style. Can be a combination of one or more
of the following (i.e. Style.Bold | Style.Italic
):
Style.Regular
(default)Style.Bold
Style.Italic
Style.Underlined
align
- Get/set the text alignment. Can be one of the following
values:
Align.Centre
(default)Align.Left
Align.Right
sel_style
- Get/set the selection text style. Can be a combination
of one or more of the following (i.e. Style.Bold | Style.Italic
):
Style.Regular
(default)Style.Bold
Style.Italic
Style.Underlined
font
- Get/set the name of the font used for this listbox. Default is
the layout font name.format_string
- Get/set the format for the text to display in each list
entry. Magic tokens can be used here, see Magic Tokens for more
information. If empty, game titles will be displayed (i.e. the same
behaviour as if set to "[Title]"). Default is an empty value.shader
- Get/set the GLSL shader for this listbox. This can only be set
to an instance of the class fe.Shader
(see: fe.add_shader()
).zorder
- Get/set the Listbox's order in the applicable draw list. When
objects overlap, the one with the higher zorder will be drawn on top.Member Functions:
set_rgb( r, g, b )
- Set the red, green and blue colour values for the
text. Range is [0 ... 255].set_bg_rgb( r, g, b )
- Set the red, green and blue colour values for
the text background. Range is [0 ... 255].set_sel_rgb( r, g, b )
- Set the red, green and blue colour values
for the selection text. Range is [0 ... 255].set_selbg_rgb( r, g, b )
- Set the red, green and blue colour values
for the selection background. Range is [0 ... 255].set_pos( x, y )
- Set the listbox position (in layout coordinates).set_pos( x, y, width, height )
- Set the listbox position and size (in
layout coordinates).fe.Sound
The class representing an audio track. Instances of this class are returned
by the fe.add_sound()
function. This is also the class for the
fe.ambient_sound
object. Object of this class cannot be otherwise
instantiated in a script.
Properties:
file_name
- Get/set the audio filename. If file_name is contained in
an archive, this string should formatted: "playing
- Get/set whether the track is currently playing (boolean).loop
- Get/set whether the track should be looped (boolean).pitch
- Get/set the audio pitch (float). Default value is 1.x
- Get/set the x position of the sound. Default value is 0.y
- Get/set the y position of the sound. Default value is 0.z
- Get/set the z position of the sound. Default value is 0.duration
- Get the audio track duration (in milliseconds).time
- Get the time that the audio track is current at (in
milliseconds).Member Functions:
get_metadata( tag )
- Get the meta data (if available in the source
file) that corresponds to the specified tag (i.e. "artist", "album", etc.)load_from_archive( archive, filename )
- Load the sound from the
specified archive file (.zip, etc).fe.Shader
The class representing a GLSL shader. Instances of this class are returned
by the fe.add_shader()
function. This class cannot be otherwise
instantiated in a script.
Properties:
type
- Get the shader type. Can be one of the following values:
Shader.VertexAndFragment
Shader.Vertex
Shader.Fragment
Shader.Empty
Member Functions:
set_param( name, f )
- Set the float variable (float GLSL type) with
the specified name to the value of f.set_param( name, f1, f2 )
- Set the 2-component vector variable (vec2
GLSL type) with the specified name to (f1,f2).set_param( name, f1, f2, f3 )
- Set the 3-component vector variable
(vec3 GLSL type) with the specified name to (f1,f2,f3).set_param( name, f1, f2, f3, f4 )
- Set the 4-component vector
variable (vec4 GLSL type) with the specified name to (f1,f2,f3,f4).set_texture_param( name )
- Set the texture variable (sampler2D GLSL
type) with the specified name. The texture used will be the texture
for whatever object (fe.Image, fe.Text, fe.Listbox) the shader is
drawing.set_texture_param( name, image )
- Set the texture variable (sampler2D
GLSL type) with the specified name to the texture contained in "image".
"image" must be an instance of the fe.Image
class.FeVersion
[string]FeVersionNum
[int]The current Attract-Mode version.
FeConfigDirectory
[string]The path to Attract-Mode's config directory.
ScreenWidth
[int]ScreenHeight
[int]The screen width and height in pixels.
ScreenSaverActive
[bool]true if the screen saver is active, false otherwise.
IntroActive
[bool]true if the intro is active, false otherwise.
OS
[string]The Operating System that Attract-Mode is running under. Will be one of: "Windows", "OSX", "FreeBSD", "Linux" or "Unknown"
ShadersAvailable
[bool]true if GLSL shaders are available on this system, false otherwise.