Author Topic: little help/advice needed  (Read 14962 times)

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
little help/advice needed
« on: May 17, 2015, 11:45:43 AM »
Update and some more issues.

Still haven't figured out how to make the grid work left to right only and just cycle between top and bottom row

that being said semi new issues. and my fix that leads to a smaller issue

as stated using Grid layout as a base, and changed a fair bit inside so far within the grid layout it has calls for the name and display
iv changed these and bit and noticed something, if you link 2 things to a call
like
Code: [Select]
gridc.mfa_t = fe.add_artwork( "boxart", fe.layout.width / 1.20, fe.layout.height / 20, 175, 0);
gridc.mfa_t = fe.add_artwork( "Logo", 1, fe.layout.height / 15, 250, 100);
gridc.mfa_t.preserve_aspect_ratio = true;
These artworks get out of sync with each other

My fix was to then add another class inside the grid

Like
Code: [Select]
gridc.mfg_t = fe.add_artwork( "boxart", fe.layout.width / 1.20, fe.layout.height / 20, 175, 0);

gridc.mfa_t = fe.add_artwork( "Logo", 1, fe.layout.height / 15, 250, 100);
gridc.mfa_t.preserve_aspect_ratio = true;

gridc.name_t =  fe.add_artwork( "Video", fe.layout.width / 4.2, fe.layout.height / 20, 672, 430);
     
gridc.child_t = fe.add_text( "[Title]", 0, 0, 1280,28 );
gridc.child_t.font = "itc-bauhaus-medium-1361514162";
then to make them the same inside grid it already has this line
Code: [Select]
mfg_t.index_offset = child_t.index_offset = name_t.index_offset = num_t.index_offset = get_sel() - selection_index;
So Iv added them as = inside to give me more calls to those being child_T and mfg_T ect this works and keeps all artwork in sync to the game selected however If I add anymore it stops working
And I dont really know why, the artwork syncs to began with or why adding more is breaking it

/////////////////////////////////////////////////////////////////////////

Lastly I am trying to add a boarder outline to the game name text, and cant really find anything documented on how to do that and still am at a loss for scrolling text



Updated look at the gui with wheels and some of the artwork in place so it looks much nicer

http://i.imgur.com/29uiwLG.jpg
« Last Edit: May 17, 2015, 06:23:00 PM by atrfate »

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #1 on: May 17, 2015, 12:17:50 PM »
i can help with the first two - I haven't messed with grid at all...


You can't dynamically  link an image to a manafacturer name, I think the proper way to do this is in code for your layout transition callback:
Code: [Select]
local logo = fe.add_image("default.png", 0, 100, 640, 360);
local text = fe.add_text("[Title]", 0, 25, fe.layout.width, 72);

function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewSelection:
            local selected = fe.game_info(Info.Manufacturer, var);
            switch ( selected )
            {
               case "Capcom":
                  logo.file_name = "capcom.jpg";
                  break;
               default:
                  logo.file_name = "default.png";
                  break;
            }
            break;
    }
}

fe.add_transition_callback("transition_callback" );


As far as centering, it looks like that's because you are only making the text label 300px wide. Change that to fe.layout.width so the whole text box goes across the screen, and it should be centered within the text area.

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #2 on: May 17, 2015, 06:23:43 PM »
thanks liquid I got that text nice and centered now but that method for manufacture is kinda crazy easier to just use ahk to parse a mame xml and copy the correct png over and over me thinks
Updated, with some new troubles, any help or advice is welcome!
« Last Edit: May 17, 2015, 06:33:40 PM by atrfate »

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #3 on: May 17, 2015, 07:19:03 PM »
hmm, I wouldn't think an ahk script would be easier if it's having to parse a huge mame.xml multiple times, but if you are familiar with it, i guess that could work.

This is actually pretty straightforward - the function runs when a transition occurs (in this case ToNewSelection of a game). In there, it just checks what the manufacturer of the currently selected game is and uses the switch statement to set the appropriate image file name.

If naming every manufacturer is too complicated/confusing/much work, you could just do:

Code: [Select]
   local selected = fe.game_info(Info.Manufacturer, var);
   logo.file_name = selected + ".png";
Then if the image for that manufacturer exists, it should display it.

Any layout that makes some dynamic changes based on the list, game selected, etc will likely need a transition function anyways, so I recommend learning how that works. The benefit here is it would be included as part of your layout - and you could include the manufacturer images with the layout so anyone could use it. If you rely on an ahk script, that complicates things for others if you plan on sharing the layout :)

Like I said, unfortunately I haven't messed with the grid stuff, so I couldn't be of much help there - but I'm sure raygun or a couple others who use it in their layout could help.

Good luck... I REALLY like the updated layout, looking great!
« Last Edit: May 17, 2015, 07:27:17 PM by liquid8d »

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #4 on: May 17, 2015, 11:30:51 PM »
That works!, well kind of it still falls out of sync to what is selected, and I cant seem to figure out why this happens

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #5 on: May 18, 2015, 08:58:15 AM »
I'm not having any issues in my test. When you say "falls out of sync" - when is it not matchng/working? Are you switching lists? filters? at startup? returning from a game? after screensaver?

Note: I forgot to add 'return false;' at the end of the transition function. Maybe this might be causing you issues.
Try using this and look at the debug output, make sure that what's being printed in the output matches what you are selecting in your layout:
Code: [Select]
local logo = fe.add_image("default.png", 0, 100, 640, 360);
logo.preserve_aspect_ratio = true;
local text = fe.add_text("[Title]", 0, 25, fe.layout.width, 72);

function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.ToNewSelection:
            local romname = fe.game_info(Info.Name, var);
            local manufacturer = fe.game_info(Info.Manufacturer, var);
            print("Selected rom: " + romname + ", Manufacturer: " + manufacturer + "\n");
            logo.file_name = manufacturer + ".png";
            break;
    }
    return false;
}

fe.add_transition_callback("transition_callback" );

I didn't do extensive testing on it but you may also need this to run on more than just the one transition to work properly:

    Transition.StartLayout
    Transition.EndLayout
    Transition.ToNewSelection
    Transition.FromOldSelection
    Transition.ToGame
    Transition.FromGame
    Transition.ToNewList
    Transition.EndNavigation

That function will  need to be modified for any other transitions - the 'var' variable used in fe.game_info is different depending on which transition you are working with. Check out this section of the reference that explains the transitions callback:

https://github.com/mickelson/attract/blob/v1.5.0/Layouts.md#add_transition_callback

There's some things you'll need to take in to consideration.. for instance Taito might show as "Taito", "Taito America Corporation", "Taito Corporation Japan" or ones where it's a mix with the license "Namco (Midway license)". Depending on how important those are, you'll either need multiple images with the various names or modify the code to do a "fuzzy match" so if the manufacturer name contains 'namco' then just use the namco.png.

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #6 on: May 18, 2015, 01:28:29 PM »
Cant really explain, as I am really new to coding of this type here are 2 examples of the desync I am talking about

Where the wheel is now in the mis placed thing on the left is where small poster art will go so don't mind that it looks ugly atm :p but that box keeps in sync fine, but I cannot add any more boxes like that

http://i.imgur.com/hrxHEis.png
http://i.imgur.com/WEu3LT4.png

I attached the grid with the manufacture pictures, the art you need in place is

Videos
Boxart
Wheel
Logo

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #7 on: May 18, 2015, 03:00:47 PM »
I see... because Grid does some custom processing of handling input and has its own transition function, it doesn't always update properly.

Might need someone with more grid experience to help. I've messed with it a bit by trying to move that code into the update_frame() function, but it still doesn't seem to update everytime a movement happens to match the currently selected index. I'll keep messing with it and let you know if I can find something.

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #8 on: May 18, 2015, 09:39:07 PM »
Found out how to add more variables into gridc
Code: [Select]
function update_frame2()
{
update_audio();

frame.x = width * sel_x;
frame.y = fe.layout.height / 1.50 + height * sel_y;

wbfs_t.index_offset = get_sel() - selection_index;
}
Copy the Update frame fuction, so this should be able to give me up to 5 more indexs, you also have to add update.frame2() everytime their is an updateframe 1
this works and keeps the artwork in sync, now i have to figure out how to use this method to get me the manufacture game, now that I have something that can follow the currently selected game

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #9 on: May 18, 2015, 09:49:16 PM »
That index_offset in the update function should be the index of the currently selected game, so you can get rid of the custom transition function you added and just use the lines from it in the update function..
Code: [Select]
        local romname = fe.game_info(Info.Name, wbfs_t.index_offset);
        local manufacturer = fe.game_info(Info.Manufacturer, wbfs_t.index_offset);
        print("Selected rom: " + romname + ", Manufacturer: " + manufacturer + "\n");
        logo.file_name = manufacturer + ".png";

However like I said - when I tried to add it to the update function, it wasn't running for every movement in the grid so you might have to play with it a bit more.

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #10 on: May 19, 2015, 12:19:15 PM »
oops deleted my last post oh, well still at a loss using that it tells me that index dosent exist ect i need to find a way to always get current game info and keep it updated with movement, if i can figure out the manufacture, it also lets me add a graphic for how many buttons a game is
what is really silly is since i added update function I can now call

gridc.wbfs_t = fe.add.text(Manufacture, 0,0,1280,72) and the text will 100% keep up to date idk why calling it into a file format makes it not want to function in that way

What i am thinking since no matter what i put into gridc.wbfs or whatever its called is always up to date

could something like
gridc.img_t =
If  fe.game_info(Info.Manufacturer ) == "Capcom";
        {
      fe.add_image ( "Capcom.png", fe.layout.width / 1.21, fe.layout.height / 4.175, 235, 0);
      }
      
else if  fe.game_info(Info.Manufacturer ) == "Konami";
        {
      fe.add_image ( "Konami.png", fe.layout.width / 1.21, fe.layout.height / 4.175, 235, 0);
      }
      

Work, however it keeps giving me errrors so my formatting has to be way off
« Last Edit: May 19, 2015, 12:31:29 PM by atrfate »

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: little help/advice needed
« Reply #11 on: May 19, 2015, 08:42:53 PM »
The reason why text and artwork update themselves is because AM handles updating specific text ([Title]) or artwork (snap,marquee, etc) dynamically based on the index_offset of the text or art object.

Images don't behave that way. With an image (non-artwork), you can't use dynamic text values like [Manufacturer] for the file_name and have it automatically update.

If you were to set an image with that code - it will only set it the first time, and not update - or if that code is run multiple times you are going to be adding multiple images.

I submitted a new feature request to github that would make this much easier, but I don't know when/if that will get implemented. In the meantime, you have to manually get the correct selected game index and find the manufacturer info using fe.game_info, then set the image file_name yourself (like we are trying to do).

I was unable to figure that out.. I could make it work until the grid flips to new entries on one side or the other, then it was wrong. I'm not sure if that's an issue with grid, an issue with my understanding of the update_frame function, or maybe something you changed in the code causing that to happen.

Someone with better knowledge of grid will have to help out with that one :(

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #12 on: May 19, 2015, 09:49:03 PM »
well i bit the bullet and went and made artwork for each game for controls, and manufacture
that leaves my last issue to scrolling text and how to get it to work

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: little help/advice needed
« Reply #13 on: May 20, 2015, 10:06:06 PM »
Hey there, just skimming this topic now, but to answer your first question about how to make the grid work left to right you need to map the "Page Up" and "Page Down" actions in the controls configuration.

atrfate

  • Full Member
  • ***
  • Posts: 86
    • View Profile
Re: little help/advice needed
« Reply #14 on: May 20, 2015, 11:14:01 PM »
Hey there, just skimming this topic now, but to answer your first question about how to make the grid work left to right you need to map the "Page Up" and "Page Down" actions in the controls configuration.
Hehe i little late:p  I ment lock the grid so only left and right movement where possiable, but i found out out to remove the animation so it dont look funkey when skipping up and down
Currently trying to find out how to make text scroll across the screen for control information, menu not something pulled form game info, like Free play active! Use left and right on the joystick to select a game"!
and trying to figure out what controls the starting point of the grid
« Last Edit: May 20, 2015, 11:28:37 PM by atrfate »