mirror of
https://github.com/mickelson/attract.git
synced 2026-10-12 02:18:55 +00:00
- The frontend now includes the "SpecificDisplay" plugin which can be configured to show a specific display when particular custom input is received. - Exposed the fe.Display and fe.Filters arrays for plugin and layout access from within the config menu
69 lines
1.5 KiB
Plaintext
69 lines
1.5 KiB
Plaintext
///////////////////////////////////////////////////
|
|
//
|
|
// Attract-Mode Frontend - SpecificDisplay plugin
|
|
//
|
|
///////////////////////////////////////////////////
|
|
class UserConfig </ help="Load a specific display on custom input" /> {
|
|
|
|
</ label="Display to Show", help="The display to be shown when input is recieved", order=1, options="" />
|
|
display="";
|
|
|
|
</ label="Trigger",
|
|
help="The custom command that will show this display (see also: Config->Controls->Costom#)",
|
|
order=2, options="Custom1,Custom2,Custom3,Custom4,Custom5,Custom6" />
|
|
trigger="";
|
|
};
|
|
|
|
local dattr = UserConfig.getattributes("display");
|
|
foreach ( d in fe.displays )
|
|
{
|
|
if ( dattr["options"].len() < 1 )
|
|
dattr["options"] = d.name;
|
|
else
|
|
dattr["options"] += "," + d.name;
|
|
}
|
|
|
|
UserConfig.setattributes("display", dattr);
|
|
|
|
class SpecificDisplay
|
|
{
|
|
trigger = "";
|
|
display_index = 0;
|
|
|
|
constructor()
|
|
{
|
|
local my_config = fe.get_config();
|
|
|
|
trigger = my_config["trigger"].tolower();
|
|
|
|
for ( local i=0; i<fe.displays.len(); i++ )
|
|
{
|
|
if ( fe.displays[i].name == my_config[ "display" ] )
|
|
{
|
|
display_index = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if ( display_index == -1 )
|
|
{
|
|
print( "SpecificDisplay plugin: could not find configured display: "
|
|
+ my_config["display"] + "\n" );
|
|
display_index = 0;
|
|
}
|
|
|
|
fe.add_signal_handler( this, "on_signal" );
|
|
}
|
|
|
|
function on_signal( signal_str )
|
|
{
|
|
if ( signal_str == trigger )
|
|
fe.set_display( display_index );
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
fe.plugin[ "SpecificDisplay" ] <- SpecificDisplay();
|
|
|