TinyAdventure/game_ui.gd

46 lines
1.1 KiB
GDScript

extends Control
@onready var tool_slots = %ToolSlots
@onready var game_menu_ui = %GameMenuUI
var game_scene:Node3D
func _on_message_timer_timeout():
%MessagesContainer.visible = false
func _on_player_trigger_message(message):
%MessagesContainer/MessageTextEdit.text = message
%MessagesContainer/MessageTimer.start(1)
%MessagesContainer.visible = true
print(message)
func _unhandled_key_input(event:InputEvent):
var key_event:InputEventKey = event as InputEventKey
if key_event and key_event.pressed and key_event.get_keycode_with_modifiers() == KEY_ESCAPE:
if %GameMenuUI.visible:
%GameMenuUI.hide()
else:
%GameMenuUI.show()
func _on_game_menu_ui_visibility_changed():
# Function gets triggered when scene is still in construction. In that
# case just return.
if tool_slots == null or game_scene == null:
return
if %GameMenuUI.visible:
tool_slots.hide()
game_scene.process_mode = Node.PROCESS_MODE_DISABLED
else:
tool_slots.show()
game_scene.process_mode = Node.PROCESS_MODE_INHERIT
func _on_back_to_game_button_pressed():
%GameMenuUI.hide()