Author Topic: Change color text  (Read 1138 times)

MegaBas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Change color text
« on: November 16, 2022, 05:15:05 AM »
Hi, I'm new to the forum and I'm trying to learn how to use this wonderful fontend.

My question is this:

How can I change the text color to black from this code?

Code: [Select]
// Text bits

local gamename = fe.add_text(" [Title] ",flx*0.085,fly*0.830,flw*0.80,40);
colors( gamename, my_config["man_color"], 0 );

local manuf = fe.add_text("[Year]  [Manufacturer]"flx*0.085,fly*0.905,flw*0.80,30);
colors( manuf, my_config["game_color"], 0 );

Full code:

Code: [Select]
// Color options

local col = "White,Grey 50%,Grey 75%,Blue,Light Blue,Green,Red,Ruby,Orange,Violet,Yellow,Yellow Orange,";

// Layout options

local o=0;
local header = "● "
local subheader = "  ○ "
local headerend = "                                                                                                   "

// Load scripts

fe.do_nut ( "scripts/colors.nut" ); // Color.nut by Giacomo Bianchi
fe.do_nut ( "scripts/carrier.nut" );
fe.load_module( "animate" );

class UserConfig
{
</ label=subheader + "Games List Type" + headerend, help="Toggle games list scrolling format",options="Text,Logo", order=o++ /> gamelist="Logo";
</ label=subheader + "Logo Speed" + headerend, help="Toggle logo games list speed",options="Fast,Medium,Slow", order=o++ /> glspeed="Medium";
</ label=subheader + "Background Skin" + headerend, help="Toggle background skin",options="Dark 1,Dark 2,Blueish,Lighter Blue,Red,Black", order=o++ /> bgrounds="Dark 2";
</ label=subheader + "Favorites Graphic" + headerend, help="Toggle (F)avorites graphic on/off",options="On,Off", order=o++ /> favorites="On";
</ label=subheader + "Text List Non-Sel. Text Color" + headerend, help="Toggle text games list non-selected list color",options="White,Red,Yellow,Blue", order=o++ /> glunsel="White";
</ label=subheader + "Year/Manufacturer Text Color" + headerend, help="Color of year and manufacturer text", options=col, order=o++ /> man_color="Red";
</ label=subheader + "Game Number Text Color" + headerend, help="Color of game number text", options=col, order=o++ /> game_color="Red";
</ label=subheader + "Progress Bar Letter Color" + headerend, help="Color of progress bar color", options=col, order=o++ /> slider_color="White";
}
local my_config = fe.get_config();

// Set up art and text elements

fe.layout.width = 640;
fe.layout.height = 480;
fe.layout.font = "captain"
local flx = fe.layout.width;
local fly = fe.layout.height;
local flw = fe.layout.width;
local flh = fe.layout.height;

// Background

if ( my_config["bgrounds"] == "Dark 1" )
{
fe.add_image( "images/background1.png", 0, 0, 640, 480 );
}
if ( my_config["bgrounds"] == "Dark 2" )
{
fe.add_image( "images/background2.png", 0, 0, 640, 480 );
}
if ( my_config["bgrounds"] == "Blueish" )
{
fe.add_image( "images/background3.png", 0, 0, 640, 480 );
}
if ( my_config["bgrounds"] == "Lighter Blue" )
{
fe.add_image( "images/background4.png", 0, 0, 640, 480 );
}
if ( my_config["bgrounds"] == "Red" )
{
fe.add_image( "images/background5.png", 0, 0, 640, 480 );
}
if ( my_config["bgrounds"] == "Black" )
{
fe.add_image( "images/background6.png", 0, 0, 640, 480 );
}

// Marquee & snap images

local snaps = fe.add_artwork( "snap", 12, 10, 512, 384 );
snaps.video_flags = Vid.ImagesOnly | Vid.NoAudio;

// videotheme timer Code by qqplayer

::OBJECTS1 <- {
artwork_videotheme = fe.add_artwork("snap", flx*0.00, fly*0.00, flw*1.00, flh*1.00),
}

OBJECTS1.artwork_videotheme.visible=false;

::videoSound <- Vid.NoAudio;
OBJECTS1.artwork_videotheme.video_flags = videoSound;

local settings = {
   delay_timer = 0,
   play_delay = 200,
   stop_play = 235000,
}

function on_transition_videotheme( ttype, var, ttime ) {
 switch ( ttype ) {
  case Transition.StartLayout:
  case Transition.ToNewSelection:
  case Transition.ToNewList:
  case Transition.EndNavigation:
        OBJECTS1.artwork_videotheme.video_flags = Vid.NoAutoStart;
        settings.delay_timer = fe.layout.time;
        OBJECTS1.artwork_videotheme.visible=false;
       break;
  }
 return false;
}

fe.add_transition_callback( "on_transition_videotheme" );

function on_tick_videotheme(tick_time) {
   if ( !OBJECTS1.artwork_videotheme.video_playing && tick_time - settings.delay_timer >= settings.play_delay ) {
   
        OBJECTS1.artwork_videotheme.video_playing = true;
       
        ::videoSound <- Vid.Default;
        OBJECTS1.artwork_videotheme.video_flags = videoSound;       
       
        OBJECTS1.artwork_videotheme.visible=true;
       
        OBJECTS1.artwork_videotheme.alpha = 0
        local alpha_artwork_videotheme_0 = {
        property = "alpha", start = 0 end = 255, time = 500 easing = Easing.Out,
        }
 
        animation.add( PropertyAnimation( OBJECTS1.artwork_videotheme, alpha_artwork_videotheme_0 ) );       
    }
   
    else if ( tick_time - settings.delay_timer >= settings.stop_play ) {
       
        OBJECTS1.artwork_videotheme.visible=false;     
    }
}
fe.add_ticks_callback(this, "on_tick_videotheme");

// Shade

fe.add_image( "images/shade.png", 0, 0, 640, 480 );

// Logo/Wheel games list

if ( my_config["gamelist"] == "Logo" )
{
if ( my_config["glspeed"] == "Fast" )
{
local carrier = Carrier( flx*0.020, fly*-0.130, flw*0.30, flh*1.1, 9, 2, 10, 0, 0 )
carrier.surfacePosSmoothing = 0.65
carrier.set_keep_aspect()
}
if ( my_config["glspeed"] == "Medium" )
{
local carrier = Carrier( flx*0.020, fly*-0.130, flw*0.30, flh*1.1, 9, 2, 10, 0, 0 )
carrier.surfacePosSmoothing = 0.80
carrier.set_keep_aspect()
}
if ( my_config["glspeed"] == "Slow" )
{
local carrier = Carrier( flx*0.020, fly*-0.130, flw*0.30, flh*1.1, 9, 2, 10, 0, 0 )
carrier.surfacePosSmoothing = 0.92
carrier.set_keep_aspect()
}
}

// Text games list

if ( my_config["gamelist"] == "Text" )
{
local lb = fe.add_listbox( flx*0.039, fly*-0.010, flw*0.478, flh*0.842 );
lb.charsize = 23;
lb.rows = 13;
lb.align = Align.Left;
lb.set_rgb ( 0, 0, 0);

lb.set_sel_rgb( 0, 0, 0 );
lb.selbg_alpha = 0

local lb = fe.add_listbox( flx*0.035, fly*-0.014, flw*0.478, flh*0.842 );
lb.charsize = 23;
lb.rows = 13;
lb.align = Align.Left;
colors( lb, my_config["glunsel"], 0 );
lb.set_sel_rgb( 241, 228, 62 );
lb.set_selbg_rgb( 45, 64, 154 );
lb.selbg_alpha = 0
}

// Text bits

local gamename = fe.add_text(" [Title] ",flx*0.085,fly*0.830,flw*0.80,40);
colors( gamename, my_config["man_color"], 0 );

local manuf = fe.add_text("[Year]  [Manufacturer]"flx*0.085,fly*0.905,flw*0.80,30);
colors( manuf, my_config["game_color"], 0 );

// Add Number of Players

local pb_x = flx*0.824;
local pb_y = fly*0.220;
local pb_w = flw*0.150;
local pb_h = flh*0.135;
local pb_text_x = pb_x-(flx*0.006);
local pb_text_y = pb_y+(fly*0.005);
local pb_text_w = pb_w;
local pb_text_h = pb_h-(flh*0.045);

function PlayerIcon() {
if (fe.game_info( Info.Players ) >= "1") return "images/players.png";
else if (fe.game_info( Info.Players ) <= "" || " ") return "images/unknownp.png";
}

local PlayerIcon= fe.add_image("[!PlayerIcon]", pb_x, pb_y, pb_w, pb_h);
local p = fe.add_text( "[Players]", pb_text_x, pb_text_y, pb_text_w, pb_text_h);
p.charsize = 50;
p.set_rgb( 0, 0, 0 );
p.align = Align.Centre;

// Add Genre images

local genre_image = fe.add_image("images/unknown.png", flx*0.824, fly* 0.805, flw*0.150, flh*0.135);
genre_image.trigger = Transition.EndNavigation;

class GenreImage
{
mode = 1;       //0 = first match, 1 = last match, 2 = random
supported = {
        //filename : [ match1, match2 ]
        "act": [ "action","platformer", "platform" ],
"plt": [ "platformer", "platform" ],
        "avg": [ "adventure" ],
        "ftg": [ "fighting", "fighter", "beat'em up" ],
        "pzg": [ "puzzle" ],
"mze": [ "maze" ],
"rhy": [ "rhythm" ],
"pbl": [ "pinball" ],
        "rcg": [ "racing", "driving" ],
        "rpg": [ "rpg", "role playing", "role-playing", "role playing game" ],
        "stg": [ "shooter", "shmup" ],
        "fly": [ "fly", "flying" ],
        "spt": [ "sports", "boxing", "golf", "baseball", "football", "soccer" "Sports" ],
        "bxg": [ "boxing" ],
        "slg": [ "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);

// Add Control images

local control_image = fe.add_image("images/unknown.png", flx*0.824, fly* 0.415, flw*0.150, flh*0.135);
control_image.trigger = Transition.EndNavigation;

class ControlImage
{
mode = 1;       //0 = first match, 1 = last match, 2 = random
supported = {
        //filename : [ match1, match2 ]
        "8way": [ "joystick (8-way)" ],
"4way": [ "joystick (4-way)" ],
"2way": [ "joystick (2-way)" ],
        "analog": [ "analog", "positional" ],
        "spin": [ "dial", "paddle" ],
        "track": [ "trackball" ],
"gun": [ "lightgun" ],
"2sticks": [ "double joystick (8-way)", "double joystick (4-way)", "double joystick (2-way)", "vertical double joystick (8-way)", "vertical double joystick (4-way)", "vertical double joystick (2-way)"  ],
"butonly": [ "only_buttons" ]
    }
    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.Control, 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";
            }
        }
    }
}
ControlImage(control_image);

// Add Buttons images

local buttons_image = fe.add_image("images/unknown.png", flx*0.824, fly* 0.610, flw*0.150, flh*0.135);
buttons_image.trigger = Transition.EndNavigation;

class ButtonsImage
{
    mode = 1;       //0 = first match, 1 = last match, 2 = random
    supported = {
        //filename : [ match1, match2 ]
        "0buttons": [ "0" ],
"1button":  [ "1" ],
"2buttons": [ "2" ],
        "3buttons": [ "3" ],
        "4buttons": [ "4" ],
        "5buttons": [ "5" ],
"6buttons": [ "6" ],
    }
    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.Buttons, 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";
            }
        }
    }
}
ButtonsImage(buttons_image);

// Favorites

if ( my_config["favorites"] == "On" )
{
function FavStar() {
if (fe.game_info( Info.Favourite ) == "1") return "images/star.png";
}
local Fav = fe.add_image("[!FavStar]", flx*0.855, fly*0.105, flw*0.090, flh*0.090);
local Fav_move_cfg = {
when =Transition.ToNewSelection,
property = "scale",
start = 3.5,
end = 1.0,
time = 1500,
tween = Tween.Bounce,
}
animation.add( PropertyAnimation( Fav, Fav_move_cfg ) );
}

// Game select sound

function select_sound( ttype, var, ttime ) {
switch ( ttype ) {
case Transition.ToNewSelection:
local sound = fe.add_sound("glclick.mp3");
sound.playing=true;
break;
}
return false;
}
fe.add_transition_callback( "select_sound" );

He tried various ways but failed.

Thank you

manzarek

  • Sr. Member
  • ****
  • Posts: 147
    • View Profile
    • YouTube
Re: Change color text
« Reply #1 on: November 16, 2022, 08:55:34 AM »
Test this
Code: [Select]
// Text bits

local gamename = fe.add_text(" [Title] ",flx*0.085,fly*0.830,flw*0.80,40);
gamename.set_rgb( 255,255,0 );

local manuf = fe.add_text("[Year]  [Manufacturer]"flx*0.085,fly*0.905,flw*0.80,30);
manuf.set_rgb( 255,255,0 );




Mame Fighting

MegaBas

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Change color text
« Reply #2 on: November 16, 2022, 10:21:35 AM »
Test this
Code: [Select]
// Text bits

local gamename = fe.add_text(" [Title] ",flx*0.085,fly*0.830,flw*0.80,40);
gamename.set_rgb( 255,255,0 );

local manuf = fe.add_text("[Year]  [Manufacturer]"flx*0.085,fly*0.905,flw*0.80,30);
manuf.set_rgb( 255,255,0 );

It is yellow but changing to 0,0,0 solved!!

Thank you very much Manzarek!