Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: ShinobiZ on November 17, 2016, 05:17:50 AM

Title: How to display a picture when au launch a game ?
Post by: ShinobiZ on November 17, 2016, 05:17:50 AM
Hello,

Anyone can provide me a sample code to display an image or a message like "Loading, please wait..."  on the screen when you launch a game from "Grid" layout ?

Some time when you press the launch key, the emulator takes several seconds before popup on the screen,  this is why a waiting message would be nice instead a frozen layout :)

Another question but off topic, somebody kown if there is a script for MAME to exit that emulator if no input occured after X seconds ?

Thanks in advance,
Title: Re: How to display a picture when au launch a game ?
Post by: paha_13 on November 17, 2016, 05:47:06 AM
Anyone can provide me a sample code to display an image or a message like "Loading, please wait..."  on the screen when you launch a game from "Grid" layout ?

Some time when you press the launch key, the emulator takes several seconds before popup on the screen,  this is why a waiting message would be nice instead a frozen layout :)

Rocket Launcher?
http://forum.attractmode.org/index.php?topic=858.0
Title: Re: How to display a picture when au launch a game ?
Post by: checkist on November 17, 2016, 11:51:41 PM
Below is code fragment of my layout that does the 'displaying a picture when lanching game'
It may need some modifying though..


The key is displaying such image at 'case Transition.ToGame' and hide at other cases.
I used alpha properties for fade in/out effects. It might be easier to use 'IsVisible'.


Anyway, the code fragment is as follows:



local screen_now_loading   = fe.add_image("Loading.png", (fe.layout.width - 600)/2, (fe.layout.height - 300)/2, 0, 0);

fe.add_transition_callback( "launch_transition" );



function launch_transition( ttype, var, ttime ) {
   switch ( ttype )
   {
   case Transition.StartLayout:
      screen_now_loading.alpha = 0;
      break;
   case Transition.FromGame:
      if ( ttime < 255 )
      {
         foreach (o in fe.obj)
            o.alpha = ttime;
               screen_now_loading.alpha = 0;
         return true;
      }
      else
      {
         foreach (o in fe.obj)
            o.alpha = 255;
         screen_now_loading.alpha = 0;
      }
      break;
   case Transition.EndLayout:
      if ( ttime < 255 )
      {
         foreach (o in fe.obj)
            o.alpha = 255 - ttime;
         screen_now_loading.alpha = 0;
         return true;
      }
      break;
   case Transition.ToGame:
      if ( ttime < 255 )
      {
         foreach (o in fe.obj)
            o.alpha = 255 - ttime;
         screen_now_loading.alpha = ttime;
         return true;
      }
      screen_now_loading.alpha = 255;
      break;
   }
   return false;
}




Title: Re: How to display a picture when au launch a game ?
Post by: jedione on November 18, 2016, 07:41:44 AM
thanks this is great thank you for sharing this code.    you are very generous !

Title: Re: How to display a picture when au launch a game ?
Post by: ShinobiZ on November 19, 2016, 04:20:36 AM
thanks a lot !

Thierry
Title: Re: How to display a picture when au launch a game ?
Post by: web on December 12, 2016, 11:00:28 AM
thanks this is great thank you for sharing this code.    you are very generous !

Is there a way to add animed gifs ? Sequence of figures ?
Title: Re: How to display a picture when au launch a game ?
Post by: bionictoothpick on January 06, 2017, 11:55:55 AM
I want to display an image on the desktop and have the window of the emulator positioned over top of the image, and then when the emulator is closed I want the image to close too....

This is implemented with retroarch, but I want for use with winuae loader.

Ideas?