Author Topic: Genre / Category class and images  (Read 16709 times)

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Genre / Category class and images
« 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.



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);




verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: Genre / Category class and images
« Reply #1 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

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: Genre / Category class and images
« Reply #2 on: October 15, 2015, 09:30:11 AM »
Very nice indeed... Good job as always Liquid8. :)

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Genre / Category class and images
« Reply #3 on: November 10, 2015, 08:58:14 PM »
liquid8d, good job.  :)

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Genre / Category class and images
« Reply #4 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

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Genre / Category class and images
« Reply #5 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" ],

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Genre / Category class and images
« Reply #6 on: December 29, 2015, 02:13:59 PM »
Thanks! It looks great in your theme, too!

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Genre / Category class and images
« Reply #7 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 :)

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: Genre / Category class and images
« Reply #8 on: December 29, 2015, 07:28:32 PM »
I can fix it if you'll send me photoshop (layered) files with these 3 icons.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: Genre / Category class and images
« Reply #10 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

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Genre / Category class and images
« Reply #11 on: December 31, 2015, 06:05:10 AM »
It is very nice. Could you help to save as png format for each? Thanks  :)

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: Genre / Category class and images
« Reply #12 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.

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Genre / Category class and images
« Reply #13 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.
« Last Edit: December 31, 2015, 08:11:08 PM by kent79 »

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Genre / Category class and images
« Reply #14 on: January 01, 2016, 06:39:33 AM »
I updated the new Fighter, Puzzle, RPG, Sports and Shooter icons:


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