forked from Zinal001/awesome-sprak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Convenient Menues.txt
67 lines (58 loc) · 1.7 KB
/
Convenient Menues.txt
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
60
61
62
63
64
65
66
67
# HandleList(lst)
# Displays a list of items that the user can choose from
#
# Param {Array} lst - The list of items to choose from
#
# Depends on LoadScreenSize(), CenterText() and [WaitForKeyPress()](./Input.txt)
#
# Author Zinal
# Return {String} - Returns the selected item
String HandleList(lst)
ClearText()
DisplayGraphics()
Array ScreenSize = LoadScreenSize()
number hCenter = ScreenSize[1] / 2
number hSpan = hCenter - 6
number Index = 0
Index = Round(Count(lst) / 2)
loop
number listStart = Index - hSpan
number listEnd = Index + hSpan
if(listStart < 0)
listStart = 0
end
if(listEnd >= Count(lst))
listEnd = Count(lst) - 1
end
number y = hCenter - hSpan
ClearText()
Color(0, 0, 0)
Rect(0, 0, Width(), Height() + 1)
Color(0, 255, 0)
loop I from listStart to listEnd
if(HasIndex(lst, I))
if(I == Index)
Color(255, 255, 255)
else
Color(0, 255, 0)
end
CenterText(lst[I], y)
y++
end
end
DisplayGraphics()
loop
Sleep(0.3)
String keyDown = WaitForKeyPress(["up", "down", "space"])
if(keyDown == "up" && Index > 0)
Index--
break
else if(keyDown == "down" && Index < Count(lst) - 1)
Index++
break
else if(keyDown == "space")
return lst[Index]
end
end
end
end