Author Topic: reset - reload layout  (Read 677 times)

Giacomo1982

  • Full Member
  • ***
  • Posts: 72
    • View Profile
reset - reload layout
« on: December 15, 2018, 06:51:25 AM »
Is it possible to reload the theme with fe.signal()?

There was a discussion with no answer 3 years ago.

http://forum.attractmode.org/index.php?topic=312.msg2235#msg2235

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 845
    • View Profile
Re: reset - reload layout
« Reply #1 on: December 15, 2018, 07:05:11 AM »

Giacomo1982

  • Full Member
  • ***
  • Posts: 72
    • View Profile
Re: reset - reload layout
« Reply #2 on: December 15, 2018, 07:20:05 AM »
Thanks!!!   :D

Giacomo1982

  • Full Member
  • ***
  • Posts: 72
    • View Profile
Re: reset - reload layout
« Reply #3 on: December 15, 2018, 08:30:03 AM »
What i want is resetting the animation when ToNewSelection AND when ToNewList

animation module allows one only transition type

I thinked resetting the layout as with change filter ( CTRL + right arrow ) could reset animation but not...

fe.signal("reload")

and with your plug in animations continue running



qqplayer

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: reset - reload layout
« Reply #4 on: December 16, 2018, 05:00:15 AM »
What i want is resetting the animation when ToNewSelection AND when ToNewList

animation module allows one only transition type

I thinked resetting the layout as with change filter ( CTRL + right arrow ) could reset animation but not...

fe.signal("reload")

and with your plug in animations continue running

Try Transition.StartLayout

spud1

  • Full Member
  • ***
  • Posts: 39
    • View Profile
Re: reset - reload layout
« Reply #5 on: December 18, 2018, 05:59:27 PM »
I'm also looking to adapt keilmillerjr's plugin so that I can call on it automatically either at time intervals or without pressing a key, rather than having to press the R key to invoke it.  Not quite sure how to do that and would be grateful for any help please. 

In the meantime, using  keilmillerjr's code, I just stripped out the framerate code leaving the reload layout code. 

I place "plugin.nut" in a sub-folder of "plugins" called "Reload", then enable it and set it to the R key under Controls.

Code: [Select]
// --------------------
// Load Modules
// --------------------
fe.load_module("helpers");

// --------------------
// Plugin User Options
// --------------------
class UserConfig </ help="A plugin that reloads layouts with a key press." /> {
</ label="Reload Layout Key",
help="The key that triggers the layout to reload. Use Custom 2.  Remember to set the key in Controls.  Set the key to R",
options="Custom1, Custom2, Custom3, Custom4, Custom5, Custom6",
order=1 />
reloadKey="Custom2";
}

// --------------------
// Reload
// --------------------
class Reload {
config = null;

reloadKey = null;


constructor() {
// Config
config = fe.get_config();

// Reload Layout
reloadKey = config["reloadKey"].tolower();
fe.add_signal_handler(this, "reload");

}

// Reload Layout on Key Press - R key
function reload(str) {
if (str == reloadKey) fe.signal("reload");
return false;
}
}
fe.plugin["Reload"] <- Reload();

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 845
    • View Profile
Re: reset - reload layout
« Reply #6 on: December 18, 2018, 07:14:59 PM »
I am very confused on your goal. Are you still looking to reset an animation? If you read the comments on the module. There is functions like restart(). This should help you.

Possibly share some code?

spud1

  • Full Member
  • ***
  • Posts: 39
    • View Profile
Re: reset - reload layout
« Reply #7 on: December 18, 2018, 11:19:03 PM »
Hi.  Thanks for replying.  In fact, it was Giacomo who started the thread and asked the original question.

My use case is a little different.  I'm running a plugin which does the following.  Whenever I add a game to Favourites, it invokes a series of bash scripts which adds the game to my favourites romlist.  If I wait about 10 seconds and go back to the Favourites layout, the game will be among the favourites.  However, if I time it badly, then my favourites romlist will not have been updated.  With your script, I can now press the "R" key and it will update the layout manually, rather than having to exit the layout and re-enter it.  That is great.  It's just it would be fantastic if I didn't have to press "R" and that instead the plugin automatically reloads the layout once all of the bash scripts have finished.

To give you an idea, my current plugin is:

Quote
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
        return false;
}}

This plugin invokes the bash script that starts the update to the favourites romlist.  It works in the background. 

Ideally, after the bash script has finished (and it takes about 10 seconds), this plugin would reload the romlist automatically.  I was thinking something like this:

Quote
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
                 fe.signal("reload");
        return false;
}}

However, I'm not sure how to get the "reload" signal to wait about 10 seconds.

Thanks.

spud1

  • Full Member
  • ***
  • Posts: 39
    • View Profile
Re: reset - reload layout
« Reply #8 on: December 19, 2018, 02:12:02 PM »
Looks like famous last words.  Although the "reload" script reloads the layout which is great for debugging, it doesn't seem to reload the romlist from what I can see.  The only way to reload the romlist that I can find is to exit the layout and re-enter it or to transition from screensaver.  Is there a way to reload the romlist by way of a script without exiting the layout?

vengador toxico

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: reset - reload layout
« Reply #9 on: January 02, 2019, 02:23:57 PM »
Hi.  Thanks for replying.  In fact, it was Giacomo who started the thread and asked the original question.

My use case is a little different.  I'm running a plugin which does the following.  Whenever I add a game to Favourites, it invokes a series of bash scripts which adds the game to my favourites romlist.  If I wait about 10 seconds and go back to the Favourites layout, the game will be among the favourites.  However, if I time it badly, then my favourites romlist will not have been updated.  With your script, I can now press the "R" key and it will update the layout manually, rather than having to exit the layout and re-enter it.  That is great.  It's just it would be fantastic if I didn't have to press "R" and that instead the plugin automatically reloads the layout once all of the bash scripts have finished.

To give you an idea, my current plugin is:

Quote
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
        return false;
}}

This plugin invokes the bash script that starts the update to the favourites romlist.  It works in the background. 

Ideally, after the bash script has finished (and it takes about 10 seconds), this plugin would reload the romlist automatically.  I was thinking something like this:

Quote
// This plugin regenerates the "Favourites.txt" romlist when a game is selected as a favourite or deselected as a favourite
fe.add_transition_callback( "favourites" );
function favourites( ttype, var, ttime )
{
 switch ( ttype )
 {
  case Transition.ChangedTag:
                system( "sudo /bin/bash /opt/retropie/configs/all/favourites.sh" ); // Starts the Favourites bash script to update the Favourites romlist whenever a game is tagged or untagged
                 fe.signal("reload");
        return false;
}}

However, I'm not sure how to get the "reload" signal to wait about 10 seconds.

Thanks.
if you use xdotool inside bash sleep 10
xdotool keydown r
sleep 0.1
xdotool keyup r

spud1

  • Full Member
  • ***
  • Posts: 39
    • View Profile
Re: reset - reload layout
« Reply #10 on: January 05, 2019, 02:21:15 PM »
Thanks, giacomo82.  Unfortunately, I'm not using X-windows at all (ie I don't have the full installation of Raspbian) and xdotool only works in Raspbian.