Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: therick3 on April 14, 2025, 01:23:48 PM
-
Update for PopUp.net:
As you move through game list this allows a person to press a key and have a specific image (using the game name) to appear. Great to show game instructions and control layout before selecting a game:
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Path to instructions, from .attract folder",
help="Enter full path assuming you start from .attract folder.", order=1 />
filePath="/scraper/mame/launch/";
// </ label="Image", help="The full path to the image that will be displayed", order=1 />
// image="";
</ label="Select file extension of instruction file",
help="File extension to use when opening instructions (png or jpg)", options="png,jpg", order=2 />
fileExtension="png";
</ label="Key", help="The key that will display the image", is_input="yes", order=3 />
key="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=4 />
hold="No";
};
class PopUpImage
{
fileExtension = null;
filePath = null;
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
filePath = config["filePath"];
fileExtension = config["fileExtension"];
print(filePath+"[Name]."+fileExtension+"\n")
_image = fe.add_image(filePath+"[Name]."+fileExtension, 0, 0, fe.layout.width, fe.layout.height);
// _image = fe.add_image(config["image"], 0, 0, fe.layout.width, fe.layout.height );
_image.visible=false;
_image.preserve_aspect_ratio = true;
_key = config["key"];
_hold = config["hold"];
fe.add_ticks_callback( this, "on_tick" );
}
function on_tick( ttime )
{
local is_down = fe.get_input_state( _key );
if ( _hold == "Yes" )
{
_image.visible = is_down;
_showing = is_down;
} else
{
if ( is_down )
{
if ( ttime - _last_check > _key_delay )
{
_last_check = ttime;
_image.visible = !_showing;
_showing = !_showing;
}
}
}
}
}
fe.plugin[ "PopUpImage" ] <- PopUpImage();