Author Topic: Progress Bar  (Read 2634 times)

Giacomo1982

  • Full Member
  • ***
  • Posts: 89
    • View Profile
Progress Bar
« on: April 20, 2018, 03:22:04 PM »
Hi coders! I want to put in my new theme a simple rectangular progress bar, with [ListEntry] as a variable of width, I try this but doesn't work

local progress = [ListEntry]*0.01;
local bar = fe.add_image("white.png", flx*0.10, fly*0.05, progress, flh*0.05);


Please help me

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Progress Bar
« Reply #1 on: April 20, 2018, 07:08:35 PM »
Magic Tokens can only be used by certain default functions provided my attract.

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

I don’t think your formula is correct anyways. You can give your object a default width, divide it by the list size, and multiply it by the index. Reassign object width.

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

Giacomo1982

  • Full Member
  • ***
  • Posts: 89
    • View Profile
Re: Progress Bar
« Reply #2 on: April 20, 2018, 11:49:43 PM »
Thanks for the fast reply keilmillerjr, but I'm not a coder, could you correct this line? Thanks

local width = (1.00 / fe.list.size) * fe.list.index;
local bar = fe.add_image("white.png", flx*0.10, fly*0.05, flw*progress, flh*0.05);

Giacomo1982

  • Full Member
  • ***
  • Posts: 89
    • View Profile
Re: Progress Bar
« Reply #3 on: April 22, 2018, 11:01:48 PM »
It work only the first time when open new list, but when I change game it doesn't change... :(

It could be usefull if someone help me

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Progress Bar
« Reply #4 on: April 23, 2018, 03:14:44 AM »
It work only the first time when open new list, but when I change game it doesn't change... :(

It could be usefull if someone help me

Sorry, I have been super exhausted from work lately and cant provide lots of help, and generally only have time to point people in the right direction. I did like 85 hours in 5 days. Took weekend off for time with wife and kids.

You need to use a transition to update the width of your progress bar.

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

Something similar to this. You might have to play with it. I have to go to work.
Code: [Select]
fe.add_transition_callback(list_progress);
function transition(ttype, var, transition_time) {
switch(ttype) {
case Transition.ToNewSelection:
// insert code here
break;
}
return false;
}