-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathui.py
More file actions
60 lines (41 loc) · 1.17 KB
/
ui.py
File metadata and controls
60 lines (41 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import colorama
def clear_screen():
return '\x1b[2J'
def clear_line():
return '\x1b[0J'
def pos(x, y):
return '\x1b[' + str(y) + ';' + str(x) + 'H'
"""Progress bar that is green when near 100 and red when near 0"""
def health_bar(value, maximum):
ret = colorama.Fore.WHITE + '['
percent = value * 100 // maximum
if (percent <= 50):
ret += colorama.Fore.RED
elif percent <= 80:
ret += colorama.Fore.YELLOW
else:
ret += colorama.Fore.GREEN
for n in range(5):
if percent // 20 >= n:
ret += '■'
else:
ret += ' '
ret += colorama.Fore.WHITE + ']'
return ret
"""Progress bar that is green when near 0 and red when near 100"""
def cargo_bar(value, maximum):
ret = colorama.Fore.WHITE + '['
percent = value * 100 // maximum
if (percent <= 50):
ret += colorama.Fore.GREEN
elif percent <= 80:
ret += colorama.Fore.YELLOW
else:
ret += colorama.Fore.RED
for n in range(5):
if percent // 20 >= n:
ret += '■'
else:
ret += ' '
ret += colorama.Fore.WHITE + ']'
return ret