extends Node ## This singleton sits in the middle allowing multiple game areas to call and # manipulate the UI enum UI_PANES {OFF, HUD, DIALOG} var dialog_text = 'foo' var dialog_portrait = preload("res://icon.png") var current_pane = UI_PANES.OFF var debug_text :String var _dialog_item :DialogItem var playing_dialog :bool = false var current_dialog_index :int signal ui_change() # Declare member variables here. Examples: # var a = 2 # var b = "text" # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. func play_dialog_item(dialog_item :DialogItem, dialog_index :int = 0): _dialog_item = dialog_item if _dialog_item.text_lines.size() > 0: current_dialog_index = dialog_index playing_dialog = true dialog_text = _dialog_item.text_lines[current_dialog_index] dialog_portrait = _dialog_item.portrait current_pane = UI_PANES.DIALOG emit_signal("ui_change") func stop_dialog(): dialog_text = 'foo' current_pane = UI_PANES.HUD emit_signal("ui_change") # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if playing_dialog: var foo = '' ##TODO: Lockout input on player before dialog happens. if Input.is_action_just_pressed("crouch_1"): if _dialog_item.text_lines.size() > (current_dialog_index + 1): current_dialog_index += 1 dialog_text = _dialog_item.text_lines[current_dialog_index] dialog_portrait = _dialog_item.portrait emit_signal("ui_change") else: stop_dialog()