-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionBox.gd
More file actions
76 lines (63 loc) · 1.78 KB
/
ActionBox.gd
File metadata and controls
76 lines (63 loc) · 1.78 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
extends Area2D
var ID
const DEADTIME_UPON_SHOWING = .3
var deadtime
signal button1
signal button2
signal cancel
signal reset_focus
var option
var option_offset_for_this_ID
func _ready():
var screensize = get_viewport().size
position = Vector2(screensize.x/2, screensize.y/2)
hide()
option = 0
option_offset_for_this_ID = 0
deadtime = 0
func _process(delta):
var mousePos = get_viewport().get_mouse_position()
var mouseRel = mousePos - position
if mouseRel.y > 165 - 200 and mouseRel.y < 345 - 200:
if mouseRel.x > 200 - 480 and mouseRel.x < 380 - 480:
option = 1
elif mouseRel.x > 440 - 480 and mouseRel.x < 620 - 480:
option = 2
elif mouseRel.x > 680 - 480 and mouseRel.x < 860 - 480:
option = 3
else:
option = 0
else:
option = 0
$AnimatedSprite.set_frame(option_offset_for_this_ID + option)
if Input.is_mouse_button_pressed(BUTTON_LEFT) and visible and option > 0 and deadtime == 0:
hide()
emit_signal("reset_focus")
if option == 1:
emit_signal("button1", ID)
elif option == 2:
emit_signal("button2", ID)
elif option == 3:
emit_signal("cancel")
deadtime = max(deadtime - delta, 0)
func _on_ExclHome_exclamation_clicked(cID):
ID = "Home"
option_offset_for_this_ID = 0
var screensize = get_viewport().size
position = Vector2(screensize.x/2, screensize.y/2)
deadtime = DEADTIME_UPON_SHOWING
show()
func _on_ExclWork_exclamation_clicked(cID):
ID = "Work"
option_offset_for_this_ID = 8
var screensize = get_viewport().size
position = Vector2(screensize.x/2, screensize.y/2)
deadtime = DEADTIME_UPON_SHOWING
show()
func _on_ExclStore_exclamation_clicked(cID):
ID = "Store"
option_offset_for_this_ID = 4
var screensize = get_viewport().size
position = Vector2(screensize.x/2, screensize.y/2)
deadtime = DEADTIME_UPON_SHOWING
show()