Attract-Mode Support > Scripting

Is it possible after a certain time back to display menu?

(1/3) > >>

kent79:
Is it possible after a certain time there was an exit game list theme back to display menu?

My concept is written a script in game list theme,

when idle 30 sec, then press "back" command, let it back to display menu.

I don't know the script, Could any one provide the code. Thanks.

keilmillerjr:
Yes. I've done it. I'll see if I can find the code tonight or tomorrow. Here's a basic outline from memory of what I did.

Create an object with tick and timer variables. Object has a tick function that updates the tick variable so it can be used in other object functions. Same function or separate function will also will add time to the timer variable. If timer variable reaches limit, then do whatever you want. Object also has function that listens for key press and resets timer back to zero.

That's what I did to implement my own screensaver.

kent79:

--- Quote from: keilmillerjr on July 30, 2017, 03:43:20 PM ---Yes. I've done it. I'll see if I can find the code tonight or tomorrow. Here's a basic outline from memory of what I did.

Create an object with tick and timer variables. Object has a tick function that updates the tick variable so it can be used in other object functions. Same function or separate function will also will add time to the timer variable. If timer variable reaches limit, then do whatever you want. Object also has function that listens for key press and resets timer back to zero.

That's what I did to implement my own screensaver.


--- End quote ---

Yeah, I know the concept, but I don't know exactly coding. Could you provide sample? Thanks.

keilmillerjr:
Here’s the screensaver code I created. It should be enough to get you going on an object that will take care of what you want. Its essentially the same concept of doing something after a period of inactivity.

In this example, I used FadeArt to display video and had all other elements on the surface „osd“. That surface would disappear leaving just the video as a screensaver to prevent screen burn in. Could also modify it to select random games as well.


--- Code: ---//
// ScreenSaver
//

class ScreenSaver {
  active = false;
  delay = null;
  fade_time = 50;
 
  time = 0;
  last_signal = 0;
 
  constructor( sec ) {
    delay = sec.tointeger()*1000;
   
    fe.add_ticks_callback( this, "Timer" );
    fe.add_transition_callback( this, "LastSignal" );
    fe.add_signal_handler( this, "BlockSignals" );
    fe.add_ticks_callback( this, "Start" );
    fe.add_ticks_callback( this, "FadeOut" );
    fe.add_transition_callback( this, "End" );
  }
 
  // private functions
 
  function Timer( ttime ) {
    time = ttime;
  }
 
  function LastSignal( ttype, var, ttime ) {
    last_signal = time;
  }
 
  function BlockSignals( signal ) {
    if ( active )
      return true;
    return false;
  }
 
  function Start( ttime ) {
    if ( !active && ( ttime >= last_signal + delay ) )
      active = true;
  }
 
  function FadeOut( ttime ) {
    if ( active && ( osd.alpha != 0 ) )
      osd.alpha -= 255/fade_time;
  }
  ^%≥÷∂f,-p;
  []\]\]
  function End( ttype, var, ttime ) {
    if ( active ) {
      active = false;
      osd.alpha = 255;
    }
  }
}

if ( config["screensaver"] == "Yes" )
  local screen_saver = ScreenSaver( config["screensaver_delay"] );

--- End code ---

kent79:
Sorry, My skill doesn't good enough to complete code. Could you help to complete it ?

Target:
idle time = 60 sec
then fe.signal( "displays_menu" )

Many Thanks

Navigation

[0] Message Index

[#] Next page

Go to full version