Author Topic: Is it possible after a certain time back to display menu?  (Read 157 times)

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Is it possible after a certain time back to display menu?
« on: July 30, 2017, 08:29:41 AM »
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

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #1 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.

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #2 on: July 30, 2017, 07:02:23 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.


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

keilmillerjr

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #3 on: July 30, 2017, 08:14:34 PM »
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: [Select]
//
// 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"] );

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #4 on: July 31, 2017, 06:22:20 AM »
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

keilmillerjr

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #5 on: July 31, 2017, 07:17:34 AM »
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

I'll make you a class possibly tonight for you to test.

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #6 on: July 31, 2017, 10:36:58 PM »
Many Thanks and look forward the good news  ;D

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #7 on: August 05, 2017, 05:59:57 PM »
Dear keilmillerjr,

Well, I know how to do it finally and will be added in new theme. Thank you for your kindly help  :)
« Last Edit: August 05, 2017, 09:01:20 PM by kent79 »

keilmillerjr

  • Sr. Member
  • ****
  • Posts: 285
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #8 on: August 06, 2017, 03:09:21 AM »
Dear keilmillerjr,

Well, I know how to do it finally and will be added in new theme. Thank you for your kindly help  :)

Woohoo!

Sorry, I've been busy trying to chase my stolen motorcycle that my broke ass was too poor for full insurance. Me moving near my work hasn't gone well.

kent79

  • Sr. Member
  • ****
  • Posts: 346
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #9 on: August 06, 2017, 08:36:29 AM »
OH ~~~~ Sorry to hear about it. Are you ok now?