Author Topic: Finally Got Custom Overlay to Work (limited to Exit Attrcat-Mode)  (Read 2195 times)

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
After so many experiments, finally got Custom Overlay to work. Thanks to omegaman's RoboSpin theme layout.nut. This theme was shared by dmmarti here > http://forum.attractmode.org/index.php?topic=1123.msg8202#msg8202.

The working code is >

Code: [Select]
//Custom Overlay Menu

//const OVERLAY_ALPHA =190;

// Overlay Surface
local overlay_surface = fe.add_surface(1920, 1080);
overlay_surface.visible = false;

// Overlay Background
local overlay_background = overlay_surface.add_image("images/black.png",0, 0, 1920, 1080);
overlay_background.alpha = 180;

// Overlay Menu Surface
local overlay_menusurface = overlay_surface.add_surface(600, 300);
overlay_menusurface.set_pos(660, 385.5);

//Overlay Menu Background
local overlay_menubg = overlay_menusurface.add_image("images/exit_overlay.png", 0, 0, 600, 300);

//Overlay Menu List Box
local overlay_listbox = overlay_menusurface.add_listbox(0, 40, 600, 300);
overlay_listbox.rows = 6;
overlay_listbox.set_rgb(150, 150, 150);
overlay_listbox.font = "TulpenOne-Regular-Caps.ttf";
overlay_listbox.charsize  = 50;
overlay_listbox.align = Align.MiddleCentre;
overlay_listbox.sel_style = Style.Bold;
overlay_listbox.selbg_alpha = 0;
overlay_listbox.set_sel_rgb( 255, 255, 255 );

//Overlay Menu Title
local overlay_menutitle = overlay_menusurface.add_text("Exit Attract-Mode?", 0, 20, 600, 100);
overlay_menutitle.font = "TulpenOne-Regular-Caps.ttf";
overlay_menutitle.charsize=80;
overlay_menutitle.align = Align.MiddleCentre;
overlay_menutitle.style = Style.Bold;

// tell Attractmode we are using a custom overlay menu
fe.overlay.set_custom_controls( overlay_menutitle, overlay_listbox );


//  The following function shows or hides the display menu properly

fe.add_transition_callback( "orbit_transition" );
function orbit_transition( ttype, var, ttime )
{
switch ( ttype )
{
  case Transition.ShowOverlay:
overlay_surface.visible = true;
if ( ttime < 255 )
{
overlay_surface.alpha = ttime;
return true;
}
else
{
overlay_surface.alpha = 255;
}
break;
case Transition.HideOverlay:
if ( ttime < 255 )
{
overlay_surface.alpha = 255 - ttime;
return true;
}
else
{
local old_alpha;
old_alpha = overlay_surface.alpha;
overlay_surface.alpha = 0;

if ( old_alpha != 0 )
return true;
}
overlay_surface.visible = false;
break;
}
return false;
}

Pressing Back on Displays Menu which earlier showed the default exit prompt now shows a custom one.



Note: Tried to use permanent slots for "Yes" and "No" (advance list box) but didn't work, tried shuffle and that too didn't works. It seems that AM expects default setup in this case.
« Last Edit: July 16, 2019, 09:27:06 AM by rand0m »