mickelson / attract

A graphical front-end for command line emulators that hides the underlying operating system and is intended to be controlled with a joystick or gamepad.
http://attractmode.org
GNU General Public License v3.0
393 stars 115 forks source link

When starting AM configured to show Displays menu, plugin transition ToNewList fires twice. #614

Closed arzoo1 closed 4 years ago

arzoo1 commented 4 years ago

When AM is configured with startup_mode = displays_menu, any plugin using a transition callback will receive two sets of transitions back-to-back; The first will be StartLayout and ToNewList for the last selected item in the displays menu, and the second will be StartLayout and ToNewList for the Displays menu itself. The first set of transition callbacks (for the last selected item) are not needed and should not be triggered.

arzoo1 commented 4 years ago

The order in which the plugin receives the first two transition callbacks is random.

pcca-matrix commented 4 years ago

I noticed that to get around it, set return false if transitions ttime = 0

arzoo1 commented 4 years ago

Can you elaborate? It seems like ttime is always = 0 and per the documentation, I always return false.

pcca-matrix commented 4 years ago

as long you use same layout for display menu and system

start_time <- 0;

fe.add_transition_callback( "hs_transition" );
function hs_transition( ttype, var, ttime )
{       
    switch ( ttype )
    {
        case Transition.ToNewList:
            if( start_time ){ // newlist transition

            }else{ // discard newlist transition when fired at startlayout         
                return false;
            }
        break;
    }
}

fe.add_ticks_callback( "hs_tick" );
function hs_tick( ttime )
{
    start_time=ttime;
}    
mickelson commented 4 years ago

Hey there, this should be fixed now in the master dev branch. thanks for the report and the description