Autor Tema: Crear Layouts de forma sencilla  (Leído 9660 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Crear Layouts de forma sencilla
« en: Abril 14, 2018, 11:12:59 am »
Advertisement
Podeis descargar el layout.nut modificado , se ira actualizando segun vaya añadiendole mas cosas.


Voy dejar unos links que pueden ayudar para empezar o para mas adelante:








WIP Layout Builder
http://forum.attractmode.org/index.php?topic=1697.0



La verdad que no lo he probado es un constructor para ir creando los layouts de forma grafica sin usar codigo.

La pagina de git de Attract Mode:
https://github.com/mickelson/attract

Nos bajamos el zip , en clone - download xq hay "cosas interesantes"

Si queremos ver online la parte de layouts es este link:
https://github.com/mickelson/attract/blob/master/Layouts.md

Aqui explican un monton de cosas utiles pero como digo estos links de momento son para tenerlos a mano.


Empiezo el tutorial con el layout "Basic" que viene dentro de de la instalacion de attract mode por defecto:



Si nos vamos a la carpeta del layout vemos tres archivos:



"layout.nut" aqui estaria el codigo que hace "funcionar" el layout y que posiciona todos los objetos.

Código: [Seleccionar]
//
// Attract-Mode Front-End - "Basic" sample layout
//
fe.layout.width=640;
fe.layout.height=480;

local t = fe.add_artwork( "snap", 348, 152, 262, 262 );
t.trigger = Transition.EndNavigation;

t = fe.add_artwork( "marquee", 348, 64, 262, 72 );
t.trigger = Transition.EndNavigation;

local lb = fe.add_listbox( 32, 64, 262, 352 );
lb.charsize = 16;
lb.set_selbg_rgb( 255, 255, 255 );
lb.set_sel_rgb( 0, 0, 0 );
lb.sel_style = Style.Bold;

fe.add_image( "bg.png", 0, 0 );

local l = fe.add_text( "[DisplayName]", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;

// The following function tells the frontend to use our title
// text and listbox (created above) for any menus (exit menu,
// etc...
//
fe.overlay.set_custom_controls( l, lb );

// Left side:

l = fe.add_text( "[Title]", 30, 424, 320, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

l = fe.add_text( "[Year] [Manufacturer]", 30, 441, 320, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

l = fe.add_text( "[Category]", 30, 458, 320, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

// Right side:

l = fe.add_text( "[ListEntry]/[ListSize]", 320, 424, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;

l = fe.add_text( "[FilterName]", 320, 441, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;

Para no "marearnos" al ver tanto texto voy a poner dos o tres ejemplos de lo mas comun que nos encontraremos.
Siempre funciona de la misma manera.

Lo tenemos aqui muy bien explicado:

https://github.com/mickelson/attract/blob/master/Layouts.md#functions

Como digo para simplificar voy poner los mas comunes:

fe.add_image
fe.add_artwork
fe.add_sound
fe.add_text
fe.add_listbox

Se me olvido comentar que en este tuto no vamos a ser "exquisitos" en temas de programacion , nos centraremos en como hacer funcionar las cosas de una forma facil y para todo el publico , no me interesa si se puede usar una mega funcion de mil parametros o si el lenguaje de squirrel usado no es correcto.
A partir de aqui , si funciona y es facil , nos sirve  ;D

Para usar cualquiera de estos cuatro elementos nos vamos al layout basic:


"fe.add_image"

Lo usaremos siempre que queramos añadir "una imagen"  :D
En este caso si queremos añadir un fondo al layout.

Código: [Seleccionar]
fe.add_image( "bg.png", 0, 0 );

Siempre que usemos "fe.add" necesitamos darle un "objeto" por asi llamarle que en este caso es "bg.png" y su posicion.
Siemrpe se usan los dos primeros para posicionarlo en "x" (desde cero hasta la derecha) "y" (desde arriba hasta abajo)  ;D
Luego vendria "el tamaño" , si en este caso le ponemos:

Código: [Seleccionar]
fe.add_image( "bg.png", 5, 100 300,300 );

Cambiariamos el tamaño y la posicion de este "objeto"

IMPORTANTE: VOY A CAMBIAR EL COLOR DEL bg.png PARA QUE SE VEA MEJOR , XQ AL SER NEGRO ES DIFICIL APRECIAR SU TAMAÑO Y FORMA.

Dejo las dos opciones:

Código: [Seleccionar]
fe.add_image( "bg.png", 0, 0 );


Código: [Seleccionar]
fe.add_image( "bg.png", 5, 100 300,300 );



IMPORTANTE: Y como sabemos donde nos va a quedar el "objeto" , pues con estas dos lineas del principio del layout.nut:

Código: [Seleccionar]
fe.layout.width=640;
fe.layout.height=480;

Aqui le estamos diciendo el "ancho" (fe.layout.width=640) y el "alto" (fe.layout.height=480) de nuestro layout.

fe.add_artwork

En el caso del layout basic tenemos:

Código: [Seleccionar]
local t = fe.add_artwork( "snap", 348, 152, 262, 262 );
t.trigger = Transition.EndNavigation;

Los mismos "principios" de fe.add_image se aplican en fe.add_artwork , en lo referente a tamaño y posicionamiento.
La diferencia mas palpable con respetecto a fe.add_image es que la ubicacion del artwork se la damos en los archivos emulator.cfg
En este layout tenemos "snap" pero podemos llamarle "video" "cosa" ...  ;D
Siempre y cuando en nuestro emlator.cfg creemos una ruta indicandole donde se encuentra "snap" "video" "cosa"... y este en formatos multimedia "png" , "mp4" , "jpg"... (no se cuantos formatos soporta pero estos tres seguro que si)

Si nos bajamos el zip de Attract Mode en la carpeta emulators tenemos varios archivos "mame.cfg" por ej:

Código: [Seleccionar]
# Generated by Attract-Mode 1.5.1
#
executable           $HOME/mame/mame
args                 [name]
rompath              $HOME/mame/roms/
romext               .zip;.7z;<DIR>
system               Arcade
info_source          listxml
artwork    flyer           
artwork    marquee         $HOME/mame/marquees
artwork    snap            $HOME/mame/videos;$HOME/mame/snap
artwork    wheel           

Vemos esta linea:

Código: [Seleccionar]
artwork    snap            $HOME/mame/videos;$HOME/mame/snap
Pues si por ej dejamos cambiasemos "snap" por "video" deberiamos darle la ruta:

Código: [Seleccionar]
artwork    video            $HOME/mame/videos;$HOME/mame/snap
Y nos funcionaria igualmente.
Porque explico esto , en algunos layouts vamos a tener que buscarnos la vida para ver exactamente que nombre le han puesto al artwork para que nos salga , puede ser "boxart", ,"cartart","cdart","boxartback"...

Supongamos que queremos "añadir" otro artwork al layout Basic , por ej colocar los flyers de mame detras del la lista de roms.

Código: [Seleccionar]
local v = fe.add_artwork( "flyer", 32, 64, 262, 352 );
Simplemente añadiendo esto antes de la linea:

Código: [Seleccionar]
local lb = fe.add_listbox( 32, 64, 262, 352 );
Obtendriamos esto:



Como queda de culo  ;D en la seccion 2 añadire algunas opciones y una pequeña "animacion".


fe.add_sound

Dejo un link muy util

http://forum.attractmode.org/index.php?topic=221.0

Este es el codigo que debemos añadir a nuestro layout.nut si queremos que haga el "tipico click" o lo que queramos caundo nos movemos por la lista de juegos.

Código: [Seleccionar]
function transition_callback(ttype, var, ttime)
{
    switch ( ttype )
    {
        case Transition.StartLayout:
case Transition.ToNewSelection:
                 local Wheelclick = fe.add_sound("Click.mp3")
Wheelclick.playing=true
            break;
    }
 return false;
}

fe.add_transition_callback( "click_transitions" );




"Click.mp3" puede ser cualquier nombre , pero debe ir al lado del layout.nut


fe.add_text


Es la forma en la que añadimos "textos" , no hay mucho mas que explicar , acepta "magic tokens" (esta parte esta explicada en el post 2 para fe.add_image) , animaciones (tambien explicado para artwork) y se le puede cargar algun modulo "especial".

Código: [Seleccionar]
local l = fe.add_text( "[DisplayName]", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;
l.align = Align.Left;

Funciona de forma similar a los anteriores.

El tipo de fuente usada en el layout se le da con este codigo:

Código: [Seleccionar]
fe.layout.font="BEYNO";
Usando un ejemplo del layout Basic:

Código: [Seleccionar]
fe.add_text( "[DisplayName]", 0, 15, 640, 30 )

Añadiria , usando el magic token "DisplayName" un texto en la posicion y tamaño que le indicamos con las coordenadas (0, 15, 640, 30)

Código: [Seleccionar]
l.font = "SF TransRobotics";
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;
l.align = Align.Left;
l.charsize = 18;

Voy enumerar las "opciones" que yo recuerdo que se le pueden dar:
Tipo de letra (l.font = "SF TransRobotics"; ) , color (l.set_rgb( 200, 200, 70 ); ) , estilo (l.style = Style.Bold; ) , alineacion del texto (l.align = Align.Left; ) , tamaño de la fuente (l.charsize = 18; )

Código: [Seleccionar]
l.font = "SF TransRobotics"; Esto lo usariamos si queremos que una parte concreta del layout tenga una fuente diferente a la "generica" que le dimos al principio.

Código: [Seleccionar]
fe.layout.font="BEYNO";
Si queremos que use la generica no hace falta poner nada  ;D


fe.add_listbox

Lo usamos para añadir la tipica "lista" de juegos.
Funciona casi igual que fe.add_text

Código: [Seleccionar]
local lb = fe.add_listbox( 32, 64, 262, 352 );
lb.charsize = 16;
lb.set_selbg_rgb( 255, 255, 255 );
lb.set_sel_rgb( 0, 0, 0 );
lb.sel_style = Style.Bold;
« Última modificación: Abril 23, 2018, 10:46:37 pm por machiminax »



Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #1 en: Abril 14, 2018, 11:13:38 am »
En este segundo post intentare explicar como usar los parametros del primer post.
Pero "complicandolo" un poco mas.
Seria "Nivel Medio"


fe.add_image Magic Tokens


Antes explique como añadir una imagen

Citar
Siempre que usemos "fe.add" necesitamos darle un "objeto" por asi llamarle que en este caso es "bg.png" y su posicion.
Siemrpe se usan los dos primeros para posicionarlo en "x" (desde cero hasta la derecha) "y" (desde arriba hasta abajo)  ;D
Luego vendria "el tamaño" , si en este caso le ponemos:

Y si queremos que este "objeto" no sea "fijo" sino que cambie , por ejemplo que sea el logo de MAME , Super Nintendo...

Usaremos "Magic Tokens"

Código: [Seleccionar]
The following magic tokens are currently supported:

    [DisplayName] - the name of the current display
    [ListSize] - the number of items in the game list
    [ListEntry] - the number of the current selection in the game list
    [FilterName] - the name of the filter
    [Search] - the search rule currently applied to the game list
    [SortName] - the attribute that the list was sorted by
    [Name] - the short name of the selected game
    [Title] - the full name of the selected game
    [Emulator] - the emulator to use for the selected game
    [CloneOf] - the short name of the game that the selection is a clone of
    [Year] - the year for the selected game
    [Manufacturer] - the manufacturer for the selected game
    [Category] - the category for the selected game
    [Players] - the number of players for the selected game
    [Rotation] - the rotation for the selected game
    [Control] - the primary control for the selected game
    [Status] - the emulation status for the selected game
    [DisplayCount] - the number of displays for the selected game
    [DisplayType] - the display type for the selected game
    [AltRomname] - the alternative Romname for the selected game
    [AltTitle] - the alternative title for the selected game
    [PlayedTime] - the amount of time the selected game has been played
    [PlayedCount] - the number of times the selected game has been played
    [SortValue] - the value used to order the selected game in the list
    [System] - the first "System" name configured for the selected game's emulator
    [SystemN] - the last "System" name configured for the selected game's emulator
    [Overview] - the overview description for the selected game

https://github.com/mickelson/attract/blob/master/Layouts.md#magic

Un compañero queria añadir un logo de MAME  al layout Basic.

http://arcadespain.info/Foro/index.php?topic=6171.msg80655;topicseen#new



Lo primero seria buscar el codigo de ese texto para no "poner por encima" el logo:

Código: [Seleccionar]
local l = fe.add_text( "[DisplayName]", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;

Como le ponemos logos en vez de "textos" pues cambiamos por lo siguiente:

Código: [Seleccionar]
local s = fe.add_image( "system/[DisplayName]", 250, 15, 100, 30 );

IMPORTANTE: Esto solo funcionara si creamos una carpeta "system" dentro de la carpeta del layout:



Y dentro obviamente metemos los logos  ;)



Este seria el codigo que necesitamos.

Código: [Seleccionar]
local s = fe.add_image( "system/[DisplayName]", 250, 15, 100, 30 );

local l = fe.add_text( "", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;

Mas adelante haremos un layout desde cero si el tema interesa pero para no complicarnos ahora fijaros que dejo esta parte asi:

Código: [Seleccionar]
local l = fe.add_text( "", 0, 15, 640, 30 );
En lugar de eliminarlo completamente xq nos daria mas dolores de cabeza que beneficios.
Esto lo hago xq el layout "llama" al "objeto" l en una funcion y en otras partes asi que mejor dejarlo "vacio" que eliminarlo.

Bueno , lo que nos interesa , asi quedaria el tema:



Igual que antes se puede "modifcar" el tamaño y la posicion variando estos parametros:

Código: [Seleccionar]
local s = fe.add_image( "system/[DisplayName]", 250, 15, 100, 30 );
Si modifcamos 250 por 300 se ira mas a la derecha y viceversa
Si modifcamos 15 por 50 se ira mas a la abajo y viceversa
Si modifcamos 100 por 200 sera mas ancho y viceversa
Si modifcamos 30 por 50 sera mas alto y viceversa


IMPORTANTE
Citar
Tengo un sistema y le pongo el logo pero no me sale el png...

Posibles motivos , al usar "Magic Tokens" , en este caso DisplayName tenemos que fijarnos en el nombre que tiene nuestro "Display"
Esto en Attract Mode es un poco lio si empezamos de cero , xq DisplayName no es una carpeta ni un archivo , lo encontrariamos en el attract.cfg

Código: [Seleccionar]
display MAME
layout               Basic
romlist              MAME
in_cycle             yes
in_menu              yes
filter               All
filter               Favourites
rule                 Favourite equals 1

Comento esto porque puede darse el caso de que nos convenga usar otro magic token para nuestro caso concreto , podria ser:

Código: [Seleccionar]
local s = fe.add_image( "system/[Emulator]", 250, 15, 100, 30 );
Si hacemos esto el "nombre" que nos usaria seria los que tenemos en la carpeta Emulators , en este caso podria ser el MAME.cfg

Y si tenemos varios emuladores para un mismo sistema , pues usamos "System"

Código: [Seleccionar]
local s = fe.add_image( "system/[System]", 250, 15, 100, 30 );
Esto de donde lo saca Attract Mode , pues si abrimos cualquier emulator.cfg veremos esta parte:

Código: [Seleccionar]
system               Arcade

Para repasar y finalizar esta parte de Magic Tokens con fe.add_image al igual que cambiamos el parametro del magic token tambien se puede cambiar su ubicacion.
Para aclarar "system/[DisplayName]" significa que el layout.nut buscara un archivo con el nombre de nuestro display en una carpeta llamada system situada junto a el.
Si hacemos una carpeta llamada logos pues lo cambiamos por "logos/[DisplayName]"
Y si lo metemos en una subcarpeta "images/logos" pues igual  :)

Código: [Seleccionar]
local s = fe.add_image( "images/logos/[DisplayName]", 250, 15, 100, 30 );
Asi quedaria el tema cambiando el texto por un logo con su bg.png original sin el verdoso que le puse antes  ;D




fe.add_artwork fe.load_module

En nuestro ejemplo tenemos un artwork "flyer" debajo de la lista de roms.
Para que luzca un poco mas le añadiremos una animacion para que pase de ser invisible a verse mediante una pequeña transicion.
Para ello nos serviremos de los "modulos" que nos ayudan a crear esa transicion sin tener que escribir el codigo completo necesario para que se produzca.

Código: [Seleccionar]
// modules
fe.load_module("fade");
fe.load_module( "animate" );

Se suelen colocar al principio del layout.nut y deben estar en la carpeta modules de nuestra instalacion.

Se necesitarian dos transicions , una para cuando arrancamos attract mode o cambiamos de layout y otra para cuando nos movemos por la lista de roms.

Código: [Seleccionar]
local v = fe.add_artwork( "flyer", 32, 64, 262, 352 );
v.alpha = 0;

local v_alpha_onload = {
    when = When.StartLayout,
    when = Transition.ToNewList,
    property = "alpha",
    start = 0,
    end = 155,
    time = 1500,
    tween = Tween.Expo
 }

animation.add( PropertyAnimation ( v, v_alpha_onload ) );

Esta seria la primera , y aqui desglosado:

Código: [Seleccionar]
v.alpha = 0
Esto hace que nuestro flyer sea "invisible" luego con la transicion haremos que aparezca.

Esta seria la parte donde le damos las "caracteristicas" de nuestra transicion:

Código: [Seleccionar]
local v_alpha_onload = {
Cuando queremos que se ejcute , en este caso cuando iniciemos el layout "When.StartLayout" y cuando cambiemos de lista "Transition.ToNewList" , esto se hace para cuando nos movemos entre filtros para que el flyer no quede invisible si por ejemplo pasas de la lista "plataformas" a la lista "shooter".

Código: [Seleccionar]
    when = When.StartLayout,
    when = Transition.ToNewList,

Esto le indica que empiece en 0 y termine en 155 (alpha 255 seria lo maximo posible)

Código: [Seleccionar]
    start = 0,
    end = 155,

El tiempo que queremos que dure la transicion:

Código: [Seleccionar]
    time = 1500,
El "tipo" de transicion , para esto se usa el modulo "animate"

Código: [Seleccionar]
    tween = Tween.Expo
Por ultimo se necesita "ejecutarla"

Código: [Seleccionar]
animation.add( PropertyAnimation ( v, v_alpha_onload ) );
"v" es el nombre que le dimos a nuestro "objeto" flyer.
"v_alpha_onload" el nombre de nuestra transicion.

Si abrimos el modulo "animate.nut" nos explica como usarlo.

Citar
ANIMATION CONFIGS:
   
        Configs are flexible and options vary depending on the Animation class you are using. The base options are:
   
        //handled by Animation base class
        when = When.ToNewSelection          // when the animation starts (can use Transition, but other When options are available)
        time = 500                          // length of animation in ms
        delay = 0                           // delay before animation starts in ms
        wait = false                        // whether this is a waiting animation during transitions (complete before continuing)
        loop = false                        // whether to loop the animation (can also be a number)
        pulse = false                       // whether to pulse the animation (can also be a number), use onReverse() to handle reversing your animation - by default, it will reverse start/end values
        tween = Tween.Linear                // type of tween to use during animation (use calculate to determine tween/easing value)
        easing = Easing.Out                 // type of easing to use during animation (use calculate to determine tween/easing value)

Ademas en el zip de github del propio attract mode en "attract-master\config\layouts\Sample Animate" encontraremos mucha informacion por si alguien quiere profundizar en el tema.

Lo siguiente seria la transicion para cuando nos movemos entre roms:

Código: [Seleccionar]
local v_alpha = {
    when = Transition.ToNewSelection,
    property = "alpha",
    start = 0,
    end = 155,
    time = 1500,
    tween = Tween.Expo
 }

animation.add( PropertyAnimation ( v, v_alpha ) );

Seria exactamente igual que la otra salvo en dos cosas , su nombre tiene que ser diferente a la otra "v_alpha" y la ejecutamos solo cuando nos movemos en la lista de roms "Transition.ToNewSelection"

Este seria el resultado:




fe.add_sound function fe.game_info

Este codigo no es mio y aun no lo he probado , es de Calle81 del grupo de Hyperpie.

http://forum.attractmode.org/index.php?topic=1793.0

Código: [Seleccionar]
////////////////
//Background Music
////////////
local bgMusic = fe.add_sound("")
function bgmusic_transitions( ttype, var, ttime ) {
switch ( ttype ) {
case Transition.FromOldSelection:
bgMusic.playing=false
bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
bgMusic.playing=true
bgMusic.loop=true
break;
case Transition.ToGame:
case Transition.ToNewList:
bgMusic.playing=false
bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
bgMusic.playing=true
bgMusic.loop=true
break;
}
return false;
}

fe.add_transition_callback( "bgmusic_transitions" );

En este caso utiliza una funcion para poder hacerlo funcionar.
De momento no me detengo mucho en explicar como crearlas xq tampoco soy un experto  :D

Una parte muy importante es usar "fe.game_info" las funciones no pueden usar "magic tokens" hasta donde yo se , por eso debemos darle el nombre del juego y su extension usando este parametro:

Código: [Seleccionar]
fe.game_info(Info.Title)+".mp3"
Tal como fue creada la funcion buscaria la cancion con el mismo nombre del juego en una carpeta "music" que estaria en la raiz de la instalacion de AM.

Código: [Seleccionar]
bgMusic.file_name = "../../music/"+fe.game_info(Info.Title)+".mp3"
Modificando esta parte por:

Código: [Seleccionar]
bgMusic.file_name = "music/"+fe.game_info(Info.Title)+".mp3"
Podriamos ponerla dentro de la carpeta del layout en una subcarpeta "music"


fe.add_text fe.load_module

Voy usar el modulo "scrollingtext" de Liquid8b

http://forum.attractmode.org/index.php?PHPSESSID=7tLoV3vG9uvbHjNbHli112&topic=300.msg2189#msg2189



Funciona todo mas o menos como vengo explicando , asi es como lo tengo configurado en el layout Basic:

Código: [Seleccionar]
/////////////
//Scroll Text

fe.load_module("objects/scrollingtext");

ScrollType.HORIZONTAL_LEFT);
local scroller = ScrollingText.add("[Title]", 400, 420, 150, 50, ScrollType.HORIZONTAL_LEFT);
scroller.settings.fixed_width= 280;
scroller.settings.loop =100;
scroller.set_rgb ( 0, 16, 150 );
scroller.text.charsize = 18;
scroller.settings.speed_x = 1;
scroller.text.font = "BEYNO";

La unica "novedad" , seria esta:

Código: [Seleccionar]
fe.load_module("objects/scrollingtext");
El modulo viene por defecto en la instalacion de AM en la carpeta "modules/objects" , por eso hay que cargarlo añadiendo "objects"  ;)

Funciona de la siguiente forma:

Código: [Seleccionar]
local scroller = ScrollingText.add("[Title]", 400, 420, 150, 50, ScrollType.HORIZONTAL_LEFT);
"scroller" esto tiene que ser "fijo" xq es como el modulo reconoce que queremos usar un texto scroll.Luego lo de siempre , magic token "Title" , posicion y tamaño y el tipo de "Scroll"

Si abrimos el "scrollingtext.nut" tenemos mas informacion:

Código: [Seleccionar]
//  Requirements:
//  the modules/objects/scroller directory along with this module
//
//  Example:
//      local scroller = ScrollingText.add( "[Title]", 0, 0, 500, 30 );
//      scroller.set_bg_rgb( 255, 255, 255 );   //wrapper function to set scroller background
//      scroller.set_rgb( 200, 0, 0);   //wrapper function to set text color
//      //some settings can be modified
//      scroller.settings.delay = 250;
//      scroller.settings.loop = 5;   //fixed loop count

Son las opciones de fe.add_text mas las propias del modulo.


fe.add_listbox Animation

Uno de los themes con las lisbox mas chula que tengo visto es el gamestation.
Usa una "funcion" para ocultar y mostrar lista.



Código: [Seleccionar]
//Game List Animation
 ::OBJECTS <- {
 wheelLogo = fe.add_artwork("wheel", flx*0.025, fly*0.03, flw*0.23, flh*0.13),
 logo = fe.add_image("logo.png", flx*0.0265, fly*0.03, flw*0.23, flh*0.13 ),
 marquee = fe.add_artwork("marquee", flx*-0.2, fly*0.67, flw*0.18, flh*0.1),
 gameListBG = fe.add_image ("black.png",flx, 0, flw*0.6, flh),
 gameListTitle = fe.add_text("[Title]", flx, fly*0.055, flw*0.05, flh*0.1),
 gameListBox = fe.add_listbox( flx, fly*0.171, flw*0.45, flh*0.65 ),
 gameListList1 = fe.add_text("[ListSize]",flx, fly*0.88, flw*0.3, flh*0.1),
 gameListList2 = fe.add_text("[ListEntry]",flx, fly*0.83, flw*0.3, flh*0.1),
 gameListList3 = fe.add_text("[ListEntry]/[ListSize]",flx*0.76, fly*0.465, flw*0.3, flh*0.06),
 moveStrip = fe.add_artwork("flyer2", flx*-1, fly*0.8, flw, flh*0.163 ),
 }

::OBJECTS["marquee"].trigger = TRIGGER;
::OBJECTS["moveStrip"].trigger = TRIGGER;

//Animation for Global & Expert Mode

 local move_shrink1 = {
    when = Transition.ToNewList ,property = "scale", start = 1.8, end = 1.0, time = 1500, tween = Tween.Bounce
 }
 local move_shrink2 = {
    when = Transition.ToNewSelection ,property = "scale", start = 1.8, end = 1.0, time = 1500, tween = Tween.Bounce
 }
 local move_marquee1 = {
    when = Transition.ToNewSelection ,property = "x", start = flx*-0.3, end = 0, time = 900
 }
 local move_marquee2 = {   
    when = Transition.ToNewSelection ,property = "x", start = 0, end = flx*-0.3, time = 1600, delay = 3600
 }
 local move_strip1 = {   
    when = Transition.ToNewSelection ,property = "x", start = flx*-1 end = flx*0, time = 3000, delay = 3600
 }
 local move_strip2 = {   
    when = Transition.ToNewSelection ,property = "x", start = flx*-1 end = flx, time = 1, delay = 1
 }
 local move_gameListBG1 = {
    when = Transition.ToNewSelection ,property = "x", start = flw, end = flx*0.59, time = 1
 }
 local move_gameListBG2 = {
    when = When.ToNewSelection ,property = "x", start = flx*0.59, end = flw, time = 600, delay=1000
 }
 local move_gameListTitle1 = {
    when = Transition.ToNewSelection ,property = "x", start = flw, end = flx*0.605, time = 1
 }
 local move_gameListTitle2 = {
    when = When.ToNewSelection ,property = "x", start = flx*0.605, end = flw, time = 580, delay=1000
 }
 local move_gameListBox1 = {
    when = Transition.ToNewSelection ,property = "x", start = flw, end = flx*0.59, time = 1
 }
 local move_gameListBox2 = {
    when = When.ToNewSelection ,property = "x", start = flx*0.6, end = flw, time = 595, delay=1000
 }
 local move_gameListList1 = {
    when = Transition.ToNewSelection ,property = "x", start = flw, end = flx*0.719, time = 1
 }
 local move_gameListList2 = {
    when = When.ToNewSelection ,property = "x", start = flx*0.719, end = flw, time = 500, delay=1000
 }
 local move_gameListList3 = {
    when = Transition.ToNewSelection ,property = "x", start = flw, end = flx*0.68, time = 1
 }
 local move_gameListList4 = {
    when = When.ToNewSelection ,property = "x", start = flx*0.689, end = flw, time = 528, delay=1000
 }


//Animation
  animation.add( PropertyAnimation( OBJECTS.gameListBG, move_gameListBG1 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListBG, move_gameListBG2 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListTitle, move_gameListTitle1 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListTitle, move_gameListTitle2 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListBox, move_gameListBox1 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListBox, move_gameListBox2 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListList1, move_gameListList1 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListList1, move_gameListList2 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListList2, move_gameListList3 ) );
  animation.add( PropertyAnimation( OBJECTS.gameListList2, move_gameListList4 ) );
  OBJECTS.gameListList3.visible = false;

if ( my_config["wheel_logo"] == "Wheel + System" ){
 OBJECTS.logo.visible = true;
 OBJECTS.wheelLogo.visible = true;
}

else if ( my_config["wheel_logo"] == "System Only" ){
 OBJECTS.logo.visible = true;
 OBJECTS.wheelLogo.visible = false;
}

else if ( my_config["wheel_logo"] == "Wheel Only" ){
 OBJECTS.logo.visible = false;
 OBJECTS.wheelLogo.visible = true;
}

if ( my_config["enable_strip"] == "No" ){
 OBJECTS.moveStrip.visible = false;
 }

 animation.add( PropertyAnimation( OBJECTS.wheelLogo, move_shrink1 ) );
 animation.add( PropertyAnimation( OBJECTS.wheelLogo, move_shrink2 ) );
 animation.add( PropertyAnimation( OBJECTS.logo, move_shrink1 ) );
 animation.add( PropertyAnimation( OBJECTS.logo, move_shrink2 ) );
 animation.add( PropertyAnimation( OBJECTS.marquee, move_marquee1 ) );
 animation.add( PropertyAnimation( OBJECTS.marquee, move_marquee2 ) );
 animation.add( PropertyAnimation( OBJECTS.moveStrip, move_strip2 ) );
 animation.add( PropertyAnimation( OBJECTS.moveStrip, move_strip1 ) );

 OBJECTS.gameListTitle.alpha = 230;
 OBJECTS.gameListBG.alpha = 235
 OBJECTS.gameListBox.charsize = 28;
 OBJECTS.gameListBox.align = Align.Left;
 OBJECTS.gameListBox.rows=9;
 OBJECTS.gameListBox.set_sel_rgb( 240, 240, 240 );
 OBJECTS.gameListBox.set_selbg_rgb( bgRed, bgGreen, bgBlue );
 OBJECTS.gameListBox.set_rgb( 205, 205, 205 );
 OBJECTS.gameListList1.align = Align.Right;
 OBJECTS.gameListList1.alpha = 20;
 OBJECTS.gameListList2.set_rgb( bgRed, bgGreen, bgBlue );
 OBJECTS.gameListList2.align = Align.Right;
 OBJECTS.gameListList2.alpha = 140;


Parece un lio descomunal al principio xq ademas de la lista le añade varias animaciones de otros objetos , pero seria sencillo dejar solo la lista si nos interesase ponerla en nuestro Basic.

Código: [Seleccionar]
gameListBox = fe.add_listbox( flx, fly*0.171, flw*0.45, flh*0.65 ),
Aprovecho para comentar esta parte:

Código: [Seleccionar]
flx, fly*0.171, flw*0.45, flh*0.65
Esto se usa para crear layouts "responsive" que se adapten a diferentes pantallas

Para que funcione correctamente necesitamos este codigo al principio del layout:

Código: [Seleccionar]
local flx = fe.layout.width;
local fly = fe.layout.height;
local flw = fe.layout.width;
local flh = fe.layout.height;


Voy dejar un ejemplo un poco mas sencillo que hice para mi rpi zero:

Código: [Seleccionar]
// Title
local title = fe.add_text("[Title]", 10, 595, 600, 50);
title.align = Align.Left;
title.charsize = 31;
title.set_rgb(255, 255, 255);
title.alpha = 0;
//title.style = Style.Underlined;

local title_alpha_cfg_on_load = {
    when = When.StartLayout,
    when = Transition.ToNewList,
    property = "alpha",
    start = 0,
    end = 255,
    time = 1000
}

animation.add( PropertyAnimation( title, title_alpha_cfg_on_load ) );

local title_shrink_cfg_on_load = {
    when = When.StartLayout,
    when = Transition.ToNewList,
    property = "scale",
    start = 0.1,
    end = 1.0,
    time = 2000
    tween = Tween.Quad,
}

animation.add( PropertyAnimation( title, title_shrink_cfg_on_load ) );

local title_alpha_cfg = {
    when = Transition.ToNewSelection ,
    property = "alpha",
    start = 0,
    end = 255,
    time = 1000
}

animation.add( PropertyAnimation( title, title_alpha_cfg ) );

local title_shrink_cfg = {
    when = Transition.ToNewSelection ,
    property = "scale",
    start = 0.1,
    end = 1.0,
    time = 2000
    tween = Tween.Quad,
}

animation.add( PropertyAnimation( title, title_shrink_cfg ) );


/////////////////////
local gamelist = fe.add_listbox( -1000, 400, 700, 400 );   
gamelist.sel_green = 255;
gamelist.sel_blue = 255;
gamelist.sel_red = 255;
gamelist.sel_alpha = 0;
gamelist.selbg_alpha = 0;
//gamelist.sel_style = Style.Underlined;
gamelist.set_rgb( 118, 118, 118 );
gamelist.charsize = 30;
gamelist.align = Align.Left;
gamelist.rows = 10;

local gamelist_slide_start_cfg = {
    when = When.StartLayout,
    property = "x",
    start = -1000,
    end = 10
    time = 1500
    tween = Tween.Quad,
}

animation.add( PropertyAnimation( gamelist, gamelist_slide_start_cfg ) );

Solamente lleva una pequeña animacion cuando inciamos el layout y cuando nos movemos entre los juegos otra unicamente para el juego seleccionado:



Basicamente , ocultamos una parte del listbox con este codigo:

Código: [Seleccionar]
gamelist.sel_green = 255;
gamelist.sel_blue = 255;
gamelist.sel_red = 255;
gamelist.sel_alpha = 0;
gamelist.selbg_alpha = 0;

Y con esta parte añadimos el juego seleccionado usando otro objeto y que parezca que forma parte de la lista  ;D

Código: [Seleccionar]
local title = fe.add_text("[Title]", 10, 595, 600, 50);


Por si alguien quiere el fondo es este:

http://backgroundcheckall.com/wp-content/uploads/2017/12/arcade-background-12.jpg
« Última modificación: Agosto 16, 2021, 04:08:57 pm por machiminax »

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #2 en: Abril 14, 2018, 11:14:25 am »
Esta parte la dejare para cosas un pelin mas complicadas

fe.add_listbox fe.load_module

Un buen ejemplo seria añadir listas animadas o wheels tipo hyperspin.

Usaremos este modulo de Arcadebliss que simplifica mucho la tarea:

http://forum.attractmode.org/index.php?topic=1945.msg13393#msg13393

Conveyor_Helper Module



https://drive.google.com/file/d/0B6SHVZjz_r1fOUVTUmktUWF5blU/view

Lo dejo aqui de momento , mas adelante lo añadiremos al basic.



conveyour_helper_mod Auto Wheel Creator Theme





Dejo el "theme" y el modulo con las modificaciones en adjuntos.

Voy explicar las partes "mas importantes" tendriamos que duplicar el theme xq no consigo que cargue el modulo usando una funcion , asi que de momento hay que hacer una copia del mismo , si por ej queremos usarlo para MAME  , lo duplicamos y le ponemos "Basic_mame" de nombre o lo que cada uno quiera.

Partes importantes:

conveyour_helper_mod.zip : debemos descomprimirlo en la carpeta "modules" , RECORDAR UNA VEZ MAS QUE EL MODULO ES DE ARCADEBLISS , yo solo le hice un par de modificaciones  ;)

Dentro del zip dejo tres "bases de wheels de ejemplo" , no son mias , son de "Viking" del foro de launchbox.



El nombre de la "base de wheel" tiene que ser el mismo de vuestro "Emulator"

Basic_md.zip : descomprimir en la carpeta layouts

Ejemplo para emulador "Sega Mega Drive"



Código: [Seleccionar]
fe.layout.font = fe.game_info(Info.Emulator); La fuente para cada sistema tiene que estar junto al layout.nut y llamarse igual que el "Emulator"

Código: [Seleccionar]
      // ----------- List Item Content: Text -----------
      spinList.text.message = "[Title]";
      spinList.text.alignment = Align.Centre;           // OPTIONS:left/right/center
      spinList.text.normal.font = fe.game_info(Info.Emulator);
      spinList.text.normal.size = 18;                // OPTIONS: text font size for every gameList item
      spinList.text.normal.color.red = 255;            // OPTIONS: text font red color channel 0 - 255
      spinList.text.normal.color.green = 255;         // OPTIONS: text font green color channel 0 - 255
      spinList.text.normal.color.blue = 255;            // OPTIONS: text font blue color channel 0 - 255
     
      spinList.text.currentlySelected.font = fe.game_info(Info.Emulator);
      spinList.text.currentlySelected.size = 18;       // OPTIONS: text font size for every gameList item
      spinList.text.currentlySelected.color.red = 255;   // OPTIONS: text font red color channel 0 - 255
      spinList.text.currentlySelected.color.green = 255; // OPTIONS: text font green color channel 0 - 255
      spinList.text.currentlySelected.color.blue = 255;  // OPTIONS: text font blue color channel 0 - 255

Con esta parte se controlan los colores y el tamaño de los textos de las wheels que crea cuando no teneis un "png"

Código: [Seleccionar]
         temp = object.add_customGameItemContent("text", "[Title]", 5 ,30 ,190 ,120);
         temp.font = object.text.normal.font;
         temp.word_wrap = true;
         temp.charsize  = object.text.normal.size;
         temp.align = object.text.alignment;
         temp.set_rgb(object.text.normal.color.red, object.text.normal.color.green, object.text.normal.color.blue);

Esta parte controla el tamaño y posicion del texto generado.

Código: [Seleccionar]
         temp = object.add_customGameItemContent("artwork","wheel", 20 ,60 ,150 ,60 );
         temp.preserve_aspect_ratio = object.artwork.preserveAspect;
         temp.trigger = Transition.EndNavigation;
         object.gi_textFallback = true;

Esta parte el tamaño de la base y su posicion.


function update_clock fe.do_nut("nuts/ryb2rgb.nut")













Mas o menos esto debe ser lo que queria hacer Empardopo , la mayor parte del codigo es de calle81 de hyperpie y el resto del theme de robospin.

layout.nut

Código: [Seleccionar]
//
// Attract-Mode Front-End - "Basic" sample layout
//
class UserConfig {
    </ label="Clock", help="Enable Clock", options="Yes,No", order=1 /> enable_clock="No";

    </ label="Enable random text colors", help=" Select random text colors.", options="yes,no", order=4/> enable_colors="yes";
   
   
    </ label="COLOUR OPTIONS", help="Brought to you by Project HyperPie", order=30 /> uct9=" ";
</ label="Border Overlay Color as R,G,B", help="( 0-255 values allowed )\nSets the colour of background elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=31 /> bgrgb="0,0,0"
</ label="List Box Background Color as R,G,B", help="( 0-255 values allowed )\nSets the colour of background elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=32 /> lbgrgb="0,0,30"
</ label="Video Frame Color as R,G,B", help="( 0-255 values allowed )\nSets the colour of the frame.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=334 /> frrgb="250,250,250"
</ label="Category text color as R,G,B", help="( 0-255 values allowed )\nSets the colour of accent elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=35 /> selrgb="255,255,255"
</ label="Title color as R,G,B", help="( 0-255 values allowed )\nSets the colour of accent elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=36 /> titrgb="255,255,255"
</ label="Clock as R,G,B", help="( 0-255 values allowed )\nSets the colour of accent elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=37 /> gslrgb="0,102,102"
</ label="Year and Manufacturer as R,G,B", help="( 0-255 values allowed )\nSets the colour of accent elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=38 /> pldrgb="254,255,255" 
</ label=" ", help="Brought to you by Project HyperPie", order=39 /> uct10=" ";




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

local layout_width = fe.layout.width
local layout_height = fe.layout.height

// modules
fe.load_module("fade");
fe.load_module( "animate" );
fe.do_nut("nuts/ryb2rgb.nut");

local my_config = fe.get_config();

function irand(max) {
local roll = (1.0 * rand() / RAND_MAX) * (max + 1)
return roll.tointeger()
}

local bgRYB = [irand(255), irand(255), irand(255)]
local lbgRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]
local selRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]
local titRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]
local gslRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]
local pldRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]
local frRYB = [255 - bgRYB[0], 255 - bgRYB[1], 255 - bgRYB[2]]

local bgRGB = ryb2rgb(bgRYB)
local lbgRGB = ryb2rgb(titRYB)
local selRGB = ryb2rgb(selRYB)
local titRGB = ryb2rgb(titRYB)
local gslRGB = ryb2rgb(titRYB)
local pldRGB = ryb2rgb(titRYB)
local frRGB = ryb2rgb(titRYB)

try { bgRGB = fe.nv[0] } catch(e) {}
try { lbgRGB = fe.nv[0] } catch(e) {}
try { selRGB = fe.nv[1] } catch(e) {}
try { titRGB = fe.nv[1] } catch(e) {}
try { gslRGB = fe.nv[1] } catch(e) {}
try { pldRGB = fe.nv[1] } catch(e) {}
try { frRGB = fe.nv[1] } catch(e) {}

local error_message = false
if( my_config["bgrgb"] != "" ) {
try { bgRGB = split(my_config["bgrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}

local error_message = false
if( my_config["lbgrgb"] != "" ) {
try { lbgRGB = split(my_config["lbgrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}

if( my_config["selrgb"] != "" ) {
try { selRGB = split(my_config["selrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}

if( my_config["titrgb"] != "" ) {
try { titRGB = split(my_config["titrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}

if( my_config["gslrgb"] != "" ) {
try { gslRGB = split(my_config["gslrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}
if( my_config["pldrgb"] != "" ) {
try { pldRGB = split(my_config["pldrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}
if( my_config["frrgb"] != "" ) {
try { frRGB = split(my_config["frrgb"], ",").map(function(value) return value.tointeger()) }
catch(e) { error_message = true}
}

if ( error_message || bgRGB.len() != 3 ||  lbgRGB.len() != 3 ||  selRGB.len() != 3 || titRGB.len() != 3 || gslRGB.len() != 3 || pldRGB.len() != 3 || frRGB.len() != 3)
while (!fe.overlay.splash_message( "Background or Accent colour has a wrong format.\nPlease check it in Layout Options")){}


local t = fe.add_artwork( "snap", 348, 152, 262, 262 );
t.trigger = Transition.EndNavigation;

t = fe.add_artwork( "marquee", 348, 64, 262, 72 );
t.trigger = Transition.EndNavigation;

local lb = fe.add_listbox( 32, 64, 262, 352 );
lb.charsize = 16;
lb.set_selbg_rgb( 255, 255, 255 );
lb.set_sel_rgb( 0, 0, 0 );
lb.sel_style = Style.Bold;

fe.add_image( "bg.png", 0, 0 );

local l = fe.add_text( "[DisplayName]", 0, 15, 640, 30 );
l.set_rgb( 200, 200, 70 );
l.style = Style.Bold;

// The following function tells the frontend to use our title
// text and listbox (created above) for any menus (exit menu,
// etc...
//
fe.overlay.set_custom_controls( l, lb );

// Left side:

l = fe.add_text( "[Title]", 30, 424, 320, 16 );
l.set_rgb(titRGB[0],titRGB[1],titRGB[2]);
//l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

l = fe.add_text( "[Year] [Manufacturer]", 30, 441, 320, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

l = fe.add_text( "[Category]", 30, 458, 320, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Left;

// Right side:

l = fe.add_text( "[ListEntry]/[ListSize]", 320, 424, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;

l = fe.add_text( "[FilterName]", 320, 441, 290, 16 );
l.set_rgb( 200, 200, 70 );
l.align = Align.Right;

//Display current time
if ( my_config["enable_clock"] == "Yes" ){
  local dt = fe.add_text( "", flw*0.65, flh*0.03, flw*0.3, flh*0.095 );
dt.align = Align.Centre;
dt.filter_offset = 1;
//dt.set_rgb( 200, 200, 70 );
dt.set_rgb(gslRGB[0], gslRGB[1], gslRGB[2]);
dt.style = Style.Regular;
dt.charsize = 24;
dt.font = "DS-DIGI";

  local clock = fe.add_image ("clock.png",flw*0.71, flh*0.042, flw*0.040, flh*0.06);
  clock.alpha = 255;
  clock.preserve_aspect_ratio = true;
  //clock.set_rgb( gslRGB[0], gslRGB[1], gslRGB[2] )

function update_clock( ttime ){
  local now = date();
  dt.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
}
  fe.add_ticks_callback( this, "update_clock" );
 

// random number for the RGB levels
if ( my_config["enable_colors"] == "yes" )
{
function brightrand() {
 return 255-(rand()/255);
}

local red = brightrand();
local green = brightrand();
local blue = brightrand();

// Color Transitions
fe.add_transition_callback( "color_transitions" );
function color_transitions( ttype, var, ttime ) {
 switch ( ttype )
 {
  case Transition.StartLayout:
  case Transition.ToNewSelection:
  red = brightrand();
  green = brightrand();
  blue = brightrand();
  lb.set_rgb(red,green,blue);
  //dt.set_rgb(red,green,blue);
  clock.set_rgb (red,green,blue);
  break;
 }
 return false;
 }
}
 
}


ryb2rgb.nut

Código: [Seleccionar]
function max(a,b) {return a > b ? a : b}
function min(a,b) {return a < b ? a : b}

function ryb2rgb(color) {
    local r = color[0].tofloat()
local y = color[1].tofloat()
local b = color[2].tofloat()
    // Remove the whiteness from the color.
    local w = min(r, min(y, b));
    r -= w;
    y -= w;
    b -= w;

    local my = max(r, max(y, b));

    // Get the green out of the yellow and blue
    local g = min(y, b);
    y -= g;
    b -= g;

    if (b > 0 && g > 0) {
        b *= 2.0;
        g *= 2.0;
    }

    // Redistribute the remaining yellow.
    r += y;
    g += y;

    // Normalize to values.
    local mg = max(r, max(g, b));
    if (mg > 0) {
        local n = my / mg;
        r *= n;
        g *= n;
        b *= n;
    }

    // Add the white back in.
    r += w;
    g += w;
    b += w;

    // And return back the ryb typed accordingly.
    return [floor(r), floor(g), floor(b)];
}

Tendriamos que eliminar parte del codigo que no lo necesitamos para el "reloj" sobre todo en la parte que gestiona los colores , pero de momento lo dejo asi  ;D

Voy intentar explicar lo mas importante por si alguien quiere añadirlo a otro layut:


ryb2rgb.nut

Necesitamos un archivo "ryb2rgb.nut" y hay que "cargarlo" en el layout.nut con este codigo:

Código: [Seleccionar]
fe.do_nut("nuts/ryb2rgb.nut");
Creamos una carpeta "nuts" dentro de nuestro layout y lo metemos dentro  ;)
El codigo completo lo puse un poco mas arriba.
Este .nut sirve para "modificar el color" del reloj y otros elementos desde el menu de opciones del layout sin tener que estar escribiendo y modificando el codigo.


layout.nut

"class UserConfig"

En este apartado le añadimos opciones de configuracion que se pueden habilitar , configurar y demas historias desde el f.e. sin tener que reescribir el codigo a mano.

Para habilitar o deshabilitar el reloj:

Código: [Seleccionar]
    </ label="Clock", help="Enable Clock", options="Yes,No", order=1 /> enable_clock="No";
Esto es un poco "hortera" para mi gusto  :D , es del theme robospin usa , una funcion para generar colores aleatorios:

Código: [Seleccionar]
    </ label="Enable random text colors", help=" Select random text colors.", options="yes,no", order=4/> enable_colors="yes";

Despues esta el "tocho" de opciones de colores que venian en el theme de hyperpie , lo he dejado completo pero solo usaremos esta parte:

Código: [Seleccionar]
</ label="Clock as R,G,B", help="( 0-255 values allowed )\nSets the colour of accent elements.\nLeave blank if you want the colour from the randomized to be stored permanently.", option="0", order=37 /> gslrgb="0,102,102"
Para que estas configuraciones se carguen se añade esta linea:

Código: [Seleccionar]
local my_config = fe.get_config();
Esta es la funcion del reloj:

Código: [Seleccionar]
//Display current time
if ( my_config["enable_clock"] == "Yes" ){
  local dt = fe.add_text( "", flw*0.65, flh*0.03, flw*0.3, flh*0.095 );
dt.align = Align.Centre;
dt.filter_offset = 1;
//dt.set_rgb( 200, 200, 70 );
dt.set_rgb(gslRGB[0], gslRGB[1], gslRGB[2]);
dt.style = Style.Regular;
dt.charsize = 24;
dt.font = "DS-DIGI";

  local clock = fe.add_image ("clock.png",flw*0.71, flh*0.042, flw*0.040, flh*0.06);
  clock.alpha = 255;
  clock.preserve_aspect_ratio = true;
  //clock.set_rgb( gslRGB[0], gslRGB[1], gslRGB[2] )

function update_clock( ttime ){
  local now = date();
  dt.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
}
  fe.add_ticks_callback( this, "update_clock" );
 

Si se quiere cambiar la fuente hay que modificar a mano esta parte:

Código: [Seleccionar]
dt.font = "DS-DIGI";
Con esta parte y la seccion de "config" es como le damos los colores al los numeros del reloj:

Código: [Seleccionar]
dt.set_rgb(gslRGB[0], gslRGB[1], gslRGB[2]);
Código: [Seleccionar]
gslRGB Es la parte que "importante" que pusimos en config.



La funcion del robospin de los colores aleatorios es esta:

Código: [Seleccionar]
// random number for the RGB levels
if ( my_config["enable_colors"] == "yes" )
{
function brightrand() {
 return 255-(rand()/255);
}

local red = brightrand();
local green = brightrand();
local blue = brightrand();

// Color Transitions
fe.add_transition_callback( "color_transitions" );
function color_transitions( ttype, var, ttime ) {
 switch ( ttype )
 {
  case Transition.StartLayout:
  case Transition.ToNewSelection:
  red = brightrand();
  green = brightrand();
  blue = brightrand();
  lb.set_rgb(red,green,blue);
  //dt.set_rgb(red,green,blue);
  clock.set_rgb (red,green,blue);
  break;
 }
 return false;
 }
}

}


Si por ejemplo queremos que los numeros del reloj cambien de color aleatoriamente cada vez que cambiamos de rom basta con dejar esta linea asi:

Código: [Seleccionar]
dt.set_rgb(red,green,blue);
En squirrel se "//" deshabilita una linea simple.

Si hacemos esto , debemos modificar esta otra para que no cree conflicto:

Código: [Seleccionar]
//dt.set_rgb(gslRGB[0], gslRGB[1], gslRGB[2]); 

UPDATE "Custom font"

Pequeño añadido para escoger el tipo de fuente del "reloj" desde el menu de configuracion:

Código: [Seleccionar]
    </ label="Custom Font", help="Choose Custom Font", options="custom1,custom2,custom3,custom4,custom5,custom6,up,down,left,right", order=10 /> custom_font="custom1";
Código: [Seleccionar]
//Display current time
if ( my_config["enable_clock"] == "Yes" ){
  local dt = fe.add_text( "", flw*0.65, flh*0.03, flw*0.3, flh*0.095 );
dt.align = Align.Centre;
dt.filter_offset = 1;
//dt.set_rgb( 200, 200, 70 );
dt.set_rgb(gslRGB[0], gslRGB[1], gslRGB[2]);
dt.style = Style.Regular;
dt.charsize = 24;
dt.font = fe.get_config()["custom_font"];

  local clock = fe.add_image ("clock.png",flw*0.71, flh*0.042, flw*0.040, flh*0.06);
  clock.alpha = 255;
  clock.preserve_aspect_ratio = true;
  //clock.set_rgb( gslRGB[0], gslRGB[1], gslRGB[2] )

function update_clock( ttime ){
  local now = date();
  dt.msg = format("%02d", now.hour) + ":" + format("%02d", now.min );
}
  fe.add_ticks_callback( this, "update_clock" );

Esta seria la modificacion de la funcion del reloj

Código: [Seleccionar]
dt.font = fe.get_config()["custom_font"];
El unico requisito seria que las fuentes usadas se llamen "custom1" , "custom2" ...
Bajamos las que nos gusten , las renombramos y ya esta  ;)
Y si no pues se modifica el config añadiendo las que mas nos gusten:


Código: [Seleccionar]
    </ label="Custom Font", help="Choose Custom Font", options="ARCADE,DS-DIGI,LemonMilk,Roboto-Regular", order=10 /> custom_font="ARCADE";
« Última modificación: Agosto 15, 2021, 09:05:26 pm por machiminax »

Desconectado Josepzin

  • VIP
  • *
  • Mensajes: 2219
  • Gracias 38
  • Habitacus!
    • Blog
  • Ciudad: Carthago Miriya
  • Pais: Argentina
Re:Crear Layouts de forma sencilla
« Respuesta #3 en: Abril 14, 2018, 01:50:26 pm »
Muy bueno!! cuando puedaa le daré un repaso porque seguro hay cosas que no sé todavía.

Desconectado empardopo

  • Admin
  • *
  • Mensajes: 21746
  • Gracias 761
  • Espero mejorar al KungFu Master!
    • Mi canal de Youtube
  • Ciudad: Norte de África
  • Pais: Escoña
  • Iniciales nick: EPP
Re:Crear Layouts de forma sencilla
« Respuesta #4 en: Abril 14, 2018, 07:52:11 pm »
@Machiminax, cojonudo el post explicadito como a mi me gusta pasito a pasito. Genial y muchísimas gracias!!!!!

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #5 en: Abril 14, 2018, 08:57:15 pm »
@Machiminax, cojonudo el post explicadito como a mi me gusta pasito a pasito. Genial y muchísimas gracias!!!!!

Se me olvido comentar que voy ir actualizando , acabo de poner fe.add_artwork y en la seccion "avanzada" el fe.load_module  ;)
Cada vez que actualice algo creo un pequeño post para que sirva de aviso.

Desconectado beaches

  • El amo de los recres
  • ****
  • Mensajes: 902
  • Gracias 18
  • Iniciales nick: TTD
Re:Crear Layouts de forma sencilla
« Respuesta #6 en: Abril 15, 2018, 01:12:53 am »
Muy buen hilo y mejor frontend. Muy interesante machiminax




Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #7 en: Abril 16, 2018, 05:00:39 pm »
Pequeño update "fe.add_sound" , es la forma en que podemos añadir "sonidos" en la seccion "media" como añadir "musica de fondo" dependiendo del layout o sistema.
« Última modificación: Abril 16, 2018, 05:07:32 pm por machiminax »

Desconectado empardopo

  • Admin
  • *
  • Mensajes: 21746
  • Gracias 761
  • Espero mejorar al KungFu Master!
    • Mi canal de Youtube
  • Ciudad: Norte de África
  • Pais: Escoña
  • Iniciales nick: EPP
Re:Crear Layouts de forma sencilla
« Respuesta #8 en: Abril 16, 2018, 08:11:18 pm »
Pequeño update "fe.add_sound" , es la forma en que podemos añadir "sonidos" en la seccion "media" como añadir "musica de fondo" dependiendo del layout o sistema.


Wapísimo! Muchas gracias compi!!! Está quedando genial! Thanks

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #9 en: Abril 16, 2018, 09:40:34 pm »
Pequeño update "fe.add_sound" , es la forma en que podemos añadir "sonidos" en la seccion "media" como añadir "musica de fondo" dependiendo del layout o sistema.


Wapísimo! Muchas gracias compi!!! Está quedando genial! Thanks

Al final "rehice" desde cero el basic layout y asi lo estoy dejando con todas las cosas que estoy explicando en los posts anteriores.



Modulo de scroll de texto y modifique un "timer.nut" de keilmillerjr.
Lo que hace basicamente es recorrer la lista de juegos cada x tiempo y lanzar un juego aleatorio  :D , es totalmente configurable.

Cuando añada la parte de texto pego el codigo completo de mi layout Basic.

« Última modificación: Agosto 16, 2021, 04:05:20 pm por machiminax »

Desconectado Josepzin

  • VIP
  • *
  • Mensajes: 2219
  • Gracias 38
  • Habitacus!
    • Blog
  • Ciudad: Carthago Miriya
  • Pais: Argentina
Re:Crear Layouts de forma sencilla
« Respuesta #10 en: Abril 17, 2018, 01:39:40 am »
Cómo controlas... :O

Desconectado empardopo

  • Admin
  • *
  • Mensajes: 21746
  • Gracias 761
  • Espero mejorar al KungFu Master!
    • Mi canal de Youtube
  • Ciudad: Norte de África
  • Pais: Escoña
  • Iniciales nick: EPP
Re:Crear Layouts de forma sencilla
« Respuesta #11 en: Abril 17, 2018, 09:17:21 am »
Es un crack!!

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #12 en: Abril 17, 2018, 11:56:04 am »
Bueno pues ya casi terminamos , dejare para el final la parte de añadir listas tipo hyper y poco mas :)

Acabo de añadir fe.add_text y listbox
« Última modificación: Abril 17, 2018, 02:32:18 pm por machiminax »

Desconectado machiminax

  • VIP
  • *
  • Mensajes: 1849
  • Gracias 112
  • Ciudad: indefinida
  • Pais: desconocido
Re:Crear Layouts de forma sencilla
« Respuesta #13 en: Abril 20, 2018, 03:03:13 pm »


A ver si este fin de semana publico esta parte , usando el modulo de conveyour_helper de ArcadeBliss con alguna pequeña modificacion podriamos crear una wheel tipo hyperspin y el propio modulo le añadiria los "bordes" a los logos o en su defecto un texto con el nombre del juego y con la fuente y el color que nosotros escojamos  ;)

La modificacion que le hice seria justo esa , que segun el sistema que usemos "cambie" el borde de la wheel , mame , mega drive , msx ... tendrian su propio fondo no usarian uno igual para todos.


Desconectado Josepzin

  • VIP
  • *
  • Mensajes: 2219
  • Gracias 38
  • Habitacus!
    • Blog
  • Ciudad: Carthago Miriya
  • Pais: Argentina
Re:Crear Layouts de forma sencilla
« Respuesta #14 en: Abril 20, 2018, 06:15:26 pm »
o en su defecto un texto con el nombre del juego y con la fuente y el color que nosotros escojamos  ;)

No entiendo porqué la wheel de AM no tiene esa opción desde hace siglos...

Esta fue una de las razones por las que me hice mi propio layout, para que en ciertos sistemas ponga lista de texto y en otras logos.

 


* Salón Recreativo #55 (27-04-2024 / 26-05-2024)  Autor: beaches Foro: Salón Recreativo FaseBonus 20/05/2024 (16:58)
* MPAGD (Multi Platform Arcade Game Designer)  Autor: jose365 Foro: Creación de juegos 19/05/2024 (17:38)
* Música y artistas aptos para nuestra jukebox  Autor: Zael Foro: Offtopic 19/05/2024 (12:20)
* [PS4] PS4 5.05 - Should I Stay or Shoud I Go?  Autor: Zael Foro: Consolas actuales 19/05/2024 (11:59)
* Retro 320 - Wizard of wor  Autor: Zael Foro: Competiciones y concursos 19/05/2024 (11:48)
* [Recomendacion] Series para ver  Autor: arquillos Foro: Offtopic 19/05/2024 (10:45)
* [Recomendación] Cine para los findes en casa (bueno, bonito y barato)  Autor: arquillos Foro: Offtopic 18/05/2024 (15:43)
* El megapost del ZX Spectrum  Autor: arquillos Foro: Offtopic 17/05/2024 (08:14)
* Van dos y se cae el del medio - Hilo de cachondeo general  Autor: joselopez Foro: Offtopic 16/05/2024 (00:56)
* ¿A qué estáis jugando ahora mismo?  Autor: joselopez Foro: Offtopic 16/05/2024 (00:35)
* Amiga Games + 1.9.3  Autor: empardopo Foro: Emuladores 15/05/2024 (20:48)
* Ofertas Amazon  Autor: empardopo Foro: Offtopic 15/05/2024 (20:33)
* [N3DS] Red Viper - Emulando Virtual Boy como Dios manda  Autor: sirdrak Foro: Noticias de emuladores 13/05/2024 (00:53)
* La inteligencia artificial ha llegado a la música  Autor: Zael Foro: Offtopic 12/05/2024 (20:24)
* Info sobre MARP  Autor: empardopo Foro: Records y wolfmame 12/05/2024 (20:09)
* Stop the express  Autor: empardopo Foro: ZX Spectrum 12/05/2024 (20:05)
* Retro Portable Maker ArcadeSpain (RPMA)  Autor: empardopo Foro: Otros programas 12/05/2024 (17:37)
* Recopilatorio Retos: Desde el 1 hasta .....  Autor: montypepa Foro: Competiciones y concursos 05/05/2024 (21:30)
* iojukebox Theme, un JukeBox para Attract-Mode  Autor: gucaza Foro: Themes AM 04/05/2024 (02:47)
* Nuevo miniPc para mi vieja recre y juegos Windows compatibles formato 4:3  Autor: jmpuk Foro: Offtopic 02/05/2024 (23:31)
* Homenaje a Locomalito  Autor: beaches Foro: Otros programas 02/05/2024 (23:03)
* Etpa8: El Reino Subterráneo  Autor: jmpuk Foro: ZX Spectrum 01/05/2024 (21:49)
* West Bank para ZX Spectrum  Autor: empardopo Foro: ZX Spectrum 01/05/2024 (20:07)
* Patrocinador para el foro ArcadeSpain  Autor: empardopo Foro: Noticias 29/04/2024 (19:37)
* Aprende a hacerte un PORTABLE de tu juego arcade favorito  Autor: empardopo Foro: Records y wolfmame 29/04/2024 (19:27)

Reto 320: Wizard of Wor
Buscaunchollo.click