ASCII art for torrent UI
Perl 5, 130 bytes
print$e=("+"."-"x10)x3 ."+
";printf"|$_.exe%4s |%-10s|%-9s |
$e",$|--&&$@++<9?("$@0%","#"x$@,leeching):("","#"x10,seeding)for a..z
Try it online!
I expect that there are a few bytes that can be golfed, but I've ran out of inspiration.
Short explanations:
$e
contains the separation line (+----------+----------+----------+
); its construction is straight forward (("+"."-"x10)x3 ."+\n"
).
Then, I loop over the characters from a
to z
:
Every time, print "|$_.exe%4s |%-10s|%-9s |\n$e
; this is a standard printf
with placeholders for strings (%s
) and left-padded strings (%-9s
).
if $|--&&$@++<9
is true ($|
is a special variable that contains either 0 or 1, and decrementing it toggles its value), then the percentage is not 100%, and the three values in the print are "$@0%","#"x$@,leeching
($@0%
is actually just $@ . "0" . "%"
- remember that $@
was incremented earlier), otherwise, the three values are "","#"x10,seeding
).
SOGL V0.12, 90 89 88 bytes
ēz{L┌* +3ΟQķ|;o".exe ”oēI»L*"% |”e» #*lLκ@*"┌5%8'Ω⅞█≡θ¹‘++++e'³>e2\+?X"⅓m÷Ko→∆)№(¤^▒«‘}o
Try it Here!
Explanation:
ē push variable E (default = input, which default is 0) and increase it after (next ē call will result in 1, or next e call - 2)
z{ iterate over the lowercase alphabet
L┌* push 10 dashes
+ push "+"
3Ο encase 3 copies of the dashes in pluses
Q output in a new line, without popping and without disabling auto-output
ķ| output in a new line "|"
;o output the current iteration (the alphabet letter)
".exe ”o output ".exe "
ē push E and increase the variable after
I increase it
5* multiply by 5 (every 2 ē calls this gets called)
"% |” push "% |"
e» push (E)/2
#* get that mant "#"s
l get the length of that string
Lκ push 10-length
@* push that many spaces
"..‘ push "|leeching |"
++++ add all those strings on the stack together ((e+1)*5, "% |", "#..#", " .. ", "|leeching |") (done this way to leave the "+-+-+-+" on the stack)
e'³> push e>19
e2\ push e divides by 2
+ add together (here works like OR)
? if that then
X remove the added-together string
"..‘ push " |##########|seeding |"
} END
o output POP (either the added string or full/seeding version)
implicitly output POP (since none of tTpP were called), which is the separator line
Python 2, 182 177 bytes
Thanks to @officialaimm for shaving off 5 bytes by changing the format of the condition.
r=("+"+10*"-")*3+"+"
for i in range(26):z=i/2+1;print r+"\n|"+chr(97+i)+".exe "+[" |"+10*"#"+"|seeding ",`10*z`+"% |"+z*"#"+(10-z)*" "+"|leeching"][i%2and i<19]+" |"
print r
Try it online!