2022-08-04 18:05:48 -06:00
|
|
|
extends Node2D
|
|
|
|
|
2022-08-05 17:15:17 -06:00
|
|
|
class_name GUI
|
|
|
|
|
|
|
|
signal toggle_music(music_off)
|
2022-08-08 15:32:57 -06:00
|
|
|
signal toggle_pause(paused)
|
2022-08-05 17:15:17 -06:00
|
|
|
|
2022-08-04 18:05:48 -06:00
|
|
|
onready var time_label := $MarginContainer/HBoxContainer/TimeLabel
|
2022-08-05 17:15:17 -06:00
|
|
|
onready var neighbor_label := $MarginContainer/HBoxContainer/NeighborLabel
|
2022-08-04 18:05:48 -06:00
|
|
|
onready var game_timer := $GameTimer
|
2022-08-08 15:32:57 -06:00
|
|
|
onready var music_button := $MarginContainer/HBoxContainer/GridContainer/MusicButton
|
2022-08-05 17:15:17 -06:00
|
|
|
onready var pause_button := $MarginContainer/HBoxContainer/GridContainer/PauseButton
|
|
|
|
|
|
|
|
var arrow = preload("res://assets/ui/pointer.png")
|
|
|
|
var hand = preload("res://assets/ui/pointer_hand.png")
|
|
|
|
#var music_enabled_texture = preload("res://assets/ui/music-enabled.png")
|
|
|
|
#var music_disabled_texture = preload("res://assets/ui/music-disabled.png")
|
|
|
|
#var pause_texture = preload("res://assets/ui/pause.png")
|
|
|
|
#var play_texture = preload("res://assets/ui/play.png")
|
2022-08-04 18:05:48 -06:00
|
|
|
|
|
|
|
func start_timer(seconds: int) -> void:
|
|
|
|
game_timer.start(seconds)
|
|
|
|
|
2022-08-05 17:15:17 -06:00
|
|
|
func set_neighbor_count(neighbors_left: int) -> void:
|
|
|
|
neighbor_label.text = "Neighbors left: %s" % neighbors_left
|
|
|
|
|
|
|
|
func set_game_label(content: String) -> void:
|
|
|
|
neighbor_label.text = content
|
|
|
|
|
2022-08-04 18:05:48 -06:00
|
|
|
func _ready() -> void:
|
2022-08-05 17:15:17 -06:00
|
|
|
Input.set_custom_mouse_cursor(arrow)
|
|
|
|
# Input.set_custom_mouse_cursor(beam, Input.CURSOR_IBEAM)
|
|
|
|
# start_timer(60)
|
2022-08-04 18:05:48 -06:00
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
var time = int(game_timer.get_time_left())
|
2022-08-05 17:15:17 -06:00
|
|
|
time_label.text = "Time: %s" % time
|
|
|
|
|
|
|
|
func _on_PauseButton_toggled(button_pressed: bool) -> void:
|
2022-08-08 15:32:57 -06:00
|
|
|
game_timer.set_paused(button_pressed)
|
|
|
|
emit_signal("toggle_pause", button_pressed)
|
2022-08-05 17:15:17 -06:00
|
|
|
|
|
|
|
func _on_MusicButton_toggled(button_pressed: bool) -> void:
|
2022-08-08 15:32:57 -06:00
|
|
|
get_tree().call_group("plays_audio", "_set_audio", button_pressed)
|
|
|
|
emit_signal("toggle_music", button_pressed)
|
2022-08-05 17:15:17 -06:00
|
|
|
|
|
|
|
func _on_mouse_entered() -> void:
|
|
|
|
Input.set_custom_mouse_cursor(hand)
|
|
|
|
|
|
|
|
func _on_mouse_exited() -> void:
|
|
|
|
Input.set_custom_mouse_cursor(arrow)
|
2022-08-04 18:05:48 -06:00
|
|
|
|
|
|
|
|
2022-08-05 17:15:17 -06:00
|
|
|
func _on_GameTimer_timeout() -> void:
|
|
|
|
pass # Replace with function body.
|