Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: malfacine on November 30, 2015, 04:11:22 PM
-
Make a show image press a key
example press "H" show a image with instructions
Somebody helppp....
-
Here you go:
- Save the code set out below as the file "PopUp.nut" in your attract mode /plugins directory. Change "image.png" to whatever the filename of your image is.
- In Attract-Mode's plugin configuration enable the PopUp plugin. In the controls configuration, map the "custom1" control to whatever you want to trigger the image.
Pushing the key should now flip the selected image on and off...
class PopUpImage
{
_my_image=null;
constructor()
{
_my_image = fe.add_image( "image.png", 0, 0 );
_my_image.visible=false;
fe.add_signal_handler( this, "on_signal" )
}
function on_signal( signal )
{
if ( signal == "custom1" )
{
_my_image.visible=!_my_image.visible;
return true;
}
return false;
}
}
local blah = PopUpImage();
-
Oh man thanks.... ;D
-
Very useful, maybe someone could make a script with options for image path and button.
I tried but couldn't make it work.
-
Here's a plugin version with a few changes... copy the code into plugins/PopupImage.nut
* I changed it to use get_input_state so you can use more than just a specific signal
* Added option to Hold key (default is toggle)
* Make sure to specify the full path to the image, otherwise it will look in the plugins folder
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Image", help="The full path to the image that will be displayed", order=1 />
image="";
</ label="Key", help="The key that will display the image", is_input="yes", order=2 />
key="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=3 />
hold="No";
};
class PopUpImage
{
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_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();
Let me know if you find any issues, then I will add this to my github... :)
-
This is great!
And that addition with "hold-key-to-display" is very user friendly, especially for real cabinet use - this way people not familiar with cabinet won't "lock" themselves in help screen.
Can I display another artwork or text - or it is limited to one image?
-
Here's a plugin version with a few changes... copy the code into plugins/PopupImage.nut
* I changed it to use get_input_state so you can use more than just a specific signal
* Added option to Hold key (default is toggle)
* Make sure to specify the full path to the image, otherwise it will look in the plugins folder
Let me know if you find any issues, then I will add this to my github... :)
Thank you so much! :D
-
This is great!
And that addition with "hold-key-to-display" is very user friendly, especially for real cabinet use - this way people not familiar with cabinet won't "lock" themselves in help screen.
Can I display another artwork or text - or it is limited to one image?
if you hack the "fe.add_image()" to "fe.add_artwork()" in the constructor then I would think this will work for artworks instead of images... you would just have to specify the artwork label you want ("snap", "cpanel"...) in the configuration instead of the "Image"...
-
Here's an updated version.. now just set Is Artwork to Yes and you can use snap, marquee, wheel, etc as the image:
class UserConfig </ help="This plugin will show a popup image when the specified button is pressed." /> {
</ label="Image", help="The full path to the image that will be displayed", order=1 />
image="";
</ label="Is Artwork" help="If enabled, the image is the selected artwork type", options="Yes,No" order=2 />
is_art=false;
</ 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
{
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
_is_art = false;
constructor()
{
local config = fe.get_config();
_is_art = config["is_art"];
_image = ( _is_art ) ? fe.add_artwork( config["image"], 0, 0, fe.layout.width, fe.layout.height ) : 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 )
{
if ( !fe.overlay.is_up )
{
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();
Also fixed so the key has no effect when the fe.overlay is up (i.e. in config)
-
This is a great script, I was wondering if you could offer some help in getting user specific sizes for the image to be used.
If I add say:
</ label="Image Height", help="Choose the image height", order=5 />
hsize="";
</ label="Image Width", help="Choose the image width", order=6 />
wsize="";
I doesn't work if I try to then get the config information under the constructor using:
_image = fe.add_image( config["image"], 0, 0, config["hsize], config["wsize"]);
// _image = fe.add_image( config["image"], 0, 0, 100, 100); This does work of course!
I'm not great with programming so any help would be appreciated!
thanks
-
This is a great script, I was wondering if you could offer some help in getting user specific sizes for the image to be used.
If I add say:
</ label="Image Height", help="Choose the image height", order=5 />
hsize="";
</ label="Image Width", help="Choose the image width", order=6 />
wsize="";
I doesn't work if I try to then get the config information under the constructor using:
_image = fe.add_image( config["image"], 0, 0, config["hsize], config["wsize"]);
// _image = fe.add_image( config["image"], 0, 0, 100, 100); This does work of course!
I'm not great with programming so any help would be appreciated!
thanks
You need to convert the string to an integer using the built in function tointeger()
-
That's great, thank you. All working :)
-
instead of a stored image I have a url to my surveillance camera feed. Could that be used in place of an image somehow? the url is just my ip address and port
-
instead of a stored image I have a url to my surveillance camera feed. Could that be used in place of an image somehow? the url is just my ip address and port
No. If you have something as important as a surveillance, my suggestion for the time being is to buy a dedicated rpi and have it output to a dedicated monitor. Perhaps you could use a smart strip and have it turn on a monitor when it senses motion? If you find an 8 inch cut, the rip could probably fit inside and make a cool project. Unless your a pro at coding and want to add http functionality to attract mode, or create a borderless webkit app and pin it to the corner of the monitor when monition is detected.
-
Here's a plugin version with a few changes... copy the code into plugins/PopupImage.nut
* I changed it to use get_input_state so you can use more than just a specific signal
* Added option to Hold key (default is toggle)
* Make sure to specify the full path to the image, otherwise it will look in the plugins folder
class UserConfig </ help="This plugin will show a popup image when the specified key is pressed." /> {
</ label="Image", help="The full path to the image that will be displayed", order=1 />
image="";
</ label="Key", help="The key that will display the image", is_input="yes", order=2 />
key="";
</ label="Hold Key", help="If enabled, you must hold the key down", options="Yes,No", order=3 />
hold="No";
};
class PopUpImage
{
_image = null;
_key = null;
_hold = false;
_showing = false;
_key_delay = 250;
_last_check = 0;
constructor()
{
local config = fe.get_config();
_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();
Let me know if you find any issues, then I will add this to my github... :)
right now its displaying snaps. how can i get it to display the boxart. im not seeing what i would change
-
Thanks for this guys!
I used CPWizard to export all my control panel layouts (because loading CPWizard dynamically was WAAAYYY too slow and glitchy).
Then moved all those exported images to a cpanelwiz directory.
Added a new artwork for cpanel to link to that directory.
Configured your plugin to do artwork and cpanel and voila! Hit a button with game select and get instant display of controls.
---
Now I just need to add a little more such as turning the pop-up off if the user changes game (moves up and down).
Cheers
Tim
EDIT: And of course there is an issue with CPWizards export function... only a bunch of the batch exports worked, the rest are defaulted. Back to trying to get showcp plugin to work.
-
This is a neat plugin.
Question / Idea:
Modify the plugin to load folder's worth of images (or, better yet, a zip/cbz of images) that are named/ordered numerically (01.jpg - 09.jpg for instance) into an array or whatever and then display them / navigate through them with left/right.
You'd essentially have a game instruction booklet popup plugin that way.
My idea of workflow:
-Set custom key for plugin to "M" (non-hold)
-Load contents of folder/zip into memory, path based on current rom name (much like snap/wheel artwork)
-Display image 1 (or a default 'no content' image if folder/zip empty/nonexistent)
-Left / Right scrolls through images sequentially
-"M" again closes.
-
This is a neat plugin.
Question / Idea:
Modify the plugin to load folder's worth of images (or, better yet, a zip/cbz of images) that are named/ordered numerically (01.jpg - 09.jpg for instance) into an array or whatever and then display them / navigate through them with left/right.
You'd essentially have a game instruction booklet popup plugin that way.
My idea of workflow:
-Set custom key for plugin to "M" (non-hold)
-Load contents of folder/zip into memory, path based on current rom name (much like snap/wheel artwork)
-Display image 1 (or a default 'no content' image if folder/zip empty/nonexistent)
-Left / Right scrolls through images sequentially
-"M" again closes.
Check it. :)
http://forum.attractmode.org/index.php?topic=939.msg7057#msg7057
-
Is there a way to have the screen automatically display when a game is selected? Or have the popup button automatically “pressed†on game selection?
It would be great for the user to be able to see a “How to Play†screen upon selecting a game. That screen could have an instruction the user to press the button defined in the pop up plugin to switch to the game selected.
-
Is there a way to have the screen automatically display when a game is selected? Or have the popup button automatically “pressed†on game selection?
It would be great for the user to be able to see a “How to Play†screen upon selecting a game. That screen could have an instruction the user to press the button defined in the pop up plugin to switch to the game selected.
Yes sure , just need to create a new "artwork" on your layout , for example:
local controlpanel = fe.add_artwork("controlpanel", 0, 10 100, 100);
And then add the path into your emulator.cfg
artwork controlpanel C:\media\cpanel
-
sorry for the necroposting
but i need some help with this plug-in
right now i'm using the "second" version (without Artwork selection)
and it work fine and i'm able do show just one image
but when i try the version with the Artwork nothing happen.....what i'm doing wrong?
i need to modify something in the script to view multiple Artwork?
i'm using Raspberry pi3 b+
thank you
-
i say no plugin just use, a script in your, layout...to show no-show, the graphical instructions you need, using the , title name..right..
using like custom1, ext...map keys
all though...im using a plugin that loads a pdf manual of the game....and i do fancy it well....
-
Jedione how plugin you use? i use one here sumatra and works good but after load PDF i put right or left for read the manual the attractmode in background go to sides change games in list, i need after load the plugin block/disable the controles in background/attractmode so and after closes the plugin/sumattra back controles to attractmode!!! you understand?