Attract-Mode Support Forum
Attract-Mode Support => Scripting => Topic started by: cools on July 28, 2014, 12:54:07 PM
-
Trying to build a simple list routine so I can alter the selected game height.
Only lists the first 9 games. Using up/down changes the preview image appropriately but the list doesn't change.
// Layout by cools / Arcade Otaku
// Layout User Options
class UserConfig {
</ label="Preview Image", help="Choose snap/video snap, title, flyer or none.", options="snap,video,title,flyer,none" /> preview_image = "snap";
}
local my_config = fe.get_config();
// Layout Constants
// Font found on 9031.com
fe.layout.font="Arcade-Regular"
local rot=(fe.layout.base_rotation+fe.layout.toggle_rotation)%4;
local flw=fe.layout.width;
local flh=fe.layout.height;
switch (rot) {
case RotateScreen.Right:
case RotateScreen.Left:
fe.layout.width=flh;
fe.layout.height=flw;
flw=fe.layout.width;
flh=fe.layout.height;
break;
}
// Preview image
local preview=fe.add_artwork (my_config["preview_image"],0,0,flw,flh/3);
// List
local lbx=0;
local lby=flh/3;
local lbw=flw;
local lbh=flh-lby;
local itn=9;
local ith=lbh/itn;
lby+=(ith*(itn/2));
for (local i=(itn/2)*-1;i<(itn/2);i+=1){
if (i==0) {
fe.add_text(fe.game_info (Info.Title),lbx,lby+(ith*i)-5,lbw,ith+10);
}
else {
fe.add_text(fe.game_info (Info.Title,i),lbx,lby+(ith*i),lbw,ith);
}
}
Actually, just doing this doesn't work as I'd expect:
fe.add_text(fe.game_info (Info.Title),0,0,fe.layout.width,fe.layout.height/25);
Even throwing the latter part alone into a "local game=" statement fails for it to update.
-
Trying to build a simple list routine so I can alter the selected game height.
Only lists the first 9 games. Using up/down changes the preview image appropriately but the list doesn't change.
// Layout by cools / Arcade Otaku
// Layout User Options
class UserConfig {
</ label="Preview Image", help="Choose snap/video snap, title, flyer or none.", options="snap,video,title,flyer,none" /> preview_image = "snap";
}
local my_config = fe.get_config();
// Layout Constants
// Font found on 9031.com
fe.layout.font="Arcade-Regular"
local rot=(fe.layout.base_rotation+fe.layout.toggle_rotation)%4;
local flw=fe.layout.width;
local flh=fe.layout.height;
switch (rot) {
case RotateScreen.Right:
case RotateScreen.Left:
fe.layout.width=flh;
fe.layout.height=flw;
flw=fe.layout.width;
flh=fe.layout.height;
break;
}
// Preview image
local preview=fe.add_artwork (my_config["preview_image"],0,0,flw,flh/3);
// List
local lbx=0;
local lby=flh/3;
local lbw=flw;
local lbh=flh-lby;
local itn=9;
local ith=lbh/itn;
lby+=(ith*(itn/2));
for (local i=(itn/2)*-1;i<(itn/2);i+=1){
if (i==0) {
fe.add_text(fe.game_info (Info.Title),lbx,lby+(ith*i)-5,lbw,ith+10);
}
else {
fe.add_text(fe.game_info (Info.Title,i),lbx,lby+(ith*i),lbw,ith);
}
}
Actually, just doing this doesn't work as I'd expect:
fe.add_text(fe.game_info (Info.Title),0,0,fe.layout.width,fe.layout.height/25);
Even throwing the latter part alone into a "local game=" statement fails for it to update.
Try replacing:
fe.add_text(fe.game_info (Info.Title),0,0,fe.layout.width,fe.layout.height/25);
with:
local temp = fe.add_text("[Title]",0,0,fe.layout.width,fe.layout.height/25);
temp.index_offset = i;
in both the places where you have it. I think that should work.
The fe.game_info() command is only really useful when it is called from a tick or a transition function. The frontend doesn't actually know what the current game is when the layout script itself is run (it only knows that later on when transitions and ticks occur)....
-
That works perfectly, thanks!
-
Result below. The list should be transplantable into any other layout ;)
// Layout by cools / Arcade Otaku
// Layout User Options
class UserConfig {
</ label="Preview Image", help="Choose snap/video snap, title, flyer or none.", options="snap,video,title,flyer,none" /> preview_image = "snap";
}
local my_config = fe.get_config();
// Layout Constants
// Font found on 9031.com
fe.layout.font="Arcade-Regular"
local rot=(fe.layout.base_rotation+fe.layout.toggle_rotation)%4;
local flw=fe.layout.width;
local flh=fe.layout.height;
switch (rot) {
case RotateScreen.Right:
case RotateScreen.Left:
fe.layout.width=flh;
fe.layout.height=flw;
flw=fe.layout.width;
flh=fe.layout.height;
break;
}
// Preview image
local preview=fe.add_artwork(my_config["preview_image"],(flw/2)-((flw/4)/2),flh*0.05,flw/4,flh/3);
// List
local lbx=flw*0.125; // Listbox X position
local lby=(flh/3)*1.2; // Listbox Y position
local lbw=flw*0.75; // Listbox width
local lbh=(flh-lby)*0.9; // Listbox height
local itn=15; // Listbox entries
local ith=lbh/itn; // Listbox entry height
lby+=(ith*(itn/2)); // Listbox draw point - do not change
local lbr=255; // Listbox red
local lbg=255; // Listbox green
local lbb=128; // Listbox blue
local lbf=0.8; // Listbox colour fade. Lower values = less fade.
for (local i=(itn/2)*-1;i<=(itn/2);i+=1){
if (i==0) {
local selgame=fe.add_text("[Title]",lbx,lby-((ith*1.3)/4),lbw,ith*1.3);
selgame.set_rgb(lbr,lbg,lbb);
}
else {
local unselgame=fe.add_text("[Title]",lbx,lby+(ith*i),lbw,ith*0.7);
unselgame.index_offset=i;
unselgame.set_rgb(lbr,lbg,lbb);
if (i<0) {unselgame.alpha=255-((i*(255/(itn/2))*-1)*lbf);}
else {unselgame.alpha=255-(i*(255/(itn/2))*lbf);}
// Fades colour rather than alpha
//if (i<0) {unselgame.set_rgb( lbr-((i*(lbr/(itn/2))*-1)*lbf) , lbg-((i*(lbg/(itn/2))*-1)*lbf) , lbb-((i*(lbb/(itn/2))*-1)*lbf) );}
//else {unselgame.set_rgb( lbr-(i*(lbr/(itn/2))*lbf) , lbg-(i*(lbg/(itn/2))*lbf) , lbb-(i*(lbb/(itn/2))*lbf) );}
}
}