Author Topic: Hyperspin theme layout script  (Read 4134 times)

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 873
    • View Profile
Hyperspin theme layout script
« on: July 03, 2014, 10:08:24 AM »
So, here is a layout based on hyperspin mame theme. This is about all I could do with my basic understanding of transitions and indexing. The offsets could use a little tweaking and the wheel will only scroll so fast until Andrew does his thing.  If anyone can think of ways to improve on this then please help with any suggestions you might have. Here is the script and artwork. Thanks...
//
// Attract-Mode Front-End - "mediaV" sample layout
//
fe.layout.width=1024;
fe.layout.height=768;
fe.layout.font="coolvetica";
fe.add_image( "bg.png", 0, 0, 1024, 768 );
fe.add_artwork( "video.png", -360, 100, 1400, 600 );

// fill an entire surface with our snap at a resolution of 480x360
local surface = fe.add_surface( 480, 360 );
local snap = surface.add_artwork( "snap", 0, 0, 480, 360 );
snap.preserve_aspect_ratio = false;
//local screen = fe.add_image( "frame.png", 50, 150, 495, 395 );

surface.set_pos( 80, 210, 540, 380 );
//surface.pinch_y = -40;

// now create a reflection of the surface
//
//local reflect = fe.add_clone( surface );
//reflect.subimg_y = reflect.texture_height;
//reflect.subimg_height = -reflect.texture_height;
//reflect.set_rgb( 20, 20, 20 );

// position the reflection
//
//reflect.set_pos( 250, 430, 475, 90 );
//reflect.skew_y = 440;
//reflect.skew_x = 0;
//reflect.pinch_y = 10;
class UserConfig {
   </ label="Orbit Artwork", help="The artwork to spin into orbit", options="marquee,flyer,wheel" />
   orbit_art="marquee";

   </ label="Bloom Effect", help="Enable Bloom Effect (requires shader support)", options="Yes,No" />
   enable_bloom="Yes";

}
local my_config = fe.get_config();
local no_shader = fe.add_shader( Shader.Empty );
local yes_shader;
if ( my_config["enable_bloom"] == "Yes" )
{
   yes_shader = fe.add_shader( Shader.Fragment, "bloom_shader.frag" );
   yes_shader.set_texture_param("bgl_RenderedTexture");
}
else
{
   yes_shader = no_shader;
}

fe.add_artwork( "pointer.png", 950, 370, 80, 120 );

local title = fe.add_text( "[Title]", 10, 660, 320, 20 );
title.set_rgb( 255, 255, 255 );
title.align = Align.Left;

local man = fe.add_text( " ([Category]) [Manufacturer] [Year] ", 10, 690, 320, 20 );
man.set_rgb( 255, 255, 255 );
man.align = Align.Left;

local name = fe.add_text( " [ListTitle] ", 02, 02, 320, 20 );
name.set_rgb( 255, 255, 255 );
name.align = Align.Left;

local entry = fe.add_text( "[ListEntry]/[ListSize]", 350, 610, 320, 18 );
entry.set_rgb( 255, 255, 255 );
entry.align = Align.Right;

local filter = fe.add_text( "[ListFilterName]", 10, 720, 290, 18 );
filter.set_rgb( 255, 255, 255 );
filter.align = Align.Left;

// Create 13 artworks. (even though only 10 artworks will appear on screen)
local title_p2 = fe.add_artwork( "wheel", 780, -80, 190, 75 );
local title_p1 = fe.add_artwork( "wheel", 780, 0, 190, 75 );
local title_p3 = fe.add_artwork( "wheel", 780, 80, 190, 75 );
local title_n1 = fe.add_artwork( "wheel", 780, 160, 190, 75 );
local title_n2 = fe.add_artwork( "wheel", 780, 240, 190, 75 );
local title_n3 = fe.add_artwork( "wheel", 780, 320, 190, 75 );
local title_n0 = fe.add_artwork( "wheel", 740, 400, 190, 75 );
local title_n5 = fe.add_artwork( "wheel", 780, 480, 190, 75 );
local title_n6 = fe.add_artwork( "wheel", 780, 560, 190, 75 );
local title_n7 = fe.add_artwork( "wheel", 780, 640, 190, 75 );
local title_n8 = fe.add_artwork( "wheel", 780, 720, 190, 75 );
local title_n9 = fe.add_artwork( "wheel", 780, 800, 190, 75 );
local title_n10 = fe.add_artwork( "wheel", 780, 880, 190, 75 );

//note title_p2, title_n10 will not be shown on screen, they are for transitional effects...
// Set index_offset for these 5 artworks.
title_p2.index_offset = -2;
title_p1.index_offset = -1;
title_p3.index_offset = 1;
title_n1.index_offset = 2;
title_n2.index_offset = 3;
title_n3.index_offset = 4;
title_n0.index_offset = 0;
title_n5.index_offset = 1;
title_n6.index_offset = 2;
title_n7.index_offset = 3;
title_n8.index_offset = 4;
title_n9.index_offset = 5;
title_n10.index_offset = 6;
// Add transition callback function.
fe.add_transition_callback( "orbit_transition" );
// Fill in orbit_transition function, as below:
local SPIN_MS=160; // Duration of transition effect (in msec)
function orbit_transition( ttype, var, ttime ) {
switch ( ttype )
{
case Transition.ToNewSelection:
if ( ttime < SPIN_MS ) {
local direction = -1;
if (var < 0) direction = 1;
local increment = (ttime * direction * 80) / SPIN_MS;
title_p2.y = -80 + increment;
title_p1.y = 0 + increment;
title_p3.y = 80 + increment;
title_n1.y = 160 + increment;
title_n2.y = 240 + increment;
title_n3.y = 320 + increment;
title_n0.y = 400 + increment;
title_n5.y = 480 + increment;
title_n6.y = 560 + increment;
title_n7.y = 640 + increment;
title_n8.y = 720 + increment;
title_n9.y = 800 + increment;
title_n10.y = 880 + increment;

return true;
}

else {
title_p2.y = -80;
title_p1.y = 0;
title_p3.y = 80;
title_n1.y = 160;
title_n2.y = 240;
title_n3.y = 320;
title_n0.y = 400;
title_n5.y = 480;
title_n6.y = 560;
title_n7.y = 640;
title_n8.y = 720;
title_n9.y = 800;
title_n10.y = 880;
return false;
}
}
return false;
}

// Gives us a nice high random number for the RGB levels
function brightrand() {
 return 255-(rand()/255);
}

local red = brightrand();
local green = brightrand();
local blue = brightrand();

// Transitions
fe.add_transition_callback( "fancy_transitions" );

function fancy_transitions( ttype, var, ttime ) {
 switch ( ttype )
 {
 case Transition.StartLayout:
 case Transition.ToNewList:
 case Transition.ToNewSelection:
 case Transition.EndLayout:
  //gametitleshadow.msg = trimmed_title( var );
  //gametitle.msg = trimmed_title( var );
  //man.msg = trimmed_man ( var );
  red = brightrand();
  green = brightrand();
  blue = brightrand();
  //year.set_rgb (red,green,blue);
  //copy.set_rgb (red,green,blue);
  //man.set_rgb (red,green,blue);
  //romlist.set_rgb (red,green,blue);
  //screen.set_rgb (red,green,blue);
  //frame3.set_rgb (red,green,blue);
  //cat.set_rgb (red,green,blue);
  //title.set_rgb (red,green,blue);
  break;

 case Transition.FromGame:
  if ( ttime < 255 )
  {
   foreach (o in fe.obj)
    o.alpha = ttime;
   //message.alpha = 0;     
   return true;
  }
  else
  {
   foreach (o in fe.obj)
    o.alpha = 255;
   //message.alpha = 0;
  }
  break;
   
 case Transition.EndLayout:
  if ( ttime < 255 )
  {
   foreach (o in fe.obj)
    o.alpha = 255 - ttime;
   //message.alpha = 0;
   return true;
  }
  else
  {
   foreach (o in fe.obj)
    o.alpha = 255;
   //message.alpha = 0;
  }
  break;
     
 case Transition.ToGame:
  if ( ttime < 255 )
  {
   foreach (o in fe.obj)
    o.alpha = 255 - ttime;
   message.alpha = ttime;
   return true;
  }   
  break;
 }
 return false;
}
« Last Edit: July 03, 2014, 10:11:43 AM by omegaman »

cherwilco

  • Jr. Member
  • **
  • Posts: 23
    • View Profile
Re: Hyperspin theme layout script
« Reply #1 on: October 19, 2014, 11:46:39 AM »
I hope you dont mind but I am using a modified version of your layout.nut to work with my ps2 layout. I am having trouble though with the marquee listbox scrolling where some of the marquee art gets out of order or doubled, just like in the video you posted here: https://www.youtube.com/watch?v=nL7T5SsINhU&feature=youtu.be

I wonder if you ever found a fix for that or if it is by design?

I started a thread with my experiences on this one here:
http://forum.attractmode.org/index.php?topic=58.0

if you have a minute maybe you could pop over there and lend a hand, thanks

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 873
    • View Profile
Re: Hyperspin theme layout script
« Reply #2 on: October 24, 2014, 05:25:02 AM »
Sorry, for the late reply. Looks like checkist got you hooked up. He actually gave me some pointers as well. So, feel free to use the script however you want. The hypertheme was a quick and dirty idea I was messing around with then I started on something similar to the grid. But, looks like Andrew has that worked out now with 1.4. Now with the fixes to orbit, that script could be used for a better hypertheme experience. The conveyor module looks promising for carts too. Keep up the good work.