Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: liquid8d on October 15, 2015, 12:01:44 AM

Title: Genre / Category class and images
Post by: liquid8d on October 15, 2015, 12:01:44 AM
I just spent a little time putting this together. Time to share :) If you like them and want to see other category images added let me know.

(http://i.imgur.com/2eElfkA.png)

You can update mappings for the images to category names in the class, and the class has 3 modes - first match, last match, or random match.

Code: [Select]
local bg = fe.add_artwork("snap", 0, 0, fe.layout.width, fe.layout.height);
local text = fe.add_text("[Title]", 0, 0, fe.layout.width, 75);
local genre_image = fe.add_image("images/unknown.png", fe.layout.width - 188, fe.layout.height - 170, 168, 150);

class GenreImage
{
    mode = 1;       //0 = first match, 1 = last match, 2 = random
    supported = {
        //filename : [ match1, match2 ]
        "action": [ "action" ],
        "adventure": [ "adventure" ],
        "fighting": [ "fighting", "fighter", "beat'em up" ],
        "platformer": [ "platformer", "platform" ],
        "puzzle": [ "puzzle" ],
        "racing": [ "racing", "driving" ],
        "rpg": [ "rpg", "role playing", "role playing game" ],
        "shooter": [ "shooter", "shmup" ],
        "sports": [ "sports", "boxing", "golf", "baseball", "football", "soccer" ],
        "strategy": [ "strategy"]
    }

    ref = null;
    constructor( image )
    {
        ref = image;
        fe.add_transition_callback( this, "transition" );
    }
   
    function transition( ttype, var, ttime )
    {
        if ( ttype == Transition.ToNewSelection || ttype == Transition.ToNewList )
        {
            local cat = " " + fe.game_info(Info.Category, var).tolower();
            local matches = [];
            foreach( key, val in supported )
            {
                foreach( nickname in val )
                {
                    if ( cat.find(nickname, 0) ) matches.push(key);
                }
            }
            if ( matches.len() > 0 )
            {
                switch( mode )
                {
                    case 0:
                        ref.file_name = "images/" + matches[0] + ".png";
                        break;
                    case 1:
                        ref.file_name = "images/" + matches[matches.len() - 1] + ".png";
                        break;
                    case 2:
                        local random_num = floor(((rand() % 1000 ) / 1000.0) * ((matches.len() - 1) - (0 - 1)) + 0);
                        ref.file_name = "images/" + matches[random_num] + ".png";
                        break;
                }
            } else
            {
                ref.file_name = "images/unknown.png";
            }
        }
    }
}

GenreImage(genre_image);


(http://i.imgur.com/TAoWNFd.png)
Title: Re: Genre / Category class and images
Post by: verion on October 15, 2015, 04:09:52 AM
nicely done!

---

Maybe you could use slightly thicker lines on
- fighter
- rpg
- sports

because these are more "delicate" than the rest
Title: Re: Genre / Category class and images
Post by: omegaman on October 15, 2015, 09:30:11 AM
Very nice indeed... Good job as always Liquid8. :)
Title: Re: Genre / Category class and images
Post by: kent79 on November 10, 2015, 08:58:14 PM
liquid8d, good job.  :)
Title: Re: Genre / Category class and images
Post by: kent79 on December 02, 2015, 05:00:45 AM
Hi liquid8d, just add its on new layout. You may try & thank you for your effort  :)

http://forum.attractmode.org/index.php?topic=430.0
Title: Re: Genre / Category class and images
Post by: kent79 on December 05, 2015, 01:16:52 AM

        //filename : [ match1, match2 ]
        "action": [ "action" ],
        "adventure": [ "adventure" ],
        "fighting": [ "fighting", "fighter", "beat'em up" ],
        "platformer": [ "platformer", "platform" ],
   

Just find some issue of above script, since file name is fighter.png, "fighting" should be amend to "fighter" . Thanks.

"fighter": [ "fighting", "fighter", "beat'em up" ],
Title: Re: Genre / Category class and images
Post by: liquid8d on December 29, 2015, 02:13:59 PM
Thanks! It looks great in your theme, too!
Title: Re: Genre / Category class and images
Post by: liquid8d on December 29, 2015, 02:18:06 PM
nicely done!

---

Maybe you could use slightly thicker lines on
- fighter
- rpg
- sports

because these are more "delicate" than the rest

btw,  I agree with you, but these were stock images I found.. I can do okay with photoshop but would probably mess up trying to make those look better :)
Title: Re: Genre / Category class and images
Post by: verion on December 29, 2015, 07:28:32 PM
I can fix it if you'll send me photoshop (layered) files with these 3 icons.
Title: Re: Genre / Category class and images
Post by: liquid8d on December 30, 2015, 10:34:56 AM
I just checked in the sample layout and the PSD:

https://github.com/liquid8d/attract-extra/blob/master/extras/genre.psd

https://github.com/liquid8d/attract-extra/tree/master/layouts/genre

Thanks!
Title: Re: Genre / Category class and images
Post by: verion on December 31, 2015, 05:15:12 AM
ok, I've updated following icons:

- new shooter (based on galaga ship)
- new fighter
- rpg - thicker and filled sword
- sports - slightly thicker
- puzzle - new shape

I've made this as separate layers - so you'll have all old and new versions in one file.

PSD file in attachment
Title: Re: Genre / Category class and images
Post by: kent79 on December 31, 2015, 06:05:10 AM
It is very nice. Could you help to save as png format for each? Thanks  :)
Title: Re: Genre / Category class and images
Post by: verion on December 31, 2015, 09:01:27 AM
I'll leave that to liquid8d - he has to decide if he likes new icons. Maybe he'll like original icons better.
Title: Re: Genre / Category class and images
Post by: kent79 on December 31, 2015, 08:05:44 PM
It is better to change image of "SPORT" (eg. football image). The current boxing image is too similar of FIGHTER. Thanks.
Title: Re: Genre / Category class and images
Post by: liquid8d on January 01, 2016, 06:39:33 AM
I updated the new Fighter, Puzzle, RPG, Sports and Shooter icons:
(http://i.imgur.com/uU2rNWA.png)

I did a new Sports with a ball and left verion's new one as -alt. I preferred the old Shooter icon, but left verion's new one as -alt. You can swap them out if you prefer the other.

Thanks verion!

https://github.com/liquid8d/attract-extra/blob/master/extras/genre.psd
https://github.com/liquid8d/attract-extra/tree/master/layouts/genre/images
Title: Re: Genre / Category class and images
Post by: verion on January 01, 2016, 07:04:29 AM
no problem
Title: Re: Genre / Category class and images
Post by: baddea on July 01, 2018, 05:38:08 PM
i want to add player number ,manufacture image using this script but it not working with me what i am missing ?
also i have problem to convert my players number from hyperspin list to AM All information convert except "players" i change it to "p" "mode"
the value is numbers . i want to view image player 1-4 in my front am if there anything can help ..

also i try to change this :

Code: [Select]
            local cat = " " + fe.game_info(Info.Category , var).tolower();
to

Code: [Select]
            local cat = " " + fe.game_info(Info.Players, var).tolower();
Title: Re: Genre / Category class and images
Post by: placebo_yue on July 11, 2019, 07:54:51 PM
I made a bunch of new genres because "rhythm" and "VR" were a must have for me, and for some reason i had "action" as the same thing as "platformer".
Since i spent a few minutes on that i'll share the images.

now i have way too many colors, but i save the bad ones for genres i don't play much, like strategy or adventure, and i save the clearly noticeable ones like yellow and red for RPG and Fighters.