61 lines
1.8 KiB
GDScript3
61 lines
1.8 KiB
GDScript3
class_name UIComponent
|
|
extends CanvasLayer
|
|
|
|
|
|
# Declare member variables here. Examples:
|
|
# var a = 2
|
|
# var b = "text"
|
|
|
|
onready var DialogContainer = $PanelContainer
|
|
|
|
onready var DialogContainerPortrait = $PanelContainer/HSplitContainer/TextureRect
|
|
|
|
onready var DialogContainerText = $PanelContainer/HSplitContainer/Label
|
|
|
|
onready var DialogIndicator = $PanelContainer/Polygon2D
|
|
|
|
onready var HUD = $HealthBar
|
|
|
|
var current_pane
|
|
|
|
var tween
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
# How to change to a differant portrait picture.
|
|
#DialogContainerPortrait.texture = UiManager.dialog_portrait
|
|
#DialogContainerText.text = UiManager.dialog_text
|
|
UiManager.current_pane = UiManager.UI_PANES.HUD
|
|
#DialogContainer.visible = false
|
|
tween = get_tree().create_tween().set_loops()
|
|
tween.tween_property(DialogIndicator, "modulate", Color.darkgray, 1)
|
|
tween.tween_property(DialogIndicator, "modulate", Color.white , 1)
|
|
##tween.tween_property(DialogIndicator, "modulate", Color.RED, 1)
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta):
|
|
|
|
if (UiManager.current_pane != current_pane):
|
|
print("UI Switch detected")
|
|
current_pane = UiManager.current_pane
|
|
DialogContainer.visible = false
|
|
HUD.visible = false
|
|
match current_pane:
|
|
UiManager.UI_PANES.HUD:
|
|
print("Enable HUD")
|
|
HUD.visible = true
|
|
UiManager.UI_PANES.DIALOG:
|
|
print("Enable Dialog")
|
|
DialogContainerPortrait.texture = UiManager.dialog_portrait
|
|
DialogContainerText.text = UiManager.dialog_text
|
|
DialogContainer.visible = true
|
|
#get_tree().paused = true
|
|
_: # Implicitly off
|
|
print("UI Turned off")
|
|
|
|
|
|
func _unhandled_input(event):
|
|
if current_pane == UiManager.UI_PANES.DIALOG and Input.is_action_just_pressed("ui_accept"):
|
|
UiManager.current_pane = UiManager.UI_PANES.HUD
|
|
#get_tree().paused = false
|