Author Topic: Display variables?  (Read 8177 times)

Brass

  • Newbie
  • *
  • Posts: 1
    • View Profile
Display variables?
« on: May 17, 2015, 07:12:43 AM »
If i set a UserConfig variable in a layout and set the same layout on multiple "displays", if i change the value of this variable on a display, it changes on all displays.
But this makes no sense, to make the variables are global? You will usually want to set something on a "display", not in the layout.
For example if I want to have a variable with a color or a logo in a layout, and I want every display has a color / different to identify the list / system that is logo, can not, I'm tied because of the variables are global.
This is my case, I have a variable to put a logo for each display system / emulator. But I can not for this restriction, I am forced to make a different layout changing only one line of code in each.

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: Display variables?
« Reply #1 on: May 17, 2015, 08:20:17 AM »
I'm not sure if I am understanding correctly your use of the UserConfig variable, but changing a logo or color based on the list/system/game is possible via code in your layout using transitions:

Per List:
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.ToNewList:
            switch ( fe.list.name )
            {
               case "Mame":
                  logo.file_name = "mame.png";
                  break;
               case "SNES":
                  logo.file_name = "snes.png";
                  break;
            }
            break;
    }
}

fe.add_transition_callback("transition_callback" );

Per Game:
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.Emulator, var);
            switch ( selected )
            {
               case "mame":
                  logo.file_name = "mame.png";
                  break;
               case "zsnes":
                  logo.file_name = "snes.png";
                  break;
            }
            break;
    }
}

fe.add_transition_callback("transition_callback" );

For either as shown above, you could use list info:
    name - Get the name of the current display.
    filter_index - Get/set the index of the currently selected filter. (see fe.filters for the list of available filters).
    index - Get/set the index of the currently selected game.

Or game_info:
    Info.Name
    Info.Title
    Info.Emulator
    Info.CloneOf
    Info.Year
    Info.Manufacturer
    Info.Category
    Info.Players
    Info.Rotation
    Info.Control
    Info.Status
    Info.DisplayCount
    Info.DisplayType
    Info.AltRomname
    Info.AltTitle
    Info.Extra
    Info.Favourite
    Info.Tags
    Info.PlayedCount
    Info.PlayedTime
    Info.FileIsAvailable
    Info.System

« Last Edit: May 17, 2015, 12:58:20 PM by liquid8d »

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: Display variables?
« Reply #2 on: May 20, 2015, 09:07:54 PM »
If i set a UserConfig variable in a layout and set the same layout on multiple "displays", if i change the value of this variable on a display, it changes on all displays.
But this makes no sense, to make the variables are global? You will usually want to set something on a "display", not in the layout.
For example if I want to have a variable with a color or a logo in a layout, and I want every display has a color / different to identify the list / system that is logo, can not, I'm tied because of the variables are global.
This is my case, I have a variable to put a logo for each display system / emulator. But I can not for this restriction, I am forced to make a different layout changing only one line of code in each.

Hi Brass, yes the user configuration variables are "global" for each layout.

This behaviour is a consequence of the fact that Attract-Mode doesn't actually reload the layout as you cycle through "displays" that have the same layout set.  SO for example, if you have the attrac-man layout going, the game keeps playing as you navigate through your various displays.  In this scenario, there was no easy way to update the layout with different user configuration variables without reloading the entire layout (and resetting where the game is at).

As you note there are workarounds.    You can simply copy the layout into another folder and then have different settings for each copy.  You could also look at using symbolic links instead of actually copying the files over: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/

slydog43

  • Full Member
  • ***
  • Posts: 66
    • View Profile
Re: Display variables?
« Reply #3 on: August 27, 2015, 02:53:16 PM »
I'm trying to do something like this.  I can't seem to get a layout change a logo based on the emulator of the romlist.  Has anyone got this working?  Thanks