Author Topic: System List possible?  (Read 7446 times)

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
System List possible?
« on: May 15, 2018, 10:02:37 AM »
Quick question.

I know you can add a game list with fe.add_listbox() but is there a way to add a system list?  Alternatively request the name of a previous system or next system with an offset value?   I'm trying to create a theme where you use up and down to swap between games and then left and right to swap between systems i.e. a dual list.

here's an example of what i'm trying to do:



So in the pic, it will show the 2 prev systems and the 2 next systems on screen.  Pressing right would shift "Saturn" to the center arrow cursor and the list will refresh with an updated 2 prev and 2 next systems.

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: System List possible?
« Reply #1 on: May 15, 2018, 10:24:29 AM »
You may refer my theme. It is similar you want  :)
http://forum.attractmode.org/index.php?topic=2211.0
« Last Edit: May 15, 2018, 10:36:23 AM by kent79 »

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #2 on: May 15, 2018, 02:00:59 PM »
You may refer my theme. It is similar you want  :)
http://forum.attractmode.org/index.php?topic=2211.0

Awesome I was "trying" to make something like this.
Thank you so much for the code  ;)

I have used the Mini nes theme code from BJose

Code: [Select]
//Bjose MiniNES Code

local console = fe.list.name;

fe.add_transition_callback(this, "logo_settings");

function logo_settings(ttype, var, ttime) {

local last_console = console;
switch( ttype)
{
case Transition.ToNewList:
case Transition.StartLayout:
//case Transition.FromOldSelection:

console = fe.list.name;
if (last_console != console)
{

fe.signal("reload");

}
break;
default:
console = fe.list.name;
  }
   return false;
}

   switch ( fe.list.name )
{
case "Super Nintendo Entertainment System":
    //snestext
    local snessystem = "SNES";
                local snestext = fe.add_text( snessystem, flx*0.08, fly*0.053, flw*0.48, flh*0.028  );
                snestext.alpha = 255;
                snestext.align = Align.Left;
                snestext.set_rgb( 255, 255, 255 );
                snestext.font = "CODE";
                snestext.charsize = 30;
                snestext.style = Style.Bold;
                local snesunderline_system_image = fe.add_image("images/underline_system.png", 122, 70, 70, 5);
               

    break;
   
    case "Nintendo Entertainment System":
    //nestext
    local nessystem = "NES";
                local nestext = fe.add_text( nessystem, flx*0.08, fly*0.053, flw*0.48, flh*0.028  );
                nestext.alpha = 255;
                nestext.align = Align.Left;
                nestext.set_rgb( 255, 255, 255 );
                nestext.font = "CODE";
                nestext.charsize = 30;
                nestext.style = Style.Bold;
                local nesunderline_system_image = fe.add_image("images/underline_system.png", 118, 70, 60, 5);


    break;
   
}

                /*local prevsystem = fe.add_text( "[DisplayName]", flx*0.18, fly*0.053, flw*0.48, flh*0.028  );
    prevsystem.alpha = 255;
                prevsystem.align = Align.Left;
                prevsystem.set_rgb( 255, 255, 255 );
                prevsystem.font = "CODE";
                prevsystem.charsize = 30;
                prevsystem.style = Style.Bold;
    prevsystem.index_offset = -1;*/

But I was stucked creating a systems list.

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #3 on: May 15, 2018, 02:59:45 PM »
@kent79 I want to make something like this "system underlined slector"



Can you help me with the code?

Just for the system selected underlined ,I mean  ;)

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: System List possible?
« Reply #4 on: May 15, 2018, 04:28:21 PM »
I have revised the script to make a sample. You may try it.  :)

Code: [Select]
local ui_filters=[];
local ui_underline=[];

        // System   
        for ( local i = 0; i < fe.displays.len(); i++ ) {
            local filter = fe.displays[i];
            local shortname = filter.name.toupper();
            local offset = 55 * i;
           
            switch(filter.name) {
                //prefer known abbreviations
                case "Sega Model 2":
                    shortname = "SM2";
                    break;
                case "Sega Model 3":
                    shortname = "SM3";
                    break;
case "Sega Naomi":
                    shortname = "NAO";
                    break;

                //grab the first three letters as the short name
                default:
if (shortname.len() > 3)
shortname = shortname.slice(0, 3);
                    break;
            }
           
            local newfilt = fe.add_text(shortname, -18 + offset, 1, 73, 18);
            newfilt.set_rgb( 240, 240, 240 );

            local underline = fe.add_image("white.png", -18 + offset, 20, 60, 3);
            underline.set_rgb( 240, 0, 0 );
    underline.visible = false ;

            if (i == fe.list.display_index)
                underline.visible = true;
            ui_filters.push(newfilt);
ui_underline.push(underline);

        }

fe.add_transition_callback( this, "on_transition" );

function on_transition( ttype, var, ttime )
{

//Update filter highlight
                for ( local i = 0; i < ui_underline.len(); i++ )

                    ui_underline[i].visible = false;
                    ui_underline[fe.list.display_index].visible = true;

}
« Last Edit: May 15, 2018, 04:41:03 PM by kent79 »

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: System List possible?
« Reply #5 on: May 15, 2018, 10:56:45 PM »
You may refer my theme. It is similar you want  :)
http://forum.attractmode.org/index.php?topic=2211.0

Hey man, thank you so much!  Btw, that's a very nice theme.  So I've been messing with it for the past hour and I can't seem to isolate the list to a certain number of systems (instead of showing them all).  You're code is too advanced for me. :P

I've done some more digging with much trial and error and i've come up with something like this (example):

Code: [Select]
function on_transition( ttype, var, ttime )
{

local display1 = fe.displays[fe.list.display_index - 1].name; //previous display
local display2 = fe.displays[fe.list.display_index].name; //current display
local display3 = fe.displays[fe.list.display_index + 1].name; //next display

local sys_text1 = fe.add_text (display1, 100, 200, 600, 100); //note: can use sys_text#'s to fe.add_image if I wanted images instead of text
local sys_text2 = fe.add_text (display2, 500, 200, 600, 100);
local sys_text3 = fe.add_text (display3, 1000, 200, 600, 100);

}
fe.add_transition_callback( this, "on_transition" );

The only problem i'm facing with this is the transition callback isn't working properly.  Every time I switch back and forth between displays, the previous text does not disappear and instead overlaps each other.  Any ideas on this?

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #6 on: May 16, 2018, 02:23:06 AM »
I have revised the script to make a sample. You may try it.  :)

Code: [Select]
local ui_filters=[];
local ui_underline=[];

        // System   
        for ( local i = 0; i < fe.displays.len(); i++ ) {
            local filter = fe.displays[i];
            local shortname = filter.name.toupper();
            local offset = 55 * i;
           
            switch(filter.name) {
                //prefer known abbreviations
                case "Sega Model 2":
                    shortname = "SM2";
                    break;
                case "Sega Model 3":
                    shortname = "SM3";
                    break;
case "Sega Naomi":
                    shortname = "NAO";
                    break;

                //grab the first three letters as the short name
                default:
if (shortname.len() > 3)
shortname = shortname.slice(0, 3);
                    break;
            }
           
            local newfilt = fe.add_text(shortname, -18 + offset, 1, 73, 18);
            newfilt.set_rgb( 240, 240, 240 );

            local underline = fe.add_image("white.png", -18 + offset, 20, 60, 3);
            underline.set_rgb( 240, 0, 0 );
    underline.visible = false ;

            if (i == fe.list.display_index)
                underline.visible = true;
            ui_filters.push(newfilt);
ui_underline.push(underline);

        }

fe.add_transition_callback( this, "on_transition" );

function on_transition( ttype, var, ttime )
{

//Update filter highlight
                for ( local i = 0; i < ui_underline.len(); i++ )

                    ui_underline[i].visible = false;
                    ui_underline[fe.list.display_index].visible = true;

}

Thank you so much , is working :)

I`m with @dukpoki , is any way to set maybe only three previous and three next...
Not the whole thing...

@dukpoki , I think you need to add something like this:

Code: [Select]
function on_transition( ttype, var, ttime ) {
 switch ( ttype ) {
  case Transition.StartLayout:
  case Transition.ToNewList:
local display1 = fe.displays[fe.list.display_index - 1].name; //previous display
local display2 = fe.displays[fe.list.display_index].name; //current display
local display3 = fe.displays[fe.list.display_index + 1].name; //next display

local sys_text1 = fe.add_text (display1, 100, 200, 600, 100); //note: can use sys_text#'s to fe.add_image if I wanted images instead of text
local sys_text2 = fe.add_text (display2, 500, 200, 600, 100);
local sys_text3 = fe.add_text (display3, 1000, 200, 600, 100);
  break;
  }
 return false;
}

fe.add_transition_callback( "on_transition" );

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: System List possible?
« Reply #7 on: May 16, 2018, 09:02:26 AM »
The best System List is combine with Conveyor module. But sorry I don't know how to write a script in this moment . Need some time for study. ArcadeBliss is a Expert. He should know how to do  :P

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: System List possible?
« Reply #8 on: May 17, 2018, 01:25:18 PM »
Got it working.

Code: [Select]

 ::OBJECTS <- {

system1= fe.add_text("",47,48,300,40)
system2= fe.add_text("",47,90,300,40)
system3= fe.add_text("",47,132,300,40)
system4= fe.add_text("",47,174,300,40)
system5= fe.add_text("",47,222,300,40)

}

function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.FromOldSelection:
            switch ( fe.list.name )
            {             
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name; //previous display
        local display3 = fe.displays[fe.list.display_index].name; //current display
        local display4 = fe.displays[fe.list.display_index + 1].name; //next display
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
OBJECTS.frame.file_name = "images/frames/Default_frame.png";
break;

        case "Dreamcast":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name; //previous display
        local display3 = fe.displays[fe.list.display_index].name; //current display
        local display4 = fe.displays[fe.list.display_index + 1].name; //next display
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
        OBJECTS.frame.file_name = "images/frames/Default_frame.png";

        break;
            }
break;
    }

}

fe.add_transition_callback("transition_callback" );


Make sure to add all your systems/displays by adding more "cases".

EDIT:  Has problems with the beginning and the end of the list.  I'm not sure how to make it loop.  Will research.

EDIT 2:  Found a very rough workaround.  You have to subtract or add the total index number which you can use fe.displays.len() to find.
So for example if you have a list of 10 systems then for the first system you need to -2, -1, 0, +1, +2 but make sure the first two formulas you are adding 10 to it.  So the formula will be (-2 + 10) and (-1 + 10).  That way the end result is the number that is at the end of the list 8 and 9 respectively and not negative numbers.  Because you the display index will never be a negative number.

For example i am doing this:
Code: [Select]
                local displaytotal = fe.displays.len();

//excerpt code below
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1 + displaytotal].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
break;
« Last Edit: May 17, 2018, 06:34:14 PM by dukpoki »

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #9 on: May 18, 2018, 05:46:35 AM »
@dukpoki Is gaving me an error , "the index -2 does not exist"

dukpoki

  • Sr. Member
  • ****
  • Posts: 138
    • View Profile
Re: System List possible?
« Reply #10 on: May 18, 2018, 09:21:33 AM »
@dukpoki Is gaving me an error , "the index -2 does not exist"

Here's a full sample code that should work if you follow the template.  You have to of course, adjust/add more systems accordingly to the total amount on your setup as this code only for a total of 5 systems.  To do that, you simply add/insert more "case" systems along with the "break".  A good rule of thumb is to alphabetize it as AM automatically assigns display numbers that way.  Also make sure your systems listed in your attract.cfg are in alphabetical order as well.  And finally make sure the first 2 and last 2 systems on the list have the same +/- displaytotal in the corresponding lines.  So if you are adding more systems then delete the +displaytotal's I have in Atomiswave & Dreamcast and also the -displaytotal's in Genesis & Mame.  Then once you've added all your systems apply those +/- exactly in the same order/way.

Code: [Select]

local displaytotal = fe.displays.len();  //the total system number

 ::OBJECTS <- {

system1= fe.add_text("",47,48,300,40)
system2= fe.add_text("",47,90,300,40)
system3= fe.add_text("",47,132,300,40)
system4= fe.add_text("",47,174,300,40)
system5= fe.add_text("",47,216,300,40)

}


function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.FromOldSelection:
            switch ( fe.list.name )
            {             
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1 + displaytotal].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

        case "Dreamcast":
local display1 = fe.displays[fe.list.display_index -2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
    break;

case "Gamecube":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

        case "Genesis":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2 - displaytotal].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;           

        case "Mame":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1 - displaytotal].name;
local display5 = fe.displays[fe.list.display_index + 2 - displaytotal].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

            }
break;
    }

}

fe.add_transition_callback("transition_callback" );


qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #11 on: May 18, 2018, 09:44:18 AM »
Ok now is working ... thank you so much  ;D

Any chance to create  a "surface" and navigate between this system list?

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: System List possible?
« Reply #12 on: May 19, 2018, 04:24:16 AM »
@dukpoki Is gaving me an error , "the index -2 does not exist"

Here's a full sample code that should work if you follow the template.  You have to of course, adjust/add more systems accordingly to the total amount on your setup as this code only for a total of 5 systems.  To do that, you simply add/insert more "case" systems along with the "break".  A good rule of thumb is to alphabetize it as AM automatically assigns display numbers that way.  Also make sure your systems listed in your attract.cfg are in alphabetical order as well.  And finally make sure the first 2 and last 2 systems on the list have the same +/- displaytotal in the corresponding lines.  So if you are adding more systems then delete the +displaytotal's I have in Atomiswave & Dreamcast and also the -displaytotal's in Genesis & Mame.  Then once you've added all your systems apply those +/- exactly in the same order/way.

Code: [Select]

local displaytotal = fe.displays.len();  //the total system number

 ::OBJECTS <- {

system1= fe.add_text("",47,48,300,40)
system2= fe.add_text("",47,90,300,40)
system3= fe.add_text("",47,132,300,40)
system4= fe.add_text("",47,174,300,40)
system5= fe.add_text("",47,216,300,40)

}


function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewList:
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.FromOldSelection:
            switch ( fe.list.name )
            {             
case "Atomiswave":
local display1 = fe.displays[fe.list.display_index - 2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1 + displaytotal].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

        case "Dreamcast":
local display1 = fe.displays[fe.list.display_index -2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
    break;

case "Gamecube":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

        case "Genesis":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2 - displaytotal].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;           

        case "Mame":
local display1 = fe.displays[fe.list.display_index - 2].name;
local display2 = fe.displays[fe.list.display_index - 1].name;
                local display3 = fe.displays[fe.list.display_index].name;
                local display4 = fe.displays[fe.list.display_index + 1 - displaytotal].name;
local display5 = fe.displays[fe.list.display_index + 2 - displaytotal].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
break;

            }
break;
    }

}

fe.add_transition_callback("transition_callback" );


I think this will work for "all systems" without "case"
I have used case to replace for shortnames like on the Kent`s example.

Code: [Select]
//
//

local displaytotal = fe.displays.len();  //the total system number

 ::OBJECTS <- {

system1= fe.add_text("",flx*0.025,715,150,40)
system2= fe.add_text("",200,715,150,40)
system3= fe.add_text("",350,715,150,40)
system4= fe.add_text("",500,715,150,40)
system5= fe.add_text("",650,715,150,40)

}


function transition_system(ttype, var, ttime)
{
    switch ( ttype )
    {
    case Transition.ToNewList:
case Transition.StartLayout:
case Transition.ToNewSelection:
case Transition.FromOldSelection:

local display1 = fe.displays[fe.list.display_index - 2 + displaytotal].name;
local display2 = fe.displays[fe.list.display_index - 1 + displaytotal].name;
        local display3 = fe.displays[fe.list.display_index].name;
        local display4 = fe.displays[fe.list.display_index + 1].name;
local display5 = fe.displays[fe.list.display_index + 2].name;
OBJECTS.system1.msg = display1;
OBJECTS.system2.msg = display2;
OBJECTS.system3.msg = display3;
OBJECTS.system4.msg = display4;
OBJECTS.system5.msg = display5;
    break;
    }

}

fe.add_transition_callback("transition_system" );

//
//

By the way I´m trying to replace "name" for "shortname" but isnt working.