-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathButtonClass.gd
67 lines (61 loc) · 1.99 KB
/
ButtonClass.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
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
class_name ButtonClass extends Node
@export var cursor : CursorManager
@export var alias : String
@export var isActive : bool
@export var isDynamic : bool
@export var ui : CanvasItem
@export var ui_control : Control
@export var speaker_press : AudioStreamPlayer2D
@export var speaker_hover : AudioStreamPlayer2D
@export var rebind : Node
@export var language : bool
@export var options : OptionsManager
@export var rebindManager : Rebinding
@export var playing : bool
@export var altsound : bool
@export var ui_opacity_inactive : float = 1
@export var ui_opacity_active : float = .78
@export var resetting : bool
@export var pipe : LobbyManager
@export var adding_cursor : bool
@export var t : Label
var mainActive = true
var orig
func _ready():
if (adding_cursor): orig = t.text
ui_control = get_parent()
get_parent().connect("focus_entered", OnHover)
get_parent().connect("focus_exited", OnExit)
get_parent().connect("mouse_entered", OnHover)
get_parent().connect("mouse_exited", OnExit)
get_parent().connect("pressed", OnPress)
if (isDynamic): ui.modulate.a = ui_opacity_inactive
func SetFilter(alias : String):
match(alias):
"ignore":
ui_control.mouse_filter = Control.MOUSE_FILTER_IGNORE
"stop":
ui_control.mouse_filter = Control.MOUSE_FILTER_STOP
func OnHover():
if (isActive && mainActive):
if (isDynamic):
speaker_hover.pitch_scale = randf_range(.95, 1.0)
speaker_hover.play()
ui.modulate.a = ui_opacity_active
cursor.SetCursorImage("hover")
if (adding_cursor): t.text = "< " + tr(orig) + " >"
func OnExit():
if (isActive && mainActive):
if (isDynamic):
ui.modulate.a = ui_opacity_inactive
cursor.SetCursorImage("point")
if (adding_cursor): t.text = tr(orig)
signal is_pressed
func OnPress():
if (isActive && mainActive):
if (altsound): speaker_press.play()
if (isDynamic && playing): speaker_press.play()
if (rebind != null): rebindManager.GetRebind(rebind)
if (language): options.AdjustLanguage(alias)
if (pipe != null): pipe.Pipe(alias)
emit_signal("is_pressed")