-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTitle.gd
More file actions
62 lines (49 loc) · 1.8 KB
/
Title.gd
File metadata and controls
62 lines (49 loc) · 1.8 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
extends Node2D
signal done
signal enter_debug
const LeftClick = preload("res://Util/LeftClick.gd")
var sticky_spec = {
type = preload("res://Modules/StickyNote.tscn"),
message = "password123"
}
var password = "password123"
var child
func _ready():
Music.play("level1")
$StickyNote.connect("input_event", self, "on_sticky_input_event")
$StickyNote.connect("mouse_entered", self, "on_sticky_mouse_entered")
$StickyNote.connect("mouse_exited", self, "on_sticky_mouse_exited")
$LineEdit.connect("text_entered", self, "on_text_entered")
$LineEdit.connect("text_changed", self, "on_text_changed")
func on_sticky_mouse_entered():
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
func on_sticky_mouse_exited():
Input.set_default_cursor_shape(Input.CURSOR_ARROW)
func on_sticky_input_event(_camera, event, _click_pos):
if LeftClick.is_left_click(event):
child = sticky_spec.type.instance()
child.connect("ready", self, "on_child_ready", [sticky_spec])
add_child(child)
func on_child_ready(spec):
child.connect("close", self, "on_child_close", [spec])
child.initialize(spec)
func on_child_close(_spec):
remove_child(child)
child.queue_free()
child = null
func on_text_changed(_text):
$LineEdit.add_color_override("font_color", Color.black)
func on_text_entered(text):
if text.to_lower() == password.to_lower():
print("done title")
emit_signal("done")
elif text.to_lower() == "admin_debug":
emit_signal("enter_debug")
else:
$LineEdit.add_color_override("font_color", Color.red)
yield(get_tree().create_timer(0.1), "timeout")
$LineEdit.add_color_override("font_color", Color.black)
yield(get_tree().create_timer(0.1), "timeout")
$LineEdit.add_color_override("font_color", Color.red)
yield(get_tree().create_timer(0.1), "timeout")
$LineEdit.add_color_override("font_color", Color.black)