Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: Wenzon on April 30, 2020, 10:33:54 AM
-
I would like to change the message when adding a game to favorites. By default, it is displayed like this in AM ...
Add <game name> to Favourites?
I would like it to be displayed that way.
Add to Favourites?
Could someone help me with a script to solve this problem?
-
hope somone can help u ,,,would be nice to know how,
i just remove comferation through Am ,dont even like it asking weather it should add or remove......i know it is doing what is needed...
-
Edit /attract/language/en.msg and add this on line #5
Add '$1' to Favourites?;Add to Favourites?
FYI - This is the file for English. If you're using a different language modify it's corresponding file.
-
In your transition callback function check if Transition.ShowOvwrlay is triggered and if type is Overlay.Favourites you can change the text.msg field of your custom overlay controls. Of course this works if you are using custom overlay controls
-
I love your passion and understand what you're saying but if this question needed to be asked, I assume they aren't coders. I was just giving a simple answer to the question.
This will also work across all layouts and not just one.
-
I love your passion and understand what you're saying but if this question needed to be asked
You are right, your solution is better for non-coders, but sometimes even a coder is not aware of all the tricks you can play to make Attract Mode do what you really want ;D
-
Edit /attract/language/en.msg and add this on line #5
Add '$1' to Favourites?;Add to Favourites?
FYI - This is the file for English. If you're using a different language modify it's corresponding file.
Excellent tip!
In your transition callback function check if Transition.ShowOvwrlay is triggered and if type is Overlay.Favourites you can change the text.msg field of your custom overlay controls. Of course this works if you are using custom overlay controls
Could you give an example using the method you mentioned?
-
This is the portion of transition callback you have to use in the Layout
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var0, ttime ) {
if (ttype == Transition.ShowOverlay) {
if (var0 == Overlay.Favourite) overlay_label.msg ="Your Message Here"
}
}
and overlay_label, overlay_listbox is a text object and a listbox object defined as custom control using:
fe.overlay.set_custom_controls( overlay_label, overlay_listbox )
-
This is the portion of transition callback you have to use in the Layout
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var0, ttime ) {
if (ttype == Transition.ShowOverlay) {
if (var0 == Overlay.Favourite) overlay_label.msg ="Your Message Here"
}
}
and overlay_label, overlay_listbox is a text object and a listbox object defined as custom control using:
fe.overlay.set_custom_controls( overlay_label, overlay_listbox )
I tried to make changes based on your information but unfortunately it didn't work.
I don't understand programming and I have a little difficulty in the English language, but I am hardworking.
If you can help me with the code I'm using, I would appreciate it.
See below.
// Overall Surface
local overlaySurface = fe.add_surface(1920,1080);
overlaySurface.visible = false;
// create extra surface for the menu
local overlayMenuSur = overlaySurface.add_surface(661,581);
overlayMenuSur.set_pos(284,160);
overlayMenuSur.add_image("images/screen.png", 0, 40, 660, 541);
local overlay_lb = overlayMenuSur.add_listbox(1,150,661,380);
overlay_lb.rows = 9;
overlay_lb.charsize = 40;
overlay_lb.set_rgb( 128, 128, 128 );
overlay_lb.font="Ledsitex St";
overlay_lb.set_sel_rgb( 255, 255, 255 );
overlay_lb.set_selbg_rgb( 0, 0, 0 );
overlay_lb.selbg_alpha = 0;
local overlayMenuTitle = overlayMenuSur.add_text("",0,80,660,35);
overlayMenuTitle.charsize=50;
overlayMenuTitle.font="Ledsitex St";
overlayMenuTitle.set_rgb(255,165,0);
fe.add_transition_callback( "orbit_transition" );
function orbit_transition( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.ShowOverlay:
overlaySurface.visible = true;
if ( ttime < 255 )
{
overlaySurface.alpha = ttime;
return true;
}
else
{
overlaySurface.alpha = 255;
}
break;
case Transition.HideOverlay:
if ( ttime < 255 )
{
overlaySurface.alpha = 255 - ttime;
return true;
}
else
{
local old_alpha;
old_alpha = overlaySurface.alpha;
overlaySurface.alpha = 0;
if ( old_alpha != 0 )
return true;
}
overlaySurface.visible = false;
break;
}
return false;
}
// tell Attractmode we are using a custom overlay menu
fe.overlay.set_custom_controls( overlayMenuTitle, overlay_lb );
-
I tried to make changes based on your information but unfortunately it didn't work.
I took a look at your code, the menu works fine but in my test it shows "behind" the usual UI of Attract Mode (the plain list with the snap background). I don't know why it happens, probably because your layout doesn't have any element besides that layout surface.
By the way if you change your case like this, adding just that single line:
case Transition.ShowOverlay:
overlaySurface.visible = true;
if (var == Overlay.Favourite) overlayMenuTitle.msg = "CUSTOM MESSAGE"
if ( ttime < 255 )
{
overlaySurface.alpha = ttime;
return true;
}
else
{
overlaySurface.alpha = 255;
}
break;
you can have the custom message when add favourite is shown
-
I tried to make changes based on your information but unfortunately it didn't work.
I took a look at your code, the menu works fine but in my test it shows "behind" the usual UI of Attract Mode (the plain list with the snap background). I don't know why it happens, probably because your layout doesn't have any element besides that layout surface.
By the way if you change your case like this, adding just that single line:
case Transition.ShowOverlay:
overlaySurface.visible = true;
if (var == Overlay.Favourite) overlayMenuTitle.msg = "CUSTOM MESSAGE"
if ( ttime < 255 )
{
overlaySurface.alpha = ttime;
return true;
}
else
{
overlaySurface.alpha = 255;
}
break;
you can have the custom message when add favourite is shown
Thank you!!! It worked perfectly zpaolo11x. :D
I thank you and progets for taking the time to try to solve this problem. In both cases, the code works perfectly.