Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: jedione on April 11, 2019, 07:19:29 PM
-
retro fe ,,,,has it
launch box has it...
apparently, we have seen it in AM ,,,, Oomek,s layout....that will never come to be..
would anyone like to give it a tackle.... i would love to try to help...
dont we deserve to on this level guys.... :D
(http://i66.tinypic.com/5ujuih.png)
thanks..
-
Hmm I never implemented it in Arcadeflow because I don't want it to look too much like Oomek's work, but considering that I already have code to extract first letter, or decade in case the sorting is by year, or genre if the sorting is by genre, I can try and craft some simple layout using this. Some ideas from the keyboard search plugin might be useful for laying out the letters and highlighting them...
I'm not sure I'll have the time, but I'll see if I can come up with something.
-
So this is the quick and dirty solution I built, based on my "gameletter" routine. Consider that my routine works for different sortings, but this layout only works if the sorting is not by category, manufacturer or year. If you want to expand it to work with all this sortings you should change the key array accordingly
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.5
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
keys = {}
local i = 0
local key_names = [ "#", "A", "B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
foreach (key, val in key_names){
local key_obj = fe.add_text(val, i*flw/key_names.len(),flh*0.5,flw/key_names.len(),50)
key_obj.charsize = 50
key_obj.alpha = 128
i++
keys[val] <- key_obj
}
keys [gameletter(0)].alpha = 255
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
}
-
ill give it a try.....after work today ,,,thanks
-
so i added your code ....thanks to... shuffle module...
and this is what i got....
for starters...it loops so it gets off letter if that makes sence....
if i can get shuffle module to just go from a to z that would be good...
also the sig used is next letter....so when you do next game it is now off to..
almost like it could be fixed with a new module by kyle....hmmm
here is a quick demo just using "next letter" then at end i screw it up to show you how it is now off.
https://youtu.be/-CiiHgsHEdw (https://youtu.be/-CiiHgsHEdw)
here is the theme....code...
local flx = fe.layout.width;
local fly = fe.layout.height;
local flw = fe.layout.width;
local flh = fe.layout.height;
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local gamename = fe.add_text("[Title]",600,400,800,50);
gamename.charsize = 50
local white = fe.add_image ("white.png",232,150,50,980);
white.set_rgb ( 0, 0, 0 );
local snap = fe.add_artwork ("snap",400,400,400,400);
//local accent = fe.add_text ("[!gameletter]",233,400,50,50);
//accent.charsize = flh*0.20
local x = flx*0.122
## fly*
local w = flw*0.260
local h = flh*0.060
local x1 = flx*0.051
## fly*
local w1 = flw*0.000
local h1 = flh*-0.02
## call module
#######################################
fe.load_module("shuffle");
## Extend the Shuffle class
#######################################
class ShuffleList extends Shuffle {
function update() {
base.update();
}
## Overwrite the select function
#######################################
function select(slot) {
slot.font="RLU.ttf";
slot.align = Align.Left;
slot.charsize = 27;
slot.style = Style.Bold;
//slot.set_rgb ( 255, 255, 0 );
//slot.alpha = 200;
}
## Overwrite the deselect function
#######################################
function deselect(slot) {
slot.font="RLU.ttf";
slot.align = Align.Left;
slot.charsize = 27;
slot.style = Style.Bold;
slot.set_rgb (240, 240, 240);
//slot.alpha = 200;
}
}
##Shuffle Gamelist
#######################################
local list = [];
list.push(fe.add_text("A", x, fly*0.122, w, h));
list.push(fe.add_text("B", x, fly*0.177, w, h));
list.push(fe.add_text("C", x, fly*0.232, w, h));
list.push(fe.add_text("D", x, fly*0.287, w, h));
list.push(fe.add_text("E", x, fly*0.342, w, h));
list.push(fe.add_text("F", x, fly*0.397, w, h));
list.push(fe.add_text("G", x, fly*0.452, w, h));
list.push(fe.add_text("H", x, fly*0.507, w, h));
list.push(fe.add_text("I", x, fly*0.562, w, h));
list.push(fe.add_text("J", x, fly*0.617, w, h));
list.push(fe.add_text("K", x, fly*0.672, w, h));
list.push(fe.add_text("L", x, fly*0.727, w, h));
list.push(fe.add_text("M", x, fly*0.782, w, h));
list.push(fe.add_text("N", x, fly*0.837, w, h));
list.push(fe.add_text("O", x, fly*0.892, w, h));
## Shufffle Pow Extend the Shuffle class
#######################################
class ShufflePow extends Shuffle {
function update() {
base.update();
}
## Overwrite the select function
#######################################
function select(slot) {
slot.visible = true;
slot.font="RLU.ttf";
slot.align = Align.Left;
slot.charsize = 27;
slot.style = Style.Bold;
slot.set_rgb ( 0, 255, 0 );
}
## Overwrite the select function
#######################################
function deselect(slot) {
slot.visible = false;
}
}
## extended image list
#######################################
local pow = [];
pow.push(fe.add_text("[!gameletter]", x, fly*0.122, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.177, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.232, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.287, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.342, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.397, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.452, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.507, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.562, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.617, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.672, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.727, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.782, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.837, w, h));
pow.push(fe.add_text("[!gameletter]", x, fly*0.892, w, h));
## Create an instance of the extended class
#########################################
local list = ShuffleList(list, "text");
local pow = ShufflePow(pow, "text");
of coarse it need shuffle module
-
Good job Jedione. I also worked on indicator/ progress bar last week for RetroMania theme. Check it out > https://www.youtube.com/watch?v=bZ9CDi08Vec
-
I think that most of the problems you have with my code (which is very rude anyway) is that it's not built to work with shuffle, I have no idea how shuffle works. The code updates only the current and previous letters based on ToNewSelection transitions to be less resource heavy, alternatively you can clean up all the letters and "light up" the current one, but you need to find the proper trigger for that in shuffle mode.
Just to be sure, the routine detecting the current letter is working right?
-
at rand0m
interesting that is exactley....like mine to
it will be in the aura theme
check it out...we must want some of the same things...
you tube...https://youtu.be/lg1gA9azSRs (https://youtu.be/lg1gA9azSRs)
-
@jedione Just the other day i made a small snippet of code for rand0m on discord to extract the letters and other characters using regex. This feature has nothing to do with shuffle, and should be implemented separately.
firstLetter(){
local firstChar = rstrip(fe.game_info(Info.Title)).slice(0,1);
local expression = regexp(“[a-zA-Z]â€);
expression.match(firstChar) ? return firstChar : return “#â€;
}
If you want to not display a whole alphabet, should probably white a separate function with similar logic to shuffle? Ill work on making shuffle not loop soon. Will connect computer tonight. Just moved and been busy.
-
at rand0m
interesting that is exactley....like mine to
it will be in the aura theme
check it out...we must want some of the same things...
you tube...https://youtu.be/lg1gA9azSRs (https://youtu.be/lg1gA9azSRs)
Yes. the code works, like a charm...
that was a just off the cuff test thinking on how to do this, because i know no other,,,way
i will probley be stuck here on this for a wile...im by no means a coder, just sometimes
try to be savvy with others codes to make things work... or revers engineer.
any way thanks for your input. if ya have any moor ideas or figure out how to do this,,
a big thanks bro... ;) ill mess with it some more this weekend.
-
@jedione Just the other day i made a small snippet of code for rand0m on discord to extract the letters and other characters using regex. This feature has nothing to do with shuffle, and should be implemented separately.
firstLetter(){
local firstChar = rstrip(fe.game_info(Info.Title)).slice(0,1);
local expression = regexp(“[a-zA-Z]â€);
expression.match(firstChar) ? return firstChar : return “#â€;
}
If you want to not display a whole alphabet, should probably white a separate function with similar logic to shuffle? Ill work on making shuffle not loop soon. Will connect computer tonight. Just moved and been busy.
i new you would show up,,before long...lol
always when i have to go to work...dam-it
ill look at your code also later tonight...thanks
this could be made ...when done into a progress-bar module..hmm
-
This thread is giving me ideas... I like both Oomek and Rand0m implementation, but I'm thinking of something even more radical... I want to add markers on my scrollbar for the letters and space them according to the actual number of games of that letter. This will work also for years, genres etc... I'll start coding ASAP lol!
-
@kyle..
firstLetter(){
local firstChar = rstrip(fe.game_info(Info.Title)).slice(0,1);
local expression = regexp(“[a-zA-Z]â€);
expression.match(firstChar) ? return firstChar : return “#â€;
}
how is this used? in a theme it just breaks it..
-
@kyle..
firstLetter(){
local firstChar = rstrip(fe.game_info(Info.Title)).slice(0,1);
local expression = regexp(“[a-zA-Z]â€);
expression.match(firstChar) ? return firstChar : return “#â€;
}
how is this used? in a theme it just breaks it..
It returns the first character of the currently selected game, or the pound symbol for other non alphabetical characters.
Ill try to assemble a lightweight module similar to shuffle.
-
how does one use it in a theme, hard coded?
it just breaks the theme the way it is..thats all :D
but also thanks, for what you are doing to!.
-
how does one use it in a theme, hard coded?
it just breaks the theme the way it is..thats all :D
but also thanks, for what you are doing to!.
Not sure what you mean by hard coded. Its just a simple function, not a class. It returns a value. Untested because i wrote it on my iphone. On my way right not with measurements to make extension cords and such to hook up computer. Excited to be back on attract.
-
im glad your exited.....your services are needed.
i guess all i was saying was , that the code was not working.. i can see what it does
it looks kind of explanatory.. its probley something simple... ill wait for you to get your stuff all handled..
thanks
-
Here is the code I am using
//Indicator Bar
local indicator_bar = fe.add_image( "images/indicator_bar.png", 36, 180, 12,760 );
local indicator_graph = fe.add_image( "images/indicator_graph.png", 38, 180, 8, 760 );
local indicator_position = fe.add_image( "images/circle.png", 20, 0, 42, 42 );
Indicator_bar is the outline in red color, indicator_graph is the red filler, its a pixel 1x1 and indicator_position is the circle where first alphabet of title is displayed.
//Get First Letter of Title and Adjust Non-Alphabetical Chars
function first_letter ()
{
local first_char = rstrip(fe.game_info(Info.Title)).slice(0,1);
local expression = regexp("[a-zA-Z]");
if (expression.match(first_char) == true) return first_char
else return "#";
}
Keil made this part, its function is to display every Alphabet (A-Z) as it is and display every Non-Alphabet (0-9, symbols) as "#". This follows the same scheme most often applied in emulation related websites/ apps, it keeps things organized (e.g. much better suited for scrolling by next/ previous letter) and user knows exactly where an item could be found. I was using a very long/ blunt code before, listing every non-alphabet character. This code works beautifully, thanks Keil :D and welcome back.
local indicator_text = fe.add_text( "[!first_letter]",22, 0, 40, 40);
indicator_text.font="BebasNeue Book.ttf";
indicator_text.set_rgb(193,9,16);
indicator_text.style = Style.Bold;
indicator_text.align = Align.MiddleCentre;
indicator_text.charsize = 38;
This displays the first character of title on Indicator_position (circle), we get the "[!first_letter]" from Keil's reg expression code, rest is simple text manipulation.
function on_indextransition( ttype, var, ttime )
{
indicator_graph.height = (indicator_bar.height)/(fe.list.size) * (fe.list.index+1)
indicator_position.y = (indicator_bar.height - 34)/(fe.list.size) * (fe.list.index+1) + 176
indicator_text.y = (indicator_bar.height - 34)/(fe.list.size) * (fe.list.index+1) + 176
}
fe.add_transition_callback( this, "on_indextransition" )
This is the main code which adjusts indicator bar location, I have added (-34) and ( +176) to get a desired result but its a temporary fix.
-
Woke up early. Ran extension cords. Zip tied cables. iMac is a go.
Created a test layout and started a new progress module. Revised the issues with my firstLetter function. Sorry, iPhone coding isn’t easy. Also created a function to create percentage of progression through a list.
I think I am going to create two classes: progress bar and indicating characters. Will do a little more work creating the classes and then to be continued on next day off.
-
This is all good if your list is always sorted by name. If you have filters sorted by different criteria it gets tricky really fast. The magic token [OrderValue] can't be retrieved through fe.game_info, so one has to tweak the "first letter" function to keep track of this, and for years sorting an entirely new list should be used with years and not letters.
-
This is my code contribution.
There's a "gameletter" function that acts differently if the list is sorted by name or manufacturer (returns the first letter), by category (returns the main category) or by year (returns the decade in the form 198x).
There is a routine in the on_transition section that, when transitioning to a new list, dynamically builds a table of "sort items" that are letters or years or categories according to the sort order, and changes it every time so the list is always consistent with the sort order. A small tweak can be done to space each "section" proportionally to the number of games in that slot but if there are few games then the category name will not fit, so I let it out
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local x0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,x0,flh*0.5,flw/tableorder.len(),50)
key_obj.charsize = 50
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
x0 = x0 + flw/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
-
This is all good if your list is always sorted by name. If you have filters sorted by different criteria it gets tricky really fast. The magic token [OrderValue] can't be retrieved through fe.game_info, so one has to tweak the "first letter" function to keep track of this, and for years sorting an entirely new list should be used with years and not letters.
[SortName] works if we use it to get text directly but can't get in through game info.
-
This is all good if your list is always sorted by name. If you have filters sorted by different criteria it gets tricky really fast. The magic token [OrderValue] can't be retrieved through fe.game_info, so one has to tweak the "first letter" function to keep track of this, and for years sorting an entirely new list should be used with years and not letters.
[SortName] works if we use it to get text directly but can't get in through game info.
Yes, [SortName] from what I get from the tutorials should give the field that is used to sort the list, like the "sort_by" attribute in the list. I don't know why it is in the magic token :D What I meant was [SortValue] (OrderValue is a typo) which again is not through game_info
-
Here is the code I pilfered from MarkC74's "The Invaders" theme... modified a bit...
// Progress Bar
if ( my_config["progress"] == "On" )
{
fe.add_image( "images/bar_h.png", flx*0.30, fly*0.595, flw*0.40, flh*0.070 );
local list_inc = fly*0.393 / (fe.list.size-1);
local current_pos = flx*0.100 + (fe.list.index * list_inc);
local list_pos_image = fe.add_image( "images/circle.png", current_pos, fly*0.603, flw*0.032, flh*0.055 );
local list_label = fe.add_text( "[Title]",current_pos, fly*0.595, flw*0.0375, flh*0.060);
list_label.font="captain"
colors( list_label, my_config["list_color"], 0 );
function progress_bar( ttype, var, ttime )
{
current_pos = flx*0.358 + (fe.list.index*list_inc);
list_pos_image.x = current_pos+2;
list_label.x = current_pos;
return false;
}
fe.add_transition_callback( "progress_bar" );
}
Here is the result...
https://youtu.be/xR1Mh8IGQKo (https://youtu.be/xR1Mh8IGQKo)
Not a great demo... but the slider at the bottom does work (there are over 1000 roms so it doesn't move much in the demo)...
-
Playing with my own code...
-
somthing going to give,,,,,nice work
here is code for my theme and results...
###################################################################################################
# progress bar
local back = fe.add_image( "artwork/white.png", flx*0.180, fly*0.992, flw*0.620, flh*0.003 );
back.set_rgb (255,255,255);
back.alpha = 40;
local front = fe.add_image( "artwork/white.png", flx*0.180, fly*0.992, flw*0.620, flh*0.002 );
front.set_rgb (0,255,0);
front.alpha = 200;
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
front.width = (back.width)/(fe.list.size) * (fe.list.index+1)
}
local list_inc = fly*0.965 / (fe.list.size-1);
local current_pos = flx*0.100 + (fe.list.index * list_inc);
local list_pos_image = fe.add_image( "", current_pos, fly*0.968, flw*0.010, flh*0.021);
local list_label = fe.add_text( "[Title]",current_pos, fly*0.936, flw*0.0215, flh*0.050);
list_label.charsize = 36;
list_label.font="TRAJANUS"
list_label.set_rgb (0,255,0);
list_label.alpha = 190
//l.align = Align.Left;
function progress_bar( ttype, var, ttime ){
current_pos = flx*0.179 + (fe.list.index*list_inc);
list_pos_image.x = current_pos+2;
list_label.x = current_pos;
return false;
}
fe.add_transition_callback( "progress_bar" );
####################################################################################################
results....preview: https://youtu.be/lg1gA9azSRs (https://youtu.be/lg1gA9azSRs)
-
@t zpaolo11x
thank you just had time to use your code,,,,,it is bad ass ...thanks you
now i soon can release the aura4k like i have wanted to, with this style bar... :)
-
thank you just had time to use your code,,,,,it is bad ass ...thanks you
That's great! In the meantime I'm coding my own flavors of progress bars inside my theme, but I think I'll post the update after Easter vacations :D
-
This is my code contribution.
There's a "gameletter" function that acts differently if the list is sorted by name or manufacturer (returns the first letter), by category (returns the main category) or by year (returns the decade in the form 198x).
There is a routine in the on_transition section that, when transitioning to a new list, dynamically builds a table of "sort items" that are letters or years or categories according to the sort order, and changes it every time so the list is always consistent with the sort order. A small tweak can be done to space each "section" proportionally to the number of games in that slot but if there are few games then the category name will not fit, so I let it out
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local x0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,x0,flh*0.5,flw/tableorder.len(),50)
key_obj.charsize = 50
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
x0 = x0 + flw/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
with this code I'm getting this error in layout, could anyone help?
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local x0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,x0,flh*0.5,flw/tableorder.len(),50)
key_obj.charsize = 50
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
x0 = x0 + flw/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
log:
Attract-Mode v2.6.0 (Windows, SFML 2.5.1 +SWF +7z +Curl)
avcodec 58.54.100 / avformat 58.29.100 / swscale 5.5.100 / avutil 56.31.100 / swresample 3.5.100
Config: D:\am\attract.cfg
*** Initializing display: 'Arcade'
- Loaded master romlist 'Arcade' in 179 ms (2665 entries kept, 0 discarded)
- Constructed 1 filters in 0 ms (2665 comparisons)
- Loaded layout: D:\am\layouts/Novo/ (layout.nut)
AN ERROR HAS OCCURED [null cannot be used as index]
CALLSTACK
*FUNCTION [on_transition()] D:\am\layouts/Novo/layout.nut line [667]
LOCALS
[keys] NULL
[flh] 1080
[flw] 1920
[err] "the index 'null' does not exist"
[s] NULL
[i] 0
[tableletter] TABLE
[tableorder] ARRAY
[ttime] 50
[var] 0
[ttype] 6
[this] TABLE
Script Error in transition function: on_transition - null cannot be used as index
- Constructed 1 filters in 0 ms (3 comparisons)
- Loaded layout: D:\am\layouts/Novo Menu/ (layout.nut)
*** Initializing display: 'Arcade'
- Loaded master romlist 'Arcade' in 72 ms (2665 entries kept, 0 discarded)
- Constructed 1 filters in 0 ms (2665 comparisons)
- Loaded layout: D:\am\layouts/Novo/ (layout.nut)
AN ERROR HAS OCCURED [null cannot be used as index]
CALLSTACK
*FUNCTION [on_transition()] D:\am\layouts/Novo/layout.nut line [667]
LOCALS
[keys] NULL
[flh] 1080
[flw] 1920
[err] "the index 'null' does not exist"
[s] NULL
[i] 0
[tableletter] TABLE
[tableorder] ARRAY
[ttime] 1
[var] 0
[ttype] 6
[this] TABLE
Script Error in transition function: on_transition - null cannot be used as index
! Unexpectedly lost focus to: None
! Unexpectedly lost focus to: SnippingTool.exe (7364)
! Unexpectedly lost focus to: SnippingTool.exe (7364)
- Constructed 1 filters in 0 ms (3 comparisons)
- Loaded layout: D:\am\layouts/Novo Menu/ (layout.nut)
-
ill add a working one, and send it to ya..tonight
-
ill add a working one, and send it to ya..tonight
jedione thanks !
enjoying your work
-
sent, test theme.... ;)
-
sent, test theme.... ;)
Ok, Jedione, thanks, but...
I've tried your aura4k coin-ops theme and the abc.nut layout gives exactly the same problem: If when changing filters or lists, there are no games, it gives the error of slice out of range and closes attract-mode. Logically, the code to get the first letter of the game is the same.
And with the statbar.nut layout, only one letter appears and then only the green line that changes size without any other letter.
Keil's code to get the first letter doesn't work either.
So we are the same as before.
-
Well, i have already solved it, it was much easier than it seemed.
You only have to give access to variable s2 if the name string --variable s-- is not empty.
-
This is my code contribution.
There's a "gameletter" function that acts differently if the list is sorted by name or manufacturer (returns the first letter), by category (returns the main category) or by year (returns the decade in the form 198x).
There is a routine in the on_transition section that, when transitioning to a new list, dynamically builds a table of "sort items" that are letters or years or categories according to the sort order, and changes it every time so the list is always consistent with the sort order. A small tweak can be done to space each "section" proportionally to the number of games in that slot but if there are few games then the category name will not fit, so I let it out
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local x0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,x0,flh*0.5,flw/tableorder.len(),50)
key_obj.charsize = 50
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
x0 = x0 + flw/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
zpaolo11x,
If it is not too much to ask, would it be possible to put it on display in a vertical position?
-
zpaolo11x,
If it is not too much to ask, would it be possible to put it on display in a vertical position?
I'm also interested. ;D
-
You mean you want the same sort of layout, but with the bar in vertical? I see if I can come up with a revised layout...
-
Just a few changes allow to place the letter strip in vertical, although there are still some issues in this old code related to games with "The" or "Vs." in the name...
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local y0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,0,y0,50,flh/tableorder.len())
key_obj.charsize = 25
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
y0 = y0 + flh/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
-
Just a few changes allow to place the letter strip in vertical, although there are still some issues in this old code related to games with "The" or "Vs." in the name...
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local y0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,0,y0,50,flh/tableorder.len())
key_obj.charsize = 25
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
y0 = y0 + flh/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
Thank you!
-
Just a few changes allow to place the letter strip in vertical, although there are still some issues in this old code related to games with "The" or "Vs." in the name...
function gameletter( offset ) {
if (fe.filters.len() > 0){
if (fe.filters[fe.list.filter_index].sort_by == Info.Year){
local s = fe.game_info( Info.Year, offset )
s = s.slice (0,3)+"x"
return s
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Manufacturer){
local s = fe.game_info( Info.Manufacturer, offset )
return s.slice(0,1)
}
else if (fe.filters[fe.list.filter_index].sort_by == Info.Category){
local s = fe.game_info( Info.Category, offset )
if (s == "") return "?"
s = split( s, "/" )
return strip(s[0])
}
else {
local s = fe.game_info( Info.Title, offset )
if (s.find("The ") == 0) s = s.slice(4,s.len())
local s2 = s.slice(0,1)
if ("1234567890".find (s2) != null ){
s2="#"
}
return s2
}
}
}
local flw = fe.layout.width
local flh = fe.layout.height
local gamename = fe.add_text("[Title]\n[SortValue]",0,0,flw,flh/10)
gamename.charsize = gamename.height*0.25
local accent = fe.add_text ("[!gameletter]",0,flh*0.5,flw,flh*0.25)
accent.charsize = flh*0.25
local keys = null
fe.add_transition_callback( this, "on_transition" )
function on_transition( ttype, var, ttime ) {
if (ttype == Transition.ToNewSelection){
local l1 = gameletter(0)
local l2 = gameletter(var)
if (l1 != l2){
keys [l1].alpha = 128
keys [l2].alpha = 255
}
}
if (ttype == Transition.ToNewList){
local tableorder = []
local tableletter = {}
for (local i = 0 ; i < fe.list.size ; i++){
local s = (gameletter (i-fe.list.index))
try { tableletter[s]++ }
catch (err) {
tableletter[s] <- 1
tableorder.push (s)
}
}
keys = {}
local i = 0
local y0 = 0
foreach (key in tableorder){
local key_obj = fe.add_text(key,0,y0,50,flh/tableorder.len())
key_obj.charsize = 25
key_obj.alpha = ((tableletter[key] > 0) ? 128 : 0)
key_obj.set_bg_rgb (100+50*(i%2),100+50*(i%2),100+50*(i%2))
i++
y0 = y0 + flh/tableorder.len()
keys[key] <- key_obj
}
keys [gameletter(0)].alpha = 255
}
}
THX!!!! ;D
-
thanks zpaolo11x for your code i need helpppppp, i tweak a bit to take off de backgorund of the letters,,, now when i change filters the entyre list of letters are duplicated, how can I delete the old ones so that it shows only the last list?, thnak youooo
-
You mean you want the same sort of layout, but with the bar in vertical? https://www.rcl-group.com/ (https://www.rcl-group.com/) I see if I can come up with a revised layout...https://www.shopsy.si/Blog/mini_blagajna_na_telefonu/ (https://www.shopsy.si/Blog/mini_blagajna_na_telefonu/)
I'll see what I can do to revise the layout for you.