Skip to content

Commit

Permalink
Fix default portrait animations and animation name regex (dialogic-go…
Browse files Browse the repository at this point in the history
…dot#2337)

Fixes the default animation names. 

Also makes sure that "Fade Up In" correctly identifies "Fade In Up" as the target animation.

---------

Co-authored-by: Jowan-Spooner <raban-loeffler@posteo.de>
  • Loading branch information
endaye and Jowan-Spooner authored Jul 11, 2024
1 parent f7976ee commit 067f5c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion addons/dialogic/Core/DialogicResourceUtil.gd
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static func guess_special_resource(type: String, string: String, default := {},
if not ignores.is_empty():
var regex := RegEx.create_from_string(r" ?\b(" + "|".join(ignores) + r")\b")
for name in resources:
if regex.sub(name, "") == string:
if regex.sub(name, "") == regex.sub(string, ""):
return resources[name]

## As a last effort check against the unfiltered list
Expand Down
12 changes: 3 additions & 9 deletions addons/dialogic/Modules/Character/settings_portraits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,19 @@ func _refresh():

# JOIN
%JoinDefault.resource_icon = get_theme_icon(&"Animation", &"EditorIcons")
%JoinDefault.set_value(DialogicUtil.pretty_name(
ProjectSettings.get_setting(ANIMATION_JOIN_DEFAULT_KEY,
get_script().resource_path.get_base_dir().path_join('DefaultAnimations/fade_in_up.gd'))))
%JoinDefault.set_value(ProjectSettings.get_setting(ANIMATION_JOIN_DEFAULT_KEY, "Fade In Up"))
%JoinDefaultLength.set_value(ProjectSettings.get_setting(ANIMATION_JOIN_DEFAULT_LENGTH_KEY, 0.5))
%JoinDefaultWait.button_pressed = ProjectSettings.get_setting(ANIMATION_JOIN_DEFAULT_WAIT_KEY, true)

# LEAVE
%LeaveDefault.resource_icon = get_theme_icon(&"Animation", &"EditorIcons")
%LeaveDefault.set_value(
ProjectSettings.get_setting(ANIMATION_LEAVE_DEFAULT_KEY,
get_script().resource_path.get_base_dir().path_join('DefaultAnimations/fade_out_down.gd')))
%LeaveDefault.set_value(ProjectSettings.get_setting(ANIMATION_LEAVE_DEFAULT_KEY, "Fade Out Down"))
%LeaveDefaultLength.set_value(ProjectSettings.get_setting(ANIMATION_LEAVE_DEFAULT_LENGTH_KEY, 0.5))
%LeaveDefaultWait.button_pressed = ProjectSettings.get_setting(ANIMATION_LEAVE_DEFAULT_WAIT_KEY, true)

# CROSS FADE
%CrossFadeDefault.resource_icon = get_theme_icon(&"Animation", &"EditorIcons")
%CrossFadeDefault.set_value(
ProjectSettings.get_setting(ANIMATION_CROSSFADE_DEFAULT_KEY,
get_script().resource_path.get_base_dir().path_join('DefaultAnimations/fade_in.gd')))
%CrossFadeDefault.set_value(ProjectSettings.get_setting(ANIMATION_CROSSFADE_DEFAULT_KEY, "Fade Cross"))
%CrossFadeDefaultLength.set_value(ProjectSettings.get_setting(ANIMATION_CROSSFADE_DEFAULT_LENGTH_KEY, 0.5))


Expand Down
12 changes: 6 additions & 6 deletions addons/dialogic/Modules/Character/subsystem_portraits.gd
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ func join_character(character:DialogicCharacter, portrait:String, position_id:S
character_joined.emit(info)

if animation_name.is_empty():
animation_name = ProjectSettings.get_setting('dialogic/animations/join_default', "Fade Up In")
animation_name = ProjectSettings.get_setting('dialogic/animations/join_default', "Fade In Up")
animation_length = _get_join_default_length()
animation_wait = ProjectSettings.get_setting('dialogic/animations/join_default_wait', true)

Expand Down Expand Up @@ -450,7 +450,7 @@ func change_character_portrait(character: DialogicCharacter, portrait: String, f
return

if fade_animation == "DEFAULT":
fade_animation = ProjectSettings.get_setting('dialogic/animations/cross_fade_default', "Fade In Out")
fade_animation = ProjectSettings.get_setting('dialogic/animations/cross_fade_default', "Fade Cross")
fade_length = ProjectSettings.get_setting('dialogic/animations/cross_fade_default_length', 0.5)

fade_animation = DialogicPortraitAnimationUtil.guess_animation(fade_animation, DialogicPortraitAnimationUtil.AnimationType.CROSSFADE)
Expand Down Expand Up @@ -522,7 +522,7 @@ func leave_character(character: DialogicCharacter, animation_name:= "", animatio
return

if animation_name.is_empty():
animation_name = ProjectSettings.get_setting('dialogic/animations/leave_default', "Fade Down Out")
animation_name = ProjectSettings.get_setting('dialogic/animations/leave_default', "Fade Out Down")
animation_length = _get_leave_default_length()
animation_wait = ProjectSettings.get_setting('dialogic/animations/leave_default_wait', true)

Expand Down Expand Up @@ -622,7 +622,7 @@ func change_speaker(speaker: DialogicCharacter = null, portrait := "") -> void:
var just_joined := true
for character_node: Node in container.get_children():
if not character_node.get_meta('character') == speaker:
var leave_animation: String = ProjectSettings.get_setting('dialogic/animations/leave_default', "Fade Up Out")
var leave_animation: String = ProjectSettings.get_setting('dialogic/animations/leave_default', "Fade Out")
leave_animation = DialogicPortraitAnimationUtil.guess_animation(leave_animation, DialogicPortraitAnimationUtil.AnimationType.OUT)
var leave_animation_length := _get_leave_default_length()

Expand All @@ -646,7 +646,7 @@ func change_speaker(speaker: DialogicCharacter = null, portrait := "") -> void:

if portrait.is_empty(): portrait = speaker.default_portrait

var fade_animation: String = ProjectSettings.get_setting('dialogic/animations/cross_fade_default', "Fade In Out")
var fade_animation: String = ProjectSettings.get_setting('dialogic/animations/cross_fade_default', "Fade Cross")
var fade_length: float = ProjectSettings.get_setting('dialogic/animations/cross_fade_default_length', 0.5)

fade_animation = DialogicPortraitAnimationUtil.guess_animation(fade_animation, DialogicPortraitAnimationUtil.AnimationType.CROSSFADE)
Expand All @@ -661,7 +661,7 @@ func change_speaker(speaker: DialogicCharacter = null, portrait := "") -> void:
continue

if just_joined:
var join_animation: String = ProjectSettings.get_setting('dialogic/animations/join_default', "Fade Up In")
var join_animation: String = ProjectSettings.get_setting('dialogic/animations/join_default', "Fade In Up")
join_animation = DialogicPortraitAnimationUtil.guess_animation(join_animation, DialogicPortraitAnimationUtil.AnimationType.IN)
var join_animation_length := _get_join_default_length()

Expand Down

0 comments on commit 067f5c0

Please sign in to comment.