Bug fixed, Dialog UI improvements.
This commit is contained in:
parent
25152de524
commit
6ed2e86806
|
|
@ -7,3 +7,4 @@
|
|||
script = ExtResource( 1 )
|
||||
portrait = ExtResource( 2 )
|
||||
text_lines = PoolStringArray( "Hey there. I heard you\'re Gangsta.", "Well I\'m pretty gangsta myself!" )
|
||||
chars_per_second = 30
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ var debug_text :String
|
|||
var _dialog_item :DialogItem
|
||||
|
||||
var playing_dialog :bool = false
|
||||
var playing_dialog_char_timer :float
|
||||
var current_dialog_index :int
|
||||
|
||||
signal ui_change()
|
||||
|
|
@ -32,7 +33,8 @@ func play_dialog_item(dialog_item :DialogItem, dialog_index :int = 0):
|
|||
if _dialog_item.text_lines.size() > 0:
|
||||
current_dialog_index = dialog_index
|
||||
playing_dialog = true
|
||||
dialog_text = _dialog_item.text_lines[current_dialog_index]
|
||||
playing_dialog_char_timer = 0.0
|
||||
dialog_text = '' #_dialog_item.text_lines[current_dialog_index]
|
||||
dialog_portrait = _dialog_item.portrait
|
||||
current_pane = UI_PANES.DIALOG
|
||||
emit_signal("ui_change")
|
||||
|
|
@ -40,20 +42,31 @@ func play_dialog_item(dialog_item :DialogItem, dialog_index :int = 0):
|
|||
|
||||
func stop_dialog():
|
||||
dialog_text = 'foo'
|
||||
#call_deferred("set", dialog_text, 'foo')
|
||||
current_pane = UI_PANES.HUD
|
||||
#call_deferred("set", current_pane, UI_PANES.HUD )
|
||||
playing_dialog = false
|
||||
playing_dialog_char_timer = 0.0
|
||||
emit_signal("ui_change")
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if playing_dialog:
|
||||
var foo = ''
|
||||
playing_dialog_char_timer += delta
|
||||
var char_count :int = floor(playing_dialog_char_timer * _dialog_item.chars_per_second )
|
||||
var text_line :String = _dialog_item.text_lines[current_dialog_index]
|
||||
if char_count <= text_line.length():
|
||||
dialog_text = text_line.substr(0, char_count )
|
||||
#emit_signal("ui_change")
|
||||
|
||||
##TODO: Lockout input on player before dialog happens.
|
||||
if Input.is_action_just_pressed("crouch_1"):
|
||||
if Input.is_action_just_pressed("ui_accept"):
|
||||
if _dialog_item.text_lines.size() > (current_dialog_index + 1):
|
||||
current_dialog_index += 1
|
||||
dialog_text = _dialog_item.text_lines[current_dialog_index]
|
||||
playing_dialog_char_timer = 0.0
|
||||
dialog_text = '' #_dialog_item.text_lines[current_dialog_index]
|
||||
dialog_portrait = _dialog_item.portrait
|
||||
emit_signal("ui_change")
|
||||
else:
|
||||
stop_dialog()
|
||||
#stop_dialog()
|
||||
call_deferred("stop_dialog")
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ func trigger_interaction():
|
|||
# UiManager.current_pane = UiManager.UI_PANES.DIALOG
|
||||
UiManager.play_dialog_item(dialog)
|
||||
|
||||
func disable_dialog():
|
||||
pass
|
||||
|
||||
func _on_Interactable_Component_body_exited(body):
|
||||
._on_Interactable_Component_body_exited(body)
|
||||
disable_dialog()
|
||||
#func disable_dialog():
|
||||
# pass
|
||||
#
|
||||
#func _on_Interactable_Component_body_exited(body):
|
||||
# ._on_Interactable_Component_body_exited(body)
|
||||
# disable_dialog()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ func wants_climb() -> bool:
|
|||
func process_physics_input(delta):
|
||||
# call the parent, Which would call the individuals
|
||||
.process_physics_input(delta)
|
||||
var foo_var = UiManager.current_pane
|
||||
# then process movement controls
|
||||
if UiManager.current_pane == UiManager.UI_PANES.HUD:
|
||||
get_movement_direction()
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ extends Resource
|
|||
|
||||
export(Texture) var portrait
|
||||
export(PoolStringArray) var text_lines
|
||||
export var chars_per_second :int = 30
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ func _ready():
|
|||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
$Debug.text = UiManager.debug_text
|
||||
DialogContainerText.text = UiManager.dialog_text
|
||||
|
||||
if (UiManager.current_pane != current_pane):
|
||||
print("UI Switch detected")
|
||||
current_pane = UiManager.current_pane
|
||||
|
|
@ -64,11 +66,12 @@ func _process(delta):
|
|||
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
|
||||
#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
|
||||
|
||||
func reset_current_pane_tracker():
|
||||
print("pane tracker signal received")
|
||||
current_pane = 0
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user