Author Topic: If support...  (Read 3909 times)

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
If support...
« on: January 25, 2016, 10:44:55 AM »
What am I missing: [Emulator] is coming from the layout's selected rom list.

// Try to display graphic for system type.
if ( "[Emulator]" == "mame" )
{
fe.add_image( "mame.png", 0, 0);
}
else if ("[Emulator]" == "snes")
{fe.add_image( "snes.png", 0, 0);
}
else {
fe.add_image( "unknown.png",0,0);
}

____
if I use this: textsurface.add_text("[Emulator]",10,10,600,150);
the Emulator is revealed...so I know the variable is there, I just don't think I am getting if to compare the variable.
« Last Edit: January 25, 2016, 04:49:01 PM by bionictoothpick »

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: If support...
« Reply #1 on: January 25, 2016, 04:53:05 PM »
The magic token strings are only "translated" when supplied to text objects.. in squirrel code you would use the Info values:
https://github.com/mickelson/attract/blob/master/Layouts.md#fegame_info

so to retrieve the emulator for the currently selected game...

local emu = fe.game_info( Info.Emulator );
if ( emu == "mame" )
{
  //...
}

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: If support...
« Reply #2 on: January 25, 2016, 05:00:19 PM »
Thanks liquid8, I got that to work. Now I just need it to change the image when the emulator changes.

This topic looks like it will due the trick: fe.gameinfo http://forum.attractmode.org/index.php?topic=357.0
« Last Edit: January 25, 2016, 05:43:26 PM by bionictoothpick »

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: If support...
« Reply #3 on: January 26, 2016, 08:34:57 AM »
If anyone is following this thread...here is the solution (which came from reading threads here, and liquid8's help.

// Changing graphic based on emulator in Rom List
// ............................................................
system = "[Emulator]" + ".png";
// "[Emulator]" reads the text name for the emulator in romlist.txt
// + ".png" adds the extension for the file name
local systempic = fe.add_image( system, 0, 0, 100,100 );
// ..............................................................
« Last Edit: January 26, 2016, 08:38:04 AM by bionictoothpick »

xbs

  • Sr. Member
  • ****
  • Posts: 180
    • View Profile
Re: If support...
« Reply #4 on: January 26, 2016, 09:30:43 AM »
This works too but the images have to be named after the emulator (e.g. fusion.png or sne9x.png).

Code: [Select]
// Emulator image
if ( my_config["enable_emulogo"] == "show")
{
 local logo = fe.add_image( "[Emulator]", 30, 15, 320, 90 );
 logo.preserve_aspect_ratio = true
}
if ( my_config["enable_emulogo"] == "hide")
{
 local logo = fe.add_image( "", 30, 15, 320, 90 );
}

Is there a way to make it work with [System] instead of [Emulator]?
So that you don't need the renamed .png's.

bionictoothpick

  • Sr. Member
  • ****
  • Posts: 320
  • He who laughs lasts.
    • View Profile
Re: If support...
« Reply #5 on: January 27, 2016, 03:15:47 PM »
system = "[System]" + ".png";
local systempic = fe.add_image( system, 0, 0, 100,100 );

That should work.

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: If support...
« Reply #6 on: February 12, 2016, 07:27:46 PM »
Sorry, for the late reply. This works, just drop system logos in the layout folder and your done. Just name logos to match emulators. No editing needed.   

//System Logos
if ( my_config["enable_logos"] == "Yes") 
{
function strip_emu( ioffset )
      {
         local m = fe.game_info(Info.Emulator,ioffset);
         return split( m, " " )[0];
      }
      fe.add_image( "[!strip_emu]", flx/3.7, fly*0.03, flw*0.1 flh*0.05 );
}