Author Topic: Help to show favourite image  (Read 9724 times)

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Help to show favourite image
« on: March 29, 2016, 09:24:59 AM »
need help with script

{
 local favs=fe.game_info(Info.Favourite);
 local favart = fe.add_image("fav1.png", flx*0.01, fly*0.22, 30, 30 );
 favart.preserve_aspect_ratio = true;

 if ( favs == "1" )
 {
 favart.visible = true;
 }
 else
 {
 favart.visible = false;
 }
}


dont work....
 :-\ :(

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Help to show favourite image
« Reply #1 on: March 29, 2016, 12:24:39 PM »
I was having trouble with this last night.

This code I would expect to work:

if ( fe.game_info ( Info.Favourite ) ) {
  // Do something
}

It should return a boolean value, not a string. Even assuming its a string as in your example proves to not work. I quit last night and its funny I see this post today.

Daimon

  • Jr. Member
  • **
  • Posts: 13
    • View Profile
Re: Help to show favourite image
« Reply #2 on: March 29, 2016, 01:37:01 PM »
Try:

fe.game_info(Info.Favourite, ioffset)

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Re: Help to show favourite image
« Reply #3 on: March 29, 2016, 03:49:26 PM »
dont work

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Re: Help to show favourite image
« Reply #4 on: March 29, 2016, 10:56:13 PM »
i forked the code of ArcadeBliss theme  :P

Code: [Select]
class favicon
{
constructor()
{
local art_ref = fe.add_artwork("none");
local fav = fe.add_image( "favicon/"+my_config["favicon"]+".png", flx*0.00, fly*0.21, 60, 60 );
fav.visible = false;
favorite = fav;
}

function set_favorite()
{
local inf_fav=fe.game_info(Info.Favourite);


if (inf_fav=="1")
favorite.visible  = true;
else
favorite.visible  = false;
}

art_ref = null;
favorite = null;
}

class fav_con extends ConveyorSlot
{
                                               
constructor()
{
local fav = favicon();
base.constructor(fav);
}

}

local fav_s = [];
{
fav_s.append( fav_con() );
}

fe.add_transition_callback( "fav_renew" );
function fav_renew( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.EndNavigation:
{
foreach (fav in fav_s)
{
fav.m_obj.set_favorite();
}
}
break;
}
return false;
}


someone to help refine...

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Help to show favourite image
« Reply #5 on: March 30, 2016, 04:59:12 AM »
http://attractmode.org/docs/Layouts.html
Code: [Select]
fe.game_info()

fe.game_info( id )
fe.game_info( id, index_offset )
fe.game_info( id, index_offset, filter_offset )
Get information about the selected game.

Parameters:

id - id of the information attribute to get. Can be one of the following values:
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
index_offset - the offset (from the current selection) of the game to retrieve info on. i.e. -1=previous game, 0=current game, 1=next game... and so on. Default value is 0.
filter_offset - the offset (from the current filter) of the filter containing the selection to retrieve info on. i.e. -1=previous filter, 0=current filter. Default value is 0.
Return Value:

A string containing the requested information.

My code example that does NOT WORK properly. The heart is displayed on every game, regardless of if it is indeed a favorite or not.
Code: [Select]
if ( fe.game_info ( Info.Favourite ) == "1" ) {
  local favorite = fe.add_image ( "heart.png", 209, 2, 18, 18 );
}

When I add the following code, every game is returning a 1 for text. This makes no sense to me.
Code: [Select]
fe.add_text (  fe.game_info ( Info.Favourite ), 209, 2, 18, 18 );

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Help to show favourite image
« Reply #6 on: March 30, 2016, 07:05:01 AM »
@malfacine I figured out what was going on. The string returned was based on the game when the front end starts. It was not dynamically updated. If you use use a function with fe.add_image([!thisfunctionshouldreturntheimagepath], x, y, w, h), it should work dynamically. However, it does not work instantly when you add or remove favorite. Still working on that.

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Re: Help to show favourite image
« Reply #7 on: March 30, 2016, 11:08:15 AM »
@malfacine I figured out what was going on. The string returned was based on the game when the front end starts. It was not dynamically updated. If you use use a function with fe.add_image([!thisfunctionshouldreturntheimagepath], x, y, w, h), it should work dynamically. However, it does not work instantly when you add or remove favorite. Still working on that.


I discovered that fe.game_info(Info.Favourite) need a fe.add_artwork as a reference for work
 ;)

ArcadeBliss

  • Sr. Member
  • ****
  • Posts: 195
    • View Profile
Re: Help to show favourite image
« Reply #8 on: April 01, 2016, 12:25:54 PM »
Do you still need help? I am welcome to share my knowhow here

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Re: Help to show favourite image
« Reply #9 on: April 01, 2016, 02:21:32 PM »
Do you still need help? I am welcome to share my knowhow here


i forked your code... I'm trying to refine it...
every help would be good  ;D

solved the problem that makes your theme crash???
was giving a revised code on your...

ArcadeBliss

  • Sr. Member
  • ****
  • Posts: 195
    • View Profile
Re: Help to show favourite image
« Reply #10 on: April 04, 2016, 10:40:34 AM »
paste you code so i can take a look

malfacine

  • Full Member
  • ***
  • Posts: 33
  • fliper80s@me.com
    • View Profile
Re: Help to show favourite image
« Reply #11 on: April 04, 2016, 01:12:50 PM »
Code: [Select]
class favicon
{
constructor()
{
local art_ref = fe.add_artwork("none");
local fav = fe.add_image( "favicon/"+my_config["favicon"]+".png", flx*0.00, fly*0.21, 60, 60 );
    local alpha_cfg =
{
when = Transition.ToNewSelection,
property = "alpha",
start = 0,
end = 255,
time = 800
}
animation.add( PropertyAnimation( fav, alpha_cfg ) );
fav.visible = false;
favorite = fav;
}

function set_favorite()
{
local inf_fav=fe.game_info(Info.Favourite);
if (inf_fav=="1")
favorite.visible  = true;
else
favorite.visible  = false;
}
art_ref = null;
favorite = null;
}

class fav_con extends ConveyorSlot
{
constructor()
{
local fav = favicon();
base.constructor(fav);
}
}

local fav_s = [];
{
fav_s.append( fav_con() );
}

fe.add_transition_callback( "fav_renew" );
function fav_renew( ttype, var, ttime )
{
switch ( ttype )
{
case Transition.EndNavigation:
{
foreach (fav in fav_s)
{
fav.m_obj.set_favorite();
}
}
break;
}
return false;
}