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

kent79

  • Hero Member
  • *****
  • Posts: 842
    • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • 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

  • Hero Member
  • *****
  • Posts: 842
    • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • 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

  • Hero Member
  • *****
  • Posts: 842
    • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • 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

  • Hero Member
  • *****
  • Posts: 842
    • 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

  • Hero Member
  • *****
  • Posts: 842
    • 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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • 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

  • Hero Member
  • *****
  • Posts: 842
    • 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?

Denis delamare

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #10 on: September 20, 2017, 07:35:33 PM »
Hello guys!
I have looked all the site topics but find no answer to this topic.
Please, tell us how you made the code to back to menu after a idle time

jedione

  • Hero Member
  • *****
  • Posts: 1135
  • punktoe
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #11 on: September 20, 2017, 09:24:38 PM »
it's posted in kents latest theme ,,,,   but here is the code in a .nut file

https://www.dropbox.com/s/e4c186rzy5th75q/timer.nut?dl=0

how it works...   drop this "timer.nut" file in your theme
then add this to the end of your "layout.nut" file in your theme

fe.do_nut("timer.nut");

after your good togo,   if needed....though..   just ajust,,   time,,,   position,,   and font,,,    as necessary K.




help a friend....

DimaKompot

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Is it possible after a certain time back to display menu?
« Reply #12 on: December 06, 2023, 05:01:04 AM »
it's posted in kents latest theme ,,,,   but here is the code in a .nut file

https://www.dropbox.com/s/e4c186rzy5th75q/timer.nut?dl=0

how it works...   drop this "timer.nut" file in your theme
then add this to the end of your "layout.nut" file in your theme

fe.do_nut("timer.nut");

after your good togo,   if needed....though..   just ajust,,   time,,,   position,,   and font,,,    as necessary K.

Hello, I am trying to use this nut in the standard Orbit layout, but it doesn't work. I added timer.nut to my layout folder and put fe.do_nut("timer.nut"); at the end of layout file. But I don't see the configuration anywhere in the options and also it doesn't go to the main menu after 2 minutes. Perhaps something was changed in last few years?