From cc887a288a1aaf655a6d90cbe1f1ab866c30c890 Mon Sep 17 00:00:00 2001 From: Edmundo Ruiz Ghanem Date: Sat, 28 Sep 2024 12:39:20 -0400 Subject: [PATCH 1/2] Flip the dialog portrait depending on the character looking dir --- .../components/dialog_text/dialog_portrait/dialog_portrait.gd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd b/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd index ed7bd4f2..f0ff7768 100644 --- a/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd +++ b/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd @@ -33,9 +33,11 @@ func _update_avatar(chr: PopochiuCharacter, _msg := '') -> void: if char_pos.x <= E.half_width: left_avatar_container.modulate.a = 1.0 left_avatar.texture = chr.get_avatar_for_emotion(chr.emotion) + left_avatar.flip_h = chr._looking_dir == PopochiuCharacter.Looking.LEFT else: right_avatar_container.modulate.a = 1.0 right_avatar.texture = chr.get_avatar_for_emotion(chr.emotion) + right_avatar.flip_h = chr._looking_dir == PopochiuCharacter.Looking.LEFT func _set_default_size() -> void: From 9508c5541bbe57dda470db0c8389a8db51e534b4 Mon Sep 17 00:00:00 2001 From: Edmundo Ruiz Ghanem Date: Sat, 28 Sep 2024 13:10:18 -0400 Subject: [PATCH 2/2] Update flip portrait avatar when looking down left or up left too --- .../dialog_text/dialog_portrait/dialog_portrait.gd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd b/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd index f0ff7768..829f2264 100644 --- a/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd +++ b/addons/popochiu/engine/objects/gui/components/dialog_text/dialog_portrait/dialog_portrait.gd @@ -5,6 +5,11 @@ extends PopochiuDialogText @onready var right_avatar_container: PanelContainer = %RightAvatarContainer @onready var right_avatar: TextureRect = %RightAvatar +const _LOOKING_LEFT_DIRS := [ + PopochiuCharacter.Looking.LEFT, + PopochiuCharacter.Looking.UP_LEFT, + PopochiuCharacter.Looking.DOWN_LEFT, + ] #region Godot ###################################################################################### func _ready() -> void: @@ -30,14 +35,16 @@ func _update_avatar(chr: PopochiuCharacter, _msg := '') -> void: E.scale if E.settings.scale_gui else Vector2.ONE ) + var flip_h := _LOOKING_LEFT_DIRS.has(chr._looking_dir) + if char_pos.x <= E.half_width: left_avatar_container.modulate.a = 1.0 left_avatar.texture = chr.get_avatar_for_emotion(chr.emotion) - left_avatar.flip_h = chr._looking_dir == PopochiuCharacter.Looking.LEFT + left_avatar.flip_h = flip_h else: right_avatar_container.modulate.a = 1.0 right_avatar.texture = chr.get_avatar_for_emotion(chr.emotion) - right_avatar.flip_h = chr._looking_dir == PopochiuCharacter.Looking.LEFT + right_avatar.flip_h = flip_h func _set_default_size() -> void: