Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Arcade-TV on January 30, 2019, 01:26:04 AM
-
Hey guys,
I'd like to thank you for all the efford that went into attract mode. Having the freedom of doing so much with it is just awesome.
I'm creating a layout for a 240p-setup to be outputted to a crt and ran into some questions I'd like to sort out.
First issue is with the default font and missing font-size parameter for it:
The font-size is calculated by the layout's size. Mine is 320x240 so the font in my "Configure"-menu is appx. 8px in height, which is okay as long as I use a pixel-font that was created with 8px height in mind. The help-messages on the bottom of the menu are rendered smaller, appx 5px in height in my layout, so again, if I use a font like "CG pixel 4x5" those texts display just fine but the menu-items don't display properly because the 5px font is stretched to a height of 8px.
I would love to see some more parameters to target this issue maybe sometime in the future development of attract mode.
Next is a scripting question about creating a condition for "DisplayName". This does exist as a Magic Token so it can be used in "add_text" but when I want to create a condition I fail to do something like this:
if([DisplayName] == "Displays Menu"){
// code for the layout where I can select the different displays/systems
}else{
// code for layouts that relate to a display/emulator/gamelist
}
I use snaps with a low alpha value in the background and titles as a small preview image in my layout. When a display has a lot of entries in its gamelist I see performance issues while navigating through the list of games, so I'd like to remove all media while browsing and add it back to the layout after a delay-timer counted to a given value. I've seen concepts like this in other threads but I have to ask:
How can remove an image or artwork and use a function to add it to the layout.
Something like this, called on transition-callbacks doesn't seem to work:
function showImage(){
fe.add_image(...);
}
I sure have some more questions, but for a start this is enough ;-)
Thanks, any help with this is very much appreciated!
-
Welcome to the forums!
1- You can use charsize to force font size
local Oview = fe.add_text"[Overview]", #,#,#,#)
Oview.charsize = 20; //Specificy charsize
2- Not sure, I *think* code should be something like
if ((fe.displays[fe.list.display_index].name) == "[Specific Display")
do this
3- U can use following for images:
local flyer = fe.add_artwork( "flyer", 670, 130, 450, 610 ); //can be any artwork or image
flyer.trigger = Transition.EndNavigation; //doesn't load all images at once, effects browsing speed in large lists
flyer.mipmap = true;// have a huge effect on performance specially when images are large and shown in AM in reduced size
-
You can always edit cfg files using nano or vim. This isn’t something a user should have to mess with while playing. However, try it on an actual crt at 240p. Default install is ok to view minus certain characters like a period. It would be nice to fix, but don’t overthink it because it doesn’t really matter in my opinion.
My layout I’m using percentages for everything including fonts. You will find a percentage that works.
-
You can always edit cfg files using nano or vim.
True, but as far as I'm aware, there are no parameters for font-size, only for the default font to use.
In Layouts it's different, but I was targeting the menu that is hardcoded within attract mode.
Or what cfg are you referring to?
Thanks!
-
Another thing that I can't sort out is the screensaver.
I'm on Ubuntu Server 18.04 LTS and already added the console blanking command to my grub file.
In RetroArch, when a game is running the screen will stay on forever, but in Attract Mode it blanks after a short time.
I dunno how it's done in RA but I'd love to disable any (system-)screen blanking or screensaver for good.
(this is not related to AM-screensaver)
If anybody has an idea, I'd love to hear it.
-
You can always edit cfg files using nano or vim.
True, but as far as I'm aware, there are no parameters for font-size, only for the default font to use.
In Layouts it's different, but I was targeting the menu that is hardcoded within attract mode.
Or what cfg are you referring to?
Thanks!
Everything in the config menu GUI can also be found in attract.cfg and [emulator].cfg files. I can tell you that the menu is not the best, but legible enough to use at 240p.
-
With your help I already sorted some problmens I had out, thanks!
Is there a way to re-assign the signals or the way a listbox is navigated?
I'd like to have a horizontal control scheme on start in the displays-menu, then a classical list - a bit like EmulationStation works.
My idea is to position a list and set it to ".visible = false", then animating the system-logos on a horizontal line.
Now I guess I just need to tell the list it has to react to "left/right" instead of "up/down" by manipulating the default signals...?
Is there something like dynamic assignment?
In other languages this might work:
array = {1,2,3,4,5};
which_element = "element_" + array[0];
which_element.animate(); // -> should be the same as: element_1
or like this
for(i=0;i<10;i++){
["element"+i].doSomething;
}
in other words: is there a way to make up an object's name out of a string + a variable and then do something with it?
-
So long as your "composite" element exists on the main table (fe), you should be able to do what you want. I have a bunch of variables that I've defined like this (for example):
this.rom_1942 <- {
"btnA": "Fire",
"btnB": "Loop"
}
Later, in a function, I want to get the values of btnA, btnB, etc., based on the currently selected game, so I reference it like this, for example:
::print( this["rom_" + fe.game_info(Info.Name)].btnA + "\n" ); // Prints "Fire" (no quotes) to the console
That's off the top of my head. I'm not in front of my "real" code, but I think the above is accurate.
-
It's coming together.. bit by bit, thanks guys!
Is there a way to prevent AM from jumping into another Display when I hit left or right in the "Displays Menu"?
I'd like to do custom stuff when up/down/left/right is pressed and I can't find a way to unbind the default signals/actions.
edit:
I think I solved this one...
I'll post my code when it's ready.
-
I'm looking for an elegant way to create this by the number of displays with a loop:
::OBJECTS <- {
sys0 = "",
sys1 = "",
sys2 = "",
sys3 = "",
sys4 = "",
sys5 = "",
sys6 = "",
sys7 = "",
sys8 = "",
sys9 = "",
sys10 = "",
sys11 = "",
sys12 = ""
}
-
::Displays = {};
for ( local i = 0; i < fe.displays.len(); i++ ) {
::Displays["sys" + i] = fe.displays[i];
}
/*
Access slots like this (these are all equivalent):
::Displays.sys0;
::Displays["sys0"];
::Displays["sys" + 0.tostring()];
*/
That should work (not at home: can't test it), but it just gives you a table-ized version of the already existing fe.displays array. Unless you're passing something else where I've included fe.displays
-
I had the same solution, but without the "::" (What does it mean?)
But it doesn't seem to work:
Script Error in /opt/retropie/configs/all/attractmode/layouts/012019-menu/layout.nut - the index 'sys1' does not exist
edit:
ha! Got the solution here: https://developer.valvesoftware.com/wiki/Squirrel#Tables
The assignment outside a table has to be a key/value pattern with "<-" instead of an equal-sign :-)
Thanks!
-
Another day - another question...
When I create a surface to "group" images that are aligned horizontally,
must it be the exact size of the layout?
I'm asking because when I create a surface that is 10x wider than the layout it just disappears...
-
Is there a opposite method for add_x? Like remove_image and remove_artwork?
Also, I see that the base for positioning a video is top/left. Could it be that this is different for images?
When I do
fe.add_image("myImage.extension", 0, 0, layout_with/2, layout_height/2);
it looks like the horizontal center is off to the left...
I'm still struggeling to disable the screen blank in AttractMode.
-
Is there a opposite method for add_x? Like remove_image and remove_artwork?
Also, I see that the base for positioning a video is top/left. Could it be that this is different for images?
When I do
fe.add_image("myImage.extension", 0, 0, layout_with/2, layout_height/2);
it looks like the horizontal center is off to the left...
I'm still struggeling to disable the screen blank in AttractMode.
You can toggle visibility, opacity, change path to empty string, or possibly changing the variable (haven’t actually tried the latter, but assume it would work).
Images will stretch (default) to the dimensions provided, and be placed at the location provided. Horizontal center of the image is off to the left of the screen because that is where you placed the image. Image is placed in the top left of your layout, and is half the size of your layout. You need to change your position if you want the image centered horizontally within your layout.
Not sure what a screen blank is.
-
Not sure what a screen blank is.
or a console-blanking, when the screen turns off - a screensaver.
as I said I already went for the grub-option but it's not working.
RetroArch has some kind of disabling that works a charm...
-
Not sure what a screen blank is.
or a console-blanking, when the screen turns off - a screensaver.
as I said I already went for the grub-option but it's not working.
RetroArch has some kind of disabling that works a charm...
What distro are you using?
-
What distro are you using?
Ubuntu Server 18.04 LTS
-
What distro are you using?
Ubuntu Server 18.04 LTS
A lot of answers in this thread might help you: https://askubuntu.com/questions/138918/how-do-i-disable-the-blank-console-screensaver-on-ubuntu-server
-
Unfortunately I already tried every grub-related solution prior to my post and none of those work for me.
Must be something related to X, I dunno.
-
I have decided to use 2 layouts, one for menu and one for lists.
Now, if I wanted to return from a display straight into the last viewed system I need to fill and read a global variable.
In my menu layout:
if(::last_display_index){
jumpToSystem(::last_display_index);
}else{
jumpToSystem(0);
}
and in the Emulator/List layout:
::last_display_index = fe.list.display_index;
This kind of declaration must be wrong, because I always get "The index last_display_index does not exist."[/s]
edit:
The solution to this was rather simple...
local sys_index = fe.list.index;
local sys_index_name = fe.displays[sys_index].name;
my "sys_index" controlls the system to show.
-
I think I managed to get rid of the screensaver by disabling DPMS with "xset":
Check for any blanking, screensaver, timeouts and DPMS (Energy Star) with
xset q
Disable DPMS:
xset -dpms
Don't forget to add these to a script and execute it on startup.