Author Topic: Script for abbreviation of current display name.  (Read 2884 times)

Wenzon

  • Full Member
  • ***
  • Posts: 59
    • View Profile
Script for abbreviation of current display name.
« on: June 06, 2019, 09:56:00 AM »
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?

Example: Capcom Play System III for CPSIII.

Thank you all and sorry for my English.


qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Script for abbreviation of current display name.
« Reply #2 on: June 09, 2019, 10:20:16 AM »
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?

Example: Capcom Play System III for CPSIII.

Thank you all and sorry for my English.

someone helped me with this

Code: [Select]
[b]       // System   
        for ( local i = 0; i < fe.displays.len(); i++ ) {
            local filter = fe.displays[i];
            local shortname = filter.name.toupper();
            local offset = 90 * 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;
                case "Commodore 64":
                    shortname = "C64";
                    break;
                case "Nintendo Entertainment System":
                    shortname = "NES";
                    break;
                case "Super Nintendo Entertainment System":
                    shortname = "SNES";
                    break;
                case "Microsoft MSX":
                    shortname = "MSX";
                    break;    
                case "Sega Mega Drive":
                    shortname = "MD";
                case "Nintendo DS":
                    shortname = "NDS";
                    break;

                //grab the first three letters as the short name
                default:
if (shortname.len() > 4)
shortname = shortname.slice(0, 4);
                    break;
            }
           
            local newfilt = fe.add_text(shortname, -98 + offset, 10, 300, 80);
                newfilt.set_rgb( 255, 255, 255 );
                newfilt.font = "CODE";
                newfilt.charsize = 30;
                newfilt.style = Style.Bold;

            local underline = fe.add_image("images/red.png", 22 + offset, 70, 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" );[/b]

Wenzon

  • Full Member
  • ***
  • Posts: 59
    • View Profile
Re: Script for abbreviation of current display name.
« Reply #3 on: June 10, 2019, 08:28:50 AM »
I'm trying to develop a theme but I'm not good at programming. Would someone help me with a script that abbreviated the name of the display I'm using?

Example: Capcom Play System III for CPSIII.

Thank you all and sorry for my English.

someone helped me with this

Code: [Select]
       // System   
        for ( local i = 0; i < fe.displays.len(); i++ ) {
            local filter = fe.displays[i];
            local shortname = filter.name.toupper();
            local offset = 90 * 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;
                case "Commodore 64":
                    shortname = "C64";
                    break;
                case "Nintendo Entertainment System":
                    shortname = "NES";
                    break;
                case "Super Nintendo Entertainment System":
                    shortname = "SNES";
                    break;
                case "Microsoft MSX":
                    shortname = "MSX";
                    break;    
                case "Sega Mega Drive":
                    shortname = "MD";
                case "Nintendo DS":
                    shortname = "NDS";
                    break;

                //grab the first three letters as the short name
                default:
if (shortname.len() > 4)
shortname = shortname.slice(0, 4);
                    break;
            }
           
            local newfilt = fe.add_text(shortname, -98 + offset, 10, 300, 80);
                newfilt.set_rgb( 255, 255, 255 );
                newfilt.font = "CODE";
                newfilt.charsize = 30;
                newfilt.style = Style.Bold;

            local underline = fe.add_image("images/red.png", 22 + offset, 70, 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" );

The script worked but did not show the name of the display I'm using.

In the figure below the display is Capcom Play System III and its script presented the abbreviation of ATOMISWAVE ("ATOM").

I struggled to see if I could run the script correctly but I did not master the programming language. Now in editing of image I dominate a little bit.  :)

qqplayer's script is almost that. If you can help me, I'll be very grateful.

qqplayer

  • Sr. Member
  • ****
  • Posts: 301
    • View Profile
Re: Script for abbreviation of current display name.
« Reply #4 on: June 20, 2019, 11:28:53 AM »
Sorry I forgot a to paste the most important part.

Code: [Select]
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;

}