Bug fixed, Dialog UI improvements.

This commit is contained in:
Dustin 2025-06-17 22:39:52 -07:00
parent 25152de524
commit 6ed2e86806
6 changed files with 34 additions and 15 deletions

View File

@ -7,3 +7,4 @@
script = ExtResource( 1 ) script = ExtResource( 1 )
portrait = ExtResource( 2 ) portrait = ExtResource( 2 )
text_lines = PoolStringArray( "Hey there. I heard you\'re Gangsta.", "Well I\'m pretty gangsta myself!" ) text_lines = PoolStringArray( "Hey there. I heard you\'re Gangsta.", "Well I\'m pretty gangsta myself!" )
chars_per_second = 30

View File

@ -14,6 +14,7 @@ var debug_text :String
var _dialog_item :DialogItem var _dialog_item :DialogItem
var playing_dialog :bool = false var playing_dialog :bool = false
var playing_dialog_char_timer :float
var current_dialog_index :int var current_dialog_index :int
signal ui_change() 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: if _dialog_item.text_lines.size() > 0:
current_dialog_index = dialog_index current_dialog_index = dialog_index
playing_dialog = true 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 dialog_portrait = _dialog_item.portrait
current_pane = UI_PANES.DIALOG current_pane = UI_PANES.DIALOG
emit_signal("ui_change") emit_signal("ui_change")
@ -40,20 +42,31 @@ func play_dialog_item(dialog_item :DialogItem, dialog_index :int = 0):
func stop_dialog(): func stop_dialog():
dialog_text = 'foo' dialog_text = 'foo'
#call_deferred("set", dialog_text, 'foo')
current_pane = UI_PANES.HUD current_pane = UI_PANES.HUD
#call_deferred("set", current_pane, UI_PANES.HUD )
playing_dialog = false playing_dialog = false
playing_dialog_char_timer = 0.0
emit_signal("ui_change") emit_signal("ui_change")
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
if playing_dialog: 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. ##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): if _dialog_item.text_lines.size() > (current_dialog_index + 1):
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 dialog_portrait = _dialog_item.portrait
emit_signal("ui_change") emit_signal("ui_change")
else: else:
stop_dialog() #stop_dialog()
call_deferred("stop_dialog")

View File

@ -27,12 +27,12 @@ func trigger_interaction():
# UiManager.current_pane = UiManager.UI_PANES.DIALOG # UiManager.current_pane = UiManager.UI_PANES.DIALOG
UiManager.play_dialog_item(dialog) UiManager.play_dialog_item(dialog)
func disable_dialog(): #func disable_dialog():
pass # pass
#
func _on_Interactable_Component_body_exited(body): #func _on_Interactable_Component_body_exited(body):
._on_Interactable_Component_body_exited(body) # ._on_Interactable_Component_body_exited(body)
disable_dialog() # disable_dialog()
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta): #func _process(delta):

View File

@ -128,6 +128,7 @@ func wants_climb() -> bool:
func process_physics_input(delta): func process_physics_input(delta):
# call the parent, Which would call the individuals # call the parent, Which would call the individuals
.process_physics_input(delta) .process_physics_input(delta)
var foo_var = UiManager.current_pane
# then process movement controls # then process movement controls
if UiManager.current_pane == UiManager.UI_PANES.HUD: if UiManager.current_pane == UiManager.UI_PANES.HUD:
get_movement_direction() get_movement_direction()

View File

@ -7,6 +7,7 @@ extends Resource
export(Texture) var portrait export(Texture) var portrait
export(PoolStringArray) var text_lines export(PoolStringArray) var text_lines
export var chars_per_second :int = 30
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():

View File

@ -43,6 +43,8 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
$Debug.text = UiManager.debug_text $Debug.text = UiManager.debug_text
DialogContainerText.text = UiManager.dialog_text
if (UiManager.current_pane != current_pane): if (UiManager.current_pane != current_pane):
print("UI Switch detected") print("UI Switch detected")
current_pane = UiManager.current_pane current_pane = UiManager.current_pane
@ -64,11 +66,12 @@ func _process(delta):
print("UI Turned off") print("UI Turned off")
func _unhandled_input(event): #func _unhandled_input(event):
if current_pane == UiManager.UI_PANES.DIALOG and Input.is_action_just_pressed("ui_accept"): # if current_pane == UiManager.UI_PANES.DIALOG and Input.is_action_just_pressed("ui_accept"):
UiManager.current_pane = UiManager.UI_PANES.HUD # UiManager.current_pane = UiManager.UI_PANES.HUD
#get_tree().paused = false # #get_tree().paused = false
func reset_current_pane_tracker(): func reset_current_pane_tracker():
print("pane tracker signal received")
current_pane = 0 current_pane = 0