forked from SamuelWolfang/UNDOTALE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
List.gd
35 lines (25 loc) · 782 Bytes
/
List.gd
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
class_name List
extends Node2D
var list = []
var selection = 0
var input = Vector2.ZERO
var enable = false
var list_increase = Vector2.ZERO
signal select
signal exit
func enable():
connect("select", self, "select")
enable = true
func _process(delta):
if enable:
input.x = (int(Input.is_action_just_pressed("ui_right")) - int(Input.is_action_just_pressed("ui_left"))) * list_increase.x
input.y = (int(Input.is_action_just_pressed("ui_down")) - int(Input.is_action_just_pressed("ui_up"))) * list_increase.y
selection = int(selection + input.x + input.y) % list.size()
if Input.is_action_just_pressed("ui_accept"):
emit_signal("select")
disable()
func disable():
disconnect("select", self, "select")
enable = false
func select():
return list[selection]