Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Flip dialog portrait avatar based on character direction #298

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ extends PopochiuDialogText
@onready var right_avatar_container: PanelContainer = %RightAvatarContainer
@onready var right_avatar: TextureRect = %RightAvatar

const _LOOKING_LEFT_DIRS := [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following Godot's style guide, constants should be defined without underscore on the first character.

Suggested change
const _LOOKING_LEFT_DIRS := [
const LOOKING_LEFT_DIRS := [

PopochiuCharacter.Looking.LEFT,
PopochiuCharacter.Looking.UP_LEFT,
PopochiuCharacter.Looking.DOWN_LEFT,
]

#region Godot ######################################################################################
func _ready() -> void:
Expand All @@ -30,12 +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)
Copy link
Contributor Author

@edmundito edmundito Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like _looking_dir is being misused publically in other singletons should either be a getter/setter or a public variable.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I guess that's very legacy code that nobody touched in a while. Nice spot!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @edmundito . We can make that property public (by removing the underscore at the beggining) or use getter/setter methods. I prefer the first option.

Changing that will also affect the i_room.gd and the popochiu_room_data.gd scripts. And this line of code, of course.


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 = flip_h
else:
right_avatar_container.modulate.a = 1.0
right_avatar.texture = chr.get_avatar_for_emotion(chr.emotion)
right_avatar.flip_h = flip_h


func _set_default_size() -> void:
Expand Down