-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.gd
67 lines (46 loc) · 1.35 KB
/
ui.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
extends CanvasLayer
signal start_game
signal reset_game
signal choice(yes: bool)
const MAXN = 32767
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
pass
func disp_message(s: String, line=0) -> void:
var cont = $Texts.get_children()[line]
cont.text = s
func change_number(num: int) -> void:
if num < 0:
$NumDisplay.text = ".".repeat(-num)
else:
$NumDisplay.text = str(num)
func get_backn() -> int:
return int($SetN/TextEdit.text)
func set_choice_buttons_visibility(b: bool) -> void:
$ButtonYes.visible = b
$ButtonNo.visible = b
func set_choice_buttons_availability(b: bool) -> void:
$ButtonYes.disabled = not b
$ButtonNo.disabled = not b
func _on_start_btn_pressed() -> void:
$StartBtn.hide()
$SetN/TextWhereN.hide()
$SetN/TextEdit.hide()
start_game.emit()
func _on_text_edit_text_changed() -> void:
var num = int($SetN/TextEdit.text)
if not num or num < 1:
num = 1
$SetN/TextEdit.text = str(num)
elif num > MAXN:
num = MAXN
$SetN/TextEdit.text = str(num)
func _on_button_go_back_pressed() -> void:
reset_game.emit()
func _on_button_yes_pressed() -> void:
choice.emit(true)
func _on_button_no_pressed() -> void:
choice.emit(false)